Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
renderobjectrecycler.cpp
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 : ww3d *
24 * *
25 * $Archive:: /Commando/Code/ww3d2/renderobjectrecycler.cpp $*
26 * *
27 * Original Author:: Greg Hjelstrom *
28 * *
29 * $Author:: Greg_h $*
30 * *
31 * $Modtime:: 5/08/01 3:54p $*
32 * *
33 * $Revision:: 1 $*
34 * *
35 *---------------------------------------------------------------------------------------------*
36 * Functions: *
37 * RenderObjectRecyclerClass::Reset -- reset the cache *
38 * RenderObjectRecyclerClass::Get_Render_Object -- Create/Re-use a render object *
39 * RenderObjectRecyclerClass::Return_Render_Object -- Return a render object to the cache *
40 * RenderObjectRecyclerClass::Insert_Inactive_Model -- Internally add a render object to the *
41 * RenderObjectRecyclerClass::Reset_Model -- resets a render object so it can be re-used *
42 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
43
45#include <string.h>
46#include "rendobj.h"
47#include "assetmgr.h"
48#include "part_emt.h"
49#include "matrix3d.h"
50
51
52/***********************************************************************************************
53 * RenderObjectRecyclerClass::Reset -- reset the pool *
54 * *
55 * INPUT: *
56 * *
57 * OUTPUT: *
58 * *
59 * WARNINGS: *
60 * *
61 * HISTORY: *
62 * 4/25/2001 gth : Created. *
63 *=============================================================================================*/
65{
66 InactiveModels.Reset_List();
67}
68
69
70/***********************************************************************************************
71 * RenderObjectRecyclerClass::Get_Render_Object -- Create/Re-use a render object *
72 * *
73 * INPUT: *
74 * *
75 * OUTPUT: *
76 * *
77 * WARNINGS: *
78 * *
79 * HISTORY: *
80 * 4/25/2001 gth : Created. *
81 *=============================================================================================*/
83{
84 RefRenderObjListIterator it(&InactiveModels);
85
86 RenderObjClass * found = NULL;
87 while (!it.Is_Done()) {
88 if (stricmp(it.Peek_Obj()->Get_Name(),name) == 0) {
89 found = it.Peek_Obj();
90 break;
91 }
92 it.Next();
93 }
94
95 if (found != NULL) {
96 found->Add_Ref();
97 InactiveModels.Remove(found);
98 found->Set_Transform(tm);
99 Reset_Model(found);
100 return found;
101
102 } else {
103
105 if (new_model != NULL) {
106 new_model->Set_Transform(tm);
107 return new_model;
108 }
109 }
110
111 return NULL;
112}
113
114
115/***********************************************************************************************
116 * RenderObjectRecyclerClass::Return_Render_Object -- Return a render object to the pool *
117 * *
118 * INPUT: *
119 * *
120 * OUTPUT: *
121 * *
122 * WARNINGS: *
123 * *
124 * HISTORY: *
125 * 4/25/2001 gth : Created. *
126 *=============================================================================================*/
128{
129 Insert_Inactive_Model(obj);
130}
131
132
133/***********************************************************************************************
134 * RenderObjectRecyclerClass::Insert_Inactive_Model -- Internally add a render object to the po*
135 * *
136 * INPUT: *
137 * *
138 * OUTPUT: *
139 * *
140 * WARNINGS: *
141 * *
142 * HISTORY: *
143 * 4/25/2001 gth : Created. *
144 *=============================================================================================*/
145void RenderObjectRecyclerClass::Insert_Inactive_Model(RenderObjClass * obj)
146{
147 WWASSERT(obj != NULL);
148 InactiveModels.Add(obj);
149}
150
151/***********************************************************************************************
152 * RenderObjectRecyclerClass::Reset_Model -- resets a render object so it can be re-used *
153 * *
154 * INPUT: *
155 * *
156 * OUTPUT: *
157 * *
158 * WARNINGS: *
159 * *
160 * HISTORY: *
161 * 5/8/2001 gth : Created. *
162 *=============================================================================================*/
163void RenderObjectRecyclerClass::Reset_Model(RenderObjClass * model)
164{
165 /*
166 ** recursively reset all sub-objects (if any)
167 */
168 for (int i=0; i<model->Get_Num_Sub_Objects(); i++) {
169 RenderObjClass * robj = model->Get_Sub_Object(i);
170 Reset_Model(robj);
171 robj->Release_Ref();
172 }
173
174 /*
175 ** particle emitters must be reset (this should release their buffers)
176 */
178 ParticleEmitterClass * emitter = (ParticleEmitterClass *)model;
179 emitter->Reset();
180 }
181
182 /*
183 ** animated models must have their animation reset (if present)
184 */
185 if (model->Peek_Animation() != NULL) {
187 }
188}
#define NULL
Definition BaseType.h:92
#define WWASSERT
WWINLINE void Release_Ref(void) const
Definition refcount.h:146
void Add_Ref(void) const
Definition refcount.cpp:171
bool Add(ObjectType *obj, bool onlyonce=true)
Definition multilist.h:353
ObjectType * Peek_Obj(void)
Definition multilist.h:461
virtual void Set_Transform(const Matrix3D &m)
Definition rendobj.cpp:423
virtual int Class_ID(void) const
Definition rendobj.h:249
virtual void Set_Animation(void)
Definition rendobj.h:341
virtual const char * Get_Name(void) const
Definition rendobj.h:250
virtual int Get_Num_Sub_Objects(void) const
Definition rendobj.h:309
virtual HAnimClass * Peek_Animation(void)
Definition rendobj.h:351
@ CLASSID_PARTICLEEMITTER
Definition rendobj.h:214
virtual RenderObjClass * Get_Sub_Object(int index) const
Definition rendobj.h:310
void Return_Render_Object(RenderObjClass *obj)
RenderObjClass * Get_Render_Object(const char *name, const Matrix3D &tm)
virtual RenderObjClass * Create_Render_Obj(const char *name)
Definition assetmgr.cpp:799
static WW3DAssetManager * Get_Instance(void)
Definition assetmgr.h:205
RefMultiListIterator< RenderObjClass > RefRenderObjListIterator
Definition robjlist.h:60