KiCad PCB EDA Suite
Loading...
Searching...
No Matches
bvh_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 <[email protected]>
5 * Copyright The 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
68
69
70#ifndef _BVH_PBRT_H_
71#define _BVH_PBRT_H_
72
73#include "accelerator_3d.h"
74#include <cstdint>
75#include <list>
76
77// Forward Declarations
78struct BVHBuildNode;
79struct BVHPrimitiveInfo;
80struct 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
108
109
111{
112public:
113 BVH_PBRT( const CONTAINER_3D_BASE& aObjectContainer, int aMaxPrimsInNode = 4,
114 SPLITMETHOD aSplitMethod = SPLITMETHOD::SAH );
115
116 ~BVH_PBRT();
117
118 // We own at least one list of raw pointers. Don't let the compiler fill in copy c'tors that
119 // will only land us in trouble.
120 BVH_PBRT( const BVH_PBRT& ) = delete;
121 BVH_PBRT& operator=( const BVH_PBRT& ) = delete;
122
123 bool Intersect( const RAY& aRay, HITINFO& aHitInfo ) const override;
124 bool Intersect( const RAY& aRay, HITINFO& aHitInfo, unsigned int aAccNodeInfo ) const override;
125 bool Intersect( const RAYPACKET& aRayPacket, HITINFO_PACKET* aHitInfoPacket ) const override;
126 bool IntersectP( const RAY& aRay, float aMaxDistance ) const override;
127
128private:
129 BVHBuildNode* recursiveBuild( std::vector<BVHPrimitiveInfo>& primitiveInfo, int start,
130 int end, int* totalNodes, CONST_VECTOR_OBJECT& orderedPrims );
131
132 BVHBuildNode* HLBVHBuild( const std::vector<BVHPrimitiveInfo>& primitiveInfo,
133 int* totalNodes, CONST_VECTOR_OBJECT& orderedPrims );
134
136 BVHBuildNode* emitLBVH( BVHBuildNode* &buildNodes,
137 const std::vector<BVHPrimitiveInfo>& primitiveInfo,
138 MortonPrimitive* mortonPrims, int nPrimitives, int* totalNodes,
139 CONST_VECTOR_OBJECT& orderedPrims, int* orderedPrimsOffset, int bit );
140
141 BVHBuildNode* buildUpperSAH( std::vector<BVHBuildNode*>& treeletRoots, int start, int end,
142 int* totalNodes );
143
144 int flattenBVHTree( BVHBuildNode* node, uint32_t* offset );
145
146 // BVH Private Data
151
152 std::list<void*> m_nodesToFree;
153
154 // Partition traversal
156};
157
158#endif // _BVH_PBRT_H_
SPLITMETHOD
Definition bvh_pbrt.h:102
BVH_PBRT & operator=(const BVH_PBRT &)=delete
std::list< void * > m_nodesToFree
Definition bvh_pbrt.h:152
int flattenBVHTree(BVHBuildNode *node, uint32_t *offset)
BVH_PBRT(const BVH_PBRT &)=delete
LinearBVHNode * m_nodes
Definition bvh_pbrt.h:150
unsigned int m_I[RAYPACKET_RAYS_PER_PACKET]
Definition bvh_pbrt.h:155
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 bvh_pbrt.cpp:795
BVH_PBRT(const CONTAINER_3D_BASE &aObjectContainer, int aMaxPrimsInNode=4, SPLITMETHOD aSplitMethod=SPLITMETHOD::SAH)
Definition bvh_pbrt.cpp:235
BVHBuildNode * buildUpperSAH(std::vector< BVHBuildNode * > &treeletRoots, int start, int end, int *totalNodes)
Definition bvh_pbrt.cpp:894
const int m_maxPrimsInNode
Definition bvh_pbrt.h:147
bool Intersect(const RAY &aRay, HITINFO &aHitInfo) const override
CONST_VECTOR_OBJECT m_primitives
Definition bvh_pbrt.h:149
bool IntersectP(const RAY &aRay, float aMaxDistance) const override
BVHBuildNode * HLBVHBuild(const std::vector< BVHPrimitiveInfo > &primitiveInfo, int *totalNodes, CONST_VECTOR_OBJECT &orderedPrims)
Definition bvh_pbrt.cpp:678
BVHBuildNode * recursiveBuild(std::vector< BVHPrimitiveInfo > &primitiveInfo, int start, int end, int *totalNodes, CONST_VECTOR_OBJECT &orderedPrims)
Definition bvh_pbrt.cpp:426
SPLITMETHOD m_splitMethod
Definition bvh_pbrt.h:148
std::vector< const OBJECT_3D * > CONST_VECTOR_OBJECT
#define RAYPACKET_RAYS_PER_PACKET
Definition raypacket.h:35
Manage a bounding box defined by two SFVEC3F min max points.
Definition bbox_3d.h:43
Stores the hit information of a ray with a point on the surface of a object.
Definition hitinfo.h:36
int secondChildOffset
interior
Definition bvh_pbrt.h:91
uint8_t axis
interior node: xyz
Definition bvh_pbrt.h:96
BBOX_3D bounds
Definition bvh_pbrt.h:85
uint16_t nPrimitives
0 -> interior node
Definition bvh_pbrt.h:95
uint8_t pad[1]
ensure 32 byte total size
Definition bvh_pbrt.h:97
int primitivesOffset
leaf
Definition bvh_pbrt.h:90
Definition ray.h:63
VECTOR2I end