Blender V5.3
mapping_util.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#include "kernel/svm/types.h"
8
9#include "util/math.h"
10#include "util/transform.h"
11#include "util/types.h"
12
14
15template<class Float3Type>
17 const Float3Type vector,
18 const float3 location,
19 const float3 rotation,
20 const float3 scale)
21{
22 const Transform rotationTransform = euler_to_transform(rotation);
23 switch (type) {
25 return transform_direction(&rotationTransform, (vector * scale)) + location;
27 return safe_divide(transform_direction_transposed(&rotationTransform, (vector - location)),
28 scale);
30 return transform_direction(&rotationTransform, (vector * scale));
32 return safe_normalize(transform_direction(&rotationTransform, safe_divide(vector, scale)));
33 default:
34 return Float3Type(zero_float3());
35 }
36}
37
#define CCL_NAMESPACE_END
float3x3 scale(float3x3 mat, float2 scale)
float3 transform_direction(float3x3 mat, float3 direction)
float safe_divide(float a, float b)
VecT safe_normalize(VecT vector)
NodeMappingType
@ NODE_MAPPING_TYPE_POINT
@ NODE_MAPPING_TYPE_VECTOR
@ NODE_MAPPING_TYPE_TEXTURE
@ NODE_MAPPING_TYPE_NORMAL
CCL_NAMESPACE_BEGIN ccl_device Float3Type svm_mapping(NodeMappingType type, const Float3Type vector, const float3 location, const float3 rotation, const float3 scale)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
Definition math_float3.h:17
#define ccl_device
ccl_device_inline T transform_direction_transposed(const ccl_private Transform *t, const T a)
Definition transform.h:176
ccl_device_inline Transform euler_to_transform(const float3 euler)
Definition transform.h:227