BEPUphysics.CollisionTests.CollisionAlgorithms.MPRToolbox.RefinePenetration C# (CSharp) 메소드

RefinePenetration() 공개 정적인 메소드

Incrementally refines the penetration depth and normal towards the local minimum.
public static RefinePenetration ( ConvexShape shapeA, ConvexShape shapeB, RigidTransform &localTransformB, float initialDepth, System.Vector3 &initialNormal, float &penetrationDepth, System.Vector3 &refinedNormal, System.Vector3 &position ) : void
shapeA BEPUphysics.CollisionShapes.ConvexShapes.ConvexShape First shape in the pair.
shapeB BEPUphysics.CollisionShapes.ConvexShapes.ConvexShape Second shape in the pair.
localTransformB BEPUutilities.RigidTransform Transformation of shape B relative to shape A.
initialDepth float Initial depth estimate.
initialNormal System.Vector3 Initial normal estimate.
penetrationDepth float Refined penetration depth.
refinedNormal System.Vector3 Refined normal.
position System.Vector3 Refined position.
리턴 void
        public static void RefinePenetration(ConvexShape shapeA, ConvexShape shapeB, ref RigidTransform localTransformB, float initialDepth, ref Vector3 initialNormal, out float penetrationDepth, out Vector3 refinedNormal, out Vector3 position)
        {
            //The local casting can optionally continue.  Eventually, it will converge to the local minimum.
            int optimizingCount = 0;
            refinedNormal = initialNormal;
            penetrationDepth = initialDepth;
            float candidateDepth;
            Vector3 candidateNormal;

            while (true)
            {

                MPRToolbox.LocalSurfaceCast(shapeA, shapeB, ref localTransformB, ref refinedNormal, out candidateDepth, out candidateNormal, out position);
                if (penetrationDepth - candidateDepth <= depthRefinementEpsilon ||
                    ++optimizingCount >= maximumDepthRefinementIterations)
                {
                    //If we've reached the end due to convergence, the normal will be extremely close to correct (if not 100% correct).
                    //The candidateDepth computed is the previous contact normal's depth.
                    //The reason why the previous normal is kept is that the last raycast computed the depth for that normal, not the new normal.
                    penetrationDepth = candidateDepth;
                    break;
                }

                penetrationDepth = candidateDepth;
                refinedNormal = candidateNormal;

            }
        }