MADEAPPS / newton-dynamics

Newton Dynamics is an integrated solution for real time simulation of physics environments.
http://www.newtondynamics.com
Other
936 stars 182 forks source link

debug assertion failed in dFastRay #247

Closed BenjaminGu closed 3 years ago

BenjaminGu commented 3 years ago

debug assertion failed at dFastRay.h line62.

dAssert(m_diff.DotProduct(m_diff).GetScalar() > dFloat32(0.0f));

The call stack is as follows.

ndNewton_d.dll!dFastRay::dFastRay(const dVector & l0, const dVector & l1) Line 62   C++
ndNewton_d.dll!dFastRay::RayDistance(const dVector & ray_q0, const dVector & ray_q1) Line 163   C++
ndNewton_d.dll!ndContactSolver::CalculateContacts(const dVector & point0, const dVector & point1, const dVector & normal) Line 985  C++
ndNewton_d.dll!ndContactSolver::ConvexToConvexContactsDiscrete() Line 2394  C++
ndNewton_d.dll!ndContactSolver::ConvexContactsDiscrete() Line 2334  C++
ndNewton_d.dll!ndContactSolver::CalculateContactsDiscrete() Line 2301   C++
ndNewton_d.dll!ndBodyPlayerCapsuleContactSolver::CalculateContacts() Line 582   C++
ndNewton_d.dll!ndBodyPlayerCapsule::PredictTimestep(ndBodyPlayerCapsuleContactSolver & contactSolver, float timestep) Line 386  C++
ndNewton_d.dll!ndBodyPlayerCapsule::IntegrateExternalForce(float timestep) Line 801 C++
ndNewton_d.dll!`ndDynamicsUpdateSoa::IntegrateUnconstrainedBodies'::`2'::ndIntegrateUnconstrainedBodies::Execute() Line 713 C++
ndNewton_d.dll!dThreadPool::ExecuteJobs(dThreadPoolJob * * const jobs) Line 156 C++
ndNewton_d.dll!ndScene::SubmitJobs<`ndDynamicsUpdateSoa::IntegrateUnconstrainedBodies'::`2'::ndIntegrateUnconstrainedBodies>(void * const context) Line 261 C++
ndNewton_d.dll!ndDynamicsUpdateSoa::IntegrateUnconstrainedBodies() Line 723 C++
ndNewton_d.dll!ndDynamicsUpdateSoa::Update() Line 2244  C++
ndNewton_d.dll!ndWorld::SubStepUpdate(float timestep) Line 765  C++
ndNewton_d.dll!ndWorld::ThreadFunction() Line 689   C++
ndNewton_d.dll!ndWorldDefaultScene::ThreadFunction() Line 54    C++
ndNewton_d.dll!dThread::ThreadFunctionCallback() Line 112   C++

For convenient debugging, I made a unit test as follows.

dVector p0(0.177790642f, -0.238193214f, -0.456974357f, 1.00000000f);
dVector p1(1.19831181f, -0.149490535f, 0.100988448f, 1.00000000f);
dVector q0(0.233102679f, -0.783371150f, -0.426293671f, 1.00000000f);
dVector q1(0.233629316f, 0.783295393f, -0.427256823f, 1.00000000);
const dFastRay ray(p0, p1);
const dFastRay intesect(ray.RayDistance(q0, q1));

So I can get the same debug assertion failed.

JulioJerez commented 3 years ago

ah yes that's would be a bad bug. the ray intersection should not return another fast ray, it should return a ray segment. Fast Ray assume the length larger that zero.

Fixed. thanks

BenjaminGu commented 3 years ago

The bug has been fixed. Thanks.