本文整理汇总了C++中btTransform::inverseTimes方法的典型用法代码示例。如果您正苦于以下问题:C++ btTransform::inverseTimes方法的具体用法?C++ btTransform::inverseTimes怎么用?C++ btTransform::inverseTimes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类btTransform
的用法示例。
在下文中一共展示了btTransform::inverseTimes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pointShape
//.........这里部分代码省略.........
virtual btScalar addSingleResult (btCollisionWorld::LocalRayResult &r, bool b)
{
btCollisionWorld::LocalShapeInfo shapeInfo;
shapeInfo.m_shapePart = -1;
shapeInfo.m_triangleIndex = m_i;
if (r.m_localShapeInfo == NULL)
r.m_localShapeInfo = &shapeInfo;
const btScalar result = m_userCallback->addSingleResult(r, b);
m_closestHitFraction = m_userCallback->m_closestHitFraction;
return result;
}
};
struct RayTester : btDbvt::ICollide
{
btCollisionObject* m_collisionObject;
const btCompoundShape* m_compoundShape;
const btTransform& m_colObjWorldTransform;
const btTransform& m_rayFromTrans;
const btTransform& m_rayToTrans;
RayResultCallback& m_resultCallback;
RayTester(btCollisionObject* collisionObject,
const btCompoundShape* compoundShape,
const btTransform& colObjWorldTransform,
const btTransform& rayFromTrans,
const btTransform& rayToTrans,
RayResultCallback& resultCallback):
m_collisionObject(collisionObject),
m_compoundShape(compoundShape),
m_colObjWorldTransform(colObjWorldTransform),
m_rayFromTrans(rayFromTrans),
m_rayToTrans(rayToTrans),
m_resultCallback(resultCallback)
{
}
void Process(int i)
{
const btCollisionShape* childCollisionShape = m_compoundShape->getChildShape(i);
const btTransform& childTrans = m_compoundShape->getChildTransform(i);
btTransform childWorldTrans = m_colObjWorldTransform * childTrans;
// replace collision shape so that callback can determine the triangle
btCollisionShape* saveCollisionShape = m_collisionObject->getCollisionShape();
m_collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape);
LocalInfoAdder2 my_cb(i, &m_resultCallback);
rayTestSingle(
m_rayFromTrans,
m_rayToTrans,
m_collisionObject,
childCollisionShape,
childWorldTrans,
my_cb);
// restore
m_collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape);
}
void Process(const btDbvtNode* leaf)
{
Process(leaf->dataAsInt);
}
};
const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(collisionShape);
const btDbvt* dbvt = compoundShape->getDynamicAabbTree();
RayTester rayCB(
collisionObject,
compoundShape,
colObjWorldTransform,
rayFromTrans,
rayToTrans,
resultCallback);
#ifndef DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION
if (dbvt)
{
btVector3 localRayFrom = colObjWorldTransform.inverseTimes(rayFromTrans).getOrigin();
btVector3 localRayTo = colObjWorldTransform.inverseTimes(rayToTrans).getOrigin();
btDbvt::rayTest(dbvt->m_root, localRayFrom , localRayTo, rayCB);
}
else
#endif //DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION
{
for (int i = 0, n = compoundShape->getNumChildShapes(); i < n; ++i)
{
rayCB.Process(i);
}
}
}
}
}
}