@series-inc/rundot-syncplay 6.0.0-rc.77 → 6.0.0-rc.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -23
- package/core/native/kinetix-native-main.cpp +3 -3
- package/core/native/mobile/box3d_probe_scenario.cpp +2 -2
- package/core/native/physics/abi.cpp +19 -5
- package/core/native/physics/articulation.cpp +3 -2
- package/core/native/physics/capsule_triangle_native.inc +11 -36
- package/core/native/physics/character.cpp +5 -4
- package/core/native/physics/checkpoint_schema.hpp +12 -3
- package/core/native/physics/cloth.cpp +2 -1
- package/core/native/physics/constraint_rows.cpp +572 -244
- package/core/native/physics/constraint_rows.hpp +84 -15
- package/core/native/physics/contact_material_store.cpp +12 -0
- package/core/native/physics/contact_material_store.hpp +34 -0
- package/core/native/physics/deterministic_composite_math.hpp +50 -0
- package/core/native/physics/extended_abi.cpp +3 -0
- package/core/native/physics/geometry_store.cpp +395 -13
- package/core/native/physics/geometry_store.hpp +99 -0
- package/core/native/physics/hull_cook.hpp +122 -0
- package/core/native/physics/hull_cook.inc +1214 -0
- package/core/native/physics/hull_manifold.inc +661 -0
- package/core/native/physics/lag_compensation.cpp +4 -3
- package/core/native/physics/mass_properties.cpp +49 -181
- package/core/native/physics/mass_properties.hpp +11 -0
- package/core/native/physics/material_pose.hpp +0 -17
- package/core/native/physics/particles.cpp +9 -8
- package/core/native/physics/path_joint.cpp +4 -3
- package/core/native/physics/physics.cpp +11411 -17684
- package/core/native/physics/physics.hpp +492 -47
- package/core/native/physics/planar_deformable.cpp +9 -8
- package/core/native/physics/platformer_2d.cpp +11 -10
- package/core/native/physics/powered_ragdoll.cpp +11 -7
- package/core/native/physics/ragdoll.cpp +6 -5
- package/core/native/physics/ragdoll.hpp +6 -4
- package/core/native/physics/rope.cpp +4 -3
- package/core/native/physics/sdf_geometry.cpp +17 -16
- package/core/native/physics/soft_collision.cpp +3 -0
- package/core/native/physics/topology.cpp +107 -5
- package/core/native/physics/topology.hpp +18 -1
- package/core/native/physics/tracks.cpp +11 -10
- package/core/native/physics/voxel_cooking.cpp +2 -1
- package/core/native/physics/world.cpp +1726 -453
- package/core/native/physics/world.hpp +267 -9
- package/core/native/physics/world_abi.cpp +910 -70
- package/core/native/physics/world_abi.hpp +186 -5
- package/core/native/physics/world_digest_visitor.hpp +47 -32
- package/core/native/physics/world_strong_digest.hpp +55 -49
- package/core/scripts/build-native.mjs +3 -1
- package/core/scripts/build-wasm-physics.mjs +21 -3
- package/core/scripts/extended-physics-profile.mjs +2 -0
- package/core/src/physics/abi-constants.mjs +5 -4
- package/core/src/physics/box3d-probe.mjs +6 -6
- package/core/src/physics/feature-api.d.mts +2 -0
- package/core/src/physics/feature-api.mjs +3 -0
- package/core/src/physics/hull-cook.d.mts +23 -0
- package/core/src/physics/hull-cook.mjs +39 -0
- package/core/src/physics/physics-profile-wasm-module.generated.mjs +17 -12
- package/core/src/physics/physics-profile.wasm +0 -0
- package/core/src/physics/physics-wasm-module.generated.mjs +17 -12
- package/core/src/physics/physics.wasm +0 -0
- package/core/src/physics/world.d.mts +5 -0
- package/core/src/physics/world.mjs +798 -33
- package/core/src/physics2d/physics2d-wasm-module.generated.mjs +1 -1
- package/core/world.d.ts +201 -3
- package/dist/lag-compensation3d.js +3 -3
- package/dist/movement3d.js +15 -30
- package/dist/physics/3d.d.ts +1054 -67
- package/dist/physics/3d.js +2239 -209
- package/dist/physics/body-forces3d.d.ts +69 -0
- package/dist/physics/body-forces3d.js +396 -0
- package/dist/physics/debug-overlay3d.d.ts +4 -5
- package/dist/physics/debug-overlay3d.js +9 -13
- package/dist/physics/hot-path-stats3d.d.ts +0 -7
- package/dist/physics/shape-mass3d.d.ts +134 -0
- package/dist/physics/shape-mass3d.js +527 -0
- package/dist/physics/vehicle-state3d.d.ts +5 -5
- package/dist/physics/vehicle-state3d.js +20 -9
- package/package.json +4 -3
- package/dist/physics/contact-decode3d.d.ts +0 -75
- package/dist/physics/contact-decode3d.js +0 -448
package/README.md
CHANGED
|
@@ -12,9 +12,9 @@ The root entry provides periodic fixed math, value noise, fBm, render helpers,
|
|
|
12
12
|
and an optional periodic xz point grid. `createPhysicsWorld3D({ periodicDomain })`
|
|
13
13
|
adds periodic raycasts, overlaps, and shape casts with an `image` on each hit.
|
|
14
14
|
The domain is flat. These utilities do not add globe curvature or contact
|
|
15
|
-
across a seam.
|
|
16
|
-
the [periodic-space guide](docs/periodic-space.md) for units,
|
|
17
|
-
examples.
|
|
15
|
+
across a seam. Every peer of a periodic world needs the same domain and native
|
|
16
|
+
world ABI 19. Read the [periodic-space guide](docs/periodic-space.md) for units,
|
|
17
|
+
limits, and examples.
|
|
18
18
|
|
|
19
19
|
## Physics profiling
|
|
20
20
|
|
|
@@ -512,7 +512,7 @@ frame, and disagreeing checksums.
|
|
|
512
512
|
|
|
513
513
|
## Physics API v1
|
|
514
514
|
|
|
515
|
-
Syncplay
|
|
515
|
+
Syncplay has one public TypeScript API for each physics dimension. Import
|
|
516
516
|
2D physics from `@series-inc/rundot-syncplay/physics/2d`. Import 3D physics from
|
|
517
517
|
`@series-inc/rundot-syncplay/physics/3d`. Do not import a raw physics adapter
|
|
518
518
|
from `/core`.
|
|
@@ -566,9 +566,11 @@ layout, WASM boundary, schedule, and checkpoint representation can change when
|
|
|
566
566
|
a complete benchmark proves a faster design. Each replacement must keep the
|
|
567
567
|
public contract, deterministic results, rollback controls, and bounded memory.
|
|
568
568
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
569
|
+
Version 6.0.0-rc.78 uses one Box3D engine for every 3D world and physics ABI 25.
|
|
570
|
+
Do not restore a checkpoint or load a replay from rc.77 or older. Those builds
|
|
571
|
+
use physics ABI 24 or earlier, and the world profile check rejects them. Every
|
|
572
|
+
peer in a match must use rc.78 or later. Change the game deterministic version,
|
|
573
|
+
record golden digests again, and start new rollback, replay, and late-join history.
|
|
572
574
|
|
|
573
575
|
Read the [2D guide](https://github.com/series-ai/venus/blob/develop/packages/sdk-docs/rundot-developer-platform/api/SYNCPLAY-PHYSICS-2D.md),
|
|
574
576
|
the [3D guide](https://github.com/series-ai/venus/blob/develop/packages/sdk-docs/rundot-developer-platform/api/SYNCPLAY-PHYSICS.md), and
|
|
@@ -584,19 +586,18 @@ the state to `released` with reason `body-removed`. That step applies no force.
|
|
|
584
586
|
Revision 1 keeps its body handle until you restore the servo state. A physics
|
|
585
587
|
restore makes the old handle stale. Restore both states before the next step.
|
|
586
588
|
|
|
587
|
-
### SI types
|
|
589
|
+
### SI types
|
|
588
590
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
the bits of a finite input. It rejects NaN and infinity.
|
|
591
|
+
Use the SI constructors for each quantity: `meters()` for positions,
|
|
592
|
+
`kilograms()` for mass, `metersPerSecond()` for linear velocity, and
|
|
593
|
+
`newtons()` for force. Use `perSecond()` for a damping rate. Use
|
|
594
|
+
`frameVelocity()` and `frameGravity()` for frame quantities. Each constructor
|
|
595
|
+
keeps the bits of a finite input. It rejects NaN and infinity. Some body input
|
|
596
|
+
fields accept a plain number as well. The type of each field states which form
|
|
597
|
+
it takes. Revision 1 helper behavior remains selected by default.
|
|
594
598
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
default. The revision 1 tests compare complete results with the previous RC.
|
|
598
|
-
|
|
599
|
-
Set `behaviorRevision: 3` to recover from contact penetration after a landing.
|
|
599
|
+
For the character controller (`stepDeterministicKcc3D`), set `behaviorRevision: 3`
|
|
600
|
+
to recover from contact penetration after a landing.
|
|
600
601
|
This revision includes slope clearance for dynamic supports. It keeps the
|
|
601
602
|
revision 1 result shape and uses required checksums by default. Revision 1
|
|
602
603
|
remains the default. Revision 2 keeps its support state and portal movement.
|
|
@@ -612,17 +613,20 @@ The operation keeps the shape, mass, inertia, logical ID, and velocities.
|
|
|
612
613
|
An identical normalized pose preserves sleep and the mutation revision.
|
|
613
614
|
A changed pose wakes the affected dynamic joint group.
|
|
614
615
|
|
|
615
|
-
Use `world.setBodyLinearDamping(idOrHandle,
|
|
616
|
-
The
|
|
617
|
-
|
|
616
|
+
Use `world.setBodyLinearDamping(idOrHandle, damping)` to change linear damping.
|
|
617
|
+
The value is a rate in 1/s, built with `perSecond(value)`. Each substep of length
|
|
618
|
+
`h` multiplies the velocity by `1 / (1 + h × damping)`. The default is 0 (no
|
|
619
|
+
damping). `setBodyAngularDamping` and `setBodyDamping` use the same unit. To
|
|
620
|
+
convert an old per-tick keep fraction k at tick rate R, use (1 / k - 1) * R.
|
|
618
621
|
The operation preserves sleep.
|
|
619
622
|
Use `world.wakeBody(idOrHandle)` to wake a dynamic body without a velocity change.
|
|
620
623
|
Resolve a new handle after a checkpoint restore, or use the logical ID.
|
|
621
624
|
|
|
622
625
|
### Batch motion output
|
|
623
626
|
|
|
624
|
-
`world.writeBodyMotionInto(poses, velocities, ids, status)` returns the body
|
|
625
|
-
mutation `revision`, and `restoreEpoch`.
|
|
627
|
+
`world.writeBodyMotionInto(poses, velocities, ids, status, teleports?)` returns the body
|
|
628
|
+
count, mutation `revision`, and `restoreEpoch`. The optional `teleports` output is a
|
|
629
|
+
`Uint32Array` of teleport counters, one per body, at least as long as the body count.
|
|
626
630
|
Use `Float64Array` for poses and velocities.
|
|
627
631
|
Use `BigUint64Array` for logical IDs.
|
|
628
632
|
Use `Uint8Array` for status.
|
|
@@ -182,10 +182,10 @@ int runPhysicsAbiVectors() {
|
|
|
182
182
|
bodyData[offset + 11] = 1.0;
|
|
183
183
|
bodyData[offset + 12] = 1.0;
|
|
184
184
|
bodyData[offset + 13] = 1.0;
|
|
185
|
-
bodyData[offset + 14] = 0.
|
|
185
|
+
bodyData[offset + 14] = 0.0; // Box3D damping rate (1/s), default none (the JS marshaler default)
|
|
186
186
|
bodyData[offset + 18] = 1.0;
|
|
187
187
|
bodyData[offset + 25] = 1.0;
|
|
188
|
-
bodyData[offset + 26] = 0.
|
|
188
|
+
bodyData[offset + 26] = 0.0;
|
|
189
189
|
bodyData[offset + 27] = 0.6;
|
|
190
190
|
bodyData[offset + 31] = 1.0;
|
|
191
191
|
bodyData[offset + 32] = 1.0;
|
|
@@ -453,7 +453,7 @@ int runPhysicsSessionV2() {
|
|
|
453
453
|
|
|
454
454
|
int runPhysicsQuerySession() {
|
|
455
455
|
constexpr std::uint32_t stride = rundot::kinetix::physics::kBodyStride;
|
|
456
|
-
constexpr std::uint32_t queryStride = rundot::kinetix::physics::
|
|
456
|
+
constexpr std::uint32_t queryStride = rundot::kinetix::physics::kLegacyQueryInputStride;
|
|
457
457
|
std::string line;
|
|
458
458
|
if (!std::getline(std::cin, line)) {
|
|
459
459
|
std::cerr << "KINETIX_PHYSICS_QUERY_HEADER_MISSING\n";
|
|
@@ -21,10 +21,10 @@ void setCommonFields(std::vector<double>& bodyData, std::size_t offset, std::uin
|
|
|
21
21
|
bodyData[offset + 11] = 1.0;
|
|
22
22
|
bodyData[offset + 12] = 1.0;
|
|
23
23
|
bodyData[offset + 13] = 1.0;
|
|
24
|
-
bodyData[offset + 14] =
|
|
24
|
+
bodyData[offset + 14] = 0.0; // Box3D damping rate (1/s): none
|
|
25
25
|
bodyData[offset + 18] = 1.0;
|
|
26
26
|
bodyData[offset + 25] = 1.0;
|
|
27
|
-
bodyData[offset + 26] =
|
|
27
|
+
bodyData[offset + 26] = 0.0; // Box3D damping rate (1/s): none
|
|
28
28
|
bodyData[offset + 27] = 0.6;
|
|
29
29
|
bodyData[offset + 31] = 1.0;
|
|
30
30
|
bodyData[offset + 32] = 1.0;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include "abi.hpp"
|
|
2
|
+
#include "deterministic_composite_math.hpp"
|
|
2
3
|
#include "certified_sum.hpp"
|
|
3
4
|
|
|
4
5
|
#include <algorithm>
|
|
@@ -273,6 +274,9 @@ Body unpackBody(const double* bodyData, std::uint32_t offset) {
|
|
|
273
274
|
body.sensorLike = body.trigger || body.sensor;
|
|
274
275
|
body.sleeping = body.dynamic && (motionType & kMotionSleeping) != 0;
|
|
275
276
|
body.angularState = (motionType & kMotionAngularState) != 0;
|
|
277
|
+
body.allowFastRotation = (motionType & kMotionAllowFastRotation) != 0;
|
|
278
|
+
body.eventFlags = motionType & kMotionEventMask;
|
|
279
|
+
body.speculativeContactDisabled = (motionType & kMotionNoSpeculativeContact) != 0;
|
|
276
280
|
|
|
277
281
|
body.shape = static_cast<ShapeKind>(static_cast<std::uint32_t>(bodyData[offset + 10]));
|
|
278
282
|
body.mass = bodyData[offset + 18];
|
|
@@ -369,7 +373,7 @@ void computeAxisStates(
|
|
|
369
373
|
velocities[i] = dotVec(relLinVel, linearAxes[i]);
|
|
370
374
|
}
|
|
371
375
|
for (std::uint32_t j = 0; j < 3; ++j) {
|
|
372
|
-
positions[3 + j] = 2.0 *
|
|
376
|
+
positions[3 + j] = 2.0 * rundot::detmath::det_atan2(qRel[j], qRel[3]);
|
|
373
377
|
velocities[3 + j] = dotVec(relAngVel, linearAxes[j]);
|
|
374
378
|
}
|
|
375
379
|
}
|
|
@@ -422,6 +426,12 @@ std::int32_t stepSoAWithSixDofJoints(
|
|
|
422
426
|
};
|
|
423
427
|
c.maximumLinearForce = joint_data[offset + 92];
|
|
424
428
|
c.maximumAngularTorque = joint_data[offset + 93];
|
|
429
|
+
{
|
|
430
|
+
JointRecordExtensions extensions;
|
|
431
|
+
if (!jointRecordExtensions(std::span<const double>(joint_data + offset, 2 * kJointStride), extensions)) return 3;
|
|
432
|
+
c.constraintHertz = extensions.constraintHertz;
|
|
433
|
+
c.constraintDampingRatio = extensions.constraintDampingRatio;
|
|
434
|
+
}
|
|
425
435
|
for (std::uint32_t a = 0; a < 6; ++a) {
|
|
426
436
|
std::uint32_t m = static_cast<std::uint32_t>(joint_data[offset + 18 + a]);
|
|
427
437
|
c.axes[a].limit.mode = m == 1 ? SixDofAxisMode::Locked
|
|
@@ -478,10 +488,14 @@ std::int32_t stepSoAWithSixDofJoints(
|
|
|
478
488
|
{g_sixDofConstraints.data(), sixDofCount},
|
|
479
489
|
{g_sixDofOutputs.data(), sixDofCount},
|
|
480
490
|
true};
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
491
|
+
rundot::kinetix::physics::SubstepConstraintHook sixDofHook;
|
|
492
|
+
if (sixDofCount > 0) {
|
|
493
|
+
sixDofHook.addParticipant({&SixDofSubstepParticipant::invoke, &sixDofParticipant,
|
|
494
|
+
SixDofSubstepParticipant::traits});
|
|
495
|
+
}
|
|
496
|
+
sixDofHook.connections = {connections.data(), sixDofCount};
|
|
497
|
+
sixDofHook.jointParticipantConnections = sixDofCount;
|
|
498
|
+
sixDofHook.collisionExclusions = {collisionExclusions.data(), collisionExclusionCount};
|
|
485
499
|
|
|
486
500
|
std::int32_t status = standardCount > 0
|
|
487
501
|
? rundot::kinetix::physics::stepSoAWithJoints(
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include "articulation.hpp"
|
|
2
|
+
#include "deterministic_composite_math.hpp"
|
|
2
3
|
|
|
3
4
|
#include <algorithm>
|
|
4
5
|
#include <array>
|
|
@@ -184,8 +185,8 @@ ArticulationVec3 invRotateByQuat(const ArticulationQuat& q, const ArticulationVe
|
|
|
184
185
|
ArticulationQuat quatFromAxisAngle(const ArticulationVec3& axis, double angle) {
|
|
185
186
|
const ArticulationVec3 n = normalizeVec3(axis);
|
|
186
187
|
const double halfAngle = angle * 0.5;
|
|
187
|
-
const double s =
|
|
188
|
-
return {n.x * s, n.y * s, n.z * s,
|
|
188
|
+
const double s = rundot::detmath::det_sin(halfAngle);
|
|
189
|
+
return {n.x * s, n.y * s, n.z * s, rundot::detmath::det_cos(halfAngle)};
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
// ---------------------------------------------------------------------------
|
|
@@ -83,26 +83,16 @@ std::array<Vec3,2> nativePairLevers(SolverOperation& operation,const NativePairC
|
|
|
83
83
|
}
|
|
84
84
|
return output;
|
|
85
85
|
}
|
|
86
|
-
std::array<Vec3,2> levers(SolverOperation& operation,const RelativeContactBasis& basis,const Body& a,const Body& b){
|
|
87
|
-
if(const auto* native=std::get_if<NativePairContactBasis>(&basis.coordinates))return nativePairLevers(operation,*native,a,b);
|
|
88
|
-
if(const auto* triangle=std::get_if<TriangleContactBasis>(&basis.coordinates))return levers(operation,*triangle,a,b);
|
|
89
|
-
return materialContactLevers(operation,basis,a,b);
|
|
90
|
-
}
|
|
91
86
|
std::array<Vec3,2> levers(SolverOperation& operation,const Collision& collision,std::uint32_t point,const Body& a,const Body& b){
|
|
92
87
|
const auto* basis=std::get_if<TriangleManifoldBasis>(&collision.coordinates);
|
|
93
88
|
if(basis==nullptr||collision.pointCount>basis->midpoints.size()||point>=collision.pointCount)throw TriangleNativeFailure{tp::Failure::InvalidInput};
|
|
94
89
|
return levers(operation,TriangleContactBasis{basis->anchor,basis->shapeOffset,basis->midpoints[point]},a,b);
|
|
95
90
|
}
|
|
96
|
-
|
|
97
|
-
if(operation.relativeContacts.empty())return nullptr;
|
|
98
|
-
for(const auto& basis:operation.relativeContacts){work(operation);if(basis.bodyA==constraint.bodyA&&basis.bodyB==constraint.bodyB&&basis.feature==constraint.featureId)return &basis;}
|
|
99
|
-
return nullptr;
|
|
100
|
-
}
|
|
101
|
-
using SelectedContactCoordinates=std::variant<WorldContactBasis,TriangleContactBasis,NativePairContactBasis,MaterialManifoldBasis>;
|
|
91
|
+
using SelectedContactCoordinates=std::variant<WorldContactBasis,TriangleContactBasis,NativePairContactBasis>;
|
|
102
92
|
SelectedContactCoordinates selectedCoordinates(const Collision& collision,std::uint32_t point){
|
|
103
93
|
return std::visit([&](const auto& basis)->SelectedContactCoordinates{
|
|
104
94
|
using T=std::decay_t<decltype(basis)>;
|
|
105
|
-
if constexpr(std::is_same_v<T,WorldContactBasis
|
|
95
|
+
if constexpr(std::is_same_v<T,WorldContactBasis>)return basis;
|
|
106
96
|
else if constexpr(std::is_same_v<T,NativePairManifoldBasis>){
|
|
107
97
|
if(point>=(collision.pointCount==0?1u:collision.pointCount)||point>=basis.points.size())throw TriangleNativeFailure{tp::Failure::InvalidInput};
|
|
108
98
|
return NativePairContactBasis{basis.anchor,basis.points[point],basis.displacement};
|
|
@@ -116,38 +106,15 @@ SelectedContactCoordinates selectedCoordinates(const Collision& collision,std::u
|
|
|
116
106
|
}else static_assert(std::is_same_v<T,void>,"Missing selected contact coordinate reader");
|
|
117
107
|
},collision.coordinates);
|
|
118
108
|
}
|
|
119
|
-
std::optional<RelativeContactBasis> relativeBasis(SolverOperation& operation,const ContactConstraintBlock& constraint,const Collision& collision,std::uint32_t point){
|
|
120
|
-
return std::visit([&](const auto& selected)->std::optional<RelativeContactBasis>{
|
|
121
|
-
using T=std::decay_t<decltype(selected)>;
|
|
122
|
-
if constexpr(std::is_same_v<T,WorldContactBasis>)return std::nullopt;
|
|
123
|
-
else if constexpr(std::is_same_v<T,MaterialManifoldBasis>)return materialRetainedBasis(operation,constraint,collision,point);
|
|
124
|
-
else if constexpr(std::is_same_v<T,TriangleContactBasis>||std::is_same_v<T,NativePairContactBasis>)
|
|
125
|
-
return RelativeContactBasis{constraint.bodyA,constraint.bodyB,constraint.featureId,selected};
|
|
126
|
-
else static_assert(std::is_same_v<T,void>,"Missing relative contact coordinate reader");
|
|
127
|
-
},selectedCoordinates(collision,point));
|
|
128
|
-
}
|
|
129
|
-
void retain(SolverOperation& operation,const ContactConstraintBlock& constraint,const Collision& collision,std::uint32_t point){
|
|
130
|
-
auto next=relativeBasis(operation,constraint,collision,point);
|
|
131
|
-
if(!next)return;
|
|
132
|
-
for(auto& basis:operation.relativeContacts){work(operation);if(basis.bodyA==next->bodyA&&basis.bodyB==next->bodyB&&basis.feature==next->feature){basis=*next;return;}}
|
|
133
|
-
append(operation,operation.relativeContacts,std::move(*next));
|
|
134
|
-
}
|
|
135
109
|
std::array<Vec3,2> collisionLevers(SolverOperation& operation,const Collision& collision,std::uint32_t pointIndex,const Body& a,const Body& b,const Vec3& point){
|
|
136
110
|
return std::visit([&](const auto& selected)->std::array<Vec3,2>{
|
|
137
111
|
using T=std::decay_t<decltype(selected)>;
|
|
138
112
|
if constexpr(std::is_same_v<T,TriangleContactBasis>)return levers(operation,selected,a,b);
|
|
139
113
|
else if constexpr(std::is_same_v<T,NativePairContactBasis>)return nativePairLevers(operation,selected,a,b);
|
|
140
|
-
else if constexpr(std::is_same_v<T,MaterialManifoldBasis>)return materialCollisionLevers(operation,collision,pointIndex,a,b);
|
|
141
114
|
else if constexpr(std::is_same_v<T,WorldContactBasis>)return {subtractVec3(point,worldCenterOfMass(a)),subtractVec3(point,worldCenterOfMass(b))};
|
|
142
115
|
else static_assert(std::is_same_v<T,void>,"Missing contact lever reader");
|
|
143
116
|
},selectedCoordinates(collision,pointIndex));
|
|
144
117
|
}
|
|
145
|
-
std::array<Vec3,2> constraintLevers(SolverOperation& operation,const ContactConstraintBlock& constraint,const Body& a,const Body& b,const std::optional<RelativeContactBasis>* explicitBasis=nullptr){
|
|
146
|
-
if(explicitBasis!=nullptr){if(*explicitBasis)return levers(operation,**explicitBasis,a,b);}
|
|
147
|
-
else if(const auto* basis=find(operation,constraint))return levers(operation,*basis,a,b);
|
|
148
|
-
const Vec3 point{constraint.point[0],constraint.point[1],constraint.point[2]};
|
|
149
|
-
return {subtractVec3(point,worldCenterOfMass(a)),subtractVec3(point,worldCenterOfMass(b))};
|
|
150
|
-
}
|
|
151
118
|
std::uint32_t ordinal(std::uint64_t offset,std::uint64_t triangle){
|
|
152
119
|
const auto value=2*std::uint64_t(offset)+triangle;
|
|
153
120
|
constexpr std::uint64_t maxPoints=12600000u/3u;
|
|
@@ -269,7 +236,15 @@ Collision observeGeometry(SolverOperation& operation,const Body& capsule,const B
|
|
|
269
236
|
};
|
|
270
237
|
auto triangle=[&](std::uint32_t a,std::uint32_t b,std::uint32_t c,std::uint64_t triangleIndex){work(operation);input.triangle={point(a),point(b),point(c)};input.immutableTraversalOrdinal=ordinal(std::uint64_t(node.offset)+geometry.geometryFeatureOffset,triangleIndex);
|
|
271
238
|
if(separatedBounds(operation,input))return;
|
|
272
|
-
|
|
239
|
+
// The exact values of one observation live only inside it (the hit keeps captured encodings),
|
|
240
|
+
// so its word allowance is per observation: GeometryCallQuota::arithmeticRequestedWordBytes is
|
|
241
|
+
// the scratch memory that one live computation can hold. One allowance for the whole step
|
|
242
|
+
// charged memory that was already freed (49-85 KB per observation, so about 45 capsules resting
|
|
243
|
+
// on a mesh stopped the step with physics.capacity-exceeded). The work meter still bounds time.
|
|
244
|
+
// observeGeometry validated the quota split with arithmetic(operation) before any triangle.
|
|
245
|
+
exact_dyadic::Operation observationArithmetic{exact_dyadic::Budget{
|
|
246
|
+
std::size_t(operation.inputs.geometryQuota.arithmeticRequestedWordBytes)}};
|
|
247
|
+
auto observation=tp::observe(input,observationArithmetic,operation.triangleQuota);
|
|
273
248
|
if(const auto* error=std::get_if<tp::Failure>(&observation))throw TriangleNativeFailure{*error};if(const auto* hit=std::get_if<tp::Hit>(&observation))select(toCollision(*hit,node.outerChild));};
|
|
274
249
|
const auto indexedTriangles = [&]() {
|
|
275
250
|
if (geometry.geometryRecord == nullptr) return false;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include "character.hpp"
|
|
2
|
+
#include "deterministic_composite_math.hpp"
|
|
2
3
|
|
|
3
4
|
#include <algorithm>
|
|
4
5
|
#include <array>
|
|
@@ -129,7 +130,7 @@ bool checkGroundSupport(
|
|
|
129
130
|
state.groundDistance = hit.distance;
|
|
130
131
|
state.groundBodyIndex = hit.bodyIndex;
|
|
131
132
|
|
|
132
|
-
if (cosSlope >=
|
|
133
|
+
if (cosSlope >= rundot::detmath::det_cos(config.maxSlopeAngle)) {
|
|
133
134
|
state.grounded = true;
|
|
134
135
|
return true;
|
|
135
136
|
} else {
|
|
@@ -188,7 +189,7 @@ bool sweepAndSlide(
|
|
|
188
189
|
// Ceiling hit
|
|
189
190
|
state.hitCeiling = true;
|
|
190
191
|
if (state.velocity.y > 0.0) state.velocity.y = 0.0;
|
|
191
|
-
} else if (upDot >=
|
|
192
|
+
} else if (upDot >= rundot::detmath::det_cos(config.maxSlopeAngle)) {
|
|
192
193
|
// Ground hit
|
|
193
194
|
state.grounded = true;
|
|
194
195
|
state.groundNormal = surfNormal;
|
|
@@ -304,7 +305,7 @@ bool tryStepUp(
|
|
|
304
305
|
CharacterVec3 landNormal = downHit.normal;
|
|
305
306
|
if (dotVec3(landNormal, downDir) > 0.0) landNormal = scaleVec3(landNormal, -1.0);
|
|
306
307
|
const double cosSlope = dotVec3(landNormal, config.up);
|
|
307
|
-
if (cosSlope <
|
|
308
|
+
if (cosSlope < rundot::detmath::det_cos(config.maxSlopeAngle)) return false;
|
|
308
309
|
|
|
309
310
|
const double landingAdvance = std::max(0.0, downHit.distance - config.skinWidth);
|
|
310
311
|
const CharacterVec3 landingPos = addVec3(forwardPos, scaleVec3(downDir, landingAdvance));
|
|
@@ -360,7 +361,7 @@ CharacterStatus stepCharacterController(
|
|
|
360
361
|
// 5. Slope motion projection when grounded
|
|
361
362
|
if (state.grounded) {
|
|
362
363
|
const double cosSlope = dotVec3(state.groundNormal, config.up);
|
|
363
|
-
if (cosSlope >=
|
|
364
|
+
if (cosSlope >= rundot::detmath::det_cos(config.maxSlopeAngle)) {
|
|
364
365
|
// Walkable slope: project horizontal movement onto slope tangent plane
|
|
365
366
|
const double slopeDot = dotVec3(horizMove, state.groundNormal);
|
|
366
367
|
horizMove = subVec3(horizMove, scaleVec3(state.groundNormal, slopeDot));
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
namespace rundot::kinetix::physics {
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// Revision 3 (P6): contactCacheH replaces the material pose leaf.
|
|
11
|
+
inline constexpr std::uint32_t kWorldStrongDigestAlgorithmRevision = 3;
|
|
11
12
|
inline constexpr char kStrongCheckpointDomain[] = "kinetix.world-checkpoint/1";
|
|
12
13
|
inline constexpr char kStrongRecordDomain[] = "kinetix.geometry-record/1";
|
|
13
14
|
inline constexpr char kStrongRootDomain[] = "kinetix.geometry-root/1";
|
|
@@ -71,6 +72,13 @@ enum class StrongSection : std::uint32_t {
|
|
|
71
72
|
DefinitionSignatures = 14,
|
|
72
73
|
BodyMaterials = 15,
|
|
73
74
|
BodyMaterialFrames = 16,
|
|
75
|
+
// Written after BodyMaterials only when a body has a non-default collision filter row.
|
|
76
|
+
BodyFilters = 17,
|
|
77
|
+
// Written after ContactEvents only when a contact event row has shape data (WorldContactEvent::hasShapes).
|
|
78
|
+
ContactShapes = 18,
|
|
79
|
+
// Written after ContactShapes (or ContactEvents) only when a contact event row has hit data
|
|
80
|
+
// (WorldContactEvent::hasHit).
|
|
81
|
+
ContactHits = 19,
|
|
74
82
|
};
|
|
75
83
|
|
|
76
84
|
// FNV revision 2 order. Supports stays in the list. The visitor omits an empty channel.
|
|
@@ -182,7 +190,8 @@ inline void checkpointRecordSchemaGuard(const WorldContactMaterialResult& value)
|
|
|
182
190
|
}
|
|
183
191
|
inline void checkpointRecordSchemaGuard(const WorldContactEvent& value) noexcept {
|
|
184
192
|
[[maybe_unused]] const auto& [type, bodyA, bodyB, trigger, sensor, normalImpulse,
|
|
185
|
-
tangentImpulse1, tangentImpulse2, point, normal, penetration, closingSpeed, material
|
|
193
|
+
tangentImpulse1, tangentImpulse2, point, normal, penetration, closingSpeed, material, shapeA, shapeB,
|
|
194
|
+
shapeBits, hitState, hitSpeed, hitPoint, hitNormal] = value;
|
|
186
195
|
}
|
|
187
196
|
inline void checkpointRecordSchemaGuard(const WorldJointReaction& value) noexcept {
|
|
188
197
|
[[maybe_unused]] const auto& [joint, bodyA, bodyB, force, torque] = value;
|
|
@@ -413,7 +422,7 @@ static_assert(sizeof(WorldSupportSpring) == 120);
|
|
|
413
422
|
static_assert(sizeof(WorldSupportForce) == 96);
|
|
414
423
|
static_assert(sizeof(WorldContactMaterialSnapshot) == 48);
|
|
415
424
|
static_assert(sizeof(WorldContactMaterialResult) == 184);
|
|
416
|
-
static_assert(sizeof(WorldContactEvent) ==
|
|
425
|
+
static_assert(sizeof(WorldContactEvent) == 376);
|
|
417
426
|
static_assert(sizeof(WorldJointReaction) == 72);
|
|
418
427
|
static_assert(sizeof(WorldJointBreakEvent) == 16);
|
|
419
428
|
static_assert(sizeof(WorldFluidInteraction) == 128);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include "cloth.hpp"
|
|
2
|
+
#include "deterministic_composite_math.hpp"
|
|
2
3
|
|
|
3
4
|
#include <algorithm>
|
|
4
5
|
#include <cmath>
|
|
@@ -20,7 +21,7 @@ inline double clothClamp(double value, double minVal, double maxVal) {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
inline double clothAcos(double value) {
|
|
23
|
-
return
|
|
24
|
+
return rundot::detmath::det_acos(clothClamp(value, -1.0, 1.0));
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
inline double bodyInverseMass(const Body& body) {
|