Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/util/util_math.h
| Show First 20 Lines • Show All 332 Lines • ▼ Show 20 Lines | ccl_device_inline int floor_to_int(float f) | ||||
| return float_to_int(floorf(f)); | return float_to_int(floorf(f)); | ||||
| } | } | ||||
| ccl_device_inline int quick_floor_to_int(float x) | ccl_device_inline int quick_floor_to_int(float x) | ||||
| { | { | ||||
| return float_to_int(x) - ((x < 0) ? 1 : 0); | return float_to_int(x) - ((x < 0) ? 1 : 0); | ||||
| } | } | ||||
| ccl_device_inline float floorfrac(float x, int *i) | ccl_device_inline float floorfrac(float x, ccl_private int *i) | ||||
| { | { | ||||
| *i = quick_floor_to_int(x); | *i = quick_floor_to_int(x); | ||||
| return x - *i; | return x - *i; | ||||
| } | } | ||||
| ccl_device_inline int ceil_to_int(float f) | ccl_device_inline int ceil_to_int(float f) | ||||
| { | { | ||||
| return float_to_int(ceilf(f)); | return float_to_int(ceilf(f)); | ||||
| ▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | |||||
| template<class A, class B> A lerp(const A &a, const A &b, const B &t) | template<class A, class B> A lerp(const A &a, const A &b, const B &t) | ||||
| { | { | ||||
| return (A)(a * ((B)1 - t) + b * t); | return (A)(a * ((B)1 - t) + b * t); | ||||
| } | } | ||||
| /* Triangle */ | /* Triangle */ | ||||
| ccl_device_inline float triangle_area(const float3 &v1, const float3 &v2, const float3 &v3) | ccl_device_inline float triangle_area(ccl_private const float3 &v1, | ||||
| ccl_private const float3 &v2, | |||||
| ccl_private const float3 &v3) | |||||
| { | { | ||||
| return len(cross(v3 - v2, v1 - v2)) * 0.5f; | return len(cross(v3 - v2, v1 - v2)) * 0.5f; | ||||
| } | } | ||||
| /* Orthonormal vectors */ | /* Orthonormal vectors */ | ||||
| ccl_device_inline void make_orthonormals(const float3 N, float3 *a, float3 *b) | ccl_device_inline void make_orthonormals(const float3 N, | ||||
| ccl_private float3 *a, | |||||
| ccl_private float3 *b) | |||||
| { | { | ||||
| #if 0 | #if 0 | ||||
| if (fabsf(N.y) >= 0.999f) { | if (fabsf(N.y) >= 0.999f) { | ||||
| *a = make_float3(1, 0, 0); | *a = make_float3(1, 0, 0); | ||||
| *b = make_float3(0, 0, 1); | *b = make_float3(0, 0, 1); | ||||
| return; | return; | ||||
| } | } | ||||
| if (fabsf(N.z) >= 0.999f) { | if (fabsf(N.z) >= 0.999f) { | ||||
| ▲ Show 20 Lines • Show All 353 Lines • Show Last 20 Lines | |||||