Blender V4.3
texture.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#include "blender/texture.h"
6
8
9namespace {
10
11/* Point density helpers. */
12
14{
15 if (size.x != 0.0f) {
16 size.x = 0.5f / size.x;
17 }
18 if (size.y != 0.0f) {
19 size.y = 0.5f / size.y;
20 }
21 if (size.z != 0.0f) {
22 size.z = 0.5f / size.z;
23 }
24
25 loc = loc * size - make_float3(0.5f, 0.5f, 0.5f);
26}
27
28} /* namespace */
29
30void point_density_texture_space(BL::Depsgraph &b_depsgraph,
31 BL::ShaderNodeTexPointDensity &b_point_density_node,
32 float3 &loc,
33 float3 &size)
34{
35 BL::Object b_ob(b_point_density_node.object());
36 if (!b_ob) {
37 loc = zero_float3();
38 size = zero_float3();
39 return;
40 }
41 float3 min, max;
42 b_point_density_node.calc_point_density_minmax(b_depsgraph, &min[0], &max[0]);
43 loc = (min + max) * 0.5f;
44 size = (max - min) * 0.5f;
45 density_texture_space_invert(loc, size);
46}
47
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
Definition math_float3.h:15
void density_texture_space_invert(float3 &loc, float3 &size)
Definition texture.cpp:13
#define min(a, b)
Definition sort.c:32
void point_density_texture_space(BL::Depsgraph &b_depsgraph, BL::ShaderNodeTexPointDensity &b_point_density_node, float3 &loc, float3 &size)
Definition texture.cpp:30
float max