Physics bug example code
by Jason Booth · in Torque Game Builder · 02/19/2006 (9:12 pm) · 4 replies
I believe this bug is cause when the physics polygon does not contain the center point of an object. Here is an example created in the level editor showing off the problem. Basically, instead of the first object landing on the second, it just jumps out of the way (in x) of the second object. If the collision polygon for the second object is redefined to have positive and negative Y values (thus, encapsulating 0,0) everything works as expected.
//--- OBJECT WRITE BEGIN ---
new t2dSceneGraph(error) {
canSaveDynamicFields = "1";
cameraSize = "100 75";
cameraPosition = "0 0";
new t2dStaticSprite() {
position = "-16.5 -15.6354";
size = "6.779 6.71271";
collisionDetectionMode = "POLYGON";
collisionResponseMode = "RIGID";
collisionActiveSend = "1";
collisionActiveReceive = "1";
collisionPhysicsSend = "1";
collisionPhysicsReceive = "1";
collisionLayerMask = "1";
collisionGroupMask = "1";
collisionCallback = "0";
collisionPolyList = "-1.000000 -1.000000 1.000000 -1.000000 1.000000 1.000000 -1.000000 1.000000";
collisionCircleScale = "1";
collisionPolyScale = "1 1";
collisionCircleSuperscribed = "1";
immovable = "0";
constantForce = "0 30";
graviticConstantForce = "1";
forwardOnly = "0";
forceScale = "1";
density = "0.01";
autoMassInertia = "1";
mass = "0.455054";
inertialMoment = "3.45141";
damping = "0";
friction = "0.3";
restitution = "1";
blendingOn = "1";
srcBlendFactor = "SRC_ALPHA";
dstBlendFactor = "ONE_MINUS_SRC_ALPHA";
blendColor = "1 1 1 1";
imageMap = "defaultImageMap";
frame = "0";
};
new t2dStaticSprite() {
position = "-15.7258 9.24372";
size = "14.1436 23";
rotation = "0";
autoRotation = "0";
collisionDetectionMode = "POLYGON";
collisionResponseMode = "CLAMP";
collisionActiveSend = "1";
collisionActiveReceive = "1";
collisionPhysicsSend = "1";
collisionPhysicsReceive = "1";
collisionLayerMask = "1";
collisionGroupMask = "1";
collisionCallback = "0";
collisionPolyList = "-0.985075 0.993884 -0.990050 0.785933 0.985075 0.773700 0.995025 0.993884";
collisionCircleScale = "1";
collisionPolyScale = "1 1";
collisionCircleSuperscribed = "1";
immovable = "1";
constantForce = "0 0";
graviticConstantForce = "0";
forwardOnly = "0";
forceScale = "1";
density = "0.01";
autoMassInertia = "1";
mass = "1.5969";
inertialMoment = "102.154";
damping = "0";
friction = "0.3";
restitution = "1";
blendingOn = "1";
srcBlendFactor = "SRC_ALPHA";
dstBlendFactor = "ONE_MINUS_SRC_ALPHA";
blendColor = "1 1 1 0.2";
imageMap = "defaultImageMap";
frame = "0";
};
};
//--- OBJECT WRITE END ---
//--- OBJECT WRITE BEGIN ---
new t2dSceneGraph(error) {
canSaveDynamicFields = "1";
cameraSize = "100 75";
cameraPosition = "0 0";
new t2dStaticSprite() {
position = "-16.5 -15.6354";
size = "6.779 6.71271";
collisionDetectionMode = "POLYGON";
collisionResponseMode = "RIGID";
collisionActiveSend = "1";
collisionActiveReceive = "1";
collisionPhysicsSend = "1";
collisionPhysicsReceive = "1";
collisionLayerMask = "1";
collisionGroupMask = "1";
collisionCallback = "0";
collisionPolyList = "-1.000000 -1.000000 1.000000 -1.000000 1.000000 1.000000 -1.000000 1.000000";
collisionCircleScale = "1";
collisionPolyScale = "1 1";
collisionCircleSuperscribed = "1";
immovable = "0";
constantForce = "0 30";
graviticConstantForce = "1";
forwardOnly = "0";
forceScale = "1";
density = "0.01";
autoMassInertia = "1";
mass = "0.455054";
inertialMoment = "3.45141";
damping = "0";
friction = "0.3";
restitution = "1";
blendingOn = "1";
srcBlendFactor = "SRC_ALPHA";
dstBlendFactor = "ONE_MINUS_SRC_ALPHA";
blendColor = "1 1 1 1";
imageMap = "defaultImageMap";
frame = "0";
};
new t2dStaticSprite() {
position = "-15.7258 9.24372";
size = "14.1436 23";
rotation = "0";
autoRotation = "0";
collisionDetectionMode = "POLYGON";
collisionResponseMode = "CLAMP";
collisionActiveSend = "1";
collisionActiveReceive = "1";
collisionPhysicsSend = "1";
collisionPhysicsReceive = "1";
collisionLayerMask = "1";
collisionGroupMask = "1";
collisionCallback = "0";
collisionPolyList = "-0.985075 0.993884 -0.990050 0.785933 0.985075 0.773700 0.995025 0.993884";
collisionCircleScale = "1";
collisionPolyScale = "1 1";
collisionCircleSuperscribed = "1";
immovable = "1";
constantForce = "0 0";
graviticConstantForce = "0";
forwardOnly = "0";
forceScale = "1";
density = "0.01";
autoMassInertia = "1";
mass = "1.5969";
inertialMoment = "102.154";
damping = "0";
friction = "0.3";
restitution = "1";
blendingOn = "1";
srcBlendFactor = "SRC_ALPHA";
dstBlendFactor = "ONE_MINUS_SRC_ALPHA";
blendColor = "1 1 1 0.2";
imageMap = "defaultImageMap";
frame = "0";
};
};
//--- OBJECT WRITE END ---
About the author
#2
02/20/2006 (1:11 pm)
Thats fine; I wasn't sure if it was a bug or not, but I spent about 2 days trying to figure out what was wrong so I figured I'd post this up here in case it was a bug or anyone else was having the same issue.
#3
02/20/2006 (1:14 pm)
Oh; just in case your mis-understanding me; the object without it's center point inside of the physics volume is set to clamp; the object which is rigid includes it's center point. I was also having these problems with clamp on both objects as well (though I didn't test it with this code), so it's not just rigid bodies which have this issue..
#4
Interesting. I'm not saying this is necessarily a good thing but currently, it is how it is. So many things to get fixed-up but please be assured that I'll take a good look at this situation as soon as humanly possible.
I've added this issue into our database (#1244).
Thanks for the heads-up.
- Melv.
02/21/2006 (10:15 am)
Jason,Interesting. I'm not saying this is necessarily a good thing but currently, it is how it is. So many things to get fixed-up but please be assured that I'll take a good look at this situation as soon as humanly possible.
I've added this issue into our database (#1244).
Thanks for the heads-up.
- Melv.
Associate Melv May
The rigid-body physics response should not only have the center-point inside the polygon but it must also try to be the center of mass where possible.
The is a lack of documentation on this area of the engine and there are several constraints when using the rigid-body physics, as you would expect. This is one of them. Not a bug but a constraint.
- Melv.