diff --git a/com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBox3DLabeler.cs b/com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBox3DLabeler.cs index a5bd86cea..6b78b8117 100644 --- a/com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBox3DLabeler.cs +++ b/com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBox3DLabeler.cs @@ -248,6 +248,9 @@ void ProcessLabel(Labeling labeledEntity) // Need to convert all bounds into labeling mesh space... foreach (var mesh in meshFilters) { + if (!mesh.GetComponent().enabled) + continue; + var currentTransform = mesh.gameObject.transform; // Grab the bounds of the game object from the mesh, although these bounds are axis-aligned, // they are axis-aligned with respect to the current component's coordinate space. This, in theory @@ -260,6 +263,8 @@ void ProcessLabel(Labeling labeledEntity) // Apply the transformations on this object until we reach the labeled transform while (currentTransform != labelTransform) { + transformedBounds.center = Vector3.Scale(transformedBounds.center, currentTransform.localScale); + transformedBounds.center = currentTransform.localRotation * transformedBounds.center; transformedBounds.center += currentTransform.localPosition; transformedBounds.extents = Vector3.Scale(transformedBounds.extents, currentTransform.localScale); transformedRotation *= currentTransform.localRotation; @@ -287,7 +292,7 @@ void ProcessLabel(Labeling labeledEntity) // Convert the combined bounds into world space combinedBounds.center = labelTransform.TransformPoint(combinedBounds.center); - combinedBounds.extents = Vector3.Scale(combinedBounds.extents, labelTransform.localScale); + combinedBounds.extents = Vector3.Scale(combinedBounds.extents, labelTransform.lossyScale); // Now convert all points into camera's space var cameraCenter = cameraTransform.InverseTransformPoint(combinedBounds.center);