Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/util/transform.h
| Show First 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| const float3 dx0 = cross(make_float3(1.0f, 0.0f, 0.0f), N); | const float3 dx0 = cross(make_float3(1.0f, 0.0f, 0.0f), N); | ||||
| const float3 dx1 = cross(make_float3(0.0f, 1.0f, 0.0f), N); | const float3 dx1 = cross(make_float3(0.0f, 1.0f, 0.0f), N); | ||||
| const float3 dx = normalize((dot(dx0, dx0) > dot(dx1, dx1)) ? dx0 : dx1); | const float3 dx = normalize((dot(dx0, dx0) > dot(dx1, dx1)) ? dx0 : dx1); | ||||
| const float3 dy = normalize(cross(N, dx)); | const float3 dy = normalize(cross(N, dx)); | ||||
| 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); | 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); | ||||
| } | } | ||||
| #ifndef __KERNEL_GPU__ | #if !defined(__KERNEL_METAL__) | ||||
| ccl_device_inline Transform transform_zero() | |||||
| { | |||||
| Transform zero = {zero_float4(), zero_float4(), zero_float4()}; | |||||
| return zero; | |||||
| } | |||||
| ccl_device_inline Transform operator*(const Transform a, const Transform b) | ccl_device_inline Transform operator*(const Transform a, const Transform b) | ||||
| { | { | ||||
| float4 c_x = make_float4(b.x.x, b.y.x, b.z.x, 0.0f); | float4 c_x = make_float4(b.x.x, b.y.x, b.z.x, 0.0f); | ||||
| float4 c_y = make_float4(b.x.y, b.y.y, b.z.y, 0.0f); | float4 c_y = make_float4(b.x.y, b.y.y, b.z.y, 0.0f); | ||||
| float4 c_z = make_float4(b.x.z, b.y.z, b.z.z, 0.0f); | float4 c_z = make_float4(b.x.z, b.y.z, b.z.z, 0.0f); | ||||
| float4 c_w = make_float4(b.x.w, b.y.w, b.z.w, 1.0f); | float4 c_w = make_float4(b.x.w, b.y.w, b.z.w, 1.0f); | ||||
| Transform t; | Transform t; | ||||
| t.x = make_float4(dot(a.x, c_x), dot(a.x, c_y), dot(a.x, c_z), dot(a.x, c_w)); | t.x = make_float4(dot(a.x, c_x), dot(a.x, c_y), dot(a.x, c_z), dot(a.x, c_w)); | ||||
| t.y = make_float4(dot(a.y, c_x), dot(a.y, c_y), dot(a.y, c_z), dot(a.y, c_w)); | t.y = make_float4(dot(a.y, c_x), dot(a.y, c_y), dot(a.y, c_z), dot(a.y, c_w)); | ||||
| t.z = make_float4(dot(a.z, c_x), dot(a.z, c_y), dot(a.z, c_z), dot(a.z, c_w)); | t.z = make_float4(dot(a.z, c_x), dot(a.z, c_y), dot(a.z, c_z), dot(a.z, c_w)); | ||||
| return t; | return t; | ||||
| } | } | ||||
| #endif | |||||
| #ifndef __KERNEL_GPU__ | |||||
| ccl_device_inline Transform transform_zero() | |||||
| { | |||||
| Transform zero = {zero_float4(), zero_float4(), zero_float4()}; | |||||
| return zero; | |||||
| } | |||||
| ccl_device_inline void print_transform(const char *label, const Transform &t) | ccl_device_inline void print_transform(const char *label, const Transform &t) | ||||
| { | { | ||||
| print_float4(label, t.x); | print_float4(label, t.x); | ||||
| print_float4(label, t.y); | print_float4(label, t.y); | ||||
| print_float4(label, t.z); | print_float4(label, t.z); | ||||
| printf("\n"); | printf("\n"); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 298 Lines • Show Last 20 Lines | |||||