本文整理汇总了C++中VoxelArea::hasEmptyExtent方法的典型用法代码示例。如果您正苦于以下问题:C++ VoxelArea::hasEmptyExtent方法的具体用法?C++ VoxelArea::hasEmptyExtent怎么用?C++ VoxelArea::hasEmptyExtent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VoxelArea
的用法示例。
在下文中一共展示了VoxelArea::hasEmptyExtent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addArea
void VoxelManipulator::addArea(const VoxelArea &area)
{
// Cancel if requested area has zero volume
if (area.hasEmptyExtent())
return;
// Cancel if m_area already contains the requested area
if(m_area.contains(area))
return;
TimeTaker timer("addArea", &addarea_time);
// Calculate new area
VoxelArea new_area;
// New area is the requested area if m_area has zero volume
if(m_area.hasEmptyExtent())
{
new_area = area;
}
// Else add requested area to m_area
else
{
new_area = m_area;
new_area.addArea(area);
}
s32 new_size = new_area.getVolume();
/*dstream<<"adding area ";
area.print(dstream);
dstream<<", old area ";
m_area.print(dstream);
dstream<<", new area ";
new_area.print(dstream);
dstream<<", new_size="<<new_size;
dstream<<std::endl;*/
// Allocate new data and clear flags
MapNode *new_data = new MapNode[new_size];
assert(new_data);
u8 *new_flags = new u8[new_size];
assert(new_flags);
memset(new_flags, VOXELFLAG_NO_DATA, new_size);
// Copy old data
s32 old_x_width = m_area.MaxEdge.X - m_area.MinEdge.X + 1;
for(s32 z=m_area.MinEdge.Z; z<=m_area.MaxEdge.Z; z++)
for(s32 y=m_area.MinEdge.Y; y<=m_area.MaxEdge.Y; y++)
{
unsigned int old_index = m_area.index(m_area.MinEdge.X,y,z);
unsigned int new_index = new_area.index(m_area.MinEdge.X,y,z);
memcpy(&new_data[new_index], &m_data[old_index],
old_x_width * sizeof(MapNode));
memcpy(&new_flags[new_index], &m_flags[old_index],
old_x_width * sizeof(u8));
}
// Replace area, data and flags
m_area = new_area;
MapNode *old_data = m_data;
u8 *old_flags = m_flags;
/*dstream<<"old_data="<<(int)old_data<<", new_data="<<(int)new_data
<<", old_flags="<<(int)m_flags<<", new_flags="<<(int)new_flags<<std::endl;*/
m_data = new_data;
m_flags = new_flags;
delete[] old_data;
delete[] old_flags;
//dstream<<"addArea done"<<std::endl;
}