本文整理汇总了C#中BulletXNA.LinearMath.IndexedMatrix.InverseTimes方法的典型用法代码示例。如果您正苦于以下问题:C# IndexedMatrix.InverseTimes方法的具体用法?C# IndexedMatrix.InverseTimes怎么用?C# IndexedMatrix.InverseTimes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BulletXNA.LinearMath.IndexedMatrix
的用法示例。
在下文中一共展示了IndexedMatrix.InverseTimes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public static void Initialize(ConvexShape shape0,ref IndexedMatrix wtrs0,
ConvexShape shape1,ref IndexedMatrix wtrs1,
ref GjkEpaSolver2Results results,
GjkEpaSolver2MinkowskiDiff shapeR,
bool withmargins)
{
/* Results */
results.witnesses0 = IndexedVector3.Zero;
results.witnesses1 = IndexedVector3.Zero;
results.status = GjkEpaSolver2Status.Separated;
/* Shape */
shapeR.m_shapes[0] = shape0;
shapeR.m_shapes[1] = shape1;
shapeR.m_toshape1 = wtrs1._basis.TransposeTimes(ref wtrs0._basis);
shapeR.m_toshape0 = wtrs0.InverseTimes(ref wtrs1);
#if DEBUG
if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugGJK)
{
MathUtil.PrintMatrix(BulletGlobals.g_streamWriter, "gjksolver2::init::shape0", shapeR.m_toshape0);
MathUtil.PrintMatrix(BulletGlobals.g_streamWriter, "gjksolver2::init::WTRS0", wtrs0);
MathUtil.PrintMatrix(BulletGlobals.g_streamWriter, "gjksolver2::init::WTRS1", wtrs1);
MathUtil.PrintMatrix(BulletGlobals.g_streamWriter, "gjksolver2::init::shape1", shapeR.m_toshape1);
}
#endif
shapeR.EnableMargin(withmargins);
}
示例2: RayTestSingle
//.........这里部分代码省略.........
if (collisionShape.GetShapeType() == BroadphaseNativeTypes.TRIANGLE_MESH_SHAPE_PROXYTYPE && collisionShape is BvhTriangleMeshShape)
{
///optimized version for btBvhTriangleMeshShape
BvhTriangleMeshShape triangleMesh = (BvhTriangleMeshShape)collisionShape;
IndexedMatrix worldTocollisionObject = colObjWorldTransform.Inverse();
IndexedVector3 rayFromLocal = worldTocollisionObject * rayFromTrans._origin;
IndexedVector3 rayToLocal = worldTocollisionObject * rayToTrans._origin;
IndexedMatrix transform = IndexedMatrix.Identity;
using (BridgeTriangleRaycastCallback rcb = BulletGlobals.BridgeTriangleRaycastCallbackPool.Get())
{
rcb.Initialize(ref rayFromLocal, ref rayToLocal, resultCallback, collisionObject, triangleMesh, ref transform);
rcb.m_hitFraction = resultCallback.m_closestHitFraction;
triangleMesh.PerformRaycast(rcb, ref rayFromLocal, ref rayToLocal);
}
}
else if (collisionShape.GetShapeType() == BroadphaseNativeTypes.TERRAIN_SHAPE_PROXYTYPE && collisionShape is HeightfieldTerrainShape)
{
///optimized version for btBvhTriangleMeshShape
HeightfieldTerrainShape heightField = (HeightfieldTerrainShape)collisionShape;
IndexedMatrix worldTocollisionObject = colObjWorldTransform.Inverse();
IndexedVector3 rayFromLocal = worldTocollisionObject * rayFromTrans._origin;
IndexedVector3 rayToLocal = worldTocollisionObject * rayToTrans._origin;
IndexedMatrix transform = IndexedMatrix.Identity;
using (BridgeTriangleConcaveRaycastCallback rcb = BulletGlobals.BridgeTriangleConcaveRaycastCallbackPool.Get())
{
rcb.Initialize(ref rayFromLocal, ref rayToLocal, resultCallback, collisionObject, heightField, ref transform);
rcb.m_hitFraction = resultCallback.m_closestHitFraction;
heightField.PerformRaycast(rcb, ref rayFromLocal, ref rayToLocal);
}
}
else
{
//generic (slower) case
ConcaveShape concaveShape = (ConcaveShape)collisionShape;
IndexedMatrix worldTocollisionObject = colObjWorldTransform.Inverse();
IndexedVector3 rayFromLocal = worldTocollisionObject * rayFromTrans._origin;
IndexedVector3 rayToLocal = worldTocollisionObject * rayToTrans._origin;
//ConvexCast::CastResult
IndexedMatrix transform = IndexedMatrix.Identity;
using (BridgeTriangleConcaveRaycastCallback rcb = BulletGlobals.BridgeTriangleConcaveRaycastCallbackPool.Get())
{
rcb.Initialize(ref rayFromLocal, ref rayToLocal, resultCallback, collisionObject, concaveShape, ref transform);
rcb.m_hitFraction = resultCallback.m_closestHitFraction;
IndexedVector3 rayAabbMinLocal = rayFromLocal;
MathUtil.VectorMin(ref rayToLocal, ref rayAabbMinLocal);
IndexedVector3 rayAabbMaxLocal = rayFromLocal;
MathUtil.VectorMax(ref rayToLocal, ref rayAabbMaxLocal);
concaveShape.ProcessAllTriangles(rcb, ref rayAabbMinLocal, ref rayAabbMaxLocal);
}
}
BulletGlobals.StopProfile();
}
else
{
BulletGlobals.StartProfile("rayTestCompound");
///@todo: use AABB tree or other BVH acceleration structure, see btDbvt
if (collisionShape.IsCompound())
{
CompoundShape compoundShape = collisionShape as CompoundShape;
Dbvt dbvt = compoundShape.GetDynamicAabbTree();
RayTester rayCB = new RayTester(
collisionObject,
compoundShape,
ref colObjWorldTransform,
ref rayFromTrans,
ref rayToTrans,
resultCallback);
#if !DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION
if (dbvt != null)
{
IndexedVector3 localRayFrom = colObjWorldTransform.InverseTimes(ref rayFromTrans)._origin;
IndexedVector3 localRayTo = colObjWorldTransform.InverseTimes(ref rayToTrans)._origin;
Dbvt.RayTest(dbvt.m_root, ref localRayFrom, ref localRayTo, rayCB);
}
else
#endif //DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION
{
for (int i = 0, n = compoundShape.GetNumChildShapes(); i < n; ++i)
{
rayCB.Process(i);
}
}
rayCB.Cleanup();
BulletGlobals.StopProfile();
}
}
}
BulletGlobals.SphereShapePool.Free(pointShape);
}