Collision on a custom dynamic mesh

Whenever I try to modify my custom mesh (only adding so far) I want to update the collision shape aswel. My mesh is transformed in the scene and I have bulletAppState.getPhysicsSpace().enableDebug(assetManager); on.



The original mesh has the blue wireframe around it, indicating that there is collision on that part of the mesh. After the transformation of the mesh I call .createCollisionData(); on my mesh. The new part of the mesh does not have any collision shape drawn around it.

Am I missing something?

Yeah, you are missing that you are updating the collision data for the bounds/geometry based collision and not for bullet physics.

1 Like

Ah damn I totally got that wrong… I see that now…

I’m guessing I have to build a collisionshape with GImpactCollisionShape or createDynamicMeshShape?

But how would you update these shapes when the mesh updates?

You would have to recreate them.

I had a similar issue, after updating a custom mesh then calling updateBound() to update the geometry, then I needed to call createCollisionData(); to update the collision shape.



Might help.



Cheers.

I created my collision shape for my dynamic terrain, whenever the mesh updates my collision shape updates with it… All of this is working fine. Although I have another issue now…

I have a player that stands on top of the part where I’m going to update the collision shape. The player has collision capsule shape around him aswel. Whenever the collision shape updates depending on how fast the collision shape updates my player either gets stuck in the terrain or he falls through it.

[java]if(filled){

state.getPhysicsSpace().remove(levelGeom);

levelGeom.removeControl(terrainCollisionShape);

}

sceneShape = new MeshCollisionShape(chunkMesh);

terrainCollisionShape = new RigidBodyControl(sceneShape, 0);

levelGeom.addControl(terrainCollisionShape);

state.getPhysicsSpace().add(levelGeom);[/java]



Any ideas on how to solve this?

I would guess that you have to


  1. create your new collision shapes
  2. translate your character to the new height of the collision shape (or slightly above it)



    It sounds like you raise your terrain (adding) without informing the character that it is now suddenly supposed to stand on a piece of terrain that is higher than it was a second ago and the new terrain/collision thingie is now where the character’s head is (or above the lowest point of the collision capsule).



    Not sure if this makes sense or if there is a automagic way to do this.



    My guess for why this is happening is because you are recreating the whole collision mesh and not in fact pushing it upwards by a force or something which would have made whatever was ontop of the thingie being pushed up, to be pushed up as well.



    Cheers