本文整理汇总了C#中BulletXNA.BulletCollision.CollisionObject类的典型用法代码示例。如果您正苦于以下问题:C# CollisionObject类的具体用法?C# CollisionObject怎么用?C# CollisionObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CollisionObject类属于BulletXNA.BulletCollision命名空间,在下文中一共展示了CollisionObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ProcessCollision
public override void ProcessCollision(CollisionObject body0, CollisionObject body1, DispatcherInfo dispatchInfo, ManifoldResult resultOut)
{
//resultOut = new ManifoldResult();
if (m_manifoldPtr == null)
{
return;
}
CollisionObject sphereObj = m_swapped ? body1 : body0;
CollisionObject triObj = m_swapped ? body0 : body1;
SphereShape sphere = sphereObj.GetCollisionShape() as SphereShape;
TriangleShape triangle = triObj.GetCollisionShape() as TriangleShape;
/// report a contact. internally this will be kept persistent, and contact reduction is done
resultOut.SetPersistentManifold(m_manifoldPtr);
using (SphereTriangleDetector detector = BulletGlobals.SphereTriangleDetectorPool.Get())
{
detector.Initialize(sphere, triangle, m_manifoldPtr.GetContactBreakingThreshold());
ClosestPointInput input = ClosestPointInput.Default();
input.m_maximumDistanceSquared = float.MaxValue;
sphereObj.GetWorldTransform(out input.m_transformA);
triObj.GetWorldTransform(out input.m_transformB);
bool swapResults = m_swapped;
detector.GetClosestPoints(ref input, resultOut, dispatchInfo.getDebugDraw(), swapResults);
if (m_ownManifold)
{
resultOut.RefreshContactPoints();
}
}
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:35,代码来源:SphereTriangleCollisionAlgorithm.cs
示例2: Initialize
public virtual void Initialize(PersistentManifold mf, CollisionAlgorithmConstructionInfo ci, CollisionObject body0, CollisionObject body1, bool swapped)
{
base.Initialize(ci, body0, body1);
m_ownManifold = false;
m_manifoldPtr = mf;
m_swapped = swapped;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:7,代码来源:SphereTriangleCollisionAlgorithm.cs
示例3: PreallocateChildAlgorithms
private void PreallocateChildAlgorithms(CollisionObject body0, CollisionObject body1)
{
CollisionObject colObj = m_isSwapped ? body1 : body0;
CollisionObject otherObj = m_isSwapped ? body0 : body1;
Debug.Assert(colObj.GetCollisionShape().IsCompound());
CompoundShape compoundShape = (CompoundShape)(colObj.GetCollisionShape());
int numChildren = compoundShape.GetNumChildShapes();
int i;
//m_childCollisionAlgorithms.resize(numChildren);
m_childCollisionAlgorithms.Clear();
for (i = 0; i < numChildren; i++)
{
if (compoundShape.GetDynamicAabbTree() != null)
{
m_childCollisionAlgorithms.Add(null);
}
else
{
CollisionShape tmpShape = colObj.GetCollisionShape();
CollisionShape childShape = compoundShape.GetChildShape(i);
colObj.InternalSetTemporaryCollisionShape(childShape);
CollisionAlgorithm ca = m_dispatcher.FindAlgorithm(colObj, otherObj, m_sharedManifold);
m_childCollisionAlgorithms.Add(ca);
colObj.InternalSetTemporaryCollisionShape(tmpShape);
}
}
}
开发者ID:bsamuels453,项目名称:BulletXNA,代码行数:30,代码来源:CompoundCollisionAlgorithm.cs
示例4: SphereTriangleCollisionAlgorithm
public SphereTriangleCollisionAlgorithm() { } // for pool
public SphereTriangleCollisionAlgorithm(PersistentManifold mf, CollisionAlgorithmConstructionInfo ci, CollisionObject body0, CollisionObject body1, bool swapped)
: base(ci, body0, body1)
{
m_ownManifold = false;
m_manifoldPtr = mf;
m_swapped = swapped;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:8,代码来源:SphereTriangleCollisionAlgorithm.cs
示例5: ProcessCollision
public override void ProcessCollision(CollisionObject body0, CollisionObject body1, DispatcherInfo dispatchInfo, ManifoldResult resultOut)
{
if (m_manifoldPtr == null)
{
//swapped?
m_manifoldPtr = m_dispatcher.GetNewManifold(body0, body1);
m_ownManifold = true;
}
resultOut.SetPersistentManifold(m_manifoldPtr);
//comment-out next line to test multi-contact generation
//resultOut.getPersistentManifold().clearManifold();
ConvexShape min0 = body0.GetCollisionShape() as ConvexShape;
ConvexShape min1 = body1.GetCollisionShape() as ConvexShape;
IndexedVector3 normalOnB = IndexedVector3.Zero;
IndexedVector3 pointOnBWorld = IndexedVector3.Zero;
{
ClosestPointInput input = ClosestPointInput.Default();
using (GjkPairDetector gjkPairDetector = BulletGlobals.GjkPairDetectorPool.Get())
{
gjkPairDetector.Initialize(min0, min1, m_simplexSolver, m_pdSolver);
//TODO: if (dispatchInfo.m_useContinuous)
gjkPairDetector.SetMinkowskiA(min0);
gjkPairDetector.SetMinkowskiB(min1);
{
input.m_maximumDistanceSquared = min0.GetMargin() + min1.GetMargin() + m_manifoldPtr.GetContactBreakingThreshold();
input.m_maximumDistanceSquared *= input.m_maximumDistanceSquared;
}
input.m_transformA = body0.GetWorldTransform();
input.m_transformB = body1.GetWorldTransform();
gjkPairDetector.GetClosestPoints(ref input, resultOut, dispatchInfo.getDebugDraw(), false);
#if DEBUG
if (BulletGlobals.g_streamWriter != null)
{
BulletGlobals.g_streamWriter.WriteLine("c2dc2d processCollision");
MathUtil.PrintMatrix(BulletGlobals.g_streamWriter, "transformA", input.m_transformA);
MathUtil.PrintMatrix(BulletGlobals.g_streamWriter, "transformB", input.m_transformB);
}
#endif
}
//BulletGlobals.GjkPairDetectorPool.Free(gjkPairDetector);
//btVector3 v0,v1;
//btVector3 sepNormalWorldSpace;
}
if (m_ownManifold)
{
resultOut.RefreshContactPoints();
}
}
开发者ID:ousttrue,项目名称:bullet-xna,代码行数:60,代码来源:Convex2dConvex2dAlgorithm.cs
示例6: GetNewManifold
public virtual PersistentManifold GetNewManifold(CollisionObject b0, CollisionObject b1)
{
gNumManifold++;
CollisionObject body0 = b0;
CollisionObject body1 = b1;
//optional relative contact breaking threshold, turned on by default (use setDispatcherFlags to switch off feature for improved performance)
float contactBreakingThreshold = ((m_dispatcherFlags & DispatcherFlags.CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD) > 0) ?
Math.Min(body0.GetCollisionShape().GetContactBreakingThreshold(BulletGlobals.gContactBreakingThreshold), body1.GetCollisionShape().GetContactBreakingThreshold(BulletGlobals.gContactBreakingThreshold))
: BulletGlobals.gContactBreakingThreshold;
float contactProcessingThreshold = Math.Min(body0.GetContactProcessingThreshold(), body1.GetContactProcessingThreshold());
// nothing in our pool so create a new one and return it.
// need a way to flush the pool ideally
PersistentManifold manifold = BulletGlobals.PersistentManifoldPool.Get();
manifold.Initialise(body0, body1, 0, contactBreakingThreshold, contactProcessingThreshold);
manifold.m_index1a = m_manifoldsPtr.Count;
m_manifoldsPtr.Add(manifold);
#if DEBUG
if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugDispatcher)
{
BulletGlobals.g_streamWriter.WriteLine("GetNewManifold[{0}][{1}]", manifold.m_index1a,m_manifoldsPtr.Count);
}
#endif
return manifold;
}
开发者ID:bsamuels453,项目名称:BulletXNA,代码行数:33,代码来源:CollisionDispatcher.cs
示例7: Initialise
public void Initialise(CollisionObject body0, CollisionObject body1)
{
m_body0 = body0;
m_body1 = body1;
m_rootTransA = body0.GetWorldTransform();
m_rootTransB = body1.GetWorldTransform();
m_manifoldPtr = null;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:8,代码来源:ManifoldResult.cs
示例8: Box2dBox2dCollisionAlgorithm
public Box2dBox2dCollisionAlgorithm(PersistentManifold mf,CollisionAlgorithmConstructionInfo ci,CollisionObject body0,CollisionObject body1) :
base(ci,body0,body1)
{
m_ownManifold = false;
m_manifoldPtr = mf;
if (m_manifoldPtr == null && m_dispatcher.NeedsCollision(body0, body1))
{
m_manifoldPtr = m_dispatcher.GetNewManifold(body0, body1);
m_ownManifold = true;
}
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:11,代码来源:Box2dBox2dCollisionAlgorithm.cs
示例9: Convex2dConvex2dAlgorithm
public Convex2dConvex2dAlgorithm(PersistentManifold mf, CollisionAlgorithmConstructionInfo ci, CollisionObject body0, CollisionObject body1, ISimplexSolverInterface simplexSolver, IConvexPenetrationDepthSolver pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold)
: base(ci, body0, body1)
{
m_simplexSolver = simplexSolver;
m_pdSolver = pdSolver;
m_ownManifold = false;
m_manifoldPtr = mf;
m_lowLevelOfDetail = false;
m_numPerturbationIterations = numPerturbationIterations;
m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
}
开发者ID:ousttrue,项目名称:bullet-xna,代码行数:11,代码来源:Convex2dConvex2dAlgorithm.cs
示例10: Initialize
public virtual void Initialize(CollisionAlgorithmConstructionInfo ci, CollisionObject body0, CollisionObject body1, bool isSwapped)
{
base.Initialize(ci, body0, body1);
m_isSwapped = isSwapped;
m_sharedManifold = ci.GetManifold();
m_ownsManifold = false;
CollisionObject colObj = m_isSwapped ? body1 : body0;
Debug.Assert(colObj.GetCollisionShape().IsCompound());
CompoundShape compoundShape = (CompoundShape)(colObj.GetCollisionShape());
m_compoundShapeRevision = compoundShape.GetUpdateRevision();
PreallocateChildAlgorithms(body0, body1);
}
开发者ID:bsamuels453,项目名称:BulletXNA,代码行数:12,代码来源:CompoundCollisionAlgorithm.cs
示例11: UpdateSingleAabb
public void UpdateSingleAabb(CollisionObject colObj)
{
IndexedVector3 minAabb;
IndexedVector3 maxAabb;
IndexedMatrix wt = colObj.GetWorldTransform();
colObj.GetCollisionShape().GetAabb(ref wt, out minAabb, out maxAabb);
//need to increase the aabb for contact thresholds
IndexedVector3 contactThreshold = new IndexedVector3(BulletGlobals.gContactBreakingThreshold);
minAabb -= contactThreshold;
maxAabb += contactThreshold;
if (GetDispatchInfo().m_useContinuous && colObj.GetInternalType() == CollisionObjectTypes.CO_RIGID_BODY && !colObj.IsStaticOrKinematicObject())
{
IndexedVector3 minAabb2,maxAabb2;
colObj.GetCollisionShape().GetAabb(colObj.GetInterpolationWorldTransform(),out minAabb2 ,out maxAabb2);
minAabb2 -= contactThreshold;
maxAabb2 += contactThreshold;
MathUtil.VectorMin(ref minAabb2,ref minAabb);
MathUtil.VectorMax(ref maxAabb2, ref maxAabb);
}
#if DEBUG
if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugCollisionWorld)
{
MathUtil.PrintVector3(BulletGlobals.g_streamWriter, "updateSingleAabbMin", minAabb);
MathUtil.PrintVector3(BulletGlobals.g_streamWriter, "updateSingleAabbMax", maxAabb);
}
#endif
IBroadphaseInterface bp = m_broadphasePairCache as IBroadphaseInterface;
//moving objects should be moderately sized, probably something wrong if not
if (colObj.IsStaticObject() || ((maxAabb - minAabb).LengthSquared() < 1e12f))
{
bp.SetAabb(colObj.GetBroadphaseHandle(), ref minAabb, ref maxAabb, m_dispatcher1);
}
else
{
//something went wrong, investigate
//this assert is unwanted in 3D modelers (danger of loosing work)
colObj.SetActivationState(ActivationState.DISABLE_SIMULATION);
//static bool reportMe = true;
bool reportMe = true;
if (reportMe && m_debugDrawer != null)
{
reportMe = false;
m_debugDrawer.ReportErrorWarning("Overflow in AABB, object removed from simulation");
m_debugDrawer.ReportErrorWarning("If you can reproduce this, please email [email protected]\n");
m_debugDrawer.ReportErrorWarning("Please include above information, your Platform, version of OS.\n");
m_debugDrawer.ReportErrorWarning("Thanks.\n");
}
}
}
开发者ID:ousttrue,项目名称:bullet-xna,代码行数:53,代码来源:CollisionWorld.cs
示例12: ProcessCollision
public override void ProcessCollision(CollisionObject body0, CollisionObject body1, DispatcherInfo dispatchInfo, ManifoldResult resultOut)
{
if (m_manifoldPtr == null)
{
return;
}
resultOut.SetPersistentManifold(m_manifoldPtr);
SphereShape sphere0 = body0.GetCollisionShape() as SphereShape;
SphereShape sphere1 = body1.GetCollisionShape() as SphereShape;
IndexedVector3 diff = body0.GetWorldTransform()._origin - body1.GetWorldTransform()._origin;
float len = diff.Length();
float radius0 = sphere0.GetRadius();
float radius1 = sphere1.GetRadius();
#if CLEAR_MANIFOLD
m_manifoldPtr.clearManifold(); //don't do this, it disables warmstarting
#endif
///iff distance positive, don't generate a new contact
if (len > (radius0 + radius1))
{
#if !CLEAR_MANIFOLD
resultOut.RefreshContactPoints();
#endif //CLEAR_MANIFOLD
return;
}
///distance (negative means penetration)
float dist = len - (radius0 + radius1);
IndexedVector3 normalOnSurfaceB = new IndexedVector3(1, 0, 0);
if (len > MathUtil.SIMD_EPSILON)
{
normalOnSurfaceB = diff / len;
}
///point on A (worldspace)
///btVector3 pos0 = col0->getWorldTransform().getOrigin() - radius0 * normalOnSurfaceB;
///point on B (worldspace)
IndexedVector3 pos1 = body1.GetWorldTransform()._origin + radius1 * normalOnSurfaceB;
/// report a contact. internally this will be kept persistent, and contact reduction is done
resultOut.AddContactPoint(ref normalOnSurfaceB, ref pos1, dist);
#if !CLEAR_MANIFOLD
resultOut.RefreshContactPoints();
#endif //CLEAR_MANIFOLD
}
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:53,代码来源:SphereSphereCollisionAlgorithm.cs
示例13: Initialize
public virtual void Initialize(PersistentManifold mf, CollisionAlgorithmConstructionInfo ci, CollisionObject colObj0, CollisionObject colObj1)
{
base.Initialize(ci, colObj0, colObj1);
m_ownManifold = false;
m_manifoldPtr = mf;
if (m_manifoldPtr == null)
{
m_manifoldPtr = m_dispatcher.GetNewManifold(colObj0, colObj1);
m_ownManifold = true;
}
}
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:12,代码来源:SphereSphereCollisionAlgorithm.cs
示例14: SphereSphereCollisionAlgorithm
public SphereSphereCollisionAlgorithm() { } // for pool
public SphereSphereCollisionAlgorithm(PersistentManifold mf, CollisionAlgorithmConstructionInfo ci, CollisionObject body0, CollisionObject body1)
: base(ci, body0, body1)
{
m_ownManifold = false;
m_manifoldPtr = mf;
// for some reason theres no check in 2.76 or 2.78 for a needs collision, just a check on pointer being null.
if (m_manifoldPtr == null)
{
m_manifoldPtr = m_dispatcher.GetNewManifold(body0, body1);
m_ownManifold = true;
}
}
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:15,代码来源:SphereSphereCollisionAlgorithm.cs
示例15: Inititialize
public void Inititialize(CollisionAlgorithmConstructionInfo ci, CollisionObject body0, CollisionObject body1, bool isSwapped)
{
base.Initialize(ci, body0, body1);
m_isSwapped = isSwapped;
if (m_convexTriangleCallback == null)
{
m_convexTriangleCallback = new ConvexTriangleCallback(m_dispatcher, body0, body1, isSwapped);
}
else
{
m_convexTriangleCallback.Initialize(m_dispatcher, body0, body1, isSwapped);
}
}
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:14,代码来源:ConvexConcaveCollisionAlgorithm.cs
示例16: SphereBoxCollisionAlgorithm
public SphereBoxCollisionAlgorithm() { } // for pool
public SphereBoxCollisionAlgorithm(PersistentManifold mf, CollisionAlgorithmConstructionInfo ci, CollisionObject col0, CollisionObject col1, bool isSwapped)
: base(ci, col0, col1)
{
m_isSwapped = isSwapped;
m_ownManifold = false;
m_manifoldPtr = mf;
CollisionObject sphereObj = m_isSwapped ? col1 : col0;
CollisionObject boxObj = m_isSwapped ? col0 : col1;
if (m_manifoldPtr == null && m_dispatcher.NeedsCollision(sphereObj, boxObj))
{
m_manifoldPtr = m_dispatcher.GetNewManifold(sphereObj, boxObj);
m_ownManifold = true;
}
}
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:16,代码来源:SphereBoxCollisionAlgorithm.cs
示例17: ConvexConvexAlgorithm
public ConvexConvexAlgorithm() { } // for pool
public ConvexConvexAlgorithm(PersistentManifold mf, CollisionAlgorithmConstructionInfo ci, CollisionObject body0, CollisionObject body1, ISimplexSolverInterface simplexSolver, IConvexPenetrationDepthSolver pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold)
: base(ci, body0, body1)
{
m_simplexSolver = simplexSolver;
m_pdSolver = pdSolver;
m_ownManifold = false;
m_manifoldPtr = mf;
m_lowLevelOfDetail = false;
#if USE_SEPDISTANCE_UTIL2
m_sepDistance ((static_cast<btConvexShape*>(body0.getCollisionShape())).getAngularMotionDisc(),
(static_cast<btConvexShape*>(body1.getCollisionShape())).getAngularMotionDisc()),
#endif
m_numPerturbationIterations = numPerturbationIterations;
m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
}
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:17,代码来源:ConvexConvexCollisionAlgorithm.cs
示例18: ResolveSingleCollision
//response between two dynamic objects without friction, assuming 0 penetration depth
public static float ResolveSingleCollision(
RigidBody body1,
CollisionObject colObj2,
ref IndexedVector3 contactPositionWorld,
ref IndexedVector3 contactNormalOnB,
ContactSolverInfo solverInfo,
float distance)
{
RigidBody body2 = RigidBody.Upcast(colObj2);
IndexedVector3 normal = contactNormalOnB;
IndexedVector3 rel_pos1 = contactPositionWorld - body1.GetWorldTransform()._origin;
IndexedVector3 rel_pos2 = contactPositionWorld - colObj2.GetWorldTransform()._origin;
IndexedVector3 vel1 = body1.GetVelocityInLocalPoint(ref rel_pos1);
IndexedVector3 vel2 = body2 != null ? body2.GetVelocityInLocalPoint(ref rel_pos2) : IndexedVector3.Zero;
IndexedVector3 vel = vel1 - vel2;
float rel_vel = normal.Dot(ref vel);
float combinedRestitution = body1.GetRestitution() * colObj2.GetRestitution();
float restitution = combinedRestitution * -rel_vel;
float positionalError = solverInfo.m_erp * -distance / solverInfo.m_timeStep;
float velocityError = -(1.0f + restitution) * rel_vel;// * damping;
float denom0 = body1.ComputeImpulseDenominator(ref contactPositionWorld, ref normal);
float denom1 = body2 != null ? body2.ComputeImpulseDenominator(ref contactPositionWorld, ref normal) : 0.0f;
float relaxation = 1.0f;
float jacDiagABInv = relaxation / (denom0 + denom1);
float penetrationImpulse = positionalError * jacDiagABInv;
float velocityImpulse = velocityError * jacDiagABInv;
float normalImpulse = penetrationImpulse + velocityImpulse;
normalImpulse = 0.0f > normalImpulse ? 0.0f : normalImpulse;
body1.ApplyImpulse(normal * (normalImpulse), rel_pos1);
if (body2 != null)
{
body2.ApplyImpulse(-normal * (normalImpulse), rel_pos2);
}
return normalImpulse;
}
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:46,代码来源:ContactConstraint.cs
示例19: Initialize
public void Initialize(PersistentManifold mf, CollisionAlgorithmConstructionInfo ci, CollisionObject col0, CollisionObject col1, bool isSwapped, int numPerturbationIterations, int minimumPointsPerturbationThreshold)
{
base.Initialize(ci);
m_manifoldPtr = mf;
m_ownManifold = false;
m_isSwapped = isSwapped;
m_numPerturbationIterations = numPerturbationIterations;
m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
CollisionObject convexObj = m_isSwapped ? col1 : col0;
CollisionObject planeObj = m_isSwapped ? col0 : col1;
if (m_manifoldPtr == null && m_dispatcher.NeedsCollision(convexObj, planeObj))
{
m_manifoldPtr = m_dispatcher.GetNewManifold(convexObj, planeObj);
m_ownManifold = true;
}
}
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:19,代码来源:ConvexPlaneCollisionAlgorithm.cs
示例20: ProcessCollision
public override void ProcessCollision(CollisionObject body0, CollisionObject body1, DispatcherInfo dispatchInfo, ManifoldResult resultOut)
{
if (m_manifoldPtr == null)
{
return;
}
CollisionObject col0 = body0;
CollisionObject col1 = body1;
Box2dShape box0 = (Box2dShape)col0.GetCollisionShape();
Box2dShape box1 = (Box2dShape)col1.GetCollisionShape();
resultOut.SetPersistentManifold(m_manifoldPtr);
B2CollidePolygons(ref resultOut, box0, col0.GetWorldTransform(), box1, col1.GetWorldTransform());
// refreshContactPoints is only necessary when using persistent contact points. otherwise all points are newly added
if (m_ownManifold)
{
resultOut.RefreshContactPoints();
}
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:23,代码来源:Box2dBox2dCollisionAlgorithm.cs
注:本文中的BulletXNA.BulletCollision.CollisionObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论