Skip to content

Commit

Permalink
Bugfix: Floor missing, wrong bounding boxes (#250)
Browse files Browse the repository at this point in the history
* Recalculate AABB

* Don't recalculate if there are no vertices
  • Loading branch information
vegasten authored Nov 5, 2024
1 parent 20139b7 commit 0a82343
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions CadRevealRvmProvider/Tessellation/RvmTessellator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ TessellationLogObject tessellationLogObject
tessellationLogObject
);

return new TriangleMesh(mesh, p.TreeIndex, p.Color, p.AxisAlignedBoundingBox);
var boundingBox = p.AxisAlignedBoundingBox;
if (mesh.Vertices.Length > 0)
{
// Recalculating AABB, since some instances of the transformed (p.AxisAlignedBoundingBox) AABB were incorrect
// Guarded agaings meshes with zero vertices, to avoid throwing an exception
boundingBox = mesh.CalculateAxisAlignedBoundingBox();
}

return new TriangleMesh(mesh, p.TreeIndex, p.Color, boundingBox);
}

var facetGroupsNotInstanced = facetGroupInstancingResult
Expand Down Expand Up @@ -109,7 +117,7 @@ TessellationLogObject tessellationLogObject
item.Transform,
item.ProtoMesh.TreeIndex,
item.ProtoMesh.Color,
item.ProtoMesh.AxisAlignedBoundingBox
group.Mesh.CalculateAxisAlignedBoundingBox(item.Transform) // Recalculating AABB, since some instances of the transformed (item.ProtoMesh.AxisAlignedBoundingBox) AABB were incorrect
))
)
.ToArray();
Expand Down

0 comments on commit 0a82343

Please sign in to comment.