Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- what i've discovered so far is that there's a branch in the collision code that is only hit if you're travelling past a certain speed along the Y axis F9A8 //fcond = F6 < 5f; change in Y + Arg SP+0x24 < 5f
- Arg SP+0x24 is 26f
- you have to be moving along the XZ plane for the branch to be hit
- if the condition is met, the game jumps to function 80030274
- which does a collision check on the background elements
- depending on an argument
- in this case, it is passed a CollisionTestType of 0x1B, which corresponds to "check floors, walls, actor meshes"(edited)
- the fucky part is that sometimes the floor collision detection fails
- when it doesn't fail, it triggers the "sticky floors" condition, where the game detects a floor surface, and sets that as being what wall Link has collided into
- when it does fail, it seems to result in a situation where walls cannot be detected
- because the test point is still underneath the floor
- sticking to floors happens at a change in position that's greater than -21
- ground clip happens at -26 (makes sense since our wall check is +26)
- i wrote this test C# code to check(edited)
- int a = 0x4480c000-1;
- var bytes = BitConverter.GetBytes(a);
- float left = BitConverter.ToSingle(bytes, 0);
- float right = -1030;
- Console.WriteLine(string.Format("{0} + {1} = {2}", left, right, left+right));
- output 1030 + -1030 = -0.0001220703
- 1030.000000000000 + -1030.000000000000000000 = -0.000122070300000000
- float y = 1030f;
- short normY = 0x7FFF;
- short dist = -1030;
- float factor = 1f/32767;
- float result = y;
- result *= factor*normY;
- result += dist;
- var rBytes = BitConverter.GetBytes(result);
- Console.WriteLine(string.Format("{0:X2}{1:X2}{2:X2}{3:X2}", rBytes[3], rBytes[2], rBytes[1], rBytes[0]));
- Console.WriteLine(result);
- that's my first attempt at an approximation of the rounding error
- written in C#
- the rounding error only happens when I add
- result += dist
- without that addition
- I believe the reality is that the computation is being done on a larger floating point register
Advertisement
Add Comment
Please, Sign In to add comment