Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpTerrain.cpp
Show All 19 Lines | |||||
#include "simulation2/system/Component.h" | #include "simulation2/system/Component.h" | ||||
#include "ICmpTerrain.h" | #include "ICmpTerrain.h" | ||||
#include "ICmpObstructionManager.h" | #include "ICmpObstructionManager.h" | ||||
#include "ICmpRangeManager.h" | #include "ICmpRangeManager.h" | ||||
#include "simulation2/MessageTypes.h" | #include "simulation2/MessageTypes.h" | ||||
#include "graphics/Terrain.h" | #include "graphics/Terrain.h" | ||||
#include "graphics/WaterManager.h" | |||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "renderer/WaterManager.h" | |||||
#include "maths/Vector3D.h" | #include "maths/Vector3D.h" | ||||
class CCmpTerrain : public ICmpTerrain | class CCmpTerrain : public ICmpTerrain | ||||
{ | { | ||||
public: | public: | ||||
static void ClassInit(CComponentManager& UNUSED(componentManager)) | static void ClassInit(CComponentManager& UNUSED(componentManager)) | ||||
{ | { | ||||
} | } | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | virtual u16 GetVerticesPerSide() const | ||||
return (u16)vertices; | return (u16)vertices; | ||||
} | } | ||||
virtual CTerrain* GetCTerrain() | virtual CTerrain* GetCTerrain() | ||||
{ | { | ||||
return m_Terrain; | return m_Terrain; | ||||
} | } | ||||
virtual void ReloadTerrain(bool ReloadWater) | virtual void ReloadTerrain() | ||||
phosit: why did you change from override to virtual?
same for other functions | |||||
Done Inline ActionsThink that's just rebase trouble wraitii: Think that's just rebase trouble | |||||
{ | { | ||||
// TODO: should refactor this code to be nicer | // TODO: should refactor this code to be nicer | ||||
u16 tiles = GetTilesPerSide(); | u16 tiles = GetTilesPerSide(); | ||||
u16 vertices = GetVerticesPerSide(); | u16 vertices = GetVerticesPerSide(); | ||||
CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); | CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); | ||||
if (cmpObstructionManager) | if (cmpObstructionManager) | ||||
{ | { | ||||
cmpObstructionManager->SetBounds(entity_pos_t::Zero(), entity_pos_t::Zero(), | cmpObstructionManager->SetBounds(entity_pos_t::Zero(), entity_pos_t::Zero(), | ||||
entity_pos_t::FromInt(tiles*(int)TERRAIN_TILE_SIZE), | entity_pos_t::FromInt(tiles*(int)TERRAIN_TILE_SIZE), | ||||
entity_pos_t::FromInt(tiles*(int)TERRAIN_TILE_SIZE)); | entity_pos_t::FromInt(tiles*(int)TERRAIN_TILE_SIZE)); | ||||
} | } | ||||
CmpPtr<ICmpRangeManager> cmpRangeManager(GetSystemEntity()); | CmpPtr<ICmpRangeManager> cmpRangeManager(GetSystemEntity()); | ||||
if (cmpRangeManager) | if (cmpRangeManager) | ||||
{ | { | ||||
cmpRangeManager->SetBounds(entity_pos_t::Zero(), entity_pos_t::Zero(), | cmpRangeManager->SetBounds(entity_pos_t::Zero(), entity_pos_t::Zero(), | ||||
entity_pos_t::FromInt(tiles*(int)TERRAIN_TILE_SIZE), | entity_pos_t::FromInt(tiles*(int)TERRAIN_TILE_SIZE), | ||||
entity_pos_t::FromInt(tiles*(int)TERRAIN_TILE_SIZE), | entity_pos_t::FromInt(tiles*(int)TERRAIN_TILE_SIZE), | ||||
vertices); | vertices); | ||||
} | } | ||||
if (ReloadWater && CRenderer::IsInitialised()) | |||||
{ | |||||
g_Renderer.GetWaterManager()->SetMapSize(vertices); | |||||
g_Renderer.GetWaterManager()->RecomputeWaterData(); | |||||
} | |||||
MakeDirty(0, 0, tiles+1, tiles+1); | MakeDirty(0, 0, tiles+1, tiles+1); | ||||
} | } | ||||
virtual void MakeDirty(i32 i0, i32 j0, i32 i1, i32 j1) | virtual void MakeDirty(i32 i0, i32 j0, i32 i1, i32 j1) | ||||
{ | { | ||||
CMessageTerrainChanged msg(i0, j0, i1, j1); | CMessageTerrainChanged msg(i0, j0, i1, j1); | ||||
GetSimContext().GetComponentManager().BroadcastMessage(msg); | GetSimContext().GetComponentManager().BroadcastMessage(msg); | ||||
Done Inline ActionsThis was previously done in WaterManager for some reason wraitii: This was previously done in WaterManager for some reason | |||||
} | } | ||||
}; | }; | ||||
REGISTER_COMPONENT_TYPE(Terrain) | REGISTER_COMPONENT_TYPE(Terrain) |
Wildfire Games · Phabricator
why did you change from override to virtual?
same for other functions