本文整理汇总了C++中VoxelManipulator::setNodeNoRef方法的典型用法代码示例。如果您正苦于以下问题:C++ VoxelManipulator::setNodeNoRef方法的具体用法?C++ VoxelManipulator::setNodeNoRef怎么用?C++ VoxelManipulator::setNodeNoRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VoxelManipulator
的用法示例。
在下文中一共展示了VoxelManipulator::setNodeNoRef方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testVoxelManipulator
void TestVoxelManipulator::testVoxelManipulator(INodeDefManager *nodedef)
{
VoxelManipulator v;
v.print(infostream, nodedef);
infostream << "*** Setting (-1,0,-1)=2 ***" << std::endl;
v.setNodeNoRef(v3s16(-1,0,-1), MapNode(t_CONTENT_GRASS));
v.print(infostream, nodedef);
UASSERT(v.getNode(v3s16(-1,0,-1)).getContent() == t_CONTENT_GRASS);
infostream << "*** Reading from inexistent (0,0,-1) ***" << std::endl;
EXCEPTION_CHECK(InvalidPositionException, v.getNode(v3s16(0,0,-1)));
v.print(infostream, nodedef);
infostream << "*** Adding area ***" << std::endl;
VoxelArea a(v3s16(-1,-1,-1), v3s16(1,1,1));
v.addArea(a);
v.print(infostream, nodedef);
UASSERT(v.getNode(v3s16(-1,0,-1)).getContent() == t_CONTENT_GRASS);
EXCEPTION_CHECK(InvalidPositionException, v.getNode(v3s16(0,1,1)));
}
示例2: testClearLightAndCollectSources
void TestVoxelAlgorithms::testClearLightAndCollectSources(INodeDefManager *ndef)
{
VoxelManipulator v;
for (u16 z = 0; z < 3; z++)
for (u16 y = 0; y < 3; y++)
for (u16 x = 0; x < 3; x++) {
v3s16 p(x,y,z);
v.setNode(p, MapNode(CONTENT_AIR));
}
VoxelArea a(v3s16(0,0,0), v3s16(2,2,2));
v.setNodeNoRef(v3s16(0,0,0), MapNode(t_CONTENT_STONE));
v.setNodeNoRef(v3s16(1,1,1), MapNode(t_CONTENT_TORCH));
{
MapNode n(CONTENT_AIR);
n.setLight(LIGHTBANK_DAY, 1, ndef);
v.setNode(v3s16(1,1,2), n);
}
{
std::set<v3s16> light_sources;
std::map<v3s16, u8> unlight_from;
voxalgo::clearLightAndCollectSources(v, a, LIGHTBANK_DAY,
ndef, light_sources, unlight_from);
//v.print(dstream, ndef, VOXELPRINT_LIGHT_DAY);
UASSERT(v.getNode(v3s16(0,1,1)).getLight(LIGHTBANK_DAY, ndef) == 0);
UASSERT(light_sources.find(v3s16(1,1,1)) != light_sources.end());
UASSERT(light_sources.size() == 1);
UASSERT(unlight_from.find(v3s16(1,1,2)) != unlight_from.end());
UASSERT(unlight_from.size() == 1);
}
}
示例3: testPropogateSunlight
void TestVoxelAlgorithms::testPropogateSunlight(INodeDefManager *ndef)
{
VoxelManipulator v;
for (u16 z = 0; z < 3; z++)
for (u16 y = 0; y < 3; y++)
for (u16 x = 0; x < 3; x++) {
v3s16 p(x,y,z);
v.setNodeNoRef(p, MapNode(CONTENT_AIR));
}
VoxelArea a(v3s16(0,0,0), v3s16(2,2,2));
{
std::set<v3s16> light_sources;
voxalgo::setLight(v, a, 0, ndef);
voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight(
v, a, true, light_sources, ndef);
//v.print(dstream, ndef, VOXELPRINT_LIGHT_DAY);
UASSERT(res.bottom_sunlight_valid == true);
UASSERT(v.getNode(v3s16(1,1,1)).getLight(LIGHTBANK_DAY, ndef)
== LIGHT_SUN);
}
v.setNodeNoRef(v3s16(0,0,0), MapNode(t_CONTENT_STONE));
{
std::set<v3s16> light_sources;
voxalgo::setLight(v, a, 0, ndef);
voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight(
v, a, true, light_sources, ndef);
UASSERT(res.bottom_sunlight_valid == true);
UASSERT(v.getNode(v3s16(1,1,1)).getLight(LIGHTBANK_DAY, ndef)
== LIGHT_SUN);
}
{
std::set<v3s16> light_sources;
voxalgo::setLight(v, a, 0, ndef);
voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight(
v, a, false, light_sources, ndef);
UASSERT(res.bottom_sunlight_valid == true);
UASSERT(v.getNode(v3s16(2,0,2)).getLight(LIGHTBANK_DAY, ndef)
== 0);
}
v.setNodeNoRef(v3s16(1,3,2), MapNode(t_CONTENT_STONE));
{
std::set<v3s16> light_sources;
voxalgo::setLight(v, a, 0, ndef);
voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight(
v, a, true, light_sources, ndef);
UASSERT(res.bottom_sunlight_valid == true);
UASSERT(v.getNode(v3s16(1,1,2)).getLight(LIGHTBANK_DAY, ndef)
== 0);
}
{
std::set<v3s16> light_sources;
voxalgo::setLight(v, a, 0, ndef);
voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight(
v, a, false, light_sources, ndef);
UASSERT(res.bottom_sunlight_valid == true);
UASSERT(v.getNode(v3s16(1,0,2)).getLight(LIGHTBANK_DAY, ndef)
== 0);
}
{
MapNode n(CONTENT_AIR);
n.setLight(LIGHTBANK_DAY, 10, ndef);
v.setNodeNoRef(v3s16(1,-1,2), n);
}
{
std::set<v3s16> light_sources;
voxalgo::setLight(v, a, 0, ndef);
voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight(
v, a, true, light_sources, ndef);
UASSERT(res.bottom_sunlight_valid == true);
}
{
std::set<v3s16> light_sources;
voxalgo::setLight(v, a, 0, ndef);
voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight(
v, a, false, light_sources, ndef);
UASSERT(res.bottom_sunlight_valid == true);
}
{
MapNode n(CONTENT_AIR);
n.setLight(LIGHTBANK_DAY, LIGHT_SUN, ndef);
v.setNodeNoRef(v3s16(1,-1,2), n);
}
{
std::set<v3s16> light_sources;
voxalgo::setLight(v, a, 0, ndef);
voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight(
//.........这里部分代码省略.........
示例4: Run
void Run()
{
/*
VoxelArea
*/
VoxelArea a(v3s16(-1,-1,-1), v3s16(1,1,1));
assert(a.index(0,0,0) == 1*3*3 + 1*3 + 1);
assert(a.index(-1,-1,-1) == 0);
VoxelArea c(v3s16(-2,-2,-2), v3s16(2,2,2));
// An area that is 1 bigger in x+ and z-
VoxelArea d(v3s16(-2,-2,-3), v3s16(3,2,2));
core::list<VoxelArea> aa;
d.diff(c, aa);
// Correct results
core::array<VoxelArea> results;
results.push_back(VoxelArea(v3s16(-2,-2,-3),v3s16(3,2,-3)));
results.push_back(VoxelArea(v3s16(3,-2,-2),v3s16(3,2,2)));
assert(aa.size() == results.size());
infostream<<"Result of diff:"<<std::endl;
for(core::list<VoxelArea>::Iterator
i = aa.begin(); i != aa.end(); i++)
{
i->print(infostream);
infostream<<std::endl;
s32 j = results.linear_search(*i);
assert(j != -1);
results.erase(j, 1);
}
/*
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 == '.')
//.........这里部分代码省略.........