40#include "flat/render/terrainresource.h"
73 float hardness = 0.5f;
76 float strength = 0.5f;
81class TerrainSession :
public Core::RefCounted
94 virtual ~TerrainSession();
98 bool Open(Editor::Scene* scene, Game::Entity entity);
101 void Close(
bool restore =
true);
111 Game::Entity GetEntity()
const;
112 const Util::Guid& GetEntityGuid()
const;
114 Graphics::GraphicsEntityId GetGraphicsEntity()
const;
117 const Util::String& GetFile()
const;
119 Util::String SuggestFile()
const;
122 Render::TerrainResourceT& GetResource();
125 void ApplyStructure();
127 void ApplyBiome(
IndexT biome);
128 void ApplyPlant(
IndexT plant);
131 void RemoveBiome(
IndexT biome);
133 void RemovePlant(
IndexT plant);
136 CoreGraphics::TextureId GetMapTexture(Map map,
IndexT index)
const;
138 int GetMapWidth()
const;
139 int GetMapHeight()
const;
142 bool HeightAt(
float x,
float z,
float& outHeight)
const;
144 bool Raycast(
const Math::line& ray, Math::vec3& outHit)
const;
147 void BeginStroke(Map map,
IndexT index);
149 void Stroke(
const TerrainBrush& brush,
const Math::vec3& center,
float seconds);
153 bool IsStroking()
const;
156 void WriteRegion(Map map,
IndexT index,
const Math::rectangle<int>& region,
const Util::FixedArray<float>& texels);
159 bool IsDirty()
const;
164 bool Save(
const Util::String& file, Util::String& outError);
169 Util::FixedArray<float> texels;
170 CoreGraphics::TextureId texture = CoreGraphics::InvalidTextureId;
171 Math::rectangle<int> dirty;
172 bool hasDirty =
false;
176 EditMap* GetMap(Map map,
IndexT index);
177 const EditMap* GetMap(Map map,
IndexT index)
const;
179 void CreateMapTexture(EditMap& map,
bool height,
const char* name);
181 static void DestroyMapTexture(EditMap& map);
183 void LoadMap(EditMap& map,
const Util::String& texture,
float fallback,
bool height,
const char* name);
185 void Resize(
int width,
int height);
187 static void Touch(EditMap& map,
const Math::rectangle<int>& region);
189 static void Upload(EditMap& map,
bool height);
196 bool SaveMap(
const EditMap& map,
bool height,
const Util::String& folder,
const Util::String& name, Util::String& outUrn, Util::String& outError);
198 Editor::Scene* scene;
200 Util::Guid entityGuid;
201 Graphics::GraphicsEntityId graphicsEntity;
203 Render::TerrainResourceT resource;
207 Util::Array<EditMap> biomes;
208 Util::Array<EditMap> plants;
213 Map map = Map::Height;
215 Util::FixedArray<float> before;
216 Math::rectangle<int> region;
217 bool touched =
false;
218 float flattenTarget = 0.0f;
219 bool hasFlattenTarget =
false;
Util::Pair< Memory::RangeAllocation, CoreGraphics::BufferId > Upload(const TYPE &data, const SizeT alignment=1)
Upload single item to GPU source buffer.
Definition graphicsdevice.h:429
Definition graphicsfeatureunit.cc:66
bool Raycast(Navigation::NavMeshId navMesh, const Math::point &start, const Math::point &end, Math::point &outHit, const QueryFilter *filter)
walk along the surface from start towards end. Returns true and the point where it is blocked if an e...
Definition navquery.cc:231
Physics::Scene & GetScene(IndexT idx)
Definition physicsinterface.cc:210
@ Update
Definition resourceloader.h:53
#define __DeclareClass(type)
int IndexT
Definition types.h:49