Beispiel #1
0
        // Clone the world
        public DynamicsWorld Clone()
        {
            DynamicsWorld clone = new DynamicsWorld
            {
                m_MotionDatas       = new NativeArray <MotionData>(m_MotionDatas.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory),
                m_MotionVelocities  = new NativeArray <MotionVelocity>(m_MotionVelocities.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory),
                m_NumMotions        = m_NumMotions,
                m_Joints            = new NativeArray <Joint>(m_Joints.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory),
                m_NumJoints         = m_NumJoints,
                EntityJointIndexMap = new NativeHashMap <Entity, int>(m_Joints.Length, Allocator.Persistent),
            };

            clone.m_MotionDatas.CopyFrom(m_MotionDatas);
            clone.m_MotionVelocities.CopyFrom(m_MotionVelocities);
            clone.m_Joints.CopyFrom(m_Joints);
            clone.UpdateJointIndexMap();
            return(clone);
        }
Beispiel #2
0
 // Schedule a job to integrate the world's motions forward by the given time step.
 internal static JobHandle ScheduleIntegrateJobs(ref DynamicsWorld world, sfloat timeStep, JobHandle inputDeps, bool multiThreaded = true)
 {
     if (!multiThreaded)
     {
         var job = new IntegrateMotionsJob
         {
             MotionDatas      = world.MotionDatas,
             MotionVelocities = world.MotionVelocities,
             TimeStep         = timeStep
         };
         return(job.Schedule(inputDeps));
     }
     else
     {
         var job = new ParallelIntegrateMotionsJob
         {
             MotionDatas      = world.MotionDatas,
             MotionVelocities = world.MotionVelocities,
             TimeStep         = timeStep
         };
         return(job.Schedule(world.NumMotions, 64, inputDeps));
     }
 }
Beispiel #3
0
 // Construct a world with the given number of uninitialized bodies and joints
 public PhysicsWorld(int numStaticBodies, int numDynamicBodies, int numJoints)
 {
     CollisionWorld = new CollisionWorld(numStaticBodies, numDynamicBodies);
     DynamicsWorld  = new DynamicsWorld(numDynamicBodies, numJoints);
 }