Skip to content

Commit 6760bcd

Browse files
Merge pull request #30 from diogocravo/master
fix production spec path used in bounding box computation
2 parents 6c1074b + 227a523 commit 6760bcd

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

core.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func (m *Model) BoundingBox() Box {
247247
defer wg.Done()
248248
item := m.Build.Items[i]
249249
if o, ok := m.FindObject(item.ObjectPath(), item.ObjectID); ok {
250-
ibox := o.boundingBox(m, "")
250+
ibox := o.boundingBox(m, item.ObjectPath())
251251
if ibox != emptyBox {
252252
mu.Lock()
253253
box = box.extend(item.Transform.MulBox(ibox))

core_test.go

+50
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,56 @@ func TestModel_BoundingBox(t *testing.T) {
476476
}}},
477477
}},
478478
}, Box{Min: Point3D{10, 20, 30}, Max: Point3D{110, 120, 130}}},
479+
{"non-root-model", &Model{
480+
Build: Build{Items: []*Item{
481+
{ObjectID: 2, Transform: Identity(), AnyAttr: spec.AnyAttr{&fakeAttr{Value: "/other.model"}}},
482+
}},
483+
Resources: Resources{},
484+
Childs: map[string]*ChildModel{
485+
"/other.model": &ChildModel{
486+
Resources: Resources{Objects: []*Object{
487+
{ID: 1, Mesh: &Mesh{Vertices: Vertices{Vertex: []Point3D{
488+
{0, 10, 20},
489+
{100, 110, 120},
490+
}}}},
491+
{ID: 2, Components: &Components{Component: []*Component{
492+
{ObjectID: 1, Transform: Identity().Translate(10, 10, 10)},
493+
{ObjectID: 10},
494+
}}},
495+
}},
496+
},
497+
},
498+
}, Box{Min: Point3D{10, 20, 30}, Max: Point3D{110, 120, 130}}},
499+
{"model-tree", &Model{
500+
Build: Build{Items: []*Item{
501+
{ObjectID: 2, Transform: Identity(), AnyAttr: spec.AnyAttr{&fakeAttr{Value: "/other.model"}}},
502+
}},
503+
Resources: Resources{},
504+
Childs: map[string]*ChildModel{
505+
"/leaf.model": &ChildModel{
506+
Resources: Resources{Objects: []*Object{
507+
{ID: 1, Mesh: &Mesh{Vertices: Vertices{Vertex: []Point3D{
508+
{0, 10, 20},
509+
{100, 110, 120},
510+
}}}},
511+
}},
512+
},
513+
"/another.model": &ChildModel{
514+
Resources: Resources{Objects: []*Object{
515+
{ID: 2, Components: &Components{Component: []*Component{
516+
{ObjectID: 1, Transform: Identity().Translate(7, 7, 7), AnyAttr: spec.AnyAttr{&fakeAttr{Value: "/leaf.model"}}},
517+
}}},
518+
}},
519+
},
520+
"/other.model": &ChildModel{
521+
Resources: Resources{Objects: []*Object{
522+
{ID: 2, Components: &Components{Component: []*Component{
523+
{ObjectID: 2, Transform: Identity().Translate(3, 3, 3), AnyAttr: spec.AnyAttr{&fakeAttr{Value: "/another.model"}}},
524+
}}},
525+
}},
526+
},
527+
},
528+
}, Box{Min: Point3D{10, 20, 30}, Max: Point3D{110, 120, 130}}},
479529
}
480530
for _, tt := range tests {
481531
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)