Exemple #1
0
        protected override void OnUpdate()
        {
            // Note: this is only for rendering, not affecting the physics simulation
            // So float operations can be used here, because it's not required to be deterministic
            sfloat timeAhead = (sfloat)(Time.ElapsedTime - m_RecordMostRecentFixedTime.MostRecentElapsedTime);
            sfloat timeStep  = (sfloat)m_RecordMostRecentFixedTime.MostRecentDeltaTime;

            if (timeAhead <= sfloat.Zero || timeStep == sfloat.Zero)
            {
                return;
            }
            sfloat normalizedTimeAhead = math.clamp(timeAhead / timeStep, sfloat.Zero, sfloat.One);

            Dependency = JobHandle.CombineDependencies(Dependency, m_InputDependency);

            Dependency = new SmoothMotionJob
            {
                TranslationType               = GetComponentTypeHandle <Translation>(true),
                RotationType                  = GetComponentTypeHandle <Rotation>(true),
                NonUniformScaleType           = GetComponentTypeHandle <NonUniformScale>(true),
                ScaleType                     = GetComponentTypeHandle <Scale>(true),
                CompositeScaleType            = GetComponentTypeHandle <CompositeScale>(true),
                PhysicsMassType               = GetComponentTypeHandle <PhysicsMass>(true),
                InterpolationBufferType       = GetComponentTypeHandle <PhysicsGraphicalInterpolationBuffer>(true),
                PhysicsGraphicalSmoothingType = GetComponentTypeHandle <PhysicsGraphicalSmoothing>(),
                LocalToWorldType              = GetComponentTypeHandle <LocalToWorld>(),
                TimeAhead                     = timeAhead,
                NormalizedTimeAhead           = normalizedTimeAhead
            }.ScheduleParallel(SmoothedDynamicBodiesGroup, 1, Dependency);

            // Combine implicit output dependency with user one
            m_OutputDependency = Dependency;

            // TODO: do we need to be able to inject this system's job handle as a dependency into the transform systems?

            // Invalidate input dependency since it's been used by now
            m_InputDependency = default;
        }
        protected override void OnUpdate()
        {
            var timeAhead = (float)(Time.ElapsedTime - m_RecordMostRecentFixedTime.MostRecentElapsedTime);
            var timeStep  = (float)m_RecordMostRecentFixedTime.MostRecentDeltaTime;

            if (timeAhead <= 0f || timeStep == 0f)
            {
                return;
            }
            var normalizedTimeAhead = math.clamp(timeAhead / timeStep, 0f, 1f);

            Dependency = JobHandle.CombineDependencies(Dependency, m_InputDependency);

            Dependency = new SmoothMotionJob
            {
                TranslationType               = GetComponentTypeHandle <Translation>(true),
                RotationType                  = GetComponentTypeHandle <Rotation>(true),
                NonUniformScaleType           = GetComponentTypeHandle <NonUniformScale>(true),
                ScaleType                     = GetComponentTypeHandle <Scale>(true),
                CompositeScaleType            = GetComponentTypeHandle <CompositeScale>(true),
                PhysicsMassType               = GetComponentTypeHandle <PhysicsMass>(true),
                InterpolationBufferType       = GetComponentTypeHandle <PhysicsGraphicalInterpolationBuffer>(true),
                PhysicsGraphicalSmoothingType = GetComponentTypeHandle <PhysicsGraphicalSmoothing>(),
                LocalToWorldType              = GetComponentTypeHandle <LocalToWorld>(),
                TimeAhead                     = timeAhead,
                NormalizedTimeAhead           = normalizedTimeAhead
            }.ScheduleParallel(SmoothedDynamicBodiesGroup, 1, Dependency);

            // Combine implicit output dependency with user one
            m_OutputDependency = Dependency;

            // TODO: do we need to be able to inject this system's job handle as a dependency into the transform systems?

            // Invalidate input dependency since it's been used by now
            m_InputDependency = default;
        }