Skip to content

Commit

Permalink
Merge pull request #30 from diogocravo/master
Browse files Browse the repository at this point in the history
fix production spec path used in bounding box computation
  • Loading branch information
thiagomourahp authored Apr 5, 2022
2 parents 6c1074b + 227a523 commit 6760bcd
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (m *Model) BoundingBox() Box {
defer wg.Done()
item := m.Build.Items[i]
if o, ok := m.FindObject(item.ObjectPath(), item.ObjectID); ok {
ibox := o.boundingBox(m, "")
ibox := o.boundingBox(m, item.ObjectPath())
if ibox != emptyBox {
mu.Lock()
box = box.extend(item.Transform.MulBox(ibox))
Expand Down
50 changes: 50 additions & 0 deletions core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,56 @@ func TestModel_BoundingBox(t *testing.T) {
}}},
}},
}, Box{Min: Point3D{10, 20, 30}, Max: Point3D{110, 120, 130}}},
{"non-root-model", &Model{
Build: Build{Items: []*Item{
{ObjectID: 2, Transform: Identity(), AnyAttr: spec.AnyAttr{&fakeAttr{Value: "/other.model"}}},
}},
Resources: Resources{},
Childs: map[string]*ChildModel{
"/other.model": &ChildModel{
Resources: Resources{Objects: []*Object{
{ID: 1, Mesh: &Mesh{Vertices: Vertices{Vertex: []Point3D{
{0, 10, 20},
{100, 110, 120},
}}}},
{ID: 2, Components: &Components{Component: []*Component{
{ObjectID: 1, Transform: Identity().Translate(10, 10, 10)},
{ObjectID: 10},
}}},
}},
},
},
}, Box{Min: Point3D{10, 20, 30}, Max: Point3D{110, 120, 130}}},
{"model-tree", &Model{
Build: Build{Items: []*Item{
{ObjectID: 2, Transform: Identity(), AnyAttr: spec.AnyAttr{&fakeAttr{Value: "/other.model"}}},
}},
Resources: Resources{},
Childs: map[string]*ChildModel{
"/leaf.model": &ChildModel{
Resources: Resources{Objects: []*Object{
{ID: 1, Mesh: &Mesh{Vertices: Vertices{Vertex: []Point3D{
{0, 10, 20},
{100, 110, 120},
}}}},
}},
},
"/another.model": &ChildModel{
Resources: Resources{Objects: []*Object{
{ID: 2, Components: &Components{Component: []*Component{
{ObjectID: 1, Transform: Identity().Translate(7, 7, 7), AnyAttr: spec.AnyAttr{&fakeAttr{Value: "/leaf.model"}}},
}}},
}},
},
"/other.model": &ChildModel{
Resources: Resources{Objects: []*Object{
{ID: 2, Components: &Components{Component: []*Component{
{ObjectID: 2, Transform: Identity().Translate(3, 3, 3), AnyAttr: spec.AnyAttr{&fakeAttr{Value: "/another.model"}}},
}}},
}},
},
},
}, Box{Min: Point3D{10, 20, 30}, Max: Point3D{110, 120, 130}}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 6760bcd

Please sign in to comment.