2
votes

I´m using Libgdx with Box2D.

I have a Problem with destroying a joint when a specific body crashes on the ground, the colliding bodies are detected and then I want to destroy some joints. Always when I will do this i get an error.

Also I tested the destroy method seperatly for testing and i get the same error. It´s called right after the world.step(...) is this right?

I read about something that the error happens when the joints are destroyed inbetween the timestep, but how i could do this outside the world.step?

I´m using R.U.B.E. for the Box2d thing.

here is some code im testing with:

  scene.world.step(1.0f/scene.stepsPerSecond, scene.velocityIterations, scene.positionIterations);


          if(!scene.world.isLocked()){      //to check that the joint is no locked

         Joint joint1= scene.get(Joint.class, "joint1");   // read the joint from RUBE scene
         scene.world.destroyJoint(joint1);                   //destroy it


         }

This is the error:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006559368f, pid=5868, tid=3772
#
# JRE version: 7.0_07-b10
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.3-b01 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [gdx64.dll+0x1368f]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\Jake\Downloads\AndroidDevelopment\EclipseDaten\Motor-race-desktop\hs_err_pid5868.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
AL lib: alc_cleanup: 1 device not closed

Can anyone help me? :)

1
Please mention the error present in file C:\Users\Jake\Downloads\AndroidDevelopment\EclipseDaten\Motor-race-desktop\hs_err_pid5868.logVikalp Jain

1 Answers

1
votes

Best way to make sure that you destroy the joint without error is you take the reference of joint which needs to be destroyed and after the world.step() function you destroy the joint.

for eg

world.step(......);
 if(jointToDestroy != null) {
   world.destroyJoint(jointToDestroy); 
   jointToDestroy = null;
 }

Hope it helps.