@series-inc/rundot-syncplay 6.0.0-rc.13 → 6.0.0-rc.15
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/capsule_triangle_native.inc +18 -1
- package/core/native/physics/physics.cpp +142 -32
- package/core/src/physics/physics-wasm-module.generated.mjs +3 -3
- package/dist/authority-room.d.ts +2 -0
- package/dist/authority-room.js +4 -0
- package/dist/physics/3d.d.ts +44 -0
- package/dist/physics/3d.js +91 -0
- package/dist/r3f-render-adapter.d.ts +41 -0
- package/dist/r3f-render-adapter.js +67 -0
- package/dist/runner.js +22 -2
- package/dist/secret-config.js +2 -60
- package/dist/secret-crypto.js +70 -36
- package/dist/testing.js +1 -1
- package/package.json +2 -2
|
@@ -239,7 +239,7 @@ Collision observeGeometry(SolverOperation& operation,const Body& capsule,const B
|
|
|
239
239
|
if(node.count<6)throw TriangleNativeFailure{tp::Failure::InvalidInput};const auto base=std::size_t(node.offset)*3;const auto countValue=payload[base+17];
|
|
240
240
|
if(!finite(countValue)||countValue<1||countValue>node.count/6||std::floor(countValue)!=countValue)throw TriangleNativeFailure{tp::Failure::InvalidInput};
|
|
241
241
|
const auto count=std::uint32_t(countValue);std::uint32_t previousEnd=count*6;
|
|
242
|
-
for(std::uint32_t child=0;child<count;++child){
|
|
242
|
+
for(std::uint32_t child=0;child<count;++child){const auto at=base+std::size_t(child)*18;
|
|
243
243
|
auto code=[&](unsigned lane){const auto value=payload[at+lane];if(!finite(value)||value<0||value>std::numeric_limits<std::uint32_t>::max()||std::floor(value)!=value)throw TriangleNativeFailure{tp::Failure::InvalidInput};return std::uint32_t(value);};
|
|
244
244
|
const auto kind=code(0),offset=code(13),size=code(14),format=code(15);
|
|
245
245
|
if(kind>11||(payload[at+16]!=0.&&payload[at+16]!=1.)||code(17)!=count)throw TriangleNativeFailure{tp::Failure::InvalidInput};
|
|
@@ -247,6 +247,18 @@ Collision observeGeometry(SolverOperation& operation,const Body& capsule,const B
|
|
|
247
247
|
if(complex){if(offset<previousEnd||offset>node.count||size>node.count-offset)throw TriangleNativeFailure{tp::Failure::InvalidInput};previousEnd=offset+size;}
|
|
248
248
|
else if(offset||size||format)throw TriangleNativeFailure{tp::Failure::InvalidInput};
|
|
249
249
|
const Vec3 translation{sum(operation,{node.translation.x,payload[at+1]}),sum(operation,{node.translation.y,payload[at+2]}),sum(operation,{node.translation.z,payload[at+3]})};
|
|
250
|
+
if(!complex){
|
|
251
|
+
const auto translated=rotateByOrientation(geometry,translation);
|
|
252
|
+
const double cX=geometry.x+geometry.shapeOffsetX+translated.x-(capsule.x+capsule.shapeOffsetX);
|
|
253
|
+
const double cY=geometry.y+geometry.shapeOffsetY+translated.y-(capsule.y+capsule.shapeOffsetY);
|
|
254
|
+
const double cZ=geometry.z+geometry.shapeOffsetZ+translated.z-(capsule.z+capsule.shapeOffsetZ);
|
|
255
|
+
const double p0=payload[at+4],p1=payload[at+5],p2=payload[at+6];
|
|
256
|
+
const double childRadius=kind==static_cast<std::uint32_t>(ShapeKind::Box)?std::sqrt(p0*p0+p1*p1+p2*p2):(kind==static_cast<std::uint32_t>(ShapeKind::Sphere)?p0:(p0+p1));
|
|
257
|
+
const double capsuleRadius=capsule.shape0+capsule.shape1;
|
|
258
|
+
const double maxDist=childRadius+capsuleRadius;
|
|
259
|
+
if(cX*cX+cY*cY+cZ*cZ>maxDist*maxDist)continue;
|
|
260
|
+
}
|
|
261
|
+
work(operation);
|
|
250
262
|
if(child>std::uint32_t(std::numeric_limits<std::int32_t>::max()))throw TriangleNativeFailure{tp::Failure::FeatureCapacity};
|
|
251
263
|
append(operation,pending,Node{ShapeKind(kind),complex?node.offset+offset:node.offset+child*6,size,format,translation,{payload[at+4],payload[at+5],payload[at+6]},node.outerChild<0?std::int32_t(child):node.outerChild});
|
|
252
264
|
}continue;
|
|
@@ -257,6 +269,11 @@ Collision observeGeometry(SolverOperation& operation,const Body& capsule,const B
|
|
|
257
269
|
const auto translated=rotateByOrientation(geometry,node.translation);
|
|
258
270
|
child.x=sum(operation,{geometry.x,geometry.shapeOffsetX,translated.x,-capsule.x,-capsule.shapeOffsetX});child.y=sum(operation,{geometry.y,geometry.shapeOffsetY,translated.y,-capsule.y,-capsule.shapeOffsetY});child.z=sum(operation,{geometry.z,geometry.shapeOffsetZ,translated.z,-capsule.z,-capsule.shapeOffsetZ});
|
|
259
271
|
child.shapeOffsetX=child.shapeOffsetY=child.shapeOffsetZ=0.;
|
|
272
|
+
const double p0=child.shape0,p1=child.shape1,p2=child.shape2;
|
|
273
|
+
const double childRadius=child.shape==ShapeKind::Box?std::sqrt(p0*p0+p1*p1+p2*p2):(child.shape==ShapeKind::Sphere?p0:(p0+p1));
|
|
274
|
+
const double capsuleRadius=capsule.shape0+capsule.shape1;
|
|
275
|
+
const double maxDist=childRadius+capsuleRadius;
|
|
276
|
+
if(child.x*child.x+child.y*child.y+child.z*child.z>maxDist*maxDist)continue;
|
|
260
277
|
auto collision=node.kind==ShapeKind::Sphere?capsuleSphere(localCapsule,child):node.kind==ShapeKind::Box?capsuleBox(localCapsule,child):capsuleCapsule(localCapsule,child);
|
|
261
278
|
if(collision.hit){if(!collision.pointCount){collision.pointCount=1;collision.points[0]={collision.pointX,collision.pointY,collision.pointZ};}
|
|
262
279
|
auto& basis=collision.coordinates.emplace<TriangleManifoldBasis>();collision.geometryChildIndex=node.outerChild;basis.anchor={capsule.x,capsule.y,capsule.z};basis.shapeOffset={capsule.shapeOffsetX,capsule.shapeOffsetY,capsule.shapeOffsetZ};
|
|
@@ -2006,13 +2006,7 @@ Collision geometryBox(SolverOperation& operation, const Body& geometry, const Bo
|
|
|
2006
2006
|
}
|
|
2007
2007
|
if (geometry.shape == ShapeKind::Compound
|
|
2008
2008
|
&& (geometry.geometryFormat == 4 || geometry.geometryFormat == 5 || geometry.geometryFormat == 6)) {
|
|
2009
|
-
|
|
2010
|
-
for (std::uint32_t child = 0; child < compoundChildCount(operation, geometry); child += 1) {
|
|
2011
|
-
const Body childBody = compoundChildBody(operation, geometry, child);
|
|
2012
|
-
const Collision candidate = collide(operation, childBody, box);
|
|
2013
|
-
if (candidate.hit && (!best.hit || candidate.penetration > best.penetration)) best = candidate;
|
|
2014
|
-
}
|
|
2015
|
-
return best;
|
|
2009
|
+
return collide(operation, geometry, box);
|
|
2016
2010
|
}
|
|
2017
2011
|
if (geometry.shape == ShapeKind::Compound && geometry.geometryFormat == 1) {
|
|
2018
2012
|
Collision best;
|
|
@@ -2723,6 +2717,7 @@ struct SolverStorage {
|
|
|
2723
2717
|
std::vector<std::uint8_t> sleepCanSleep;
|
|
2724
2718
|
std::vector<std::uint8_t> sleepHasKinematic;
|
|
2725
2719
|
std::vector<std::uint8_t> sleepHasStaticAnchor;
|
|
2720
|
+
std::vector<std::uint8_t> bodyJointAffected;
|
|
2726
2721
|
std::unique_ptr<FixedDynamicAabbTree> broadphaseTree;
|
|
2727
2722
|
bool dynamicTreeEnabled = true;
|
|
2728
2723
|
std::vector<PreparedJointSharedGeometry> preparedJointGeometry;
|
|
@@ -3408,6 +3403,7 @@ void prepareStepStorage(SolverStorage& storage, std::uint32_t bodyCount, std::ui
|
|
|
3408
3403
|
storage.sleepCanSleep.resize(bodyCount);
|
|
3409
3404
|
storage.sleepHasKinematic.resize(bodyCount);
|
|
3410
3405
|
storage.sleepHasStaticAnchor.resize(bodyCount);
|
|
3406
|
+
storage.bodyJointAffected.assign(bodyCount, 0);
|
|
3411
3407
|
storage.broadphaseTree->prepare(bodyCount, pairCapacity);
|
|
3412
3408
|
}
|
|
3413
3409
|
|
|
@@ -3748,11 +3744,127 @@ Collision capsuleBox(const Body& capsule, const Body& box) {
|
|
|
3748
3744
|
#include "capsule_triangle_native.inc"
|
|
3749
3745
|
|
|
3750
3746
|
Collision collide(SolverOperation& operation, const Body& a, const Body& b) {
|
|
3747
|
+
|
|
3751
3748
|
if (operation.materialMotionEpochs != nullptr) return collideMaterialCurrent(operation, a, b);
|
|
3752
|
-
const auto triangleGeometry=[](const Body& body){return body.shape==ShapeKind::Mesh||body.shape==ShapeKind::Heightfield
|
|
3753
|
-
||(body.shape==ShapeKind::Compound&&body.geometryFormat==5);};
|
|
3749
|
+
const auto triangleGeometry=[](const Body& body){return body.shape==ShapeKind::Mesh||body.shape==ShapeKind::Heightfield ||(body.shape==ShapeKind::Compound&&body.geometryFormat==5);};
|
|
3754
3750
|
if(a.shape==ShapeKind::Capsule&&triangleGeometry(b))return triangle_adapter_private::observeGeometry(operation,a,b);
|
|
3755
3751
|
if(b.shape==ShapeKind::Capsule&&triangleGeometry(a))return flipCollision(triangle_adapter_private::observeGeometry(operation,b,a));
|
|
3752
|
+
if (a.shape == ShapeKind::Compound && (a.geometryFormat == 4 || a.geometryFormat == 5 || a.geometryFormat == 6)) {
|
|
3753
|
+
const BroadphaseBounds boundsA = queryProxyBounds(operation, a);
|
|
3754
|
+
const BroadphaseBounds boundsB = queryProxyBounds(operation, b);
|
|
3755
|
+
if (!boundsOverlap(boundsA, boundsB)) return {};
|
|
3756
|
+
|
|
3757
|
+
Collision best;
|
|
3758
|
+
std::int32_t bestChild = -1;
|
|
3759
|
+
struct CandidateContact {
|
|
3760
|
+
std::uint32_t childIndex = 0;
|
|
3761
|
+
Collision collision;
|
|
3762
|
+
};
|
|
3763
|
+
std::vector<CandidateContact> candidates;
|
|
3764
|
+
candidates.reserve(32);
|
|
3765
|
+
|
|
3766
|
+
for (std::uint32_t child = 0; child < compoundChildCount(operation, a); child += 1) {
|
|
3767
|
+
const Body childBody = compoundChildBody(operation, a, child);
|
|
3768
|
+
const BroadphaseBounds childBounds = queryProxyBounds(operation, childBody);
|
|
3769
|
+
if (!boundsOverlap(childBounds, boundsB)) continue;
|
|
3770
|
+
const Collision candidate = collide(operation, childBody, b);
|
|
3771
|
+
if (candidate.hit) {
|
|
3772
|
+
if (!best.hit || candidate.penetration > best.penetration) {
|
|
3773
|
+
best = candidate;
|
|
3774
|
+
bestChild = static_cast<std::int32_t>(child);
|
|
3775
|
+
}
|
|
3776
|
+
candidates.push_back({child, candidate});
|
|
3777
|
+
}
|
|
3778
|
+
}
|
|
3779
|
+
if (!best.hit) return {};
|
|
3780
|
+
if (bestChild >= 0) best.geometryChildIndex = bestChild;
|
|
3781
|
+
if (candidates.size() <= 1) return best;
|
|
3782
|
+
|
|
3783
|
+
const Vec3 primaryNormal{best.nx, best.ny, best.nz};
|
|
3784
|
+
struct MergedPoint {
|
|
3785
|
+
std::array<double, 3> pt;
|
|
3786
|
+
std::uint32_t featureId;
|
|
3787
|
+
double depth;
|
|
3788
|
+
std::uint32_t childIndex;
|
|
3789
|
+
};
|
|
3790
|
+
std::vector<MergedPoint> collected;
|
|
3791
|
+
collected.reserve(64);
|
|
3792
|
+
|
|
3793
|
+
for (std::size_t cIdx = 0; cIdx < candidates.size(); cIdx += 1) {
|
|
3794
|
+
const auto& entry = candidates[cIdx];
|
|
3795
|
+
const Collision& c = entry.collision;
|
|
3796
|
+
const Vec3 cNormal{c.nx, c.ny, c.nz};
|
|
3797
|
+
if (dotVec3(primaryNormal, cNormal) < 0.98) continue;
|
|
3798
|
+
|
|
3799
|
+
const std::uint32_t pCount = (c.pointCount == 0) ? 1u : std::min<std::uint32_t>(c.pointCount, 4u);
|
|
3800
|
+
for (std::uint32_t p = 0; p < pCount; p += 1) {
|
|
3801
|
+
std::array<double, 3> pos{};
|
|
3802
|
+
if (c.pointCount > 0) {
|
|
3803
|
+
pos = c.points[p];
|
|
3804
|
+
} else {
|
|
3805
|
+
pos = {c.pointX, c.pointY, c.pointZ};
|
|
3806
|
+
}
|
|
3807
|
+
const std::uint32_t rawFeature = (c.pointCount > 0) ? c.featureIds[p] : 0u;
|
|
3808
|
+
const std::uint32_t namespacedFeature = (rawFeature * 16777619u) ^ ((entry.childIndex + 1u) * 2166136261u) ^ (p * 374761393u);
|
|
3809
|
+
collected.push_back({pos, namespacedFeature, c.penetration, entry.childIndex});
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
|
|
3813
|
+
if (collected.size() <= 1) return best;
|
|
3814
|
+
|
|
3815
|
+
std::array<std::uint32_t, 4> selectedIndices{};
|
|
3816
|
+
std::vector<std::uint8_t> used(collected.size(), 0);
|
|
3817
|
+
std::uint32_t selectedCount = 0;
|
|
3818
|
+
|
|
3819
|
+
while (selectedCount < std::min<std::uint32_t>(4, static_cast<std::uint32_t>(collected.size()))) {
|
|
3820
|
+
std::uint32_t bestIdx = 0;
|
|
3821
|
+
double bestScore = -1.0;
|
|
3822
|
+
bool found = false;
|
|
3823
|
+
for (std::uint32_t index = 0; index < collected.size(); index += 1) {
|
|
3824
|
+
if (used[index] != 0) continue;
|
|
3825
|
+
double score = collected[index].depth * collected[index].depth;
|
|
3826
|
+
if (selectedCount != 0) {
|
|
3827
|
+
score = std::numeric_limits<double>::infinity();
|
|
3828
|
+
const Vec3 ptA{collected[index].pt[0], collected[index].pt[1], collected[index].pt[2]};
|
|
3829
|
+
for (std::uint32_t chosen = 0; chosen < selectedCount; chosen += 1) {
|
|
3830
|
+
const auto& sel = collected[selectedIndices[chosen]];
|
|
3831
|
+
const Vec3 ptB{sel.pt[0], sel.pt[1], sel.pt[2]};
|
|
3832
|
+
const Vec3 delta = subtractVec3(ptA, ptB);
|
|
3833
|
+
score = std::min(score, dotVec3(delta, delta));
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
if (!found || score > bestScore
|
|
3837
|
+
|| (score == bestScore
|
|
3838
|
+
&& collected[index].featureId < collected[bestIdx].featureId)) {
|
|
3839
|
+
bestIdx = index;
|
|
3840
|
+
bestScore = score;
|
|
3841
|
+
found = true;
|
|
3842
|
+
}
|
|
3843
|
+
}
|
|
3844
|
+
selectedIndices[selectedCount++] = bestIdx;
|
|
3845
|
+
used[bestIdx] = 1;
|
|
3846
|
+
}
|
|
3847
|
+
|
|
3848
|
+
best.pointCount = selectedCount;
|
|
3849
|
+
double avgX = 0.0, avgY = 0.0, avgZ = 0.0;
|
|
3850
|
+
for (std::uint32_t s = 0; s < selectedCount; s += 1) {
|
|
3851
|
+
best.points[s] = collected[selectedIndices[s]].pt;
|
|
3852
|
+
best.featureIds[s] = collected[selectedIndices[s]].featureId;
|
|
3853
|
+
avgX += collected[selectedIndices[s]].pt[0];
|
|
3854
|
+
avgY += collected[selectedIndices[s]].pt[1];
|
|
3855
|
+
avgZ += collected[selectedIndices[s]].pt[2];
|
|
3856
|
+
}
|
|
3857
|
+
const double invCount = 1.0 / static_cast<double>(selectedCount);
|
|
3858
|
+
best.pointX = avgX * invCount;
|
|
3859
|
+
best.pointY = avgY * invCount;
|
|
3860
|
+
best.pointZ = avgZ * invCount;
|
|
3861
|
+
|
|
3862
|
+
return best;
|
|
3863
|
+
}
|
|
3864
|
+
if (b.shape == ShapeKind::Compound && (b.geometryFormat == 4 || b.geometryFormat == 5 || b.geometryFormat == 6)) {
|
|
3865
|
+
const Collision result = collide(operation, b, a);
|
|
3866
|
+
return flipCollision(result);
|
|
3867
|
+
}
|
|
3756
3868
|
if (a.shape == ShapeKind::Sphere && b.shape == ShapeKind::Sphere) {
|
|
3757
3869
|
return sphereSphere(a, b);
|
|
3758
3870
|
}
|
|
@@ -3812,25 +3924,7 @@ Collision collide(SolverOperation& operation, const Body& a, const Body& b) {
|
|
|
3812
3924
|
if (a.shape == ShapeKind::Box && b.shape == ShapeKind::Box) {
|
|
3813
3925
|
return boxBox(a, b);
|
|
3814
3926
|
}
|
|
3815
|
-
if (a.shape == ShapeKind::Compound && (a.geometryFormat == 4 || a.geometryFormat == 5 || a.geometryFormat == 6)) {
|
|
3816
|
-
const BroadphaseBounds boundsA = queryProxyBounds(operation, a);
|
|
3817
|
-
const BroadphaseBounds boundsB = queryProxyBounds(operation, b);
|
|
3818
|
-
if (!boundsOverlap(boundsA, boundsB)) return {};
|
|
3819
3927
|
|
|
3820
|
-
Collision best;
|
|
3821
|
-
for (std::uint32_t child = 0; child < compoundChildCount(operation, a); child += 1) {
|
|
3822
|
-
const Body childBody = compoundChildBody(operation, a, child);
|
|
3823
|
-
const BroadphaseBounds childBounds = queryProxyBounds(operation, childBody);
|
|
3824
|
-
if (!boundsOverlap(childBounds, boundsB)) continue;
|
|
3825
|
-
const Collision candidate = collide(operation, childBody, b);
|
|
3826
|
-
if (candidate.hit && (!best.hit || candidate.penetration > best.penetration)) best = candidate;
|
|
3827
|
-
}
|
|
3828
|
-
return best;
|
|
3829
|
-
}
|
|
3830
|
-
if (b.shape == ShapeKind::Compound && (b.geometryFormat == 4 || b.geometryFormat == 5 || b.geometryFormat == 6)) {
|
|
3831
|
-
const Collision result = collide(operation, b, a);
|
|
3832
|
-
return flipCollision(result);
|
|
3833
|
-
}
|
|
3834
3928
|
if (!robustConvexBodiesOverlap(operation, a, b)) return {};
|
|
3835
3929
|
return convexSupportCollision(operation, a, b);
|
|
3836
3930
|
}
|
|
@@ -7512,7 +7606,7 @@ ContactPassPolicy contactPassPolicy(ContactPass pass) {
|
|
|
7512
7606
|
case ContactPass::BeginLaterSubstep:
|
|
7513
7607
|
return {false, true, true, false, true, true};
|
|
7514
7608
|
case ContactPass::OwnedActivateVelocity:
|
|
7515
|
-
return {false, false, false, true,
|
|
7609
|
+
return {false, false, false, true, true, true};
|
|
7516
7610
|
case ContactPass::OwnedContinueVelocity:
|
|
7517
7611
|
return {false, false, false, false, false, true};
|
|
7518
7612
|
case ContactPass::StandaloneFirstTick:
|
|
@@ -7520,7 +7614,7 @@ ContactPassPolicy contactPassPolicy(ContactPass pass) {
|
|
|
7520
7614
|
case ContactPass::StandaloneLaterSubstep:
|
|
7521
7615
|
return {false, true, false, false, true, true};
|
|
7522
7616
|
case ContactPass::LegacyJointContinueVelocity:
|
|
7523
|
-
return {false, false,
|
|
7617
|
+
return {false, false, false, false, false, true};
|
|
7524
7618
|
}
|
|
7525
7619
|
std::terminate();
|
|
7526
7620
|
}
|
|
@@ -7588,7 +7682,11 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
7588
7682
|
std::uint32_t preparedEnd) {
|
|
7589
7683
|
if (initialize && collisionDisabled(operation, first, second)) return;
|
|
7590
7684
|
if (initialize && !bodies[first].dynamic && !bodies[first].kinematic && !bodies[second].dynamic && !bodies[second].kinematic) return;
|
|
7685
|
+
const bool pairHasJoint = first < operation.storage.bodyJointAffected.size()
|
|
7686
|
+
&& second < operation.storage.bodyJointAffected.size()
|
|
7687
|
+
&& (operation.storage.bodyJointAffected[first] != 0 || operation.storage.bodyJointAffected[second] != 0);
|
|
7591
7688
|
if (!solveVelocity) {
|
|
7689
|
+
if (operation.materialMotionEpochs == nullptr && !pairHasJoint) return;
|
|
7592
7690
|
if (resolveContactPair(operation, bodies[first], bodies[second], options,
|
|
7593
7691
|
nullptr, nullptr, nullptr, nullptr, nullptr, true,
|
|
7594
7692
|
applyPositionCorrection, false) && updateConstraintMobility) {
|
|
@@ -7734,9 +7832,11 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
7734
7832
|
double pointNormal = 0.0;
|
|
7735
7833
|
double pointTangent1 = 0.0;
|
|
7736
7834
|
double pointTangent2 = 0.0;
|
|
7835
|
+
const bool shouldApplyPositionCorrection = applyPositionCorrection
|
|
7836
|
+
&& (pass != ContactPass::OwnedActivateVelocity || (!pairHasJoint && operation.materialMotionEpochs == nullptr));
|
|
7737
7837
|
if (!resolveContactPair(operation, bodies[first], bodies[second], options,
|
|
7738
7838
|
&pointNormal, &pointTangent1, &pointTangent2, nullptr,
|
|
7739
|
-
constraint, true,
|
|
7839
|
+
constraint, true, shouldApplyPositionCorrection && !corrected, true, false,
|
|
7740
7840
|
&preparation, pointIndex, false, false,
|
|
7741
7841
|
1.0 / static_cast<double>(pointCount))) {
|
|
7742
7842
|
if (preservedForCache) constraint->impulses = preservedImpulses;
|
|
@@ -7818,7 +7918,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
7818
7918
|
forEachCollectedSweepPair(operation, solveCollectedPair);
|
|
7819
7919
|
}
|
|
7820
7920
|
} else {
|
|
7821
|
-
solvePreparedConstraints(iteration != 0);
|
|
7921
|
+
solvePreparedConstraints(iteration != 0 || pass == ContactPass::LegacyJointContinueVelocity);
|
|
7822
7922
|
}
|
|
7823
7923
|
if (solveVelocity && (beginSubstep || preparedSubstep) && iteration == 0) {
|
|
7824
7924
|
std::sort(operation.storage.contactConstraints.begin(),
|
|
@@ -7852,7 +7952,7 @@ void resolveSoAContacts(SolverOperation& operation, Body* bodies, std::uint32_t
|
|
|
7852
7952
|
operation.storage.broadphaseTree->forEachCollectedPair(solveCollectedPair);
|
|
7853
7953
|
}
|
|
7854
7954
|
} else {
|
|
7855
|
-
solvePreparedConstraints(iteration != 0);
|
|
7955
|
+
solvePreparedConstraints(iteration != 0 || pass == ContactPass::LegacyJointContinueVelocity);
|
|
7856
7956
|
}
|
|
7857
7957
|
if (solveVelocity && (beginSubstep || preparedSubstep) && iteration == 0) {
|
|
7858
7958
|
std::sort(operation.storage.contactConstraints.begin(),
|
|
@@ -18892,6 +18992,16 @@ std::int32_t solveStartingConstraints(SolverOperation& operation,
|
|
|
18892
18992
|
if ((warmState != nullptr && jointCount != 0) || hook.fn != nullptr
|
|
18893
18993
|
|| operation.materialMotionEpochs != nullptr) {
|
|
18894
18994
|
operation.jointSubstepDuration = substepOptions.dtTicks;
|
|
18995
|
+
operation.storage.bodyJointAffected.assign(bodyCount, 0);
|
|
18996
|
+
for (std::uint32_t j = 0; j < jointCount; ++j) {
|
|
18997
|
+
const Joint& joint = operation.storage.soaJoints[j];
|
|
18998
|
+
if (joint.bodyA < bodyCount) operation.storage.bodyJointAffected[joint.bodyA] = 1;
|
|
18999
|
+
if (joint.bodyB < bodyCount) operation.storage.bodyJointAffected[joint.bodyB] = 1;
|
|
19000
|
+
}
|
|
19001
|
+
for (const auto& connection : hook.connections) {
|
|
19002
|
+
if (connection[0] < bodyCount) operation.storage.bodyJointAffected[connection[0]] = 1;
|
|
19003
|
+
if (connection[1] < bodyCount) operation.storage.bodyJointAffected[connection[1]] = 1;
|
|
19004
|
+
}
|
|
18895
19005
|
resolveSoAContacts(operation, operation.storage.soaBodies.data(), bodyCount,
|
|
18896
19006
|
1, substepOptions, ContactPass::OwnedPositionCorrection);
|
|
18897
19007
|
if (operation.storage.contactConstraintOverflow) return 5;
|