2
// Copyright � 1997 - 2002, Paul C. Gregory
4
// Contact: pgregory@aqsis.com
6
// This library is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation; either
9
// version 2 of the License, or (at your option) any later version.
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
// General Public License for more details.
16
// You should have received a copy of the GNU General Public
17
// License along with this library; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
\brief Declares the hierarchical occlusion culling class.
23
\author Andy Gill (billybobjimboy@users.sf.net)
26
//? Is .h included already?
27
#ifndef OCCLUSION_H_INCLUDED
28
#define OCCLUSION_H_INCLUDED 1
32
START_NAMESPACE( Aqsis )
41
static void CreateHierarchy( TqInt bucketXSize, TqInt bucketYSize, TqInt XFWidth, TqInt YFWidth );
42
static void DeleteHierarchy();
43
static void SetupHierarchy( CqBucket* bucket, TqInt xMin, TqInt yMin, TqInt xMax, TqInt yMax );
46
UpdateLevel( m_HierarchyLevels - 1 );
49
static TqBool CanCull( CqBound* bound )
51
return m_Hierarchy[ 0 ].IsCullable( bound );
53
static void MarkForUpdate( TqInt id )
55
assert( id >= 0 && id < m_TotalBoxes );
56
m_Hierarchy[ id ].MarkForUpdate();
64
static void UpdateLevel( TqInt level );
65
TqBool UpdateZValues(); // returns true if we changed anything
68
void SetBounds( TqInt x0, TqInt y0, TqInt x1, TqInt y1 );
69
bool Overlaps( CqBound* bound );
71
TqBool IsCullable( CqBound* bound );
72
TqBool NeedsUpdating()
74
return m_NeedsUpdating;
78
m_NeedsUpdating = TqTrue;
81
TqInt m_MinX; // pixel positions of box boundary
92
m_Hierarchy is a tree but implemented as an array for speed.
93
Each box has exactly 4 children apart from the leaves (obviously).
95
this = m_Hierarchy[m_Id];
96
parent = m_Hierarchy[m_Id/4]; (integer divide, rounds down)
97
first child = m_Hierarchy[m_Id*4 + 1]; (if we are a leaf this will be >= m_TotalBoxes)
98
next sibling = m_Hierarchy[m_Id + 1];
101
static CqBucket* m_Bucket;
102
static CqOcclusionBox* m_Hierarchy; // tree of OcclusionBoxes
103
static TqInt m_HierarchyLevels; // the depth of the tree
104
static TqInt m_TotalBoxes;
105
static TqInt* m_LevelStartId; // the id for the start of each level, ie 0,1,5,21... etc
107
TqBool m_NeedsUpdating;
110
END_NAMESPACE( Aqsis )
113
#endif // OCCLUSION_H_INCLUDED