本文整理汇总了C++中Point3::isFinite方法的典型用法代码示例。如果您正苦于以下问题:C++ Point3::isFinite方法的具体用法?C++ Point3::isFinite怎么用?C++ Point3::isFinite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point3
的用法示例。
在下文中一共展示了Point3::isFinite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AABox
void ShadowMap::computeMatrices
(const shared_ptr<Light>& light,
AABox sceneBounds,
CFrame& lightFrame,
Projection& lightProjection,
Matrix4& lightProjectionMatrix,
float lightProjX,
float lightProjY,
float lightProjNearMin,
float lightProjFarMax,
float intensityCutoff) {
if (! sceneBounds.isFinite() || sceneBounds.isEmpty()) {
// Produce some reasonable bounds
sceneBounds = AABox(Point3(-20, -20, -20), Point3(20, 20, 20));
}
lightFrame = light->frame();
if (light->type() == Light::Type::DIRECTIONAL) {
Point3 center = sceneBounds.center();
if (! center.isFinite()) {
center = Point3::zero();
}
// Move directional light away from the scene. It must be far enough to see all objects
lightFrame.translation = -lightFrame.lookVector() *
min(1e6f, max(sceneBounds.extent().length() / 2.0f, lightProjNearMin, 30.0f)) + center;
}
const CFrame& f = lightFrame;
float lightProjNear = finf();
float lightProjFar = 0.0f;
// TODO: for a spot light, only consider objects this light can see
// Find nearest and farthest corners of the scene bounding box
for (int c = 0; c < 8; ++c) {
const Vector3& v = sceneBounds.corner(c);
const float distance = -f.pointToObjectSpace(v).z;
lightProjNear = min(lightProjNear, distance);
lightProjFar = max(lightProjFar, distance);
}
// Don't let the near get too close to the source, and obey
// the specified hint.
lightProjNear = max(lightProjNearMin, lightProjNear);
// Don't bother tracking shadows past the effective radius
lightProjFar = min(light->effectSphere(intensityCutoff).radius, lightProjFar);
lightProjFar = max(lightProjNear + 0.1f, min(lightProjFarMax, lightProjFar));
debugAssert(lightProjNear < lightProjFar);
if (light->type() != Light::Type::DIRECTIONAL) {
// TODO: Square spot
// Spot light; we can set the lightProj bounds intelligently
alwaysAssertM(light->spotHalfAngle() <= halfPi(), "Spot light with shadow map and greater than 180-degree bounds");
// The cutoff is half the angle of extent (See the Red Book, page 193)
const float angle = light->spotHalfAngle();
lightProjX = tan(angle) * lightProjNear;
// Symmetric in x and y
lightProjY = lightProjX;
lightProjectionMatrix =
Matrix4::perspectiveProjection
(-lightProjX, lightProjX, -lightProjY,
lightProjY, lightProjNear, lightProjFar);
} else if (light->type() == Light::Type::DIRECTIONAL) {
// Directional light
// Construct a projection and view matrix for the camera so we can
// render the scene from the light's point of view
//
// Since we're working with a directional light,
// we want to make the center of projection for the shadow map
// be in the direction of the light but at a finite distance
// to preserve z precision.
lightProjectionMatrix =
Matrix4::orthogonalProjection
(-lightProjX, lightProjX, -lightProjY,
lightProjY, lightProjNear, lightProjFar);
} else {
// Omni light. Nothing good can happen here, but at least we
// generate something
lightProjectionMatrix =
Matrix4::perspectiveProjection
(-lightProjX, lightProjX, -lightProjY,
lightProjY, lightProjNear, lightProjFar);
}
//.........这里部分代码省略.........