mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Firelike drawtype: Improve code
Remove unusable fine rotation by param2 Remove unused and redundant code Fix code style issues
This commit is contained in:
parent
620dcddf43
commit
8e9c9e305a
@ -1177,11 +1177,8 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||
|
||||
bool drawAllFaces = true;
|
||||
|
||||
bool drawBottomFacesOnly = false; // Currently unused
|
||||
|
||||
// Check for adjacent nodes
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
for (int i = 0; i < 6; i++) {
|
||||
n2p = blockpos_nodes + p + dirs[i];
|
||||
n2 = data->m_vmanip.getNodeNoEx(n2p);
|
||||
n2c = n2.getContent();
|
||||
@ -1193,13 +1190,9 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||
}
|
||||
}
|
||||
|
||||
for(int j = 0; j < 6; j++)
|
||||
{
|
||||
int vOffset = 0; // Vertical offset of faces after rotation
|
||||
int hOffset = 4; // Horizontal offset of faces to reach the edge
|
||||
for (int j = 0; j < 6; j++) {
|
||||
|
||||
video::S3DVertex vertices[4] =
|
||||
{
|
||||
video::S3DVertex vertices[4] = {
|
||||
video::S3DVertex(-s, -BS / 2, 0, 0, 0, 0, c, 0, 1),
|
||||
video::S3DVertex( s, -BS / 2, 0, 0, 0, 0, c, 1, 1),
|
||||
video::S3DVertex( s, -BS / 2 + s * 2, 0, 0, 0, 0, c, 1, 0),
|
||||
@ -1207,101 +1200,76 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||
};
|
||||
|
||||
// Calculate which faces should be drawn, (top or sides)
|
||||
if(j == 0 && (drawAllFaces || (doDraw[3] == 1 || doDraw[1] == 1)))
|
||||
{
|
||||
if (j == 0 && (drawAllFaces ||
|
||||
(doDraw[3] == 1 || doDraw[1] == 1))) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vertices[i].Pos.rotateXZBy(90 + n.param2 * 2);
|
||||
vertices[i].Pos.rotateXZBy(90);
|
||||
vertices[i].Pos.rotateXYBy(-10);
|
||||
vertices[i].Pos.Y -= vOffset;
|
||||
vertices[i].Pos.X -= hOffset;
|
||||
vertices[i].Pos.X -= 4.0;
|
||||
}
|
||||
}
|
||||
else if(j == 1 && (drawAllFaces || (doDraw[5] == 1 || doDraw[1] == 1)))
|
||||
{
|
||||
} else if (j == 1 && (drawAllFaces ||
|
||||
(doDraw[5] == 1 || doDraw[1] == 1))) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vertices[i].Pos.rotateXZBy(180 + n.param2 * 2);
|
||||
vertices[i].Pos.rotateXZBy(180);
|
||||
vertices[i].Pos.rotateYZBy(10);
|
||||
vertices[i].Pos.Y -= vOffset;
|
||||
vertices[i].Pos.Z -= hOffset;
|
||||
vertices[i].Pos.Z -= 4.0;
|
||||
}
|
||||
}
|
||||
else if(j == 2 && (drawAllFaces || (doDraw[2] == 1 || doDraw[1] == 1)))
|
||||
{
|
||||
} else if (j == 2 && (drawAllFaces ||
|
||||
(doDraw[2] == 1 || doDraw[1] == 1))) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vertices[i].Pos.rotateXZBy(270 + n.param2 * 2);
|
||||
vertices[i].Pos.rotateXZBy(270);
|
||||
vertices[i].Pos.rotateXYBy(10);
|
||||
vertices[i].Pos.Y -= vOffset;
|
||||
vertices[i].Pos.X += hOffset;
|
||||
vertices[i].Pos.X += 4.0;
|
||||
}
|
||||
}
|
||||
else if(j == 3 && (drawAllFaces || (doDraw[4] == 1 || doDraw[1] == 1)))
|
||||
{
|
||||
} else if (j == 3 && (drawAllFaces ||
|
||||
(doDraw[4] == 1 || doDraw[1] == 1))) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vertices[i].Pos.rotateYZBy(-10);
|
||||
vertices[i].Pos.Y -= vOffset;
|
||||
vertices[i].Pos.Z += hOffset;
|
||||
vertices[i].Pos.Z += 4.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Center cross-flames
|
||||
else if(j == 4 && (drawAllFaces || doDraw[1] == 1))
|
||||
{
|
||||
} else if (j == 4 && (drawAllFaces || doDraw[1] == 1)) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vertices[i].Pos.rotateXZBy(45 + n.param2 * 2);
|
||||
vertices[i].Pos.Y -= vOffset;
|
||||
vertices[i].Pos.rotateXZBy(45);
|
||||
}
|
||||
}
|
||||
else if(j == 5 && (drawAllFaces || doDraw[1] == 1))
|
||||
{
|
||||
} else if (j == 5 && (drawAllFaces || doDraw[1] == 1)) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vertices[i].Pos.rotateXZBy(-45 + n.param2 * 2);
|
||||
vertices[i].Pos.Y -= vOffset;
|
||||
vertices[i].Pos.rotateXZBy(-45);
|
||||
}
|
||||
}
|
||||
|
||||
// Render flames on bottom
|
||||
else if(j == 0 && (drawBottomFacesOnly || (doDraw[0] == 1 && doDraw[1] == 0)))
|
||||
{
|
||||
// Render flames on bottom of node above
|
||||
} else if (j == 0 && doDraw[0] == 1 && doDraw[1] == 0) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vertices[i].Pos.rotateYZBy(70);
|
||||
vertices[i].Pos.rotateXZBy(90 + n.param2 * 2);
|
||||
vertices[i].Pos.rotateXZBy(90);
|
||||
vertices[i].Pos.Y += 4.84;
|
||||
vertices[i].Pos.X -= hOffset+0.7;
|
||||
vertices[i].Pos.X -= 4.7;
|
||||
}
|
||||
}
|
||||
else if(j == 1 && (drawBottomFacesOnly || (doDraw[0] == 1 && doDraw[1] == 0)))
|
||||
{
|
||||
} else if (j == 1 && doDraw[0] == 1 && doDraw[1] == 0) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vertices[i].Pos.rotateYZBy(70);
|
||||
vertices[i].Pos.rotateXZBy(180 + n.param2 * 2);
|
||||
vertices[i].Pos.rotateXZBy(180);
|
||||
vertices[i].Pos.Y += 4.84;
|
||||
vertices[i].Pos.Z -= hOffset+0.7;
|
||||
vertices[i].Pos.Z -= 4.7;
|
||||
}
|
||||
}
|
||||
else if(j == 2 && (drawBottomFacesOnly || (doDraw[0] == 1 && doDraw[1] == 0)))
|
||||
{
|
||||
} else if (j == 2 && doDraw[0] == 1 && doDraw[1] == 0) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vertices[i].Pos.rotateYZBy(70);
|
||||
vertices[i].Pos.rotateXZBy(270 + n.param2 * 2);
|
||||
vertices[i].Pos.rotateXZBy(270);
|
||||
vertices[i].Pos.Y += 4.84;
|
||||
vertices[i].Pos.X += hOffset+0.7;
|
||||
vertices[i].Pos.X += 4.7;
|
||||
}
|
||||
}
|
||||
else if(j == 3 && (drawBottomFacesOnly || (doDraw[0] == 1 && doDraw[1] == 0)))
|
||||
{
|
||||
} else if (j == 3 && doDraw[0] == 1 && doDraw[1] == 0) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vertices[i].Pos.rotateYZBy(70);
|
||||
vertices[i].Pos.Y += 4.84;
|
||||
vertices[i].Pos.Z += hOffset+0.7;
|
||||
vertices[i].Pos.Z += 4.7;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Skip faces that aren't adjacent to a node
|
||||
continue;
|
||||
}
|
||||
|
||||
for(int i=0; i<4; i++)
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vertices[i].Pos *= f.visual_scale;
|
||||
vertices[i].Pos += intToFloat(p, BS);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user