blini_plz

mzx ground clip notes

Jan 6th, 2019
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. 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
  2. Arg SP+0x24 is 26f
  3. you have to be moving along the XZ plane for the branch to be hit
  4. if the condition is met, the game jumps to function 80030274
  5. which does a collision check on the background elements
  6. depending on an argument
  7. in this case, it is passed a CollisionTestType of 0x1B, which corresponds to "check floors, walls, actor meshes"(edited)
  8. the fucky part is that sometimes the floor collision detection fails
  9. 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
  10. when it does fail, it seems to result in a situation where walls cannot be detected
  11. because the test point is still underneath the floor
  12.  
  13. sticking to floors happens at a change in position that's greater than -21
  14. ground clip happens at -26 (makes sense since our wall check is +26)
  15.  
  16. i wrote this test C# code to check(edited)
  17. int a = 0x4480c000-1;
  18. var bytes = BitConverter.GetBytes(a);
  19. float left = BitConverter.ToSingle(bytes, 0);
  20. float right = -1030;
  21.  
  22. Console.WriteLine(string.Format("{0} + {1} = {2}", left, right, left+right));
  23.  
  24. output 1030 + -1030 = -0.0001220703
  25.  
  26. 1030.000000000000 + -1030.000000000000000000 = -0.000122070300000000
  27.  
  28. float y = 1030f;
  29. short normY = 0x7FFF;
  30. short dist = -1030;
  31. float factor = 1f/32767;
  32.  
  33. float result = y;
  34. result *= factor*normY;
  35. result += dist;
  36. var rBytes = BitConverter.GetBytes(result);
  37. Console.WriteLine(string.Format("{0:X2}{1:X2}{2:X2}{3:X2}", rBytes[3], rBytes[2], rBytes[1], rBytes[0]));
  38. Console.WriteLine(result);
  39. that's my first attempt at an approximation of the rounding error
  40. written in C#
  41.  
  42. the rounding error only happens when I add
  43. result += dist
  44. without that addition
  45.  
  46. 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