• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Conoktra

Bullet Physics - Objects pass through certain triangles in mesh

7 posts in this topic

Hello.

 

I am using Bullet Physics 2.82 and am getting some weird results.  I build some voxel terrain and pass the mesh information to Bullet Physics (via btTriangleIndexVertexArray with btBvhTriangleMeshShape).  It works fantastically, except that in certain spots basic shapes can fall through the terrain.  Here is a video of it:  http://www.youtube.com/watch?v=-sElC7c-Ug8&t=0m23s

 

I have tried quite a bit to fix it, and post here as a "last resort" of sorts.  Help is very much appreciated!  I have tried:

  • Rebuilding Bullet Physics with double precision.
  • Increasing the cycles-per second to 120 and even 240 simulations/second.
  • Increased all objects' collision margins (btCollisionShape::setMargin()) to larger values (0.1, 0.5, 1.0).
  • Reversed the vertex winding order (in-case it was a backward facing polygon allowing the fall-through).

And still objects fall through the terrain!  There is no visual deformity-- the terrain is built and displayed correctly.  The debug drawer also shows the terrain is built in that area.  The physics shape is built off of the same data that is used for the rendering.  Any idea on what could cause this?

 

Terrain initialization (performed on each chunk of the terrain's octree):

// pre-filled, just here to show you the declaration
s32 * indices;
btScalar * vertices;

physicsMesh = new btTriangleIndexVertexArray(mesh->indices.size() / 3, indices, sizeof(s32) * 3, mesh->vertices.size(), vertices, sizeof(btScalar) * 3);

physicsShape = new btBvhTriangleMeshShape(physicsMesh, true, true);
physicsShape->setMargin(0.04); // tried changing to 0.1/0.5/1.0

btVector3 inertia(0, 0, 0);
physicsShape->calculateLocalInertia(0.0, inertia);

physicsMotionState = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0, 0, 0)));
btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(
	0,  // mass
	physicsMotionState,// initial position
	physicsShape,      // collision shape of body
	inertia   // local inertia
);

physicsRigidBody = new btRigidBody(rigidBodyCI);
physicsRigidBody->setLinearVelocity(btVector3(0, 0, 0));
physicsRigidBody->setAngularVelocity(btVector3(0, 0, 0));
physicsRigidBody->setFriction(1.0);

// This is done in a separate threads.  Making it single-threaded made no difference.
bulletManager.lock();
bulletManager.addRigidBody(physicsRigidBody);
bulletManager.unlock();

Basic shape initialization:

physicsShape = new btSphereShape(minGroupRange);
physicsShape->setMargin(0.04); // tried 0.1/0.5/1.0

btVector3 inertia(0, 0, 0);
physicsShape->calculateLocalInertia(1.0, inertia);

btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(
	1.0,   // mass
	this,  // initial position
	physicsShape,  // collision shape of body
	inertia // local inertia
);

physicsRigidBody = new btRigidBody(rigidBodyCI);
physicsRigidBody->clearForces();
physicsRigidBody->setLinearVelocity(btVector3(0, 0, 0));
physicsRigidBody->setAngularVelocity(btVector3(0, 0, 0));
//physicsRigidBody->setActivationState(DISABLE_DEACTIVATION);

BulletManager::get().addRigidBody(physicsRigidBody);

And updating Bullet Physics:

dynamicsWorld->stepSimulation(timer.getDeltaTime_Seconds());
//dynamicsWorld->stepSimulation(timer.getDeltaTime_Seconds(), 10, 1.0 / 240);
0

Share this post


Link to post
Share on other sites

Why don’t you check the original mesh in that area in a tool or draw its triangles and check it in your engine and see what kind of triangles are living there?


Following up on Spiro, I suggest you add the ability to draw a wireframe of your mesh, highlight shared edges and non-shared edges (and vertices), draw normals for each vertex and face, and counts triangles, slivers, denormalized triangles, etc.

The very first thing you should ever get up and running in any graphics engines is your debug drawing facilities. smile.png
1

Share this post


Link to post
Share on other sites

Bullet debug draw should give you the ability to draw contact normals and so on which should help.

Does this problem occur with all collision shapes for just spheres ? 2.82 seems to have have a few new issues with heightfield and triangle mesh collisions which previous versions didn't so that might also be worth looking at.

What is the size of your sphere (minGroupRange ) ?

1

Share this post


Link to post
Share on other sites

I had same or similar problem

Try changing m_fixContactNormalDirection from 1 to 0 in constructors of btGjkPairDetector

That helped me.

1

Share this post


Link to post
Share on other sites

Thank you to everyone the help!  It turns out it was the "sliver" problem.  Marching cubes was making some triangles that where simply too small and narrow in certain places.  Tweaking the scale was able to increase the stability.  Thanks again.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0