They are falling under the plane :(

Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

They are falling under the plane :(

Post by Jack »

Situation:
Static plane (StaticPlaneShape). Objects (BoxShape, ConvexHullShape or ConvexTriangleMeshShape) are falling from some height down to the plane. They hit plane, simi-penetrate, reflect....hit again....roll/jump...simi-penetrate....and fall completly under the plane :(
If two objects collide, they penetrate deeply. They nearly do not sense each other.

Samples seem to work OK.

What can be wrong in my program?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

Without a sample file that is difficult to determine. Do you have a modified Bullet demo that shows similar behaviour?

Many things can be wrong. What is gravity? How large are the objects? What is the collision margin? Do you initialize the inertia tensor? What is the timestep?

Also, the continuous collision detection (CCD) is not enabled by default, which means there is no safety for fast moving objects (moving faster then their own size in one timestep). This CCD is work in progress, and should prevent objects going though eachother.

Thanks,
Erwin
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Post by Jack »

Erwin Coumans wrote:Without a sample file that is difficult to determine. Do you have a modified Bullet demo that shows similar behaviour?
No. Demos from the "bullet-1.9\msvc\8" folder work OK.
Erwin Coumans wrote:Many things can be wrong. What is gravity? How large are the objects? What is the collision margin? Do you initialize the inertia tensor? What is the timestep?
1) gravity = 9.8
2) BoxShape object (half size = 25), ConvexTriangleMeshShape approx. the size of the box object.
3) margin? what is it? I do not set it in my program...
4) inertia tensor comes from CalculateLocalInertia
5) timestep is constant = 1/60. By the way if I set variable timestep, ojects do not move at all (they freeze in the space)

Here is some fragments of my code:

PHYSICS::PHYSICS()
{
SimdVector3 worldAabbMin(-30000,-30000,-30000);
SimdVector3 worldAabbMax(30000,30000,30000);

_pDispatcher = new CollisionDispatcher;
_pBroadPhase = new AxisSweep3(worldAabbMin, worldAabbMax, 32766, 65535);
_pPhysEnv = new CcdPhysicsEnvironment(_pDispatcher, _pBroadPhase);
}

void ATOM::Initialize(SHAPE *const pShape, RENDER::ATOM *const pRenderAtom, bool bStatic)
{
assert(pShape);
assert(pRenderAtom);

_pRenderAtom = pRenderAtom;

_ci.m_MotionState = this;
_ci.m_collisionShape = pShape->m_pCollisionShape;
if(bStatic)
{
_ci.m_collisionFlags = CollisionObject::isStatic;
_ci.m_mass = 0;
_ci.m_collisionFilterGroup = CcdConstructionInfo::StaticFilter;
_ci.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter;
}
else
{
SimdVector3 LocalIn;
pShape->m_pCollisionShape->CalculateLocalInertia(1, LocalIn);

_ci.m_localInertiaTensor = LocalIn;
_ci.m_mass = 1;
_ci.m_gravity = SimdVector3(0, -9.8f, 0);
_ci.m_collisionFlags = 0;
}
_pPhyCtrl = new CcdPhysicsController(_ci);
}

void STATIC_PLANE_SHAPE::Initialize(const __m128 &vNormal)
{
m_pCollisionShape = new StaticPlaneShape(*(SimdVector3*)&vNormal, vNormal.m128_f32[3]);
}

void BOX_SHAPE::Initialize(const __m128 &vHalfSize)
{
m_pCollisionShape = new BoxShape(*(SimdVector3*)&vHalfSize);
}
Erwin Coumans wrote:Also, the continuous collision detection (CCD) is not enabled by default, which means there is no safety for fast moving objects (moving faster then their own size in one timestep). This CCD is work in progress, and should prevent objects going though eachother.
Objects fall from height = 100, 150 and 225 (starting speed=0). Their speeds at the surface are small. Sometimes objects do not fall thru the surface plane. They can lie on the surface but approx. 50% of the object is under the surface.
How to enable CCD?

Also sometimes
assert(proxy0 != proxy1);
from the
OverlappingPairCache::AddOverlappingPair(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1)
occurs
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

This assert should never fail. It's probably best to try to solve this offline, with a source sample.
Thanks,
Erwin
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Post by Jack »

I found! It is working now. My testbed is working!!!
I'll be creating my new game with BULLET now!

BULLET is GREAT! :D
User avatar
SteveBaker
Posts: 127
Joined: Sun Aug 13, 2006 4:41 pm
Location: Cedar Hill, Texas

Post by SteveBaker »

Jack wrote:I found! It is working now. My testbed is working!!!
I'll be creating my new game with BULLET now!

BULLET is GREAT! :D
What was wrong? Maybe someone else can benefit from what you learned?
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Post by Jack »

SteveBaker wrote:
Jack wrote:I found! It is working now. My testbed is working!!!
I'll be creating my new game with BULLET now!

BULLET is GREAT! :D
What was wrong? Maybe someone else can benefit from what you learned?
That was my stupid error:

void ATOM::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
{
const D3DXMATRIXA16 *const pmat = &_pRenderAtom->Final();

scaleX = 1;//pmat->_11;
scaleY = 1;//pmat->_22;
scaleZ = 1;//pmat->_33;
}

I took scale factors from 11,22,33 of the World Martix. It is of course wrong, if rotation is present.