Posted November 08, 2021 by AndrewNReinke
I would highly recommend that you check out the twitter thread for more info: https://twitter.com/AndrewNReinke/status/1457696732939100163
I wanted to write this up as a tech post to more accurately describe how I solved the collectables' collision volume bug.
So to start, I have both the boat and the collectable in their respective "model spaces". So if you were to compare their vertexes and see if they were colliding, by the actual positions and math, they'd always be colliding.
I then move them out using a matrix that stores their translation and rotation out into the world space, so typical stuff here.
The thing is, when doing the collision tests, I had two options from what I can tell.
A: Move the boat into the a given collectable's space and just do < or > than tests between the bottom left and upper right corner of the collectable's collision volume. This is achievable by using an inverse transform that was made by using the collectable's transform and multiplying the target object's current world vertexes by it (this being said, I tried this and it didn't work so idk what I did wrong but by the math / logic of math it should work so lmk if you have a solution to something like this for me to learn tnx) .
B: Take the collectable's collision volume's bottom left and upper right vertexes and subtract the given vertex that might be between them to then see if their signs match up or not. So in other words, something like:
vec3 = 3 floats that are named x, y, z;
vec3 L = CollectableCollisionLowerVert - TestVertex;
vec3 U = CollectableCollisionUpperVert - TestVertex;
bool CheckIfSigned(float Value)
{
return(Value < 0.0f);
}
if(CheckIfSigned(L.x) != CheckIfSigned(U.x) &&
CheckIfSigned(L.y) != CheckIfSigned(U.y) &&
CheckIfSigned(L.z) != CheckIfSigned(U.z)))
{
Colliding;
}
I chose B by the way as I liked the solution / never have solved a collision problem in this particular way before so it was more fun this way.
Let me know your thoughts on today's build please! I got all the timing stuff fixed so the game should run like butter (even ran on my 2.0ghz laptop eariler so it should be fine for you too I hope but if not report the bug asap to me so I can fix please). Thank you for reading and have a nice day :]