Example #1
0
        private void PreStepForward()
        {
            bool savePreFirstTimeStep = Application.isEditor &&
                                        SavePreFirstStep &&
                                        SavePreFirstStepPath != string.Empty &&
                                        m_simulation.getTimeStamp() == 0.0;

            if (savePreFirstTimeStep)
            {
                var saveSuccess = SaveToNativeFile(SavePreFirstStepPath);
                if (saveSuccess)
                {
                    Debug.Log(Utils.GUI.AddColorTag("Successfully wrote initial state to: ", Color.green) +
                              new FileInfo(SavePreFirstStepPath).FullName);
                }
            }

            agx.Timer timer = null;
            if (DisplayStatistics)
            {
                timer = new agx.Timer(true);
            }

            if (TrackMemoryAllocations)
            {
                MemoryAllocations.Snap(MemoryAllocations.Section.Begin);
            }

            if (StepCallbacks.PreStepForward != null)
            {
                StepCallbacks.PreStepForward.Invoke();
            }

            if (TrackMemoryAllocations)
            {
                MemoryAllocations.Snap(MemoryAllocations.Section.PreStepForward);
            }

            if (StepCallbacks.PreSynchronizeTransforms != null)
            {
                StepCallbacks.PreSynchronizeTransforms.Invoke();
            }

            if (TrackMemoryAllocations)
            {
                MemoryAllocations.Snap(MemoryAllocations.Section.PreSynchronizeTransforms);
            }

            if (timer != null)
            {
                timer.stop();
            }
        }
Example #2
0
        private void PostStepForward()
        {
            agx.Timer timer = null;
            if (DisplayStatistics)
            {
                timer = new agx.Timer(true);
            }

            if (TrackMemoryAllocations)
            {
                MemoryAllocations.Snap(MemoryAllocations.Section.StepForward);
            }

            if (StepCallbacks.PostSynchronizeTransforms != null)
            {
                StepCallbacks.PostSynchronizeTransforms.Invoke();
            }

            if (TrackMemoryAllocations)
            {
                MemoryAllocations.Snap(MemoryAllocations.Section.PostSynchronizeTransforms);
            }

            if (StepCallbacks.PostStepForward != null)
            {
                StepCallbacks.PostStepForward.Invoke();
            }

            if (TrackMemoryAllocations)
            {
                MemoryAllocations.Snap(MemoryAllocations.Section.PostStepForward);
            }

            Rendering.DebugRenderManager.OnActiveSimulationPostStep(m_simulation);

            if (timer != null)
            {
                timer.stop();
                m_statisticsWindowData.ManagedStepForward = Convert.ToSingle(timer.getTime());
            }
        }
        protected void FixedUpdate()
        {
            if (!NativeHandler.Instance.HasValidLicense)
            {
                return;
            }

            if (m_simulation != null)
            {
                bool savePreFirstTimeStep = Application.isEditor &&
                                            SavePreFirstStep &&
                                            SavePreFirstStepPath != string.Empty &&
                                            m_simulation.getTimeStamp() == 0.0;
                if (savePreFirstTimeStep)
                {
                    var saveSuccess = SaveToNativeFile(SavePreFirstStepPath);
                    if (saveSuccess)
                    {
                        Debug.Log("Successfully wrote initial state to: " + SavePreFirstStepPath);
                    }
                }

                agx.Timer timer = null;
                if (DisplayStatistics)
                {
                    timer = new agx.Timer(true);
                }

                MemoryAllocations.Snap(MemoryAllocations.Section.Begin);

                StepCallbacks.PreStepForward?.Invoke();

                MemoryAllocations.Snap(MemoryAllocations.Section.PreStepForward);

                StepCallbacks.PreSynchronizeTransforms?.Invoke();

                MemoryAllocations.Snap(MemoryAllocations.Section.PreSynchronizeTransforms);

                if (timer != null)
                {
                    timer.stop();
                }

                m_simulation.stepForward();

                if (timer != null)
                {
                    timer.start();
                }

                MemoryAllocations.Snap(MemoryAllocations.Section.StepForward);

                StepCallbacks.PostSynchronizeTransforms?.Invoke();

                MemoryAllocations.Snap(MemoryAllocations.Section.PostSynchronizeTransforms);

                StepCallbacks.PostStepForward?.Invoke();

                MemoryAllocations.Snap(MemoryAllocations.Section.PostStepForward);

                Rendering.DebugRenderManager.OnActiveSimulationPostStep(m_simulation);

                if (timer != null)
                {
                    timer.stop();
                    m_statisticsWindowData.ManagedStepForward = Convert.ToSingle(timer.getTime());
                }
            }
        }