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

Method ReadFaces

geometry/geometry.go:275–302  ·  view source on GitHub ↗

ReadFaces iterates over all the vertices and calls the specified callback function with face-forming vertex triples. The callback function returns false to continue or true to break.

(cb func(vA, vB, vC math32.Vector3) bool)

Source from the content-addressed store, hash-verified

273// the specified callback function with face-forming vertex triples.
274// The callback function returns false to continue or true to break.
275func (g *Geometry) ReadFaces(cb func(vA, vB, vC math32.Vector3) bool) {
276
277 // Get buffer with position vertices
278 vbo := g.VBO(gls.VertexPosition)
279 if vbo == nil {
280 return
281 }
282
283 // If geometry has indexed vertices need to loop over indexes
284 if g.Indexed() {
285 var vA, vB, vC math32.Vector3
286 positions := vbo.Buffer()
287 for i := 0; i < g.indices.Size(); i += 3 {
288 // Get face vertices
289 positions.GetVector3(int(3*g.indices[i]), &vA)
290 positions.GetVector3(int(3*g.indices[i+1]), &vB)
291 positions.GetVector3(int(3*g.indices[i+2]), &vC)
292 // Call callback with face vertices
293 brk := cb(vA, vB, vC)
294 if brk {
295 break
296 }
297 }
298 } else {
299 // Geometry does NOT have indexed vertices - can read vertices in sequence
300 vbo.ReadTripleVectors3(gls.VertexPosition, cb)
301 }
302}
303
304// TODO Read and Operate on Texcoords, Faces, Edges, FaceNormals, etc...
305

Callers 4

AreaMethod · 0.95
VolumeMethod · 0.95
RaycastMeshMethod · 0.80

Calls 6

VBOMethod · 0.95
IndexedMethod · 0.95
BufferMethod · 0.80
GetVector3Method · 0.80
ReadTripleVectors3Method · 0.80
SizeMethod · 0.45

Tested by

no test coverage detected