Velocity loss with CDD after a collision #3658
Replies: 9 comments 1 reply
-
thanks for your sharing. this is my understanding. it is engine's procedure when it detects the collision point by the CCD.
so the final velocity depends on the distance when the first detect the collision. i will check if there is any other method to make it more better. thanks. |
Beta Was this translation helpful? Give feedback.
-
provide a preliminary scheme for reference. index e4da468..13bf146 100644
--- a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
+++ b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
@@ -944,9 +944,9 @@ void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstra
if (penetration > 0)
{
- positionalError = 0;
+ positionalError = -restitution - (penetration - (infoGlobal.m_timeStep - penetration/(-rel_vel)) * restitution) * invTimeStep;
- velocityError -= penetration * invTimeStep;
+ //velocityError -= penetration * invTimeStep;
}
else
{
@@ -971,6 +971,8 @@ void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstra
solverConstraint.m_cfm = cfm * solverConstraint.m_jacDiagABInv;
solverConstraint.m_lowerLimit = 0;
solverConstraint.m_upperLimit = 1e10f;
+ if (penetration > 0)
+ solverConstraint.m_lowerLimit = -1e10f;
}
}
diff --git a/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp b/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
index a3c9f42..a4be4ec 100644
--- a/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
+++ b/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
@@ -907,7 +907,7 @@ void btDiscreteDynamicsWorld::createPredictiveContactsInternal(btRigidBody** bod
bool isPredictive = true;
int index = manifold->addManifoldPoint(newPoint, isPredictive);
btManifoldPoint& pt = manifold->getContactPoint(index);
- pt.m_combinedRestitution = 0;
+ pt.m_combinedRestitution = gCalculateCombinedRestitutionCallback(body, sweepResults.m_hitCollisionObject);
pt.m_combinedFriction = gCalculateCombinedFrictionCallback(body, sweepResults.m_hitCollisionObject);
pt.m_positionWorldOnA = body->getWorldTransform().getOrigin();
pt.m_positionWorldOnB = worldPointB;
Here is the output (i change the step size as this ammoWorld->stepSimulation(1 / 240.0, 1, 1/240.0)) |
Beta Was this translation helpful? Give feedback.
-
Thanks, I couldn't reproduce your result with the information provided. |
Beta Was this translation helpful? Give feedback.
-
please don't use this patch which maybe cause some other regression issues. if you only want to test, you also need to change your test app like this
|
Beta Was this translation helpful? Give feedback.
-
At the moment, restitution is not compatible with the CCD feature. For regular contact constraints, the outgoing velocity gets compensated for restitution during solver setup. For CCD contacts this doesn't happen. We need a different approach for CCD contacts to enable restitution. |
Beta Was this translation helpful? Give feedback.
-
i'm not fully understand this
i also thought to split the timestep into two parts but that seems more complicated. |
Beta Was this translation helpful? Give feedback.
-
I have a similar issue with CCD, but before my rigidbody hits the ground (static heightfield). The rigidbody falls from the sky at relatively high velocity but near the ground it suddenly stops in mid air, then continue falling from that 'halted' position losing basically all the energy from the fall. Is it legit behavior of CCD? Or do I use some wrong parameter? I set the ccd radius as the length of aabb half extents, and the motion threshold as a small fraction of this (like 0.05 of the radius). |
Beta Was this translation helpful? Give feedback.
-
Unfortunately at the moment the CCD has no restitution and will loose energy. It will require modifications to the implementation. |
Beta Was this translation helpful? Give feedback.
-
I roll my own CCD using raycast from points 90 off from linv on a sphere,
I use vector.reflect() and place the object at where it's reflected off the
next frame
I run my CCD after my logic in bge.scene.pre_draw callback
…On Tue, May 19, 2020 at 6:17 PM erwincoumans ***@***.***> wrote:
Unfortunately at the moment the CCD has no restitution and will loose
energy. It will require modifications to the implementation.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2483 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABW3SWPVVH4DPMVSFMNXNSLRSMVRFANCNFSM4JM2H36Q>
.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a simple example of a bullet (ball) going through a wall at high speed. Both have restitution = 1.
With CCD off, the bullet goes through (as expected).
With CCD on, the bullet bounces but loses some of the velocity.
Also, changing the bullet start position, I get a different velocity after the bounce.
Any idea what's wrong with it? And how I could fix it?
Here's the code
Here's the console output:
With a start position of 0,20.5,0 the resulting velocity after bounce is 24
Beta Was this translation helpful? Give feedback.
All reactions