Skip to content

Commit 72429cb

Browse files
committed
refactor usage of angle adding
1 parent 1acf7d6 commit 72429cb

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

include/nbl/builtin/hlsl/sampling/spherical_rectangle.hlsl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ struct SphericalRectangle
4343
-n_z[3] * n_z[0]
4444
);
4545

46-
scalar_type p = math::getSumofArccosAB(cosGamma[0], cosGamma[1]);
47-
scalar_type q = math::getSumofArccosAB(cosGamma[2], cosGamma[3]);
46+
math::sincos_accumulator<scalar_type> angle_adder = math::sincos_accumulator<scalar_type>::create(cosGamma[0]);
47+
angle_adder.addCosine(cosGamma[1]);
48+
scalar_type p = angle_adder.getSumofArccos();
49+
angle_adder = math::sincos_accumulator<scalar_type>::create(cosGamma[2]);
50+
angle_adder.addCosine(cosGamma[3]);
51+
scalar_type q = angle_adder.getSumofArccos();
4852

4953
const scalar_type k = 2 * numbers::pi<scalar_type> - q;
5054
const scalar_type b0 = n_z[0];

include/nbl/builtin/hlsl/shapes/rectangle.hlsl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <nbl/builtin/hlsl/cpp_compat.hlsl>
99
#include <nbl/builtin/hlsl/numbers.hlsl>
1010
#include <nbl/builtin/hlsl/math/functions.hlsl>
11+
#include <nbl/builtin/hlsl/math/angle_adding.hlsl>
1112

1213
namespace nbl
1314
{
@@ -49,7 +50,11 @@ struct SphericalRectangle
4950
-n_z[2] * n_z[3],
5051
-n_z[3] * n_z[0]
5152
);
52-
return math::getSumofArccosABCD(cosGamma[0], cosGamma[1], cosGamma[2], cosGamma[3]) - 2 * numbers::pi<float>;
53+
math::sincos_accumulator<scalar_type> angle_adder = math::sincos_accumulator<scalar_type>::create(cosGamma[0]);
54+
angle_adder.addCosine(cosGamma[1]);
55+
angle_adder.addCosine(cosGamma[2]);
56+
angle_adder.addCosine(cosGamma[3]);
57+
return angle_adder.getSumofArccos() - scalar_type(2.0) * numbers::pi<float>;
5358
}
5459

5560
vector3_type r0;

0 commit comments

Comments
 (0)