Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rapid-cue-switch crash bug mitigation #201

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1850,6 +1850,9 @@ private void OnLocalTurnStart()
{
ResetTimer();
}

// sanitize old cue tip location data to prevent stale data from causing unintended effects.
localSpacePositionOfCueTipLastFrame = tableSurface.transform.InverseTransformPoint(cueTip.transform.position);
}

private void OnNewGameStarted()
Expand Down Expand Up @@ -3303,4 +3306,4 @@ private void PlayAudioClip(AudioClip clip)
mainSrc.PlayOneShot(clip);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ protected override void HitBallWithCue(Vector3 shotDirection, float velocity)

float a = jkPlane.GetDistanceToPoint(Q);
float b = Q.y - o.y;
float c = Mathf.Sqrt(Mathf.Pow(ballRadius, 2) - Mathf.Pow(a, 2) - Mathf.Pow(b, 2));
float c = Mathf.Sqrt(Mathf.Max(0,Mathf.Pow(ballRadius, 2) - Mathf.Pow(a, 2) - Mathf.Pow(b, 2)));

float adj = Mathf.Sqrt(Mathf.Pow(q.x, 2) + Mathf.Pow(q.z, 2));
float opp = q.y;
Expand All @@ -352,7 +352,7 @@ protected override void HitBallWithCue(Vector3 shotDirection, float velocity)

// https://billiards.colostate.edu/physics_articles/Alciatore_pool_physics_article.pdf
float alpha = -Mathf.Atan(
(5f / 2f * a / ballRadius * Mathf.Sqrt(1f - Mathf.Pow(a / ballRadius, 2))) /
(5f / 2f * a / ballRadius * Mathf.Sqrt(Mathf.Max(0,1f - Mathf.Pow(a / ballRadius, 2)))) /
(1 + MASS_OF_BALL / m_e + 5f / 2f * (1f - Mathf.Pow(a / ballRadius, 2)))
) * 180 / Mathf.PI;

Expand Down Expand Up @@ -1260,4 +1260,4 @@ private void TriggerPocketBall(int id)
));
}
}
}
}