setIsDebugItemDisplayed crash? #320
-
Hello, I am having a very weird issue. So far I have only two things in my project; a rigid body with a heightfield shape, and the debugrenderer. I set everything up like I did last time, and it all works well. But I kept getting crashes, and wasn't sure why it was happening. I kept removing and commenting out things until I found out that debugRenderer.setIsDebugItemDisplayed was the problem. When I leave it in, I can render the terrain collider, but there is always a 40% chance of crashing on the first render pass. If it doesn't crash, it works fine and doesn't seem to have any issue. But it's just that randomly it will decide to crash between builds. Now, when I remove it, I get no crash. Everything else is the same, such as creating the collider and rigidbody, creating and updating the world, setting up VBOs for debug renderer, etc. I just comment out the one line where debug item is called, and everything works. Even when I remove everything else, just having that line in crashes it. I am very confused as to why this would be. My best guess is that my terrain is 100 x 100 vertices, which may be too many triangles for the debug renderer. BUT, as I said, it works fine if it doesn't crash on start, so I don't think it's that. I even shrunk the terrain and it still happens. It closes instantly and there is no error message from the compiler, opengl, or from rp3d asserts. So it sounds like undefined behavior, but I have no idea why that would happen. Everything else in the project seems to be running fine so far. If you have any clue as to why this may be happening, please let me know. |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments
-
Alright, so I don't think it's that. I changed heightfield to a capsule just to test, and it worked fine. Even when I made 100, it still didn't crash. So I think the problem is with heightfieldshape. I am also unable to add height data when creating the heightfield, so it seems that there's something going wrong there. Not sure what the problem could be |
Beta Was this translation helpful? Give feedback.
-
Are you compiling the library in DEBUG or RELEASE mode when it crashes? Can you try to compile everything (the ReactPhysics3D library and your code) in DEBUG mode and try to run it? If the application crashes in DEBUG mode, you will probably get a stacktrace and know when it crashes exactly. |
Beta Was this translation helpful? Give feedback.
-
I built it in debug and it caught a couple more errors, but it's still happening. I don't think it's a problem with the engine, just me. HeightFieldShape.cpp, Line 440 So I assume I'm doing the heightfield wrong. But sometimes when I try to use something like a sine function to get points, it just crashes without any assert. I assume the aabb is generated by getting the width and height, and the min and max points. What I don't understand is that it crashes when world->update() is called. If I leave it off, everything builds fine. But once I call it, it crashes, sometimes throwing the assert. |
Beta Was this translation helpful? Give feedback.
-
Can you try to create a very simple heigtfield? For instance a 4x4 grid with a constant height and see if it's working. |
Beta Was this translation helpful? Give feedback.
-
Same thing. Am I doing this right? a 4x4 heightfield with height of 1: `
` And creating a heightfield:
Adding it to rigidbody:
|
Beta Was this translation helpful? Give feedback.
-
I think I know what you are doing wrong. The idea of the height-field is to provide only the height values of your grid and not the whole 3D coordinates of each point. Therefore, If you have a 4x4 height-field with a constant height of 1.0 then you must only put the 16 height values in your array. Your array would then be:
This is the advantage of the HeightFieldShape compared to the ConcaveMeshShape, you only need to provide height values and the 3D mesh will be computed automatically by the library. |
Beta Was this translation helpful? Give feedback.
-
I GOT IT! So yes, that was a problem. Forgot it's just the y values lol. Thank you for your help! |
Beta Was this translation helpful? Give feedback.
-
You are welcome. I am glad that you have fixed your issue. |
Beta Was this translation helpful? Give feedback.
I think I know what you are doing wrong. The idea of the height-field is to provide only the height values of your grid and not the whole 3D coordinates of each point. Therefore, If you have a 4x4 height-field with a constant height of 1.0 then you must only put the 16 height values in your array. Your array would then be:
const float heights[] = {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,}; };
This is the advantage of the HeightFieldShape compared to the ConcaveMeshShape, you only need to provide height values and the 3D mesh will be computed automatically by the library.