本文整理汇总了C#中BulletXNA.BulletCollision.CollisionObject.InternalSetTemporaryCollisionShape方法的典型用法代码示例。如果您正苦于以下问题:C# CollisionObject.InternalSetTemporaryCollisionShape方法的具体用法?C# CollisionObject.InternalSetTemporaryCollisionShape怎么用?C# CollisionObject.InternalSetTemporaryCollisionShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BulletXNA.BulletCollision.CollisionObject
的用法示例。
在下文中一共展示了CollisionObject.InternalSetTemporaryCollisionShape方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvexVsConvexCollision
protected void ConvexVsConvexCollision(CollisionObject body0,
CollisionObject body1,
CollisionShape shape0,
CollisionShape shape1)
{
CollisionShape tmpShape0 = body0.GetCollisionShape();
CollisionShape tmpShape1 = body1.GetCollisionShape();
body0.InternalSetTemporaryCollisionShape(shape0);
body1.InternalSetTemporaryCollisionShape(shape1);
if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugGimpactAlgo)
{
BulletGlobals.g_streamWriter.WriteLine("GImpactAglo::ConvexVsConvex");
}
m_resultOut.SetShapeIdentifiersA(m_part0, m_triface0);
m_resultOut.SetShapeIdentifiersB(m_part1, m_triface1);
CheckConvexAlgorithm(body0, body1);
m_convex_algorithm.ProcessCollision(body0, body1, m_dispatchInfo, m_resultOut);
body0.InternalSetTemporaryCollisionShape(tmpShape0);
body1.InternalSetTemporaryCollisionShape(tmpShape1);
}
示例2: ObjectQuerySingle
//.........这里部分代码省略.........
{
if (collisionShape.GetShapeType() == BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE)
{
CastResult castResult = BulletGlobals.CastResultPool.Get();
castResult.m_allowedPenetration = allowedPenetration;
castResult.m_fraction = resultCallback.m_closestHitFraction;
StaticPlaneShape planeShape = collisionShape as StaticPlaneShape;
ContinuousConvexCollision convexCaster1 = new ContinuousConvexCollision(castShape, planeShape);
if (convexCaster1.CalcTimeOfImpact(ref convexFromTrans, ref convexToTrans, ref colObjWorldTransform, ref colObjWorldTransform, castResult))
{
//add hit
if (castResult.m_normal.LengthSquared() > 0.0001f)
{
if (castResult.m_fraction < resultCallback.m_closestHitFraction)
{
castResult.m_normal.Normalize();
LocalConvexResult localConvexResult = new LocalConvexResult
(
collisionObject,
//null, // updated to allow different ctor on struct
ref castResult.m_normal,
ref castResult.m_hitPoint,
castResult.m_fraction
);
bool normalInWorldSpace = true;
resultCallback.AddSingleResult(ref localConvexResult, normalInWorldSpace);
}
}
}
castResult.Cleanup();
}
else
{
BulletGlobals.StartProfile("convexSweepConcave");
ConcaveShape concaveShape = (ConcaveShape)collisionShape;
IndexedMatrix worldTocollisionObject = colObjWorldTransform.Inverse();
IndexedVector3 convexFromLocal = worldTocollisionObject * convexFromTrans._origin;
IndexedVector3 convexToLocal = worldTocollisionObject * convexToTrans._origin;
// rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation
IndexedMatrix rotationXform = new IndexedMatrix(worldTocollisionObject._basis * convexToTrans._basis, new IndexedVector3(0));
using (BridgeTriangleConvexcastCallback tccb = BulletGlobals.BridgeTriangleConvexcastCallbackPool.Get())
{
tccb.Initialize(castShape, ref convexFromTrans, ref convexToTrans, resultCallback, collisionObject, concaveShape, ref colObjWorldTransform);
tccb.m_hitFraction = resultCallback.m_closestHitFraction;
tccb.m_allowedPenetration = allowedPenetration;
IndexedVector3 boxMinLocal;
IndexedVector3 boxMaxLocal;
castShape.GetAabb(ref rotationXform, out boxMinLocal, out boxMaxLocal);
IndexedVector3 rayAabbMinLocal = convexFromLocal;
MathUtil.VectorMin(ref convexToLocal, ref rayAabbMinLocal);
//rayAabbMinLocal.setMin(convexToLocal);
IndexedVector3 rayAabbMaxLocal = convexFromLocal;
//rayAabbMaxLocal.setMax(convexToLocal);
MathUtil.VectorMax(ref convexToLocal, ref rayAabbMaxLocal);
rayAabbMinLocal += boxMinLocal;
rayAabbMaxLocal += boxMaxLocal;
concaveShape.ProcessAllTriangles(tccb, ref rayAabbMinLocal, ref rayAabbMaxLocal);
BulletGlobals.StopProfile();
}
}
}
}
else
{
///@todo : use AABB tree or other BVH acceleration structure!
if (collisionShape.IsCompound())
{
BulletGlobals.StartProfile("convexSweepCompound");
CompoundShape compoundShape = (CompoundShape)collisionShape;
for (int i = 0; i < compoundShape.GetNumChildShapes(); i++)
{
IndexedMatrix childTrans = compoundShape.GetChildTransform(i);
CollisionShape childCollisionShape = compoundShape.GetChildShape(i);
IndexedMatrix childWorldTrans = colObjWorldTransform * childTrans;
// replace collision shape so that callback can determine the triangle
CollisionShape saveCollisionShape = collisionObject.GetCollisionShape();
collisionObject.InternalSetTemporaryCollisionShape(childCollisionShape);
LocalInfoAdder my_cb = new LocalInfoAdder(i, resultCallback);
my_cb.m_closestHitFraction = resultCallback.m_closestHitFraction;
ObjectQuerySingle(castShape, ref convexFromTrans, ref convexToTrans,
collisionObject,
childCollisionShape,
ref childWorldTrans,
my_cb, allowedPenetration);
// restore
collisionObject.InternalSetTemporaryCollisionShape(saveCollisionShape);
}
BulletGlobals.StopProfile();
}
}
}
}
示例3: ShapeVsShapeCollision
protected void ShapeVsShapeCollision(
CollisionObject body0,
CollisionObject body1,
CollisionShape shape0,
CollisionShape shape1)
{
CollisionShape tmpShape0 = body0.GetCollisionShape();
CollisionShape tmpShape1 = body1.GetCollisionShape();
body0.InternalSetTemporaryCollisionShape(shape0);
body1.InternalSetTemporaryCollisionShape(shape1);
if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugGimpactAlgo)
{
BulletGlobals.g_streamWriter.WriteLine("GImpactAglo::ShapeVsShape");
}
{
CollisionAlgorithm algor = NewAlgorithm(body0, body1);
// post : checkManifold is called
m_resultOut.SetShapeIdentifiersA(m_part0, m_triface0);
m_resultOut.SetShapeIdentifiersB(m_part1, m_triface1);
algor.ProcessCollision(body0, body1, m_dispatchInfo, m_resultOut);
m_dispatcher.FreeCollisionAlgorithm(algor);
}
body0.InternalSetTemporaryCollisionShape(tmpShape0);
body1.InternalSetTemporaryCollisionShape(tmpShape1);
}