1
0
mirror of https://github.com/minetest/minetest.git synced 2024-09-26 06:20:32 +02:00

commit before some radical changes

This commit is contained in:
Perttu Ahola 2011-04-02 13:44:06 +03:00
parent 2e7b15fed3
commit 2990f5d90b
8 changed files with 204 additions and 138 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 556 B

After

Width:  |  Height:  |  Size: 548 B

View File

@ -1,5 +1,9 @@
#!/usr/bin/python #!/usr/bin/python
"
This is an example script that generates some valid map data.
"
import struct import struct
import random import random

View File

@ -1039,6 +1039,8 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
m_chat_queue.push_back(message); m_chat_queue.push_back(message);
} }
else if(command == TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD) else if(command == TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD)
{
if(g_settings.getBool("enable_experimental"))
{ {
/* /*
u16 command u16 command
@ -1094,7 +1096,10 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
} }
} }
} }
}
else if(command == TOCLIENT_ACTIVE_OBJECT_MESSAGES) else if(command == TOCLIENT_ACTIVE_OBJECT_MESSAGES)
{
if(g_settings.getBool("enable_experimental"))
{ {
/* /*
u16 command u16 command
@ -1134,6 +1139,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
} }
} }
} }
}
// Default to queueing it (for slow commands) // Default to queueing it (for slow commands)
else else
{ {

View File

@ -160,6 +160,9 @@ TODO: Flowing water animation
* Combine meshes to bigger ones in ClientMap and set them EHM_STATIC * Combine meshes to bigger ones in ClientMap and set them EHM_STATIC
SUGG: Draw cubes in inventory directly with 3D drawing commands, so that
animating them is easier.
Configuration: Configuration:
-------------- --------------
@ -242,9 +245,6 @@ TODO: Mineral and ground material properties
TODO: Flowing water to actually contain flow direction information TODO: Flowing water to actually contain flow direction information
TODO: Remove duplicate lighting implementation from Map (leave
VoxelManipulator, which is faster)
FEATURE: Create a system that allows a huge amount of different "map FEATURE: Create a system that allows a huge amount of different "map
generator modules/filters" generator modules/filters"
@ -273,18 +273,27 @@ Mapgen v2:
the other chunk making nasty straight walls when the other chunk the other chunk making nasty straight walls when the other chunk
is generated. Fix it. is generated. Fix it.
Mapgen v4 (not doing):
* only_from_disk might not work anymore - check and fix it.
* Make the generator to run in background and not blocking block
placement and transfer
* Make chunks to be tiled vertically too
* MAKE IT FASTER
Mapgen v3: Mapgen v3:
* Generate trees better * Generate trees better
- Add a "trees_added" flag to sector, or something - Add a "trees_added" flag to sector, or something
* How 'bout making turbulence controlled so that for a given 2d position * How 'bout making turbulence controlled so that for a given 2d position
it can be completely turned off, and is usually so. This way generation it can be completely turned off, and is usually so. This way generation
can be sped up a lot. can be sped up a lot.
* Add a way to generate a block partly, so that trees are not added, like
the chunks in v2
* Add mud "discretely", not by guessing from the noise
Mapgen v4: Mapgen v4:
* only_from_disk might not work anymore - check and fix it. * This will be the final way.
* Make the generator to run in background and not blocking block * Generate blocks in the same way as chunks, by copying a voxelmanipulator
placement and transfer from the map that is one block larger in all directions.
* Make chunks to be tiled vertically too
Misc. stuff: Misc. stuff:
------------ ------------

View File

@ -183,6 +183,9 @@ bool Map::isNodeUnderground(v3s16 p)
light_sources to re-light the area without the removed light. light_sources to re-light the area without the removed light.
values of from_nodes are lighting values. values of from_nodes are lighting values.
There is a duplicate implementation of this in VoxelManipulator,
which is faster for large volumes
*/ */
void Map::unspreadLight(enum LightBank bank, void Map::unspreadLight(enum LightBank bank,
core::map<v3s16, u8> & from_nodes, core::map<v3s16, u8> & from_nodes,
@ -366,6 +369,9 @@ void Map::unLightNeighbors(enum LightBank bank,
/* /*
Lights neighbors of from_nodes, collects all them and then Lights neighbors of from_nodes, collects all them and then
goes on recursively. goes on recursively.
There is a duplicate implementation of this in VoxelManipulator,
which is faster for large volumes
*/ */
void Map::spreadLight(enum LightBank bank, void Map::spreadLight(enum LightBank bank,
core::map<v3s16, bool> & from_nodes, core::map<v3s16, bool> & from_nodes,
@ -840,6 +846,8 @@ void Map::updateLighting(core::map<v3s16, MapBlock*> & a_blocks,
This is called after changing a node from transparent to opaque. This is called after changing a node from transparent to opaque.
The lighting value of the node should be left as-is after changing The lighting value of the node should be left as-is after changing
other values. This sets the lighting value to 0. other values. This sets the lighting value to 0.
NOTE: This takes almost no time, the slow one is updateMeshes.
*/ */
void Map::addNodeAndUpdate(v3s16 p, MapNode n, void Map::addNodeAndUpdate(v3s16 p, MapNode n,
core::map<v3s16, MapBlock*> &modified_blocks) core::map<v3s16, MapBlock*> &modified_blocks)
@ -1036,6 +1044,7 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
} }
/* /*
NOTE: This takes almost no time, the slow one is updateMeshes.
*/ */
void Map::removeNodeAndUpdate(v3s16 p, void Map::removeNodeAndUpdate(v3s16 p,
core::map<v3s16, MapBlock*> &modified_blocks) core::map<v3s16, MapBlock*> &modified_blocks)
@ -1982,7 +1991,7 @@ bool get_have_sand_ground(u64 seed, v2f p)
double sandnoise = noise2d_perlin( double sandnoise = noise2d_perlin(
0.5+(float)p.X/500, 0.5+(float)p.Y/500, 0.5+(float)p.X/500, 0.5+(float)p.Y/500,
seed+54290232, 6, 0.65); seed+54290232, 6, 0.65);
return (sandnoise > 0.8); return (sandnoise > 1.0);
} }
// -1->0, 0->1, 1->0 // -1->0, 0->1, 1->0
@ -4079,7 +4088,6 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
{ {
DSTACK(__FUNCTION_NAME); DSTACK(__FUNCTION_NAME);
/* /*
Don't generate if already fully generated Don't generate if already fully generated
*/ */
@ -4095,6 +4103,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
} }
} }
#if 0
dstream<<"generateChunkRaw(): Generating chunk " dstream<<"generateChunkRaw(): Generating chunk "
<<"("<<chunkpos.X<<","<<chunkpos.Y<<")" <<"("<<chunkpos.X<<","<<chunkpos.Y<<")"
<<std::endl; <<std::endl;
@ -4733,7 +4742,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
block->updateDayNightDiff(); block->updateDayNightDiff();
} }
} }
#endif
/* /*
Create chunk metadata Create chunk metadata
@ -4947,7 +4956,8 @@ MapSector * ServerMap::emergeSector(v2s16 p2d,
/* /*
NOTE: This is not used for main map generation, only for blocks NOTE: This is not used for main map generation, only for blocks
that are very high or low that are very high or low.
NOTE: Now it is used mainly. Might change in the future.
*/ */
MapBlock * ServerMap::generateBlock( MapBlock * ServerMap::generateBlock(
v3s16 p, v3s16 p,
@ -5130,17 +5140,14 @@ MapBlock * ServerMap::generateBlock(
float surface_y_f = 0; float surface_y_f = 0;
s16 surface_y = 0; s16 surface_y = 0;
if(turbulence_is_used == false) float noturb_surface_y_f = base_rock_level_2d(m_seed, real_p2d_f);
{ s16 noturb_surface_y = noturb_surface_y_f;
surface_y_f = base_rock_level_2d(m_seed, real_p2d_f),
surface_y = surface_y_f;
// Get some statistics of surface height // Get some statistics of surface height
if(surface_y < lowest_ground_y) if(noturb_surface_y < lowest_ground_y)
lowest_ground_y = surface_y; lowest_ground_y = noturb_surface_y;
if(surface_y > highest_ground_y) if(noturb_surface_y > highest_ground_y)
highest_ground_y = surface_y; highest_ground_y = noturb_surface_y;
}
for(s16 y0=0; y0<MAP_BLOCKSIZE; y0++) for(s16 y0=0; y0<MAP_BLOCKSIZE; y0++)
{ {
@ -5164,7 +5171,20 @@ MapBlock * ServerMap::generateBlock(
bool is_ground = false; bool is_ground = false;
v3f real_pos_f = intToFloat(real_pos, 1); v3f real_pos_f = intToFloat(real_pos, 1);
if(turbulence_is_used) bool turb_for_node = (turbulence_is_used
&& real_y >= TURBULENCE_BOTTOM_CUTOFF_Y);
bool is_cavern = false;
if(is_carved(m_seed, real_pos_f))
{
is_ground = false;
if(real_y < noturb_surface_y)
is_cavern = true;
}
else
{
if(turb_for_node)
{ {
double depth_guess; double depth_guess;
is_ground = is_base_ground(m_seed, is_ground = is_base_ground(m_seed,
@ -5182,9 +5202,9 @@ MapBlock * ServerMap::generateBlock(
} }
else else
{ {
if(is_carved(m_seed, real_pos_f)) surface_y = noturb_surface_y;
is_ground = false; }
else
is_ground = (real_y <= surface_y); is_ground = (real_y <= surface_y);
} }
@ -5192,7 +5212,7 @@ MapBlock * ServerMap::generateBlock(
if(is_ground == false) if(is_ground == false)
{ {
// If under water level, it's water // If under water level, it's water
if(real_y < WATER_LEVEL) if(real_y < WATER_LEVEL && !is_cavern)
{ {
n.d = water_material; n.d = water_material;
u8 dist = 16; u8 dist = 16;
@ -7181,8 +7201,6 @@ void ClientMap::expireMeshes(bool only_daynight_diffed)
void ClientMap::updateMeshes(v3s16 blockpos, u32 daynight_ratio) void ClientMap::updateMeshes(v3s16 blockpos, u32 daynight_ratio)
{ {
assert(mapType() == MAPTYPE_CLIENT);
try{ try{
v3s16 p = blockpos + v3s16(0,0,0); v3s16 p = blockpos + v3s16(0,0,0);
MapBlock *b = getBlockNoCreate(p); MapBlock *b = getBlockNoCreate(p);
@ -7208,25 +7226,41 @@ void ClientMap::updateMeshes(v3s16 blockpos, u32 daynight_ratio)
b->updateMesh(daynight_ratio); b->updateMesh(daynight_ratio);
} }
catch(InvalidPositionException &e){} catch(InvalidPositionException &e){}
/*// Trailing edge }
try{
v3s16 p = blockpos + v3s16(1,0,0); /*
MapBlock *b = getBlockNoCreate(p); Update mesh of block in which the node is, and if the node is at the
leading edge, update the appropriate leading blocks too.
*/
void ClientMap::updateNodeMeshes(v3s16 nodepos, u32 daynight_ratio)
{
v3s16 dirs[4] = {
v3s16(0,0,0),
v3s16(-1,0,0),
v3s16(0,-1,0),
v3s16(0,0,-1),
};
v3s16 blockposes[4];
for(u32 i=0; i<4; i++)
{
v3s16 np = nodepos + dirs[i];
blockposes[i] = getNodeBlockPos(np);
// Don't update mesh of block if it has been done already
bool already_updated = false;
for(u32 j=0; j<i; j++)
{
if(blockposes[j] == blockposes[i])
{
already_updated = true;
break;
}
}
if(already_updated)
continue;
// Update mesh
MapBlock *b = getBlockNoCreate(blockposes[i]);
b->updateMesh(daynight_ratio); b->updateMesh(daynight_ratio);
} }
catch(InvalidPositionException &e){}
try{
v3s16 p = blockpos + v3s16(0,1,0);
MapBlock *b = getBlockNoCreate(p);
b->updateMesh(daynight_ratio);
}
catch(InvalidPositionException &e){}
try{
v3s16 p = blockpos + v3s16(0,0,1);
MapBlock *b = getBlockNoCreate(p);
b->updateMesh(daynight_ratio);
}
catch(InvalidPositionException &e){}*/
} }
void ClientMap::PrintInfo(std::ostream &out) void ClientMap::PrintInfo(std::ostream &out)

View File

@ -679,7 +679,7 @@ public:
void updateMeshes(v3s16 blockpos, u32 daynight_ratio); void updateMeshes(v3s16 blockpos, u32 daynight_ratio);
// Update meshes that touch the node // Update meshes that touch the node
//void updateNodeMeshes(v3s16 nodepos, u32 daynight_ratio); void updateNodeMeshes(v3s16 nodepos, u32 daynight_ratio);
// For debug printing // For debug printing
virtual void PrintInfo(std::ostream &out); virtual void PrintInfo(std::ostream &out);

View File

@ -61,6 +61,17 @@ u32 TimeTaker::getTime()
return dtime; return dtime;
} }
const v3s16 g_6dirs[6] =
{
// +right, +top, +back
v3s16( 0, 0, 1), // back
v3s16( 0, 1, 0), // top
v3s16( 1, 0, 0), // right
v3s16( 0, 0,-1), // front
v3s16( 0,-1, 0), // bottom
v3s16(-1, 0, 0) // left
};
const v3s16 g_26dirs[26] = const v3s16 g_26dirs[26] =
{ {
// +right, +top, +back // +right, +top, +back

View File

@ -34,6 +34,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "exceptions.h" #include "exceptions.h"
#include "porting.h" #include "porting.h"
extern const v3s16 g_6dirs[6];
extern const v3s16 g_26dirs[26]; extern const v3s16 g_26dirs[26];
// 26th is (0,0,0) // 26th is (0,0,0)