all kinds of tweaking and fixing

This commit is contained in:
Perttu Ahola 2011-02-04 01:22:07 +02:00
parent 24c1ea7103
commit 102c5e31fe
8 changed files with 122 additions and 60 deletions

View File

@ -19,14 +19,54 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "light.h" #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] =
{ {
1000, 8,
600, 11,
300 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] =
{
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, 0,
7, 7,
@ -43,7 +83,9 @@ u8 light_decode_table[LIGHT_MAX+1] =
167, 167,
205, 205,
255, 255,
}; };*/
// This was used for a long time, manually made
/*u8 light_decode_table[LIGHT_MAX+1] = /*u8 light_decode_table[LIGHT_MAX+1] =
{ {
0, 0,
@ -62,6 +104,7 @@ u8 light_decode_table[LIGHT_MAX+1] =
191, 191,
255, 255,
};*/ };*/
/*u8 light_decode_table[LIGHT_MAX+1] = /*u8 light_decode_table[LIGHT_MAX+1] =
{ {
0, 0,

View File

@ -36,7 +36,9 @@ extern u32 daynight_cache_ratios[DAYNIGHT_CACHE_COUNT];*/
Lower level lighting stuff 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 #define LIGHT_MAX 14
// Light is stored as 4 bits, thus 15 is the maximum. // Light is stored as 4 bits, thus 15 is the maximum.
// This brightness is reserved for sunlight // This brightness is reserved for sunlight

View File

@ -1675,7 +1675,7 @@ int main(int argc, char *argv[])
driverType = video::EDT_OPENGL; driverType = video::EDT_OPENGL;
#else #else
driverType = video::EDT_OPENGL; driverType = video::EDT_OPENGL;
//driverType = video::EDT_BURNINGSVIDEO; //driverType = video::EDT_BURNINGSVIDEO; // Best software renderer
#endif #endif
// create device and exit if creation failed // create device and exit if creation failed

View File

@ -2903,48 +2903,58 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
v3s16(-1,0,0), // left v3s16(-1,0,0), // left
}; };
// Drop mud on side // Theck that upper is air or doesn't exist.
// Only drop mud if upper doesn't contain anything that
for(u32 di=0; di<4; di++) // 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; // Drop mud on side
// Move to side
vmanip.m_area.add_p(em, i2, dirp); for(u32 di=0; di<4; di++)
// Fail if out of area {
if(vmanip.m_area.contains(i2) == false) v3s16 dirp = dirs4[di];
continue; u32 i2 = i;
// Check that side is air // Move to side
MapNode *n2 = &vmanip.m_data[i2]; vmanip.m_area.add_p(em, i2, dirp);
if(content_walkable(n2->d)) // Fail if out of area
continue; if(vmanip.m_area.contains(i2) == false)
// Check that under side is air continue;
vmanip.m_area.add_y(em, i2, -1); // Check that side is air
// Fail if out of area MapNode *n2 = &vmanip.m_data[i2];
if(vmanip.m_area.contains(i2) == false) if(content_walkable(n2->d))
continue; continue;
n2 = &vmanip.m_data[i2]; // Check that under side is air
if(content_walkable(n2->d))
continue;
// Loop further down until not air
do{
vmanip.m_area.add_y(em, i2, -1); vmanip.m_area.add_y(em, i2, -1);
// Fail if out of area // Fail if out of area
if(vmanip.m_area.contains(i2) == false) if(vmanip.m_area.contains(i2) == false)
continue; continue;
n2 = &vmanip.m_data[i2]; n2 = &vmanip.m_data[i2];
}while(content_walkable(n2->d) == false); if(content_walkable(n2->d))
// Loop one up so that we're in air continue;
vmanip.m_area.add_y(em, i2, 1); // Loop further down until not air
n2 = &vmanip.m_data[i2]; 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 // Move mud to new place
*n2 = *n; *n2 = *n;
// Set old place to be air // Set old place to be air
*n = MapNode(CONTENT_AIR); *n = MapNode(CONTENT_AIR);
// Done // Done
break; break;
}
} }
// Continue from next y // Continue from next y
@ -2990,18 +3000,19 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
*/ */
{ {
v3s16 em = vmanip.m_area.getExtent(); v3s16 em = vmanip.m_area.getExtent();
s16 y_start = WATER_LEVEL;
u8 light = LIGHT_MAX; 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)); u32 i = vmanip.m_area.index(v3s16(p2d.X, y_start, p2d.Y));
MapNode *n = &vmanip.m_data[i]; 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) if(n->d == CONTENT_WATER || n->d == CONTENT_WATERSOURCE)
{ {
v3s16 p = v3s16(p2d.X, y_start, p2d.Y); v3s16 p = v3s16(p2d.X, y_start, p2d.Y);
m_transforming_liquid.push_back(p); m_transforming_liquid.push_back(p);
} }*/
for(s16 y=y_start; y>=y_nodes_min; y--) for(s16 y=y_start; y>=y_nodes_min; y--)
{ {
n = &vmanip.m_data[i]; n = &vmanip.m_data[i];
@ -3010,16 +3021,14 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
if(n->d != CONTENT_AIR && n->d != CONTENT_WATERSOURCE if(n->d != CONTENT_AIR && n->d != CONTENT_WATERSOURCE
&& n->d != CONTENT_WATER) && 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); vmanip.m_area.add_y(em, i, 1);
n = &vmanip.m_data[i]; n = &vmanip.m_data[i];
if(n->d == CONTENT_WATER || n->d == CONTENT_WATERSOURCE) if(n->d == CONTENT_WATER || n->d == CONTENT_WATERSOURCE)
{ {
v3s16 p = v3s16(p2d.X, y, p2d.Y); v3s16 p = v3s16(p2d.X, y, p2d.Y);
m_transforming_liquid.push_back(p); m_transforming_liquid.push_back(p);
} }*/
break; break;
} }
@ -3027,10 +3036,10 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
n->d = CONTENT_WATERSOURCE; n->d = CONTENT_WATERSOURCE;
n->setLight(LIGHTBANK_DAY, light); 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) // start flowing)
v3s16 p = v3s16(p2d.X, y, p2d.Y); v3s16 p = v3s16(p2d.X, y, p2d.Y);
m_transforming_liquid.push_back(p);*/ m_transforming_liquid.push_back(p);
// Next one // Next one
vmanip.m_area.add_y(em, i, -1); vmanip.m_area.add_y(em, i, -1);
@ -5324,9 +5333,10 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
float range = 100000 * BS; float range = 100000 * BS;
if(m_control.range_all == false) if(m_control.range_all == false)
range = m_control.wanted_range * BS; range = m_control.wanted_range * BS;
float d = 0.0;
if(isBlockInSight(block->getPos(), camera_position, if(isBlockInSight(block->getPos(), camera_position,
camera_direction, range) == false) camera_direction, range, &d) == false)
{ {
continue; continue;
} }
@ -5379,7 +5389,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
continue; continue;
} }
#endif #endif
#if 0
v3s16 blockpos_nodes = block->getPosRelative(); v3s16 blockpos_nodes = block->getPosRelative();
// Block center position // Block center position
@ -5394,6 +5404,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
// Total distance // Total distance
f32 d = blockpos_relative.getLength(); f32 d = blockpos_relative.getLength();
#endif
#if 1 #if 1
/* /*

View File

@ -75,7 +75,7 @@ void init_mapnode(IIrrlichtWrapper *irrlicht)
i = CONTENT_SAND; i = CONTENT_SAND;
f = &g_content_features[i]; f = &g_content_features[i];
f->setAllTextures(irrlicht->getTextureId("mud.png")); f->setAllTextures(irrlicht->getTextureId("sand.png"));
f->param_type = CPT_MINERAL; f->param_type = CPT_MINERAL;
f->is_ground_content = true; f->is_ground_content = true;

View File

@ -45,11 +45,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
10: (dev) water pressure 10: (dev) water pressure
11: (dev) zlib'd blocks, block flags 11: (dev) zlib'd blocks, block flags
12: (dev) UnlimitedHeightmap now uses interpolated areas 12: (dev) UnlimitedHeightmap now uses interpolated areas
13: (dev) Mapgen v2
*/ */
// This represents an uninitialized or invalid format // This represents an uninitialized or invalid format
#define SER_FMT_VER_INVALID 255 #define SER_FMT_VER_INVALID 255
// Highest supported serialization version // Highest supported serialization version
#define SER_FMT_VER_HIGHEST 12 #define SER_FMT_VER_HIGHEST 13
// Lowest supported serialization version // Lowest supported serialization version
#define SER_FMT_VER_LOWEST 2 #define SER_FMT_VER_LOWEST 2

View File

@ -380,7 +380,8 @@ lopuks sit otetaan a/b
camera_dir: an unit vector pointing to camera direction camera_dir: an unit vector pointing to camera direction
range: viewing range 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; 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 // Total distance
f32 d = blockpos_relative.getLength(); f32 d = blockpos_relative.getLength();
if(distance_ptr)
*distance_ptr = d;
// If block is far away, it's not in sight // If block is far away, it's not in sight
if(d > range * BS) if(d > range * BS)

View File

@ -1663,7 +1663,8 @@ private:
Miscellaneous functions 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 Queue with unique values with fast checking of value existence