本文整理汇总了C++中vec3::Y方法的典型用法代码示例。如果您正苦于以下问题:C++ vec3::Y方法的具体用法?C++ vec3::Y怎么用?C++ vec3::Y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec3
的用法示例。
在下文中一共展示了vec3::Y方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
int ComputeBoxVisibility(const vec3& min, const vec3& max, const ViewState& s, int ClipHint)
// Returns a visibility code indicating whether the axis-aligned box defined by {min, max} is
// completely inside the frustum, completely outside the frustum, or partially in.
// The return value corresponds to ClipHint. The first six bits in ClipHint correspond
// to flags for each frustum plane; if a bit is set, that means the box is known to
// be inside the corresponding plane, so no additional test is needed.
{
// Doesn't do a perfect test for NOT_VISIBLE. Checks each
// box vertex against each frustum plane.
// Check each vertex of the box against the view frustum, and compute
// bit codes for whether the point is outside each plane.
int OrCodes = 0, AndCodes = ~0;
for (int i = 0; i < 8; i++) {
vec3 v(min), w;
if (i & 1) v.SetX(max.X());
if (i & 2) v.SetY(max.Y());
if (i & 4) v.SetZ(max.Z());
s.ViewMatrix.Apply(&w, v); // May need to pull matrix out of gl
// Now check against the frustum planes.
int Code = ClipHint;
int Bit = 1;
for (int j = 0; j < 6; j++, Bit <<= 1) {
if ((ClipHint & Bit) == 0) {
if (w * s.ClipPlane[j].Normal > s.ClipPlane[j].D) {
// The point is inside this plane.
Code |= Bit;
}
}
}
OrCodes |= Code;
AndCodes &= Code;
}
// Based on bit-codes, return culling results.
if (OrCodes != 0x3F) {
// All verts are outside (at least) one of the planes.
return NOT_VISIBLE;
} else if (AndCodes == 0x3F) {
// All verts are inside all planes.
return NO_CLIP;
} else {
// All verts possibly inside some planes.
return AndCodes;
}
}