Skip to content

Commit fc0b314

Browse files
committed
Expose mouse-spring tau/damp as global constants
1 parent b6cff33 commit fc0b314

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

genesis/ext/pyrender/interaction/mouse_spring.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
from genesis.engine.entities.rigid_entity.rigid_link import RigidLink
99

10+
MOUSE_SPRING_POSITION_CORRECTION_FACTOR = 1.0 / 2
11+
MOUSE_SPRING_VELOCITY_CORRECTION_FACTOR = 1.0 * 2
12+
1013
def _ensure_torch_imported() -> None:
1114
global torch
1215
import torch
@@ -50,8 +53,8 @@ def apply_force(self, control_point: Vec3, delta_time: float):
5053
inv_dt: float = 1.0 / delta_time
5154
# these are temporary values, till we fix an issue with apply_links_external_force.
5255
# after fixing it, use tau = damp = 1.0:
53-
tau: float = 1.0 / 2
54-
damp: float = 1.0 * 2
56+
tau: float = MOUSE_SPRING_POSITION_CORRECTION_FACTOR
57+
damp: float = MOUSE_SPRING_VELOCITY_CORRECTION_FACTOR
5558

5659
total_impulse: Vec3 = Vec3.zero()
5760

@@ -67,6 +70,7 @@ def apply_force(self, control_point: Vec3, delta_time: float):
6770
lin_vel += imp * dir * inv_mass
6871
total_impulse.v[i] = imp
6972

73+
# Apply the new force
7074
total_force = total_impulse * inv_dt
7175
force_tensor: torch.Tensor = total_force.as_tensor().unsqueeze(0)
7276
link.solver.apply_links_external_force(force_tensor, (link.idx,), ref='link_com', local=False)

0 commit comments

Comments
 (0)