本文整理汇总了C++中VoxelManipulator::flowWater方法的典型用法代码示例。如果您正苦于以下问题:C++ VoxelManipulator::flowWater方法的具体用法?C++ VoxelManipulator::flowWater怎么用?C++ VoxelManipulator::flowWater使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VoxelManipulator
的用法示例。
在下文中一共展示了VoxelManipulator::flowWater方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
//.........这里部分代码省略.........
/*
VoxelManipulator
*/
VoxelManipulator v;
v.print(infostream);
infostream<<"*** Setting (-1,0,-1)=2 ***"<<std::endl;
v.setNodeNoRef(v3s16(-1,0,-1), MapNode(2));
v.print(infostream);
assert(v.getNode(v3s16(-1,0,-1)).getContent() == 2);
infostream<<"*** Reading from inexistent (0,0,-1) ***"<<std::endl;
EXCEPTION_CHECK(InvalidPositionException, v.getNode(v3s16(0,0,-1)));
v.print(infostream);
infostream<<"*** Adding area ***"<<std::endl;
v.addArea(a);
v.print(infostream);
assert(v.getNode(v3s16(-1,0,-1)).getContent() == 2);
EXCEPTION_CHECK(InvalidPositionException, v.getNode(v3s16(0,1,1)));
#if 0
/*
Water stuff
*/
v.clear();
const char *content =
"#...###### "
"#...##..## "
"#........ .."
"############"
"#...###### "
"#...##..## "
"#........# "
"############"
;
v3s16 size(12, 4, 2);
VoxelArea area(v3s16(0,0,0), size-v3s16(1,1,1));
const char *p = content;
for(s16 z=0; z<size.Z; z++)
for(s16 y=size.Y-1; y>=0; y--)
for(s16 x=0; x<size.X; x++)
{
MapNode n;
//n.pressure = size.Y - y;
if(*p == '#')
n.setContent(CONTENT_STONE);
else if(*p == '.')
n.setContent(CONTENT_WATER);
else if(*p == ' ')
n.setContent(CONTENT_AIR);
else
assert(0);
v.setNode(v3s16(x,y,z), n);
p++;
}
v.print(infostream, VOXELPRINT_WATERPRESSURE);
core::map<v3s16, u8> active_nodes;
v.updateAreaWaterPressure(area, active_nodes);
v.print(infostream, VOXELPRINT_WATERPRESSURE);
//s16 highest_y = -32768;
/*
NOTE: These are commented out because this behaviour is changed
all the time
*/
//assert(v.getWaterPressure(v3s16(7, 1, 1), highest_y, 0) == -1);
//assert(highest_y == 3);
/*assert(v.getWaterPressure(v3s16(7, 1, 1), highest_y, 0) == 3);
//assert(highest_y == 3);*/
active_nodes.clear();
active_nodes[v3s16(9,1,0)] = 1;
//v.flowWater(active_nodes, 0, true, 1000);
v.flowWater(active_nodes, 0, false, 1000);
infostream<<"Final result of flowWater:"<<std::endl;
v.print(infostream, VOXELPRINT_WATERPRESSURE);
#endif
//assert(0);
}