コード例 #1
0
ファイル: DbvtBroadphase.cs プロジェクト: himapo/ccm
        public BroadphaseProxy createProxy(ref btVector3 aabbMin,ref btVector3 aabbMax,
            BroadphaseNativeTypes shapeType, object userPtr,
            short collisionFilterGroup, short collisionFilterMask, IDispatcher dispatcher,
            object multiSapProxy)
        {

            DbvtProxy proxy = new DbvtProxy(aabbMin, aabbMax, userPtr,
                collisionFilterGroup,
                collisionFilterMask);

            DbvtAabbMm aabb;// = DbvtAabbMm.FromMM(aabbMin, aabbMax);
            DbvtAabbMm.FromMM(ref aabbMin, ref aabbMax, out aabb);

            //bproxy->aabb			=	btDbvtVolume::FromMM(aabbMin,aabbMax);
            proxy.stage = m_stageCurrent;
            proxy.m_uniqueId = ++m_gid;
            proxy.leaf = m_sets[0].insert(ref aabb, proxy);
            listappend(ref proxy, ref m_stageRoots[m_stageCurrent]);
            if (!m_deferedcollide)
            {
                DbvtTreeCollider collider = new DbvtTreeCollider(this);
                collider.proxy = proxy;
                m_sets[0].collideTV(m_sets[0].m_root, ref aabb, collider);
                m_sets[1].collideTV(m_sets[1].m_root,ref aabb, collider);
            }
            return (proxy);
        }
コード例 #2
0
ファイル: CollisionWorld.cs プロジェクト: palestar/medusa
        public void AddCollisionObject(CollisionObject collisionObject, BroadphaseProxy.CollisionFilterGroups collisionFilterGroup, BroadphaseProxy.CollisionFilterGroups collisionFilterMask)
        {
            //check that the object isn't already added
            if (!_collisionObjects.Contains(collisionObject))
            {
                _collisionObjects.Add(collisionObject);

                //calculate new AABB
                Matrix trans = collisionObject.WorldTransform;

                Vector3 minAabb;
                Vector3 maxAabb;
                collisionObject.CollisionShape.GetAabb(trans, out minAabb, out maxAabb);

                BroadphaseNativeTypes type = collisionObject.CollisionShape.ShapeType;
                collisionObject.Broadphase = Broadphase.CreateProxy(
                    minAabb,
                    maxAabb,
                    type,
                    collisionObject,
                    collisionFilterGroup,
                    collisionFilterMask
                    );
            }
        }
コード例 #3
0
        private CollisionAlgorithmCreateFunction FindCreateFunction(BroadphaseNativeTypes proxyTypeA, BroadphaseNativeTypes proxyTypeB)
        {
            if (BroadphaseProxy.IsConvex(proxyTypeA) && BroadphaseProxy.IsConvex(proxyTypeB))
            {
                return(_convexConvexCreateFunc);
            }

            if (BroadphaseProxy.IsConvex(proxyTypeA) && BroadphaseProxy.IsConcave(proxyTypeB))
            {
                return(_convexConcaveCreateFunc);
            }

            if (BroadphaseProxy.IsConvex(proxyTypeB) && BroadphaseProxy.IsConcave(proxyTypeA))
            {
                return(_swappedConvexConcaveCreateFunc);
            }

            if (BroadphaseProxy.IsCompound(proxyTypeA))
            {
                return(_compoundCreateFunc);
            }
            else
            {
                if (BroadphaseProxy.IsCompound(proxyTypeB))
                {
                    return(_swappedCompoundCreateFunc);
                }
            }

            //failed to find an algorithm
            return(_emptyCreateFunc);
        }
コード例 #4
0
        public override BroadphaseProxy CreateProxy(Vector3 min, Vector3 max, BroadphaseNativeTypes shapeType, object userData, BroadphaseProxy.CollisionFilterGroups collisionFilterGroup, BroadphaseProxy.CollisionFilterGroups collisionFilterMask)
        {
            ushort handleId = AddHandle(min, max, userData, collisionFilterGroup, collisionFilterMask);

            Handle handle = GetHandle(handleId);

            return(handle);
        }
コード例 #5
0
ファイル: MultiSapProxy.cs プロジェクト: HaKDMoDz/InVision
/*		void*	m_userPtr;
		short int	m_collisionFilterGroup;
		short int	m_collisionFilterMask;
*/
		public MultiSapProxy(ref Vector3 aabbMin, ref Vector3 aabbMax, BroadphaseNativeTypes shapeType,
		                     Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask)
			: base(ref aabbMin, ref aabbMax, userPtr, collisionFilterGroup, collisionFilterMask, null)
		{
			m_aabbMin = aabbMin;
			m_aabbMax = aabbMax;
			m_shapeType = shapeType;
			m_multiSapParentProxy =this;
		}
コード例 #6
0
 /*		void*	m_userPtr;
  *      short int	m_collisionFilterGroup;
  *      short int	m_collisionFilterMask;
  */
 public MultiSapProxy(ref IndexedVector3 aabbMin, ref IndexedVector3 aabbMax, BroadphaseNativeTypes shapeType,
                      Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask)
     : base(ref aabbMin, ref aabbMax, userPtr, collisionFilterGroup, collisionFilterMask, null)
 {
     m_aabbMin             = aabbMin;
     m_aabbMax             = aabbMax;
     m_shapeType           = shapeType;
     m_multiSapParentProxy = this;
 }
コード例 #7
0
        public virtual BroadphaseProxy CreateProxy(ref Vector3 aabbMin, ref Vector3 aabbMax, BroadphaseNativeTypes shapeType, Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, IDispatcher dispatcher, Object multiSapProxy)
        {
	        //void* ignoreMe -> we could think of recursive multi-sap, if someone is interested

	        MultiSapProxy proxy = new MultiSapProxy(ref aabbMin,  ref aabbMax,shapeType,userPtr, collisionFilterGroup,collisionFilterMask);
	        m_multiSapProxies.Add(proxy);

	        ///this should deal with inserting/removal into child broadphases
	        SetAabb(proxy,ref aabbMin,ref aabbMax,dispatcher);
	        return proxy;
        }
コード例 #8
0
        public override BroadphaseProxy CreateProxy(Vector3 min, Vector3 max, BroadphaseNativeTypes shapeType, object userData, BroadphaseProxy.CollisionFilterGroups collisionFilterGroup, BroadphaseProxy.CollisionFilterGroups collisionFilterMask)
        {
            if (_proxies.Count >= _maxProxies)
            {
                BulletDebug.Assert(false);
                return null; //should never happen, but don't let the game crash ;-)
            }
            BulletDebug.Assert(min.X <= max.X && min.Y <= max.Y && min.Z <= max.Z);

            SimpleBroadphaseProxy proxy = new SimpleBroadphaseProxy(min, max, shapeType, userData, collisionFilterGroup, collisionFilterMask);
            _proxies.Add(proxy);

            return proxy;
        }
コード例 #9
0
        public override BroadphaseProxy CreateProxy(Vector3 min, Vector3 max, BroadphaseNativeTypes shapeType, object userData, BroadphaseProxy.CollisionFilterGroups collisionFilterGroup, BroadphaseProxy.CollisionFilterGroups collisionFilterMask)
        {
            if (_proxies.Count >= _maxProxies)
            {
                BulletDebug.Assert(false);
                return(null);                //should never happen, but don't let the game crash ;-)
            }
            BulletDebug.Assert(min.X <= max.X && min.Y <= max.Y && min.Z <= max.Z);

            SimpleBroadphaseProxy proxy = new SimpleBroadphaseProxy(min, max, shapeType, userData, collisionFilterGroup, collisionFilterMask);

            _proxies.Add(proxy);

            return(proxy);
        }
コード例 #10
0
ファイル: GjkPairDetector.cs プロジェクト: HaKDMoDz/InVision
        public GjkPairDetector(ConvexShape objectA, ConvexShape objectB, BroadphaseNativeTypes shapeTypeA, BroadphaseNativeTypes shapeTypeB, float marginA, float marginB, ISimplexSolverInterface simplexSolver, IConvexPenetrationDepthSolver penetrationDepthSolver)
        {
            m_minkowskiA = objectA;
            m_minkowskiB = objectB;
            m_shapeTypeA = shapeTypeA;
            m_shapeTypeB = shapeTypeB;
            m_marginA = marginA;
            m_marginB = marginB;

            m_cachedSeparatingAxis = new Vector3(0, 1, 0);

            m_simplexSolver = simplexSolver;
            m_penetrationDepthSolver = penetrationDepthSolver;
            m_ignoreMargin = false;
            m_lastUsedMethod = -1;
            m_catchDegeneracies = true;

        }
コード例 #11
0
ファイル: GjkPairDetector.cs プロジェクト: himapo/ccm
        public GjkPairDetector(ConvexShape objectA, ConvexShape objectB, ISimplexSolver simplexSolver, IConvexPenetrationDepthSolver penetrationDepthSolver)
        {
            m_cachedSeparatingAxis = new btVector3(0f, 1f, 0f);
            m_penetrationDepthSolver = penetrationDepthSolver;
            m_simplexSolver = simplexSolver;
            m_minkowskiA = objectA;
            m_minkowskiB = objectB;
            m_shapeTypeA = objectA.ShapeType;
            m_shapeTypeB = objectB.ShapeType;
            m_marginA = objectA.Margin;
            m_marginB = objectB.Margin;
            m_ignoreMargin = false;
            m_lastUsedMethod = -1;
            m_catchDegeneracies = 1;

            m_cachedSeparatingDistance = 0f;
            m_curIter = -1;
            m_degenerateSimplex = -1;
        }
コード例 #12
0
        public void Initialize(ConvexShape objectA, ConvexShape objectB, BroadphaseNativeTypes shapeTypeA, BroadphaseNativeTypes shapeTypeB, float marginA, float marginB, ISimplexSolverInterface simplexSolver, IConvexPenetrationDepthSolver penetrationDepthSolver)
        {
            m_minkowskiA = objectA;
            m_minkowskiB = objectB;
            m_shapeTypeA = shapeTypeA;
            m_shapeTypeB = shapeTypeB;
            m_marginA    = marginA;
            m_marginB    = marginB;

            m_cachedSeparatingAxis = new IndexedVector3(0, 1, 0);

            m_simplexSolver          = simplexSolver;
            m_penetrationDepthSolver = penetrationDepthSolver;
            m_ignoreMargin           = false;
            m_lastUsedMethod         = -1;
            m_catchDegeneracies      = true;
            if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugGJKDetector)
            {
                BulletGlobals.g_streamWriter.WriteLine(String.Format("GjkPairDetector-alt [{0}] [{1}]", objectA.GetName(), objectB.GetName()));
            }
        }
コード例 #13
0
        public void Initialize(ConvexShape objectA, ConvexShape objectB, BroadphaseNativeTypes shapeTypeA, BroadphaseNativeTypes shapeTypeB, float marginA, float marginB, ISimplexSolverInterface simplexSolver, IConvexPenetrationDepthSolver penetrationDepthSolver)
        {
            m_minkowskiA = objectA;
            m_minkowskiB = objectB;
            m_shapeTypeA = shapeTypeA;
            m_shapeTypeB = shapeTypeB;
            m_marginA = marginA;
            m_marginB = marginB;

            m_cachedSeparatingAxis = new IndexedVector3(0, 1, 0);

            m_simplexSolver = simplexSolver;
            m_penetrationDepthSolver = penetrationDepthSolver;
            m_ignoreMargin = false;
            m_lastUsedMethod = -1;
            m_catchDegeneracies = true;
            if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugGJKDetector)
            {
                BulletGlobals.g_streamWriter.WriteLine(String.Format("GjkPairDetector-alt [{0}] [{1}]", objectA.GetName(), objectB.GetName()));
            }

        }
コード例 #14
0
        public CollisionDispatcher()
        {
            NearCallback = DefaultNearCallback;
            //_useIslands = true;
            //default CreationFunctions, filling the m_doubleDispatch table
            _convexConvexCreateFunc         = new ConvexConvexAlgorithm.CreateFunc();
            _convexConcaveCreateFunc        = new ConvexConcaveCollisionAlgorithm.CreateFunc();
            _swappedConvexConcaveCreateFunc = new ConvexConcaveCollisionAlgorithm.SwappedCreateFunc();
            _compoundCreateFunc             = new CompoundCollisionAlgorithm.CreateFunc();
            _swappedCompoundCreateFunc      = new CompoundCollisionAlgorithm.SwappedCreateFunc();
            _emptyCreateFunc = new EmptyAlgorithm.CreateFunc();

            for (BroadphaseNativeTypes i = BroadphaseNativeTypes.Box; i < BroadphaseNativeTypes.MaxBroadphaseCollisionTypes; i++)
            {
                for (BroadphaseNativeTypes j = BroadphaseNativeTypes.Box; j < BroadphaseNativeTypes.MaxBroadphaseCollisionTypes; j++)
                {
                    _doubleDispatch[(int)i, (int)j] = FindCreateFunction(i, j);
                    if (_doubleDispatch[(int)i, (int)j] == null)
                    {
                        throw new BulletException();
                    }
                }
            }
        }
コード例 #15
0
 public GjkPairDetector(ConvexShape objectA, ConvexShape objectB, BroadphaseNativeTypes shapeTypeA, BroadphaseNativeTypes shapeTypeB, float marginA, float marginB, ISimplexSolverInterface simplexSolver, IConvexPenetrationDepthSolver penetrationDepthSolver)
 {
     Initialize(objectA, objectB, shapeTypeA, shapeTypeB, marginA, marginB, simplexSolver, penetrationDepthSolver);
 }
コード例 #16
0
ファイル: BroadphaseProxy.cs プロジェクト: suzuke/BulletXNA
 public static bool IsPolyhedral(BroadphaseNativeTypes proxyType)
 {
     return(proxyType < BroadphaseNativeTypes.IMPLICIT_CONVEX_SHAPES_START_HERE);
 }
コード例 #17
0
ファイル: BroadphaseProxy.cs プロジェクト: Belxjander/Asuna
		public static bool IsCompound(BroadphaseNativeTypes proxyType)
		{
			return (proxyType == BroadphaseNativeTypes.Compound);
		}
コード例 #18
0
		public abstract BroadphaseProxy CreateProxy(MonoXnaCompactMaths.Vector3 min, MonoXnaCompactMaths.Vector3 max, BroadphaseNativeTypes shapeType, object userData, BroadphaseProxy.CollisionFilterGroups collisionFilterGroup, BroadphaseProxy.CollisionFilterGroups collisionFilterMask);
コード例 #19
0
 public virtual BroadphaseProxy CreateProxy(IndexedVector3 aabbMin, IndexedVector3 aabbMax, BroadphaseNativeTypes shapeType, Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, IDispatcher dispatcher, Object multiSapProxy)
 {
     return(CreateProxy(ref aabbMin, ref aabbMax, shapeType, userPtr, collisionFilterGroup, collisionFilterMask, dispatcher, multiSapProxy));
 }
コード例 #20
0
        public virtual BroadphaseProxy CreateProxy(ref IndexedVector3 aabbMin, ref IndexedVector3 aabbMax, BroadphaseNativeTypes shapeType, Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, IDispatcher dispatcher, Object multiSapProxy)
        {
            DbvtProxy proxy = new DbvtProxy(ref aabbMin, ref aabbMax, userPtr, collisionFilterGroup, collisionFilterMask);

            DbvtAabbMm aabb = DbvtAabbMm.FromMM(ref aabbMin, ref aabbMax);

            //bproxy.aabb			=	btDbvtAabbMm::FromMM(aabbMin,aabbMax);
            proxy.stage      = m_stageCurrent;
            proxy.m_uniqueId = ++m_gid;
            proxy.leaf       = m_sets[0].Insert(ref aabb, proxy);
            ListAppend(proxy, ref m_stageRoots[m_stageCurrent]);
            if (!m_deferedcollide)
            {
                DbvtTreeCollider collider = BulletGlobals.DbvtTreeColliderPool.Get();
                collider.Initialize(this);
                collider.proxy = proxy;
                Dbvt.CollideTV(m_sets[0].m_root, ref aabb, collider);
                Dbvt.CollideTV(m_sets[1].m_root, ref aabb, collider);
                BulletGlobals.DbvtTreeColliderPool.Free(collider);
            }
            return(proxy);
        }
コード例 #21
0
ファイル: BroadphaseProxy.cs プロジェクト: tikibeast/orkid
 public static bool IsCompound(BroadphaseNativeTypes proxyType)
 {
     return(proxyType == BroadphaseNativeTypes.Compound);
 }
コード例 #22
0
ファイル: BroadphaseProxy.cs プロジェクト: suzuke/BulletXNA
 public static bool IsInfinite(BroadphaseNativeTypes proxyType)
 {
     return(proxyType == BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE);
 }
コード例 #23
0
 public SimpleBroadphaseProxy(Vector3 minPoint, Vector3 maxPoint, BroadphaseNativeTypes shapeType, object userData, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask)
     : base(userData, collisionFilterGroup, collisionFilterMask)
 {
     _min = minPoint;
     _max = maxPoint;
 }
コード例 #24
0
ファイル: BroadphaseProxy.cs プロジェクト: suzuke/BulletXNA
 public static bool IsCompound(BroadphaseNativeTypes proxyType)
 {
     return(proxyType == BroadphaseNativeTypes.COMPOUND_SHAPE_PROXYTYPE);
 }
コード例 #25
0
ファイル: BroadphaseProxy.cs プロジェクト: suzuke/BulletXNA
 public static bool IsSoftBody(BroadphaseNativeTypes proxyType)
 {
     return(proxyType == BroadphaseNativeTypes.SOFTBODY_SHAPE_PROXYTYPE);
 }
コード例 #26
0
ファイル: BroadphaseProxy.cs プロジェクト: suzuke/BulletXNA
 public static bool IsConcave(BroadphaseNativeTypes proxyType)
 {
     return((proxyType > BroadphaseNativeTypes.CONCAVE_SHAPES_START_HERE) &&
            (proxyType < BroadphaseNativeTypes.CONCAVE_SHAPES_END_HERE));
 }
コード例 #27
0
ファイル: BroadphaseProxy.cs プロジェクト: suzuke/BulletXNA
 public static bool IsNonMoving(BroadphaseNativeTypes proxyType)
 {
     return(IsConcave(proxyType) && !(proxyType == BroadphaseNativeTypes.GIMPACT_SHAPE_PROXYTYPE));
 }
コード例 #28
0
ファイル: BroadphaseProxy.cs プロジェクト: suzuke/BulletXNA
 public static bool IsConvex(BroadphaseNativeTypes proxyType)
 {
     return(proxyType < BroadphaseNativeTypes.CONCAVE_SHAPES_START_HERE);
 }
コード例 #29
0
        public virtual BroadphaseProxy CreateProxy(ref IndexedVector3 aabbMin, ref IndexedVector3 aabbMax, BroadphaseNativeTypes shapeType, Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, IDispatcher dispatcher, Object multiSapProxy)
        {
            //void* ignoreMe -> we could think of recursive multi-sap, if someone is interested

            MultiSapProxy proxy = new MultiSapProxy(ref aabbMin, ref aabbMax, shapeType, userPtr, collisionFilterGroup, collisionFilterMask);

            m_multiSapProxies.Add(proxy);

            ///this should deal with inserting/removal into child broadphases
            SetAabb(proxy, ref aabbMin, ref aabbMax, dispatcher);
            return(proxy);
        }
コード例 #30
0
 public abstract BroadphaseProxy CreateProxy(MonoXnaCompactMaths.Vector3 min, MonoXnaCompactMaths.Vector3 max, BroadphaseNativeTypes shapeType, object userData, BroadphaseProxy.CollisionFilterGroups collisionFilterGroup, BroadphaseProxy.CollisionFilterGroups collisionFilterMask);
コード例 #31
0
 public SimpleBroadphaseProxy(int position, ref IndexedVector3 minpt, ref IndexedVector3 maxpt, BroadphaseNativeTypes shapeType, Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, Object multiSapProxy)
     : base(ref minpt, ref maxpt, userPtr, collisionFilterGroup, collisionFilterMask, multiSapProxy)
 {
     // bit of a cheat/hack - store the position in the array as we can't find it for freehandle otherwise.
     m_position = position;
 }
コード例 #32
0
		//Broadphase Interface
		public virtual BroadphaseProxy CreateProxy(Vector3 aabbMin, Vector3 aabbMax, BroadphaseNativeTypes shapeType, Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, IDispatcher dispatcher, Object multiSapProxy)
		{
			return CreateProxy(ref aabbMin, ref aabbMax, shapeType, userPtr, collisionFilterGroup, collisionFilterMask, dispatcher, multiSapProxy);
		}
コード例 #33
0
        public void DrawXNA(ref IndexedMatrix m, CollisionShape shape, ref IndexedVector3 color, DebugDrawModes debugMode, ref IndexedVector3 worldBoundsMin, ref IndexedVector3 worldBoundsMax, ref IndexedMatrix view, ref IndexedMatrix projection)
        {
            //btglMultMatrix(m);
            if (shape == null)
            {
                return;
            }

            if (shape.GetShapeType() == BroadphaseNativeTypes.UNIFORM_SCALING_SHAPE_PROXYTYPE)
            {
                UniformScalingShape scalingShape = (UniformScalingShape)shape;
                ConvexShape         convexShape  = scalingShape.GetChildShape();
                float         scalingFactor      = scalingShape.GetUniformScalingFactor();
                IndexedMatrix scaleMatrix        = IndexedMatrix.CreateScale(scalingFactor);
                IndexedMatrix finalMatrix        = scaleMatrix * m;
                DrawXNA(ref finalMatrix, convexShape, ref color, debugMode, ref worldBoundsMin, ref worldBoundsMax, ref view, ref projection);
                return;
            }
            if (shape.GetShapeType() == BroadphaseNativeTypes.COMPOUND_SHAPE_PROXYTYPE)
            {
                CompoundShape compoundShape = (CompoundShape)shape;
                for (int i = compoundShape.GetNumChildShapes() - 1; i >= 0; i--)
                {
                    IndexedMatrix  childTrans = compoundShape.GetChildTransform(i);
                    CollisionShape colShape   = compoundShape.GetChildShape(i);
                    IndexedMatrix  childMat   = childTrans;

                    //childMat = MathUtil.bulletMatrixMultiply(m, childMat);
                    //childMat = childMat * m;
                    childMat = m * childMat;



                    DrawXNA(ref childMat, colShape, ref color, debugMode, ref worldBoundsMin, ref worldBoundsMax, ref view, ref projection);
                }
            }
            else
            {
                bool useWireframeFallback = true;

                if ((debugMode & DebugDrawModes.DBG_DrawWireframe) == 0)
                {
                    ///you can comment out any of the specific cases, and use the default
                    ///the benefit of 'default' is that it approximates the actual collision shape including collision margin
                    //BroadphaseNativeTypes shapetype = m_textureEnabled ? BroadphaseNativeTypes.MAX_BROADPHASE_COLLISION_TYPES : shape.getShapeType();
                    BroadphaseNativeTypes shapetype = shape.GetShapeType();
                    switch (shapetype)
                    {
                    case BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE:
                    {
                        BoxShape       boxShape    = shape as BoxShape;
                        IndexedVector3 halfExtents = boxShape.GetHalfExtentsWithMargin();

                        DrawSolidCube(ref halfExtents, ref m, ref view, ref projection, ref color);
                        //drawSolidSphere(halfExtents.X, 10, 10, ref m, ref view, ref projection);
                        //drawCylinder(halfExtents.X, halfExtents.Y, 1, ref m, ref view, ref projection);
                        //drawSolidCone(halfExtents.Y, halfExtents.X, ref m, ref view, ref projection);

                        //DrawText("Hello World", new IndexedVector3(20, 20, 0), new IndexedVector3(255, 255, 255));
                        useWireframeFallback = false;
                        break;
                    }


                    case BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE:
                    {
                        SphereShape sphereShape = shape as SphereShape;
                        float       radius      = sphereShape.GetMargin();//radius doesn't include the margin, so draw with margin
                        DrawSolidSphere(radius, 10, 10, ref m, ref view, ref projection, ref color);
                        //glutSolidSphere(radius,10,10);
                        useWireframeFallback = false;
                        break;
                    }

                    case BroadphaseNativeTypes.CAPSULE_SHAPE_PROXYTYPE:
                    {
                        CapsuleShape capsuleShape = shape as CapsuleShape;

                        float radius     = capsuleShape.GetRadius();
                        float halfHeight = capsuleShape.GetHalfHeight();

                        int upAxis = capsuleShape.GetUpAxis();

                        IndexedVector3 capStart = IndexedVector3.Zero;
                        capStart[upAxis] = -halfHeight;

                        IndexedVector3 capEnd = IndexedVector3.Zero;
                        capEnd[upAxis] = halfHeight;

                        // Draw the ends
                        {
                            IndexedMatrix childTransform = IndexedMatrix.Identity;
                            childTransform._origin = m * capStart;
                            DrawSolidSphere(radius, 5, 5, ref childTransform, ref view, ref projection, ref color);
                        }

                        {
                            IndexedMatrix childTransform = IndexedMatrix.Identity;
                            childTransform._origin = m * capEnd;
                            DrawSolidSphere(radius, 5, 5, ref childTransform, ref view, ref projection, ref color);
                        }

                        DrawCylinder(radius, halfHeight, upAxis, ref m, ref view, ref projection, ref color);
                        break;
                    }

                    case BroadphaseNativeTypes.CONE_SHAPE_PROXYTYPE:
                    {
                        ConeShape     coneShape    = (ConeShape)(shape);
                        int           upIndex      = coneShape.GetConeUpIndex();
                        float         radius       = coneShape.GetRadius(); //+coneShape.getMargin();
                        float         height       = coneShape.GetHeight(); //+coneShape.getMargin();
                        IndexedMatrix rotateMatrix = IndexedMatrix.Identity;


                        switch (upIndex)
                        {
                        case 0:
                            rotateMatrix = IndexedMatrix.CreateRotationX(-MathUtil.SIMD_HALF_PI);
                            break;

                        case 1:
                            break;

                        case 2:
                            rotateMatrix = IndexedMatrix.CreateRotationX(MathUtil.SIMD_HALF_PI);
                            break;

                        default:
                        {
                            break;
                        }
                        }
                        ;

                        IndexedMatrix translationMatrix = IndexedMatrix.CreateTranslation(0f, 0f, -0.5f * height);

                        IndexedMatrix resultant = m * rotateMatrix * translationMatrix;

                        DrawSolidCone(height, radius, ref resultant, ref view, ref projection, ref color);
                        useWireframeFallback = false;
                        break;
                    }


                    case BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE:
                    {
                        StaticPlaneShape staticPlaneShape = shape as StaticPlaneShape;
                        float            planeConst = staticPlaneShape.GetPlaneConstant();
                        IndexedVector3   planeNormal = staticPlaneShape.GetPlaneNormal();
                        IndexedVector3   planeOrigin = planeNormal * planeConst;
                        IndexedVector3   vec0, vec1;
                        TransformUtil.PlaneSpace1(ref planeNormal, out vec0, out vec1);
                        float          vecLen = 100f;
                        IndexedVector3 pt0 = planeOrigin + vec0 * vecLen;
                        IndexedVector3 pt1 = planeOrigin - vec0 * vecLen;
                        IndexedVector3 pt2 = planeOrigin + vec1 * vecLen;
                        IndexedVector3 pt3 = planeOrigin - vec1 * vecLen;

                        // Fallback to debug draw - needs tidying
                        IndexedVector3 colour = new IndexedVector3(255, 255, 255);
                        DrawLine(ref pt0, ref pt1, ref colour);
                        DrawLine(ref pt1, ref pt2, ref colour);
                        DrawLine(ref pt2, ref pt3, ref colour);
                        DrawLine(ref pt3, ref pt1, ref colour);

                        break;
                    }

                    case BroadphaseNativeTypes.CYLINDER_SHAPE_PROXYTYPE:
                    {
                        CylinderShape cylinder = (CylinderShape)(shape);
                        int           upAxis   = cylinder.GetUpAxis();

                        float radius     = cylinder.GetRadius();
                        float halfHeight = cylinder.GetHalfExtentsWithMargin()[upAxis];
                        DrawCylinder(radius, halfHeight, upAxis, ref m, ref view, ref projection, ref color);
                        break;
                    }

                    default:
                    {
                        if (shape.IsConvex())
                        {
                            ShapeCache sc = Cache(shape as ConvexShape);

                            //if (shape.getUserPointer())
                            {
                                //glutSolidCube(1.0);
                                ShapeHull hull = sc.m_shapehull /*(btShapeHull*)shape.getUserPointer()*/;

                                int numTriangles = hull.NumTriangles();
                                int numIndices   = hull.NumIndices();
                                int numVertices  = hull.NumVertices();
                                if (numTriangles > 0)
                                {
                                    int                    index = 0;
                                    IList <int>            idx   = hull.m_indices;
                                    IList <IndexedVector3> vtx   = hull.m_vertices;

                                    for (int i = 0; i < numTriangles; i++)
                                    {
                                        int i1 = index++;
                                        int i2 = index++;
                                        int i3 = index++;
                                        Debug.Assert(i1 < numIndices &&
                                                     i2 < numIndices &&
                                                     i3 < numIndices);

                                        int index1 = idx[i1];
                                        int index2 = idx[i2];
                                        int index3 = idx[i3];
                                        Debug.Assert(index1 < numVertices &&
                                                     index2 < numVertices &&
                                                     index3 < numVertices);

                                        IndexedVector3 v1     = m * vtx[index1];
                                        IndexedVector3 v2     = m * vtx[index2];
                                        IndexedVector3 v3     = m * vtx[index3];
                                        IndexedVector3 normal = IndexedVector3.Cross((v3 - v1), (v2 - v1));
                                        normal.Normalize();

                                        Vector2 tex = new Vector2(0, 0);
                                        AddVertex(ref v1, ref normal, ref tex);
                                        AddVertex(ref v2, ref normal, ref tex);
                                        AddVertex(ref v3, ref normal, ref tex);
                                    }
                                }
                            }
                        }
                        break;
                    }
                    }
                }

                /// for polyhedral shapes
                if (debugMode == DebugDrawModes.DBG_DrawFeaturesText && (shape.IsPolyhedral()))
                {
                    PolyhedralConvexShape polyshape = (PolyhedralConvexShape)shape;
                    {
                        //BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),polyshape.getExtraDebugInfo());

                        IndexedVector3 colour = new IndexedVector3(255, 255, 255);
                        for (int i = 0; i < polyshape.GetNumVertices(); i++)
                        {
                            IndexedVector3 vtx;
                            polyshape.GetVertex(i, out vtx);
                            String buf = " " + i;
                            DrawText(buf, ref vtx, ref colour);
                        }

                        for (int i = 0; i < polyshape.GetNumPlanes(); i++)
                        {
                            IndexedVector3 normal;
                            IndexedVector3 vtx;
                            polyshape.GetPlane(out normal, out vtx, i);
                            float d = IndexedVector3.Dot(vtx, normal);
                            vtx *= d;

                            String buf = " plane " + i;
                            DrawText(buf, ref vtx, ref colour);
                        }
                    }
                }

                if (shape.IsConcave() && !shape.IsInfinite())    //>getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE||shape.getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
                //		if (shape.getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
                {
                    ConcaveShape concaveMesh = shape as ConcaveShape;

                    XNADrawcallback drawCallback = new XNADrawcallback(this, ref m);
                    drawCallback.m_wireframe = (debugMode & DebugDrawModes.DBG_DrawWireframe) != 0;

                    concaveMesh.ProcessAllTriangles(drawCallback, ref worldBoundsMin, ref worldBoundsMax);
                }

                //glDisable(GL_DEPTH_TEST);
                //glRasterPos3f(0,0,0);//mvtx.x(),  vtx.y(),  vtx.z());
                if ((debugMode & DebugDrawModes.DBG_DrawText) != 0)
                {
                    IndexedVector3 position = IndexedVector3.Zero;
                    IndexedVector3 colour   = new IndexedVector3(255, 255, 255);
                    DrawText(shape.GetName(), ref position, ref colour);
                }

                if ((debugMode & DebugDrawModes.DBG_DrawFeaturesText) != 0)
                {
                    //drawText(shape.getEx]
                    //BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape.getExtraDebugInfo());
                }
                //glEnable(GL_DEPTH_TEST);

                ////	glPopMatrix();
                //if(m_textureenabled) glDisable(GL_TEXTURE_2D);
                //  }
                //    glPopMatrix();
            }
        }
コード例 #34
0
        public virtual CollisionAlgorithmCreateFunc GetCollisionAlgorithmCreateFunc(BroadphaseNativeTypes proxyType0, BroadphaseNativeTypes proxyType1)
        {
            if ((proxyType0 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE))
            {
                return(m_sphereSphereCF);
            }

            if ((proxyType0 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE))
            {
                return(m_sphereBoxCF);
            }

            if ((proxyType0 == BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE))
            {
                return(m_boxSphereCF);
            }

            if ((proxyType0 == BroadphaseNativeTypes.CONVEX_2D_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.CONVEX_2D_SHAPE_PROXYTYPE))
            {
                return(m_convexAlgo2DCF);
            }

            if ((proxyType0 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.TRIANGLE_SHAPE_PROXYTYPE))
            {
                return(m_sphereTriangleCF);
            }

            if ((proxyType0 == BroadphaseNativeTypes.TRIANGLE_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE))
            {
                return(m_triangleSphereCF);
            }

            if ((proxyType0 == BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE))
            {
                return(m_boxBoxCF);
            }

            if (BroadphaseProxy.IsConvex(proxyType0) && (proxyType1 == BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE))
            {
                return(m_convexPlaneCF);
            }

            if (BroadphaseProxy.IsConvex(proxyType1) && (proxyType0 == BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE))
            {
                return(m_planeConvexCF);
            }
            if (BroadphaseProxy.IsConvex(proxyType0) && BroadphaseProxy.IsConvex(proxyType1))
            {
                return(m_convexConvexCreateFunc);
            }

            if (BroadphaseProxy.IsConvex(proxyType0) && BroadphaseProxy.IsConcave(proxyType1))
            {
                return(m_convexConcaveCreateFunc);
            }

            if (BroadphaseProxy.IsConvex(proxyType1) && BroadphaseProxy.IsConcave(proxyType0))
            {
                return(m_swappedConvexConcaveCreateFunc);
            }

            if (BroadphaseProxy.IsCompound(proxyType0))
            {
                return(m_compoundCreateFunc);
            }
            else
            {
                if (BroadphaseProxy.IsCompound(proxyType1))
                {
                    return(m_swappedCompoundCreateFunc);
                }
            }

            //failed to find an algorithm
            return(m_emptyCreateFunc);
        }
コード例 #35
0
ファイル: BroadphaseProxy.cs プロジェクト: tikibeast/orkid
 public static bool IsConcave(BroadphaseNativeTypes proxyType)
 {
     return((proxyType > BroadphaseNativeTypes.ConcaveShapesStart) &&
            (proxyType < BroadphaseNativeTypes.ConcaveShapesEnd));
 }
コード例 #36
0
 public SimpleBroadphaseProxy(int position, ref IndexedVector3 minpt, ref IndexedVector3 maxpt, BroadphaseNativeTypes shapeType, Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, Object multiSapProxy)
     : base(ref minpt, ref maxpt, userPtr, collisionFilterGroup, collisionFilterMask, multiSapProxy)
 {
     // bit of a cheat/hack - store the position in the array as we can't find it for freehandle otherwise.
     m_position = position;
 }
コード例 #37
0
ファイル: DbvtBroadphase.cs プロジェクト: Belxjander/Asuna
        public virtual BroadphaseProxy CreateProxy(ref IndexedVector3 aabbMin, ref IndexedVector3 aabbMax, BroadphaseNativeTypes shapeType, Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, IDispatcher dispatcher, Object multiSapProxy)
        {
            DbvtProxy proxy = new DbvtProxy(ref aabbMin, ref aabbMax, userPtr, collisionFilterGroup, collisionFilterMask);

            DbvtAabbMm aabb = DbvtAabbMm.FromMM(ref aabbMin, ref aabbMax);

            //bproxy.aabb			=	btDbvtAabbMm::FromMM(aabbMin,aabbMax);
            proxy.stage = m_stageCurrent;
            proxy.m_uniqueId = ++m_gid;
            proxy.leaf = m_sets[0].Insert(ref aabb, proxy);
            ListAppend(proxy, ref m_stageRoots[m_stageCurrent]);
            
            if (!m_deferedcollide)
            {
                DbvtTreeCollider collider = new DbvtTreeCollider();
                collider.Initialize(this);
                collider.proxy = proxy;
                Dbvt.CollideTV(m_sets[0].m_root, ref aabb, collider, m_sets[0].CollideTVStack, ref m_sets[0].CollideTVCount);
                Dbvt.CollideTV(m_sets[1].m_root, ref aabb, collider, m_sets[1].CollideTVStack, ref m_sets[1].CollideTVCount);
                
            }
            return (proxy);

        }
コード例 #38
0
ファイル: BroadphaseProxy.cs プロジェクト: Belxjander/Asuna
		public static bool IsConvex(BroadphaseNativeTypes proxyType)
		{
			return (proxyType < BroadphaseNativeTypes.ConcaveShapesStart);
		}
コード例 #39
0
        public virtual BroadphaseProxy CreateProxy(ref IndexedVector3 aabbMin, ref IndexedVector3 aabbMax, BroadphaseNativeTypes shapeType, Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, IDispatcher dispatcher, Object multiSapProxy)
        {
            if (m_numHandles >= m_maxHandles)
            {
                Debug.Assert(false);
                return(null); //should never happen, but don't let the game crash ;-)
            }

            int position = AllocHandle();

            m_pHandles[position]            = new SimpleBroadphaseProxy(position, ref aabbMin, ref aabbMax, shapeType, userPtr, collisionFilterGroup, collisionFilterMask, multiSapProxy);;
            m_pHandles[position].m_uniqueId = ++m_proxyCounter;
            return(m_pHandles[position]);
        }
コード例 #40
0
ファイル: BroadphaseProxy.cs プロジェクト: suzuke/BulletXNA
 public static bool IsConvex2d(BroadphaseNativeTypes proxyType)
 {
     return((proxyType == BroadphaseNativeTypes.BOX_2D_SHAPE_PROXYTYPE) || (proxyType == BroadphaseNativeTypes.CONVEX_2D_SHAPE_PROXYTYPE));
 }
コード例 #41
0
ファイル: BroadphaseProxy.cs プロジェクト: Belxjander/Asuna
		public static bool IsPolyhedral(BroadphaseNativeTypes proxyType)
		{
			return (proxyType < BroadphaseNativeTypes.ImplicitConvexShapes);
		}
コード例 #42
0
 public abstract BroadphaseProxy CreateProxy(Microsoft.Xna.Framework.Vector3 min, Microsoft.Xna.Framework.Vector3 max, BroadphaseNativeTypes shapeType, object userData, BroadphaseProxy.CollisionFilterGroups collisionFilterGroup, BroadphaseProxy.CollisionFilterGroups collisionFilterMask);
コード例 #43
0
ファイル: BroadphaseProxy.cs プロジェクト: Belxjander/Asuna
		public static bool IsConcave(BroadphaseNativeTypes proxyType)
		{
			return ((proxyType > BroadphaseNativeTypes.ConcaveShapesStart) &&
				(proxyType < BroadphaseNativeTypes.ConcaveShapesEnd));
		}
コード例 #44
0
		private CollisionAlgorithmCreateFunction FindCreateFunction(BroadphaseNativeTypes proxyTypeA, BroadphaseNativeTypes proxyTypeB)
		{
			if (BroadphaseProxy.IsConvex(proxyTypeA) && BroadphaseProxy.IsConvex(proxyTypeB))
			{
				return _convexConvexCreateFunc;
			}

			if (BroadphaseProxy.IsConvex(proxyTypeA) && BroadphaseProxy.IsConcave(proxyTypeB))
			{
				return _convexConcaveCreateFunc;
			}

			if (BroadphaseProxy.IsConvex(proxyTypeB) && BroadphaseProxy.IsConcave(proxyTypeA))
			{
				return _swappedConvexConcaveCreateFunc;
			}

			if (BroadphaseProxy.IsCompound(proxyTypeA))
			{
				return _compoundCreateFunc;
			}
			else
			{
				if (BroadphaseProxy.IsCompound(proxyTypeB))
				{
					return _swappedCompoundCreateFunc;
				}
			}

			//failed to find an algorithm
			return _emptyCreateFunc;
		}
コード例 #45
0
ファイル: BroadphaseProxy.cs プロジェクト: Belxjander/Asuna
		public static bool IsInfinite(BroadphaseNativeTypes proxyType)
		{
			return (proxyType == BroadphaseNativeTypes.StaticPlane);
		}
コード例 #46
0
ファイル: BroadphaseProxy.cs プロジェクト: tikibeast/orkid
 public static bool IsInfinite(BroadphaseNativeTypes proxyType)
 {
     return(proxyType == BroadphaseNativeTypes.StaticPlane);
 }
コード例 #47
0
ファイル: BroadphaseProxy.cs プロジェクト: himapo/ccm
 public static bool isCompound(BroadphaseNativeTypes proxyType)
 {
     return (proxyType == BroadphaseNativeTypes.COMPOUND_SHAPE_PROXYTYPE);
 }
コード例 #48
0
        public virtual BroadphaseProxy CreateProxy(ref IndexedVector3 aabbMin, ref IndexedVector3 aabbMax, BroadphaseNativeTypes shapeType, Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, IDispatcher dispatcher, Object multiSapProxy)
        {
            ushort handleId = AddHandle(ref aabbMin, ref aabbMax, userPtr, collisionFilterGroup, collisionFilterMask, dispatcher, multiSapProxy);

            Handle handle = GetHandle(handleId);

            if (m_raycastAccelerator != null)
            {
                BroadphaseProxy rayProxy = m_raycastAccelerator.CreateProxy(ref aabbMin, ref aabbMax, shapeType, userPtr, collisionFilterGroup, collisionFilterMask, dispatcher, 0);
                handle.m_dbvtProxy = rayProxy;
            }
            return(handle);
        }
コード例 #49
0
		public virtual BroadphaseProxy CreateProxy(ref Vector3 aabbMin, ref Vector3 aabbMax, BroadphaseNativeTypes shapeType, Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, IDispatcher dispatcher, Object multiSapProxy)
		{
			ushort handleId = AddHandle(ref aabbMin,ref aabbMax, userPtr,collisionFilterGroup,collisionFilterMask,dispatcher,multiSapProxy);
		
			Handle handle = GetHandle(handleId);
		
			if (m_raycastAccelerator != null)
			{
				BroadphaseProxy rayProxy = m_raycastAccelerator.CreateProxy(ref aabbMin,ref aabbMax,shapeType,userPtr,collisionFilterGroup,collisionFilterMask,dispatcher,0);
				handle.m_dbvtProxy = rayProxy;
			}
			return handle;

		}
コード例 #50
0
ファイル: BroadphaseProxy.cs プロジェクト: himapo/ccm
        public static bool isSoftBody(BroadphaseNativeTypes proxyType)
	    {
            return (proxyType == BroadphaseNativeTypes.SOFTBODY_SHAPE_PROXYTYPE);
	    }
コード例 #51
0
		public abstract BroadphaseProxy CreateProxy(Microsoft.Xna.Framework.Vector3 min, Microsoft.Xna.Framework.Vector3 max, BroadphaseNativeTypes shapeType, object userData, BroadphaseProxy.CollisionFilterGroups collisionFilterGroup, BroadphaseProxy.CollisionFilterGroups collisionFilterMask);
コード例 #52
0
ファイル: BroadphaseProxy.cs プロジェクト: himapo/ccm
        public static bool isInfinite(BroadphaseNativeTypes proxyType)
	    {
            return (proxyType == BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE);
	    }
コード例 #53
0
ファイル: AxisSweep3.cs プロジェクト: Belxjander/Asuna
        public override BroadphaseProxy CreateProxy(Vector3 min, Vector3 max, BroadphaseNativeTypes shapeType, object userData, BroadphaseProxy.CollisionFilterGroups collisionFilterGroup, BroadphaseProxy.CollisionFilterGroups collisionFilterMask)
        {
		    ushort handleId = AddHandle(min, max, userData, collisionFilterGroup, collisionFilterMask);
    		
		    Handle handle = GetHandle(handleId);
    				
		    return handle;
        }
コード例 #54
0
ファイル: BroadphaseProxy.cs プロジェクト: himapo/ccm
 public static bool isConvex2d(BroadphaseNativeTypes proxyType)
 {
     return (proxyType == BroadphaseNativeTypes.BOX_2D_SHAPE_PROXYTYPE) || (proxyType == BroadphaseNativeTypes.CONVEX_2D_SHAPE_PROXYTYPE);
 }
コード例 #55
0
ファイル: BSAPIXNA.cs プロジェクト: CassieEllen/opensim
    public BSPhysicsShapeType BSShapeTypeFromBroadPhaseNativeType(BroadphaseNativeTypes pin)
    {
        BSPhysicsShapeType ret = BSPhysicsShapeType.SHAPE_UNKNOWN;
        switch (pin)
        {
            case BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_BOX;
                break;
            case BroadphaseNativeTypes.TRIANGLE_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;

            case BroadphaseNativeTypes.TETRAHEDRAL_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            case BroadphaseNativeTypes.CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_CONVEXHULL;
                break;
            case BroadphaseNativeTypes.CONVEX_HULL_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_HULL;
                break;
            case BroadphaseNativeTypes.CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            case BroadphaseNativeTypes.CUSTOM_POLYHEDRAL_SHAPE_TYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            //implicit convex shapes
            case BroadphaseNativeTypes.IMPLICIT_CONVEX_SHAPES_START_HERE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            case BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_SPHERE;
                break;
            case BroadphaseNativeTypes.MULTI_SPHERE_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            case BroadphaseNativeTypes.CAPSULE_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_CAPSULE;
                break;
            case BroadphaseNativeTypes.CONE_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_CONE;
                break;
            case BroadphaseNativeTypes.CONVEX_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_CONVEXHULL;
                break;
            case BroadphaseNativeTypes.CYLINDER_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_CYLINDER;
                break;
            case BroadphaseNativeTypes.UNIFORM_SCALING_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            case BroadphaseNativeTypes.MINKOWSKI_SUM_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            case BroadphaseNativeTypes.MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            case BroadphaseNativeTypes.BOX_2D_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            case BroadphaseNativeTypes.CONVEX_2D_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            case BroadphaseNativeTypes.CUSTOM_CONVEX_SHAPE_TYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            //concave shape
            case BroadphaseNativeTypes.CONCAVE_SHAPES_START_HERE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            //keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
            case BroadphaseNativeTypes.TRIANGLE_MESH_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_MESH;
                break;
            case BroadphaseNativeTypes.SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_MESH;
                break;
            ///used for demo integration FAST/Swift collision library and Bullet
            case BroadphaseNativeTypes.FAST_CONCAVE_MESH_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_MESH;
                break;
            //terrain
            case BroadphaseNativeTypes.TERRAIN_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_HEIGHTMAP;
                break;
            ///Used for GIMPACT Trimesh integration
            case BroadphaseNativeTypes.GIMPACT_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_GIMPACT;
                break;
            ///Multimaterial mesh
            case BroadphaseNativeTypes.MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_MESH;
                break;

            case BroadphaseNativeTypes.EMPTY_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            case BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_GROUNDPLANE;
                break;
            case BroadphaseNativeTypes.CUSTOM_CONCAVE_SHAPE_TYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            case BroadphaseNativeTypes.CONCAVE_SHAPES_END_HERE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;

            case BroadphaseNativeTypes.COMPOUND_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_COMPOUND;
                break;

            case BroadphaseNativeTypes.SOFTBODY_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_MESH;
                break;
            case BroadphaseNativeTypes.HFFLUID_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            case BroadphaseNativeTypes.HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
            case BroadphaseNativeTypes.INVALID_SHAPE_PROXYTYPE:
                ret =  BSPhysicsShapeType.SHAPE_UNKNOWN;
                break;
        }
        return ret;
    }
コード例 #56
0
		public abstract btBroadphaseProxy createProxy( ref btVector3 aabbMin, ref btVector3 aabbMax, BroadphaseNativeTypes shapeType, btCollisionObject userPtr, btBroadphaseProxy.CollisionFilterGroups collisionFilterGroup, btBroadphaseProxy.CollisionFilterGroups collisionFilterMask, btDispatcher dispatcher, object multiSapProxy );
コード例 #57
0
		//registerCollisionCreateFunc allows registration of custom/alternative collision create functions
		public void RegisterCollisionCreateFunc(BroadphaseNativeTypes proxyTypeA, BroadphaseNativeTypes proxyTypeB, CollisionAlgorithmCreateFunction createFunc)
		{
			_doubleDispatch[(int)proxyTypeA, (int)proxyTypeB] = createFunc;
		}
コード例 #58
0
 public GjkPairDetector(ConvexShape objectA, ConvexShape objectB, BroadphaseNativeTypes shapeTypeA, BroadphaseNativeTypes shapeTypeB, float marginA, float marginB, ISimplexSolverInterface simplexSolver, IConvexPenetrationDepthSolver penetrationDepthSolver)
 {
     Initialize(objectA, objectB, shapeTypeA, shapeTypeB, marginA, marginB, simplexSolver,penetrationDepthSolver);
 }
コード例 #59
0
    public virtual CollisionAlgorithmCreateFunc GetCollisionAlgorithmCreateFunc(BroadphaseNativeTypes proxyType0, BroadphaseNativeTypes proxyType1)
    {

	    if ((proxyType0 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE) && (proxyType1==BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE))
	    {
		    return	m_sphereSphereCF;
	    }

	    if ((proxyType0 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE) && (proxyType1==BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE))
	    {
		    return	m_sphereBoxCF;
	    }

	    if ((proxyType0 == BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE ) && (proxyType1==BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE))
	    {
		    return	m_boxSphereCF;
	    }

        if ((proxyType0 == BroadphaseNativeTypes.CONVEX_2D_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.CONVEX_2D_SHAPE_PROXYTYPE))
        {
            return m_convexAlgo2DCF;
        }

	    if ((proxyType0 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE ) && (proxyType1==BroadphaseNativeTypes.TRIANGLE_SHAPE_PROXYTYPE))
	    {
		    return	m_sphereTriangleCF;
	    }

	    if ((proxyType0 == BroadphaseNativeTypes.TRIANGLE_SHAPE_PROXYTYPE  ) && (proxyType1==BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE))
	    {
		    return	m_triangleSphereCF;
	    } 

	    if ((proxyType0 == BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE))
	    {
		    return m_boxBoxCF;
	    }
    	
	    if (BroadphaseProxy.IsConvex(proxyType0) && (proxyType1 == BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE))
	    {
		    return m_convexPlaneCF;
	    }

	    if (BroadphaseProxy.IsConvex(proxyType1) && (proxyType0 == BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE))
	    {
		    return m_planeConvexCF;
	    }
	    if (BroadphaseProxy.IsConvex(proxyType0) && BroadphaseProxy.IsConvex(proxyType1))
	    {
		    return m_convexConvexCreateFunc;
	    }

	    if (BroadphaseProxy.IsConvex(proxyType0) && BroadphaseProxy.IsConcave(proxyType1))
	    {
		    return m_convexConcaveCreateFunc;
	    }

	    if (BroadphaseProxy.IsConvex(proxyType1) && BroadphaseProxy.IsConcave(proxyType0))
	    {
		    return m_swappedConvexConcaveCreateFunc;
	    }

	    if (BroadphaseProxy.IsCompound(proxyType0))
	    {
		    return m_compoundCreateFunc;
	    } 
        else
	    {
		    if (BroadphaseProxy.IsCompound(proxyType1))
		    {
			    return m_swappedCompoundCreateFunc;
		    }
	    }

	    //failed to find an algorithm
	    return m_emptyCreateFunc;
    }
コード例 #60
0
        public virtual BroadphaseProxy CreateProxy(ref IndexedVector3 aabbMin, ref IndexedVector3 aabbMax, BroadphaseNativeTypes shapeType, Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, IDispatcher dispatcher, Object multiSapProxy)
        {
            if (m_numHandles >= m_maxHandles)
            {
                Debug.Assert(false);
                return null; //should never happen, but don't let the game crash ;-)
            }

            int position = AllocHandle();
            m_pHandles[position] = new SimpleBroadphaseProxy(position, ref aabbMin, ref aabbMax, shapeType, userPtr, collisionFilterGroup, collisionFilterMask, multiSapProxy); ;
            m_pHandles[position].m_uniqueId = ++m_proxyCounter;
            return m_pHandles[position];
        }