//------------------------------------- // Collision Methods - Single Particle Colliders //------------------------------------- /// <summary> /// Separate 2 objects where at least one is a SingleParticle object (SphereCollider). /// </summary> private void SeparateParticleObjectWithSingleParticles(BaseCollider bc, SphereCollider sp, Vector3 currPoint, Vector3 projPoint, ColliderTypes collTypes) { if (collTypes == ColliderTypes.FirstRigidBody_SecondSingleParticle) { //ParticleObject po = bc.GetParticleObject(); //float[] c1 = this.ComputeParticlesCoefficients(po, currPoint); //float lambda1 = this.ComputeLambda(c1); Logger.Instance.DebugInfo("Updating FirstRigidBody_SecondSingleParticle object", "COLLISION"); // Update the dynamic object //for (int i = 0; i < 4; i++) //{ // po.particles[i].position = po.particles[i].position + (lambda1 * c1[i] * (projPoint - currPoint) * 0.5f) * po.particles[i].invMass; //} // Update also the single particle Vector3 newPos = sp.GetSingleParticlePosition() - ((projPoint - currPoint)) * 0.5f * sp.GetSingleParticleInvMass(); sp.ChangeSingleParticlePosition(newPos); } // if both are single particle objects else if (collTypes == ColliderTypes.BothSingleParticles) { // TODO: test SphereCollider sp1 = (SphereCollider)bc; Vector3 newPosSp1 = sp1.GetSingleParticlePosition() + ((projPoint - currPoint)) * sp1.GetSingleParticleInvMass(); sp1.ChangeSingleParticlePosition(newPosSp1); Vector3 newPosSp2 = sp.GetSingleParticlePosition() - ((projPoint - currPoint)) * sp.GetSingleParticleInvMass(); sp.ChangeSingleParticlePosition(newPosSp2); } }