Exemplo n.º 1
0
            public void Execute(ref VehiclePathing p, ref VehicleTargetPosition pos, [ReadOnly] ref VehiclePhysicsState physicsState)
            {
                var rs = RoadSections[p.RoadIndex];

                float3 c0 = CatmullRom.GetPosition(rs.p0, rs.p1, rs.p2, rs.p3, p.curvePos);
                float3 c1 = CatmullRom.GetTangent(rs.p0, rs.p1, rs.p2, rs.p3, p.curvePos);
                float3 c2 = CatmullRom.GetConcavity(rs.p0, rs.p1, rs.p2, rs.p3, p.curvePos);

                float curveSpeed = length(c1);

                pos.IdealPosition = c0;
                pos.IdealSpeed    = p.speed;

                if (lengthsq(physicsState.Position - c0) < kMaxTetherSquared)
                {
                    p.curvePos += Constants.VehicleSpeedFudge / rs.arcLength * p.speed / curveSpeed * DeltaTimeSeconds;
                }
            }