Joe can you tell me the sizes mass of the boxes so that I can recreate the problem.
or better yet copy teh script code that regerate the bug so that I paste in one of teh demos.?
Moderators: Sascha Willems, walaber
#if 1
{
dVector location (0.0f, 6.0f, 0.0f);
dVector size (1.5f, 2.0f, 2.0f, 0.0f);
NewtonWorld* const world = scene->GetNewton();
int materialID = NewtonMaterialGetDefaultGroupID (world);
NewtonCollision* const collision = CreateConvexCollision (world, dGetIdentityMatrix(), size, _BOX_PRIMITIVE, 0);
DemoMesh* const geometry = new DemoMesh("primitive", collision, "smilli.tga", "smilli.tga", "smilli.tga");
dFloat mass = 1.0f;
dMatrix matrix (dGetIdentityMatrix());
matrix.m_posit = location;
matrix.m_posit.m_w = 1.0f;
NewtonBody* const body = CreateSimpleSolid (scene, geometry, mass, matrix, collision, materialID);
geometry->Release();
NewtonDestroyCollision(collision);
}
{
dVector location (0.0f, 3.0f, 0.0f);
dVector size (1.5f, 2.0f, 2.0f, 0.0f);
NewtonWorld* const world = scene->GetNewton();
int materialID = NewtonMaterialGetDefaultGroupID (world);
NewtonCollision* const collision = CreateConvexCollision (world, dGetIdentityMatrix(), size, _BOX_PRIMITIVE, 0);
DemoMesh* const geometry = new DemoMesh("primitive", collision, "smilli.tga", "smilli.tga", "smilli.tga");
dFloat mass = 1.0f;
dMatrix matrix (dGetIdentityMatrix());
matrix.m_posit = location;
matrix.m_posit.m_w = 1.0f;
//NewtonBody* const body = CreateSimpleSolid (scene, geometry, mass, matrix, collision, materialID);
DemoMesh* const mesh = geometry;
DemoEntity* const entity = new DemoEntity(matrix, NULL);
scene->Append (entity);
if (mesh) {
entity->SetMesh(mesh, dGetIdentityMatrix());
}
//NewtonBody* body = CreateSimpleBody (scene->GetNewton(), entity, mass, matrix, collision, materialID);
NewtonBody* const rigidBody = NewtonCreateKinematicBody (world, collision, &matrix[0][0]);
NewtonBodySetMassProperties (rigidBody, mass, collision);
NewtonBodySetUserData (rigidBody, entity);
NewtonBodySetMaterialGroupID (rigidBody, materialID);
NewtonBodySetDestructorCallback (rigidBody, PhysicsBodyDestructor);
NewtonBodySetTransformCallback (rigidBody, DemoEntity::TransformCallback);
NewtonBodySetForceAndTorqueCallback (rigidBody, PhysicsApplyGravityForce);
geometry->Release();
NewtonDestroyCollision(collision);
}
#endif
dgKinematicBody::dgKinematicBody()
:dgBody()
{
m_collidable = false;
m_type = m_kinematicBody;
m_rtti |= m_kinematicBodyRTTI;
}
#if 1
{
dVector location (0.0f, 6.0f, 0.0f);
dVector size (1.5f, 2.0f, 2.0f, 0.0f);
NewtonWorld* const world = scene->GetNewton();
int materialID = NewtonMaterialGetDefaultGroupID (world);
NewtonCollision* const collision = CreateConvexCollision (world, dGetIdentityMatrix(), size, _BOX_PRIMITIVE, 0);
DemoMesh* const geometry = new DemoMesh("primitive", collision, "smilli.tga", "smilli.tga", "smilli.tga");
dFloat mass = 100.0f;
dMatrix matrix (dGetIdentityMatrix());
matrix.m_posit = location;
matrix.m_posit.m_w = 1.0f;
NewtonBody* const body = CreateSimpleSolid (scene, geometry, mass, matrix, collision, materialID);
geometry->Release();
NewtonDestroyCollision(collision);
}
{
dVector location (0.0f, 3.0f, 0.0f);
dVector size (1.5f, 2.0f, 2.0f, 0.0f);
NewtonWorld* const world = scene->GetNewton();
int materialID = NewtonMaterialGetDefaultGroupID (world);
NewtonCollision* const collision = CreateConvexCollision (world, dGetIdentityMatrix(), size, _BOX_PRIMITIVE, 0);
DemoMesh* const geometry = new DemoMesh("primitive", collision, "smilli.tga", "smilli.tga", "smilli.tga");
dFloat mass = 1.0f;
dMatrix matrix (dGetIdentityMatrix());
matrix.m_posit = location;
matrix.m_posit.m_w = 1.0f;
//NewtonBody* const body = CreateSimpleSolid (scene, geometry, mass, matrix, collision, materialID);
DemoMesh* const mesh = geometry;
DemoEntity* const entity = new DemoEntity(matrix, NULL);
scene->Append (entity);
if (mesh) {
entity->SetMesh(mesh, dGetIdentityMatrix());
}
//NewtonBody* body = CreateSimpleBody (scene->GetNewton(), entity, mass, matrix, collision, materialID);
NewtonBody* const rigidBody = NewtonCreateKinematicBody (world, collision, &matrix[0][0]);
NewtonBodySetMassProperties (rigidBody, mass, collision);
NewtonBodySetUserData (rigidBody, entity);
NewtonBodySetMaterialGroupID (rigidBody, materialID);
NewtonBodySetDestructorCallback (rigidBody, PhysicsBodyDestructor);
NewtonBodySetTransformCallback (rigidBody, DemoEntity::TransformCallback);
NewtonBodySetForceAndTorqueCallback (rigidBody, PhysicsApplyGravityForce);
NewtonBodySetCollidable (rigidBody, true);
geometry->Release();
NewtonDestroyCollision(collision);
}
#endif
Julio Jerez wrote:are you saying thsi was different before?
Julio Jerez wrote:k0 is the velocity penealty and k1 is the penetration penalty
This is a bit unclear to me. So those are constants that define how aggressive collision forces will be. Do the come from a #define, from solver or from user parameters?
1) M * a = Fe + Jt * l
10) J * inv(M) * Jt * l = - J * inv(M) * Fet - k0 * vr - k1 * he
[1 - 1] * [1/m 0] * [1 -1] * l = -[1 -1] * [1/m 0] * [w w] - k0 * 0 - k1 * 0
[0 1/m] [0 1/m]
(1/m + 1/m) * l = [w/m - w/m] = 0
l = 0
the magnitude of the reaction force is zero. so equation 1 becomes
M * a = Fe + J * 0
and each body fall with the acceleration of gravity
a0 = (w + 1 * (0)) (1/m) = w * (1/m) = -g
a1 = (w - 1 * (0)) * (1/m) = w * (1/m) = -g
which that is what we expect for such simple problem.
[1 - 1] * [1/m 0] * [1 -1] * l = -[1 -1] * [1/m 0] * [w w] - k0 * 0 - k1 * 0
[0 0] [0 0]
(1/m) * l = [w/m - 0] = -w/m0
l = w
the magnitude of the reaction force is the weight of the top body. so equation 1 becomes
a0 = (w + 1 * (-w)) ( 1/ m) = 0 * (1/m) = 0
a1 = (w - 1 * (-w)) * (0) = 2 * w * 0 = 0
so both bodies remind a rest, which is what we expect for a body resting of top of a static body
if (bodies[i1].mass != 0)
{
float extAcc0 = gravity;
float extAcc1 = gravity;
float w = bodies[i0].mass * extAcc0 + bodies[i1].mass * extAcc1;
float m = bodies[i0].mass + bodies[i1].mass;
a0 = (w + 1 * (0)) * (1/m);// = w * (1/m) = -g;
a1 = (w - 1 * (0)) * (1/m);// = w * (1/m) = -g;
base_debug::logA->PrintV ("Dyn-Dyn a0 %f a1 %f", a0, a1);
}
1) M * a = Fe + Jt * l
10) J * inv(M) * Jt * l = - J * inv(M) * Fet - k0 * vr - k1 * he
[1 - 1] * [1/100 0] * [1 -1] * l = -[1 -1] * [1/100 0] * [w w] - k0 * 0 - k1 * 0
[0 1/1] [0 0]
(1/100 + 1/1) * l = [w/100 - 0] = w/m0
l = 0.01 * w
teh reaction force is 1% of the weight, we can see that thsi will not be enough to stop the top body for falling
and each body fall with the acceleration of gravity
a0 = (w - 1 * (w * 0.01)) (1/100) = -0.99 * g
a1 = (w + 1 * (0)) * (0) = 0
you can see teh teh top body move with almist the force of gravity
if (bodies[i1].mass < 0) // using negative mass to identify kinetic body
{
float extAcc = gravity;
float w0 = bodies[i0].mass * extAcc;
//float w1 = 0;
float m0 = bodies[i0].mass;
float m1 = -bodies[i1].mass;
a0 = (w0 - 1 * (w0 * m0/m1)) * (1/m1);// = -0.99 * g; but i get 0.0099 * g
a1 = (w0 + 1 * (0)) * (0);// = 0
base_debug::logA->PrintV ("Dyn-Kin a0 %f a1 %f", a0, a1);
}
bodies[i0].acc = a0;
bodies[i1].acc = a1;
Julio Jerez wrote:which requires a very small penatration fo k1 * he to calcel it.
Users browsing this forum: Google Adsense [Bot] and 90 guests