-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
group.go
42 lines (36 loc) · 982 Bytes
/
group.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2022 Cogent Core. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package vshape
import "cogentcore.org/core/mat32"
// ShapeGroup is a group of shapes -- returns summary data for shape elements
type ShapeGroup struct {
ShapeBase
// list of shapes in group
Shapes []Shape
}
// N returns number of vertex, index points in this shape element.
func (sb *ShapeGroup) N() (nVtx, nIdx int) {
nVtx = 0
nIdx = 0
for _, sh := range sb.Shapes {
nv, ni := sh.N()
nVtx += nv
nIdx += ni
}
return
}
// Set sets points in given allocated arrays, also updates offsets
func (sb *ShapeGroup) Set(vtxAry, normAry, texAry mat32.ArrayF32, idxAry mat32.ArrayU32) {
vo := sb.VtxOff
io := sb.IdxOff
sb.CBBox.SetEmpty()
for _, sh := range sb.Shapes {
sh.SetOffs(vo, io)
sh.Set(vtxAry, normAry, texAry, idxAry)
sb.CBBox.ExpandByBox(sh.BBox())
nv, ni := sh.N()
vo += nv
io += ni
}
}