HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
TS_Octree.h
Go to the documentation of this file.
1
/*
2
* PROPRIETARY INFORMATION. This software is proprietary to
3
* Side Effects Software Inc., and is not to be reproduced,
4
* transmitted, or disclosed in any way without written permission.
5
*
6
* NAME: Octree (C++)
7
*
8
* COMMENTS:
9
*
10
*/
11
12
13
#ifndef __TS_Octree_H__
14
#define __TS_Octree_H__
15
16
#include "
TS_API.h
"
17
#include <
UT/UT_Array.h
>
18
#include <
UT/UT_BoundingBox.h
>
19
#include "
TS_Expression.h
"
20
#include "
TS_Primitive.h
"
21
22
#define TS_OCTREE_INITIALIZED 1 // Normal octree intersect
23
#define TS_OCTREE_DOFAST 2 // For small octrees (1 deep)
24
25
//
26
// Here's the class for a voxel. Each voxel contains a list of primitives
27
// as well as a bounding box and a split direction. Each voxel can
28
// be split into two children (creating a binary tree).
29
//
30
class
TS_API
TS_OctreeVoxel
31
{
32
public
:
33
TS_OctreeVoxel
();
34
~
TS_OctreeVoxel
();
35
36
/// Compute memory usage
37
int64
getMemoryUsage(
bool
inclusive)
const
;
38
39
TS_OctreeVoxel
*myKids[2];
// Left and right
40
TS_ExpressionList
myList
;
// List of objects in this voxel
41
unsigned
myAxis
;
// My split direction (axis)
42
float
myAvg
;
// The split distance
43
UT_BoundingBox
myBBox
;
// Bounding box
44
45
float
xmin
()
const
{
return
myBBox(0, 0); }
46
float
xmax
()
const
{
return
myBBox(0, 1); }
47
float
ymin
()
const
{
return
myBBox(1, 0); }
48
float
ymax
()
const
{
return
myBBox(1, 1); }
49
float
zmin
()
const
{
return
myBBox(2, 0); }
50
float
zmax
()
const
{
return
myBBox(2, 1); }
51
TS_OctreeVoxel
*
left
() {
return
myKids[0]; }
52
TS_OctreeVoxel
*
right
() {
return
myKids[1]; }
53
54
void
addThing(
TS_MetaPrimitive
*
object
);
55
56
void
subdivide(
const
TS_ExpressionList
&nodes,
57
unsigned
maxEntries,
unsigned
level
);
58
private
:
59
void
bestSplit(
unsigned
maxEntries,
60
const
TS_ExpressionList
&nodes);
61
void
getKids(
TS_ExpressionList
&kids,
62
const
TS_ExpressionList
&nodes,
63
int
left
= 1);
64
};
65
66
//
67
// This class is used in octree traversal. This maintains a stack
68
// of where we are in the octree...
69
//
70
class
TS_API
TS_OctreeStack
71
{
72
public
:
73
TS_OctreeVoxel
*
myVoxel
;
74
float
myMin
, myMax;
75
76
TS_OctreeStack
&
operator=
(
const
TS_OctreeStack
&d) =
default
;
77
unsigned
operator==
(
const
TS_OctreeStack
&)
const
78
{
79
return
0;
80
}
81
};
82
83
//
84
// Here is the real octree class.
85
//
86
class
TS_API
TS_Octree
87
{
88
public
:
89
TS_Octree
();
90
TS_Octree
(
const
TS_MetaExpression
*e);
91
~
TS_Octree
();
92
93
void
setSweepList(
const
TS_Ray
&ray,
TS_SweepList
&sweep,
94
fpreal
tmin=0,
fpreal
tmax=1e20);
95
TS_OctreeVoxel
*findVoxel(
const
UT_Vector3
&
P
)
const
;
96
97
/// Compute memory usage
98
int64
getMemoryUsage(
bool
inclusive)
const
;
99
100
private
:
101
int
buildMe();
// Other people may have to do things
102
103
private
:
104
TS_OctreeVoxel
*myHead;
// My BSP tree
105
unsigned
myMaxLevel;
106
107
UT_Array<TS_OctreeStack>
myStack;
// used for intersect
108
const
TS_MetaExpression
*myOwner;
109
unsigned
myStackPtr;
110
};
111
112
#endif
TS_OctreeVoxel::myAxis
unsigned myAxis
Definition:
TS_Octree.h:41
TS_OctreeVoxel::myList
TS_ExpressionList myList
Definition:
TS_Octree.h:40
TS_OctreeVoxel::xmin
float xmin() const
Definition:
TS_Octree.h:45
UT_BoundingBoxT< float >
TS_OctreeVoxel::xmax
float xmax() const
Definition:
TS_Octree.h:46
TS_OctreeStack::myVoxel
TS_OctreeVoxel * myVoxel
Definition:
TS_Octree.h:73
left
GLint left
Definition:
glcorearb.h:2005
level
GLint level
Definition:
glcorearb.h:108
UT_Array.h
UT_Vector3T< float >
TS_API.h
UT_Array< TS_MetaExpressionPtr >
TS_OctreeVoxel::ymax
float ymax() const
Definition:
TS_Octree.h:48
TS_OctreeVoxel::myAvg
float myAvg
Definition:
TS_Octree.h:42
TS_OctreeVoxel::left
TS_OctreeVoxel * left()
Definition:
TS_Octree.h:51
TS_Ray
Definition:
TS_Ray.h:21
TS_OctreeVoxel::right
TS_OctreeVoxel * right()
Definition:
TS_Octree.h:52
TS_MetaExpression
Definition:
TS_Expression.h:76
TS_Primitive.h
TS_OctreeVoxel::ymin
float ymin() const
Definition:
TS_Octree.h:47
int64
long long int64
Definition:
SYS_Types.h:116
TS_Octree
Definition:
TS_Octree.h:86
TS_OctreeVoxel
Definition:
TS_Octree.h:30
TS_API
#define TS_API
Definition:
api.h:41
TS_Expression.h
TS_OctreeVoxel::zmax
float zmax() const
Definition:
TS_Octree.h:50
TS_OctreeStack::myMin
float myMin
Definition:
TS_Octree.h:74
fpreal
fpreal64 fpreal
Definition:
SYS_Types.h:277
nanovdb::operator=
LeafData & operator=(const LeafData &)=delete
UT_BoundingBox.h
TS_OctreeVoxel::myBBox
UT_BoundingBox myBBox
Definition:
TS_Octree.h:43
OBJ_MatchTransform::P
TS_OctreeStack::operator==
unsigned operator==(const TS_OctreeStack &) const
Definition:
TS_Octree.h:77
TS_MetaPrimitive
Definition:
TS_Primitive.h:22
TS_OctreeVoxel::zmin
float zmin() const
Definition:
TS_Octree.h:49
TS_OctreeStack
Definition:
TS_Octree.h:70
TS
TS_Octree.h
Generated on Tue Dec 17 2024 03:41:59 for HDK by
1.8.6