all kinds of tweaking and fixing
authorPerttu Ahola <celeron55@gmail.com>
Thu, 3 Feb 2011 23:22:07 +0000 (01:22 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Thu, 3 Feb 2011 23:22:07 +0000 (01:22 +0200)
src/light.cpp
src/light.h
src/main.cpp
src/map.cpp
src/mapnode.cpp
src/serialization.h
src/utility.cpp
src/utility.h

index c0255f7fbb1b8b01b23d4aadb2841606ffd03aa8..1e4dfcdf12051f813d6e3354e6db7debd2b98287 100644 (file)
@@ -19,14 +19,54 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "light.h"
 
-/*u32 daynight_cache_ratios[DAYNIGHT_CACHE_COUNT] =
+
+// a_n+1 = a_n * 0.786
+// Length of LIGHT_MAX+1 means LIGHT_MAX is the last value.
+// LIGHT_SUN is read as LIGHT_MAX from here.
+u8 light_decode_table[LIGHT_MAX+1] = 
+{
+8,
+11,
+14,
+18,
+22,
+29,
+37,
+47,
+60,
+76,
+97,
+123,
+157,
+200,
+255,
+};
+
+// As in minecraft, a_n+1 = a_n * 0.8
+// NOTE: This doesn't really work that well because this defines
+//       LIGHT_MAX as dimmer than LIGHT_SUN
+// NOTE: Uh, this has had 34 left out; forget this.
+/*u8 light_decode_table[LIGHT_MAX+1] = 
 {
-       1000,
-       600,
-       300
+8,
+11,
+14,
+17,
+21,
+27,
+42,
+53,
+66,
+83,
+104,
+130,
+163,
+204,
+255,
 };*/
 
-u8 light_decode_table[LIGHT_MAX+1] = 
+// This was a quick try of more light, manually quickly made
+/*u8 light_decode_table[LIGHT_MAX+1] = 
 {
 0,
 7,
@@ -43,7 +83,9 @@ u8 light_decode_table[LIGHT_MAX+1] =
 167,
 205,
 255,
-};
+};*/
+
+// This was used for a long time, manually made
 /*u8 light_decode_table[LIGHT_MAX+1] = 
 {
 0,
@@ -62,6 +104,7 @@ u8 light_decode_table[LIGHT_MAX+1] =
 191,
 255,
 };*/
+
 /*u8 light_decode_table[LIGHT_MAX+1] = 
 {
 0,
index 888b6da50108aa5131cea024c2cbe291da7f489e..c1af7fa62dcee09929b013a3cc2da3d21e9ca52f 100644 (file)
@@ -36,7 +36,9 @@ extern u32 daynight_cache_ratios[DAYNIGHT_CACHE_COUNT];*/
        Lower level lighting stuff
 */
 
-// This directly sets the range of light
+// This directly sets the range of light.
+// Actually this is not the real maximum, and this is not the
+// brightest. The brightest is LIGHT_SUN.
 #define LIGHT_MAX 14
 // Light is stored as 4 bits, thus 15 is the maximum.
 // This brightness is reserved for sunlight
index 728de280054921b2682bcbabac478aa92c99f2d6..57ebfce1a7f61b07eecd3ad27a491c69cff208df 100644 (file)
@@ -1675,7 +1675,7 @@ int main(int argc, char *argv[])
        driverType = video::EDT_OPENGL;\r
 #else\r
        driverType = video::EDT_OPENGL;\r
-       //driverType = video::EDT_BURNINGSVIDEO;\r
+       //driverType = video::EDT_BURNINGSVIDEO; // Best software renderer\r
 #endif\r
 \r
        // create device and exit if creation failed\r
index 9a976614f430ab4b88272a0c49e5469c7aa9a8f0..d03bc0ce2f4e5c7740d38cc5d8b15ab2033f41e4 100644 (file)
@@ -2903,48 +2903,58 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
                                v3s16(-1,0,0), // left
                        };
 
-                       // Drop mud on side
-                       
-                       for(u32 di=0; di<4; di++)
+                       // Theck that upper is air or doesn't exist.
+                       // Only drop mud if upper doesn't contain anything that
+                       // would keep the mud in place.
+                       u32 i3 = i;
+                       vmanip.m_area.add_y(em, i3, 1);
+                       if(vmanip.m_area.contains(i3) == false
+                                       || content_walkable(vmanip.m_data[i3].d) == false)
                        {
-                               v3s16 dirp = dirs4[di];
-                               u32 i2 = i;
-                               // Move to side
-                               vmanip.m_area.add_p(em, i2, dirp);
-                               // Fail if out of area
-                               if(vmanip.m_area.contains(i2) == false)
-                                       continue;
-                               // Check that side is air
-                               MapNode *n2 = &vmanip.m_data[i2];
-                               if(content_walkable(n2->d))
-                                       continue;
-                               // Check that under side is air
-                               vmanip.m_area.add_y(em, i2, -1);
-                               // Fail if out of area
-                               if(vmanip.m_area.contains(i2) == false)
-                                       continue;
-                               n2 = &vmanip.m_data[i2];
-                               if(content_walkable(n2->d))
-                                       continue;
-                               // Loop further down until not air
-                               do{
+
+                               // Drop mud on side
+                               
+                               for(u32 di=0; di<4; di++)
+                               {
+                                       v3s16 dirp = dirs4[di];
+                                       u32 i2 = i;
+                                       // Move to side
+                                       vmanip.m_area.add_p(em, i2, dirp);
+                                       // Fail if out of area
+                                       if(vmanip.m_area.contains(i2) == false)
+                                               continue;
+                                       // Check that side is air
+                                       MapNode *n2 = &vmanip.m_data[i2];
+                                       if(content_walkable(n2->d))
+                                               continue;
+                                       // Check that under side is air
                                        vmanip.m_area.add_y(em, i2, -1);
                                        // Fail if out of area
                                        if(vmanip.m_area.contains(i2) == false)
                                                continue;
                                        n2 = &vmanip.m_data[i2];
-                               }while(content_walkable(n2->d) == false);
-                               // Loop one up so that we're in air
-                               vmanip.m_area.add_y(em, i2, 1);
-                               n2 = &vmanip.m_data[i2];
+                                       if(content_walkable(n2->d))
+                                               continue;
+                                       // Loop further down until not air
+                                       do{
+                                               vmanip.m_area.add_y(em, i2, -1);
+                                               // Fail if out of area
+                                               if(vmanip.m_area.contains(i2) == false)
+                                                       continue;
+                                               n2 = &vmanip.m_data[i2];
+                                       }while(content_walkable(n2->d) == false);
+                                       // Loop one up so that we're in air
+                                       vmanip.m_area.add_y(em, i2, 1);
+                                       n2 = &vmanip.m_data[i2];
 
-                               // Move mud to new place
-                               *n2 = *n;
-                               // Set old place to be air
-                               *n = MapNode(CONTENT_AIR);
+                                       // Move mud to new place
+                                       *n2 = *n;
+                                       // Set old place to be air
+                                       *n = MapNode(CONTENT_AIR);
 
-                               // Done
-                               break;
+                                       // Done
+                                       break;
+                               }
                        }
                        
                        // Continue from next y
@@ -2990,18 +3000,19 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
                */
                {
                        v3s16 em = vmanip.m_area.getExtent();
-                       s16 y_start = WATER_LEVEL;
                        u8 light = LIGHT_MAX;
+                       // Start at global water surface level
+                       s16 y_start = WATER_LEVEL;
                        u32 i = vmanip.m_area.index(v3s16(p2d.X, y_start, p2d.Y));
                        MapNode *n = &vmanip.m_data[i];
-                       /*
-                               Add first one to transforming liquid queue
-                       */
+
+                       /*// Add first one to transforming liquid queue, if water
                        if(n->d == CONTENT_WATER || n->d == CONTENT_WATERSOURCE)
                        {
                                v3s16 p = v3s16(p2d.X, y_start, p2d.Y);
                                m_transforming_liquid.push_back(p);
-                       }
+                       }*/
+
                        for(s16 y=y_start; y>=y_nodes_min; y--)
                        {
                                n = &vmanip.m_data[i];
@@ -3010,16 +3021,14 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
                                if(n->d != CONTENT_AIR && n->d != CONTENT_WATERSOURCE
                                                && n->d != CONTENT_WATER)
                                {
-                                       /*
-                                               Add bottom one to transforming liquid queue
-                                       */
+                                       /*// Add bottom one to transforming liquid queue
                                        vmanip.m_area.add_y(em, i, 1);
                                        n = &vmanip.m_data[i];
                                        if(n->d == CONTENT_WATER || n->d == CONTENT_WATERSOURCE)
                                        {
                                                v3s16 p = v3s16(p2d.X, y, p2d.Y);
                                                m_transforming_liquid.push_back(p);
-                                       }
+                                       }*/
 
                                        break;
                                }
@@ -3027,10 +3036,10 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
                                n->d = CONTENT_WATERSOURCE;
                                n->setLight(LIGHTBANK_DAY, light);
 
-                               /*// Add to transforming liquid queue (in case it'd
+                               // Add to transforming liquid queue (in case it'd
                                // start flowing)
                                v3s16 p = v3s16(p2d.X, y, p2d.Y);
-                               m_transforming_liquid.push_back(p);*/
+                               m_transforming_liquid.push_back(p);
                                
                                // Next one
                                vmanip.m_area.add_y(em, i, -1);
@@ -5324,9 +5333,10 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
                        float range = 100000 * BS;
                        if(m_control.range_all == false)
                                range = m_control.wanted_range * BS;
-
+                       
+                       float d = 0.0;
                        if(isBlockInSight(block->getPos(), camera_position,
-                                       camera_direction, range) == false)
+                                       camera_direction, range, &d) == false)
                        {
                                continue;
                        }
@@ -5379,7 +5389,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
                                        continue;
                        }
 #endif                 
-
+#if 0
                        v3s16 blockpos_nodes = block->getPosRelative();
                        
                        // Block center position
@@ -5394,6 +5404,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
 
                        // Total distance
                        f32 d = blockpos_relative.getLength();
+#endif
                        
 #if 1
                        /*
index 2ba2a2dbfddac8ede3dc8276a790342ec58dd50d..6f34aa03900fbe319736471e09a4ef937f233c2b 100644 (file)
@@ -75,7 +75,7 @@ void init_mapnode(IIrrlichtWrapper *irrlicht)
        
        i = CONTENT_SAND;
        f = &g_content_features[i];
-       f->setAllTextures(irrlicht->getTextureId("mud.png"));
+       f->setAllTextures(irrlicht->getTextureId("sand.png"));
        f->param_type = CPT_MINERAL;
        f->is_ground_content = true;
        
index a2eca235772a636bc7ace67965fb31bb7e189db7..e84ceee3e0d631582356f020195d314862f7ac4a 100644 (file)
@@ -45,11 +45,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
        10: (dev) water pressure
        11: (dev) zlib'd blocks, block flags
        12: (dev) UnlimitedHeightmap now uses interpolated areas
+       13: (dev) Mapgen v2
 */
 // This represents an uninitialized or invalid format
 #define SER_FMT_VER_INVALID 255
 // Highest supported serialization version
-#define SER_FMT_VER_HIGHEST 12
+#define SER_FMT_VER_HIGHEST 13
 // Lowest supported serialization version
 #define SER_FMT_VER_LOWEST 2
 
index 8b2b78b447f7290f7515acaf7dfd6147863a0925..8c2dc533aead564eef57d5b8353bfea0d145d761 100644 (file)
@@ -380,7 +380,8 @@ lopuks sit otetaan a/b
        camera_dir: an unit vector pointing to camera direction
        range: viewing range
 */
-bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, f32 range)
+bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, f32 range,
+               f32 *distance_ptr)
 {
        v3s16 blockpos_nodes = blockpos_b * MAP_BLOCKSIZE;
        
@@ -399,6 +400,9 @@ bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, f32 range)
 
        // Total distance
        f32 d = blockpos_relative.getLength();
+
+       if(distance_ptr)
+               *distance_ptr = d;
        
        // If block is far away, it's not in sight
        if(d > range * BS)
index e6e72efcf076a2f0a9548ca395cdfb4286525ca0..a24b57d5d1a8bbbd64e65a4f1edff6030b5c51e1 100644 (file)
@@ -1663,7 +1663,8 @@ private:
        Miscellaneous functions
 */
 
-bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, f32 range);
+bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, f32 range,
+               f32 *distance_ptr=NULL);
 
 /*
        Queue with unique values with fast checking of value existence