Moderators: Sascha Willems, walaber
Julio Jerez wrote:Ok, it is fixed now. Please sync to SVN again.
This was a bad bug
*const dFloat* *matrix - pointer to an array of at least three floats containing the beginning and orienetaion of the shape in global space.
// convexCast
void NewtonScene::convexCast (const BodyID & bodyID,
TraceDataf & traceData)
{ TRACE("NewtonScen::convexCast")
PhysicsBodies::iterator it = bodies_.find(bodyID);
if ( it != bodies_.end() )
{
PhysicsBody::Ptr pBody = it->second;
if( pBody && pBody->component )
{
const NewtonBody * const newtonBody = (NewtonBody*)pBody->component->userData;
if( !newtonBody ) return;
NewtonCollision * const shape = NewtonBodyGetCollision(newtonBody);
if( !shape ) return;
dMatrix matrix;
NewtonToolBase::convertEigenToNewtonPose(pBody->component->worldTransform, matrix);
Matrix3f orientation = pBody->component->worldTransform.linear();
// ray is along the Z
Vector3f rayEnd = pBody->component->worldTransform.translation() + (1000000 * orientation.col(2).normalized());
dVector endPoint( rayEnd[0], rayEnd[1], rayEnd[2] );
dFloat hitParam;
NewtonWorldConvexCastReturnInfo info[16];
int count = NewtonWorldConvexCast (world_, &matrix[0][0], &endPoint[0], shape, &hitParam, NULL, NULL, &info[0], 4, 0);
if (count)
{
const NewtonBody* hitBody = info->m_hitBody;
NewtonEntity * body = (NewtonEntity*) NewtonBodyGetUserData(hitBody);
matrix.m_posit += (endPoint - matrix.m_posit).Scale (hitParam);
DB(pBody->name + " hit " + body->name);
dVector v = matrix.m_posit;
Vector3f p( v[0], v[1], v[2] );
pBody->component->worldTransform.translation() = p;
}
}
}
}
Julio Jerez wrote:is this the very latest I check in this morning?
Bird wrote:*const dFloat* *matrix - pointer to an array of at least three floats containing the beginning and orienetaion of the shape in global space.
Is that correct. That doesn' look like what you're doing in the Convex Cast demo scene.
I am sure you have it right, but make sure that it is right
to clarify, did this was working and just broke on my last fix or was it broke before.
float x = dFloat (mouseX);
float y = dFloat (mouseY);
dVector p0 (camera->ScreenToWorld(dVector (x, y, 0.0f, 0.0f)));
dVector p1 (camera->ScreenToWorld(dVector (x, y, 1.0f, 0.0f)));
// do the convex cast here
dMatrix matrix (GetIdentityMatrix());
matrix.m_posit = p0;
dFloat hitParam;
NewtonWorldConvexCastReturnInfo info[16];
NewtonCollision* const shape = m_stupidLevel->GetCurrentShape();
int count = NewtonWorldConvexCast (world, &matrix[0][0], &p1[0], shape, &hitParam, NULL, NULL, &info[0], 4, 0);
The funtion is call wi the casted body, the shape hit, and the userdata that you pass to the call, then in the fiolter call bakc you chek if the body, maches
anyone that you place on some list of objects, and if it does returrn false so that is skip that object or shape.
It is very similar to ray cast.
My guess that this is the problem
Users browsing this forum: No registered users and 3 guests