MCPcopy
hub / github.com/g3n/engine / BoundingBox

Method BoundingBox

geometry/geometry.go:314–332  ·  view source on GitHub ↗

BoundingBox computes the bounding box of the geometry if necessary and returns is value.

()

Source from the content-addressed store, hash-verified

312// BoundingBox computes the bounding box of the geometry if necessary
313// and returns is value.
314func (g *Geometry) BoundingBox() math32.Box3 {
315
316 // If valid, return its value
317 if g.boundingBoxValid {
318 return g.boundingBox
319 }
320
321 // Reset bounding box
322 g.boundingBox.Min.Set(math.MaxFloat32, math.MaxFloat32, math.MaxFloat32)
323 g.boundingBox.Max.Set(-math.MaxFloat32, -math.MaxFloat32, -math.MaxFloat32)
324
325 // Expand bounding box by each vertex
326 g.ReadVertices(func(vertex math32.Vector3) bool {
327 g.boundingBox.ExpandByPoint(&vertex)
328 return false
329 })
330 g.boundingBoxValid = true
331 return g.boundingBox
332}
333
334// BoundingSphere computes the bounding sphere of this geometry
335// if necessary and returns its value.

Callers 2

BoundingSphereMethod · 0.95
RotationalInertiaMethod · 0.95

Calls 3

ReadVerticesMethod · 0.95
SetMethod · 0.45
ExpandByPointMethod · 0.45

Tested by

no test coverage detected