本文整理汇总了C++中AABBox::Max方法的典型用法代码示例。如果您正苦于以下问题:C++ AABBox::Max方法的具体用法?C++ AABBox::Max怎么用?C++ AABBox::Max使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AABBox
的用法示例。
在下文中一共展示了AABBox::Max方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DivideNode
void OCTree::DivideNode(size_t index, uint32_t curr_depth)
{
if (octree_[index].obj_ptrs.size() > 1)
{
size_t const this_size = octree_.size();
AABBox const parent_bb = octree_[index].bb;
float3 const parent_center = parent_bb.Center();
octree_[index].first_child_index = static_cast<int>(this_size);
octree_[index].visible = BO_No;
octree_.resize(this_size + 8);
for (SceneObjsType::const_reference so : octree_[index].obj_ptrs)
{
AABBox const & aabb = *so->PosBoundWS();
int mark[6];
mark[0] = aabb.Min().x() >= parent_center.x() ? 1 : 0;
mark[1] = aabb.Min().y() >= parent_center.y() ? 2 : 0;
mark[2] = aabb.Min().z() >= parent_center.z() ? 4 : 0;
mark[3] = aabb.Max().x() >= parent_center.x() ? 1 : 0;
mark[4] = aabb.Max().y() >= parent_center.y() ? 2 : 0;
mark[5] = aabb.Max().z() >= parent_center.z() ? 4 : 0;
for (int j = 0; j < 8; ++ j)
{
if (j == ((j & 1) ? mark[3] : mark[0])
+ ((j & 2) ? mark[4] : mark[1])
+ ((j & 4) ? mark[5] : mark[2]))
{
octree_[this_size + j].obj_ptrs.push_back(so);
}
}
}
for (size_t j = 0; j < 8; ++ j)
{
octree_node_t& new_node = octree_[this_size + j];
new_node.first_child_index = -1;
new_node.bb = AABBox(float3((j & 1) ? parent_center.x() : parent_bb.Min().x(),
(j & 2) ? parent_center.y() : parent_bb.Min().y(),
(j & 4) ? parent_center.z() : parent_bb.Min().z()),
float3((j & 1) ? parent_bb.Max().x() : parent_center.x(),
(j & 2) ? parent_bb.Max().y() : parent_center.y(),
(j & 4) ? parent_bb.Max().z() : parent_center.z()));
if (curr_depth < max_tree_depth_)
{
this->DivideNode(this_size + j, curr_depth + 1);
}
}
SceneObjsType empty;
octree_[index].obj_ptrs.swap(empty);
}
}
示例2: BoundVisible
BoundOverlap OCTree::BoundVisible(size_t index, AABBox const & aabb) const
{
BOOST_ASSERT(index < octree_.size());
octree_node_t const & node = octree_[index];
if ((node.visible != BO_No) && MathLib::intersect_aabb_aabb(node.bb, aabb))
{
if (BO_Yes == node.visible)
{
return BO_Yes;
}
else
{
BOOST_ASSERT(BO_Partial == node.visible);
if (node.first_child_index != -1)
{
float3 const center = node.bb.Center();
int mark[6];
mark[0] = aabb.Min().x() >= center.x() ? 1 : 0;
mark[1] = aabb.Min().y() >= center.y() ? 2 : 0;
mark[2] = aabb.Min().z() >= center.z() ? 4 : 0;
mark[3] = aabb.Max().x() >= center.x() ? 1 : 0;
mark[4] = aabb.Max().y() >= center.y() ? 2 : 0;
mark[5] = aabb.Max().z() >= center.z() ? 4 : 0;
for (int j = 0; j < 8; ++ j)
{
if (j == ((j & 1) ? mark[3] : mark[0])
+ ((j & 2) ? mark[4] : mark[1])
+ ((j & 4) ? mark[5] : mark[2]))
{
BoundOverlap const bo = this->BoundVisible(node.first_child_index + j, aabb);
if (bo != BO_No)
{
return bo;
}
}
}
return BO_No;
}
else
{
return BO_Partial;
}
}
}
else
{
return BO_No;
}
}
示例3: UpdateCascades
void PSSMCascadedShadowLayer::UpdateCascades(Camera const & camera, float4x4 const & light_view_proj,
float3 const & light_space_border)
{
float const range = camera.FarPlane() - camera.NearPlane();
float const ratio = camera.FarPlane() / camera.NearPlane();
std::vector<float> distances(intervals_.size() + 1);
for (size_t i = 0; i < intervals_.size(); ++ i)
{
float p = i / static_cast<float>(intervals_.size());
float log = camera.NearPlane() * std::pow(ratio, p);
float uniform = camera.NearPlane() + range * p;
distances[i] = lambda_ * (log - uniform) + uniform;
}
distances[intervals_.size()] = camera.FarPlane();
for (size_t i = 0; i < intervals_.size(); ++ i)
{
AABBox aabb = CalcFrustumExtents(camera, distances[i], distances[i + 1],
light_view_proj);
aabb &= AABBox(float3(-1, -1, -1), float3(+1, +1, +1));
aabb.Min() -= light_space_border;
aabb.Max() += light_space_border;
aabb.Min().x() = +aabb.Min().x() * 0.5f + 0.5f;
aabb.Min().y() = -aabb.Min().y() * 0.5f + 0.5f;
aabb.Max().x() = +aabb.Max().x() * 0.5f + 0.5f;
aabb.Max().y() = -aabb.Max().y() * 0.5f + 0.5f;
std::swap(aabb.Min().y(), aabb.Max().y());
float3 const scale = float3(1.0f, 1.0f, 1.0f) / (aabb.Max() - aabb.Min());
float3 const bias = -aabb.Min() * scale;
intervals_[i] = float2(distances[i], distances[i + 1]);
scales_[i] = scale;
biases_[i] = bias;
}
this->UpdateCropMats();
}