示例#1
0
文件: World.cs 项目: lochrist/UniVer
        public void Step(float dt)
        {
            recorder?.BeginFrame(dt);

            recorder?.BeginSolvingStep("beforeIntegrate", RecordinInfo.All());
            recorder?.EndSolvingStep();
            recorder?.BeginSolvingStep("integrate", RecordinInfo.BodyVertices());
            if (softIntegration)
            {
                SoftIntegrate(dt);
            }
            else
            {
                HardIntegrate(dt);
            }
            recorder?.EndSolvingStep();

            var stepCoef = 1.0f / numIterations;

            for (var i = 0; i < numIterations; ++i)
            {
                recorder?.BeginSolvingStep("constrain_solve_" + i, RecordinInfo.BodyVertices());
                Solve(dt, stepCoef);
                recorder?.EndSolvingStep();

                recorder?.BeginSolvingStep("boundingbox_" + i, RecordinInfo.BodyData());
                UpdateBoundingBox(dt);
                recorder?.EndSolvingStep();

                if (enableCollision)
                {
                    recorder?.BeginSolvingStep("collision_" + i, RecordinInfo.BodyVertices());
                    CollisionDetection(dt);
                    recorder?.EndSolvingStep();
                }
            }

            recorder?.BeginSolvingStep("boundsChecking", RecordinInfo.BodyVertices());
            BoundsChecking();
            recorder?.EndSolvingStep();

            recorder?.EndFrame();
            ++frame;
        }