Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
cullsys.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : WWMath *
24 * *
25 * $Archive:: /Commando/Code/wwmath/cullsys.h $*
26 * *
27 * Author:: Greg Hjelstrom *
28 * *
29 * $Modtime:: 5/08/01 6:33p $*
30 * *
31 * $Revision:: 5 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37
38#if defined(_MSC_VER)
39#pragma once
40#endif
41
42#ifndef CULLSYS_H
43#define CULLSYS_H
44
45#include "wwdebug.h"
46#include "stdlib.h"
47#include "refcount.h"
48#include "aabox.h"
49
50class CullableClass;
51class CullSystemClass;
52class FrustumClass;
53
54/*
55** CullLinkClass
56** This class will serve as a base class for the various types of linkage information
57** that the Cullable instances will need. Each CullableClass will have a pointer to
58** a class derived from CullLinkClass where the different culling systems can store
59** things.
60*/
62{
63public:
65 virtual ~CullLinkClass(void) { WWASSERT(System == NULL); }
66
69
70protected:
72};
73
74
75/*
76** CullableClass
77** This is the base class for any object that can be inserted into a culling system
78** This class provides an axis aligned bounding box and some linkage variables which
79** allow it to be processed by any culling system.
80*/
82{
83public:
84
85 CullableClass(void);
86 virtual ~CullableClass(void);
87
88 /*
89 ** Access to the culling box for this object. When you set the cull box, you are
90 ** basically guaranteeing that the object is contained within the given box. The
91 ** object will automatically be updated in whatever culling system it is currently
92 ** contained in (if any)
93 */
94 WWINLINE const AABoxClass & Get_Cull_Box(void) const { return CullBox; }
95 void Set_Cull_Box(const AABoxClass & box,bool just_loaded = false);
96
97 /*
98 ** These functions are used by various culling systems to manage the linkage
99 ** pointers. *The average user should NEVER call these*
100 */
103 WWINLINE void Set_Cull_Link(CullLinkClass * c) { CullLink = c; }
104 WWINLINE CullLinkClass * Get_Cull_Link(void) const { return CullLink; }
105
106private:
107
108 WWINLINE void Set_Next_Collected(CullableClass * c) { NextCollected = c; }
109 WWINLINE CullableClass * Get_Next_Collected(void) { return NextCollected; }
110
111 /*
112 ** Culling Data
113 ** Each object can be linked into various types of culling systems.
114 ** Each culling system can use its own linkage data structure (derived
115 ** from CullLinkClass) to keep track of the object. The CullData pointer
116 ** will point to one of the culling link objects and NULL
117 ** if its not in any system.
118 */
119 CullLinkClass * CullLink;
120
121 /*
122 ** Bounding Box
123 ** Any objects derived from Cullable should update the bounding box
124 ** whenever the object moves or changes size. In order to do this,
125 ** call Set_Cull_Box...
126 */
127 AABoxClass CullBox;
128
129 /*
130 ** NextCollected
131 ** This pointer is used by the culling system to keep a singly linked
132 ** list of cullable object that have been "collected".
133 */
134 CullableClass * NextCollected;
135
136 // Not Implemented:
137 CullableClass(const CullableClass & src);
138 CullableClass & operator = (const CullableClass & src);
139
140 friend class CullSystemClass;
141};
142
143
144
145
146/*
147** CullSystemClass
148** Base class of any culling system. This interface exists so that things can
149** be shuffled around without having explicit knowledge of what system they are in.
150*/
152{
153public:
154
155 CullSystemClass(void);
156 virtual ~CullSystemClass(void);
157
158 /*
159 ** Collect_Objects. Updates the internal collection list with the
160 ** objects that overlap the given primitive.
161 ** WARNING: This builds an internal list that is only valid until
162 ** another list is built, only one list can be valid at any time.
163 ** WARNING: Always call Reset_Collection if you want to start a
164 ** fresh collection!
165 */
166 void Reset_Collection(void);
167 virtual void Collect_Objects(const Vector3 & point) = 0;
168 virtual void Collect_Objects(const AABoxClass & box) = 0;
169 virtual void Collect_Objects(const OBBoxClass & box) = 0;
170 virtual void Collect_Objects(const FrustumClass & frustum) = 0;
171
172 /*
173 ** This object has moved or changed size, update it
174 */
175 virtual void Update_Culling(CullableClass * obj) = 0;
176
177protected:
178
179 /*
180 ** Iterate through the collected objects
181 */
186
187 /*
188 ** Build the list of collected objects
189 */
191
192 /*
193 ** Pointer to the head of the current collection of objects
194 */
196
197 friend class CullableClass;
198};
199
200
201#endif
#define NULL
Definition BaseType.h:92
#define WWASSERT
#define WWINLINE
Definition always.h:172
CullableClass * Get_Next_Collected_Object_Internal(CullableClass *obj)
Definition cullsys.cpp:119
virtual void Update_Culling(CullableClass *obj)=0
void Reset_Collection(void)
Definition cullsys.cpp:140
CullableClass * Get_First_Collected_Object_Internal(void)
Definition cullsys.cpp:114
friend class CullableClass
Definition cullsys.h:197
CullableClass * Peek_First_Collected_Object_Internal(void)
Definition cullsys.cpp:127
void Add_To_Collection(CullableClass *obj)
Definition cullsys.cpp:145
virtual ~CullSystemClass(void)
Definition cullsys.cpp:108
virtual void Collect_Objects(const AABoxClass &box)=0
CullSystemClass(void)
Definition cullsys.cpp:103
virtual void Collect_Objects(const OBBoxClass &box)=0
virtual void Collect_Objects(const FrustumClass &frustum)=0
virtual void Collect_Objects(const Vector3 &point)=0
CullableClass * Peek_Next_Collected_Object_Internal(CullableClass *obj)
Definition cullsys.cpp:132
CullableClass * CollectionHead
Definition cullsys.h:195
void Set_Culling_System(CullSystemClass *sys)
Definition cullsys.cpp:79
WWINLINE CullLinkClass * Get_Cull_Link(void) const
Definition cullsys.h:104
void Set_Cull_Box(const AABoxClass &box, bool just_loaded=false)
Definition cullsys.cpp:62
WWINLINE const AABoxClass & Get_Cull_Box(void) const
Definition cullsys.h:94
friend class CullSystemClass
Definition cullsys.h:140
virtual ~CullableClass(void)
Definition cullsys.cpp:54
CullableClass(void)
Definition cullsys.cpp:47
WWINLINE void Set_Cull_Link(CullLinkClass *c)
Definition cullsys.h:103
CullSystemClass * Get_Culling_System(void) const
Definition cullsys.cpp:86
RefCountClass(void)
Definition refcount.h:108