本文整理汇总了C++中QuadTree::sampleHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ QuadTree::sampleHeight方法的具体用法?C++ QuadTree::sampleHeight怎么用?C++ QuadTree::sampleHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QuadTree
的用法示例。
在下文中一共展示了QuadTree::sampleHeight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plantGrass
void GrassField::plantGrass(i32 lodLevel, QuadTree &QT){
patchData.emplace_back();
fieldIds[lodLevel] = patchData.size()-1;
patchDataOwner.push_back(this);
noOfpatchData++;
std::default_random_engine generator(lodLevel + owner->id);
std::uniform_real_distribution<float> x(center.x + size.x, center.x - size.x);
std::uniform_real_distribution<float> y(center.y + size.y, center.y - size.y);
std::uniform_real_distribution<float> fallofFix(2.f, 10.f);
auto sample = [&, this](glm::vec4 &position) -> bool {
auto result = QT.sampleHeight(position, owner);
position.z = result.position.z - (1 - result.normal.z)*2;
position.w = 0.f;
if(result.normal.z < 0.93) position.z = -100000;
return result.normal.z > 0.9;
};
u32 failureCount(0), maxFailures(2);
for(u32 i=0; i<NO_OF_GRASS_PATCHES_IN_FIELD; i++){
auto &patch = patchData.back()[i];
patch.position = glm::vec4(x(generator), y(generator), 0, 0);
if(not sample(patch.position)){
// if(not sample(patch.position) && failureCount++ < maxFailures){
// i--;
patch.size = 0;
}
else if(failureCount >= maxFailures){ /// skip patch
failureCount = 0;
continue;
}
else {
patch.size = 1;
// patch.size = 2;
patch.fallof = lodDistances[lodLevel]-fallofFix(generator);
}
}
}