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"
/*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,
600,
300
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] =
{
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,

View 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

View File

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

View 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
/*

View 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;

View 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

View 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)

View 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