Exemple #1
0
        private void CheckParticleEdge_F2D(
            ref List <Particle.CCDDebugInfo> ccds,
            Particle particle,
            Particle origin, Particle neighbor,
            ref List <CollisionSubframeBuffer> collisionBuffer, double timeCoefficientPrediction,
            CollisionSubframeBuffer subframeToAdd
            )
        {
            // swept collision for body
            LineSegment edge     = new LineSegment(origin.x, neighbor.x);
            LineSegment edgeNext = new LineSegment(edge.start + origin.v * timeCoefficientPrediction, edge.end + neighbor.v * timeCoefficientPrediction);

            EdgePointCCDSolver.SolverInput solverInput = new EdgePointCCDSolver.SolverInput(edge, edgeNext, particle.x, particle.x);
            double?ccdCollisionTime = EdgePointCCDSolver.Solve(solverInput);

            if (ccdCollisionTime != null)
            {
                Particle.CCDDebugInfo   ccd     = GenerateDebugInfo(solverInput, ccdCollisionTime.Value);
                CollisionSubframeBuffer contact =
                    GenerateContact_ImpulseConservation_F2D(
                        particle, origin, neighbor, ccd, ccdCollisionTime.Value, timeCoefficientPrediction,
                        subframeToAdd
                        );
                if (contact != null)
                {
                    collisionBuffer.Add(contact);
                }
                ccds.Add(ccd);

                if (LsmBody.pauseOnBodyBodyCollision)
                {
                    Testbed.Paused = true;
                }
            }
        }
Exemple #2
0
 // DEBUG
 Particle.CCDDebugInfo GenerateDebugInfo(EdgePointCCDSolver.SolverInput solverInput, double time)
 {
     Particle.CCDDebugInfo ccd = new Particle.CCDDebugInfo(
         solverInput.currentPoint + (solverInput.nextPoint - solverInput.currentPoint) * time,
         new LineSegment(
             solverInput.currentEdge.start + (solverInput.nextEdge.start - solverInput.currentEdge.start) * time,
             solverInput.currentEdge.end + (solverInput.nextEdge.end - solverInput.currentEdge.end) * time
         )
     );
     return ccd;
 }