Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CollisionDetectionSystem::createSnapshotContacts assertion problem #414

Open
darktemplar216 opened this issue Jan 8, 2025 · 3 comments
Open
Assignees
Milestone

Comments

@darktemplar216
Copy link

darktemplar216 commented Jan 8, 2025

CollisionDetectionSystem.txt
`void CollisionDetectionSystem::createSnapshotContacts(Array& contactPairs,
Array& contactManifolds,
Array& contactPoints,
Array& potentialContactManifolds,
Array& potentialContactPoints) {

RP3D_PROFILE("CollisionDetectionSystem::createSnapshotContacts()", mProfiler);

contactManifolds.reserve(contactPairs.size());
contactPoints.reserve(contactManifolds.size());

// For each contact pair
const uint32 nbContactPairs = static_cast<uint32>(contactPairs.size());
for (uint32 p=0; p < nbContactPairs; p++) {

    ContactPair& contactPair = contactPairs[p];

    // add this continue --------------------------------------------------------------------------
    if(contactPair.isTrigger) continue;
    // add this continue --------------------------------------------------------------------------
    assert(contactPair.nbPotentialContactManifolds > 0);

	contactPair.contactManifoldsIndex = static_cast<uint32>(contactManifolds.size());
	contactPair.nbContactManifolds = contactPair.nbPotentialContactManifolds;
	contactPair.contactPointsIndex = static_cast<uint32>(contactPoints.size());

	// For each potential contact manifold of the pair
	for (uint32 m = 0; m < contactPair.nbPotentialContactManifolds; m++) {

		ContactManifoldInfo& potentialManifold = potentialContactManifolds[contactPair.potentialContactManifoldsIndices[m]];
		assert(potentialManifold.nbPotentialContactPoints > 0);

		// Start index and number of contact points for this manifold
		const uint32 contactPointsIndex = static_cast<uint32>(contactPoints.size());
		const uint8 nbContactPoints = potentialManifold.nbPotentialContactPoints;
		contactPair.nbToTalContactPoints += nbContactPoints;

		// Create and add the contact manifold
		contactManifolds.emplace(contactPair.body1Entity, contactPair.body2Entity, contactPair.collider1Entity,
			contactPair.collider2Entity, contactPointsIndex, nbContactPoints);

		assert(potentialManifold.nbPotentialContactPoints > 0);

		// For each contact point of the manifold
		for (uint32 c = 0; c < potentialManifold.nbPotentialContactPoints; c++) {

			ContactPointInfo& potentialContactPoint = potentialContactPoints[potentialManifold.potentialContactPointsIndices[c]];

			// Create a new contact point
			ContactPoint contactPoint(potentialContactPoint, mWorld->mConfig.persistentContactDistanceThreshold);

			// Add the contact point
			contactPoints.add(contactPoint);
		}
	}
}

}`

When using PhysicsWorld::testCollision on an ordinary capsule collider, I found a static concave trigger collider in the scene could cause this assertion to fail "assert(contactPair.nbPotentialContactManifolds > 0);" So I add a continue. Does it make any sense?

@darktemplar216
Copy link
Author

oh btw I commented this assertion due to the same reason

assert((isTrigger && narrowPhaseInfoBatch.narrowPhaseInfos[i].nbContactPoints == 0) ||
(!isTrigger && narrowPhaseInfoBatch.narrowPhaseInfos[i].nbContactPoints > 0));

in

CollisionDetectionSystem::processPotentialContacts(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, bool updateLastFrameInfo,
Array& potentialContactPoints,
Array& potentialContactManifolds,
Map<uint64, uint>& mapPairIdToContactPairIndex,
Array* contactPairs) {

@darktemplar216
Copy link
Author

And @DanielChappuis, I heard you are working on a Character Controller. I would like to offer my game project as a test bed if you are interested. It's a unity PVP (mobile/pc) MOBA like game and I got your engine compiled on Android/iOS/Windows10. Give me your email address if you are in. I give full access.

@DanielChappuis DanielChappuis self-assigned this Jan 8, 2025
@DanielChappuis DanielChappuis added this to the v0.10.3 milestone Jan 8, 2025
@DanielChappuis
Copy link
Owner

Thanks a lot for reporting this. I will investigate that. I think it might be the same kind of issue as issue #364 that was fixed some time ago.

Concerning the Character Controller. I am not currently working on that but I plan to do it. I don't really know when yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants