// Gets the furthest point from the origin in this geometry func (geometry *Geometry) MaximalPointFromGeometry() mgl32.Vec3 { var longestSq float32 var longest *mgl32.Vec3 for i := 0; i < len(geometry.Indicies); i = i + 1 { index := geometry.Indicies[i] v := mgl32.Vec3{ geometry.Verticies[index*VertexStride], geometry.Verticies[index*VertexStride+1], geometry.Verticies[index*VertexStride+2], } if longest == nil || util.Vec3LenSq(v) > longestSq { longestSq = util.Vec3LenSq(v) longest = &v } } if longest != nil { return *longest } return mgl32.Vec3{} }
// Converts a geometry directly into points (does threshold culling optimisation) func PointsFromGeometry(geometry *renderer.Geometry, cullThreshold float32) *[]mgl32.Vec3 { verticies := make([]mgl32.Vec3, 0, len(geometry.Indicies)) for i := 0; i < len(geometry.Indicies); i = i + 1 { index := geometry.Indicies[i] v := mgl32.Vec3{ geometry.Verticies[index*renderer.VertexStride], geometry.Verticies[index*renderer.VertexStride+1], geometry.Verticies[index*renderer.VertexStride+2], } //do culling include := true for _, vert := range verticies { if util.Vec3LenSq(vert.Sub(v)) < cullThreshold*cullThreshold { include = false break } } if include { verticies = append(verticies, v) } } return &verticies }