瀏覽代碼

Fixed passing underestimate of penetration depth in ContactListener::OnContactPersisted

The penetration depth calculation in `ContactConstraintsManager::GetContactsFromCache()` was using the first relative contact points for each iteration of the loop.
Nicholas Zollinger 1 月之前
父節點
當前提交
d811492a31
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Jolt/Physics/Constraints/ContactConstraintManager.cpp

+ 1 - 1
Jolt/Physics/Constraints/ContactConstraintManager.cpp

@@ -923,7 +923,7 @@ void ContactConstraintManager::GetContactsFromCache(ContactAllocator &ioContactA
 				const CachedContactPoint &ccp = output_cm->mContactPoints[i];
 				const CachedContactPoint &ccp = output_cm->mContactPoints[i];
 				manifold.mRelativeContactPointsOn1[i] = transform_body1.Multiply3x3(Vec3::sLoadFloat3Unsafe(ccp.mPosition1));
 				manifold.mRelativeContactPointsOn1[i] = transform_body1.Multiply3x3(Vec3::sLoadFloat3Unsafe(ccp.mPosition1));
 				manifold.mRelativeContactPointsOn2[i] = local_transform_body2 * Vec3::sLoadFloat3Unsafe(ccp.mPosition2);
 				manifold.mRelativeContactPointsOn2[i] = local_transform_body2 * Vec3::sLoadFloat3Unsafe(ccp.mPosition2);
-				penetration_depth = max(penetration_depth, (manifold.mRelativeContactPointsOn1[0] - manifold.mRelativeContactPointsOn2[0]).Dot(world_space_normal));
+				penetration_depth = max(penetration_depth, (manifold.mRelativeContactPointsOn1[i] - manifold.mRelativeContactPointsOn2[i]).Dot(world_space_normal));
 			}
 			}
 			manifold.mPenetrationDepth = penetration_depth; // We don't have the penetration depth anymore, estimate it
 			manifold.mPenetrationDepth = penetration_depth; // We don't have the penetration depth anymore, estimate it