Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 31 Aug 2010
Offline Last Active Aug 18 2014 03:48 PM

Topics I've Started

Bullet Physics - Objects pass through certain triangles in mesh

02 June 2014 - 02:42 PM



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));

// This is done in a separate threads.  Making it single-threaded made no difference.

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->setLinearVelocity(btVector3(0, 0, 0));
physicsRigidBody->setAngularVelocity(btVector3(0, 0, 0));


And updating Bullet Physics:

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

OpenGL color interpolation not linear?

02 January 2014 - 06:13 PM

I have a rather simple problem that I am positive has a simple solution.  I am rendering a quad twice as two layers, each with a color.  The first is green, the second is red.  I am using the alpha channel of the color component for the quad's vertices to blend the two colors together across the quads.


Attached bellow are two images.  Image A is how it looks when rendered with OpenGL, image B is how it should look.  The black color in image A is the background bleeding through.  If OpenGL interpolated the color values linearly there would be no bleeding, it would be a nice transition from red to green and no black would show.  But that's obviously not the case.


I've tried using a GLSL program and setting the color variable to noperspective but it makes no difference.  Is there a way to force OpenGL to do plain linear interpolation of my vertex colors, so that the red and green blend evenly across the quad like in image B?


Additional information:

Red layer alpha values:
1.0 -------- 0.0
|             |
|             |
|             |
0.0 -------- 1.0

Green layer alpha values:
0.0 -------- 1.0
|              |
|              |
|              |
1.0 -------- 0.0



Template specialization and class references

15 March 2013 - 09:16 AM

Consider the following:


class Vector3 {
	f64 x, y, z;

// pass an unkown userdata type to lua
template<typename T> inline void luaPushArg(lua_State * const LuaState, T arg) {
	tolua_pushusertype(LuaState, (void*)&arg, typeid(T).name() + 6);

void testFunction(const Vector3 &v) {
	luaPushArg(LuaState, v);
	luaCallFunction("TestFunction"); // CRASH (only sometimes though!)



What went wrong here?  Can you spot the bug?  This one was a real pain in the tush.  luaPushArg() would work with all my specialized types (int, float, etc) that I was passing to Lua, but when I passed classes it would sometimes crash.  Turns out that luaPushArg() is taking a T arg instead of a T &arg.  This means that a new copy of 'v' is created inside testFunction() when it calls luaPushArg().  luaPushArg() then pushes the newly created object onto the Lua stack.  Upon luaPushArg()'s return, the pointer too the class object that was just pushed onto the lua stack is now invalidated.  Sometimes it would crash, sometimes it wouldn't.  This one was a real nightmare.



Hehehe biggrin.png.  I can't wait for C11 support in GCC, that way bugs like this can be avoided using type-generic expression macros.

Pay someone without PayPal

04 September 2012 - 09:11 AM

Hi Posted Image

I need to make payments to a freelancer who lives in Sweden. He has requested that we not use PayPal (eg "paypal is stealing my money!"). Ive looked into doing an International Wire Transfer but it would add a 15% overhead to my costs. I looked into Western Union and it didn't work out for many reasons (very poor customer support being one of them). Money Gram only supports physically going to an agent and picking it up but that's not an option because I would prefer to just do it electronically (minimal hassle on the client). The US post office doesn't do money orders to Sweden. I have no clue if I could send him a check (or a prepaid visa) and if it would work over there.

Does anyone know what the best way would be to pay someone in Sweden? Maybe I will pay him in fruit-baskets from an online gift shop xD.

Assimp only importing some bones?

10 July 2012 - 10:59 AM


I have written a tool based off of Assimp that converts collada/fbx models to a custom format. For some reason assimp is omitting some of the mesh's bones from the aiMesh::mBones list, but they still appear in the aiScene::mRootNode node tree. This causes my converter to mangle the bone tree structure, because some of the bone's parent bones don't appear in the aiMesh::mBones list!

Here is an example. The "RiggedModel_Final_FootNull" gets omitted from the aiMesh::mBones list but its children are not. Why does assimp do this and how would I fix it? It would be great if assimp would store all bones in the bone list.
<node name="RiggedModel_Final_FootNull" id="RiggedModel_Final_FootNull" sid="RiggedModel_Final_FootNull" type="JOINT">
				  <matrix sid="matrix">-0.059679 -0.519840 0.852176 6.103344 -0.147692 0.848900 0.507499 -0.000000 -0.987231 -0.095573 -0.127438 -0.000000 0.000000 0.000000 0.000000 1.000000</matrix>
					<technique profile="FCOLLADA">
				  <node name="RiggedModel_Final_Outtue_L" id="RiggedModel_Final_Outtue_L" sid="RiggedModel_Final_Outtue_L" type="JOINT">
					<matrix sid="matrix">0.922692 0.327107 -0.204061 1.479940 -0.312313 0.944503 0.101859 0.000000 0.226055 -0.030253 0.973645 0.000000 0.000000 0.000000 0.000000 1.000000</matrix>
					  <technique profile="FCOLLADA">

I really appreciate any and all help!