Blender V4.5
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
7#include "util/math.h"
8
10
11namespace {
12
13/* Point density helpers. */
14
16{
17 if (size.x != 0.0f) {
18 size.x = 0.5f / size.x;
19 }
20 if (size.y != 0.0f) {
21 size.y = 0.5f / size.y;
22 }
23 if (size.z != 0.0f) {
24 size.z = 0.5f / size.z;
25 }
26
27 loc = loc * size - make_float3(0.5f, 0.5f, 0.5f);
28}
29
30} /* namespace */
31
32void point_density_texture_space(BL::Depsgraph &b_depsgraph,
33 BL::ShaderNodeTexPointDensity &b_point_density_node,
34 float3 &loc,
35 float3 &size)
36{
37 BL::Object b_ob(b_point_density_node.object());
38 if (!b_ob) {
39 loc = zero_float3();
40 size = zero_float3();
41 return;
42 }
43 float3 min;
44 float3 max;
45 b_point_density_node.calc_point_density_minmax(b_depsgraph, &min[0], &max[0]);
46 loc = (min + max) * 0.5f;
47 size = (max - min) * 0.5f;
48 density_texture_space_invert(loc, size);
49}
50
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
#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:15
#define min(a, b)
Definition sort.cc:36
max
Definition text_draw.cc:251
void point_density_texture_space(BL::Depsgraph &b_depsgraph, BL::ShaderNodeTexPointDensity &b_point_density_node, float3 &loc, float3 &size)
Definition texture.cpp:32