Pyrogenesis  trunk
Patch.h
Go to the documentation of this file.
1 /* Copyright (C) 2009 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /*
19  * A patch of terrain holding NxN MiniPatch tiles
20  */
21 
22 #ifndef INCLUDED_PATCH
23 #define INCLUDED_PATCH
24 
25 #include "MiniPatch.h"
26 #include "RenderableObject.h"
27 
28 class CTerrain;
29 
30 ///////////////////////////////////////////////////////////////////////////////
31 // Terrain Constants:
32 //
33 // PATCH_SIZE: number of tiles in each patch
34 const ssize_t PATCH_SIZE = 16;
35 
36 // Flags for whether the patch should be drawn with a solid plane
37 // on each side
39 {
40  CPATCH_SIDE_NEGX = (1 << 0),
41  CPATCH_SIDE_POSX = (1 << 1),
42  CPATCH_SIDE_NEGZ = (1 << 2),
43  CPATCH_SIDE_POSZ = (1 << 3),
44 };
45 
46 ///////////////////////////////////////////////////////////////////////////////
47 // CPatch: a single terrain patch, PATCH_SIZE tiles square
48 class CPatch : public CRenderableObject
49 {
50 public:
51  // constructor
52  CPatch();
53  // destructor
54  ~CPatch();
55 
56  // initialize the patch
57  void Initialize(CTerrain* parent,ssize_t x,ssize_t z);
58  // calculate and store bounds of this patch
59  void CalcBounds();
60 
61 public:
62  // minipatches (tiles) making up the patch
64  // position of patch in parent terrain grid
65  int m_X,m_Z;
66  // parent terrain
68 
69  int GetSideFlags();
70 };
71 
72 
73 #endif
74 
75 
Definition: Patch.h:41
Definition: Patch.h:40
Definition: Patch.h:43
Definition: Terrain.h:51
CPatch()
Definition: Patch.cpp:30
CPatchSideFlags
Definition: Patch.h:38
~CPatch()
Definition: Patch.cpp:37
int m_X
Definition: Patch.h:65
Definition: Patch.h:42
Definition: Patch.h:48
intptr_t ssize_t
Definition: wposix_types.h:82
int GetSideFlags()
Definition: Patch.cpp:78
Definition: MiniPatch.h:31
CTerrain * m_Parent
Definition: Patch.h:67
int m_Z
Definition: Patch.h:65
CMiniPatch m_MiniPatches[PATCH_SIZE][PATCH_SIZE]
Definition: Patch.h:63
Definition: RenderableObject.h:54
void Initialize(CTerrain *parent, ssize_t x, ssize_t z)
Definition: Patch.cpp:44
const ssize_t PATCH_SIZE
Definition: Patch.h:34
void CalcBounds()
(Re)calculates and stores any bounds or bound-dependent data for this object.
Definition: Patch.cpp:58