コード例 #1
0
ファイル: CollisionWorld.cs プロジェクト: HaKDMoDz/InVision
        public void	UpdateSingleAabb(CollisionObject colObj)
        {
	        Vector3 minAabb = new Vector3();
            Vector3 maxAabb = new Vector3();
            Matrix wt = colObj.GetWorldTransform();
	        colObj.GetCollisionShape().GetAabb(ref wt, ref minAabb,ref maxAabb);
	        //need to increase the aabb for contact thresholds
            Vector3 contactThreshold = new Vector3(BulletGlobals.gContactBreakingThreshold, BulletGlobals.gContactBreakingThreshold, BulletGlobals.gContactBreakingThreshold);
	        minAabb -= contactThreshold;
	        maxAabb += contactThreshold;



            if (BulletGlobals.g_streamWriter != null && debugCollisionWorld)
            {
                MathUtil.PrintVector3(BulletGlobals.g_streamWriter, "updateSingleAabbMin", minAabb);
                MathUtil.PrintVector3(BulletGlobals.g_streamWriter, "updateSingleAabbMax", maxAabb);
            }


	        IBroadphaseInterface bp = (IBroadphaseInterface)m_broadphasePairCache;

	        //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");
		        }
	        }
        }
コード例 #2
0
ファイル: CollisionWorld.cs プロジェクト: HaKDMoDz/InVision
        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);
        }