using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace GuidewireSim
{
    public class CollisionSolvingStep_UnityVariant : CollisionSolvingStep
    {
        protected override void SolveCollisionConstraint(Vector3 spherePositionPrediction, CollisionPair collisionPair, int solverStep,
                                                         out Vector3 deltaPosition)
        {
            ContactPoint contactPoint = collisionPair.vesselCollider.GetContact(0);
            Vector3 otherPosition = contactPoint.otherCollider.transform.position;

            Vector3 closestSurfacePoint = contactPoint.point;
            // Vector3 normalVector = (closestSurfacePoint - otherPosition).normalized;
            Vector3 normalVector = contactPoint.normal;

            if (solverStep == 0)
            {
                DrawCollisionInformation(spherePositionPrediction, contactPoint, otherPosition, closestSurfacePoint, normalVector);
            }

            deltaPosition = CalculateDeltaPosition(spherePositionPrediction, closestSurfacePoint, normalVector);
        }
    }
}