@series-inc/rundot-syncplay 6.0.0-rc.64 → 6.0.0-rc.66
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/core/native/physics/physics.cpp +290 -227
- package/core/src/engine-math.d.mts +23 -0
- package/core/src/engine-math.mjs +1060 -0
- package/core/src/kinetix-deterministic-stdlib.mjs +3 -1
- package/core/src/physics/gear.mjs +2 -1
- package/core/src/physics/particles.mjs +2 -1
- package/core/src/physics/path-joint.mjs +4 -3
- package/core/src/physics/physics-profile-wasm-module.generated.mjs +4 -4
- package/core/src/physics/physics-profile.wasm +0 -0
- package/core/src/physics/physics-wasm-module.generated.mjs +4 -4
- package/core/src/physics/physics.wasm +0 -0
- package/core/src/physics/ragdoll.mjs +7 -6
- package/core/src/physics/rope.mjs +3 -2
- package/core/src/physics/voxel-cooking.mjs +2 -1
- package/core/src/physics/world.mjs +3 -2
- package/core/src/physics2d/compound.mjs +4 -2
- package/core/src/physics2d/contour-state.mjs +6 -4
- package/core/src/physics2d/physics2d-wasm-module.generated.mjs +1 -1
- package/dist/collider-preparation.js +7 -6
- package/dist/math.js +2 -1
- package/dist/modules/extraction.js +6 -5
- package/dist/movement3d.js +7 -6
- package/dist/navmesh.js +3 -2
- package/dist/physics/3d.js +8 -7
- package/dist/physics/debug-overlay3d.js +17 -16
- package/dist/physics/vehicle-state2d.js +9 -8
- package/dist/physics/vehicle-state3d.js +182 -22
- package/dist/presentation-ik.js +3 -2
- package/package.json +4 -4
|
@@ -280,9 +280,12 @@ static_assert(offsetof(PreparedJointRow, upper) == 120);
|
|
|
280
280
|
|
|
281
281
|
struct ContactConstraintBlock {
|
|
282
282
|
std::uint32_t bodyA = 0;
|
|
283
|
-
std::uint32_t bodyB :
|
|
283
|
+
std::uint32_t bodyB : 29 = 0;
|
|
284
284
|
std::uint32_t activeForVelocityPhase : 1 = 0;
|
|
285
285
|
std::uint32_t preserveForCache : 1 = 0;
|
|
286
|
+
// A later substep applied this contact's impulse as its warm start, and the collecting pass has
|
|
287
|
+
// not matched the contact yet.
|
|
288
|
+
std::uint32_t warmPending : 1 = 0;
|
|
286
289
|
std::uint32_t featureId = 0;
|
|
287
290
|
std::uint32_t solveOrder = 0;
|
|
288
291
|
std::array<double, 3> point{};
|
|
@@ -298,7 +301,7 @@ struct ContactConstraintBlock {
|
|
|
298
301
|
};
|
|
299
302
|
|
|
300
303
|
static_assert(sizeof(ContactConstraintBlock) == 160);
|
|
301
|
-
static_assert(kBroadphaseCapacity < (1u <<
|
|
304
|
+
static_assert(kBroadphaseCapacity < (1u << 29));
|
|
302
305
|
|
|
303
306
|
namespace {
|
|
304
307
|
|
|
@@ -4187,12 +4190,12 @@ struct SolverStorage {
|
|
|
4187
4190
|
std::vector<ContactConstraintBlock> contactConstraints;
|
|
4188
4191
|
std::vector<double> contactCacheOutput;
|
|
4189
4192
|
std::vector<std::uint8_t> contactSupported;
|
|
4190
|
-
// Support contacts (lower << 32 | upper) seen by the collecting iteration of this substep.
|
|
4191
|
-
// first
|
|
4192
|
-
//
|
|
4193
|
+
// Support contacts (lower << 32 | upper) seen by the collecting iteration of this substep. Before
|
|
4194
|
+
// the first extra velocity pass, propagateContactSupport marks every body that rests on support
|
|
4195
|
+
// through a chain of them; the collecting order alone missed crates visited before their support.
|
|
4196
|
+
// The marks choose the pairs that get the supported-structure iteration floor, nothing else.
|
|
4193
4197
|
std::vector<std::uint64_t> supportEdges;
|
|
4194
4198
|
bool supportPropagated = false;
|
|
4195
|
-
std::vector<std::uint8_t> movingFoundation;
|
|
4196
4199
|
// Dynamic-dynamic pairs that the collecting contact iteration solves after the support pairs.
|
|
4197
4200
|
std::vector<std::uint64_t> deferredDynamicPairs;
|
|
4198
4201
|
// collide() results of frozen pairs (see collide()), valid within one solver operation. Each
|
|
@@ -5095,7 +5098,6 @@ void SolverStorage::invalidate(bool keepBroadphaseTree) noexcept {
|
|
|
5095
5098
|
contactSupported.clear();
|
|
5096
5099
|
supportEdges.clear();
|
|
5097
5100
|
supportPropagated = false;
|
|
5098
|
-
movingFoundation.clear();
|
|
5099
5101
|
deferredDynamicPairs.clear();
|
|
5100
5102
|
// The collide() memo keeps its capacity: a new operation starts it empty (see collide()), so a
|
|
5101
5103
|
// restore does not free it and the next steps do not allocate it again.
|
|
@@ -5158,7 +5160,6 @@ std::uint64_t SolverStorage::retainedBytes() const noexcept {
|
|
|
5158
5160
|
+ retainedVectorBytes(contactCacheOutput)
|
|
5159
5161
|
+ retainedVectorBytes(contactSupported)
|
|
5160
5162
|
+ retainedVectorBytes(supportEdges)
|
|
5161
|
-
+ retainedVectorBytes(movingFoundation)
|
|
5162
5163
|
+ retainedVectorBytes(deferredDynamicPairs)
|
|
5163
5164
|
+ retainedVectorBytes(collideMemoBodies)
|
|
5164
5165
|
+ retainedVectorBytes(collideMemoPairs)
|
|
@@ -5324,7 +5325,6 @@ void prepareStepStorage(SolverStorage& storage, std::uint32_t bodyCount, std::ui
|
|
|
5324
5325
|
storage.jointConstraintState.resize(jointCount);
|
|
5325
5326
|
storage.contactConstraints.clear();
|
|
5326
5327
|
storage.contactSupported.resize(bodyCount);
|
|
5327
|
-
storage.movingFoundation.resize(bodyCount);
|
|
5328
5328
|
storage.restingSubstepPairCount = 0;
|
|
5329
5329
|
storage.restingSubstepPairCursor = 0;
|
|
5330
5330
|
storage.firstSubstepOfTick = false;
|
|
@@ -8810,8 +8810,6 @@ bool resolveContactPair(SolverOperation& operation,
|
|
|
8810
8810
|
bool usePreparedGeometry = false,
|
|
8811
8811
|
const ContactManifoldPreparation* preparedContact = nullptr,
|
|
8812
8812
|
std::uint32_t contactPointIndex = 0,
|
|
8813
|
-
bool freezeA = false,
|
|
8814
|
-
bool freezeB = false,
|
|
8815
8813
|
double velocityBiasScale = 1.0,
|
|
8816
8814
|
PreparedContactApplications* applications = nullptr,
|
|
8817
8815
|
bool deferVelocitySolve = false) {
|
|
@@ -8841,10 +8839,8 @@ bool resolveContactPair(SolverOperation& operation,
|
|
|
8841
8839
|
const Vec3 normal = usePreparedGeometry
|
|
8842
8840
|
? Vec3{constraint->normal[0], constraint->normal[1], constraint->normal[2]}
|
|
8843
8841
|
: Vec3{contact.nx, contact.ny, contact.nz};
|
|
8844
|
-
const bool
|
|
8845
|
-
const bool
|
|
8846
|
-
const bool responseMovableA = movableA && !freezeA;
|
|
8847
|
-
const bool responseMovableB = movableB && !freezeB;
|
|
8842
|
+
const bool responseMovableA = a.dynamic && !a.sleeping;
|
|
8843
|
+
const bool responseMovableB = b.dynamic && !b.sleeping;
|
|
8848
8844
|
if (!responseMovableA && !responseMovableB) return false;
|
|
8849
8845
|
if (constraint != nullptr && woke[0]) {
|
|
8850
8846
|
operation.storage.constraintMobility[constraint->bodyA] = constraintBodyMobility(a);
|
|
@@ -8940,7 +8936,7 @@ bool resolveContactPair(SolverOperation& operation,
|
|
|
8940
8936
|
: Vec3{});
|
|
8941
8937
|
const Vec3 relative = subtractVec3(contactRelativeVelocity(a, b, rA, rB), S);
|
|
8942
8938
|
const double relativeVelocity = dotVec3(relative, normal);
|
|
8943
|
-
const bool usePreparedMass = usePreparedGeometry
|
|
8939
|
+
const bool usePreparedMass = usePreparedGeometry;
|
|
8944
8940
|
const double normalMass = usePreparedMass
|
|
8945
8941
|
? constraint->normalMass
|
|
8946
8942
|
: contactEffectiveMass(rA, rB, normal);
|
|
@@ -9040,8 +9036,6 @@ inline bool solvePreparedContact(
|
|
|
9040
9036
|
const ConstraintBodyMobility& mobilityA,
|
|
9041
9037
|
const ConstraintBodyMobility& mobilityB,
|
|
9042
9038
|
ContactConstraintBlock& constraint,
|
|
9043
|
-
bool freezeA,
|
|
9044
|
-
bool freezeB,
|
|
9045
9039
|
double& normalTotalOutput,
|
|
9046
9040
|
double& tangentTotal1Output,
|
|
9047
9041
|
double& tangentTotal2Output,
|
|
@@ -9050,41 +9044,27 @@ inline bool solvePreparedContact(
|
|
|
9050
9044
|
ContactResponsePhase phase = ContactResponsePhase::Continued) {
|
|
9051
9045
|
if (phase != ContactResponsePhase::Fresh && phase != ContactResponsePhase::Continued)
|
|
9052
9046
|
throw TriangleNativeFailure{triangle_private::Failure::InvalidInput};
|
|
9053
|
-
|
|
9054
|
-
|
|
9047
|
+
// Every contact impulse acts on both bodies, equal and opposite. There is no frozen body: a
|
|
9048
|
+
// one-sided impulse does not conserve momentum. Tall stacks hold through iterations instead (the
|
|
9049
|
+
// supported-structure floor in resolveSoAContacts).
|
|
9050
|
+
const bool movableA = a.dynamic && !a.sleeping;
|
|
9051
|
+
const bool movableB = b.dynamic && !b.sleeping;
|
|
9055
9052
|
if (!movableA && !movableB) return false;
|
|
9056
9053
|
|
|
9057
9054
|
const Vec3 normal{constraint.normal[0], constraint.normal[1], constraint.normal[2]};
|
|
9058
9055
|
const auto contactLevers=triangle_adapter_private::constraintLevers(operation,constraint,a,b,explicitBasis);
|
|
9059
9056
|
const Vec3 rA=contactLevers[0],rB=contactLevers[1];
|
|
9060
|
-
const auto effectiveMass = [&](const Vec3& direction, double prepared) {
|
|
9061
|
-
return !freezeA && !freezeB
|
|
9062
|
-
? prepared
|
|
9063
|
-
: effectiveContactMass(
|
|
9064
|
-
mobilityA, mobilityB, movableA, movableB, rA, rB, direction);
|
|
9065
|
-
};
|
|
9066
9057
|
const auto applyImpulse = [&](const Vec3& impulse) {
|
|
9067
9058
|
captureStartingContactApplication(operation, &constraint, rA, rB, impulse);
|
|
9068
9059
|
captureContactApplication(applications, rA, rB, impulse);
|
|
9069
9060
|
applyContactImpulse(
|
|
9070
9061
|
a, b, mobilityA, mobilityB, movableA, movableB, rA, rB, impulse);
|
|
9071
9062
|
};
|
|
9072
|
-
// A frozen support body takes no normal impulse, so a stack cannot press it down, but friction
|
|
9073
|
-
// acts on both bodies. Friction against a frozen body moved the upper body with the lower one and
|
|
9074
|
-
// gave nothing back: a knocked or torch-cut crate stack kept moving at about 0.1 m/s forever.
|
|
9075
|
-
const bool frictionMovableA = a.dynamic && !a.sleeping;
|
|
9076
|
-
const bool frictionMovableB = b.dynamic && !b.sleeping;
|
|
9077
|
-
const auto applyFrictionImpulse = [&](const Vec3& impulse) {
|
|
9078
|
-
captureStartingContactApplication(operation, &constraint, rA, rB, impulse);
|
|
9079
|
-
captureContactApplication(applications, rA, rB, impulse);
|
|
9080
|
-
applyContactImpulse(
|
|
9081
|
-
a, b, mobilityA, mobilityB, frictionMovableA, frictionMovableB, rA, rB, impulse);
|
|
9082
|
-
};
|
|
9083
9063
|
|
|
9084
9064
|
const Vec3 S{constraint.materialVelocity[0], constraint.materialVelocity[1], constraint.materialVelocity[2]};
|
|
9085
9065
|
const Vec3 relative = subtractVec3(contactRelativeVelocity(a, b, rA, rB), S);
|
|
9086
9066
|
const double relativeVelocity = dotVec3(relative, normal);
|
|
9087
|
-
const double normalMass =
|
|
9067
|
+
const double normalMass = constraint.normalMass;
|
|
9088
9068
|
const double oldNormal = constraint.impulses[0];
|
|
9089
9069
|
const double normalTotal = normalMass > 0.0
|
|
9090
9070
|
? std::max(0.0,
|
|
@@ -9099,7 +9079,7 @@ inline bool solvePreparedContact(
|
|
|
9099
9079
|
contactTangentBasis(normal, tangent1, tangent2);
|
|
9100
9080
|
if (normalTotal <= 0.0) {
|
|
9101
9081
|
if (constraint.impulses[1] != 0.0 || constraint.impulses[2] != 0.0) {
|
|
9102
|
-
|
|
9082
|
+
applyImpulse(addVec3(
|
|
9103
9083
|
scaleVec3(tangent1, -constraint.impulses[1]),
|
|
9104
9084
|
scaleVec3(tangent2, -constraint.impulses[2])));
|
|
9105
9085
|
constraint.impulses[1] = 0.0;
|
|
@@ -9134,7 +9114,7 @@ inline bool solvePreparedContact(
|
|
|
9134
9114
|
constraint.impulses[2] = tangentTotal2;
|
|
9135
9115
|
tangentTotal1Output = tangentTotal1;
|
|
9136
9116
|
tangentTotal2Output = tangentTotal2;
|
|
9137
|
-
|
|
9117
|
+
applyImpulse(addVec3(
|
|
9138
9118
|
scaleVec3(tangent1, tangentTotal1 - oldTangent1),
|
|
9139
9119
|
scaleVec3(tangent2, tangentTotal2 - oldTangent2)));
|
|
9140
9120
|
if (phase == ContactResponsePhase::Fresh) {
|
|
@@ -11427,6 +11407,21 @@ void captureStartingWarmApplication(SolverOperation& operation, std::uint32_t fi
|
|
|
11427
11407
|
const Vec3& point, const Vec3& rA, const Vec3& rB, const Vec3& normal,
|
|
11428
11408
|
const PreparedWarmContactApplication& prepared);
|
|
11429
11409
|
|
|
11410
|
+
// Box and compound (voxel box) bodies touch with flat faces, so their contact points persist from
|
|
11411
|
+
// substep to substep, and the accumulated impulse of the last solve is the start of the next one at
|
|
11412
|
+
// any orientation. Up to rc.64 only box pairs kept it, with a normal within 3.6 degrees of vertical
|
|
11413
|
+
// and no sliding foundation below; compound crates, side contacts between columns, tilted contacts
|
|
11414
|
+
// and contacts above a sliding foundation started from the closing-speed impulse alone, so a crate
|
|
11415
|
+
// stack held its load only while the frozen-support rule pushed one body. A curved contact moves
|
|
11416
|
+
// every substep, so its warm start stays limited to the impulse that stops the current closing
|
|
11417
|
+
// speed: a five-tire stack with the full cached impulse fell apart in 120 of 192 corpus runs.
|
|
11418
|
+
bool persistentFaceContact(const Body& a, const Body& b) {
|
|
11419
|
+
const auto flat = [](const Body& body) {
|
|
11420
|
+
return body.shape == ShapeKind::Box || body.shape == ShapeKind::Compound;
|
|
11421
|
+
};
|
|
11422
|
+
return flat(a) && flat(b);
|
|
11423
|
+
}
|
|
11424
|
+
|
|
11430
11425
|
PreparedWarmContactApplication prepareWarmContactApplication(const Body& a, const Body& b,
|
|
11431
11426
|
bool movableA, bool movableB, const Vec3& rA, const Vec3& rB, const Vec3& normal,
|
|
11432
11427
|
const std::array<double, 3>& cachedImpulses, bool isSmallWorld = false) {
|
|
@@ -11436,15 +11431,14 @@ PreparedWarmContactApplication prepareWarmContactApplication(const Body& a, cons
|
|
|
11436
11431
|
contactTangentBasis(normal, tangent1, tangent2);
|
|
11437
11432
|
|
|
11438
11433
|
if (isSmallWorld) {
|
|
11439
|
-
const bool isPlanarPair = (a
|
|
11434
|
+
const bool isPlanarPair = persistentFaceContact(a, b);
|
|
11440
11435
|
const double relVx = a.vx - b.vx;
|
|
11441
11436
|
const double relVy = a.vy - b.vy;
|
|
11442
11437
|
const double relVz = a.vz - b.vz;
|
|
11443
11438
|
const double relHorizSpeedSq = relVx * relVx + relVz * relVz;
|
|
11444
11439
|
const bool isDynamicMotion = (a.dynamic && a.vy < -1.5) || (b.dynamic && b.vy < -1.5);
|
|
11445
11440
|
const double closingVelocity = -dotVec3(contactRelativeVelocity(a, b, rA, rB), normal);
|
|
11446
|
-
const bool useRestingPlanar = isPlanarPair && !isDynamicMotion &&
|
|
11447
|
-
&& closingVelocity >= -0.35;
|
|
11441
|
+
const bool useRestingPlanar = isPlanarPair && !isDynamicMotion && closingVelocity >= -0.35;
|
|
11448
11442
|
|
|
11449
11443
|
double appliedNormal = 0.0;
|
|
11450
11444
|
double appliedTangent1 = 0.0;
|
|
@@ -11856,10 +11850,13 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
11856
11850
|
std::remove_if(
|
|
11857
11851
|
operation.storage.contactConstraints.begin(),
|
|
11858
11852
|
operation.storage.contactConstraints.end(),
|
|
11859
|
-
[](const ContactConstraintBlock& constraint) {
|
|
11853
|
+
[&](const ContactConstraintBlock& constraint) {
|
|
11860
11854
|
if (constraint.preserveForCache) return false;
|
|
11861
11855
|
if (!constraint.activeForVelocityPhase) return true;
|
|
11862
|
-
|
|
11856
|
+
// A side contact between faces keeps its impulse (persistentFaceContact).
|
|
11857
|
+
return std::abs(constraint.normal[1]) < 0.7
|
|
11858
|
+
&& (constraint.bodyA >= bodyCount || constraint.bodyB >= bodyCount
|
|
11859
|
+
|| !persistentFaceContact(bodies[constraint.bodyA], bodies[constraint.bodyB]));
|
|
11863
11860
|
}),
|
|
11864
11861
|
operation.storage.contactConstraints.end());
|
|
11865
11862
|
for (auto& constraint : operation.storage.contactConstraints) {
|
|
@@ -11913,55 +11910,27 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
11913
11910
|
});
|
|
11914
11911
|
}
|
|
11915
11912
|
if (beginSubstep && !firstTickSubstep && solveVelocity && isSmallCandidateWorld) {
|
|
11916
|
-
|
|
11917
|
-
|
|
11918
|
-
|
|
11919
|
-
|
|
11920
|
-
|
|
11921
|
-
|
|
11922
|
-
|
|
11923
|
-
|
|
11924
|
-
|
|
11925
|
-
|
|
11926
|
-
|
|
11927
|
-
|
|
11928
|
-
|
|
11929
|
-
|
|
11930
|
-
|
|
11931
|
-
|
|
11932
|
-
|
|
11933
|
-
movingFoundation[bA] = 1;
|
|
11934
|
-
}
|
|
11935
|
-
}
|
|
11936
|
-
for (std::uint32_t pass = 0; pass < 12; ++pass) {
|
|
11937
|
-
bool changed = false;
|
|
11938
|
-
for (std::uint32_t index = 0; index < operation.storage.contactConstraintCount; ++index) {
|
|
11939
|
-
const ContactConstraintBlock& constraint = operation.storage.contactConstraints[index];
|
|
11940
|
-
const std::uint32_t bA = constraint.bodyA;
|
|
11941
|
-
const std::uint32_t bB = constraint.bodyB;
|
|
11942
|
-
if (bA >= bodyCount || bB >= bodyCount) continue;
|
|
11943
|
-
if (std::abs(constraint.normal[1]) < 0.7) continue;
|
|
11944
|
-
const Body& a = bodies[bA];
|
|
11945
|
-
const Body& b = bodies[bB];
|
|
11946
|
-
if (a.y > b.y + 0.1 && movingFoundation[bB] && !movingFoundation[bA]) {
|
|
11947
|
-
movingFoundation[bA] = 1;
|
|
11948
|
-
changed = true;
|
|
11949
|
-
} else if (b.y > a.y + 0.1 && movingFoundation[bA] && !movingFoundation[bB]) {
|
|
11950
|
-
movingFoundation[bB] = 1;
|
|
11951
|
-
changed = true;
|
|
11952
|
-
}
|
|
11953
|
-
}
|
|
11954
|
-
if (!changed) break;
|
|
11955
|
-
}
|
|
11956
|
-
|
|
11957
|
-
std::uint32_t cachedFirst = std::numeric_limits<std::uint32_t>::max();
|
|
11958
|
-
std::uint32_t cachedSecond = std::numeric_limits<std::uint32_t>::max();
|
|
11959
|
-
Collision cachedContact{};
|
|
11913
|
+
// A later substep warm-starts each face contact before the first solve, from the point, normal
|
|
11914
|
+
// and impulse that the last solve left in it. The collecting pass collides the pair anyway and
|
|
11915
|
+
// matches the contact (findPendingConstraintNear) or takes its impulse back
|
|
11916
|
+
// (withdrawUnmatchedWarmStarts). Up to rc.64 this block collided every pair a second time; with
|
|
11917
|
+
// compound crates warm-started too, that was 658 more collisions per step on the 300kb bench
|
|
11918
|
+
// (rc.64 makes 1687 in all). CCD bodies (bullets) and
|
|
11919
|
+
// material-motion contacts are collided again here: from an old point and normal a CCD box
|
|
11920
|
+
// pressed into a wall corner failed the step at 30 to 45 m/s, and a material contact needs the
|
|
11921
|
+
// manifold basis of a fresh collision. Every warm start comes before the first solve: applied
|
|
11922
|
+
// pair by pair in the collecting pass, the solve of the floor contact undid the warm start of a
|
|
11923
|
+
// ten-crate column before the crates above it had theirs, and the column sank at 0.12 m/s.
|
|
11924
|
+
std::uint32_t writeIndex = 0;
|
|
11925
|
+
std::uint32_t runFirst = std::numeric_limits<std::uint32_t>::max();
|
|
11926
|
+
std::uint32_t runSecond = std::numeric_limits<std::uint32_t>::max();
|
|
11927
|
+
std::uint32_t runPoints = 0;
|
|
11928
|
+
bool runCollided = false;
|
|
11929
|
+
Collision runContact{};
|
|
11960
11930
|
std::uint32_t usedPointMask = 0;
|
|
11961
11931
|
bool anyFeatureIdChanged = false;
|
|
11962
11932
|
Body preWarmA{};
|
|
11963
11933
|
Body preWarmB{};
|
|
11964
|
-
std::uint32_t writeIndex = 0;
|
|
11965
11934
|
const auto skipConstraint = [&](ContactConstraintBlock& c) {
|
|
11966
11935
|
if (!isLargeStackWorld) {
|
|
11967
11936
|
c.impulses.fill(0.0);
|
|
@@ -11989,6 +11958,20 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
11989
11958
|
}
|
|
11990
11959
|
Body& a = bodies[bodyA];
|
|
11991
11960
|
Body& b = bodies[bodyB];
|
|
11961
|
+
if (runFirst != bodyA || runSecond != bodyB) {
|
|
11962
|
+
runFirst = bodyA;
|
|
11963
|
+
runSecond = bodyB;
|
|
11964
|
+
runPoints = 0;
|
|
11965
|
+
for (std::uint32_t scan = index; scan < operation.storage.contactConstraintCount
|
|
11966
|
+
&& operation.storage.contactConstraints[scan].bodyA == bodyA
|
|
11967
|
+
&& operation.storage.contactConstraints[scan].bodyB == bodyB; ++scan) {
|
|
11968
|
+
if (!operation.storage.contactConstraints[scan].preserveForCache) runPoints += 1;
|
|
11969
|
+
}
|
|
11970
|
+
runCollided = false;
|
|
11971
|
+
usedPointMask = 0;
|
|
11972
|
+
preWarmA = a;
|
|
11973
|
+
preWarmB = b;
|
|
11974
|
+
}
|
|
11992
11975
|
const bool movableA = a.dynamic && !a.sleeping;
|
|
11993
11976
|
const bool movableB = b.dynamic && !b.sleeping;
|
|
11994
11977
|
if (!movableA && !movableB) {
|
|
@@ -11999,88 +11982,88 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
11999
11982
|
skipConstraint(constraintRef);
|
|
12000
11983
|
continue;
|
|
12001
11984
|
}
|
|
12002
|
-
|
|
12003
|
-
if (!isPlanarPair) {
|
|
11985
|
+
if (!persistentFaceContact(a, b)) {
|
|
12004
11986
|
skipConstraint(constraintRef);
|
|
12005
11987
|
continue;
|
|
12006
11988
|
}
|
|
12007
|
-
|
|
12008
11989
|
const bool pairHasJoint = bodyA < operation.storage.bodyJointAffected.size()
|
|
12009
11990
|
&& bodyB < operation.storage.bodyJointAffected.size()
|
|
12010
11991
|
&& (operation.storage.bodyJointAffected[bodyA] != 0 || operation.storage.bodyJointAffected[bodyB] != 0);
|
|
12011
|
-
if (cachedFirst != bodyA || cachedSecond != bodyB) {
|
|
12012
|
-
cachedFirst = bodyA;
|
|
12013
|
-
cachedSecond = bodyB;
|
|
12014
|
-
cachedContact = collide(operation, a, b);
|
|
12015
|
-
usedPointMask = 0;
|
|
12016
|
-
preWarmA = a;
|
|
12017
|
-
preWarmB = b;
|
|
12018
|
-
}
|
|
12019
11992
|
const bool usePreWarm = isLargeStackWorld && !pairHasJoint;
|
|
12020
11993
|
const Body& warmA = usePreWarm ? preWarmA : a;
|
|
12021
11994
|
const Body& warmB = usePreWarm ? preWarmB : b;
|
|
12022
|
-
|
|
12023
11995
|
const double relVx = warmA.vx - warmB.vx;
|
|
12024
|
-
const double relVy = warmA.vy - warmB.vy;
|
|
12025
11996
|
const double relVz = warmA.vz - warmB.vz;
|
|
12026
11997
|
const double relHorizSpeedSq = relVx * relVx + relVz * relVz;
|
|
12027
11998
|
const bool isDynamicMotion = (warmA.dynamic && warmA.vy < -1.5) || (warmB.dynamic && warmB.vy < -1.5);
|
|
12028
|
-
|
|
12029
|
-
if (isDynamicMotion || movingFoundation[bodyA] || movingFoundation[bodyB] || relHorizSpeedSq >= 0.55 * 0.55) {
|
|
12030
|
-
skipConstraint(constraintRef);
|
|
12031
|
-
continue;
|
|
12032
|
-
}
|
|
12033
|
-
const Collision& contact = cachedContact;
|
|
12034
|
-
if (!contact.hit || std::abs(contact.ny) < 0.998) {
|
|
11999
|
+
if (isDynamicMotion || relHorizSpeedSq >= 0.55 * 0.55) {
|
|
12035
12000
|
skipConstraint(constraintRef);
|
|
12036
12001
|
continue;
|
|
12037
12002
|
}
|
|
12038
|
-
|
|
12039
|
-
|
|
12040
|
-
|
|
12041
|
-
|
|
12042
|
-
|
|
12043
|
-
|
|
12044
|
-
|
|
12003
|
+
const bool fromStoredContact = !a.bullet && !b.bullet && operation.materialMotionEpochs == nullptr;
|
|
12004
|
+
Vec3 normal{constraintRef.normal[0], constraintRef.normal[1], constraintRef.normal[2]};
|
|
12005
|
+
Vec3 point{constraintRef.point[0], constraintRef.point[1], constraintRef.point[2]};
|
|
12006
|
+
Vec3 rA;
|
|
12007
|
+
Vec3 rB;
|
|
12008
|
+
std::uint32_t manifoldPoints = runPoints;
|
|
12009
|
+
if (fromStoredContact) {
|
|
12010
|
+
const auto levers = triangle_adapter_private::constraintLevers(operation, constraintRef, a, b);
|
|
12011
|
+
rA = levers[0];
|
|
12012
|
+
rB = levers[1];
|
|
12013
|
+
} else {
|
|
12014
|
+
if (!runCollided) {
|
|
12015
|
+
runContact = collide(operation, a, b);
|
|
12016
|
+
runCollided = true;
|
|
12045
12017
|
}
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
for (std::uint32_t candidate = 0; candidate < contactPointCount(
|
|
12018
|
+
if (!runContact.hit) {
|
|
12019
|
+
skipConstraint(constraintRef);
|
|
12020
|
+
continue;
|
|
12021
|
+
}
|
|
12022
|
+
std::uint32_t pointIndex = contactPointCount(runContact);
|
|
12023
|
+
for (std::uint32_t candidate = 0; candidate < contactPointCount(runContact); candidate += 1) {
|
|
12052
12024
|
if ((usedPointMask & (1u << candidate)) != 0) continue;
|
|
12053
|
-
|
|
12054
|
-
const Vec3 delta = subtractVec3(candidatePoint, cachedPoint);
|
|
12055
|
-
const double distanceSquared = dotVec3(delta, delta);
|
|
12056
|
-
if (distanceSquared <= bestDistanceSquared) {
|
|
12057
|
-
bestDistanceSquared = distanceSquared;
|
|
12025
|
+
if (contactFeatureId(runContact, candidate) == constraintRef.featureId) {
|
|
12058
12026
|
pointIndex = candidate;
|
|
12027
|
+
break;
|
|
12059
12028
|
}
|
|
12060
12029
|
}
|
|
12030
|
+
if (pointIndex == contactPointCount(runContact) && finite(point.x) && finite(point.y) && finite(point.z)) {
|
|
12031
|
+
constexpr double kMaxCornerDriftSquared = 0.02 * 0.02;
|
|
12032
|
+
double bestDistanceSquared = kMaxCornerDriftSquared;
|
|
12033
|
+
for (std::uint32_t candidate = 0; candidate < contactPointCount(runContact); candidate += 1) {
|
|
12034
|
+
if ((usedPointMask & (1u << candidate)) != 0) continue;
|
|
12035
|
+
const Vec3 delta = subtractVec3(contactPoint(runContact, a, b, candidate), point);
|
|
12036
|
+
const double distanceSquared = dotVec3(delta, delta);
|
|
12037
|
+
if (distanceSquared <= bestDistanceSquared) {
|
|
12038
|
+
bestDistanceSquared = distanceSquared;
|
|
12039
|
+
pointIndex = candidate;
|
|
12040
|
+
}
|
|
12041
|
+
}
|
|
12042
|
+
}
|
|
12043
|
+
if (pointIndex == contactPointCount(runContact)) {
|
|
12044
|
+
skipConstraint(constraintRef);
|
|
12045
|
+
continue;
|
|
12046
|
+
}
|
|
12047
|
+
usedPointMask |= (1u << pointIndex);
|
|
12048
|
+
const std::uint32_t matchedFeatureId = contactFeatureId(runContact, pointIndex);
|
|
12049
|
+
if (constraintRef.featureId != matchedFeatureId) {
|
|
12050
|
+
constraintRef.featureId = matchedFeatureId;
|
|
12051
|
+
anyFeatureIdChanged = true;
|
|
12052
|
+
}
|
|
12053
|
+
point = contactPoint(runContact, a, b, pointIndex);
|
|
12054
|
+
const auto levers = triangle_adapter_private::collisionLevers(
|
|
12055
|
+
operation, runContact, pointIndex, a, b, point);
|
|
12056
|
+
rA = levers[0];
|
|
12057
|
+
rB = levers[1];
|
|
12058
|
+
normal = Vec3{runContact.nx, runContact.ny, runContact.nz};
|
|
12059
|
+
manifoldPoints = contactPointCount(runContact);
|
|
12061
12060
|
}
|
|
12062
|
-
if (pointIndex == contactPointCount(contact)) {
|
|
12063
|
-
skipConstraint(constraintRef);
|
|
12064
|
-
continue;
|
|
12065
|
-
}
|
|
12066
|
-
usedPointMask |= (1u << pointIndex);
|
|
12067
|
-
const std::uint32_t matchedFeatureId = contactFeatureId(contact, pointIndex);
|
|
12068
|
-
if (constraintRef.featureId != matchedFeatureId) {
|
|
12069
|
-
constraintRef.featureId = matchedFeatureId;
|
|
12070
|
-
anyFeatureIdChanged = true;
|
|
12071
|
-
}
|
|
12072
|
-
const Vec3 point = contactPoint(contact, a, b, pointIndex);
|
|
12073
|
-
const auto contactLevers = triangle_adapter_private::collisionLevers(
|
|
12074
|
-
operation, contact, pointIndex, a, b, point);
|
|
12075
|
-
const Vec3 rA = contactLevers[0];
|
|
12076
|
-
const Vec3 rB = contactLevers[1];
|
|
12077
|
-
const Vec3 normal{contact.nx, contact.ny, contact.nz};
|
|
12078
12061
|
const double closingSpeed = -dotVec3(contactRelativeVelocity(warmA, warmB, rA, rB), normal);
|
|
12079
12062
|
if (closingSpeed >= 2.0) {
|
|
12080
12063
|
skipConstraint(constraintRef);
|
|
12081
12064
|
continue;
|
|
12082
12065
|
}
|
|
12083
|
-
if (
|
|
12066
|
+
if (manifoldPoints == 1
|
|
12084
12067
|
&& (isLargeStackWorld
|
|
12085
12068
|
? ((movableA && (rA.x * rA.x + rA.z * rA.z >= 0.20 * 0.20))
|
|
12086
12069
|
|| (movableB && (rB.x * rB.x + rB.z * rB.z >= 0.20 * 0.20)))
|
|
@@ -12088,22 +12071,34 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12088
12071
|
skipConstraint(constraintRef);
|
|
12089
12072
|
continue;
|
|
12090
12073
|
}
|
|
12091
|
-
|
|
12074
|
+
const double maxSubstepImpulse = (!a.dynamic || !b.dynamic) ? 1.25 : 0.75;
|
|
12092
12075
|
std::array<double, 3> laterImpulses = constraintRef.impulses;
|
|
12093
12076
|
laterImpulses[0] = std::min(laterImpulses[0], maxSubstepImpulse);
|
|
12094
|
-
|
|
12095
12077
|
const auto prepared = prepareWarmContactApplication(
|
|
12096
12078
|
warmA, warmB, movableA, movableB, rA, rB, normal, laterImpulses, true);
|
|
12097
12079
|
applyWarmContactApplication(a, b, movableA, movableB, rA, rB, prepared);
|
|
12098
12080
|
constraintRef.impulses = prepared.impulses;
|
|
12099
|
-
|
|
12100
|
-
|
|
12081
|
+
Collision kept;
|
|
12082
|
+
if (fromStoredContact) {
|
|
12083
|
+
constraintRef.warmPending = 1;
|
|
12084
|
+
kept.hit = true;
|
|
12085
|
+
kept.nx = normal.x;
|
|
12086
|
+
kept.ny = normal.y;
|
|
12087
|
+
kept.nz = normal.z;
|
|
12088
|
+
kept.pointX = point.x;
|
|
12089
|
+
kept.pointY = point.y;
|
|
12090
|
+
kept.pointZ = point.z;
|
|
12091
|
+
} else {
|
|
12092
|
+
constraintRef.normal = {normal.x, normal.y, normal.z};
|
|
12093
|
+
constraintRef.point = {point.x, point.y, point.z};
|
|
12094
|
+
}
|
|
12095
|
+
const Collision& outputContact = fromStoredContact ? kept : runContact;
|
|
12101
12096
|
const std::uint32_t orderedFirst = std::min(bodyA, bodyB);
|
|
12102
12097
|
const std::uint32_t orderedSecond = std::max(bodyA, bodyB);
|
|
12103
12098
|
const std::uint32_t outputIndex = recordWorldContactOutput(
|
|
12104
|
-
operation, orderedFirst, orderedSecond,
|
|
12099
|
+
operation, orderedFirst, orderedSecond, outputContact);
|
|
12105
12100
|
const std::uint32_t telemetryIndex = recordContactTelemetry(
|
|
12106
|
-
operation, orderedFirst, orderedSecond,
|
|
12101
|
+
operation, orderedFirst, orderedSecond, outputContact);
|
|
12107
12102
|
if (outputIndex == std::numeric_limits<std::uint32_t>::max()
|
|
12108
12103
|
|| telemetryIndex == std::numeric_limits<std::uint32_t>::max()) {
|
|
12109
12104
|
operation.storage.contactConstraintOverflow = true;
|
|
@@ -12151,8 +12146,53 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12151
12146
|
&& found->featureId == featureId
|
|
12152
12147
|
? &*found : static_cast<ContactConstraintBlock*>(nullptr);
|
|
12153
12148
|
};
|
|
12149
|
+
// A contact warm-started from its stored point whose feature id changed since the last substep
|
|
12150
|
+
// goes to the nearest new point of its pair; withdrawUnmatchedWarmStarts takes back the impulse of
|
|
12151
|
+
// one that no new point takes. With a 2 cm limit, as for the first-substep warm start, a knocked
|
|
12152
|
+
// stack lost the warm start of the contacts that slid (kick: median 7 s with the withdrawal, 4 s
|
|
12153
|
+
// with the nearest point).
|
|
12154
|
+
const auto findPendingConstraintNear = [&](std::uint32_t first, std::uint32_t second,
|
|
12155
|
+
const Vec3& point, std::uint32_t constraintCount) {
|
|
12156
|
+
auto begin = operation.storage.contactConstraints.begin();
|
|
12157
|
+
auto end = begin + constraintCount;
|
|
12158
|
+
auto found = std::lower_bound(begin, end, std::tuple{first, second, 0u},
|
|
12159
|
+
[](const ContactConstraintBlock& block,
|
|
12160
|
+
const std::tuple<std::uint32_t, std::uint32_t, std::uint32_t>& key) {
|
|
12161
|
+
return std::tuple{block.bodyA, block.bodyB, block.featureId} < key;
|
|
12162
|
+
});
|
|
12163
|
+
double bestDistanceSquared = std::numeric_limits<double>::infinity();
|
|
12164
|
+
ContactConstraintBlock* best = nullptr;
|
|
12165
|
+
for (; found != end && found->bodyA == first && found->bodyB == second; ++found) {
|
|
12166
|
+
if (found->warmPending == 0 || found->activeForVelocityPhase) continue;
|
|
12167
|
+
const Vec3 delta = subtractVec3(point, Vec3{found->point[0], found->point[1], found->point[2]});
|
|
12168
|
+
const double distanceSquared = dotVec3(delta, delta);
|
|
12169
|
+
if (distanceSquared <= bestDistanceSquared) {
|
|
12170
|
+
bestDistanceSquared = distanceSquared;
|
|
12171
|
+
best = &*found;
|
|
12172
|
+
}
|
|
12173
|
+
}
|
|
12174
|
+
return best;
|
|
12175
|
+
};
|
|
12176
|
+
// A manifold of two or more points between boxes and cylinders is solved as a block (a centroid
|
|
12177
|
+
// step, then a per-point correction) on every path. Up to rc.64 only box pairs on the stack path
|
|
12178
|
+
// were. Point by point, the four points of a tire on a tire converged so slowly that a five-tire
|
|
12179
|
+
// stack kept rocking unless its support was frozen (tire corpus without the rc.63 frozen-support
|
|
12180
|
+
// rule: 13 of 192 runs never slept; with the block solve, 0), and a ten-box column in a small world
|
|
12181
|
+
// drifted 0.13 m. Compound manifolds stay point by point: the block step adds work on top of the
|
|
12182
|
+
// per-point solve and no gate needed it (14% of the 300kb bench rollback step).
|
|
12183
|
+
const auto solvesManifoldAsBlock = [&](std::uint32_t pointCount, bool pairHasJoint,
|
|
12184
|
+
std::uint32_t first, std::uint32_t second) {
|
|
12185
|
+
const auto blockShape = [](const Body& body) {
|
|
12186
|
+
return body.shape == ShapeKind::Box || body.shape == ShapeKind::Cylinder;
|
|
12187
|
+
};
|
|
12188
|
+
return blockShape(bodies[first]) && blockShape(bodies[second])
|
|
12189
|
+
&& pointCount > 1
|
|
12190
|
+
&& !pairHasJoint
|
|
12191
|
+
&& operation.materialMotionEpochs == nullptr
|
|
12192
|
+
&& operation.startingContactCapture == nullptr;
|
|
12193
|
+
};
|
|
12154
12194
|
const auto solveBodyPair = [&](std::uint32_t first, std::uint32_t second,
|
|
12155
|
-
bool initialize,
|
|
12195
|
+
bool initialize,
|
|
12156
12196
|
std::uint32_t preparedBegin,
|
|
12157
12197
|
std::uint32_t preparedEnd) {
|
|
12158
12198
|
if (initialize && collisionDisabled(operation, first, second)) return;
|
|
@@ -12234,15 +12274,14 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12234
12274
|
return;
|
|
12235
12275
|
}
|
|
12236
12276
|
const auto runBlockManifoldSolve = [&](std::span<ContactConstraintBlock* const> points,
|
|
12237
|
-
bool fA, bool fB,
|
|
12238
12277
|
ContactResponsePhase phase,
|
|
12239
12278
|
double& outNormalDelta,
|
|
12240
12279
|
double& outTangent1Delta,
|
|
12241
12280
|
double& outTangent2Delta) {
|
|
12242
12281
|
Body& a = bodies[first];
|
|
12243
12282
|
Body& b = bodies[second];
|
|
12244
|
-
const bool movableA = a.dynamic && !a.sleeping
|
|
12245
|
-
const bool movableB = b.dynamic && !b.sleeping
|
|
12283
|
+
const bool movableA = a.dynamic && !a.sleeping;
|
|
12284
|
+
const bool movableB = b.dynamic && !b.sleeping;
|
|
12246
12285
|
if (!movableA && !movableB) return false;
|
|
12247
12286
|
const ConstraintBodyMobility& mobilityA = operation.storage.constraintMobility[first];
|
|
12248
12287
|
const ConstraintBodyMobility& mobilityB = operation.storage.constraintMobility[second];
|
|
@@ -12324,9 +12363,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12324
12363
|
ContactConstraintBlock& c = *points[i];
|
|
12325
12364
|
const Vec3 rel = subtractVec3(contactRelativeVelocity(a, b, rAList[i], rBList[i]), S);
|
|
12326
12365
|
const double relVel = dotVec3(rel, normal);
|
|
12327
|
-
const double normalMass =
|
|
12328
|
-
? c.normalMass
|
|
12329
|
-
: effectiveContactMass(mobilityA, mobilityB, movableA, movableB, rAList[i], rBList[i], normal);
|
|
12366
|
+
const double normalMass = c.normalMass;
|
|
12330
12367
|
const double oldN = c.impulses[0];
|
|
12331
12368
|
const double newN = normalMass > 0.0
|
|
12332
12369
|
? std::max(0.0, oldN - (relVel - c.normalTarget) / normalMass)
|
|
@@ -12342,9 +12379,6 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12342
12379
|
Vec3 tangent1;
|
|
12343
12380
|
Vec3 tangent2;
|
|
12344
12381
|
contactTangentBasis(normal, tangent1, tangent2);
|
|
12345
|
-
// Friction acts on both bodies even when the support body is frozen (see solvePreparedContact).
|
|
12346
|
-
const bool frictionMovableA = a.dynamic && !a.sleeping;
|
|
12347
|
-
const bool frictionMovableB = b.dynamic && !b.sleeping;
|
|
12348
12382
|
std::array<double, 4> errT1List{};
|
|
12349
12383
|
std::array<double, 4> errT2List{};
|
|
12350
12384
|
double errT1Avg = 0.0;
|
|
@@ -12365,9 +12399,9 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12365
12399
|
maxErrTDiff = std::max(maxErrTDiff, std::max(std::abs(errT1List[i] - errT1Avg), std::abs(errT2List[i] - errT2Avg)));
|
|
12366
12400
|
}
|
|
12367
12401
|
const double centroidT1Mass = effectiveContactMass(
|
|
12368
|
-
mobilityA, mobilityB,
|
|
12402
|
+
mobilityA, mobilityB, movableA, movableB, rAAvg, rBAvg, tangent1);
|
|
12369
12403
|
const double centroidT2Mass = effectiveContactMass(
|
|
12370
|
-
mobilityA, mobilityB,
|
|
12404
|
+
mobilityA, mobilityB, movableA, movableB, rAAvg, rBAvg, tangent2);
|
|
12371
12405
|
const double symDeltaT1 = centroidT1Mass > 0.0 ? (-errT1Avg / centroidT1Mass) * invCount : 0.0;
|
|
12372
12406
|
const double symDeltaT2 = centroidT2Mass > 0.0 ? (-errT2Avg / centroidT2Mass) * invCount : 0.0;
|
|
12373
12407
|
if (symDeltaT1 != 0.0 || symDeltaT2 != 0.0) {
|
|
@@ -12410,12 +12444,12 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12410
12444
|
sumTorqueA = snapSmallVec(sumTorqueA);
|
|
12411
12445
|
sumTorqueB = snapSmallVec(sumTorqueB);
|
|
12412
12446
|
}
|
|
12413
|
-
const Vec3 linA = inverseLinearMass(mobilityA,
|
|
12414
|
-
const Vec3 linB = inverseLinearMass(mobilityB,
|
|
12447
|
+
const Vec3 linA = inverseLinearMass(mobilityA, movableA);
|
|
12448
|
+
const Vec3 linB = inverseLinearMass(mobilityB, movableB);
|
|
12415
12449
|
a.vx -= sumImpT.x * linA.x; a.vy -= sumImpT.y * linA.y; a.vz -= sumImpT.z * linA.z;
|
|
12416
12450
|
b.vx += sumImpT.x * linB.x; b.vy += sumImpT.y * linB.y; b.vz += sumImpT.z * linB.z;
|
|
12417
|
-
const Vec3 angA = inverseAngularMass(mobilityA,
|
|
12418
|
-
const Vec3 angB = inverseAngularMass(mobilityB,
|
|
12451
|
+
const Vec3 angA = inverseAngularMass(mobilityA, movableA, sumTorqueA);
|
|
12452
|
+
const Vec3 angB = inverseAngularMass(mobilityB, movableB, sumTorqueB);
|
|
12419
12453
|
a.angularVelX -= angA.x; a.angularVelY -= angA.y; a.angularVelZ -= angA.z;
|
|
12420
12454
|
b.angularVelX += angB.x; b.angularVelY += angB.y; b.angularVelZ += angB.z;
|
|
12421
12455
|
outTangent1Delta += sumDT1;
|
|
@@ -12428,7 +12462,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12428
12462
|
double pT1 = 0.0;
|
|
12429
12463
|
double pT2 = 0.0;
|
|
12430
12464
|
const auto prev = c.impulses;
|
|
12431
|
-
if (!solvePreparedContact(operation, a, b, mobilityA, mobilityB, c,
|
|
12465
|
+
if (!solvePreparedContact(operation, a, b, mobilityA, mobilityB, c, pN, pT1, pT2, nullptr, nullptr, phase)) continue;
|
|
12432
12466
|
finishStartingContactActivation(operation, c);
|
|
12433
12467
|
outNormalDelta += pN - prev[0];
|
|
12434
12468
|
outTangent1Delta += pT1 - prev[1];
|
|
@@ -12453,36 +12487,11 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12453
12487
|
manifold[manifoldCount++] = &*iterator;
|
|
12454
12488
|
}
|
|
12455
12489
|
}
|
|
12456
|
-
|
|
12457
|
-
bool freezeB = false;
|
|
12458
|
-
if (stabilizeSupported && manifoldCount != 0) {
|
|
12459
|
-
const Vec3 normal{manifold[0]->normal[0], manifold[0]->normal[1],
|
|
12460
|
-
manifold[0]->normal[2]};
|
|
12461
|
-
const Vec3 gravity{options.gravityX, options.gravityY, options.gravityZ};
|
|
12462
|
-
const double gravityLengthSquared = dotVec3(gravity, gravity);
|
|
12463
|
-
const double supportAlignment = dotVec3(normal, gravity);
|
|
12464
|
-
if (gravityLengthSquared > 1e-18
|
|
12465
|
-
&& supportAlignment * supportAlignment >= gravityLengthSquared * 0.25) {
|
|
12466
|
-
if (supportAlignment < 0.0 && operation.storage.contactSupported[supportIndex(first)] != 0) {
|
|
12467
|
-
freezeA = true;
|
|
12468
|
-
} else if (supportAlignment > 0.0
|
|
12469
|
-
&& operation.storage.contactSupported[supportIndex(second)] != 0) {
|
|
12470
|
-
freezeB = true;
|
|
12471
|
-
}
|
|
12472
|
-
}
|
|
12473
|
-
}
|
|
12474
|
-
const bool canBlockPrestep = isLargeStackWorld
|
|
12475
|
-
&& manifoldCount > 1
|
|
12476
|
-
&& !pairHasJoint
|
|
12477
|
-
&& operation.materialMotionEpochs == nullptr
|
|
12478
|
-
&& operation.startingContactCapture == nullptr
|
|
12479
|
-
&& bodies[first].shape == ShapeKind::Box
|
|
12480
|
-
&& bodies[second].shape == ShapeKind::Box;
|
|
12481
|
-
if (canBlockPrestep) {
|
|
12490
|
+
if (solvesManifoldAsBlock(manifoldCount, pairHasJoint, first, second)) {
|
|
12482
12491
|
double dN = 0.0;
|
|
12483
12492
|
double dT1 = 0.0;
|
|
12484
12493
|
double dT2 = 0.0;
|
|
12485
|
-
if (runBlockManifoldSolve(std::span{manifold.data(), manifoldCount},
|
|
12494
|
+
if (runBlockManifoldSolve(std::span{manifold.data(), manifoldCount},
|
|
12486
12495
|
ContactResponsePhase::Continued, dN, dT1, dT2)) {
|
|
12487
12496
|
worldImpulseDelta = addVec3(worldImpulseDelta, contactImpulse(
|
|
12488
12497
|
Vec3{manifold[0]->normal[0], manifold[0]->normal[1], manifold[0]->normal[2]},
|
|
@@ -12502,7 +12511,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12502
12511
|
bodies[first], bodies[second],
|
|
12503
12512
|
operation.storage.constraintMobility[first],
|
|
12504
12513
|
operation.storage.constraintMobility[second],
|
|
12505
|
-
constraint,
|
|
12514
|
+
constraint,
|
|
12506
12515
|
pointNormal, pointTangent1, pointTangent2)) continue;
|
|
12507
12516
|
finishStartingContactActivation(operation, constraint);
|
|
12508
12517
|
worldImpulseDelta = addVec3(worldImpulseDelta, contactImpulse(
|
|
@@ -12701,13 +12710,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12701
12710
|
if (outputIndex < operation.storage.worldContactMaterialOutput.size()) {
|
|
12702
12711
|
operation.storage.worldContactMaterialOutput[outputIndex] = preparation.materialResult;
|
|
12703
12712
|
}
|
|
12704
|
-
const bool canBlockInit =
|
|
12705
|
-
&& pointCount > 1
|
|
12706
|
-
&& !pairHasJoint
|
|
12707
|
-
&& operation.materialMotionEpochs == nullptr
|
|
12708
|
-
&& operation.startingContactCapture == nullptr
|
|
12709
|
-
&& bodies[first].shape == ShapeKind::Box
|
|
12710
|
-
&& bodies[second].shape == ShapeKind::Box;
|
|
12713
|
+
const bool canBlockInit = solvesManifoldAsBlock(pointCount, pairHasJoint, first, second);
|
|
12711
12714
|
std::array<std::uint32_t, 4> initManifoldIndices{};
|
|
12712
12715
|
std::uint32_t initManifoldCount = 0;
|
|
12713
12716
|
for (std::uint32_t pointIndex = 0; pointIndex < pointCount; pointIndex += 1) {
|
|
@@ -12718,9 +12721,14 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12718
12721
|
candidate.featureId = featureId;
|
|
12719
12722
|
ContactConstraintBlock* existing = findConstraint(
|
|
12720
12723
|
first, second, featureId, seededConstraintCount);
|
|
12724
|
+
if (existing == nullptr) {
|
|
12725
|
+
existing = findPendingConstraintNear(first, second,
|
|
12726
|
+
contactPoint(contact, bodies[first], bodies[second], pointIndex), seededConstraintCount);
|
|
12727
|
+
}
|
|
12721
12728
|
ContactConstraintBlock* constraint = existing == nullptr ? &candidate : existing;
|
|
12722
12729
|
constraint->solveOrder = solveOrder;
|
|
12723
12730
|
const bool preservedForCache = constraint->preserveForCache;
|
|
12731
|
+
constraint->warmPending = 0;
|
|
12724
12732
|
const std::array<double, 3> preservedImpulses = constraint->impulses;
|
|
12725
12733
|
if (preservedForCache) constraint->impulses.fill(0.0);
|
|
12726
12734
|
double pointNormal = 0.0;
|
|
@@ -12731,7 +12739,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12731
12739
|
if (!resolveContactPair(operation, bodies[first], bodies[second], options,
|
|
12732
12740
|
&pointNormal, &pointTangent1, &pointTangent2, nullptr,
|
|
12733
12741
|
constraint, true, shouldApplyPositionCorrection && !corrected, true, false,
|
|
12734
|
-
&preparation, pointIndex,
|
|
12742
|
+
&preparation, pointIndex,
|
|
12735
12743
|
1.0 / static_cast<double>(pointCount), nullptr, canBlockInit)) {
|
|
12736
12744
|
if (preservedForCache) constraint->impulses = preservedImpulses;
|
|
12737
12745
|
continue;
|
|
@@ -12765,7 +12773,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12765
12773
|
}
|
|
12766
12774
|
resolved = runBlockManifoldSolve(
|
|
12767
12775
|
std::span{initManifold.data(), initManifoldCount},
|
|
12768
|
-
|
|
12776
|
+
ContactResponsePhase::Fresh,
|
|
12769
12777
|
normalImpulse, tangentImpulse1, tangentImpulse2);
|
|
12770
12778
|
}
|
|
12771
12779
|
if (!resolved) return;
|
|
@@ -12785,7 +12793,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12785
12793
|
// A pair on a proxy solves on the current copy of its source, and its
|
|
12786
12794
|
// changes reach the source before the next pair is solved.
|
|
12787
12795
|
const auto solvePair = [&](std::uint32_t first, std::uint32_t second,
|
|
12788
|
-
bool initialize,
|
|
12796
|
+
bool initialize,
|
|
12789
12797
|
std::uint32_t preparedBegin,
|
|
12790
12798
|
std::uint32_t preparedEnd) {
|
|
12791
12799
|
if (!solveVelocity && operation.materialMotionEpochs == nullptr
|
|
@@ -12794,7 +12802,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12794
12802
|
return;
|
|
12795
12803
|
}
|
|
12796
12804
|
const ProxyBodySync proxySync{proxyHook, bodies, first, second};
|
|
12797
|
-
solveBodyPair(first, second, initialize,
|
|
12805
|
+
solveBodyPair(first, second, initialize, preparedBegin, preparedEnd);
|
|
12798
12806
|
};
|
|
12799
12807
|
const auto finalizeRestingCacheOrder = [&]() {
|
|
12800
12808
|
if (!operation.storage.firstSubstepOfTick) return;
|
|
@@ -12813,6 +12821,46 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12813
12821
|
}
|
|
12814
12822
|
operation.storage.firstSubstepOfTick = false;
|
|
12815
12823
|
};
|
|
12824
|
+
// A contact warm-started from its stored point that the collecting pass found nowhere in its pair
|
|
12825
|
+
// (the bodies separated or the box tipped off the edge) gives its impulse back before any velocity
|
|
12826
|
+
// iteration, so every applied impulse is either solved or withdrawn. Kept, it held a box that slid
|
|
12827
|
+
// off the end of the Wreck Yard Lost Property belt leaning in the air.
|
|
12828
|
+
const auto withdrawUnmatchedWarmStarts = [&]() {
|
|
12829
|
+
for (std::uint32_t index = 0; index < operation.storage.contactConstraintCount; ++index) {
|
|
12830
|
+
ContactConstraintBlock& constraint = operation.storage.contactConstraints[index];
|
|
12831
|
+
if (constraint.warmPending == 0) continue;
|
|
12832
|
+
constraint.warmPending = 0;
|
|
12833
|
+
if (constraint.activeForVelocityPhase) continue;
|
|
12834
|
+
Body& a = bodies[constraint.bodyA];
|
|
12835
|
+
Body& b = bodies[constraint.bodyB];
|
|
12836
|
+
const bool movableA = a.dynamic && !a.sleeping;
|
|
12837
|
+
const bool movableB = b.dynamic && !b.sleeping;
|
|
12838
|
+
if (!movableA && !movableB) continue;
|
|
12839
|
+
const Vec3 normal{constraint.normal[0], constraint.normal[1], constraint.normal[2]};
|
|
12840
|
+
Vec3 tangent1;
|
|
12841
|
+
Vec3 tangent2;
|
|
12842
|
+
contactTangentBasis(normal, tangent1, tangent2);
|
|
12843
|
+
const Vec3 applied = addVec3(scaleVec3(normal, constraint.impulses[0]),
|
|
12844
|
+
addVec3(scaleVec3(tangent1, constraint.impulses[1]), scaleVec3(tangent2, constraint.impulses[2])));
|
|
12845
|
+
const auto levers = triangle_adapter_private::constraintLevers(operation, constraint, a, b);
|
|
12846
|
+
applyContactImpulse(a, b, movableA, movableB, levers[0], levers[1], scaleVec3(applied, -1.0));
|
|
12847
|
+
// The contact output of the pair counted the warm start; it counts the withdrawal too.
|
|
12848
|
+
Collision kept;
|
|
12849
|
+
kept.hit = true;
|
|
12850
|
+
kept.nx = normal.x;
|
|
12851
|
+
kept.ny = normal.y;
|
|
12852
|
+
kept.nz = normal.z;
|
|
12853
|
+
kept.pointX = constraint.point[0];
|
|
12854
|
+
kept.pointY = constraint.point[1];
|
|
12855
|
+
kept.pointZ = constraint.point[2];
|
|
12856
|
+
const std::uint32_t orderedFirst = std::min(constraint.bodyA, static_cast<std::uint32_t>(constraint.bodyB));
|
|
12857
|
+
const std::uint32_t orderedSecond = std::max(constraint.bodyA, static_cast<std::uint32_t>(constraint.bodyB));
|
|
12858
|
+
accumulateContactOutput(operation,
|
|
12859
|
+
recordWorldContactOutput(operation, orderedFirst, orderedSecond, kept),
|
|
12860
|
+
recordContactTelemetry(operation, orderedFirst, orderedSecond, kept), scaleVec3(applied, -1.0));
|
|
12861
|
+
constraint.impulses.fill(0.0);
|
|
12862
|
+
}
|
|
12863
|
+
};
|
|
12816
12864
|
const auto indexPreparedPairs = [&]() {
|
|
12817
12865
|
std::uint32_t begin = 0;
|
|
12818
12866
|
while (begin < operation.storage.contactConstraintCount) {
|
|
@@ -12866,8 +12914,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12866
12914
|
}
|
|
12867
12915
|
}
|
|
12868
12916
|
};
|
|
12869
|
-
const auto solvePreparedConstraints = [&](
|
|
12870
|
-
if (stabilizeSupported) propagateContactSupport();
|
|
12917
|
+
const auto solvePreparedConstraints = [&]() {
|
|
12871
12918
|
for (std::uint32_t order = operation.storage.contactSolvePairCount;
|
|
12872
12919
|
order > 0; order -= 1) {
|
|
12873
12920
|
const std::uint32_t begin = operation.storage.contactSolvePairBegin[order - 1];
|
|
@@ -12877,7 +12924,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12877
12924
|
operation.storage.contactConstraints[begin];
|
|
12878
12925
|
const std::uint32_t first = firstConstraint.bodyA;
|
|
12879
12926
|
const std::uint32_t second = firstConstraint.bodyB;
|
|
12880
|
-
solvePair(first, second, false,
|
|
12927
|
+
solvePair(first, second, false, begin, end);
|
|
12881
12928
|
}
|
|
12882
12929
|
};
|
|
12883
12930
|
// Curved contacts move from tick to tick, so their warm start carries less than a box face's and
|
|
@@ -12893,15 +12940,21 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12893
12940
|
// its loop marks the last call, and the extra passes come before that iteration's joint and
|
|
12894
12941
|
// portal work, as on the standalone path.
|
|
12895
12942
|
//
|
|
12896
|
-
// A pair inside a supported structure (each body static, kinematic, or resting on support,
|
|
12897
|
-
//
|
|
12898
|
-
//
|
|
12899
|
-
//
|
|
12900
|
-
//
|
|
12943
|
+
// A pair inside a supported structure (each body static, kinematic, or resting on support, side
|
|
12944
|
+
// contacts included) reaches 16 iterations. Every contact impulse acts on both bodies, so the
|
|
12945
|
+
// load of a tall stack reaches its base only through iterations. Measured on 400-crate stacks
|
|
12946
|
+
// and the Wreck Yard torch: with 6 a stack of crates tilted up to 2 degrees fell on every
|
|
12947
|
+
// seed and the torch collapsed the bay; with 12 one tilted stack in eight dropped 18 crates; 16
|
|
12948
|
+
// and 24 settled every seed, and 16 settled tilted and yawed stacks no later than 24 (a kicked
|
|
12949
|
+
// stack: median 4 s at 16, 3 to 4 s at 24).
|
|
12901
12950
|
constexpr std::uint32_t kCylinderMinimumVelocityIterations = 24;
|
|
12951
|
+
constexpr std::uint32_t kSupportedMinimumVelocityIterations = 16;
|
|
12902
12952
|
const std::uint32_t cylinderExtraVelocityIterations =
|
|
12903
12953
|
options.velocityIterations < kCylinderMinimumVelocityIterations
|
|
12904
12954
|
? kCylinderMinimumVelocityIterations - options.velocityIterations : 0;
|
|
12955
|
+
const std::uint32_t supportedExtraVelocityIterations =
|
|
12956
|
+
options.velocityIterations < kSupportedMinimumVelocityIterations
|
|
12957
|
+
? kSupportedMinimumVelocityIterations - options.velocityIterations : 0;
|
|
12905
12958
|
const bool cylinderExtraIterations = solveVelocity && options.velocityIterations > 1
|
|
12906
12959
|
&& cylinderExtraVelocityIterations != 0
|
|
12907
12960
|
&& (pass == ContactPass::StandaloneFirstTick || pass == ContactPass::StandaloneLaterSubstep
|
|
@@ -12912,7 +12965,11 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12912
12965
|
};
|
|
12913
12966
|
return (bodies[first].dynamic || bodies[second].dynamic) && supported(first) && supported(second);
|
|
12914
12967
|
};
|
|
12915
|
-
|
|
12968
|
+
// One extra pass. It returns false when it solved no pair; a later pass solves a subset of the
|
|
12969
|
+
// pairs of an earlier one, so the loop can stop there.
|
|
12970
|
+
const auto solvePreparedCylinderConstraints = [&](std::uint32_t extra) {
|
|
12971
|
+
const bool supportedPass = extra < supportedExtraVelocityIterations;
|
|
12972
|
+
bool solvedAny = false;
|
|
12916
12973
|
propagateContactSupport();
|
|
12917
12974
|
for (std::uint32_t order = operation.storage.contactSolvePairCount;
|
|
12918
12975
|
order > 0; order -= 1) {
|
|
@@ -12924,9 +12981,11 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12924
12981
|
const std::uint32_t first = firstConstraint.bodyA;
|
|
12925
12982
|
const std::uint32_t second = firstConstraint.bodyB;
|
|
12926
12983
|
if (bodies[first].shape != ShapeKind::Cylinder && bodies[second].shape != ShapeKind::Cylinder
|
|
12927
|
-
&& !isSupportPair(first, second)) continue;
|
|
12928
|
-
solvePair(first, second, false,
|
|
12984
|
+
&& !(supportedPass && isSupportPair(first, second))) continue;
|
|
12985
|
+
solvePair(first, second, false, begin, end);
|
|
12986
|
+
solvedAny = true;
|
|
12929
12987
|
}
|
|
12988
|
+
return solvedAny;
|
|
12930
12989
|
};
|
|
12931
12990
|
// In tree mode (N >= 256) the collecting iteration solves the contacts with a static or kinematic
|
|
12932
12991
|
// body first, then the contacts between dynamic bodies, each group in broadphase order; later
|
|
@@ -12958,8 +13017,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12958
13017
|
for (std::uint32_t iteration = 0; iteration < velocityIterations; iteration += 1) {
|
|
12959
13018
|
auto solveCollectedPair = [&](std::uint32_t first, std::uint32_t second) {
|
|
12960
13019
|
solvePair(first, second,
|
|
12961
|
-
!solveVelocity || ((beginSubstep || preparedSubstep) && iteration == 0),
|
|
12962
|
-
iteration != 0, 0, 0);
|
|
13020
|
+
!solveVelocity || ((beginSubstep || preparedSubstep) && iteration == 0), 0, 0);
|
|
12963
13021
|
};
|
|
12964
13022
|
if (!solveVelocity || ((beginSubstep || preparedSubstep) && iteration == 0)) {
|
|
12965
13023
|
if (operation.storage.broadphasePairOverflow) {
|
|
@@ -12973,7 +13031,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12973
13031
|
forEachCollectedSweepPair(operation, solveCollectedPair);
|
|
12974
13032
|
}
|
|
12975
13033
|
} else {
|
|
12976
|
-
solvePreparedConstraints(
|
|
13034
|
+
solvePreparedConstraints();
|
|
12977
13035
|
}
|
|
12978
13036
|
if (solveVelocity && (beginSubstep || preparedSubstep) && iteration == 0) {
|
|
12979
13037
|
std::sort(operation.storage.contactConstraints.begin(),
|
|
@@ -12983,12 +13041,15 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
12983
13041
|
|| (left.bodyA == right.bodyA && (left.bodyB < right.bodyB
|
|
12984
13042
|
|| (left.bodyB == right.bodyB && left.featureId < right.featureId)));
|
|
12985
13043
|
});
|
|
13044
|
+
withdrawUnmatchedWarmStarts();
|
|
12986
13045
|
indexPreparedPairs();
|
|
12987
13046
|
finalizeRestingCacheOrder();
|
|
12988
13047
|
}
|
|
12989
13048
|
}
|
|
12990
13049
|
if (cylinderExtraIterations) {
|
|
12991
|
-
for (std::uint32_t extra = 0; extra < cylinderExtraVelocityIterations; extra += 1)
|
|
13050
|
+
for (std::uint32_t extra = 0; extra < cylinderExtraVelocityIterations; extra += 1) {
|
|
13051
|
+
if (!solvePreparedCylinderConstraints(extra)) break;
|
|
13052
|
+
}
|
|
12992
13053
|
}
|
|
12993
13054
|
if (solveVelocity && applyPositionCorrection) {
|
|
12994
13055
|
operation.storage.broadphaseBoundsReady = false;
|
|
@@ -13005,8 +13066,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
13005
13066
|
for (std::uint32_t iteration = 0; iteration < velocityIterations; iteration += 1) {
|
|
13006
13067
|
auto solveCollectedPair = [&](std::uint32_t first, std::uint32_t second) {
|
|
13007
13068
|
solvePair(first, second,
|
|
13008
|
-
!solveVelocity || ((beginSubstep || preparedSubstep) && iteration == 0),
|
|
13009
|
-
iteration != 0, 0, 0);
|
|
13069
|
+
!solveVelocity || ((beginSubstep || preparedSubstep) && iteration == 0), 0, 0);
|
|
13010
13070
|
};
|
|
13011
13071
|
if (!solveVelocity || ((beginSubstep || preparedSubstep) && iteration == 0)) {
|
|
13012
13072
|
if (operation.storage.broadphaseTree->pairsOverflowed()) {
|
|
@@ -13016,7 +13076,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
13016
13076
|
visitSupportFirst([&](auto&& visit) { operation.storage.broadphaseTree->forEachCollectedPair(visit); }, solveCollectedPair);
|
|
13017
13077
|
}
|
|
13018
13078
|
} else {
|
|
13019
|
-
solvePreparedConstraints(
|
|
13079
|
+
solvePreparedConstraints();
|
|
13020
13080
|
}
|
|
13021
13081
|
if (solveVelocity && (beginSubstep || preparedSubstep) && iteration == 0) {
|
|
13022
13082
|
std::sort(operation.storage.contactConstraints.begin(),
|
|
@@ -13026,12 +13086,15 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
13026
13086
|
|| (left.bodyA == right.bodyA && (left.bodyB < right.bodyB
|
|
13027
13087
|
|| (left.bodyB == right.bodyB && left.featureId < right.featureId)));
|
|
13028
13088
|
});
|
|
13089
|
+
withdrawUnmatchedWarmStarts();
|
|
13029
13090
|
indexPreparedPairs();
|
|
13030
13091
|
finalizeRestingCacheOrder();
|
|
13031
13092
|
}
|
|
13032
13093
|
}
|
|
13033
13094
|
if (cylinderExtraIterations) {
|
|
13034
|
-
for (std::uint32_t extra = 0; extra < cylinderExtraVelocityIterations; extra += 1)
|
|
13095
|
+
for (std::uint32_t extra = 0; extra < cylinderExtraVelocityIterations; extra += 1) {
|
|
13096
|
+
if (!solvePreparedCylinderConstraints(extra)) break;
|
|
13097
|
+
}
|
|
13035
13098
|
}
|
|
13036
13099
|
}
|
|
13037
13100
|
|
|
@@ -22959,7 +23022,7 @@ EventContactResponseStatus stageEventContactResponse(SolverOperation& operation,
|
|
|
22959
23022
|
PreparedContactApplications applications;
|
|
22960
23023
|
double n, t1, t2;
|
|
22961
23024
|
solvePreparedContact(operation, staged.bodies[0], staged.bodies[1],
|
|
22962
|
-
staged.mobility[0], staged.mobility[1], staged.constraint,
|
|
23025
|
+
staged.mobility[0], staged.mobility[1], staged.constraint, n, t1, t2,
|
|
22963
23026
|
&geometry.relativeBasis, &applications, geometry.phase);
|
|
22964
23027
|
for (const auto& body : staged.bodies) {
|
|
22965
23028
|
if (!validBodyMotion(bodyMotionEpoch(body, operation.committedMotionTime)))
|