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

@ -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,

@ -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

@ -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

@ -2903,6 +2903,15 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
v3s16(-1,0,0), // left
};
// 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)
{
// Drop mud on side
for(u32 di=0; di<4; di++)
@ -2946,6 +2955,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
// Done
break;
}
}
// Continue from next y
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);
@ -5325,8 +5334,9 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
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
/*

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

@ -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

@ -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;
@ -400,6 +401,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)
return false;

@ -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