satoshinm / NetCraft

Web-based fork of fogleman/Craft ⛺
https://satoshinm.github.io/NetCraft/
MIT License
57 stars 13 forks source link

Consistent cube block face texture indices #116

Closed satoshinm closed 7 years ago

satoshinm commented 7 years ago

https://github.com/satoshinm/NetCraft/pull/112 hit_test_face used this ordering:

# face
0 front
1 back
2 left
3 right
4 top
5 bottom

but cube.c make_cube was already using something different:

    int wleft = blocks[w][0];
    int wright = blocks[w][1];
    int wtop = blocks[w][2];
    int wbottom = blocks[w][3];
    int wfront = blocks[w][4];
    int wback = blocks[w][5];

And OpenGL cube maps picked yet a different order:

https://www.khronos.org/opengl/wiki/Cubemap_Texture#Layered_Rendering

Layer number    Cubemap face
0   GL_TEXTURE_CUBE_MAP_POSITIVE_X
1   GL_TEXTURE_CUBE_MAP_NEGATIVE_X
2   GL_TEXTURE_CUBE_MAP_POSITIVE_Y
3   GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
4   GL_TEXTURE_CUBE_MAP_POSITIVE_Z
5   GL_TEXTURE_CUBE_MAP_NEGATIVE_Z

The app should at least use a convention consistently, doesn't matter what exactly, as long as it is consistent everywhere. hit_test_face returns the face number shown in the debug text, so that should match the texture faces defined in item.c at least. Probably break the sign face ordering, might as well split out face and rotation in the database and protocol while at it?

satoshinm commented 7 years ago

Changing the face ordering in item.c wouldn't break protocol and world save compatibility