Cycles: Make all #include statements relative to cycles source directory
[blender.git] / intern / cycles / blender / blender_texture.cpp
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
17 #include "blender/blender_texture.h"
18
19 CCL_NAMESPACE_BEGIN
20
21 namespace {
22
23 /* Point density helpers. */
24
25 void density_texture_space_invert(float3& loc,
26                                   float3& size)
27 {
28         if(size.x != 0.0f) size.x = 0.5f/size.x;
29         if(size.y != 0.0f) size.y = 0.5f/size.y;
30         if(size.z != 0.0f) size.z = 0.5f/size.z;
31
32         loc = loc*size - make_float3(0.5f, 0.5f, 0.5f);
33 }
34
35 }  /* namespace */
36
37 void point_density_texture_space(BL::Scene& b_scene,
38                                  BL::ShaderNodeTexPointDensity& b_point_density_node,
39                                  int settings,
40                                  float3& loc,
41                                  float3& size)
42 {
43         BL::Object b_ob(b_point_density_node.object());
44         if(!b_ob) {
45                 loc = make_float3(0.0f, 0.0f, 0.0f);
46                 size = make_float3(0.0f, 0.0f, 0.0f);
47                 return;
48         }
49         float3 min, max;
50         b_point_density_node.calc_point_density_minmax(b_scene,
51                                                        settings,
52                                                        &min[0],
53                                                        &max[0]);
54         loc = (min + max) * 0.5f;
55         size = (max - min) * 0.5f;
56         density_texture_space_invert(loc, size);
57 }
58
59 CCL_NAMESPACE_END