2424 triangle_face_normal ,
2525)
2626
27- from .raycaster import ensure_solver_bvhs , update_solver_bvhs
27+ from .raycaster import RaycastContext
2828
2929from .base_sensor import RigidSensorMetadataMixin , RigidSensorMixin , SimpleSensor , SimpleSensorMetadata
3030from .probe import (
@@ -914,12 +914,13 @@ def build(self):
914914 # SDF activation is the default fallback; the idempotent call keeps it active even in mixed-mode scenes.
915915 self ._shared_metadata .solver .collider .activate_sdf ()
916916
917- # Last-value-wins propagation of contact_depth_query. Build the shared collision BVH lazily on raycast opt-in.
917+ # Last-value-wins propagation of contact_depth_query. In raycast mode, activate the shared RaycastContext so it
918+ # builds its BVH (only on raycast opt-in); SDF-mode scenes never pay for it.
918919 mode = self ._options .contact_depth_query
919920 if mode is not None :
920921 self ._shared_metadata .contact_depth_query = mode
921922 if self ._shared_metadata .contact_depth_query == "raycast" :
922- self ._shared_metadata . collision_bvh = ensure_solver_bvhs ( self . _manager . _sim )
923+ self ._shared_context . activate ( )
923924
924925
925926@dataclass
@@ -939,7 +940,7 @@ class ContactDepthProbeSensor(
939940 KinematicTactileSensorMixin [ContactDepthProbeMetadata ],
940941 ProbesWithNormalSensorMixin [ContactDepthProbeMetadata ],
941942 RigidSensorMixin [ContactDepthProbeMetadata ],
942- SimpleSensor [ContactDepthProbeOptions , None , ContactDepthProbeMetadata , tuple ],
943+ SimpleSensor [ContactDepthProbeOptions , RaycastContext , ContactDepthProbeMetadata , tuple ],
943944):
944945 """
945946 Returns contact depth in meters per probe.
@@ -965,7 +966,7 @@ def _get_cache_dtype(cls) -> torch.dtype:
965966 @classmethod
966967 def _update_current_timestep_data (
967968 cls ,
968- shared_context : None ,
969+ shared_context : RaycastContext ,
969970 shared_metadata : ContactDepthProbeMetadata ,
970971 current_ground_truth_data_T : torch .Tensor ,
971972 ground_truth_data_timeline : "TensorRingBuffer | None" ,
@@ -1013,8 +1014,7 @@ def _update_current_timestep_data(
10131014 solver .collider ._collider_state ,
10141015 shared_metadata .sensor_candidate_geom_mask ,
10151016 )
1016- update_solver_bvhs (shared_metadata .collision_bvh )
1017- rigid_entry = next (e for e in shared_metadata .collision_bvh if e .raycast_mask is None )
1017+ rigid_entry = next (e for e in shared_context .bvh_contexts if e .raycast_mask is None )
10181018 _kernel_contact_depth_probe_bvh (
10191019 shared_metadata .probe_positions ,
10201020 shared_metadata .probe_local_normal ,
@@ -1059,7 +1059,9 @@ class ContactProbeMetadata(ContactDepthProbeMetadata):
10591059 release_threshold_row : torch .Tensor = make_tensor_field ((0 ,))
10601060
10611061
1062- class ContactProbeSensor (ContactDepthProbeSensor , SimpleSensor [ContactProbeOptions , None , ContactProbeMetadata , tuple ]):
1062+ class ContactProbeSensor (
1063+ ContactDepthProbeSensor , SimpleSensor [ContactProbeOptions , RaycastContext , ContactProbeMetadata , tuple ]
1064+ ):
10631065 """
10641066 Returns boolean contact per probe with optional Schmitt-trigger hysteresis. Shares the depth-probe kernel.
10651067
@@ -1321,7 +1323,7 @@ class KinematicTaxelSensor(
13211323 KinematicTactileSensorMixin [KinematicTaxelMetadata ],
13221324 ProbesWithNormalSensorMixin [KinematicTaxelMetadata ],
13231325 RigidSensorMixin [KinematicTaxelMetadata ],
1324- SimpleSensor [KinematicTaxelOptions , None , KinematicTaxelMetadata , KinematicTaxelReturnType ],
1326+ SimpleSensor [KinematicTaxelOptions , RaycastContext , KinematicTaxelMetadata , KinematicTaxelReturnType ],
13251327):
13261328 """Kinematic taxels: spring-damper force and torque per probe from contact geometry and relative motion."""
13271329
@@ -1409,7 +1411,7 @@ def _get_cache_dtype(cls) -> torch.dtype:
14091411 @classmethod
14101412 def _update_current_timestep_data (
14111413 cls ,
1412- shared_context : None ,
1414+ shared_context : RaycastContext ,
14131415 shared_metadata : KinematicTaxelMetadata ,
14141416 current_ground_truth_data_T : torch .Tensor ,
14151417 ground_truth_data_timeline : "TensorRingBuffer | None" ,
@@ -1472,8 +1474,7 @@ def _update_current_timestep_data(
14721474 solver .collider ._collider_state ,
14731475 shared_metadata .sensor_candidate_geom_mask ,
14741476 )
1475- update_solver_bvhs (shared_metadata .collision_bvh )
1476- rigid_entry = next (e for e in shared_metadata .collision_bvh if e .raycast_mask is None )
1477+ rigid_entry = next (e for e in shared_context .bvh_contexts if e .raycast_mask is None )
14771478 _kernel_kinematic_taxel_bvh (
14781479 shared_metadata .probe_positions ,
14791480 shared_metadata .probe_local_normal ,
0 commit comments