GithubHelp home page GithubHelp logo

Comments (11)

DanielChappuis avatar DanielChappuis commented on September 26, 2024 1

Hello. It seems to happen in the call of the DynamicsWorld.update() method. Are you doing something special in your code before you call this method (between this call and the previous one) ? Like adding, removing bodies from the world ?

Also, where the assert is hit, can I ask you what is the value of the variables "indexBody" and "mSplitLinearVelocities.size()" ?

from reactphysics3d.

andreasdr avatar andreasdr commented on September 26, 2024

Hi

Backtrace with debug build looks like:

(gdb) bt
#0  0x000000000050846a in reactphysics3d::Vector3::operator= (this=0x83a3704f8, vector=@0x7fffdfbfa750) at Vector3.h:360
#1  0x00000000009e7bfa in reactphysics3d::DynamicsWorld::integrateRigidBodiesVelocities (this=0x8062b0000) at ext/reactphysics3d/src/engine/DynamicsWorld.cpp:301
#2  0x00000000009e7278 in reactphysics3d::DynamicsWorld::update (this=0x8062b0000, timeStep=0.0160000008) at ext/reactphysics3d/src/engine/DynamicsWorld.cpp:132
#3  0x00000000004ebdbb in tdme::engine::physics::World::update (this=0x8062b0000, deltaTime=0.0160000008) at src/tdme/engine/physics/World.cpp:179

I need collision bodies for several game features.

Best regards
Andreas

from reactphysics3d.

andreasdr avatar andreasdr commented on September 26, 2024

I will do today.

from reactphysics3d.

andreasdr avatar andreasdr commented on September 26, 2024

I am adding a collision body in a frame and then just remove it after several frames(means after several world.update() calls). So nothing special at all. Meanwhile I do not add or remove bodies.

from reactphysics3d.

andreasdr avatar andreasdr commented on September 26, 2024

I have added the following line to debug:

Console::println(to_string(mBodies.size()) + ":" + to_string(indexBody));

(mSplitLinearVelocities is a C++ Array, not a STL container or something)

Before the game crashes it prints:
573:6337680
573:571

from reactphysics3d.

andreasdr avatar andreasdr commented on September 26, 2024

Oh overread that too fast.

Also, where the assert is hit, can I ask you what is the value of the variables "indexBody" and "mSplitLinearVelocities.size()" ?

I will check tomorrow. I have made changes to TDME2 that requires me to modify game logics too.

from reactphysics3d.

andreasdr avatar andreasdr commented on September 26, 2024

Hi,

please see attached a patch that fixes the crash.

diff --git a/ext/reactphysics3d/src/engine/DynamicsWorld.cpp b/ext/reactphysics3d/src/engine/DynamicsWorld.cpp
index 91112d74..68eff2ab 100644
--- a/ext/reactphysics3d/src/engine/DynamicsWorld.cpp
+++ b/ext/reactphysics3d/src/engine/DynamicsWorld.cpp
@@ -746,13 +746,18 @@ void DynamicsWorld::computeIslands() {
                 // Check if the current contact manifold has already been added into an island
                 if (contactManifold->isAlreadyInIsland()) continue;
 
+                // Get the other body of the contact manifold
+                RigidBody* body1 = dynamic_cast<RigidBody*>(contactManifold->getBody1());
+                RigidBody* body2 = dynamic_cast<RigidBody*>(contactManifold->getBody2());
+
+                // if body1 or body2 is nullptr dynamic cast have failed due to beeing collision body
+                if (body1 == nullptr || body2 == nullptr) continue;
+
                 // Add the contact manifold into the island
                 mIslands[mNbIslands]->addContactManifold(contactManifold);
                 contactManifold->mIsAlreadyInIsland = true;
 
-                // Get the other body of the contact manifold
-                RigidBody* body1 = static_cast<RigidBody*>(contactManifold->getBody1());
-                RigidBody* body2 = static_cast<RigidBody*>(contactManifold->getBody2());
+                //
                 RigidBody* otherBody = (body1->getId() == bodyToVisit->getId()) ? body2 : body1;
 
                 // Check if the other body has already been added to the island
@@ -781,6 +786,10 @@ void DynamicsWorld::computeIslands() {
                 // Get the other body of the contact manifold
                 RigidBody* body1 = static_cast<RigidBody*>(joint->getBody1());
                 RigidBody* body2 = static_cast<RigidBody*>(joint->getBody2());
+

Best regards
Andreas

from reactphysics3d.

DanielChappuis avatar DanielChappuis commented on September 26, 2024

Yes thanks. I have also found how to solve it yesterday evening with this commit. I was just running some tests to see that this fix was OK. I think our patches are similar.

I have pushed my changes into the develop branch. Could you test if the issue is also resolved on your side with the develop branch ?

from reactphysics3d.

andreasdr avatar andreasdr commented on September 26, 2024

Ok. Nice. Will test later today.

from reactphysics3d.

andreasdr avatar andreasdr commented on September 26, 2024

Seems to be fixed. Thank you.

from reactphysics3d.

DanielChappuis avatar DanielChappuis commented on September 26, 2024

Ok Thanks. The fix is now merged in the master branch.

from reactphysics3d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.