DanielChappuis / reactphysics3d

Open source C++ physics engine library in 3D
http://www.reactphysics3d.com
zlib License
1.54k stars 223 forks source link

rp3d 0.7: ray tracing only works in approximatly 75% of cases #81

Closed andreasdr closed 5 years ago

andreasdr commented 5 years ago

Hi,

We use ray tracing to determine interaction objects in our game. For some reason it only works in like 75% of all cases. I tried to enable assertions but the game crashes then early so I cant test if a assertion is hit when doing ray casting. How can I help to track down the issue?

E.g. I can provide videos or provide backtraces of assertions.

Its also possible that you already fixed this?

Any help is highly appreciated.

Many thanx and

Best regards Andeas

andreasdr commented 5 years ago

Hi,

Strange. This is the assertion I hit when starting the game with assertions enabled.

Everything from frame 13 is broken but frame 14 gives a hint. Seems like there is some corruption or something.

frame #13: 0x0000000000a6eead ASWServertdme::engine::subsystems::framebuffer::FrameBufferRenderShader::initialize(this=0x0000000000000000) at FrameBufferRenderShader.cpp:58 frame #14: 0x0000000000654c22 ASWServerreactphysics3d::CollisionWorld::testOverlap(this=0x0000000803d7d000, body=0x000000083b3c9e40, overlapCallback=0x00007fffdfbf6a98, categoryMaskBits=17) at CollisionWorld.h:255 frame #15: 0x00000000006511e0 ASWServertdme::engine::physics::World::doesCollideWith(this=0x0000000803d7d000, collisionTypeIds=17, body=0x000000080b10d000, rigidBodies=0x00007fffdfbf6cb0) at World.cpp:374 frame #16: 0x00000000006513f3 ASWServertdme::engine::physics::World::doesCollideWith(this=0x0000000803d7d000, collisionTypeIds=17, transformations=0x00007fffdfbf6cd8, boundingVolumes=vector<tdme::engine::primitives::BoundingVolume *, std::__1::allocator<tdme::engine::primitives::BoundingVolume *> > @ 0x00007fffdfbf6c98, rigidBodies=0x00007fffdfbf6cb0) at World.cpp:382 frame #17: 0x0000000000485bf6 ASWServerasw::logics::PlayerLogic::canSpawn(context=0x0000000803d6c1c8, spawnPoint=const tdme::math::Vector3 @ 0x00007fffdfbf6f80) at PlayerLogic.cpp:899 frame #18: 0x0000000000469c56 ASWServerasw::logics::NewLogic::handleNewClient(this=0x0000000803ce0040, clientId=0x00007fffdfbf7eb0) at NewLogic.cpp:70 frame #19: 0x000000000044acb1 ASWServerasw::ASWServerGameLogicThread::run(this=0x0000000803d91070) at ASWServerGameLogicThread.cpp:203 frame #20: 0x0000000000862f04 ASWServerasw::ASWClientGameLogicThread::run(this=0x0000000000000000) at ASWClientGameLogicThread.cpp:0 frame #21: 0x00000008016d5776 libthr.so.3___lldb_unnamed_symbol1$$libthr.so.3 + 326`

andreasdr commented 5 years ago

Related involved tdme2 logic(frame 16) of this first assertion:

https://github.com/andreasdr/tdme2/blob/master/src/tdme/engine/physics/World.cpp#L380

andreasdr commented 5 years ago

Hmm. Strange. Seems to be a optimization level issue: If I buld like so it seems to work. I will investigate i bit further.

+
+OFLAGS := 
+
 CPPFLAGS := $(INCLUDES)
-CFLAGS := -g $(OFLAGS) -pipe -MMD -MP -DNDEBUG
+CFLAGS := -g $(OFLAGS) -pipe -MMD -MP
 #CFLAGS := $(OFLAGS) -pipe -MMD -MP -DNDEBUG
-CFLAGS_EXT_RP3D := $(OFLAGS) -pipe -MMD -MP -DNDEBUG
+CFLAGS_EXT_RP3D := $(OFLAGS) -g -pipe -MMD -MP
andreasdr commented 5 years ago

Hi,

Ok. I switched from -O3 to -O2 on FreeBSD/MacOSX(both use clang). This leads to no assertions and ray tracing seem to work in all cases.

Sorry for the noise. You can delete this issue.

Many thanx and

Best regards Andreas

DanielChappuis commented 5 years ago

Hi,

I am glad that you found the issue. If I remember correctly you already had issues with this level of optimizations with ReactPhysics3D in the past. I will need to try to understand what is going on at some point.

Best regards

andreasdr commented 5 years ago

Hi,

yes I switched to -O2 for GCC a while ago! But -O3 was working good with clang. Now we started using ray tracing and this does not seem to work reliable with -O3 on clang.

Thank you!