|
|
|
@ -28,7 +28,7 @@ namespace Physic
|
|
|
|
|
mRaycastingBody = mEngine->createAndAdjustRigidBody(mMesh, mName, scale, position, rotation, &mBoxScaledTranslation, &mBoxRotation, true);
|
|
|
|
|
Ogre::Quaternion inverse = mBoxRotation.Inverse();
|
|
|
|
|
mBoxRotationInverse = btQuaternion(inverse.x, inverse.y, inverse.z,inverse.w);
|
|
|
|
|
mEngine->addRigidBody(mBody, false, mRaycastingBody); //Add rigid body to dynamics world, but do not add to object map
|
|
|
|
|
//mEngine->addRigidBody(mBody, false, mRaycastingBody,true); //Add rigid body to dynamics world, but do not add to object map
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PhysicActor::~PhysicActor()
|
|
|
|
@ -422,15 +422,17 @@ namespace Physic
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PhysicEngine::addRigidBody(RigidBody* body, bool addToMap, RigidBody* raycastingBody)
|
|
|
|
|
void PhysicEngine::addRigidBody(RigidBody* body, bool addToMap, RigidBody* raycastingBody,bool actor)
|
|
|
|
|
{
|
|
|
|
|
if(!body && !raycastingBody)
|
|
|
|
|
return; // nothing to do
|
|
|
|
|
|
|
|
|
|
const std::string& name = (body ? body->mName : raycastingBody->mName);
|
|
|
|
|
|
|
|
|
|
if (body)
|
|
|
|
|
dynamicsWorld->addRigidBody(body,CollisionType_World,CollisionType_World|CollisionType_ActorInternal|CollisionType_ActorExternal);
|
|
|
|
|
if (body){
|
|
|
|
|
if(actor) {dynamicsWorld->addRigidBody(body,CollisionType_ActorInternal,CollisionType_World|CollisionType_ActorInternal);std::cout << "actor";}
|
|
|
|
|
else dynamicsWorld->addRigidBody(body,CollisionType_World,CollisionType_World|CollisionType_ActorInternal|CollisionType_ActorExternal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (raycastingBody)
|
|
|
|
|
dynamicsWorld->addRigidBody(raycastingBody,CollisionType_Raycasting,CollisionType_Raycasting|CollisionType_World);
|
|
|
|
@ -603,14 +605,15 @@ namespace Physic
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::pair<std::string,float> PhysicEngine::rayTest(btVector3& from,btVector3& to)
|
|
|
|
|
std::pair<std::string,float> PhysicEngine::rayTest(btVector3& from,btVector3& to,bool raycastingObjectOnly)
|
|
|
|
|
{
|
|
|
|
|
std::string name = "";
|
|
|
|
|
float d = -1;
|
|
|
|
|
|
|
|
|
|
float d1 = 10000.;
|
|
|
|
|
btCollisionWorld::ClosestRayResultCallback resultCallback1(from, to);
|
|
|
|
|
resultCallback1.m_collisionFilterMask = CollisionType_Raycasting;
|
|
|
|
|
if(raycastingObjectOnly) resultCallback1.m_collisionFilterMask = CollisionType_Raycasting;
|
|
|
|
|
else resultCallback1.m_collisionFilterMask = CollisionType_ActorExternal;
|
|
|
|
|
dynamicsWorld->rayTest(from, to, resultCallback1);
|
|
|
|
|
if (resultCallback1.hasHit())
|
|
|
|
|
{
|
|
|
|
|