Optimise functions from CNodeDefManager and VoxelManipulator
CNodeDefManager::get() VoxelManipulator::addArea()master
parent
ea404979e1
commit
d406ac994b
|
@ -65,8 +65,9 @@ void MeshMakeData::fill(MapBlock *block)
|
||||||
|
|
||||||
// Allocate this block + neighbors
|
// Allocate this block + neighbors
|
||||||
m_vmanip.clear();
|
m_vmanip.clear();
|
||||||
m_vmanip.addArea(VoxelArea(blockpos_nodes-v3s16(1,1,1)*MAP_BLOCKSIZE,
|
VoxelArea voxel_area(blockpos_nodes - v3s16(1,1,1) * MAP_BLOCKSIZE,
|
||||||
blockpos_nodes+v3s16(1,1,1)*MAP_BLOCKSIZE*2-v3s16(1,1,1)));
|
blockpos_nodes + v3s16(1,1,1) * MAP_BLOCKSIZE*2-v3s16(1,1,1));
|
||||||
|
m_vmanip.addArea(voxel_area);
|
||||||
|
|
||||||
{
|
{
|
||||||
//TimeTaker timer("copy central block data");
|
//TimeTaker timer("copy central block data");
|
||||||
|
|
|
@ -389,8 +389,8 @@ public:
|
||||||
virtual ~CNodeDefManager();
|
virtual ~CNodeDefManager();
|
||||||
void clear();
|
void clear();
|
||||||
virtual IWritableNodeDefManager *clone();
|
virtual IWritableNodeDefManager *clone();
|
||||||
virtual const ContentFeatures& get(content_t c) const;
|
inline virtual const ContentFeatures& get(content_t c) const;
|
||||||
virtual const ContentFeatures& get(const MapNode &n) const;
|
inline virtual const ContentFeatures& get(const MapNode &n) const;
|
||||||
virtual bool getId(const std::string &name, content_t &result) const;
|
virtual bool getId(const std::string &name, content_t &result) const;
|
||||||
virtual content_t getId(const std::string &name) const;
|
virtual content_t getId(const std::string &name) const;
|
||||||
virtual void getIds(const std::string &name, std::set<content_t> &result) const;
|
virtual void getIds(const std::string &name, std::set<content_t> &result) const;
|
||||||
|
@ -530,16 +530,14 @@ IWritableNodeDefManager *CNodeDefManager::clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const ContentFeatures& CNodeDefManager::get(content_t c) const
|
inline const ContentFeatures& CNodeDefManager::get(content_t c) const
|
||||||
{
|
{
|
||||||
if (c < m_content_features.size())
|
return c < m_content_features.size()
|
||||||
return m_content_features[c];
|
? m_content_features[c] : m_content_features[CONTENT_UNKNOWN];
|
||||||
else
|
|
||||||
return m_content_features[CONTENT_UNKNOWN];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const ContentFeatures& CNodeDefManager::get(const MapNode &n) const
|
inline const ContentFeatures& CNodeDefManager::get(const MapNode &n) const
|
||||||
{
|
{
|
||||||
return get(n.getContent());
|
return get(n.getContent());
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ void VoxelManipulator::print(std::ostream &o, INodeDefManager *ndef,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelManipulator::addArea(VoxelArea area)
|
void VoxelManipulator::addArea(const VoxelArea &area)
|
||||||
{
|
{
|
||||||
// Cancel if requested area has zero volume
|
// Cancel if requested area has zero volume
|
||||||
if(area.getExtent() == v3s16(0,0,0))
|
if(area.getExtent() == v3s16(0,0,0))
|
||||||
|
@ -310,7 +310,8 @@ void VoxelManipulator::unspreadLight(enum LightBank bank, v3s16 p, u8 oldlight,
|
||||||
v3s16(-1,0,0), // left
|
v3s16(-1,0,0), // left
|
||||||
};
|
};
|
||||||
|
|
||||||
addArea(VoxelArea(p - v3s16(1,1,1), p + v3s16(1,1,1)));
|
VoxelArea voxel_area(p - v3s16(1,1,1), p + v3s16(1,1,1));
|
||||||
|
addArea(voxel_area);
|
||||||
|
|
||||||
// Loop through 6 neighbors
|
// Loop through 6 neighbors
|
||||||
for(u16 i=0; i<6; i++)
|
for(u16 i=0; i<6; i++)
|
||||||
|
@ -515,7 +516,8 @@ void VoxelManipulator::spreadLight(enum LightBank bank, v3s16 p,
|
||||||
v3s16(-1,0,0), // left
|
v3s16(-1,0,0), // left
|
||||||
};
|
};
|
||||||
|
|
||||||
addArea(VoxelArea(p - v3s16(1,1,1), p + v3s16(1,1,1)));
|
VoxelArea voxel_area(p - v3s16(1,1,1), p + v3s16(1,1,1));
|
||||||
|
addArea(voxel_area);
|
||||||
|
|
||||||
u32 i = m_area.index(p);
|
u32 i = m_area.index(p);
|
||||||
|
|
||||||
|
@ -619,7 +621,8 @@ void VoxelManipulator::spreadLight(enum LightBank bank,
|
||||||
{
|
{
|
||||||
v3s16 pos = *j;
|
v3s16 pos = *j;
|
||||||
|
|
||||||
addArea(VoxelArea(pos - v3s16(1,1,1), pos + v3s16(1,1,1)));
|
VoxelArea voxel_area(pos - v3s16(1,1,1), pos + v3s16(1,1,1));
|
||||||
|
addArea(voxel_area);
|
||||||
|
|
||||||
u32 i = m_area.index(pos);
|
u32 i = m_area.index(pos);
|
||||||
|
|
||||||
|
|
20
src/voxel.h
20
src/voxel.h
|
@ -80,7 +80,7 @@ public:
|
||||||
Modifying methods
|
Modifying methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void addArea(VoxelArea &a)
|
void addArea(const VoxelArea &a)
|
||||||
{
|
{
|
||||||
if(getExtent() == v3s16(0,0,0))
|
if(getExtent() == v3s16(0,0,0))
|
||||||
{
|
{
|
||||||
|
@ -94,7 +94,7 @@ public:
|
||||||
if(a.MaxEdge.Y > MaxEdge.Y) MaxEdge.Y = a.MaxEdge.Y;
|
if(a.MaxEdge.Y > MaxEdge.Y) MaxEdge.Y = a.MaxEdge.Y;
|
||||||
if(a.MaxEdge.Z > MaxEdge.Z) MaxEdge.Z = a.MaxEdge.Z;
|
if(a.MaxEdge.Z > MaxEdge.Z) MaxEdge.Z = a.MaxEdge.Z;
|
||||||
}
|
}
|
||||||
void addPoint(v3s16 p)
|
void addPoint(const v3s16 &p)
|
||||||
{
|
{
|
||||||
if(getExtent() == v3s16(0,0,0))
|
if(getExtent() == v3s16(0,0,0))
|
||||||
{
|
{
|
||||||
|
@ -111,7 +111,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pad with d nodes
|
// Pad with d nodes
|
||||||
void pad(v3s16 d)
|
void pad(const v3s16 &d)
|
||||||
{
|
{
|
||||||
MinEdge -= d;
|
MinEdge -= d;
|
||||||
MaxEdge += d;
|
MaxEdge += d;
|
||||||
|
@ -366,7 +366,8 @@ public:
|
||||||
*/
|
*/
|
||||||
MapNode getNode(v3s16 p)
|
MapNode getNode(v3s16 p)
|
||||||
{
|
{
|
||||||
addArea(p);
|
VoxelArea voxel_area(p);
|
||||||
|
addArea(voxel_area);
|
||||||
|
|
||||||
if(m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA)
|
if(m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA)
|
||||||
{
|
{
|
||||||
|
@ -383,7 +384,8 @@ public:
|
||||||
}
|
}
|
||||||
MapNode getNodeNoEx(v3s16 p)
|
MapNode getNodeNoEx(v3s16 p)
|
||||||
{
|
{
|
||||||
addArea(p);
|
VoxelArea voxel_area(p);
|
||||||
|
addArea(voxel_area);
|
||||||
|
|
||||||
if(m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA)
|
if(m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA)
|
||||||
{
|
{
|
||||||
|
@ -417,7 +419,8 @@ public:
|
||||||
}
|
}
|
||||||
MapNode & getNodeRef(v3s16 p)
|
MapNode & getNodeRef(v3s16 p)
|
||||||
{
|
{
|
||||||
addArea(p);
|
VoxelArea voxel_area(p);
|
||||||
|
addArea(voxel_area);
|
||||||
if(getFlagsRefUnsafe(p) & VOXELFLAG_NO_DATA)
|
if(getFlagsRefUnsafe(p) & VOXELFLAG_NO_DATA)
|
||||||
{
|
{
|
||||||
/*dstream<<"EXCEPT: VoxelManipulator::getNode(): "
|
/*dstream<<"EXCEPT: VoxelManipulator::getNode(): "
|
||||||
|
@ -432,7 +435,8 @@ public:
|
||||||
}
|
}
|
||||||
void setNode(v3s16 p, const MapNode &n)
|
void setNode(v3s16 p, const MapNode &n)
|
||||||
{
|
{
|
||||||
addArea(p);
|
VoxelArea voxel_area(p);
|
||||||
|
addArea(voxel_area);
|
||||||
|
|
||||||
m_data[m_area.index(p)] = n;
|
m_data[m_area.index(p)] = n;
|
||||||
m_flags[m_area.index(p)] &= ~VOXELFLAG_NO_DATA;
|
m_flags[m_area.index(p)] &= ~VOXELFLAG_NO_DATA;
|
||||||
|
@ -499,7 +503,7 @@ public:
|
||||||
void print(std::ostream &o, INodeDefManager *nodemgr,
|
void print(std::ostream &o, INodeDefManager *nodemgr,
|
||||||
VoxelPrintMode mode=VOXELPRINT_MATERIAL);
|
VoxelPrintMode mode=VOXELPRINT_MATERIAL);
|
||||||
|
|
||||||
void addArea(VoxelArea area);
|
void addArea(const VoxelArea &area);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copy data and set flags to 0
|
Copy data and set flags to 0
|
||||||
|
|
Loading…
Reference in New Issue