Exemple #1
0
        /**
         * In the case of skinned cloth, we need to tell the animator controller to update the skeletal animation,
         * then grab the skinned vertex positions prior to starting the simulation steps for this frame.
         */
        public override void OnSolverStepBegin()
        {
            if (skinnedMeshRenderer == null)
            {
                // regular on step begin: transform fixed particles.
                base.OnSolverStepBegin();
            }
            else
            {
                // manually update animator (before particle physics):
                if (animatorController != null)
                {
                    if (solver.simulationOrder != ObiSolver.SimulationOrder.LateUpdate)
                    {
                        animatorController.UpdateAnimation();
                    }
                    else
                    {
                        animatorController.ResumeAutonomousUpdate();
                    }
                }

                // apply world space velocity:
                ApplyWorldSpaceVelocity();

                // grab skeleton bone transforms:
                GrabSkeletonBones();
            }
        }
Exemple #2
0
        public override void OnSolverStepBegin()
        {
            // apparently checking whether the actor is enabled or not doesn't take a despreciable amount of time.
            bool actorEnabled = this.enabled;

            // manually update animator (before particle physics):

            // TODO: update root bone here if animator is deactiavted.
            if (animatorController != null)
            {
                animatorController.UpdateAnimation();
            }

            Vector4[] simulationPosition = { Vector4.zero };

            // build local to simulation space transform:
            Matrix4x4 l2sTransform;

            if (Solver.simulateInLocalSpace)
            {
                l2sTransform = Solver.transform.worldToLocalMatrix * ActorLocalToWorldMatrix;
            }
            else
            {
                l2sTransform = ActorLocalToWorldMatrix;
            }

            //Matrix4x4 delta = Solver.transform.worldToLocalMatrix * Solver.LastTransform;

            ObiSkinConstraintBatch skinConstraints = SkinConstraints.GetFirstBatch();

            // transform fixed particles:
            for (int i = 0; i < particleIndices.Length; i++)
            {
                Vector3 solverSpaceBone = l2sTransform.MultiplyPoint3x4(transform.InverseTransformPoint(bones[i].position));

                if (!actorEnabled || invMasses[i] == 0)
                {
                    simulationPosition[0] = solverSpaceBone;
                    Oni.SetParticlePositions(solver.OniSolver, simulationPosition, 1, particleIndices[i]);
                }                /*else if (Solver.simulateInLocalSpace){
                                  *
                                  *     Oni.GetParticlePositions(solver.OniSolver,simulationPosition,1,particleIndices[i]);
                                  *     simulationPosition[0] = Vector3.Lerp(simulationPosition[0],delta.MultiplyPoint3x4(simulationPosition[0]),worldVelocityScale);
                                  *     Oni.SetParticlePositions(solver.OniSolver,simulationPosition,1,particleIndices[i]);
                                  *
                                  * }*/

                skinConstraints.skinPoints[i] = solverSpaceBone;
            }

            skinConstraints.PushDataToSolver(SkinConstraints);
        }
Exemple #3
0
        /**
         * In the case of skinned cloth, we need to tell the animator controller to update the skeletal animation,
         * then grab the skinned vertex positions prior to starting the simulation steps for this frame.
         */
        public override void OnSolverFrameBegin(bool fixedUpdate)
        {
            if (skinnedMeshRenderer == null)
            {
                // regular on frame begin: transform fixed particles.
                UpdateFixedParticles();
            }
            else
            {
                // manually update animator (before particle physics):
                if (animatorController != null && isActiveAndEnabled)
                {
                    animatorController.UpdateAnimation(fixedUpdate);
                }

                // grab skeleton bone transforms:
                UpdateBoneTransforms();
            }
        }