Esempio n. 1
0
        public virtual void RemoveCollisionObject(CollisionObject collisionObject)
        {
	        //bool removeFromBroadphase = false;
	        {
		        BroadphaseProxy bp = collisionObject.GetBroadphaseHandle();
		        if (bp != null)
		        {
			        //
			        // only clear the cached algorithms
			        //
			        GetBroadphase().GetOverlappingPairCache().CleanProxyFromPairs(bp,m_dispatcher1);
			        GetBroadphase().DestroyProxy(bp,m_dispatcher1);
			        collisionObject.SetBroadphaseHandle(null);
		        }
	        }
	        //swapremove
	        m_collisionObjects.Remove(collisionObject);
        }
Esempio n. 2
0
        public virtual void AddCollisionObject(CollisionObject collisionObject, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask)
        {
    	    //check that the object isn't already added
            //btAssert( m_collisionObjects.findLinearSearch(collisionObject)  == m_collisionObjects.size());

            Debug.Assert(collisionObject != null);
		    m_collisionObjects.Add(collisionObject);

		    //calculate new AABB
		    Matrix trans = collisionObject.GetWorldTransform();
            Vector3 minAabb = new Vector3();
            Vector3 maxAabb= new Vector3();

		    collisionObject.GetCollisionShape().GetAabb(ref trans,ref minAabb,ref maxAabb);

		    BroadphaseNativeTypes type = collisionObject.GetCollisionShape().ShapeType;
		    collisionObject.SetBroadphaseHandle( GetBroadphase().CreateProxy(
			    ref minAabb,
			    ref maxAabb,
			    type,
			    collisionObject,
			    collisionFilterGroup,
			    collisionFilterMask,
			    m_dispatcher1,0
			    ))	;
        }