Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/Terrain.cpp
Show All 17 Lines | |||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "graphics/Terrain.h" | #include "graphics/Terrain.h" | ||||
#include "graphics/Patch.h" | #include "graphics/Patch.h" | ||||
#include "graphics/TerrainProperties.h" | #include "graphics/TerrainProperties.h" | ||||
#include "graphics/TerrainTextureEntry.h" | #include "graphics/TerrainTextureEntry.h" | ||||
#include "graphics/TerrainTextureManager.h" | #include "graphics/TerrainTextureManager.h" | ||||
#include "graphics/Water.h" | |||||
#include "lib/sysdep/cpu.h" | #include "lib/sysdep/cpu.h" | ||||
#include "maths/FixedVector3D.h" | #include "maths/FixedVector3D.h" | ||||
#include "maths/MathUtil.h" | #include "maths/MathUtil.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "simulation2/helpers/Pathfinding.h" | #include "simulation2/helpers/Pathfinding.h" | ||||
#include <string.h> | #include <string.h> | ||||
▲ Show 20 Lines • Show All 762 Lines • ▼ Show 20 Lines | for (ssize_t i = 0; i < m_MapSizePatches; i++) | ||||
patch->SetDirty(dirtyFlags); | patch->SetDirty(dirtyFlags); | ||||
} | } | ||||
} | } | ||||
if (m_Heightmap) | if (m_Heightmap) | ||||
m_HeightMipmap.Update(m_Heightmap); | m_HeightMipmap.Update(m_Heightmap); | ||||
} | } | ||||
CBoundingBoxAligned CTerrain::GetVertexesBound(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1) | CBoundingBoxAligned CTerrain::GetVertexesBound(CWater* water, ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1) | ||||
{ | { | ||||
i0 = Clamp<ssize_t>(i0, 0, m_MapSize - 1); | i0 = Clamp<ssize_t>(i0, 0, m_MapSize - 1); | ||||
j0 = Clamp<ssize_t>(j0, 0, m_MapSize - 1); | j0 = Clamp<ssize_t>(j0, 0, m_MapSize - 1); | ||||
i1 = Clamp<ssize_t>(i1, 0, m_MapSize - 1); | i1 = Clamp<ssize_t>(i1, 0, m_MapSize - 1); | ||||
j1 = Clamp<ssize_t>(j1, 0, m_MapSize - 1); | j1 = Clamp<ssize_t>(j1, 0, m_MapSize - 1); | ||||
u16 minH = 65535; | u16 minH = 65535; | ||||
u16 maxH = 0; | u16 maxH = 0; | ||||
for (ssize_t j = j0; j <= j1; ++j) | for (ssize_t j = j0; j <= j1; ++j) | ||||
{ | { | ||||
for (ssize_t i = i0; i <= i1; ++i) | for (ssize_t i = i0; i <= i1; ++i) | ||||
{ | { | ||||
minH = std::min(minH, m_Heightmap[j*m_MapSize + i]); | minH = std::min(minH, m_Heightmap[j*m_MapSize + i]); | ||||
maxH = std::max(maxH, m_Heightmap[j*m_MapSize + i]); | maxH = std::max(maxH, m_Heightmap[j*m_MapSize + i]); | ||||
} | } | ||||
} | } | ||||
u16 waterHeight = water->GetWaterHeight() * HEIGHT_SCALE; | |||||
minH = std::min(waterHeight, minH); | |||||
maxH = std::max(waterHeight, maxH); | |||||
CBoundingBoxAligned bound; | CBoundingBoxAligned bound; | ||||
bound[0].X = (float)(i0*TERRAIN_TILE_SIZE); | bound[0].X = (float)(i0*TERRAIN_TILE_SIZE); | ||||
bound[0].Y = (float)(minH*HEIGHT_SCALE); | bound[0].Y = (float)(minH*HEIGHT_SCALE); | ||||
bound[0].Z = (float)(j0*TERRAIN_TILE_SIZE); | bound[0].Z = (float)(j0*TERRAIN_TILE_SIZE); | ||||
bound[1].X = (float)(i1*TERRAIN_TILE_SIZE); | bound[1].X = (float)(i1*TERRAIN_TILE_SIZE); | ||||
bound[1].Y = (float)(maxH*HEIGHT_SCALE); | bound[1].Y = (float)(maxH*HEIGHT_SCALE); | ||||
bound[1].Z = (float)(j1*TERRAIN_TILE_SIZE); | bound[1].Z = (float)(j1*TERRAIN_TILE_SIZE); | ||||
return bound; | return bound; | ||||
} | } |
Wildfire Games · Phabricator