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
38 enum CPatchSideFlags
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
63 	CMiniPatch m_MiniPatches[PATCH_SIZE][PATCH_SIZE];
64 	// position of patch in parent terrain grid
65 	int m_X,m_Z;
66 	// parent terrain
67 	CTerrain* m_Parent;
68 
69 	int GetSideFlags();
70 };
71 
72 
73 #endif
74 
75 
76