Hi, I’m grabbing aabb bounding boxes of two prims like this:
cache = UsdGeom.BBoxCache(Usd.TimeCode.Default(), [‘default’, ‘render’])
bb_box = cache.ComputeWorldBound(self.prim_box)
bb_range_box = bb_box.ComputeAlignedBox() # of type Gf.Range3d(Gf.Vec3d(...), Gf.Vec3d())
bb_trigger = cache.ComputeWorldBound(self.prim_sorter_trigger)
bb_range_trigger = bb_trigger.ComputeAlignedBox() # of type Gf.Range3d(Gf.Vec3d(...), Gf.Vec3d())
I want to check if these two bounding boxes are 1. completely inside each other and 2. completely outside each other.
I wonder if there are some library functions that can perform these checks?
I am not aware of any direct usd function offering this, it should however be relatively straight forward to write such a helper function using python 3d math:
def check_bounding_boxes(box1, box2):
# Assuming box1 and box2 are defined as tuples of min and max Gf.Vec3d: ((min_x, min_y, min_z), (max_x, max_y, max_z))
# Completely inside check
completely_inside = all(box1[0][i] >= box2[0][i] and box1[1][i] <= box2[1][i] for i in range(3))
# Completely outside check (simplified version for illustration)
completely_outside = any(box1[1][i] < box2[0][i] or box1[0][i] > box2[1][i] for i in range(3))
return completely_inside, completely_outside