Closed lperkin1 closed 1 year ago
Looking at the code, I do not see anything that stand out. I will paste it in the demos, and see whe I get.
On Mon, May 22, 2023, 11:39 AM Luke Perkins @.***> wrote:
I'm having an issue in my code with undefined behavior. To find it, I compiled with debug enabled and started getting assertion failures on collisions between kinematic and dynamic bodies. I put together a test of what my code is doing that throws the same assert failures. I'm probably being an idiot, but everything I've seen seems like this should work.
Here's the test I added
ifdef _DEBUG
include "ndNewton.h"
include <gtest/gtest.h>
TEST(Collisions, KinematicCollision) { ndWorld* world = new ndWorld(); ndShapeInstance shapeinst(new ndShapeSphere(ndFloat32(0.5f)));
ndMatrix matrix(ndGetIdentityMatrix());
ndBodyKinematic* staticbody = new ndBodyKinematic(); staticbody->SetCollisionShape(shapeinst); staticbody->SetMatrix(matrix); staticbody->SetMassMatrix(ndFloat32(10), shapeinst); ndSharedPtr
staticPtr(staticbody); world->AddBody(staticPtr); matrix.m_posit.m_y = 5;
ndBodyDynamic* movingbody = new ndBodyDynamic(); movingbody->SetNotifyCallback(new ndBodyNotify(ndBigVector(ndFloat32(0), ndFloat32(-9.81f), ndFloat32(0), ndFloat32(0)))); movingbody->SetCollisionShape(shapeinst); movingbody->SetMatrix(matrix); movingbody->SetMassMatrix(ndFloat32(10), shapeinst); ndSharedPtr
movingPtr(movingbody); world->AddBody(movingPtr); for (int i = 0; i < 480; i++) { world->Update(1.0f / 60.0f); world->Sync(); }
world->CleanUp(); delete world; }
endif
I compiled it with these parameters cmake .. -DCMAKE_BUILD_TYPE=Debug -DNEWTON_EXCLUDE_UNIX_TEST=OFF -DNEWTON_BUILD_SHARED_LIBS=OFF
That got me the assertion errors out of the tests. Let me know what I've messed up.
— Reply to this email directly, view it on GitHub https://github.com/MADEAPPS/newton-dynamics/issues/313, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6EPJGBXZYYCFTFUVIN5K3XHOXHBANCNFSM6AAAAAAYK2H3PE . You are receiving this because you are subscribed to this thread.Message ID: @.***>
ok, I see the assert, it was a harmless one from the time that kinematics weren't part of the dynamics. in 4.cc they are, so the check is not needed.
it's fixed now.
On Mon, May 22, 2023 at 12:29 PM Julio Jerez @.***> wrote:
Looking at the code, I do not see anything that stand out. I will paste it in the demos, and see whe I get.
On Mon, May 22, 2023, 11:39 AM Luke Perkins @.***> wrote:
I'm having an issue in my code with undefined behavior. To find it, I compiled with debug enabled and started getting assertion failures on collisions between kinematic and dynamic bodies. I put together a test of what my code is doing that throws the same assert failures. I'm probably being an idiot, but everything I've seen seems like this should work.
Here's the test I added
ifdef _DEBUG
include "ndNewton.h"
include <gtest/gtest.h>
TEST(Collisions, KinematicCollision) { ndWorld* world = new ndWorld(); ndShapeInstance shapeinst(new ndShapeSphere(ndFloat32(0.5f)));
ndMatrix matrix(ndGetIdentityMatrix());
ndBodyKinematic* staticbody = new ndBodyKinematic(); staticbody->SetCollisionShape(shapeinst); staticbody->SetMatrix(matrix); staticbody->SetMassMatrix(ndFloat32(10), shapeinst); ndSharedPtr
staticPtr(staticbody); world->AddBody(staticPtr); matrix.m_posit.m_y = 5;
ndBodyDynamic* movingbody = new ndBodyDynamic(); movingbody->SetNotifyCallback(new ndBodyNotify(ndBigVector(ndFloat32(0), ndFloat32(-9.81f), ndFloat32(0), ndFloat32(0)))); movingbody->SetCollisionShape(shapeinst); movingbody->SetMatrix(matrix); movingbody->SetMassMatrix(ndFloat32(10), shapeinst); ndSharedPtr
movingPtr(movingbody); world->AddBody(movingPtr); for (int i = 0; i < 480; i++) { world->Update(1.0f / 60.0f); world->Sync(); }
world->CleanUp(); delete world; }
endif
I compiled it with these parameters cmake .. -DCMAKE_BUILD_TYPE=Debug -DNEWTON_EXCLUDE_UNIX_TEST=OFF -DNEWTON_BUILD_SHARED_LIBS=OFF
That got me the assertion errors out of the tests. Let me know what I've messed up.
— Reply to this email directly, view it on GitHub https://github.com/MADEAPPS/newton-dynamics/issues/313, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6EPJGBXZYYCFTFUVIN5K3XHOXHBANCNFSM6AAAAAAYK2H3PE . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Makes sense. Thanks!
I'm having an issue in my code with undefined behavior. To find it, I compiled with debug enabled and started getting assertion failures on collisions between kinematic and dynamic bodies. I put together a test of what my code is doing that throws the same assert failures. I'm probably being an idiot, but everything I've seen seems like this should work.
Here's the test I added
I compiled it with these parameters
cmake .. -DCMAKE_BUILD_TYPE=Debug -DNEWTON_EXCLUDE_UNIX_TEST=OFF -DNEWTON_BUILD_SHARED_LIBS=OFF
That got me the assertion errors out of the tests. Let me know what I've messed up.