Blender V5.3
transform.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#ifndef __KERNEL_GPU__
8# include <cstring>
9#endif
10
11#include "util/math.h"
12#include "util/types.h"
13
14#ifndef __KERNEL_GPU__
15# include "util/system.h"
16#endif
17
19
20/* Transform p from a local coordinate system (spanned by X and Y) into global coordinates. */
21template<class T> ccl_device_inline T to_global(const float2 p, const T X, const T Y)
22{
23 return p.x * X + p.y * Y;
24}
25
26/* Transform p from a local coordinate system (spanned by X, Y and Z) into global coordinates. */
27template<class T> ccl_device_inline T to_global(const float3 p, const T X, const T Y, const T Z)
28{
29 return p.x * X + p.y * Y + p.z * Z;
30}
31
32/* Transform p from global coordinates into a local coordinate system (spanned by X and Y). */
33template<class T> ccl_device_inline float2 to_local(const T p, const T X, const T Y)
34{
35 return make_float2(dot(p, X), dot(p, Y));
36}
37
38/* Transform p from global coordinates into a local coordinate system (spanned by X, Y and Z). */
39template<class T> ccl_device_inline float3 to_local(const T p, const T X, const T Y, const T Z)
40{
41 return make_float3(dot(p, X), dot(p, Y), dot(p, Z));
42}
43
44template<class T>
45ccl_device_inline dual3 to_local(const dual<T> p, const T X, const T Y, const T Z)
46{
47 return make_float3(dot(p, X), dot(p, Y), dot(p, Z));
48}
49
50/* Affine transformation, stored as 4x3 matrix. */
51
52struct Transform {
54
55#ifndef __KERNEL_GPU__
56 float4 operator[](int i) const
57 {
58 return *(&x + i);
59 }
61 {
62 return *(&x + i);
63 }
64#endif
65};
66
67/* Transform decomposed in rotation/translation/scale. we use the same data
68 * structure as Transform, and tightly pack decomposition into it. first the
69 * rotation (4), then translation (3), then 3x3 scale matrix (9). */
70
72 float4 x, y, z, w;
73};
74
75/* Functions */
76
77#ifdef __KERNEL_METAL__
78/* transform_point specialized for ccl_global */
80{
81 const ccl_global metal::float3x3 &b(*(const ccl_global metal::float3x3 *)t);
82 return (a * b).xyz + make_float3(t->x.w, t->y.w, t->z.w);
83}
84#endif
85
87{
88#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE2__)
89 const float4 aa(a.m128);
90 float4 x = t->x;
91 float4 y = t->y;
92 float4 z = t->z;
93 float4 w(_mm_set_ps(1.0f, 0.0f, 0.0f, 0.0f));
94 _MM_TRANSPOSE4_PS(x.m128, y.m128, z.m128, w.m128);
95 float4 tmp = w;
96 tmp = madd(shuffle<2>(aa), z, tmp);
97 tmp = madd(shuffle<1>(aa), y, tmp);
98 tmp = madd(shuffle<0>(aa), x, tmp);
99 return float3(tmp.m128);
100#else
101 const float4 a_ = make_homogeneous(a);
102 return make_float3(dot(a_, t->x), dot(a_, t->y), dot(a_, t->z));
103#endif
104}
105
107{
108#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE2__)
109 /* NOTE: `dot()` has large latency on Intel platforms, the following method of transpose + madd
110 * is faster. However, we did not measure on Neon platforms, it might be that `dot()` is fine
111 * there, and we can use the simpler implementation at the end of the function. */
112 float4 x = t->x;
113 float4 y = t->y;
114 float4 z = t->z;
115 float4 w(_mm_set_ps(1.0f, 0.0f, 0.0f, 0.0f));
116 _MM_TRANSPOSE4_PS(x.m128, y.m128, z.m128, w.m128);
117
118 float4 tmp = w;
119 dual3 result;
120 {
121 const float4 aa(a.val.m128);
122 tmp = madd(shuffle<2>(aa), z, tmp);
123 tmp = madd(shuffle<1>(aa), y, tmp);
124 tmp = madd(shuffle<0>(aa), x, tmp);
125 result.val = float3(tmp.m128);
126 }
127
128 {
129 const float4 dx(a.dx.m128);
130 tmp = shuffle<2>(dx) * z;
131 tmp = madd(shuffle<1>(dx), y, tmp);
132 tmp = madd(shuffle<0>(dx), x, tmp);
133 result.dx = float3(tmp.m128);
134 }
135
136 {
137 const float4 dy(a.dy.m128);
138 tmp = shuffle<2>(dy) * z;
139 tmp = madd(shuffle<1>(dy), y, tmp);
140 tmp = madd(shuffle<0>(dy), x, tmp);
141 result.dy = float3(tmp.m128);
142 }
143
144 return result;
145#else
146 const dual4 a_ = make_homogeneous(a);
147 return make_float3(dot(a_, t->x), dot(a_, t->y), dot(a_, t->z));
148#endif
149}
150
152{
153#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE2__)
154 const float4 aa(a.m128);
155 float4 x = t->x;
156 float4 y = t->y;
157 float4 z = t->z;
158 float4 w(_mm_setzero_ps());
159 _MM_TRANSPOSE4_PS(x.m128, y.m128, z.m128, w.m128);
160 float4 tmp = shuffle<2>(aa) * z;
161 tmp = madd(shuffle<1>(aa), y, tmp);
162 tmp = madd(shuffle<0>(aa), x, tmp);
163 return float3(tmp.m128);
164#else
165 const float4 a_ = make_float4(a, 0.0f);
166 return make_float3(dot(a_, t->x), dot(a_, t->y), dot(a_, t->z));
167#endif
168}
169
171{
172 return to_local(a, make_float3(t->x), make_float3(t->y), make_float3(t->z));
173}
174
175template<class T>
177{
178 const float3 x = make_float3(t->x.x, t->y.x, t->z.x);
179 const float3 y = make_float3(t->x.y, t->y.y, t->z.y);
180 const float3 z = make_float3(t->x.z, t->y.z, t->z.z);
181
182 return to_local(a, x, y, z);
183}
184
186 const float b,
187 const float c,
188 const float d,
189 const float e,
190 const float f,
191 const float g,
192 const float h,
193 const float i,
194 const float j,
195 const float k,
196 const float l)
197{
198 Transform t;
199
200 t.x.x = a;
201 t.x.y = b;
202 t.x.z = c;
203 t.x.w = d;
204 t.y.x = e;
205 t.y.y = f;
206 t.y.z = g;
207 t.y.w = h;
208 t.z.x = i;
209 t.z.y = j;
210 t.z.z = k;
211 t.z.w = l;
212
213 return t;
214}
215
217{
218 Transform t;
219
220 t.x = make_float4(x, 0.0f);
221 t.y = make_float4(y, 0.0f);
222 t.z = make_float4(z, 0.0f);
223
224 return t;
225}
226
228{
229 const float cx = cosf(euler.x);
230 const float cy = cosf(euler.y);
231 const float cz = cosf(euler.z);
232 const float sx = sinf(euler.x);
233 const float sy = sinf(euler.y);
234 const float sz = sinf(euler.z);
235
236 Transform t;
237 t.x.x = cy * cz;
238 t.y.x = cy * sz;
239 t.z.x = -sy;
240
241 t.x.y = sy * sx * cz - cx * sz;
242 t.y.y = sy * sx * sz + cx * cz;
243 t.z.y = cy * sx;
244
245 t.x.z = sy * cx * cz + sx * sz;
246 t.y.z = sy * cx * sz - sx * cz;
247 t.z.z = cy * cx;
248
249 t.x.w = t.y.w = t.z.w = 0.0f;
250 return t;
251}
252
253/* Constructs a coordinate frame from a normalized normal. */
255{
256 const float3 dx0 = cross(make_float3(1.0f, 0.0f, 0.0f), N);
257 const float3 dx1 = cross(make_float3(0.0f, 1.0f, 0.0f), N);
258 const float3 dx = normalize((dot(dx0, dx0) > dot(dx1, dx1)) ? dx0 : dx1);
259 const float3 dy = normalize(cross(N, dx));
260 return make_transform(dx.x, dx.y, dx.z, 0.0f, dy.x, dy.y, dy.z, 0.0f, N.x, N.y, N.z, 0.0f);
261}
262
263#if !defined(__KERNEL_METAL__)
265{
266 const float4 c_x = make_float4(b.x.x, b.y.x, b.z.x, 0.0f);
267 const float4 c_y = make_float4(b.x.y, b.y.y, b.z.y, 0.0f);
268 const float4 c_z = make_float4(b.x.z, b.y.z, b.z.z, 0.0f);
269 const float4 c_w = make_float4(b.x.w, b.y.w, b.z.w, 1.0f);
270
271 Transform t;
272 t.x = make_float4(dot(a.x, c_x), dot(a.x, c_y), dot(a.x, c_z), dot(a.x, c_w));
273 t.y = make_float4(dot(a.y, c_x), dot(a.y, c_y), dot(a.y, c_z), dot(a.y, c_w));
274 t.z = make_float4(dot(a.z, c_x), dot(a.z, c_y), dot(a.z, c_z), dot(a.z, c_w));
275
276 return t;
277}
278#endif
279
281{
283 return zero;
284}
285
286#ifndef __KERNEL_GPU__
287
288ccl_device_inline void print_transform(const char *label, const Transform &t)
289{
290 print_float4(label, t.x);
291 print_float4(label, t.y);
292 print_float4(label, t.z);
293 printf("\n");
294}
295
297{
298 return make_transform(1, 0, 0, t.x, 0, 1, 0, t.y, 0, 0, 1, t.z);
299}
300
301ccl_device_inline Transform transform_translate(const float x, const float y, float z)
302{
304}
305
307{
308 T.x.w += t.x;
309 T.y.w += t.y;
310 T.z.w += t.z;
311}
312
314{
315 return make_transform(s.x, 0, 0, 0, 0, s.y, 0, 0, 0, 0, s.z, 0);
316}
317
318ccl_device_inline Transform transform_scale(const float x, const float y, float z)
319{
320 return transform_scale(make_float3(x, y, z));
321}
322
324{
325 const float s = sinf(angle);
326 const float c = cosf(angle);
327 const float t = 1.0f - c;
328
329 axis = normalize(axis);
330
331 return make_transform(axis.x * axis.x * t + c,
332 axis.x * axis.y * t - s * axis.z,
333 axis.x * axis.z * t + s * axis.y,
334 0.0f,
335
336 axis.y * axis.x * t + s * axis.z,
337 axis.y * axis.y * t + c,
338 axis.y * axis.z * t - s * axis.x,
339 0.0f,
340
341 axis.z * axis.x * t - s * axis.y,
342 axis.z * axis.y * t + s * axis.x,
343 axis.z * axis.z * t + c,
344 0.0f);
345}
346
347/* Euler is assumed to be in XYZ order. */
349{
350 return transform_rotate(euler.z, make_float3(0.0f, 0.0f, 1.0f)) *
351 transform_rotate(euler.y, make_float3(0.0f, 1.0f, 0.0f)) *
352 transform_rotate(euler.x, make_float3(1.0f, 0.0f, 0.0f));
353}
354
356{
357 return transform_scale(1.0f, 1.0f, 1.0f);
358}
359
361{
362 /* Using memcmp because it returns true for NaN unlike component ==,
363 * which we need for set_if_different for node sockets to copy the value. */
364 return memcmp(&A, &B, sizeof(Transform)) == 0;
365}
366
368{
369 return !(A == B);
370}
371
373 const Transform &B,
374 const float threshold)
375{
376 for (int x = 0; x < 3; x++) {
377 for (int y = 0; y < 4; y++) {
378 if (fabsf(A[x][y] - B[x][y]) > threshold) {
379 return false;
380 }
381 }
382 }
383
384 return true;
385}
386
388{
389 return make_float3(t->x[column], t->y[column], t->z[column]);
390}
391
392ccl_device_inline void transform_set_column(Transform *t, const int column, const float3 value)
393{
394 t->x[column] = value.x;
395 t->y[column] = value.y;
396 t->z[column] = value.z;
397}
398
403
405
407{
408 /* the epsilon here is quite arbitrary, but this function is only used for
409 * surface area and bump, where we expect it to not be so sensitive */
410 const float eps = 1e-6f;
411
412 const float sx = len_squared(make_float3(tfm.x));
413 const float sy = len_squared(make_float3(tfm.y));
414 const float sz = len_squared(make_float3(tfm.z));
415 const float stx = len_squared(transform_get_column(&tfm, 0));
416 const float sty = len_squared(transform_get_column(&tfm, 1));
417 const float stz = len_squared(transform_get_column(&tfm, 2));
418
419 if (fabsf(sx - sy) < eps && fabsf(sx - sz) < eps && fabsf(sx - stx) < eps &&
420 fabsf(sx - sty) < eps && fabsf(sx - stz) < eps)
421 {
422 scale = sx;
423 return true;
424 }
425
426 return false;
427}
428
430{
431 const float3 c0 = transform_get_column(&tfm, 0);
432 const float3 c1 = transform_get_column(&tfm, 1);
433 const float3 c2 = transform_get_column(&tfm, 2);
434
435 return (dot(cross(c0, c1), c2) < 0.0f);
436}
437
439{
440 Transform ntfm = tfm;
441
445
446 return ntfm;
447}
448
450{
451 return make_transform(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
452}
453
454#endif
455
456/* Motion Transform */
457
458ccl_device_inline float4 quat_interpolate(const float4 q1, const float4 q2, const float t)
459{
460 /* Optix and MetalRT are using linear interpolation to interpolate motion transformations. */
461#if defined(__KERNEL_GPU_RAYTRACING__)
462 return normalize((1.0f - t) * q1 + t * q2);
463#else /* defined(__KERNEL_GPU_RAYTRACING__) */
464 /* NOTE: this does not ensure rotation around shortest angle, q1 and q2
465 * are assumed to be matched already in transform_motion_decompose */
466 const float costheta = dot(q1, q2);
467
468 /* possible optimization: it might be possible to precompute theta/qperp */
469
470 if (costheta > 0.9995f) {
471 /* linear interpolation in degenerate case */
472 return normalize((1.0f - t) * q1 + t * q2);
473 }
474 /* slerp */
475 const float theta = acosf(clamp(costheta, -1.0f, 1.0f));
476 const float4 qperp = normalize(q2 - q1 * costheta);
477 const float thetap = theta * t;
478 return q1 * cosf(thetap) + qperp * sinf(thetap);
479
480#endif /* defined(__KERNEL_GPU_RAYTRACING__) */
481}
482
483#ifndef __KERNEL_GPU__
484void transform_inverse_cpu_avx2(const Transform &tfm, Transform &itfm);
485#endif
486
487/* Custom cross and dot implementations that match Embree bit for bit.
488 * Normally we don't use SSE41/AVX outside the kernel, but for this it's
489 * important to match exactly for ray tracing precision. */
490
492{
493#if defined(__AVX2__) && defined(__KERNEL_SSE2__)
494 const __m128 a = (const __m128 &)a_;
495 const __m128 b = (const __m128 &)b_;
496 const __m128 a_shuffle = _mm_castsi128_ps(
497 _mm_shuffle_epi32(_mm_castps_si128(a), _MM_SHUFFLE(3, 0, 2, 1)));
498 const __m128 b_shuffle = _mm_castsi128_ps(
499 _mm_shuffle_epi32(_mm_castps_si128(b), _MM_SHUFFLE(3, 0, 2, 1)));
500 const __m128 r = _mm_castsi128_ps(
501 _mm_shuffle_epi32(_mm_castps_si128(_mm_fmsub_ps(a, b_shuffle, _mm_mul_ps(a_shuffle, b))),
502 _MM_SHUFFLE(3, 0, 2, 1)));
503 return (const float3 &)r;
504#endif
505
506 return cross(a_, b_);
507}
508
510{
511#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE42__)
512 const __m128 a = (const __m128 &)a_;
513 const __m128 b = (const __m128 &)b_;
514 return _mm_cvtss_f32(_mm_dp_ps(a, b, 0x7F));
515#endif
516
517 return dot(a_, b_);
518}
519
521{
522 /* This implementation matches the one in Embree exactly, to ensure consistent
523 * results with the ray intersection of instances. */
524 float3 x = make_float3(tfm.x.x, tfm.y.x, tfm.z.x);
525 float3 y = make_float3(tfm.x.y, tfm.y.y, tfm.z.y);
526 float3 z = make_float3(tfm.x.z, tfm.y.z, tfm.z.z);
527 const float3 w = make_float3(tfm.x.w, tfm.y.w, tfm.z.w);
528
529 /* Compute determinant. */
531
532 if (det == 0.0f) {
533 /* Matrix is degenerate (e.g. 0 scale on some axis), ideally we should
534 * never be in this situation, but try to invert it anyway with tweak.
535 *
536 * This logic does not match Embree which would just give an invalid
537 * matrix. A better solution would be to remove this and ensure any object
538 * matrix is valid. */
539 x.x += 1e-8f;
540 y.y += 1e-8f;
541 z.z += 1e-8f;
542
543 det = transform_inverse_dot(x, cross(y, z));
544 if (det == 0.0f) {
545 det = FLT_MAX;
546 }
547 }
548
549 /* Divide adjoint matrix by the determinant to compute inverse of 3x3 matrix. */
550 const float3 inverse_x = transform_inverse_cross(y, z) / det;
551 const float3 inverse_y = transform_inverse_cross(z, x) / det;
552 const float3 inverse_z = transform_inverse_cross(x, y) / det;
553
554 /* Compute translation and fill transform. */
555 Transform itfm;
556 itfm.x = make_float4(inverse_x, -transform_inverse_dot(inverse_x, w));
557 itfm.y = make_float4(inverse_y, -transform_inverse_dot(inverse_y, w));
558 itfm.z = make_float4(inverse_z, -transform_inverse_dot(inverse_z, w));
559
560 return itfm;
561}
562
564{
565 /* Optimized transform implementations. */
566#ifndef __KERNEL_GPU__
568 Transform itfm;
570 return itfm;
571 }
572#endif
573
574 return transform_inverse_impl(tfm);
575}
576
578 const ccl_private DecomposedTransform *decomp)
579{
580 /* rotation */
581 float q0;
582 float q1;
583 float q2;
584 float q3;
585 float qda;
586 float qdb;
587 float qdc;
588 float qaa;
589 float qab;
590 float qac;
591 float qbb;
592 float qbc;
593 float qcc;
594
595 q0 = M_SQRT2_F * decomp->x.w;
596 q1 = M_SQRT2_F * decomp->x.x;
597 q2 = M_SQRT2_F * decomp->x.y;
598 q3 = M_SQRT2_F * decomp->x.z;
599
600 qda = q0 * q1;
601 qdb = q0 * q2;
602 qdc = q0 * q3;
603 qaa = q1 * q1;
604 qab = q1 * q2;
605 qac = q1 * q3;
606 qbb = q2 * q2;
607 qbc = q2 * q3;
608 qcc = q3 * q3;
609
610 const float3 rotation_x = make_float3(1.0f - qbb - qcc, -qdc + qab, qdb + qac);
611 const float3 rotation_y = make_float3(qdc + qab, 1.0f - qaa - qcc, -qda + qbc);
612 const float3 rotation_z = make_float3(-qdb + qac, qda + qbc, 1.0f - qaa - qbb);
613
614 /* scale */
615 const float3 scale_x = make_float3(decomp->y.w, decomp->z.z, decomp->w.y);
616 const float3 scale_y = make_float3(decomp->z.x, decomp->z.w, decomp->w.z);
617 const float3 scale_z = make_float3(decomp->z.y, decomp->w.x, decomp->w.w);
618
619 /* compose with translation */
620 tfm->x = make_float4(
621 dot(rotation_x, scale_x), dot(rotation_x, scale_y), dot(rotation_x, scale_z), decomp->y.x);
622 tfm->y = make_float4(
623 dot(rotation_y, scale_x), dot(rotation_y, scale_y), dot(rotation_y, scale_z), decomp->y.y);
624 tfm->z = make_float4(
625 dot(rotation_z, scale_x), dot(rotation_z, scale_y), dot(rotation_z, scale_z), decomp->y.z);
626}
627
628/* Interpolate from array of decomposed transforms. */
630 const ccl_global DecomposedTransform *motion,
631 const int numsteps,
632 const float time)
633{
634 /* Figure out which steps we need to interpolate. */
635 const int maxstep = numsteps - 1;
636 const int step = min((int)(time * maxstep), maxstep - 1);
637 const float t = time * maxstep - step;
638
639 const ccl_global DecomposedTransform *a = motion + step;
640 const ccl_global DecomposedTransform *b = motion + step + 1;
641
642 /* Interpolate rotation, translation and scale. */
643 DecomposedTransform decomp;
644 decomp.x = quat_interpolate(a->x, b->x, t);
645 decomp.y = (1.0f - t) * a->y + t * b->y;
646 decomp.z = (1.0f - t) * a->z + t * b->z;
647 decomp.w = (1.0f - t) * a->w + t * b->w;
648
649 /* Compose rotation, translation, scale into matrix. */
650 transform_compose(tfm, &decomp);
651}
652
654{
655 return isfinite_safe(tfm->x) && isfinite_safe(tfm->y) && isfinite_safe(tfm->z);
656}
657
659{
660 return isfinite_safe(decomp->x) && isfinite_safe(decomp->y) && isfinite_safe(decomp->z) &&
661 isfinite_safe(decomp->w);
662}
663
664#ifndef __KERNEL_GPU__
665
666class BoundBox2D;
667
669{
670 return memcmp(&A, &B, sizeof(DecomposedTransform)) == 0;
671}
672
673/* NOTE: quaternion (w, x, y, z) is stored as float4(x, y, z, w). */
676 const Transform *motion,
677 const size_t size);
679
680#endif
681
682/* Packed Transform.
683 *
684 * Transform type with no alignment requirements.
685 * It does not support any mathematical operations, only conversion to Transform. */
686
688 PackedTransform() = default;
689
691
693 {
694 x = a.x;
695 y = a.y;
696 z = a.z;
697 return *this;
698 }
699
701};
702static_assert(alignof(PackedTransform) == alignof(float),
703 "PackedTransform expected to have the same alignment as float");
704static_assert(sizeof(PackedTransform) == 48, "packed_float4 expected to be exactly 48 bytes");
705
707{
708 Transform tfm;
709 tfm.x = packed_tfm.x;
710 tfm.y = packed_tfm.y;
711 tfm.z = packed_tfm.z;
712 return tfm;
713}
714
715/* TODO: This can be removed when we know if no devices will require explicit
716 * address space qualifiers for this case. */
717
718#define transform_point_auto transform_point
719#define transform_direction_auto transform_direction
720#define transform_direction_transposed_auto transform_direction_transposed
721
#define Z
#define Y
#define A
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
#define printf
#define ccl_device_forceinline
#define M_SQRT2_F
#define ccl_private
#define ccl_device_inline
#define ccl_global
#define ccl_device_inline_method
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
#define acosf(x)
#define FLT_MAX
VecBase< float, D > normalize(VecOp< float, D >) RET
float dot(VecOp< float, D >, VecOp< float, D >) RET
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
VecBase< float, 3 > cross(VecOp< float, 3 >, VecOp< float, 3 >) RET
constexpr T clamp(T, U, U) RET
float3x3 scale(float3x3 mat, float2 scale)
float3 transform_direction(float3x3 mat, float3 direction)
float3 transform_point(float3x3 mat, float3 point)
ccl_device_inline Extrema< T > operator*(const Extrema< T > a, const T b)
Definition math_base.h:967
ccl_device_inline bool isfinite_safe(const float f)
Definition math_base.h:362
ccl_device_inline dual1 len_squared(const ccl_private dual< T > &a)
Definition math_dual.h:273
CCL_NAMESPACE_BEGIN ccl_device_inline float madd(const float a, const float b, const float c)
Definition math_fast.h:35
ccl_device_inline bool operator!=(const float2 a, const float2 b)
ccl_device_inline bool operator==(const float2 a, const float2 b)
CCL_NAMESPACE_BEGIN ccl_device_inline float4 zero_float4()
Definition math_float4.h:13
#define N
#define T
#define B
#define X(TYPE)
const btScalar eps
Definition poly34.cpp:11
#define fabsf
#define ccl_device
#define sinf
#define make_float2
#define make_float4
#define cosf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
ccl_device_inline_method PackedTransform operator=(const Transform a)
Definition transform.h:692
ccl_device_inline_method PackedTransform(const Transform a)
Definition transform.h:690
packed_float4 y
Definition transform.h:700
packed_float4 x
Definition transform.h:700
PackedTransform()=default
packed_float4 z
Definition transform.h:700
float4 & operator[](int i)
Definition transform.h:60
float4 operator[](int i) const
Definition transform.h:56
float4 y
Definition transform.h:53
float4 x
Definition transform.h:53
float4 z
Definition transform.h:53
ccl_device_inline_method dual< float > x() const
Definition types_dual.h:86
ccl_device_inline_method dual< float > y() const
Definition types_dual.h:90
ccl_device_inline_method dual< float > z() const
Definition types_dual.h:94
float x
float y
float z
Definition sky_math.h:136
float y
Definition sky_math.h:136
float x
Definition sky_math.h:136
float y
Definition sky_math.h:225
float z
Definition sky_math.h:225
float x
Definition sky_math.h:225
float w
Definition sky_math.h:225
bool system_cpu_support_avx2()
Definition system.cpp:240
float4 transform_to_quat(const Transform &tfm)
Definition transform.cpp:23
void transform_motion_decompose(DecomposedTransform *decomp, const Transform *motion, const size_t size)
Transform transform_from_viewplane(const BoundBox2D &viewplane)
CCL_NAMESPACE_BEGIN Transform transform_transposed_inverse(const Transform &tfm)
Definition transform.cpp:15
ccl_device_forceinline Transform transform_inverse_impl(const Transform tfm)
Definition transform.h:520
ccl_device_inline T transform_direction_transposed(const ccl_private Transform *t, const T a)
Definition transform.h:176
ccl_device_inline float3 transform_get_column(const Transform *t, const int column)
Definition transform.h:387
ccl_device_inline Transform transform_rotate(const float angle, float3 axis)
Definition transform.h:323
ccl_device_inline Transform euler_to_transform(const float3 euler)
Definition transform.h:227
ccl_device_inline Transform transform_identity()
Definition transform.h:355
ccl_device void transform_motion_array_interpolate(ccl_private Transform *tfm, const ccl_global DecomposedTransform *motion, const int numsteps, const float time)
Definition transform.h:629
ccl_device_inline void print_transform(const char *label, const Transform &t)
Definition transform.h:288
ccl_device_inline Transform transform_empty()
Definition transform.h:449
ccl_device_inline bool transform_equal_threshold(const Transform &A, const Transform &B, const float threshold)
Definition transform.h:372
ccl_device_inline float4 quat_interpolate(const float4 q1, const float4 q2, const float t)
Definition transform.h:458
void transform_inverse_cpu_avx2(const Transform &tfm, Transform &itfm)
ccl_device_forceinline float3 transform_inverse_cross(const float3 a_, const float3 b_)
Definition transform.h:491
ccl_device_inline bool transform_decomposed_isfinite_safe(ccl_private DecomposedTransform *decomp)
Definition transform.h:658
ccl_device_inline Transform make_transform_frame(const float3 N)
Definition transform.h:254
ccl_device_inline bool transform_negative_scale(const Transform &tfm)
Definition transform.h:429
ccl_device_inline bool transform_isfinite_safe(ccl_private Transform *tfm)
Definition transform.h:653
ccl_device_inline Transform transform_scale(const float3 s)
Definition transform.h:313
ccl_device_inline Transform transform_inverse(const Transform tfm)
Definition transform.h:563
ccl_device_inline float2 to_local(const T p, const T X, const T Y)
Definition transform.h:33
ccl_device_inline Transform transform_translate(const float3 t)
Definition transform.h:296
ccl_device_inline Transform transform_zero()
Definition transform.h:280
ccl_device_inline void transform_compose(ccl_private Transform *tfm, const ccl_private DecomposedTransform *decomp)
Definition transform.h:577
CCL_NAMESPACE_BEGIN ccl_device_inline T to_global(const float2 p, const T X, const T Y)
Definition transform.h:21
ccl_device_inline Transform make_transform(const float a, const float b, const float c, const float d, const float e, const float f, const float g, const float h, const float i, const float j, const float k, const float l)
Definition transform.h:185
ccl_device_inline bool transform_uniform_scale(const Transform &tfm, float &scale)
Definition transform.h:406
ccl_device_inline Transform transform_euler(const float3 euler)
Definition transform.h:348
ccl_device_inline Transform transform_clear_scale(const Transform &tfm)
Definition transform.h:438
ccl_device_inline void transform_set_column(Transform *t, const int column, const float3 value)
Definition transform.h:392
ccl_device_forceinline float transform_inverse_dot(const float3 a_, const float3 b_)
Definition transform.h:509
ccl_device_inline float3 transform_get_translation(const Transform *t)
Definition transform.h:399
dual< float4 > dual4
Definition types_dual.h:107
dual< float3 > dual3
Definition types_dual.h:106
ccl_device_inline dual4 make_homogeneous(const dual3 a)
Definition types_dual.h:177
ccl_device_inline void print_float4(const ccl_private char *label, const float4 a)