public void Reset(ref PhysicsWorld world, UnityEngine.Camera camera = null)
        {
            int numDynamicBodies = world.NumDynamicBodies;

            if (!InputVelocities.IsCreated || InputVelocities.Length < numDynamicBodies)
            {
                if (InputVelocities.IsCreated)
                {
                    InputVelocities.Dispose();
                }
                InputVelocities = new NativeArray <Velocity>(numDynamicBodies, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
            }

            if (VisualDebuggerEnabled)
            {
                camera = (camera == null ? UnityEngine.Camera.main : camera);
                Camera = new HavokSimulation.Camera
                {
                    From        = camera.transform.position,
                    To          = camera.transform.position + camera.transform.forward,
                    Up          = camera.transform.up,
                    NearPlane   = camera.nearClipPlane,
                    FarPlane    = camera.farClipPlane,
                    FieldOfView = camera.fieldOfView
                };
            }
        }
        public SimulationContext(HavokConfiguration config)
        {
            // Unlock the plugin if it hasn't already been done.
            // If it remains locked, the simulation will do nothing.
            Plugin.EnsureUnlocked();

            TimeStep        = default;
            InputVelocities = default;

            Camera = default;

            unsafe
            {
                // Allocate this at a fixed memory location. The plugin writes to it.
                StepContext = (HavokSimulation.StepContext *)UnsafeUtility.Malloc(sizeof(HavokSimulation.StepContext), 16, Allocator.Persistent);
                UnsafeUtility.MemClear(StepContext, sizeof(HavokSimulation.StepContext));

                VisualDebuggerEnabled = config.VisualDebugger.Enable != 0;
                WorldIndex            = Plugin.HP_AllocateWorld(ref config, StepContext);
                m_WorldAllocated      = true;
            }

            HaveStaticBodiesChanged = default;
            StaticBodiesSyncedOnce  = false;
        }
Exemple #3
0
 internal static extern void HP_StepVisualDebugger(int worldIndex, float timeStep, ref HavokSimulation.Camera camera);