]> git.lizzy.rs Git - minetest.git/blobdiff - src/nodedef.cpp
Use single box for halo mesh
[minetest.git] / src / nodedef.cpp
index 0bcc00e47bab3c5565d7dbb2bccdee4f364c5e68..31366f7e08f2858b2be969f1e08f15fb5183f4c6 100644 (file)
@@ -139,7 +139,7 @@ void TileDef::serialize(std::ostream &os, u16 protocol_version) const
        }
 }
 
-void TileDef::deSerialize(std::istream &is)
+void TileDef::deSerialize(std::istream &is, const u8 contenfeatures_version, const NodeDrawType drawtype)
 {
        int version = readU8(is);
        name = deSerializeString(is);
@@ -153,6 +153,13 @@ void TileDef::deSerialize(std::istream &is)
                tileable_horizontal = readU8(is);
                tileable_vertical = readU8(is);
        }
+
+       if ((contenfeatures_version < 8) &&
+               ((drawtype == NDT_MESH) ||
+                (drawtype == NDT_FIRELIKE) ||
+                (drawtype == NDT_LIQUID) ||
+                (drawtype == NDT_PLANTLIKE)))
+               backface_culling = false;
 }
 
 
@@ -263,7 +270,8 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) const
                return;
        }
 
-       writeU8(os, 7); // version
+       writeU8(os, protocol_version < 27 ? 7 : 8);
+
        os<<serializeString(name);
        writeU16(os, groups.size());
        for(ItemGroupList::const_iterator
@@ -325,9 +333,11 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) const
 void ContentFeatures::deSerialize(std::istream &is)
 {
        int version = readU8(is);
-       if(version != 7){
+       if (version < 7) {
                deSerializeOld(is, version);
                return;
+       } else if (version > 8) {
+               throw SerializationError("unsupported ContentFeatures version");
        }
 
        name = deSerializeString(is);
@@ -339,15 +349,16 @@ void ContentFeatures::deSerialize(std::istream &is)
                groups[name] = value;
        }
        drawtype = (enum NodeDrawType)readU8(is);
+
        visual_scale = readF1000(is);
        if(readU8(is) != 6)
                throw SerializationError("unsupported tile count");
        for(u32 i = 0; i < 6; i++)
-               tiledef[i].deSerialize(is);
+               tiledef[i].deSerialize(is, version, drawtype);
        if(readU8(is) != CF_SPECIAL_COUNT)
                throw SerializationError("unsupported CF_SPECIAL_COUNT");
        for(u32 i = 0; i < CF_SPECIAL_COUNT; i++)
-               tiledef_special[i].deSerialize(is);
+               tiledef_special[i].deSerialize(is, version, drawtype);
        alpha = readU8(is);
        post_effect_color.setAlpha(readU8(is));
        post_effect_color.setRed(readU8(is));
@@ -960,7 +971,7 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef,
                        //Convert regular nodebox nodes to meshnodes
                        //Change the drawtype and apply scale
                        f->drawtype = NDT_MESH;
-                       f->mesh_ptr[0] = convertNodeboxNodeToMesh(f);
+                       f->mesh_ptr[0] = convertNodeboxesToMesh(f->node_box.fixed);
                        v3f scale = v3f(1.0, 1.0, 1.0) * f->visual_scale;
                        scaleMesh(f->mesh_ptr[0], scale);
                        recalculateBoundingBox(f->mesh_ptr[0]);
@@ -1258,7 +1269,6 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version) const
                        "Unsupported version requested");
 }
 
-
 void ContentFeatures::deSerializeOld(std::istream &is, int version)
 {
        if (version == 5) // In PROTOCOL_VERSION 13
@@ -1272,15 +1282,16 @@ void ContentFeatures::deSerializeOld(std::istream &is, int version)
                        groups[name] = value;
                }
                drawtype = (enum NodeDrawType)readU8(is);
+
                visual_scale = readF1000(is);
                if (readU8(is) != 6)
                        throw SerializationError("unsupported tile count");
                for (u32 i = 0; i < 6; i++)
-                       tiledef[i].deSerialize(is);
+                       tiledef[i].deSerialize(is, version, drawtype);
                if (readU8(is) != CF_SPECIAL_COUNT)
                        throw SerializationError("unsupported CF_SPECIAL_COUNT");
                for (u32 i = 0; i < CF_SPECIAL_COUNT; i++)
-                       tiledef_special[i].deSerialize(is);
+                       tiledef_special[i].deSerialize(is, version, drawtype);
                alpha = readU8(is);
                post_effect_color.setAlpha(readU8(is));
                post_effect_color.setRed(readU8(is));
@@ -1324,12 +1335,12 @@ void ContentFeatures::deSerializeOld(std::istream &is, int version)
                if (readU8(is) != 6)
                        throw SerializationError("unsupported tile count");
                for (u32 i = 0; i < 6; i++)
-                       tiledef[i].deSerialize(is);
+                       tiledef[i].deSerialize(is, version, drawtype);
                // CF_SPECIAL_COUNT in version 6 = 2
                if (readU8(is) != 2)
                        throw SerializationError("unsupported CF_SPECIAL_COUNT");
                for (u32 i = 0; i < 2; i++)
-                       tiledef_special[i].deSerialize(is);
+                       tiledef_special[i].deSerialize(is, version, drawtype);
                alpha = readU8(is);
                post_effect_color.setAlpha(readU8(is));
                post_effect_color.setRed(readU8(is));