some optimisations and tweaks

This commit is contained in:
darkrose 2014-08-18 02:37:05 +10:00
parent b87f39a8d7
commit 20ae2ead8f
5 changed files with 12 additions and 70 deletions

View File

@ -881,15 +881,6 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
block->deSerialize(istr, ser_version);
sector->insertBlock(block);
//DEBUG
/*NodeMod mod;
mod.type = NODEMOD_CHANGECONTENT;
mod.param = CONTENT_MESE;
block->setTempMod(v3s16(8,10,8), mod);
block->setTempMod(v3s16(8,9,8), mod);
block->setTempMod(v3s16(8,8,8), mod);
block->setTempMod(v3s16(8,7,8), mod);
block->setTempMod(v3s16(8,6,8), mod);*/
}
#if 0

View File

@ -249,10 +249,6 @@ TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir,
*/
NodeMod mod;
if (temp_mods.get(p, &mod)) {
if (mod == NODEMOD_CHANGECONTENT) {
MapNode mn2(mod.param);
spec = mn2.getTile(face_dir);
}
if (mod == NODEMOD_CRACK) {
/*
Get texture id, translate it to name, append stuff to
@ -306,10 +302,6 @@ TileSpec getMetaTile(MapNode mn, v3s16 p, v3s16 face_dir,
*/
NodeMod mod;
if (temp_mods.get(p, &mod)) {
if (mod == NODEMOD_CHANGECONTENT) {
MapNode mn2(mod.param);
spec = mn2.getMetaTile(face_dir);
}
if (mod == NODEMOD_CRACK) {
/*
Get texture id, translate it to name, append stuff to
@ -348,32 +340,6 @@ TileSpec getMetaTile(MapNode mn, v3s16 p, v3s16 face_dir,
return spec;
}
content_t getNodeContent(v3s16 p, MapNode mn, NodeModMap &temp_mods)
{
/*
Check temporary modifications on this node
*/
NodeMod mod;
if (temp_mods.get(p, &mod)) {
if(mod == NODEMOD_CHANGECONTENT)
return mod.param;
/*if(mod.type == NODEMOD_CRACK)
{
Content doesn't change.
face_contents works just like it should, because
there should not be faces between differently cracked
nodes.
If a semi-transparent node is cracked in front an
another one, it really doesn't matter whether there
is a cracked face drawn in between or not.
}*/
}
return mn.getContent();
}
v3s16 dirs8[8] = {
v3s16(0,0,0),
v3s16(0,0,1),
@ -468,14 +434,9 @@ void getTileInfo(
{
MapNode n0 = vmanip.getNodeNoEx(blockpos_nodes + p);
MapNode n1 = vmanip.getNodeNoEx(blockpos_nodes + p + face_dir);
TileSpec tile0 = getNodeTile(n0, p, face_dir, temp_mods);
TileSpec tile1 = getNodeTile(n1, p + face_dir, -face_dir, temp_mods);
// This is hackish
content_t content0 = getNodeContent(p, n0, temp_mods);
content_t content1 = getNodeContent(p + face_dir, n1, temp_mods);
bool equivalent = false;
u8 mf = face_contents(content0, content1, &equivalent);
u8 mf = face_contents(n0.getContent(), n1.getContent(), &equivalent);
if (mf == 0) {
makes_face = false;
@ -485,11 +446,11 @@ void getTileInfo(
makes_face = true;
if (mf == 1) {
tile = tile0;
tile = getNodeTile(n0, p, face_dir, temp_mods);
p_corrected = p;
face_dir_corrected = face_dir;
}else{
tile = tile1;
tile = getNodeTile(n1, p + face_dir, -face_dir, temp_mods);
p_corrected = p + face_dir;
face_dir_corrected = -face_dir;
}

View File

@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
enum NodeModType
{
NODEMOD_NONE = 0x0,
NODEMOD_CHANGECONTENT = 0x01, //param is content id
NODEMOD_UNUSED = 0x01, // used to be CHANGECONTENT - no longer used
NODEMOD_CRACK = 0x02, // param is crack progression
NODEMOD_SELECTION = 0x04 // param is ignored
};

View File

@ -186,11 +186,10 @@ void VoxelManipulator::addArea(VoxelArea area)
// Allocate and clear new data
MapNode *new_data = new MapNode[new_size];
assert(new_data);
u8 *new_flags = new u8[new_size];
for(s32 i=0; i<new_size; i++)
{
new_flags[i] = VOXELFLAG_NOT_LOADED;
}
assert(new_flags);
memset(new_flags, VOXELFLAG_INEXISTENT, new_size);
// Copy old data
@ -198,11 +197,12 @@ void VoxelManipulator::addArea(VoxelArea area)
for(s32 y=m_area.MinEdge.Y; y<=m_area.MaxEdge.Y; y++)
for(s32 x=m_area.MinEdge.X; x<=m_area.MaxEdge.X; x++)
{
unsigned int old_index = m_area.index(x,y,z);
// If loaded, copy data and flags
if((m_flags[m_area.index(x,y,z)] & VOXELFLAG_NOT_LOADED) == false)
{
new_data[new_area.index(x,y,z)] = m_data[m_area.index(x,y,z)];
new_flags[new_area.index(x,y,z)] = m_flags[m_area.index(x,y,z)];
if((m_flags[old_index] & VOXELFLAG_NOT_LOADED) == false) {
unsigned int new_index = new_area.index(x,y,z);
new_data[new_index] = m_data[old_index];
new_flags[new_index] = m_flags[old_index];
}
}

View File

@ -524,16 +524,6 @@ public:
{
//dstream<<"emerge p=("<<p.X<<","<<p.Y<<","<<p.Z<<")"<<std::endl;
addArea(a);
for(s32 z=a.MinEdge.Z; z<=a.MaxEdge.Z; z++)
for(s32 y=a.MinEdge.Y; y<=a.MaxEdge.Y; y++)
for(s32 x=a.MinEdge.X; x<=a.MaxEdge.X; x++)
{
s32 i = m_area.index(x,y,z);
// Don't touch nodes that have already been loaded
if(!(m_flags[i] & VOXELFLAG_NOT_LOADED))
continue;
m_flags[i] = VOXELFLAG_INEXISTENT;
}
}
/*