Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ on:
- main
pull_request:

# Pin: 0.841.0, the latest release, and aeb v0.333. The move from 0.839.0
# is evidence-based, not a tracking bump: 0.840.0 and 0.841.0 add the
# ownership rules (0.840: a borrowed ptr put into a list or map is
# E0902 without @keep) and E0202 / E0305, and every module, test,
# benchmark and example checks clean on them with no source change, the
# golden trace bit for bit. aeb v0.333 is the one whose @keep session
# handle the family moved to together. The two functions that take over a
# Pin: 0.919.0, the latest release, and aeb v0.347, the one ae3d builds
# beside. Every module, test, benchmark and example checks clean on
# 0.919.0 with no source change from 0.841.0, the golden trace bit for
# bit. 0.840.0 and 0.841.0 added the ownership rules (a borrowed ptr put
# into a list or map is E0902 without @keep) and E0202 / E0305. The two functions that take over a
# struct's buffers declare it `@keep`, which 0.838.0 checks; the
# accessors that hand back a pointer into their argument declare it
# `@into` (aether#2990), which 0.836.0 checks; the lane moves
Expand All @@ -22,8 +20,8 @@ on:
# bootstrap version: the floor this code needs, verified by every job
# below.
env:
AE_PIN: 0.841.0
AEB_REF: v0.333
AE_PIN: 0.919.0
AEB_REF: v0.347

jobs:
test:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Install Aether with the version-pinned installer (it puts `ae` and `aeb` in

```sh
curl -fsSL https://raw.githubusercontent.com/aether-lang-dev/aeb/main/get.sh \
| AE_PIN=0.841.0 AEB_REF=v0.333 sh
| AE_PIN=0.919.0 AEB_REF=v0.347 sh
export PATH="$HOME/.local/bin:$PATH"
```

Expand Down Expand Up @@ -180,7 +180,7 @@ scripts/profile.sh file.ae # a sampling profile on Windows
```

CI runs the suite on Linux, on Linux with AVX2 and FMA, on macOS arm64, and
on Windows at `-O3` and `-O0`. It pins one Aether release, 0.841.0; older
on Windows at `-O3` and `-O0`. It pins one Aether release, 0.919.0; older
ones are not tested.

## Credits
Expand Down
56 changes: 43 additions & 13 deletions aephysics/dynamics/module.ae

Large diffs are not rendered by default.

616 changes: 530 additions & 86 deletions aephysics/human/module.ae

Large diffs are not rendered by default.

58 changes: 55 additions & 3 deletions aephysics/joint_solver/module.ae
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ exports (
revolute_joint_get_max_motor_torque, revolute_joint_get_motor_torque,
spherical_joint_enable_cone_limit, spherical_joint_is_cone_limit_enabled, spherical_joint_get_cone_limit, spherical_joint_set_cone_limit,
spherical_joint_get_cone_angle, spherical_joint_set_cone_axis, spherical_joint_get_cone_axis,
spherical_joint_set_cone_ellipse, spherical_joint_get_cone_minor_angle, spherical_joint_get_cone_major_axis, spherical_joint_enable_twist_limit, spherical_joint_is_twist_limit_enabled,
spherical_joint_set_cone_ellipse, spherical_joint_lock_cone_minor, spherical_joint_is_cone_minor_locked, spherical_joint_get_cone_minor_angle, spherical_joint_get_cone_major_axis, spherical_joint_enable_twist_limit, spherical_joint_is_twist_limit_enabled,
spherical_joint_get_lower_twist_limit, spherical_joint_get_upper_twist_limit, spherical_joint_set_twist_limits,
spherical_joint_get_twist_angle, spherical_joint_enable_spring, spherical_joint_is_spring_enabled, spherical_joint_set_target_rotation,
spherical_joint_get_target_rotation, spherical_joint_set_spring_hertz, spherical_joint_get_spring_hertz,
Expand Down Expand Up @@ -1668,6 +1668,15 @@ prepare_spherical_joint(base: *JointSim, ctx: *StepContext) {
if k > 0.0 { j.twist_mass = 1.0 / k }
j.twist_jacobian = jacobian
}
// The minor lock: C = B's z along the cone's minor axis on A, whose
// rate is (w_b - w_a) along B's z crossed with that axis.
if j.lock_cone_minor {
lock_axis = math.cross(twist_axis, math.rotate_vector(j.frame_a.q, dynamics.spherical_cone_minor_axis(j)))
k = math.dot(lock_axis, math.mul_mv(inertia_sum, lock_axis))
j.lock_mass = 0.0
if k > 0.0 { j.lock_mass = 1.0 / k }
j.lock_axis = lock_axis
}
if base.fixed_rotation == false { j.rotation_mass = math.invert_matrix(inertia_sum) } else { j.rotation_mass = math.mat3_zero() }
j.spring_softness = dynamics.make_soft(j.hertz, j.damping_ratio, ctx.h)
// A spring off or of no stiffness computes no impulse; its last one is
Expand All @@ -1680,6 +1689,7 @@ prepare_spherical_joint(base: *JointSim, ctx: *StepContext) {
j.swing_impulse = 0.0
j.lower_twist_impulse = 0.0
j.upper_twist_impulse = 0.0
j.lock_impulse = 0.0
}
}

Expand All @@ -1692,7 +1702,7 @@ warm_start_spherical_joint(base: *JointSim, ctx: *StepContext) {
// The angular impulses are each zeroed when their part is off, so a
// plain point (no spring, motor or limit) has none to give back.
angular = math.vec3_zero()
if j.enable_spring || j.enable_motor || j.enable_cone_limit || j.enable_twist_limit { angular = spherical_angular_impulse(j) }
if j.enable_spring || j.enable_motor || j.enable_cone_limit || j.enable_twist_limit || j.lock_cone_minor { angular = spherical_angular_impulse(j) }
v_a = math.mul_sub(math.widen3(state_a.v), base.inv_mass_a, j.linear_impulse)
w_a = math.sub(math.widen3(state_a.w), math.mul_mv(math.widen_mat3(base.inv_inertia_a), math.add(math.cross(r_a, j.linear_impulse), angular)))
v_b = math.mul_add(math.widen3(state_b.v), base.inv_mass_b, j.linear_impulse)
Expand Down Expand Up @@ -1774,6 +1784,23 @@ solve_spherical_joint(base: *JointSim, ctx: *StepContext, use_bias: bool) {
w_a = math.mul_add(w_a, delta, math.mul_mv(i_a, swing_axis))
w_b = math.mul_sub(w_b, delta, math.mul_mv(i_b, swing_axis))
}
// The minor lock, an equality softened as the point is.
if j.lock_cone_minor && fixed_rotation == false {
lock_axis = j.lock_axis
cdot = math.dot(math.sub(w_b, w_a), lock_axis)
bias = 0.0
mass_scale = 1.0
impulse_scale = 0.0
if use_bias {
bias = base.constraint_softness.bias_rate * dynamics.spherical_lock_error(j, quat_a, quat_b)
mass_scale = base.constraint_softness.mass_scale
impulse_scale = base.constraint_softness.impulse_scale
}
delta = 0.0 - mass_scale * j.lock_mass * (cdot + bias) - impulse_scale * j.lock_impulse
j.lock_impulse = j.lock_impulse + delta
w_a = math.mul_sub(w_a, delta, math.mul_mv(i_a, lock_axis))
w_b = math.mul_add(w_b, delta, math.mul_mv(i_b, lock_axis))
}
// The point.
r_a = math.rotate_vector(math.widen_quat(state_a.dq), j.frame_a.p)
r_b = math.rotate_vector(math.widen_quat(state_b.dq), j.frame_b.p)
Expand Down Expand Up @@ -1811,7 +1838,9 @@ get_spherical_joint_torque(w: *World, base: *JointSim) -> Vec3 {
spherical_angular_impulse(j: *SphericalJoint) -> Vec3 {
angular = math.add(j.spring_impulse, j.motor_impulse)
angular = math.mul_sub(angular, j.swing_impulse, j.swing_axis)
return math.mul_add(angular, j.lower_twist_impulse - j.upper_twist_impulse, j.twist_jacobian)
angular = math.mul_add(angular, j.lower_twist_impulse - j.upper_twist_impulse, j.twist_jacobian)
if j.lock_cone_minor { angular = math.mul_add(angular, j.lock_impulse, j.lock_axis) }
return angular
}

// The relative rotation of the frames, B's polarity matched to A's.
Expand Down Expand Up @@ -1889,6 +1918,29 @@ spherical_joint_set_cone_ellipse(id: JointId, major_angle: float, minor_angle: f
j.cone_minor_angle = dynamics.spherical_cone_minor(j, minor_angle)
j.cone_major_axis = math.narrow3(major_axis)
}
// A hinge that twists (#190): the cone's minor half-angle locked at zero,
// so frame B's z stays in the plane of the cone's centre and its major
// axis (an equality, as a revolute holds its axis) and swings along it as
// far as the circle of cone_angle about the centre; the twist about B's z
// is still the twist limit's. An elbow is one: it bends along its arc,
// its forearm turns about itself, and it never bends sideways. Locking
// drops an ellipse's minor angle; unlocked, the cone is a circle until an
// ellipse is set again.
spherical_joint_lock_cone_minor(id: JointId, flag: bool) {
if dynamics.recording_on(id.world0) { recorder = dynamics.rec_begin(id.world0, dynamics.OP_SPHERICAL_JOINT_LOCK_CONE_MINOR); dynamics.rec_id(recorder, id.index1, id.generation); dynamics.rec_bool(recorder, flag); dynamics.rec_end(recorder) }
base = sim_of(id, dynamics.JOINT_SPHERICAL)
if base == null { return }
j = dynamics.spherical_joint_of(base)
if flag == j.lock_cone_minor { return }
j.lock_cone_minor = flag
j.cone_minor_angle = 0.0
j.lock_impulse = 0.0
}
spherical_joint_is_cone_minor_locked(id: JointId) -> bool {
base = sim_of(id, dynamics.JOINT_SPHERICAL)
if base == null { return false }
return dynamics.spherical_joint_of(base).lock_cone_minor
}
spherical_joint_get_cone_minor_angle(id: JointId) -> float {
base = sim_of(id, dynamics.JOINT_SPHERICAL)
if base == null { return 0.0 }
Expand Down
6 changes: 6 additions & 0 deletions aephysics/recording/module.ae
Original file line number Diff line number Diff line change
Expand Up @@ -2890,6 +2890,12 @@ dispatch_call(p: *Player, op: int) -> bool {
if p.ok { joint_solver.spherical_joint_enable_twist_limit(a_joint_id_id, a_bool_flag) }
return true
}
if op == dynamics.OP_SPHERICAL_JOINT_LOCK_CONE_MINOR {
a_joint_id_id = read_joint_id(p)
a_bool_flag = read_bool(p)
if p.ok { joint_solver.spherical_joint_lock_cone_minor(a_joint_id_id, a_bool_flag) }
return true
}
if op == dynamics.OP_SPHERICAL_JOINT_SET_TWIST_LIMITS {
a_joint_id_id = read_joint_id(p)
a_float_lower = read_float(p)
Expand Down
Loading
Loading