Hello,
I faced a problem with btHeightfieldTerrainShape which doesn't collide with anything, not even btSphereShape.
Suprisingly raycasting with this shape enabled results in nice raycast positions, matching the terrain perfectly .
If I raycast and create a sphere some meters above, it will fall through.
I recorded a video of that issue https://youtu.be/ZK2d4dQB3w0
Here is the code I use to initialize physics, very standard setting https://github.com/achlubek/venginenati ... hysics.cpp
Please if you can help I will be very thankful!
[SOLVED] btHeightfieldTerrainShape wont collide, raycast ok
-
- Posts: 3
- Joined: Tue Feb 28, 2017 8:06 pm
[SOLVED] btHeightfieldTerrainShape wont collide, raycast ok
Last edited by aeroflyluby on Wed Mar 01, 2017 4:45 pm, edited 1 time in total.
Re: btHeightfieldTerrainShape doesn't collide but raycast go
At a glance it looks like your using rigid bodies for everything, should use btCollisionObject for static concave collision shapes like btBvhTriangleMeshShape and btHeightfieldTerrainShape. I'm not sure that's the source of the problem though. Things to check would be collision groups and filters, and activation state. I am not sure what else could be wrong if ray test works but not collision.
-
- Posts: 3
- Joined: Tue Feb 28, 2017 8:06 pm
Re: btHeightfieldTerrainShape doesn't collide but raycast go
Thank you for your response. I was indeed threating everything as btRigidBody, but changing terrain to use btCollisionObject doesn't make any change. I also reviewed collision groups and masks, also collision objects flags, everything seems ok.ktfh wrote:At a glance it looks like your using rigid bodies for everything, should use btCollisionObject for static concave collision shapes like btBvhTriangleMeshShape and btHeightfieldTerrainShape. I'm not sure that's the source of the problem though. Things to check would be collision groups and filters, and activation state. I am not sure what else could be wrong if ray test works but not collision.
It seems like a bug somewhere in btHeightfieldTerrainShape collision detection, but I have no idea how it works internally.
Re: btHeightfieldTerrainShape doesn't collide but raycast go
I just tried the height field out it seems fine. Can you try some minimal implementation and drop a ball on it?
Code: Select all
void* data = calloc(100*100, sizeof(float));
btHeightfieldTerrainShape* hf = new btHeightfieldTerrainShape(100, 100, data, 1, 0, 1, 1, PHY_FLOAT, flase);
btCollisionObject* body = new btCollisionObject();
body->setCollisionShape(hf);
dynamicsWorld->addCollisionObject(body);
-
- Posts: 3
- Joined: Tue Feb 28, 2017 8:06 pm
Re: btHeightfieldTerrainShape doesn't collide but raycast go
I have tried your code and it worked beautifully.ktfh wrote:I just tried the height field out it seems fine. Can you try some minimal implementation and drop a ball on it?Code: Select all
void* data = calloc(100*100, sizeof(float)); btHeightfieldTerrainShape* hf = new btHeightfieldTerrainShape(100, 100, data, 1, 0, 1, 1, PHY_FLOAT, flase); btCollisionObject* body = new btCollisionObject(); body->setCollisionShape(hf); dynamicsWorld->addCollisionObject(body);
I messed with my code and I found out that I missed heightMin/Max parameters, now I detect it while loading parameters. Also I needed to translate mesh afterwards to accomodate its recentering along minmax height.
It now works great! http://i.imgur.com/e9wC0rc.jpg
Thank you very much ktfh