Commit 4bb3aef7 authored by rv3Dcv's avatar rv3Dcv

Add collisionMargin

parent 742f6d7c
...@@ -14,7 +14,7 @@ namespace GuidewireSim ...@@ -14,7 +14,7 @@ namespace GuidewireSim
Vector3 initialPositionPrediction = new Vector3(); Vector3 initialPositionPrediction = new Vector3();
float sphereRadius = 5f; //!< The radius of a sphere of the guidewire. float sphereRadius = 5f; //!< The radius of a sphere of the guidewire.
float collisionMargin = 0.001f; /**< A margin by which a colliding element of the guidewire is set away from the object colliding with float collisionMargin = 0.01f; /**< A margin by which a colliding element of the guidewire is set away from the object colliding with
* in the direction of the normal. * in the direction of the normal.
* @note Without this margin, the colliding element of the guidewire (e.g. a sphere) is corrected such that * @note Without this margin, the colliding element of the guidewire (e.g. a sphere) is corrected such that
* its surface exactly touches the object colliding with, which results in the guidewire still * its surface exactly touches the object colliding with, which results in the guidewire still
...@@ -185,7 +185,7 @@ namespace GuidewireSim ...@@ -185,7 +185,7 @@ namespace GuidewireSim
Vector3 closestSurfacePoint, Vector3 normalVector) Vector3 closestSurfacePoint, Vector3 normalVector)
{ {
Debug.DrawLine(closestSurfacePoint, closestSurfacePoint + 20f * normalVector, Color.blue, 2f); Debug.DrawLine(closestSurfacePoint, closestSurfacePoint + 20f * normalVector, Color.blue, 2f);
Debug.DrawLine(otherPosition, spherePositionPrediction, Color.yellow, 2f); // Debug.DrawLine(otherPosition, spherePositionPrediction, Color.yellow, 2f);
DebugExtension.DrawPoint(spherePositionPrediction, Color.white); DebugExtension.DrawPoint(spherePositionPrediction, Color.white);
...@@ -195,7 +195,8 @@ namespace GuidewireSim ...@@ -195,7 +195,8 @@ namespace GuidewireSim
protected Vector3 CalculateDeltaPosition(Vector3 spherePositionPrediction, Vector3 closestSurfacePoint, Vector3 normalVector) protected Vector3 CalculateDeltaPosition(Vector3 spherePositionPrediction, Vector3 closestSurfacePoint, Vector3 normalVector)
{ {
return - (spherePositionPrediction - sphereRadius * normalVector - closestSurfacePoint); // return - (spherePositionPrediction - sphereRadius * normalVector - closestSurfacePoint);
return - (spherePositionPrediction - sphereRadius * normalVector - closestSurfacePoint - collisionMargin * normalVector);
} }
private void CorrectCollisionPredictions(int sphereIndex, Vector3[] spherePositionPredictions, int solverStep, int constraintSolverSteps) private void CorrectCollisionPredictions(int sphereIndex, Vector3[] spherePositionPredictions, int solverStep, int constraintSolverSteps)
......
...@@ -13,7 +13,8 @@ namespace GuidewireSim ...@@ -13,7 +13,8 @@ namespace GuidewireSim
Vector3 otherPosition = contactPoint.otherCollider.transform.position; Vector3 otherPosition = contactPoint.otherCollider.transform.position;
Vector3 closestSurfacePoint = contactPoint.point; Vector3 closestSurfacePoint = contactPoint.point;
Vector3 normalVector = (closestSurfacePoint - otherPosition).normalized; // Vector3 normalVector = (closestSurfacePoint - otherPosition).normalized;
Vector3 normalVector = contactPoint.normal;
if (solverStep == 0) if (solverStep == 0)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment