perf(simulation): push current previews and streamline native sensor startup

This commit is contained in:
DCCONSTRUCTIONS
2026-10-09 10:09:59 +03:00
parent c4d4ea4cf8
commit 5e2e0aa4d7
18 changed files with 395 additions and 74 deletions
+9 -4
View File
@@ -188,7 +188,9 @@ class MountedSensors:
class MountedRange:
def __init__(self, rig, contact_height):
from terrain import RangeSensor
from carb import Float3
self.query_vector = lambda xyz: Float3(*xyz)
legacy = RangeSensor()
self.query = legacy.query
self.mounts, self.contact_height = rig["mounts"], contact_height
@@ -244,7 +246,7 @@ class MountedRange:
origins.append(origin)
observed, clear, depth, paths = mounted_range_returns(
self.query, origin, rays @ rotation, key, self.mounts[key], self.rs_rays[:, 0],
organized_ranges=view_ranges,
organized_ranges=view_ranges, query_vector=self.query_vector,
)
points.extend(observed)
ends.extend(clear)
@@ -268,7 +270,8 @@ class MountedRange:
return np.asarray(points, np.float32).reshape(-1, 3)
def mounted_range_returns(query, origin, directions, key, spec, forward, *, organized_ranges=None):
def mounted_range_returns(query, origin, directions, key, spec, forward, *,
organized_ranges=None, query_vector=tuple):
"""Same first-hit rays, with range filtering outside the Python query loop.
Keep per-beam ownership and order. A self hit never becomes a no-return
@@ -277,14 +280,16 @@ def mounted_range_returns(query, origin, directions, key, spec, forward, *, orga
"""
count = len(directions)
maximum = np.full(count, 8.0) if key == "k1" else np.minimum(8.0, 6.0 / forward)
mount = tuple(origin)
# PhysX consumes Float3 internally. Native callers avoid repeated pybind
# sequence conversion; portable checks can use the identical tuple contract.
mount = query_vector(origin)
positions = np.full((count, 3), np.nan)
no_hit = np.zeros(count, dtype=bool)
paths = [None] * count
for row, (direction, limit) in enumerate(
zip(directions.tolist(), maximum.tolist(), strict=True)
):
hit = query.raycast_closest(mount, tuple(direction), limit, bothSides=True)
hit = query.raycast_closest(mount, query_vector(direction), limit, bothSides=True)
if not hit["hit"]:
no_hit[row] = True
elif not (