Index: binaries/data/mods/public/art/actors/structures/celts/wall_long.xml
===================================================================
--- binaries/data/mods/public/art/actors/structures/celts/wall_long.xml (revision 14215)
+++ binaries/data/mods/public/art/actors/structures/celts/wall_long.xml (working copy)
@@ -2,25 +2,17 @@
-
- structural/celt_wall_long.dae
-
-
-
-
-
-
-
-
-
-
-
+
+ structural/slope_wall_propped.dae
-
-
-
+
+
+
+
+
+
- player_trans_ao_parallax_spec.xml
+ basic_trans.xml
Index: binaries/data/mods/public/art/actors/structures/celts/wall_medium.xml
===================================================================
--- binaries/data/mods/public/art/actors/structures/celts/wall_medium.xml (revision 14215)
+++ binaries/data/mods/public/art/actors/structures/celts/wall_medium.xml (working copy)
@@ -2,25 +2,17 @@
-
- structural/celt_wall_medium.dae
-
-
-
-
-
-
-
-
-
-
-
+
+ structural/slope_wall_propped.dae
-
-
-
+
+
+
+
+
+
- player_trans_ao_parallax_spec.xml
+ basic_trans.xml
Index: binaries/data/mods/public/art/actors/structures/celts/wall_short.xml
===================================================================
--- binaries/data/mods/public/art/actors/structures/celts/wall_short.xml (revision 14215)
+++ binaries/data/mods/public/art/actors/structures/celts/wall_short.xml (working copy)
@@ -2,25 +2,17 @@
-
- structural/celt_wall_short.dae
-
-
-
-
-
-
-
-
-
-
-
+
+ structural/slope_wall_propped.dae
-
-
-
+
+
+
+
+
+
- player_trans_ao_parallax_spec.xml
+ basic_trans.xml
Index: binaries/data/mods/public/art/actors/structures/celts/wall_tower.xml
===================================================================
--- binaries/data/mods/public/art/actors/structures/celts/wall_tower.xml (revision 14215)
+++ binaries/data/mods/public/art/actors/structures/celts/wall_tower.xml (working copy)
@@ -1,36 +1,18 @@
-
+
-
- structural/celt_wall_tower.dae
+
+ structural/slope_wall_propped.dae
-
-
-
+
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- player_trans_ao_parallax_spec.xml
+ basic_trans.xml
Index: binaries/data/mods/public/simulation/templates/structures/brit_wall_gate.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/brit_wall_gate.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/brit_wall_gate.xml (working copy)
@@ -11,6 +11,9 @@
9.0
+
+ 1500
+
brit
Dor
Index: binaries/data/mods/public/simulation/templates/structures/brit_wall_long.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/brit_wall_long.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/brit_wall_long.xml (working copy)
@@ -1,7 +1,10 @@
+
+ 20
+
-
+
9.0
@@ -11,8 +14,13 @@
The Romans called this wall 'Murus Gallicus'. Translated, it means 'Gaulish wall'. It was extremely resistant to assault by battering ram. Julius Caesar described a type of wood and stone wall, known as a Murus Gallicus, in his account of the Gallic Wars. These walls were made of a stone wall filled with rubble, with wooden logs inside for stability. Caesar noted how the flexibility of the wood added to the strength of the fort in case of battering ram attack.
-
+
+
+
+ slopeWall
+
+
structures/celts/wall_long.xml
Index: binaries/data/mods/public/simulation/templates/structures/brit_wall_medium.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/brit_wall_medium.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/brit_wall_medium.xml (working copy)
@@ -1,7 +1,10 @@
+
+ 20
+
-
+
9.0
@@ -14,8 +17,13 @@
The Romans called this wall 'Murus Gallicus'. Translated, it means 'Gaulish wall'. It was extremely resistant to assault by battering ram. Julius Caesar described a type of wood and stone wall, known as a Murus Gallicus, in his account of the Gallic Wars. These walls were made of a stone wall filled with rubble, with wooden logs inside for stability. Caesar noted how the flexibility of the wood added to the strength of the fort in case of battering ram attack.
-
+
+
+
+ slopeWall
+
+
structures/celts/wall_medium.xml
Index: binaries/data/mods/public/simulation/templates/structures/brit_wall_short.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/brit_wall_short.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/brit_wall_short.xml (working copy)
@@ -1,7 +1,10 @@
+
+ 20
+
-
+
9.0
@@ -14,8 +17,13 @@
The Romans called this wall 'Murus Gallicus'. Translated, it means 'Gaulish wall'. It was extremely resistant to assault by battering ram. Julius Caesar described a type of wood and stone wall, known as a Murus Gallicus, in his account of the Gallic Wars. These walls were made of a stone wall filled with rubble, with wooden logs inside for stability. Caesar noted how the flexibility of the wood added to the strength of the fort in case of battering ram attack.
-
+
+
+
+ slopeWall
+
+
structures/celts/wall_short.xml
Index: binaries/data/mods/public/simulation/templates/structures/brit_wall_tower.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/brit_wall_tower.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/brit_wall_tower.xml (working copy)
@@ -1,9 +1,12 @@
+
+ 20
+
-
- 20.0
+
+ 9.0
@@ -13,8 +16,13 @@
Does not shoot or garrison.
-
+
+
+
+ slopeWall
+
+
structures/celts/wall_tower.xml
Index: binaries/data/mods/public/simulation/templates/structures/celt_wall_gate.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/celt_wall_gate.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/celt_wall_gate.xml (working copy)
@@ -11,6 +11,9 @@
9.0
+
+ 1500
+
celt
Gate
Index: binaries/data/mods/public/simulation/templates/structures/celt_wall_long.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/celt_wall_long.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/celt_wall_long.xml (working copy)
@@ -1,7 +1,10 @@
+
+ 20
+
-
+
9.0
@@ -11,8 +14,13 @@
The Romans called this wall 'Murus Gallicus'. Translated, it means 'Gaulish wall'. It was extremely resistant to assault by battering ram. Julius Caesar described a type of wood and stone wall, known as a Murus Gallicus, in his account of the Gallic Wars. These walls were made of a stone wall filled with rubble, with wooden logs inside for stability. Caesar noted how the flexibility of the wood added to the strength of the fort in case of battering ram attack.
-
+
+
+
+ slopeWall
+
+
structures/celts/wall_long.xml
Index: binaries/data/mods/public/simulation/templates/structures/celt_wall_medium.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/celt_wall_medium.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/celt_wall_medium.xml (working copy)
@@ -1,7 +1,10 @@
+
+ 20
+
-
+
9.0
@@ -14,8 +17,13 @@
The Romans called this wall 'Murus Gallicus'. Translated, it means 'Gaulish wall'. It was extremely resistant to assault by battering ram. Julius Caesar described a type of wood and stone wall, known as a Murus Gallicus, in his account of the Gallic Wars. These walls were made of a stone wall filled with rubble, with wooden logs inside for stability. Caesar noted how the flexibility of the wood added to the strength of the fort in case of battering ram attack.
-
+
+
+
+ slopeWall
+
+
structures/celts/wall_medium.xml
Index: binaries/data/mods/public/simulation/templates/structures/celt_wall_short.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/celt_wall_short.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/celt_wall_short.xml (working copy)
@@ -1,7 +1,10 @@
+
+ 20
+
-
+
9.0
@@ -14,8 +17,13 @@
The Romans called this wall 'Murus Gallicus'. Translated, it means 'Gaulish wall'. It was extremely resistant to assault by battering ram. Julius Caesar described a type of wood and stone wall, known as a Murus Gallicus, in his account of the Gallic Wars. These walls were made of a stone wall filled with rubble, with wooden logs inside for stability. Caesar noted how the flexibility of the wood added to the strength of the fort in case of battering ram attack.
-
+
+
+
+ slopeWall
+
+
structures/celts/wall_short.xml
Index: binaries/data/mods/public/simulation/templates/structures/celt_wall_tower.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/celt_wall_tower.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/celt_wall_tower.xml (working copy)
@@ -1,9 +1,12 @@
+
+ 20
+
-
- 20.0
+
+ 9.0
@@ -13,9 +16,14 @@
Does not shoot or garrison.
-
+
+
+
+ slopeWall
+
+
structures/celts/wall_tower.xml
Index: binaries/data/mods/public/simulation/templates/structures/gaul_wall_gate.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/gaul_wall_gate.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/gaul_wall_gate.xml (working copy)
@@ -11,6 +11,9 @@
9.0
+
+ 1500
+
gaul
Duro
Index: binaries/data/mods/public/simulation/templates/structures/gaul_wall_long.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/gaul_wall_long.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/gaul_wall_long.xml (working copy)
@@ -1,7 +1,10 @@
+
+ 20
+
-
+
9.0
@@ -11,8 +14,13 @@
The Romans called this wall 'Murus Gallicus'. Translated, it means 'Gaulish wall'. It was extremely resistant to assault by battering ram. Julius Caesar described a type of wood and stone wall, known as a Murus Gallicus, in his account of the Gallic Wars. These walls were made of a stone wall filled with rubble, with wooden logs inside for stability. Caesar noted how the flexibility of the wood added to the strength of the fort in case of battering ram attack.
-
+
+
+
+ slopeWall
+
+
structures/celts/wall_long.xml
Index: binaries/data/mods/public/simulation/templates/structures/gaul_wall_medium.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/gaul_wall_medium.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/gaul_wall_medium.xml (working copy)
@@ -1,7 +1,10 @@
+
+ 20
+
-
+
9.0
@@ -14,8 +17,13 @@
The Romans called this wall 'Murus Gallicus'. Translated, it means 'Gaulish wall'. It was extremely resistant to assault by battering ram. Julius Caesar described a type of wood and stone wall, known as a Murus Gallicus, in his account of the Gallic Wars. These walls were made of a stone wall filled with rubble, with wooden logs inside for stability. Caesar noted how the flexibility of the wood added to the strength of the fort in case of battering ram attack.
-
+
+
+
+ slopeWall
+
+
structures/celts/wall_medium.xml
Index: binaries/data/mods/public/simulation/templates/structures/gaul_wall_short.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/gaul_wall_short.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/gaul_wall_short.xml (working copy)
@@ -1,7 +1,10 @@
+
+ 20
+
-
+
9.0
@@ -14,8 +17,13 @@
The Romans called this wall 'Murus Gallicus'. Translated, it means 'Gaulish wall'. It was extremely resistant to assault by battering ram. Julius Caesar described a type of wood and stone wall, known as a Murus Gallicus, in his account of the Gallic Wars. These walls were made of a stone wall filled with rubble, with wooden logs inside for stability. Caesar noted how the flexibility of the wood added to the strength of the fort in case of battering ram attack.
-
+
+
+
+ slopeWall
+
+
structures/celts/wall_short.xml
Index: binaries/data/mods/public/simulation/templates/structures/gaul_wall_tower.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/gaul_wall_tower.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/gaul_wall_tower.xml (working copy)
@@ -1,9 +1,12 @@
+
+ 20
+
-
- 20.0
+
+ 9.0
@@ -13,8 +16,13 @@
Does not shoot or garrison.
-
+
+
+
+ slopeWall
+
+
structures/celts/wall_tower.xml
Index: binaries/data/mods/public/simulation/templates/structures/iber_house.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/iber_house.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/structures/iber_house.xml (working copy)
@@ -19,6 +19,11 @@
16
65536
+
+
+ flatten
+
+
structures/iberians/house.xml
structures/fndn_2x2.xml
Index: binaries/data/mods/public/simulation/templates/template_structure_defense_wall.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_structure_defense_wall.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/template_structure_defense_wall.xml (working copy)
@@ -48,6 +48,7 @@
20
65536
+
20
Index: binaries/data/mods/public/simulation/templates/template_structure_defense_wall_long.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_structure_defense_wall_long.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/template_structure_defense_wall_long.xml (working copy)
@@ -10,7 +10,7 @@
rubble/rubble_stone_wall_long
- LongWall
- Long wall segments can be converted to gates.
-
-
+ LongWall
+ Long wall segments can be converted to gates.
+
+
Index: binaries/data/mods/public/simulation/templates/template_structure_defense_wall_tower.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_structure_defense_wall_tower.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/template_structure_defense_wall_tower.xml (working copy)
@@ -85,6 +85,7 @@
20.0
+
false
20
Index: binaries/data/mods/public/simulation/templates/template_structure_military_dock.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_structure_military_dock.xml (revision 14215)
+++ binaries/data/mods/public/simulation/templates/template_structure_military_dock.xml (working copy)
@@ -53,6 +53,7 @@
+
0.8
Index: source/simulation2/TypeList.h
===================================================================
--- source/simulation2/TypeList.h (revision 14215)
+++ source/simulation2/TypeList.h (working copy)
@@ -148,6 +148,9 @@
INTERFACE(Terrain)
COMPONENT(Terrain)
+INTERFACE(TerrainModifier)
+COMPONENT(TerrainModifierScripted)
+
INTERFACE(TerritoryInfluence)
COMPONENT(TerritoryInfluence)
Index: source/simulation2/components/CCmpTerrain.cpp
===================================================================
--- source/simulation2/components/CCmpTerrain.cpp (revision 14215)
+++ source/simulation2/components/CCmpTerrain.cpp (working copy)
@@ -20,13 +20,18 @@
#include "simulation2/system/Component.h"
#include "ICmpTerrain.h"
+#include "ICmpTerrainModifier.h"
#include "ICmpObstructionManager.h"
#include "ICmpRangeManager.h"
+#include "ICmpPosition.h"
#include "simulation2/MessageTypes.h"
+#include "simulation2/helpers/Geometry.h"
#include "graphics/Terrain.h"
#include "renderer/Renderer.h"
#include "renderer/WaterManager.h"
+#include "graphics/Patch.h"
+#include "maths/MathUtil.h"
#include "maths/Vector3D.h"
class CCmpTerrain : public ICmpTerrain
@@ -40,6 +45,10 @@
CTerrain* m_Terrain; // not null
+ std::vector m_SimHeightmap;
+ ssize_t m_MapSizePatches;
+
+
static std::string GetSchema()
{
return "";
@@ -48,6 +57,8 @@
virtual void Init(const CParamNode& UNUSED(paramNode))
{
m_Terrain = &GetSimContext().GetTerrain();
+ m_MapSizePatches = 0;
+ ReloadTerrain();
}
virtual void Deinit()
@@ -68,6 +79,21 @@
return m_Terrain->GetVerticesPerSide() != 0;
}
+
+ virtual u16* GetSimHeightMap()
+ {
+ return &m_SimHeightmap[0];
+ }
+
+ virtual void MakeVisualTerrainDirty()
+ {
+ if (m_Terrain->GetPatchesPerSide() != m_MapSizePatches)
+ m_Terrain->Resize(m_MapSizePatches);
+
+ if (m_MapSizePatches)
+ RecalculateVisualHeightmap();
+ }
+
virtual CFixedVector3D CalcNormal(entity_pos_t x, entity_pos_t z)
{
CFixedVector3D normal;
@@ -83,7 +109,6 @@
virtual entity_pos_t GetGroundLevel(entity_pos_t x, entity_pos_t z)
{
// TODO: this can crash if the terrain heightmap isn't initialised yet
-
return m_Terrain->GetExactGroundLevelFixed(x, z);
}
@@ -94,7 +119,7 @@
virtual u16 GetTilesPerSide()
{
- ssize_t tiles = m_Terrain->GetTilesPerSide();
+ ssize_t tiles = m_MapSizePatches * PATCH_SIZE;
ENSURE(1 <= tiles && tiles <= 65535);
return (u16)tiles;
}
@@ -101,8 +126,8 @@
virtual u16 GetVerticesPerSide()
{
- ssize_t vertices = m_Terrain->GetVerticesPerSide();
- ENSURE(1 <= vertices && vertices <= 65535);
+ ssize_t vertices = m_MapSizePatches * PATCH_SIZE + 1;
+ ENSURE(1 < vertices && vertices <= 65535);
return (u16)vertices;
}
@@ -111,10 +136,115 @@
return m_Terrain;
}
+ struct IterateHeightmapAverage
+ {
+ u16* heightmap;
+ int pitch;
+
+ // weighted sum of the wanted heights
+ fixed* avgHeightmap;
+ // sum of the weights
+ fixed* sumWeightmap;
+
+ void operator()(int i, int j, fixed weight, fixed newHeight)
+ {
+ if (weight > fixed::Zero())
+ {
+ fixed sumWeight = sumWeightmap[i+j*pitch] + weight;
+ // avoid overflows by dividing before multiplying
+ avgHeightmap[i+j*pitch] = (avgHeightmap[i+j*pitch]/sumWeight).Multiply(sumWeightmap[i+j*pitch]) + (newHeight/sumWeight).Multiply(weight);
+
+ sumWeightmap[i+j*pitch] = sumWeight;
+ int h = HEIGHT_UNITS_PER_METRE*avgHeightmap[i+j*pitch].ToInt_RoundToNearest();
+ heightmap[i + j*pitch] = Clamp(h, 0, 65535);
+ }
+ }
+ };
+
+ template
+ void IterateHeightmap(T& callback, CFixedVector2D pos, fixed angle, entity_id_t ent)
+ {
+ CmpPtr CCmpTerrainModifier(GetSimContext(), ent);
+ // get the bbox, multiply by sqrt(2)/2 (rounded up) to get half the size and take
+ // account of possible rotations
+ fixed BBoxSize = CCmpTerrainModifier->GetBBox()/2;
+ fixed maxBBoxSize = BBoxSize*142/100;
+ int numVerts = m_MapSizePatches*PATCH_SIZE + 1;
+
+ int i0 = ((pos.X - maxBBoxSize) / TERRAIN_TILE_SIZE).ToInt_RoundToNegInfinity();
+ int i1 = ((pos.X + maxBBoxSize) / TERRAIN_TILE_SIZE).ToInt_RoundToInfinity();
+ int j0 = ((pos.Y - maxBBoxSize) / TERRAIN_TILE_SIZE).ToInt_RoundToNegInfinity();
+ int j1 = ((pos.Y + maxBBoxSize) / TERRAIN_TILE_SIZE).ToInt_RoundToInfinity();
+ i0 = Clamp(i0, 0, numVerts);
+ i1 = Clamp(i1, 0, numVerts);
+ j0 = Clamp(j0, 0, numVerts);
+ j1 = Clamp(j1, 0, numVerts);
+
+ fixed entHeight = m_Terrain->GetExactGroundLevelFixed(pos.X, pos.Y);
+ for (int j = j0; j <= j1; ++j)
+ {
+ for (int i = i0; i <= i1; ++i)
+ {
+ CFixedVector2D pt = CFixedVector2D(fixed::FromInt(i*TERRAIN_TILE_SIZE), fixed::FromInt(j*TERRAIN_TILE_SIZE)) - CFixedVector2D(pos.X, pos.Y);
+ pt = pt.Rotate(-angle);
+ if (pt.X.Absolute() > BBoxSize || pt.Y.Absolute() > BBoxSize)
+ continue;
+ fixed oldHeight = m_Terrain->GetVertexGroundLevelFixed(i, j);
+ fixed newHeight, weight;
+ CCmpTerrainModifier->GetNewHeight(pt, oldHeight, entHeight, newHeight, weight);
+ callback(i, j, weight, newHeight);
+ }
+ }
+ MakeDirty(i0, j0, i1, j1);
+ }
+
+ void RecalculateVisualHeightmap()
+ {
+ u16* heightmap = m_Terrain->GetHeightMap();
+ int pitch = m_MapSizePatches * PATCH_SIZE + 1;
+ std::vector tempHeightmap(pitch*pitch);
+ memcpy(&tempHeightmap[0], &m_SimHeightmap[0], pitch * pitch * sizeof(u16));
+ memcpy(heightmap, &m_SimHeightmap[0], pitch * pitch * sizeof(u16));
+
+ IterateHeightmapAverage callback;
+ callback.heightmap = &tempHeightmap[0];
+ callback.pitch = pitch;
+ std::vector avgHeightmap(pitch * pitch, fixed::Zero());
+ callback.avgHeightmap = &avgHeightmap[0];
+ std::vector sumWeightmap(pitch * pitch, fixed::Zero());
+ callback.sumWeightmap = &sumWeightmap[0];
+
+ CComponentManager::InterfaceList ents = GetSimContext().GetComponentManager().GetEntitiesWithInterface(IID_TerrainModifier);
+ for (CComponentManager::InterfaceList::const_iterator it = ents.begin(); it != ents.end(); ++it)
+ {
+ CmpPtr cmpPosition(GetSimContext(), it->first);
+ if (cmpPosition)
+ {
+ CFixedVector2D pos = cmpPosition->GetPosition2D();
+ fixed angle = cmpPosition->GetRotation().Y;
+
+ IterateHeightmap(callback, pos, angle, it->first);
+ }
+ }
+
+ memcpy(heightmap, &tempHeightmap[0], pitch * pitch * sizeof(u16));
+ m_Terrain->MakeDirty(RENDERDATA_UPDATE_VERTICES);
+ }
+
virtual void ReloadTerrain()
{
// TODO: should refactor this code to be nicer
+ m_MapSizePatches = m_Terrain->GetPatchesPerSide();
+ if (!m_MapSizePatches)
+ return;// terrain wasn't loaded yet, this method must be called manually
+ size_t size = (m_MapSizePatches * PATCH_SIZE + 1)*(m_MapSizePatches * PATCH_SIZE + 1);
+ m_SimHeightmap.resize(size);
+ if (m_Terrain->GetHeightMap())
+ memcpy(&m_SimHeightmap[0], m_Terrain->GetHeightMap(), size*sizeof(u16));
+ else
+ memset(&m_SimHeightmap[0], 0, size*sizeof(u16));
+
u16 tiles = GetTilesPerSide();
u16 vertices = GetVerticesPerSide();
@@ -138,7 +268,8 @@
if (CRenderer::IsInitialised())
g_Renderer.GetWaterManager()->SetMapSize(vertices);
- MakeDirty(0, 0, tiles+1, tiles+1);
+ MakeVisualTerrainDirty();
+ MakeDirty(0, 0, tiles + 1, tiles + 1);
}
virtual void MakeDirty(i32 i0, i32 j0, i32 i1, i32 j1)
Index: source/simulation2/components/ICmpTerrain.cpp
===================================================================
--- source/simulation2/components/ICmpTerrain.cpp (revision 14215)
+++ source/simulation2/components/ICmpTerrain.cpp (working copy)
@@ -24,4 +24,5 @@
BEGIN_INTERFACE_WRAPPER(Terrain)
DEFINE_INTERFACE_METHOD_2("GetGroundLevel", entity_pos_t, ICmpTerrain, GetGroundLevel, entity_pos_t, entity_pos_t)
DEFINE_INTERFACE_METHOD_2("CalcNormal", CFixedVector3D, ICmpTerrain, CalcNormal, entity_pos_t, entity_pos_t)
+DEFINE_INTERFACE_METHOD_0("MakeVisualTerrainDirty", void, ICmpTerrain, MakeVisualTerrainDirty)
END_INTERFACE_WRAPPER(Terrain)
Index: source/simulation2/components/ICmpTerrain.h
===================================================================
--- source/simulation2/components/ICmpTerrain.h (revision 14215)
+++ source/simulation2/components/ICmpTerrain.h (working copy)
@@ -32,6 +32,10 @@
public:
virtual bool IsLoaded() = 0;
+ virtual u16* GetSimHeightMap() = 0;
+
+ virtual void MakeVisualTerrainDirty() = 0;
+
virtual CFixedVector3D CalcNormal(entity_pos_t x, entity_pos_t z) = 0;
virtual CVector3D CalcExactNormal(float x, float z) = 0;
Index: source/simulation2/system/ComponentTest.h
===================================================================
--- source/simulation2/system/ComponentTest.h (revision 14215)
+++ source/simulation2/system/ComponentTest.h (working copy)
@@ -229,4 +229,13 @@
virtual void ReloadTerrain()
{
}
+
+ virtual void MakeVisualTerrainDirty()
+ {
+ }
+
+ virtual u16* GetSimHeightMap()
+ {
+ return NULL;
+ }
};
Index: source/tools/atlas/GameInterface/Handlers/ElevationHandlers.cpp
===================================================================
--- source/tools/atlas/GameInterface/Handlers/ElevationHandlers.cpp (revision 14215)
+++ source/tools/atlas/GameInterface/Handlers/ElevationHandlers.cpp (working copy)
@@ -41,6 +41,9 @@
void Init()
{
m_Heightmap = g_Game->GetWorld()->GetTerrain()->GetHeightMap();
+ CmpPtr cmpTerrain(*g_Game->GetSimulation2(), SYSTEM_ENTITY);
+ if (cmpTerrain)
+ m_SimHeightmap = cmpTerrain->GetSimHeightMap();
m_VertsPerSide = g_Game->GetWorld()->GetTerrain()->GetVerticesPerSide();
}
@@ -90,9 +93,12 @@
void setNew(ssize_t x, ssize_t y, const u16& val)
{
m_Heightmap[y*m_VertsPerSide + x] = val;
+ if (m_SimHeightmap)
+ m_SimHeightmap[y*m_VertsPerSide + x] = val;
}
u16* m_Heightmap;
+ u16* m_SimHeightmap;
ssize_t m_VertsPerSide;
};