Skip to content

Commit f228673

Browse files
committed
btManifoldPoint.h: keep track of whether a contact point is predictive
1 parent 6645e50 commit f228673

5 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/main/java/com/jme3/bullet/collision/ContactPointFlag.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ final public class ContactPointFlag {
6969
* contact is swapped (bodyA is body1 and bodyB is body0)
7070
*/
7171
final public static int SWAPPED = 0x20;
72+
/**
73+
* contact is predictive (generated by Continuous Collision Detection)
74+
*/
75+
final public static int PREDICTIVE = 0x40;
7276
/**
7377
* message logger for this class
7478
*/

src/main/native/bullet3/BulletCollision/CollisionDispatch/btCollisionWorld.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,8 @@ struct btBridgedManifoldResult : public btManifoldResult
11581158
localB = m_body1Wrap->getCollisionObject()->getWorldTransform().invXform(pointInWorld);
11591159
}
11601160

1161-
btManifoldPoint newPt(localA, localB, normalOnBInWorld, depth, isSwapped); // stephengold modified 2026-03-21
1161+
bool isPredictive = false; // stephengold added 2026-03-21
1162+
btManifoldPoint newPt(localA, localB, normalOnBInWorld, depth, isPredictive, isSwapped); // stephengold modified 2026-03-21
11621163
newPt.m_positionWorldOnA = pointA;
11631164
newPt.m_positionWorldOnB = pointInWorld;
11641165

src/main/native/bullet3/BulletCollision/CollisionDispatch/btManifoldResult.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ void btManifoldResult::addContactPoint(const btVector3& normalOnBInWorld, const
148148
valid = pShape->isValidContact(localB, m_partId1, m_index1);// stephengold added 2021-10-22
149149
}// stephengold added 2021-10-22
150150
if (!valid) return;// stephengold added 2021-10-22
151-
btManifoldPoint newPt(localA, localB, normalOnBInWorld, depth, isSwapped); // stephengold modified 2026-03-21
151+
const bool isPredictive = false;
152+
btManifoldPoint newPt(localA, localB, normalOnBInWorld, depth, isPredictive, isSwapped); // stephengold modified 2026-03-21
152153
newPt.m_positionWorldOnA = pointA;
153154
newPt.m_positionWorldOnB = pointInWorld;
154155

src/main/native/bullet3/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ enum btContactPointFlags
4545
BT_CONTACT_FLAG_CONTACT_STIFFNESS_DAMPING = 8,
4646
BT_CONTACT_FLAG_FRICTION_ANCHOR = 16,
4747
BT_CONTACT_FLAG_SWAPPED = 32, // stephengold added 2026-03-21
48+
BT_CONTACT_FLAG_PREDICTIVE = 64, // stephengold added 2026-03-21
4849
};
4950

5051
/// ManifoldContactPoint collects and maintains persistent contactpoints.
@@ -70,7 +71,7 @@ class btManifoldPoint
7071

7172
btManifoldPoint(const btVector3& pointA, const btVector3& pointB,
7273
const btVector3& normal,
73-
btScalar distance, bool isSwapped) : m_localPointA(pointA), // stephengold modified 2026-03-21
74+
btScalar distance, bool isPredictive, bool isSwapped) : m_localPointA(pointA), // stephengold modified 2026-03-21
7475
m_localPointB(pointB),
7576
m_positionWorldOnB(0,0,0),
7677
m_positionWorldOnA(0,0,0),
@@ -85,7 +86,7 @@ class btManifoldPoint
8586
m_index0(-1),
8687
m_index1(-1),
8788
m_userPersistentData(0),
88-
m_contactPointFlags(isSwapped ? BT_CONTACT_FLAG_SWAPPED : 0), // stephengold modified 2026-03-21
89+
m_contactPointFlags((isSwapped ? BT_CONTACT_FLAG_SWAPPED : 0)|(isPredictive ? BT_CONTACT_FLAG_PREDICTIVE : 0)), // stephengold modified 2026-03-21
8990
m_appliedImpulse(0.f),
9091
m_prevRHS(0.f),
9192
m_appliedImpulseLateral1(0.f),

src/main/native/bullet3/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,10 +901,11 @@ void btDiscreteDynamicsWorld::createPredictiveContactsInternal(btRigidBody** bod
901901
btVector3 worldPointB = body->getWorldTransform().getOrigin() + distVec;
902902
btVector3 localPointB = sweepResults.m_hitCollisionObject->getWorldTransform().inverse() * worldPointB;
903903

904+
bool isPredictive = true; // stephengold added 2026-03-21
904905
bool isSwapped = false; // stephengold added 2026-03-21
905-
btManifoldPoint newPoint(btVector3(0, 0, 0), localPointB, sweepResults.m_hitNormalWorld, distance, isSwapped); // stephengold modified 2026-03-21
906+
btManifoldPoint newPoint(btVector3(0, 0, 0), localPointB, sweepResults.m_hitNormalWorld, distance, isPredictive, isSwapped); // stephengold modified 2026-03-21
906907

907-
bool isPredictive = true;
908+
//bool isPredictive = true; // stephengold commented out 2026-03-21
908909
int index = manifold->addManifoldPoint(newPoint, isPredictive);
909910
btManifoldPoint& pt = manifold->getContactPoint(index);
910911
pt.m_combinedRestitution = 0;

0 commit comments

Comments
 (0)