///this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete those
		public DiscreteDynamicsWorld(IDispatcher dispatcher, IBroadphaseInterface pairCache, IConstraintSolver constraintSolver, ICollisionConfiguration collisionConfiguration)
			: base(dispatcher, pairCache, collisionConfiguration)
		{
			m_ownsIslandManager = true;
			m_constraints = new ObjectArray<TypedConstraint>();
			m_actions = new List<IActionInterface>();
			m_nonStaticRigidBodies = new ObjectArray<RigidBody>();
			m_islandManager = new SimulationIslandManager();
			m_constraintSolver = constraintSolver;

			Gravity = new Vector3(0, -10, 0);
			m_localTime = 1f / 60f;
			m_profileTimings = 0;
			m_synchronizeAllMotionStates = false;

			if (m_constraintSolver == null)
			{
				m_constraintSolver = new SequentialImpulseConstraintSolver();
				m_ownsConstraintSolver = true;
			}
			else
			{
				m_ownsConstraintSolver = false;
			}
		}
Example #2
0
 public DynamicsWorld(IDispatcher dispatcher, IBroadphaseInterface broadphase, ICollisionConfiguration collisionConfiguration)
     : base(dispatcher, broadphase, collisionConfiguration)
 {
     m_internalTickCallback = null;
     m_worldUserInfo        = null;
     m_solverInfo           = new ContactSolverInfo();
 }
Example #3
0
 public DynamicsWorld(IDispatcher dispatcher, IBroadphaseInterface broadphase, ICollisionConfiguration collisionConfiguration)
     : base(dispatcher, broadphase, collisionConfiguration)
 {
     InternalTickCallback = null;
     InternalPreTickCallback = null;
     m_worldUserInfo = null;
 }
        ///this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete those
        public DiscreteDynamicsWorld(IDispatcher dispatcher, IBroadphaseInterface pairCache, IConstraintSolver constraintSolver, ICollisionConfiguration collisionConfiguration)
            : base(dispatcher, pairCache, collisionConfiguration)
        {
            m_ownsIslandManager        = true;
            m_constraints              = new ObjectArray <TypedConstraint>();
            m_sortedConstraints        = new ObjectArray <TypedConstraint>();
            m_islandSortPredicate      = new SortConstraintOnIslandPredicate();
            m_islandQuickSortPredicate = new QuickSortConstraintOnIslandPredicate();
            m_actions = new List <IActionInterface>();
            m_nonStaticRigidBodies = new ObjectArray <RigidBody>();
            m_islandManager        = new SimulationIslandManager();
            m_constraintSolver     = constraintSolver;

            IndexedVector3 gravity = new IndexedVector3(0, -10, 0);

            SetGravity(ref gravity);
            m_localTime                  = 0f;
            m_profileTimings             = 0;
            m_synchronizeAllMotionStates = false;

            if (m_constraintSolver == null)
            {
                m_constraintSolver     = new SequentialImpulseConstraintSolver();
                m_ownsConstraintSolver = true;
            }
            else
            {
                m_ownsConstraintSolver = false;
            }
        }
Example #5
0
		public DynamicsWorld(IDispatcher dispatcher,IBroadphaseInterface broadphase,ICollisionConfiguration collisionConfiguration)
		:base(dispatcher,broadphase,collisionConfiguration)
		{
            m_internalTickCallback = null;
            m_worldUserInfo = null;
            m_solverInfo = new ContactSolverInfo();
		}
Example #6
0
 //this constructor doesn't own the dispatcher and paircache/broadphase
 public CollisionWorld(IDispatcher dispatcher, IBroadphaseInterface broadphasePairCache, ICollisionConfiguration collisionConfiguration)
 {
     m_dispatcher1 = dispatcher;
     m_broadphasePairCache = broadphasePairCache;
     m_collisionObjects = new ObjectArray<CollisionObject>();
     m_dispatchInfo = new DispatcherInfo();
     m_forceUpdateAllAabbs = true;
 }
        ///this btSimpleDynamicsWorld constructor creates dispatcher, broadphase pairCache and constraintSolver
        public SimpleDynamicsWorld(IDispatcher dispatcher, IBroadphaseInterface pairCache, IConstraintSolver constraintSolver, ICollisionConfiguration collisionConfiguration)
            : base(dispatcher, pairCache, collisionConfiguration)
        {
            m_constraintSolver     = constraintSolver;
            m_ownsConstraintSolver = false;
            IndexedVector3 gravity = new IndexedVector3(0, 0, -10f);

            SetGravity(ref gravity);
        }
		///this btSimpleDynamicsWorld constructor creates dispatcher, broadphase pairCache and constraintSolver
		public SimpleDynamicsWorld(IDispatcher dispatcher, IBroadphaseInterface pairCache, IConstraintSolver constraintSolver, ICollisionConfiguration collisionConfiguration)
			: base(dispatcher, pairCache, collisionConfiguration)
		{
			m_constraintSolver = constraintSolver;
			m_ownsConstraintSolver = false;
			IndexedVector3 gravity = new IndexedVector3(0, 0, -10f);
			SetGravity(ref gravity);

		}
		public void update(float speed,float amplitude,IBroadphaseInterface pbi)
		{
			time +=	speed;
			center.X = (float)(System.Math.Cos(time*2.17f)*amplitude+System.Math.Sin(time)*amplitude/2f);
			center.Y =	(float)(System.Math.Cos(time*1.38f)*amplitude+System.Math.Sin(time)*amplitude);
			center.Z = (float)(System.Math.Sin(time*0.777f)*amplitude);
			Vector3 temp1 = center-extents;
			Vector3 temp2 = center+extents;
			pbi.SetAabb(proxy,ref temp1,ref temp2,null);
		}
Example #10
0
 public CollisionWorld(IDispatcher dispatcher, IBroadphaseInterface pairCache, ICollisionConfiguration collisionConfiguration)
 {
     m_dispatcher1 = dispatcher;
     m_broadphasePairCache = pairCache;
     m_debugDrawer = null;
     m_forceUpdateAllAabbs = true;
     //メモリ確保系?
     //m_stackAlloc = collisionConfiguration->getStackAllocator();
     //m_dispatchInfo.m_stackAllocator = m_stackAlloc;
 }
Example #11
0
        public void update(float speed, float amplitude, IBroadphaseInterface pbi)
        {
            time    += speed;
            center.X = (float)(Math.Cos(time * 2.17f) * amplitude + Math.Sin(time) * amplitude / 2f);
            center.Y = (float)(Math.Cos(time * 1.38f) * amplitude + Math.Sin(time) * amplitude);
            center.Z = (float)(Math.Sin(time * 0.777f) * amplitude);
            IndexedVector3 temp1 = center - extents;
            IndexedVector3 temp2 = center + extents;

            pbi.SetAabb(proxy, ref temp1, ref temp2, null);
        }
 public override void UpdateAabbs()
 {
     //IndexedMatrix predictedTrans = IndexedMatrix.Identity;
     foreach (CollisionObject colObj in m_collisionObjects)
     {
         RigidBody body = RigidBody.Upcast(colObj);
         if (body != null)
         {
             if (body.IsActive() && (!body.IsStaticObject()))
             {
                 IndexedVector3 minAabb;
                 IndexedVector3 maxAabb;
                 colObj.GetCollisionShape().GetAabb(colObj.GetWorldTransform(), out minAabb, out maxAabb);
                 IBroadphaseInterface bp = GetBroadphase();
                 bp.SetAabb(body.GetBroadphaseHandle(), ref minAabb, ref maxAabb, m_dispatcher1);
             }
         }
     }
 }
Example #13
0
        /// <summary>
        /// 物理ワールドの初期化
        /// </summary>
        public void init(CollisionDispatcher d, IBroadphaseInterface b, IConstraintSolver s, ICollisionConfiguration c)
        {
            // Construct physics objects
            CoreDescription coreDesc = new CoreDescription();
            UserOutput      output   = new UserOutput();

            this.Core = new Core(coreDesc, output);

            Core core = this.Core;

            // デバッグ描画用の設定
            core.SetParameter(PhysicsParameter.VisualizationScale, 2.0f);
            core.SetParameter(PhysicsParameter.VisualizeForceFields, true);
            core.SetParameter(PhysicsParameter.VisualizeCollisionShapes, true);
            core.SetParameter(PhysicsParameter.VisualizeJointLimits, true);

            /*
             * core.SetParameter(PhysicsParameter.VisualizeJointLocalAxes, true);
             * //core.SetParameter(PhysicsParameter.VisualizeJointWorldAxes, true);
             *          core.SetParameter(PhysicsParameter.VisualizeClothMesh, true);
             *          core.SetParameter(PhysicsParameter.VisualizeFluidPosition, true);
             *          core.SetParameter(PhysicsParameter.VisualizeFluidEmitters, false); // Slows down rendering a bit too much
             *          core.SetParameter(PhysicsParameter.VisualizeSoftBodyMesh, true);
             */

            // シーンの設定
            SceneDescription sceneDesc = new SceneDescription()
            {
                //SimulationType = SimulationType.Hardware,
                Gravity            = new Vector3(0, -9.81f, 0),
                GroundPlaneEnabled = true
            };

            this.scene = core.CreateScene(sceneDesc);

            HardwareVersion ver     = Core.HardwareVersion;
            SimulationType  simType = this.scene.SimulationType;

            // Connect to the remote debugger if it's there
            //core.Foundation.RemoteDebugger.Connect("localhost");
        }
            public virtual void ProcessNode(int nodeSubPart, int broadphaseIndex)
            {
                IBroadphaseInterface childBroadphase = m_multiSap.GetBroadphaseArray()[broadphaseIndex];

                int containingBroadphaseIndex = -1;

                //already found?
                for (int i = 0; i < m_multiProxy.m_bridgeProxies.Count; i++)
                {
                    if (m_multiProxy.m_bridgeProxies[i].m_childBroadphase == childBroadphase)
                    {
                        containingBroadphaseIndex = i;
                        break;
                    }
                }
                if (containingBroadphaseIndex < 0)
                {
                    //add it
                    BroadphaseProxy childProxy = childBroadphase.CreateProxy(ref m_multiProxy.m_aabbMin, ref m_multiProxy.m_aabbMax, m_multiProxy.m_shapeType, m_multiProxy.m_clientObject, m_multiProxy.m_collisionFilterGroup, m_multiProxy.m_collisionFilterMask, m_dispatcher, m_multiProxy);
                    m_multiSap.AddToChildBroadphase(m_multiProxy, childProxy, childBroadphase);
                }
            }
Example #15
0
        public static void Benchmark(IBroadphaseInterface broadphaseInterface)
        {
            IList<BroadphaseBenchmarkObject> objects = new List<BroadphaseBenchmarkObject>();
            Stopwatch wallclock = new Stopwatch();
            /* Begin			*/
            for (int iexp = 0; iexp < s_experiments.Length; ++iexp)
            {
                BroadphaseBenchmarkExperiment experiment = DbvtBroadphase.s_experiments[iexp];
                int object_count = experiment.object_count;
                int update_count = (object_count * experiment.update_count) / 100;
                int spawn_count = (object_count * experiment.spawn_count) / 100;
                float speed = experiment.speed;
                float amplitude = experiment.amplitude;
                if (BulletGlobals.g_streamWriter != null)
                {
                    BulletGlobals.g_streamWriter.WriteLine("Experiment #{0} '{1}':", iexp, experiment.name);
                    BulletGlobals.g_streamWriter.WriteLine("\tObjects: {0}", object_count);
                    BulletGlobals.g_streamWriter.WriteLine("\tUpdate: {0}", update_count);
                    BulletGlobals.g_streamWriter.WriteLine("\tSpawn: {0}", spawn_count);
                    BulletGlobals.g_streamWriter.WriteLine("\tSpeed: {0}", speed);
                    BulletGlobals.g_streamWriter.WriteLine("\tAmplitude: {0}", amplitude);
                }
                //srand(180673);
                /* Create objects	*/
                wallclock.Reset();
                //objects.Capacity = object_count;
                for (int i = 0; i < object_count; ++i)
                {
                    BroadphaseBenchmarkObject po = new BroadphaseBenchmarkObject();
                    po.center.X = BroadphaseBenchmark.UnitRand() * 50;
                    po.center.Y = BroadphaseBenchmark.UnitRand() * 50;
                    po.center.Z = BroadphaseBenchmark.UnitRand() * 50;
                    po.extents.X = BroadphaseBenchmark.UnitRand() * 2 + 2;
                    po.extents.Y = BroadphaseBenchmark.UnitRand() * 2 + 2;
                    po.extents.Z = BroadphaseBenchmark.UnitRand() * 2 + 2;
                    po.time = BroadphaseBenchmark.UnitRand() * 2000;
                    po.proxy = broadphaseInterface.CreateProxy(po.center - po.extents, po.center + po.extents, BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE, po, CollisionFilterGroups.BDefaultGroup, CollisionFilterGroups.BDefaultGroup, null, null);
                    objects.Add(po);

                }
                BroadphaseBenchmark.OutputTime("\tInitialization", wallclock, 1);
                /* First update		*/
                wallclock.Reset();
                for (int i = 0; i < objects.Count; ++i)
                {
                    objects[i].update(speed, amplitude, broadphaseInterface);
                }
                BroadphaseBenchmark.OutputTime("\tFirst update", wallclock, 1);
                /* Updates			*/
                wallclock.Reset();
                for (int i = 0; i < experiment.iterations; ++i)
                {
                    for (int j = 0; j < update_count; ++j)
                    {
                        objects[j].update(speed, amplitude, broadphaseInterface);
                    }
                    broadphaseInterface.CalculateOverlappingPairs(null);
                }
                BroadphaseBenchmark.OutputTime("\tUpdate", wallclock, (uint)experiment.iterations);
                /* Clean up			*/
                wallclock.Reset();
                for (int i = 0; i < objects.Count; ++i)
                {
                    broadphaseInterface.DestroyProxy(objects[i].proxy, null);
                    objects[i] = null;
                }
                objects.Clear();
                BroadphaseBenchmark.OutputTime("\tRelease", wallclock, 1);
            }
        }
 public ContinuousDynamicsWorld(IDispatcher dispatcher, IBroadphaseInterface pairCache, IConstraintSolver constraintSolver, ICollisionConfiguration collisionConfiguration)
     : base(dispatcher, pairCache, constraintSolver, collisionConfiguration)
 {
 }
Example #17
0
        //this constructor doesn't own the dispatcher and paircache/broadphase
        public CollisionWorld(IDispatcher dispatcher, IBroadphaseInterface broadphasePairCache, ICollisionConfiguration collisionConfiguration)
        {
            m_dispatcher1 = dispatcher;
            m_broadphasePairCache = broadphasePairCache;
            m_collisionObjects = new ObjectArray<CollisionObject>();
            m_dispatchInfo = new DispatcherInfo();
            m_forceUpdateAllAabbs = true;
            WorldSettings.Params = new WorldData.ParamData();
            WorldSettings.Params.VoronoiSimplexSolverPool = new PooledType<VoronoiSimplexSolver>();
            WorldSettings.Params.SubSimplexConvexCastPool = new PooledType<SubSimplexConvexCast>();
            WorldSettings.Params.ManifoldPointPool = new PooledType<ManifoldPoint>();
            WorldSettings.Params.CastResultPool = new PooledType<CastResult>();
            WorldSettings.Params.SphereShapePool = new PooledType<SphereShape>();
            WorldSettings.Params.DbvtNodePool = new PooledType<DbvtNode>();
            WorldSettings.Params.SingleRayCallbackPool = new PooledType<SingleRayCallback>();
            WorldSettings.Params.SubSimplexClosestResultPool = new PooledType<SubSimplexClosestResult>();
            WorldSettings.Params.GjkPairDetectorPool = new PooledType<GjkPairDetector>();
            WorldSettings.Params.DbvtTreeColliderPool = new PooledType<DbvtTreeCollider>();
            WorldSettings.Params.SingleSweepCallbackPool = new PooledType<SingleSweepCallback>();
            WorldSettings.Params.BroadphaseRayTesterPool = new PooledType<BroadphaseRayTester>();
            WorldSettings.Params.ClosestNotMeConvexResultCallbackPool = new PooledType<ClosestNotMeConvexResultCallback>();
            WorldSettings.Params.GjkEpaPenetrationDepthSolverPool = new PooledType<GjkEpaPenetrationDepthSolver>();
            WorldSettings.Params.ContinuousConvexCollisionPool = new PooledType<ContinuousConvexCollision>();
            WorldSettings.Params.DbvtStackDataBlockPool = new PooledType<DbvtStackDataBlock>();

            WorldSettings.Params.BoxBoxCollisionAlgorithmPool = new PooledType<BoxBoxCollisionAlgorithm>();
            WorldSettings.Params.CompoundCollisionAlgorithmPool = new PooledType<CompoundCollisionAlgorithm>();
            WorldSettings.Params.ConvexConcaveCollisionAlgorithmPool = new PooledType<ConvexConcaveCollisionAlgorithm>();
            WorldSettings.Params.ConvexConvexAlgorithmPool = new PooledType<ConvexConvexAlgorithm>();
            WorldSettings.Params.ConvexPlaneAlgorithmPool = new PooledType<ConvexPlaneCollisionAlgorithm>();
            WorldSettings.Params.SphereBoxCollisionAlgorithmPool = new PooledType<SphereBoxCollisionAlgorithm>();
            WorldSettings.Params.SphereSphereCollisionAlgorithmPool = new PooledType<SphereSphereCollisionAlgorithm>();
            WorldSettings.Params.SphereTriangleCollisionAlgorithmPool = new PooledType<SphereTriangleCollisionAlgorithm>();
            WorldSettings.Params.GImpactCollisionAlgorithmPool = new PooledType<GImpactCollisionAlgorithm>();
            WorldSettings.Params.GjkEpaSolver2MinkowskiDiffPool = new PooledType<GjkEpaSolver2MinkowskiDiff>();
            WorldSettings.Params.PersistentManifoldPool = new PooledType<PersistentManifold>();
            WorldSettings.Params.ManifoldResultPool = new PooledType<ManifoldResult>();
            WorldSettings.Params.GJKPool = new PooledType<GJK>();
            WorldSettings.Params.GIM_ShapeRetrieverPool = new PooledType<GIM_ShapeRetriever>();
            WorldSettings.Params.TriangleShapePool = new PooledType<TriangleShape>();
            WorldSettings.Params.SphereTriangleDetectorPool = new PooledType<SphereTriangleDetector>();
            WorldSettings.Params.CompoundLeafCallbackPool = new PooledType<CompoundLeafCallback>();
            WorldSettings.Params.GjkConvexCastPool = new PooledType<GjkConvexCast>();
            WorldSettings.Params.LocalTriangleSphereCastCallbackPool = new PooledType<LocalTriangleSphereCastCallback>();
            WorldSettings.Params.BridgeTriangleRaycastCallbackPool = new PooledType<BridgeTriangleRaycastCallback>();
            WorldSettings.Params.BridgeTriangleConcaveRaycastCallbackPool = new PooledType<BridgeTriangleConcaveRaycastCallback>();
            WorldSettings.Params.BridgeTriangleConvexcastCallbackPool = new PooledType<BridgeTriangleConvexcastCallback>();
            WorldSettings.Params.MyNodeOverlapCallbackPool = new PooledType<MyNodeOverlapCallback>();
            WorldSettings.Params.ClosestRayResultCallbackPool = new PooledType<ClosestRayResultCallback>();
            WorldSettings.Params.DebugDrawcallbackPool = new PooledType<BulletXNA.DebugDrawcallback>();
            
        }
Example #18
0
        public void AddToChildBroadphase(MultiSapProxy parentMultiSapProxy, BroadphaseProxy childProxy, IBroadphaseInterface childBroadphase)
        {
	        BridgeProxy bridgeProxyRef = new BridgeProxy();
	        bridgeProxyRef.m_childProxy = childProxy;
	        bridgeProxyRef.m_childBroadphase = childBroadphase;
	        parentMultiSapProxy.m_bridgeProxies.Add(bridgeProxyRef);
        }
        public void AddToChildBroadphase(MultiSapProxy parentMultiSapProxy, BroadphaseProxy childProxy, IBroadphaseInterface childBroadphase)
        {
            BridgeProxy bridgeProxyRef = new BridgeProxy();

            bridgeProxyRef.m_childProxy      = childProxy;
            bridgeProxyRef.m_childBroadphase = childBroadphase;
            parentMultiSapProxy.m_bridgeProxies.Add(bridgeProxyRef);
        }
Example #20
0
 public void SetBroadphase(IBroadphaseInterface pairCache)
 {
     m_broadphasePairCache = pairCache;
 }
Example #21
0
        public static void Benchmark(IBroadphaseInterface broadphaseInterface)
        {
            IList <BroadphaseBenchmarkObject> objects = new List <BroadphaseBenchmarkObject>();
            Stopwatch wallclock = new Stopwatch();

            /* Begin			*/
            for (int iexp = 0; iexp < s_experiments.Length; ++iexp)
            {
                BroadphaseBenchmarkExperiment experiment = DbvtBroadphase.s_experiments[iexp];
                int   object_count = experiment.object_count;
                int   update_count = (object_count * experiment.update_count) / 100;
                int   spawn_count  = (object_count * experiment.spawn_count) / 100;
                float speed        = experiment.speed;
                float amplitude    = experiment.amplitude;
                if (BulletGlobals.g_streamWriter != null)
                {
                    BulletGlobals.g_streamWriter.WriteLine("Experiment #{0} '{1}':", iexp, experiment.name);
                    BulletGlobals.g_streamWriter.WriteLine("\tObjects: {0}", object_count);
                    BulletGlobals.g_streamWriter.WriteLine("\tUpdate: {0}", update_count);
                    BulletGlobals.g_streamWriter.WriteLine("\tSpawn: {0}", spawn_count);
                    BulletGlobals.g_streamWriter.WriteLine("\tSpeed: {0}", speed);
                    BulletGlobals.g_streamWriter.WriteLine("\tAmplitude: {0}", amplitude);
                }
                //srand(180673);
                /* Create objects	*/
                wallclock.Reset();
                //objects.Capacity = object_count;
                for (int i = 0; i < object_count; ++i)
                {
                    BroadphaseBenchmarkObject po = new BroadphaseBenchmarkObject();
                    po.center.X  = BroadphaseBenchmark.UnitRand() * 50;
                    po.center.Y  = BroadphaseBenchmark.UnitRand() * 50;
                    po.center.Z  = BroadphaseBenchmark.UnitRand() * 50;
                    po.extents.X = BroadphaseBenchmark.UnitRand() * 2 + 2;
                    po.extents.Y = BroadphaseBenchmark.UnitRand() * 2 + 2;
                    po.extents.Z = BroadphaseBenchmark.UnitRand() * 2 + 2;
                    po.time      = BroadphaseBenchmark.UnitRand() * 2000;
                    po.proxy     = broadphaseInterface.CreateProxy(po.center - po.extents, po.center + po.extents, BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE, po, CollisionFilterGroups.DefaultFilter, CollisionFilterGroups.DefaultFilter, null, null);
                    objects.Add(po);
                }
                BroadphaseBenchmark.OutputTime("\tInitialization", wallclock, 1);
                /* First update		*/
                wallclock.Reset();
                for (int i = 0; i < objects.Count; ++i)
                {
                    objects[i].update(speed, amplitude, broadphaseInterface);
                }
                BroadphaseBenchmark.OutputTime("\tFirst update", wallclock, 1);
                /* Updates			*/
                wallclock.Reset();
                for (int i = 0; i < experiment.iterations; ++i)
                {
                    for (int j = 0; j < update_count; ++j)
                    {
                        objects[j].update(speed, amplitude, broadphaseInterface);
                    }
                    broadphaseInterface.CalculateOverlappingPairs(null);
                }
                BroadphaseBenchmark.OutputTime("\tUpdate", wallclock, (uint)experiment.iterations);
                /* Clean up			*/
                wallclock.Reset();
                for (int i = 0; i < objects.Count; ++i)
                {
                    broadphaseInterface.DestroyProxy(objects[i].proxy, null);
                    objects[i] = null;
                }
                objects.Clear();
                BroadphaseBenchmark.OutputTime("\tRelease", wallclock, 1);
            }
        }