// Allocate this block + neighbors
m_vmanip.clear();
- m_vmanip.addArea(VoxelArea(blockpos_nodes-v3s16(1,1,1)*MAP_BLOCKSIZE,
- blockpos_nodes+v3s16(1,1,1)*MAP_BLOCKSIZE*2-v3s16(1,1,1)));
+ VoxelArea voxel_area(blockpos_nodes - v3s16(1,1,1) * MAP_BLOCKSIZE,
+ blockpos_nodes + v3s16(1,1,1) * MAP_BLOCKSIZE*2-v3s16(1,1,1));
+ m_vmanip.addArea(voxel_area);
{
//TimeTaker timer("copy central block data");
virtual ~CNodeDefManager();
void clear();
virtual IWritableNodeDefManager *clone();
- virtual const ContentFeatures& get(content_t c) const;
- virtual const ContentFeatures& get(const MapNode &n) const;
+ inline virtual const ContentFeatures& get(content_t c) const;
+ inline virtual const ContentFeatures& get(const MapNode &n) const;
virtual bool getId(const std::string &name, content_t &result) const;
virtual content_t getId(const std::string &name) const;
virtual void getIds(const std::string &name, std::set<content_t> &result) const;
}
-const ContentFeatures& CNodeDefManager::get(content_t c) const
+inline const ContentFeatures& CNodeDefManager::get(content_t c) const
{
- if (c < m_content_features.size())
- return m_content_features[c];
- else
- return m_content_features[CONTENT_UNKNOWN];
+ return c < m_content_features.size()
+ ? m_content_features[c] : 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());
}
}
}
-void VoxelManipulator::addArea(VoxelArea area)
+void VoxelManipulator::addArea(const VoxelArea &area)
{
// Cancel if requested area has zero volume
if(area.getExtent() == v3s16(0,0,0))
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
for(u16 i=0; i<6; i++)
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);
{
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);
Modifying methods
*/
- void addArea(VoxelArea &a)
+ void addArea(const VoxelArea &a)
{
if(getExtent() == v3s16(0,0,0))
{
if(a.MaxEdge.Y > MaxEdge.Y) MaxEdge.Y = a.MaxEdge.Y;
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))
{
}
// Pad with d nodes
- void pad(v3s16 d)
+ void pad(const v3s16 &d)
{
MinEdge -= d;
MaxEdge += d;
*/
MapNode getNode(v3s16 p)
{
- addArea(p);
+ VoxelArea voxel_area(p);
+ addArea(voxel_area);
if(m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA)
{
}
MapNode getNodeNoEx(v3s16 p)
{
- addArea(p);
+ VoxelArea voxel_area(p);
+ addArea(voxel_area);
if(m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA)
{
}
MapNode & getNodeRef(v3s16 p)
{
- addArea(p);
+ VoxelArea voxel_area(p);
+ addArea(voxel_area);
if(getFlagsRefUnsafe(p) & VOXELFLAG_NO_DATA)
{
/*dstream<<"EXCEPT: VoxelManipulator::getNode(): "
}
void setNode(v3s16 p, const MapNode &n)
{
- addArea(p);
+ VoxelArea voxel_area(p);
+ addArea(voxel_area);
m_data[m_area.index(p)] = n;
m_flags[m_area.index(p)] &= ~VOXELFLAG_NO_DATA;
void print(std::ostream &o, INodeDefManager *nodemgr,
VoxelPrintMode mode=VOXELPRINT_MATERIAL);
- void addArea(VoxelArea area);
+ void addArea(const VoxelArea &area);
/*
Copy data and set flags to 0