]> git.lizzy.rs Git - minetest.git/blobdiff - src/content_mapblock.cpp
Exclude vertical mapblock borders when setting light
[minetest.git] / src / content_mapblock.cpp
index 9f0d8aa5f335fcef29ff5f7f18031ded0516d655..b84b69629d99082ad6cc490d3da65449e20be7a7 100644 (file)
@@ -1162,15 +1162,16 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
                        u16 l = getInteriorLight(n, 1, nodedef);
                        video::SColor c = MapBlock_LightColor(255, l, f.light_source);
                        
-                       float s = BS / 2;
-                       for(u32 j = 0; j < 2; j++)
+                       float s = BS / 2 * f.visual_scale;
+
+                       for (int j = 0; j < 2; j++)
                        {
                                video::S3DVertex vertices[4] =
                                {
-                                       video::S3DVertex(-s,-s, 0, 0,0,0, c, 0,1),
-                                       video::S3DVertex( s,-s, 0, 0,0,0, c, 1,1),
-                                       video::S3DVertex( s, s, 0, 0,0,0, c, 1,0),
-                                       video::S3DVertex(-s, s, 0, 0,0,0, c, 0,0),
+                                       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),
+                                       video::S3DVertex(-s,-BS/2 + s*2,0, 0,0,0, c, 0,0),
                                };
 
                                if(j == 0)
@@ -1184,10 +1185,10 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
                                                vertices[i].Pos.rotateXZBy(-44 + n.param2 * 2);
                                }
 
-                               for(u16 i = 0; i < 4; i++)
+                               for (int i = 0; i < 4; i++)
                                {
                                        vertices[i].Pos *= f.visual_scale;
-                                       vertices[i].Pos.Y -= s * (1 - f.visual_scale);
+                                       vertices[i].Pos.Y += BS/2 * (f.visual_scale - 1);
                                        vertices[i].Pos += intToFloat(p, BS);
                                }
 
@@ -1621,17 +1622,18 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
                        video::SColor c = MapBlock_LightColor(255, l, f.light_source);
 
                        float d = (float)BS/64;
-                       
-                       char g=-1;
+                       float s = BS/2;
+
+                       short 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])
-                               g=1; //Object is at a slope
+                               g = 1; //Object is at a slope
 
                        video::S3DVertex vertices[4] =
                        {
-                                       video::S3DVertex(-BS/2,-BS/2+d,-BS/2, 0,0,0, c, 0,1),
-                                       video::S3DVertex(BS/2,-BS/2+d,-BS/2, 0,0,0, c, 1,1),
-                                       video::S3DVertex(BS/2,g*BS/2+d,BS/2, 0,0,0, c, 1,0),
-                                       video::S3DVertex(-BS/2,g*BS/2+d,BS/2, 0,0,0, c, 0,0),
+                                       video::S3DVertex(-s,  -s+d,-s,  0,0,0,  c,0,1),
+                                       video::S3DVertex( s,  -s+d,-s,  0,0,0,  c,1,1),
+                                       video::S3DVertex( s, g*s+d, s,  0,0,0,  c,1,0),
+                                       video::S3DVertex(-s, g*s+d, s,  0,0,0,  c,0,0),
                        };
 
                        for(s32 i=0; i<4; i++)
@@ -1731,9 +1733,9 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
                        } else if (f.param_type_2 == CPT2_WALLMOUNTED) {
                                //convert wallmounted to 6dfacedir.
                                //when cache enabled, it is already converted
-                               facedir = n.getWallMounted(nodedef);                            
+                               facedir = n.getWallMounted(nodedef);
                                if (!enable_mesh_cache) {
-                                       static const u8 wm_to_6d[6] =   {20, 0, 16, 12, 8, 4};
+                                       static const u8 wm_to_6d[6] = {20, 0, 16+1, 12+3, 8, 4+2};
                                        facedir = wm_to_6d[facedir];
                                }
                        }