Closed satoshinm closed 7 years ago
hit_test_face
maps faces as:
dx | dy | dz | face |
---|---|---|---|
-1 | 0 | 0 | 0 |
+1 | 0 | 0 | 1 |
0 | 0 | -1 | 2 |
0 | 0 | +1 | 3 |
0 | +1 | 0 | 4 to 7 |
The top face has three different values depending on the rotation (for writing text on top of blocks from each side). Could add another:
dx | dy | dz | face |
---|---|---|---|
0 | -1 | 0 | 8 to 11 |
but elsewhere in the code will have to be updated (_gen_sign_buffer
and make_character_3d
). Maybe a new function, hit_test_normal, to simply get the normal vector instead of encoded face?
Now shows the normal, although not too fond of showing it as 0,+1,0
(or even 0+0)
, would prefer a single integer. The face encoding generated in hit_test_face
and consumed in _gen_sign_buffer
and make_character_3d
covers the first 4 side faces (0-3), but overloads 4-7 for top face plus a 90º rotation. Change it to split out rotation into its own variable, and use face=4 as top, 5 as bottom, for consistency throughout the game? It is important to get it correct here since this is in debug text.
Or, go all the way and keep four "faces" for the top (and bottom) + rotation?
Cube faces numbers:
# | face |
---|---|
0 | front |
1 | back |
2 | left |
3 | right |
4 | top |
5 | bottom |
Example of showing the info line on face 4, looking at the top of a block:
This necessarily changes some of the functions used by signs, since they were the only user of face hit testing (which side of the block the user was on. But for compatibility, the database and protocol still encode the face + rotation, and it is only possible to write on the sides or top of a block, same as before.
Get the face on which a block is being targeted, using
hit_test_face()
.Cube faces numbers:
Current problems:hit_test_face() excludes non-obstacles, so can't mine plantsmissing bottom face: 0,-1,0, can't mine from underneath a block, nor write on signs (intended by current design, writing on bottom of signs would be a new feature)