示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sphere"></param>
        /// <param name="energyDissipation" the impact of the energy dissipation on the reflected velocity></param>
        public void Choc(MonoPhysicalSphere sphere, float energyDissipation = 0f)
        {
            //Debug.Log("choc: " + name);
            if (IsColliding(sphere) == false)
            {
                return;
            }

            //Debug.Log("Sphere plane collision on: " + name);
            //Debug.Log("Velocity Error: isVerlet: " + sphere.isVerlet + " " + sphere.ErrorVelocityOnTheGround());

            //sphere.Velocity = Vector3.Reflect(sphere.Velocity, Normal);

            if (IsSphereStaticOnPlane(sphere))
            {
                sphere.transform.position = CorrectedPosition(sphere);
                sphere.ApplyForce(-sphere.mass * Physics.gravity);
            }
            else // sphere is dynamic
            {
                sphere.transform.position = CorrectedPosition(sphere);
                InverseRelativeVelocity(sphere, Reflect(RelativeVelocity(sphere), energyDissipation));
                //sphere.Velocity = Reflect(RelativeVelocity(sphere), energyDissipation);
            }
        }