ServerRemotePlayer implements ServerActiveObject
[oweals/minetest.git] / src / mapnode.cpp
index 484fcbe0af3a8fddd1aac23d2cbcc18a0fef8a0e..f816319999e1c30196c0b066f5aa83a45f55800a 100644 (file)
@@ -164,6 +164,9 @@ void init_mapnode()
                f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
        }
 
+       // Make CONTENT_IGNORE to not block the view when occlusion culling
+       content_features(CONTENT_IGNORE).solidness = 0;
+
        /*
                Initialize mapnode content
        */
@@ -171,6 +174,57 @@ void init_mapnode()
        
 }
 
+/*
+       Nodes make a face if contents differ and solidness differs.
+       Return value:
+               0: No face
+               1: Face uses m1's content
+               2: Face uses m2's content
+       equivalent: Whether the blocks share the same face (eg. water and glass)
+*/
+u8 face_contents(content_t m1, content_t m2, bool *equivalent)
+{
+       *equivalent = false;
+
+       if(m1 == CONTENT_IGNORE || m2 == CONTENT_IGNORE)
+               return 0;
+       
+       bool contents_differ = (m1 != m2);
+       
+       // Contents don't differ for different forms of same liquid
+       if(content_liquid(m1) && content_liquid(m2)
+                       && make_liquid_flowing(m1) == make_liquid_flowing(m2))
+               contents_differ = false;
+       
+       u8 c1 = content_solidness(m1);
+       u8 c2 = content_solidness(m2);
+
+       bool solidness_differs = (c1 != c2);
+       bool makes_face = contents_differ && solidness_differs;
+
+       if(makes_face == false)
+               return 0;
+       
+       if(c1 == 0)
+               c1 = content_features(m1).visual_solidness;
+       if(c2 == 0)
+               c2 = content_features(m2).visual_solidness;
+       
+       if(c1 == c2){
+               *equivalent = true;
+               // If same solidness, liquid takes precense
+               if(content_features(m1).liquid_type != LIQUID_NONE)
+                       return 1;
+               if(content_features(m2).liquid_type != LIQUID_NONE)
+                       return 2;
+       }
+       
+       if(c1 > c2)
+               return 1;
+       else
+               return 2;
+}
+
 v3s16 facedir_rotate(u8 facedir, v3s16 dir)
 {
        /*