Blender  V2.93
blender_texture.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2015 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
20 
21 namespace {
22 
23 /* Point density helpers. */
24 
26 {
27  if (size.x != 0.0f)
28  size.x = 0.5f / size.x;
29  if (size.y != 0.0f)
30  size.y = 0.5f / size.y;
31  if (size.z != 0.0f)
32  size.z = 0.5f / size.z;
33 
34  loc = loc * size - make_float3(0.5f, 0.5f, 0.5f);
35 }
36 
37 } /* namespace */
38 
40  BL::ShaderNodeTexPointDensity &b_point_density_node,
41  float3 &loc,
42  float3 &size)
43 {
44  BL::Object b_ob(b_point_density_node.object());
45  if (!b_ob) {
46  loc = zero_float3();
47  size = zero_float3();
48  return;
49  }
50  float3 min, max;
51  b_point_density_node.calc_point_density_minmax(b_depsgraph, &min[0], &max[0]);
52  loc = (min + max) * 0.5f;
53  size = (max - min) * 0.5f;
55 }
56 
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
struct Object Object
void point_density_texture_space(BL::Depsgraph &b_depsgraph, BL::ShaderNodeTexPointDensity &b_point_density_node, float3 &loc, float3 &size)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
#define CCL_NAMESPACE_END
#define make_float3(x, y, z)
void density_texture_space_invert(float3 &loc, float3 &size)
#define min(a, b)
Definition: sort.c:51
float max
ccl_device_inline float3 zero_float3()