Restyled a bit

This commit is contained in:
Joel Leclerc 2012-05-14 17:57:29 -06:00
parent e304ec13c4
commit cd39b15f0c

View File

@ -675,7 +675,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
}; };
v3f move_torch(0,0,0); v3f move_torch(0,0,0);
int xyrotation = 180; int xyrotation = 0;
int yzrotation = 0; int yzrotation = 0;
for(s32 i=0; i<4; i++) for(s32 i=0; i<4; i++)
{ {
@ -955,32 +955,56 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
content_t thiscontent = n.getContent(); content_t thiscontent = n.getContent();
if(n_minus_x.getContent() == thiscontent) if(n_minus_x.getContent() == thiscontent)
{
is_mesecon_x[0] = true; is_mesecon_x[0] = true;
}
if(n_minus_x_minus_y.getContent() == thiscontent) if(n_minus_x_minus_y.getContent() == thiscontent)
{
is_mesecon_x_minus_y[0] = true; is_mesecon_x_minus_y[0] = true;
}
if(n_minus_x_plus_y.getContent() == thiscontent) if(n_minus_x_plus_y.getContent() == thiscontent)
{
is_mesecon_x_plus_y[0] = true; is_mesecon_x_plus_y[0] = true;
}
if(n_plus_x.getContent() == thiscontent) if(n_plus_x.getContent() == thiscontent)
{
is_mesecon_x[1] = true; is_mesecon_x[1] = true;
}
if(n_plus_x_minus_y.getContent() == thiscontent) if(n_plus_x_minus_y.getContent() == thiscontent)
{
is_mesecon_x_minus_y[1] = true; is_mesecon_x_minus_y[1] = true;
}
if(n_plus_x_plus_y.getContent() == thiscontent) if(n_plus_x_plus_y.getContent() == thiscontent)
{
is_mesecon_x_plus_y[1] = true; is_mesecon_x_plus_y[1] = true;
}
if(n_minus_z.getContent() == thiscontent) if(n_minus_z.getContent() == thiscontent)
{
is_mesecon_z[0] = true; is_mesecon_z[0] = true;
}
if(n_minus_z_minus_y.getContent() == thiscontent) if(n_minus_z_minus_y.getContent() == thiscontent)
{
is_mesecon_z_minus_y[0] = true; is_mesecon_z_minus_y[0] = true;
}
if(n_minus_z_plus_y.getContent() == thiscontent) if(n_minus_z_plus_y.getContent() == thiscontent)
{
is_mesecon_z_plus_y[0] = true; is_mesecon_z_plus_y[0] = true;
}
if(n_plus_z.getContent() == thiscontent) if(n_plus_z.getContent() == thiscontent)
{
is_mesecon_z[1] = true; is_mesecon_z[1] = true;
}
if(n_plus_z_minus_y.getContent() == thiscontent) if(n_plus_z_minus_y.getContent() == thiscontent)
{
is_mesecon_z_minus_y[1] = true; is_mesecon_z_minus_y[1] = true;
}
if(n_plus_z_plus_y.getContent() == thiscontent) if(n_plus_z_plus_y.getContent() == thiscontent)
{
is_mesecon_z_plus_y[1] = true; is_mesecon_z_plus_y[1] = true;
}
bool is_mesecon_x_all[] = {false, false}; bool is_mesecon_x_all[] = {false, false};
@ -1001,14 +1025,22 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
else if(adjacencies == 2) else if(adjacencies == 2)
{ {
if(is_straight) if(is_straight)
{
tileindex = 0; // straight tileindex = 0; // straight
}
else else
{
tileindex = 1; // curved tileindex = 1; // curved
} }
}
else if(adjacencies == 3) else if(adjacencies == 3)
{
tileindex = 2; // t-junction tileindex = 2; // t-junction
}
else if(adjacencies == 4) else if(adjacencies == 4)
{
tileindex = 3; // crossing tileindex = 3; // crossing
}
TileSpec tile = getNodeTileN(n, p, tileindex, data); TileSpec tile = getNodeTileN(n, p, tileindex, data);
tile.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING; tile.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
@ -1073,14 +1105,22 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
vertices_slope_zplus0[i].Pos += intToFloat(p, BS); vertices_slope_zplus0[i].Pos += intToFloat(p, BS);
} }
if(is_mesecon_x_plus_y[1]) if(is_mesecon_x_plus_y[1])
{
collector.append(tile, vertices_slope_xplus1, 4, indices, 6); collector.append(tile, vertices_slope_xplus1, 4, indices, 6);
}
if(is_mesecon_x_plus_y[0]) if(is_mesecon_x_plus_y[0])
{
collector.append(tile, vertices_slope_xplus0, 4, indices, 6); collector.append(tile, vertices_slope_xplus0, 4, indices, 6);
}
if(is_mesecon_z_plus_y[1]) if(is_mesecon_z_plus_y[1])
{
collector.append(tile, vertices_slope_zplus1, 4, indices, 6); collector.append(tile, vertices_slope_zplus1, 4, indices, 6);
}
if(is_mesecon_z_plus_y[0]) if(is_mesecon_z_plus_y[0])
{
collector.append(tile, vertices_slope_zplus0, 4, indices, 6); collector.append(tile, vertices_slope_zplus0, 4, indices, 6);
} }
}
video::S3DVertex vertices[4] = video::S3DVertex vertices[4] =
{ {
@ -1100,8 +1140,10 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
if(adjacencies == 1) if(adjacencies == 1)
{ {
if(is_mesecon_x_all[0] || is_mesecon_x_all[1]) if(is_mesecon_x_all[0] || is_mesecon_x_all[1])
{
angle = 90; angle = 90;
} }
}
if(adjacencies == 2) if(adjacencies == 2)
{ {
if(is_mesecon_x_all[0] && is_mesecon_x_all[1]) if(is_mesecon_x_all[0] && is_mesecon_x_all[1])
@ -1110,31 +1152,51 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
} }
if(is_mesecon_z_all[0] && is_mesecon_z_all[1]) if(is_mesecon_z_all[0] && is_mesecon_z_all[1])
{ {
if (n_minus_z_plus_y.getContent() == thiscontent) angle = 180; if (n_minus_z_plus_y.getContent() == thiscontent)
{
angle = 180;
}
} }
else if(is_mesecon_x_all[0] && is_mesecon_z_all[0]) else if(is_mesecon_x_all[0] && is_mesecon_z_all[0])
{
angle = 270; angle = 270;
}
else if(is_mesecon_x_all[0] && is_mesecon_z_all[1]) else if(is_mesecon_x_all[0] && is_mesecon_z_all[1])
{
angle = 180; angle = 180;
}
else if(is_mesecon_x_all[1] && is_mesecon_z_all[1]) else if(is_mesecon_x_all[1] && is_mesecon_z_all[1])
{
angle = 90; angle = 90;
} }
}
if(adjacencies == 3) if(adjacencies == 3)
{ {
if(!is_mesecon_x_all[0]) if(!is_mesecon_x_all[0])
{
angle=0; angle=0;
}
if(!is_mesecon_x_all[1]) if(!is_mesecon_x_all[1])
{
angle=180; angle=180;
}
if(!is_mesecon_z_all[0]) if(!is_mesecon_z_all[0])
{
angle=90; angle=90;
}
if(!is_mesecon_z_all[1]) if(!is_mesecon_z_all[1])
{
angle=270; angle=270;
} }
}
if(angle != 0) { if(angle != 0)
{
for(u16 i=0; i<4; i++) for(u16 i=0; i<4; i++)
{
vertices[i].Pos.rotateXZBy(angle); vertices[i].Pos.rotateXZBy(angle);
} }
}
for(s32 i=0; i<4; i++) for(s32 i=0; i<4; i++)
{ {
@ -1169,32 +1231,56 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
content_t thiscontent = n.getContent(); content_t thiscontent = n.getContent();
if(n_minus_x.getContent() == thiscontent) if(n_minus_x.getContent() == thiscontent)
{
is_rail_x[0] = true; is_rail_x[0] = true;
}
if(n_minus_x_minus_y.getContent() == thiscontent) if(n_minus_x_minus_y.getContent() == thiscontent)
{
is_rail_x_minus_y[0] = true; is_rail_x_minus_y[0] = true;
}
if(n_minus_x_plus_y.getContent() == thiscontent) if(n_minus_x_plus_y.getContent() == thiscontent)
{
is_rail_x_plus_y[0] = true; is_rail_x_plus_y[0] = true;
}
if(n_plus_x.getContent() == thiscontent) if(n_plus_x.getContent() == thiscontent)
{
is_rail_x[1] = true; is_rail_x[1] = true;
}
if(n_plus_x_minus_y.getContent() == thiscontent) if(n_plus_x_minus_y.getContent() == thiscontent)
{
is_rail_x_minus_y[1] = true; is_rail_x_minus_y[1] = true;
}
if(n_plus_x_plus_y.getContent() == thiscontent) if(n_plus_x_plus_y.getContent() == thiscontent)
{
is_rail_x_plus_y[1] = true; is_rail_x_plus_y[1] = true;
}
if(n_minus_z.getContent() == thiscontent) if(n_minus_z.getContent() == thiscontent)
{
is_rail_z[0] = true; is_rail_z[0] = true;
}
if(n_minus_z_minus_y.getContent() == thiscontent) if(n_minus_z_minus_y.getContent() == thiscontent)
{
is_rail_z_minus_y[0] = true; is_rail_z_minus_y[0] = true;
}
if(n_minus_z_plus_y.getContent() == thiscontent) if(n_minus_z_plus_y.getContent() == thiscontent)
{
is_rail_z_plus_y[0] = true; is_rail_z_plus_y[0] = true;
}
if(n_plus_z.getContent() == thiscontent) if(n_plus_z.getContent() == thiscontent)
{
is_rail_z[1] = true; is_rail_z[1] = true;
}
if(n_plus_z_minus_y.getContent() == thiscontent) if(n_plus_z_minus_y.getContent() == thiscontent)
{
is_rail_z_minus_y[1] = true; is_rail_z_minus_y[1] = true;
}
if(n_plus_z_plus_y.getContent() == thiscontent) if(n_plus_z_plus_y.getContent() == thiscontent)
{
is_rail_z_plus_y[1] = true; is_rail_z_plus_y[1] = true;
}
bool is_rail_x_all[] = {false, false}; bool is_rail_x_all[] = {false, false};
@ -1216,18 +1302,28 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
// Assign textures // Assign textures
u8 tileindex = 0; // straight u8 tileindex = 0; // straight
if(adjacencies < 2) if(adjacencies < 2)
{
tileindex = 0; // straight tileindex = 0; // straight
}
else if(adjacencies == 2) else if(adjacencies == 2)
{ {
if(is_straight) if(is_straight)
{
tileindex = 0; // straight tileindex = 0; // straight
}
else else
{
tileindex = 1; // curved tileindex = 1; // curved
} }
}
else if(adjacencies == 3) else if(adjacencies == 3)
{
tileindex = 2; // t-junction tileindex = 2; // t-junction
}
else if(adjacencies == 4) else if(adjacencies == 4)
{
tileindex = 3; // crossing tileindex = 3; // crossing
}
TileSpec tile = getNodeTileN(n, p, tileindex, data); TileSpec tile = getNodeTileN(n, p, tileindex, data);
tile.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING; tile.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
@ -1242,7 +1338,9 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
char g=-1; char g=-1;
if(is_rail_x_plus_y[0] || is_rail_x_plus_y[1] || is_rail_z_plus_y[0] || is_rail_z_plus_y[1]) if(is_rail_x_plus_y[0] || is_rail_x_plus_y[1] || is_rail_z_plus_y[0] || is_rail_z_plus_y[1])
{
g=1; //Object is at a slope g=1; //Object is at a slope
}
video::S3DVertex vertices[4] = video::S3DVertex vertices[4] =
{ {
@ -1263,8 +1361,10 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
if(adjacencies == 1) if(adjacencies == 1)
{ {
if(is_rail_x_all[0] || is_rail_x_all[1]) if(is_rail_x_all[0] || is_rail_x_all[1])
{
angle = 90; angle = 90;
} }
}
if(adjacencies == 2) if(adjacencies == 2)
{ {
if(is_rail_x_all[0] && is_rail_x_all[1]) if(is_rail_x_all[0] && is_rail_x_all[1])
@ -1273,41 +1373,67 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
} }
if(is_rail_z_all[0] && is_rail_z_all[1]) if(is_rail_z_all[0] && is_rail_z_all[1])
{ {
if (n_minus_z_plus_y.getContent() == thiscontent) angle = 180; if (n_minus_z_plus_y.getContent() == thiscontent)
{
angle = 180;
}
} }
else if(is_rail_x_all[0] && is_rail_z_all[0]) else if(is_rail_x_all[0] && is_rail_z_all[0])
{
angle = 270; angle = 270;
}
else if(is_rail_x_all[0] && is_rail_z_all[1]) else if(is_rail_x_all[0] && is_rail_z_all[1])
{
angle = 180; angle = 180;
}
else if(is_rail_x_all[1] && is_rail_z_all[1]) else if(is_rail_x_all[1] && is_rail_z_all[1])
{
angle = 90; angle = 90;
} }
}
if(adjacencies == 3) if(adjacencies == 3)
{ {
if(!is_rail_x_all[0]) if(!is_rail_x_all[0])
{
angle = 0; angle = 0;
}
if(!is_rail_x_all[1]) if(!is_rail_x_all[1])
{
angle = 180; angle = 180;
}
if(!is_rail_z_all[0]) if(!is_rail_z_all[0])
{
angle = 90; angle = 90;
}
if(!is_rail_z_all[1]) if(!is_rail_z_all[1])
{
angle = 270; angle = 270;
} }
}
//adjacencies 4: Crossing //adjacencies 4: Crossing
if(adjacencies == 5) //sloped if(adjacencies == 5) //sloped
{ {
if(is_rail_z_plus_y[0]) if(is_rail_z_plus_y[0])
{
angle = 180; angle = 180;
}
if(is_rail_x_plus_y[0]) if(is_rail_x_plus_y[0])
{
angle = 90; angle = 90;
}
if(is_rail_x_plus_y[1]) if(is_rail_x_plus_y[1])
{
angle = -90; angle = -90;
} }
}
if(angle != 0) { if(angle != 0)
{
for(u16 i=0; i<4; i++) for(u16 i=0; i<4; i++)
{
vertices[i].Pos.rotateXZBy(angle); vertices[i].Pos.rotateXZBy(angle);
} }
}
for(s32 i=0; i<4; i++) for(s32 i=0; i<4; i++)
{ {