forked from 0ad/0ad
Delete an unused obsolete method
This was SVN commit r11540.
This commit is contained in:
parent
46bf2cac22
commit
a16d56cc72
@ -563,37 +563,6 @@ void CTerrain::SetHeightMap(u16* heightmap)
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// FlattenArea: flatten out an area of terrain (specified in world space
|
||||
// coords); return the average height of the flattened area
|
||||
float CTerrain::FlattenArea(float x0, float x1, float z0, float z1)
|
||||
{
|
||||
const ssize_t tx0 = clamp(ssize_t(x0/TERRAIN_TILE_SIZE), (ssize_t)0, m_MapSize-1);
|
||||
const ssize_t tx1 = clamp(ssize_t(x1/TERRAIN_TILE_SIZE)+1, (ssize_t)0, m_MapSize-1);
|
||||
const ssize_t tz0 = clamp(ssize_t(z0/TERRAIN_TILE_SIZE), (ssize_t)0, m_MapSize-1);
|
||||
const ssize_t tz1 = clamp(ssize_t(z1/TERRAIN_TILE_SIZE)+1, (ssize_t)0, m_MapSize-1);
|
||||
|
||||
size_t count=0;
|
||||
double sum=0.0f;
|
||||
for (ssize_t z=tz0;z<=tz1;z++) {
|
||||
for (ssize_t x=tx0;x<=tx1;x++) {
|
||||
sum+=m_Heightmap[z*m_MapSize + x];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
const u16 avgY = u16(sum/count);
|
||||
|
||||
for (ssize_t z=tz0;z<=tz1;z++) {
|
||||
for (ssize_t x=tx0;x<=tx1;x++) {
|
||||
m_Heightmap[z*m_MapSize + x]=avgY;
|
||||
}
|
||||
}
|
||||
|
||||
MakeDirty(tx0, tz0, tx1, tz1, RENDERDATA_UPDATE_VERTICES);
|
||||
|
||||
return avgY*HEIGHT_SCALE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CTerrain::MakeDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1, int dirtyFlags)
|
||||
|
@ -128,10 +128,6 @@ public:
|
||||
|
||||
CVector3D CalcExactNormal(float x, float z) const;
|
||||
|
||||
// flatten out an area of terrain (specified in world space coords); return
|
||||
// the average height of the flattened area
|
||||
float FlattenArea(float x0, float x1, float z0, float z1);
|
||||
|
||||
// mark a specific square of tiles as dirty - use this after modifying the heightmap
|
||||
void MakeDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1, int dirtyFlags);
|
||||
// mark the entire map as dirty
|
||||
|
@ -192,57 +192,4 @@ public:
|
||||
TS_ASSERT_EQUALS(vec.Y.ToFloat(), 1.f);
|
||||
TS_ASSERT_EQUALS(vec.Z.ToFloat(), 0.f);
|
||||
}
|
||||
|
||||
void test_FlattenArea()
|
||||
{
|
||||
CTerrain terrain;
|
||||
terrain.Initialize(4, NULL);
|
||||
size_t m = terrain.GetVerticesPerSide() - 1;
|
||||
SetVertex(terrain, 0, 0, 25600);
|
||||
SetVertex(terrain, 2, 3, 25600);
|
||||
SetVertex(terrain, m, m, 25600);
|
||||
|
||||
terrain.FlattenArea(-1000, 1000, -1000, 1000);
|
||||
|
||||
// (25600*3) / (65*65) = 18
|
||||
TS_ASSERT_EQUALS(GetVertex(terrain, 0, 0), 18);
|
||||
TS_ASSERT_EQUALS(GetVertex(terrain, 4, 5), 18);
|
||||
TS_ASSERT_EQUALS(GetVertex(terrain, m, m), 18);
|
||||
}
|
||||
|
||||
void test_FlattenArea_dirty()
|
||||
{
|
||||
CTerrain terrain;
|
||||
terrain.Initialize(4, NULL);
|
||||
|
||||
for (ssize_t pj = 0; pj < terrain.GetPatchesPerSide(); ++pj)
|
||||
for (ssize_t pi = 0; pi < terrain.GetPatchesPerSide(); ++pi)
|
||||
terrain.GetPatch(pi, pj)->SetRenderData(new CRenderData());
|
||||
|
||||
#define EXPECT_DIRTY(which, pi, pj) TS_ASSERT_EQUALS((terrain.GetPatch(pi, pj)->GetRenderData()->m_UpdateFlags & RENDERDATA_UPDATE_VERTICES) != 0, which)
|
||||
|
||||
EXPECT_DIRTY(false, 0, 0);
|
||||
EXPECT_DIRTY(false, 1, 0);
|
||||
EXPECT_DIRTY(false, 2, 0);
|
||||
EXPECT_DIRTY(false, 0, 1);
|
||||
EXPECT_DIRTY(false, 1, 1);
|
||||
EXPECT_DIRTY(false, 2, 1);
|
||||
EXPECT_DIRTY(false, 0, 2);
|
||||
EXPECT_DIRTY(false, 1, 2);
|
||||
EXPECT_DIRTY(false, 2, 2);
|
||||
|
||||
terrain.FlattenArea(PATCH_SIZE*TERRAIN_TILE_SIZE, 2*PATCH_SIZE*TERRAIN_TILE_SIZE, PATCH_SIZE*TERRAIN_TILE_SIZE+1, 2*PATCH_SIZE*TERRAIN_TILE_SIZE-1);
|
||||
|
||||
EXPECT_DIRTY(true, 0, 0);
|
||||
EXPECT_DIRTY(true, 1, 0);
|
||||
EXPECT_DIRTY(true, 2, 0);
|
||||
EXPECT_DIRTY(true, 0, 1);
|
||||
EXPECT_DIRTY(true, 1, 1);
|
||||
EXPECT_DIRTY(true, 2, 1);
|
||||
EXPECT_DIRTY(true, 0, 2);
|
||||
EXPECT_DIRTY(true, 1, 2);
|
||||
EXPECT_DIRTY(true, 2, 2);
|
||||
// This is dirtying more than strictly necessary, but that's okay
|
||||
}
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user