Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
static_sort_list.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 : G *
24 * *
25 * $Archive:: $*
26 * *
27 * Creator::Scott K. Bowen - 7/15/2002 *
28 * *
29 * $Author:: $*
30 * *
31 * $Modtime:: $*
32 * *
33 * $Revision:: $*
34 * *
35 *-------------------------------------------------------------------------------------------------*
36 * Functions: *
37 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
38
40// Include files ///////////////////////////////////////////////////////////////////////////////////
41
42#include "static_sort_list.h"
43
44#include "rendobj.h"
45#include "dx8renderer.h"
46
48// Initialization Functions ////////////////////////////////////////////////////////////////////////
49
52 SortLists(),
53 MinSort(1),
54 MaxSort(MAX_SORT_LEVEL)
55{
56}
57
61
63// Virtual functions ///////////////////////////////////////////////////////////////////////////////
64
65void DefaultStaticSortListClass::Add_To_List(RenderObjClass * robj, unsigned int sort_level)
66{
67 if(sort_level < 1 || sort_level > MAX_SORT_LEVEL) {
68 WWASSERT(0);
69 return;
70 }
71 SortLists[sort_level].Add_Tail(robj, false);
72}
73
75{
76 // We go from higher sort level to lower, since lower sort level means higher priority (in
77 // front), so lower sort level meshes need to be rendered later.
78 for(unsigned int sort_level = MaxSort; sort_level >= MinSort; sort_level--) {
79 bool render=false;
80 for ( RenderObjClass *robj = SortLists[sort_level].Remove_Head(); robj;
81 robj->Release_Ref(), robj = SortLists[sort_level].Remove_Head())
82 {
83 if (robj->Get_Render_Hook()) {
84 if (robj->Get_Render_Hook()->Pre_Render(robj, rinfo)) {
85 robj->Render(rinfo);
86 render = true;
87 }
88 robj->Get_Render_Hook()->Post_Render(robj, rinfo);
89 } else {
90 robj->Render(rinfo);
91 render = true;
92 }
93 }
94 if (render) TheDX8MeshRenderer.Flush();
95 }
96}
97
#define WWASSERT
#define MAX_SORT_LEVEL
Definition w3d_file.h:1196
virtual void Render_And_Clear(RenderInfoClass &rinfo)
virtual void Add_To_List(RenderObjClass *robj, unsigned int sort_level)
virtual ~DefaultStaticSortListClass(void)
WWINLINE void Release_Ref(void) const
Definition refcount.h:146
DX8MeshRendererClass TheDX8MeshRenderer