1 /* Copyright (C) 2010 Wildfire Games.
2 * This file is part of 0 A.D.
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.
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.
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/>.
19 * A patch of terrain holding NxN MiniPatch tiles
22 #include "precompiled.h"
28 ///////////////////////////////////////////////////////////////////////////////
35 ///////////////////////////////////////////////////////////////////////////////
42 ///////////////////////////////////////////////////////////////////////////////
43 // Initialize: setup patch data
44 void CPatch::Initialize(CTerrain
* parent
,ssize_t x
,ssize_t z
)
56 ///////////////////////////////////////////////////////////////////////////////
57 // CalcBounds: calculating the bounds of this patch
58 void CPatch::CalcBounds()
60 m_WorldBounds
.SetEmpty();
62 for (ssize_t j
=0;j
<PATCH_SIZE
+1;j
++)
64 for (ssize_t i
=0;i
<PATCH_SIZE
+1;i
++)
67 m_Parent
->CalcPosition(m_X
*PATCH_SIZE
+i
,m_Z
*PATCH_SIZE
+j
,pos
);
72 // If this a side patch, the sides go down to height 0, so add them
75 m_WorldBounds
[0].Y
= std::min(m_WorldBounds
[0].Y
, 0.f
);
78 int CPatch::GetSideFlags()
82 flags
|= CPATCH_SIDE_NEGX
;
84 flags
|= CPATCH_SIDE_NEGZ
;
85 if (m_X
== m_Parent
->GetPatchesPerSide()-1)
86 flags
|= CPATCH_SIDE_POSX
;
87 if (m_Z
== m_Parent
->GetPatchesPerSide()-1)
88 flags
|= CPATCH_SIDE_POSZ
;