KiCad PCB EDA Suite
cbvh_pbrt.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
5  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
70 #ifndef _CBVH_PBRT_H_
71 #define _CBVH_PBRT_H_
72 
73 #include "caccelerator.h"
74 #include <list>
75 #include <stdint.h>
76 
77 // Forward Declarations
78 struct BVHBuildNode;
79 struct BVHPrimitiveInfo;
80 struct MortonPrimitive;
81 
83 {
84  // 24 bytes
86 
87  // 4 bytes
88  union
89  {
92  };
93 
94  // 4 bytes
95  uint16_t nPrimitives;
96  uint8_t axis;
97  uint8_t pad[1];
98 };
99 
100 
102 {
107 };
108 
109 
111 {
112 
113 public:
114  CBVH_PBRT( const CGENERICCONTAINER &aObjectContainer,
115  int aMaxPrimsInNode = 4,
116  SPLITMETHOD aSplitMethod = SPLIT_SAH );
117 
118  ~CBVH_PBRT();
119 
120  // Imported from CGENERICACCELERATOR
121  bool Intersect( const RAY &aRay, HITINFO &aHitInfo ) const override;
122  bool Intersect( const RAY &aRay, HITINFO &aHitInfo, unsigned int aAccNodeInfo ) const override;
123  bool Intersect( const RAYPACKET &aRayPacket, HITINFO_PACKET *aHitInfoPacket ) const override;
124  bool IntersectP( const RAY &aRay, float aMaxDistance ) const override;
125 
126 private:
127 
128  BVHBuildNode *recursiveBuild( std::vector<BVHPrimitiveInfo> &primitiveInfo,
129  int start,
130  int end,
131  int *totalNodes,
132  CONST_VECTOR_OBJECT &orderedPrims );
133 
134  BVHBuildNode *HLBVHBuild( const std::vector<BVHPrimitiveInfo> &primitiveInfo,
135  int *totalNodes,
136  CONST_VECTOR_OBJECT &orderedPrims );
137 
139  BVHBuildNode *emitLBVH( BVHBuildNode *&buildNodes,
140  const std::vector<BVHPrimitiveInfo> &primitiveInfo,
141  MortonPrimitive *mortonPrims,
142  int nPrimitives,
143  int *totalNodes,
144  CONST_VECTOR_OBJECT &orderedPrims,
145  int *orderedPrimsOffset,
146  int bit );
147 
148  BVHBuildNode *buildUpperSAH( std::vector<BVHBuildNode *> &treeletRoots,
149  int start,
150  int end,
151  int *totalNodes );
152 
153  int flattenBVHTree( BVHBuildNode *node,
154  uint32_t *offset );
155 
156  // BVH Private Data
157  const int m_maxPrimsInNode;
161 
163 
164  // Partition traversal
166 };
167 
168 #endif // _CBVH_PBRT_H_
CONST_VECTOR_OBJECT m_primitives
Definition: cbvh_pbrt.h:159
int primitivesOffset
leaf
Definition: cbvh_pbrt.h:90
uint16_t nPrimitives
0 -> interior node
Definition: cbvh_pbrt.h:95
std::vector< const COBJECT * > CONST_VECTOR_OBJECT
Definition: ccontainer.h:39
uint8_t axis
interior node: xyz
Definition: cbvh_pbrt.h:96
CBVH_PBRT(const CGENERICCONTAINER &aObjectContainer, int aMaxPrimsInNode=4, SPLITMETHOD aSplitMethod=SPLIT_SAH)
Definition: cbvh_pbrt.cpp:233
Definition: ray.h:43
const int m_maxPrimsInNode
Definition: cbvh_pbrt.h:157
uint8_t pad[1]
ensure 32 byte total size
Definition: cbvh_pbrt.h:97
bool IntersectP(const RAY &aRay, float aMaxDistance) const override
Definition: cbvh_pbrt.cpp:1261
BVHBuildNode * buildUpperSAH(std::vector< BVHBuildNode * > &treeletRoots, int start, int end, int *totalNodes)
Definition: cbvh_pbrt.cpp:947
bool Intersect(const RAY &aRay, HITINFO &aHitInfo) const override
Definition: cbvh_pbrt.cpp:1129
BVHBuildNode * emitLBVH(BVHBuildNode *&buildNodes, const std::vector< BVHPrimitiveInfo > &primitiveInfo, MortonPrimitive *mortonPrims, int nPrimitives, int *totalNodes, CONST_VECTOR_OBJECT &orderedPrims, int *orderedPrimsOffset, int bit)
TODO: after implement memory arena, put const back to this functions.
Definition: cbvh_pbrt.cpp:846
BVHBuildNode * recursiveBuild(std::vector< BVHPrimitiveInfo > &primitiveInfo, int start, int end, int *totalNodes, CONST_VECTOR_OBJECT &orderedPrims)
Definition: cbvh_pbrt.cpp:445
LinearBVHNode * m_nodes
Definition: cbvh_pbrt.h:160
Stores the hit information of a ray with a point on the surface of a object.
Definition: hitinfo.h:40
#define RAYPACKET_RAYS_PER_PACKET
Definition: raypacket.h:40
unsigned int m_I[RAYPACKET_RAYS_PER_PACKET]
Definition: cbvh_pbrt.h:165
static long bit[8][9]
Definition: solve.cpp:826
int flattenBVHTree(BVHBuildNode *node, uint32_t *offset)
Definition: cbvh_pbrt.cpp:1098
BVHBuildNode * HLBVHBuild(const std::vector< BVHPrimitiveInfo > &primitiveInfo, int *totalNodes, CONST_VECTOR_OBJECT &orderedPrims)
Definition: cbvh_pbrt.cpp:719
int secondChildOffset
interior
Definition: cbvh_pbrt.h:91
SPLITMETHOD
Definition: cbvh_pbrt.h:101
CBBOX bounds
Definition: cbvh_pbrt.h:85
Class CBBOX manages a bounding box defined by two SFVEC3F min max points.
Definition: cbbox.h:40
std::list< void * > m_addresses_pointer_to_mm_free
Definition: cbvh_pbrt.h:162
SPLITMETHOD m_splitMethod
Definition: cbvh_pbrt.h:158