@@ -1000,14 +1000,14 @@ void TileRenderer::tesselateTorch(Tile* tile, const Vec3& pos, float a, float b)
1000
1000
constexpr float C_RATIO = 1 .0f / 256 .0f ;
1001
1001
constexpr float C_ONE_PIXEL = 1 .0f / 16 .0f ;
1002
1002
constexpr float C_HALF_TILE = 1 .0f / 2 .0f ;
1003
- constexpr float C_UNK_1 = 0 .375f ;
1003
+ constexpr float C_TOP_SKEW_RATIO = 0 .375f ;
1004
1004
1005
1005
int texture = tile->getTexture (Facing::DOWN);
1006
1006
1007
1007
if (m_textureOverride >= 0 )
1008
1008
texture = m_textureOverride;
1009
1009
1010
- // @TODO: Clean up a bit
1010
+ // @TODO: Clean up a bit more
1011
1011
1012
1012
float texX = float (16 * (texture % 16 ));
1013
1013
float texY = float (16 * (texture / 16 ));
@@ -1017,58 +1017,69 @@ void TileRenderer::tesselateTorch(Tile* tile, const Vec3& pos, float a, float b)
1017
1017
float texV_1 = (texY * C_RATIO) + 1 .0f / 32 .0f ;
1018
1018
float texV_2 = (texY + 15 .99f ) * C_RATIO;
1019
1019
1020
- float x1 = pos.x + 0 .5f , z1 = pos.z + 0 .5f ;
1021
- float z2 = z1 + (float )(b * C_UNK_1);
1020
+ float x1 = pos.x + C_HALF_TILE, z1 = pos.z + C_HALF_TILE;
1021
+ float x2 = x1 + (float )(a * C_TOP_SKEW_RATIO);
1022
+ float z2 = z1 + (float )(b * C_TOP_SKEW_RATIO);
1022
1023
1023
1024
Tesselator& t = Tesselator::instance;
1025
+
1026
+ // Top side (flame)
1027
+ float x_1 = x2 - C_ONE_PIXEL;
1028
+ float x_2 = x2 + C_ONE_PIXEL;
1029
+ float z_1 = z2 - C_ONE_PIXEL;
1030
+ float z_2 = z2 + C_ONE_PIXEL;
1024
1031
1025
- float x_1 = (x1 + (a * C_UNK_1)) - C_ONE_PIXEL;
1026
- float x_2 = (x1 + (a * C_UNK_1)) + C_ONE_PIXEL;
1032
+ // Edges (close by)
1027
1033
float x_3 = x1 - C_ONE_PIXEL;
1028
1034
float x_4 = x1 + C_ONE_PIXEL;
1029
- float x_5 = x1 - C_HALF_TILE;
1035
+ float z_5 = z1 - C_ONE_PIXEL;
1036
+ float z_6 = z1 + C_ONE_PIXEL;
1037
+
1038
+ // Far edges
1039
+ float x_5 = x1 - C_HALF_TILE;
1030
1040
float x_6 = x1 + C_HALF_TILE;
1031
- float x_7 = x_6 + a;
1041
+ float z_3 = z1 - C_HALF_TILE;
1042
+ float z_4 = z1 + C_HALF_TILE;
1043
+
1044
+ float x_7 = x_6 + a; // Skewed bottom
1032
1045
float x_8 = x_3 + a;
1033
1046
float x_9 = x_4 + a;
1034
1047
float x_0 = x_5 + a;
1035
-
1036
- float y_1 = pos.y + C_ONE_PIXEL * 10 .0f ;
1037
- float y_2 = pos.y + 1 .0f ;
1038
- float y_3 = pos.y + 0 .0f ;
1039
-
1040
- float z_1 = z2 - C_ONE_PIXEL;
1041
- float z_2 = z2 + C_ONE_PIXEL;
1042
- float z_3 = z1 - 0 .5f ;
1043
- float z_4 = z1 + 0 .5f ;
1044
- float z_5 = z1 - C_ONE_PIXEL;
1045
- float z_6 = z1 + C_ONE_PIXEL;
1046
1048
float z_7 = z_3 + b;
1047
1049
float z_8 = z_4 + b;
1048
1050
float z_9 = z_5 + b;
1049
1051
float z_0 = z_6 + b;
1050
1052
1053
+ float y_1 = pos.y + C_ONE_PIXEL * 10 .0f ; // Torch height
1054
+ float y_2 = pos.y + 1 .0f ; // Top
1055
+ float y_3 = pos.y + 0 .0f ; // Bottom
1056
+
1051
1057
float texU_3 = texU_1 + 0 .027344f ;
1052
1058
float texU_4 = texU_1 + 0 .035156f ;
1053
1059
float texV_3 = texY * C_RATIO;
1054
1060
float texV_4 = texY * C_RATIO + 0 .023438f ;
1055
1061
1062
+ // Top
1056
1063
t.vertexUV (x_1, y_1, z_1, texU_3, texV_4);
1057
1064
t.vertexUV (x_1, y_1, z_2, texU_3, texV_1);
1058
1065
t.vertexUV (x_2, y_1, z_2, texU_4, texV_1);
1059
1066
t.vertexUV (x_2, y_1, z_1, texU_4, texV_4);
1067
+ // Sides
1060
1068
t.vertexUV (x_3, y_2, z_3, texU_1, texV_3);
1061
1069
t.vertexUV (x_8, y_3, z_7, texU_1, texV_2);
1062
1070
t.vertexUV (x_8, y_3, z_8, texU_2, texV_2);
1063
1071
t.vertexUV (x_3, y_2, z_4, texU_2, texV_3);
1072
+
1064
1073
t.vertexUV (x_4, y_2, z_4, texU_1, texV_3);
1065
1074
t.vertexUV (x_9, y_3, z_8, texU_1, texV_2);
1066
1075
t.vertexUV (x_9, y_3, z_7, texU_2, texV_2);
1067
1076
t.vertexUV (x_4, y_2, z_3, texU_2, texV_3);
1077
+
1068
1078
t.vertexUV (x_5, y_2, z_6, texU_1, texV_3);
1069
1079
t.vertexUV (x_0, y_3, z_0, texU_1, texV_2);
1070
1080
t.vertexUV (x_7, y_3, z_0, texU_2, texV_2);
1071
1081
t.vertexUV (x_6, y_2, z_6, texU_2, texV_3);
1082
+
1072
1083
t.vertexUV (x_6, y_2, z_5, texU_1, texV_3);
1073
1084
t.vertexUV (x_7, y_3, z_9, texU_1, texV_2);
1074
1085
t.vertexUV (x_0, y_3, z_9, texU_2, texV_2);
0 commit comments