~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to intern/cycles/bvh/bvh_node.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Adapted from code copyright 2009-2010 NVIDIA Corporation
 
3
 * Modifications Copyright 2011, Blender Foundation.
 
4
 *
 
5
 * Licensed under the Apache License, Version 2.0 (the "License");
 
6
 * you may not use this file except in compliance with the License.
 
7
 * You may obtain a copy of the License at
 
8
 *
 
9
 * http://www.apache.org/licenses/LICENSE-2.0
 
10
 *
 
11
 * Unless required by applicable law or agreed to in writing, software
 
12
 * distributed under the License is distributed on an "AS IS" BASIS,
 
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
 * See the License for the specific language governing permissions and
 
15
 * limitations under the License.
 
16
 */
 
17
 
 
18
#ifndef __BVH_NODE_H__
 
19
#define __BVH_NODE_H__
 
20
 
 
21
#include "util_boundbox.h"
 
22
#include "util_debug.h"
 
23
#include "util_types.h"
 
24
 
 
25
CCL_NAMESPACE_BEGIN
 
26
 
 
27
enum BVH_STAT
 
28
{
 
29
        BVH_STAT_NODE_COUNT,
 
30
        BVH_STAT_INNER_COUNT,
 
31
        BVH_STAT_LEAF_COUNT,
 
32
        BVH_STAT_TRIANGLE_COUNT,
 
33
        BVH_STAT_CHILDNODE_COUNT
 
34
};
 
35
 
 
36
class BVHParams;
 
37
 
 
38
class BVHNode
 
39
{
 
40
public:
 
41
        BVHNode()
 
42
        {
 
43
        }
 
44
 
 
45
        virtual ~BVHNode() {}
 
46
        virtual bool is_leaf() const = 0;
 
47
        virtual int num_children() const = 0;
 
48
        virtual BVHNode *get_child(int i) const = 0;
 
49
        virtual int num_triangles() const { return 0; }
 
50
        virtual void print(int depth = 0) const = 0;
 
51
 
 
52
        float getArea() const { return m_bounds.area(); }
 
53
 
 
54
        BoundBox m_bounds;
 
55
        uint m_visibility;
 
56
 
 
57
        // Subtree functions
 
58
        int getSubtreeSize(BVH_STAT stat=BVH_STAT_NODE_COUNT) const;
 
59
        float computeSubtreeSAHCost(const BVHParams& p, float probability = 1.0f) const;        
 
60
        void deleteSubtree();
 
61
};
 
62
 
 
63
class InnerNode : public BVHNode
 
64
{
 
65
public:
 
66
        InnerNode(const BoundBox& bounds, BVHNode* child0, BVHNode* child1)
 
67
        {
 
68
                m_bounds = bounds;
 
69
                m_visibility = child0->m_visibility|child1->m_visibility;
 
70
                children[0] = child0;
 
71
                children[1] = child1;
 
72
        }
 
73
 
 
74
        bool is_leaf() const { return false; }
 
75
        int num_children() const { return 2; }
 
76
        BVHNode *get_child(int i) const{ assert(i>=0 && i<2); return children[i]; }
 
77
        void print(int depth) const;
 
78
 
 
79
        BVHNode *children[2];
 
80
};
 
81
 
 
82
class LeafNode : public BVHNode
 
83
{
 
84
public:
 
85
        LeafNode(const BoundBox& bounds, uint visibility, int lo, int hi) 
 
86
        {
 
87
                m_bounds = bounds;
 
88
                m_visibility = visibility;
 
89
                m_lo = lo;
 
90
                m_hi = hi;
 
91
        }
 
92
 
 
93
        LeafNode(const LeafNode& s)
 
94
        : BVHNode()
 
95
        {
 
96
                *this = s;
 
97
        }
 
98
 
 
99
        bool is_leaf() const { return true; }
 
100
        int num_children() const { return 0; }
 
101
        BVHNode *get_child(int) const { return NULL; }
 
102
        int num_triangles() const { return m_hi - m_lo; }
 
103
        void print(int depth) const;
 
104
 
 
105
        int m_lo;
 
106
        int m_hi;
 
107
};
 
108
 
 
109
CCL_NAMESPACE_END
 
110
 
 
111
#endif /* __BVH_NODE_H__ */
 
112