@Joe
I switched to 2.76 and it looks like this now:
Code:
///// Instant Collision Query
btDeepestContactResultCallback contRes(wheel_infos[wheel]->wheelCollisionObject,chassisBody,false);
// Query for result
m_dynamics_world->contactTest( wheel_infos[wheel]->wheelCollisionObject,contRes);
(I wrote the callback myself.)
So there is only a collision test done (and that several times, for new positions if one wants to). Performance seems ok. What do you think?
Ok, i got those parameters totally wrong (normal, position and wheelheight).
How do I have to fill them?
Are the following assumptions right?
* normal -> has nothing to do with collision itself? just the normal on the surface at the collision point? currently I am using the collision normal between the two collision points.
* Position-> Is it correct to just take the deepest point of the collision of the wheel (with positions from getWheelPosition and orientation from getWheelOrientation)?
* Wheelheight-> It is a projection from the {colPoint to the wheel center point vector} to the {average direction of suspension displacement}. what do you mean by the latter?
I interpreted something like: ( wheelCenter-colPoint) x ( (0,0,-1).rotate(wheelOrientationFloating) )
Not sure, whether this makes sense....
I especially don't know where to get the following from:
Quote:the position where the tire patch would touch the road if the suspension were deflected as far as needed to cause the tire to touch the ground
I can only collide the wheel in the position it is and not get the point, where it would collide if it was deflected correctly.
@NaN: The problem is, that my code is not really compatible. I did not use the car class itself to implement stuff, but inherited an interface class to put it in our simulation. it contains a lot of specific Open Scene Graph things, I don't use the graphic models from vdrift, etc. I will surely help you and you can of course have my code (although you will have to wait a little, till it is readable

)
Edit: Forget about the things I said about averaging the speed. I am not sure why, but the results are better when just taking the final vdrift speed (I tested it by letting a car and bullet objects fall from some hundred meters and watching which arrived at the ground first.
Edit:
This seems to work properly... Still have to get the surface normal.
Just taking the collision point (that one on the surface) works and seems to work as an approximation to the contact point with optimally deflected suspension. (values greater than the tire radius are not used, right? ) .
Code:
///// Instant Collision Query
btDeepestContactResultCallback contRes(wheel_infos[wheel]->wheelCollisionObject,chassisBody,false);
// Query for result
m_dynamics_world->contactTest( wheel_infos[wheel]->wheelCollisionObject,contRes);
if (contRes.m_hitCount>0)
{
colPoint=contRes.getPoint();
//colNormal= contRes.getNormal();
colNormal= btVector3(0,0,1);
//colDepth= contRes.getHitDepth();
// Vector from collision point to wheel center
btVector3 wheelLocalHitPos= wheel_infos[wheel]->wheelRigidbody->getCenterOfMassPosition() -colPoint;
// Get the normal of the suspension
btVector3 down (0,0,1);
down.rotate(wheel_infos[wheel]->wheelRigidbody->getOrientation().getAxis(),wheel_infos[wheel]->wheelRigidbody->getOrientation().getAngle());
//down.normalize();
//cout << "down "<< down.x()<<" "<< down.y()<<" "<< down.z()<<endl;
double projectedDepth= wheelLocalHitPos.dot(down);
double distanceFromWheelCenter = projectedDepth;
car_dynamics->SetWheelContactProperties(WHEEL_POSITION(wheel), (double)distanceFromWheelCenter ,getMATHVECTOR(colPoint), getMATHVECTOR(colNormal),bumpwave, bumpamp, frict_no, frict_tread, roll_res, roll_drag, surface);
std::cout << "ColPoint: " << colPoint.getX() << " " << colPoint.getY() << " " << colPoint.getZ() <<endl;
std::cout << " Collision normal: "<< colNormal.getX() << " " << colNormal.getY() << " " << colNormal.getZ() << std::endl;
cout << " Wheelheight: " << "tire radius: "<<car.GetTireRadius((WHEEL_POSITION)wheel)<<" distance: "<<distanceFromWheelCenter<<endl;
cout << "-----------------------------------"<<endl;
} else
{
//cout << "NOOO"<<endl;
car_dynamics->SetWheelContactProperties(WHEEL_POSITION(wheel), (double)1000,
MATHVECTOR<double,3>(0), MATHVECTOR<double,3>(0,0,1),
bumpwave, bumpamp, frict_no, frict_tread, roll_res, roll_drag, surface);
}
@Joe: Another thing:
Shouldn't the tread change with the tire contact? I think it is not used at all (set to zero in all .car files).