提交 a417e141 编写于 作者: M Matt Pharr

Inline LightBounds Union() method.

This speeds up light BVH builds by ~20%.
上级 1cc11a8e
......@@ -101,24 +101,6 @@ std::string LightBounds::ToString() const {
}
// LightBounds Method Definitions
LightBounds Union(const LightBounds &a, const LightBounds &b) {
// If one _LightBounds_ has zero power, return the other
if (a.phi == 0)
return b;
if (b.phi == 0)
return a;
// Find average direction and updated angles for _LightBounds_
DirectionCone cone =
Union(DirectionCone(a.w, a.cosTheta_o), DirectionCone(b.w, b.cosTheta_o));
Float cosTheta_o = cone.cosTheta;
Float cosTheta_e = std::min(a.cosTheta_e, b.cosTheta_e);
// Return final _LightBounds_ union
return LightBounds(Union(a.bounds, b.bounds), cone.w, a.phi + b.phi, cosTheta_o,
cosTheta_e, a.twoSided | b.twoSided);
}
Float LightBounds::Importance(Point3f p, Normal3f n) const {
// Return importance for light bounds at reference point
// Compute clamped squared distance to reference point
......
......@@ -133,7 +133,23 @@ inline LightBounds::LightBounds(const Bounds3f &b, Vector3f w, Float phi,
cosTheta_e(cosTheta_e),
twoSided(twoSided) {}
LightBounds Union(const LightBounds &a, const LightBounds &b);
inline LightBounds Union(const LightBounds &a, const LightBounds &b) {
// If one _LightBounds_ has zero power, return the other
if (a.phi == 0)
return b;
if (b.phi == 0)
return a;
// Find average direction and updated angles for _LightBounds_
DirectionCone cone =
Union(DirectionCone(a.w, a.cosTheta_o), DirectionCone(b.w, b.cosTheta_o));
Float cosTheta_o = cone.cosTheta;
Float cosTheta_e = std::min(a.cosTheta_e, b.cosTheta_e);
// Return final _LightBounds_ union
return LightBounds(Union(a.bounds, b.bounds), cone.w, a.phi + b.phi, cosTheta_o,
cosTheta_e, a.twoSided | b.twoSided);
}
// LightBase Definition
class LightBase {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册