Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/Terrain.cpp
Show First 20 Lines • Show All 602 Lines • ▼ Show 20 Lines | void CTerrain::Resize(ssize_t size) | ||||
// initialise all the new patches | // initialise all the new patches | ||||
InitialisePatches(); | InitialisePatches(); | ||||
// initialise mipmap | // initialise mipmap | ||||
m_HeightMipmap.Initialize(m_MapSize,m_Heightmap); | m_HeightMipmap.Initialize(m_MapSize,m_Heightmap); | ||||
} | } | ||||
void CTerrain::ChangeHeight(ssize_t x, ssize_t z, u16 height) | |||||
{ | |||||
x = clamp((ssize_t)floor(x / (int)TERRAIN_TILE_SIZE), (ssize_t)0, m_MapSize-2); | |||||
Stan: We decided to use c++ casts in the convention s so static_cast<> | |||||
z = clamp((ssize_t)floor(z / (int)TERRAIN_TILE_SIZE), (ssize_t)0, m_MapSize-2); | |||||
u16 heightValue = height/HEIGHT_SCALE; | |||||
StanUnsubmitted Not Done Inline ActionsMight want to cast to float for the computation then cast back to u16. Stan: Might want to cast to float for the computation then cast back to u16. | |||||
// Maybe support for changing verteces height instead of the whole tile would be useful | |||||
lyvAuthorUnsubmitted Not Done Inline ActionsNeeds decision regarding this comment. lyv: Needs decision regarding this comment. | |||||
elexisUnsubmitted Not Done Inline ActionsList the advantages and disadvantages, then you might find the answer already. elexis: List the advantages and disadvantages, then you might find the answer already. | |||||
lyvAuthorUnsubmitted Not Done Inline Actionspros:
cons:
Well, I guess that decides it then. lyv: pros:
- Removes a pretty big restriction.
- Allow better terrain geometry.
- I… | |||||
m_Heightmap[z * m_MapSize + x] = heightValue; | |||||
m_Heightmap[(z+1) * m_MapSize + x] = heightValue; | |||||
m_Heightmap[z * m_MapSize + (x+1)] = heightValue; | |||||
m_Heightmap[(z+1) * m_MapSize + (x+1)] = heightValue; | |||||
StanUnsubmitted Not Done Inline ActionsMissing spaces between operators. Stan: Missing spaces between operators. | |||||
} | |||||
/////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||
// InitialisePatches: initialise patch data | // InitialisePatches: initialise patch data | ||||
void CTerrain::InitialisePatches() | void CTerrain::InitialisePatches() | ||||
{ | { | ||||
for (ssize_t j = 0; j < m_MapSizePatches; j++) | for (ssize_t j = 0; j < m_MapSizePatches; j++) | ||||
{ | { | ||||
for (ssize_t i = 0; i < m_MapSizePatches; i++) | for (ssize_t i = 0; i < m_MapSizePatches; i++) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
We decided to use c++ casts in the convention s so static_cast<>