Changeset 25278
- Timestamp:
- Apr 16, 2021, 6:01:30 PM (3 years ago)
- Location:
- ps/trunk/source
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/source/graphics/Camera.cpp
r25269 r25278 263 263 if (gotWater) 264 264 { 265 waterPoint.X = Clamp (waterPoint.X, 0.f, (mapSize - 1) * TERRAIN_TILE_SIZE);266 waterPoint.Z = Clamp (waterPoint.Z, 0.f, (mapSize - 1) * TERRAIN_TILE_SIZE);265 waterPoint.X = Clamp(waterPoint.X, 0.f, (mapSize - 1) * TERRAIN_TILE_SIZE); 266 waterPoint.Z = Clamp(waterPoint.Z, 0.f, (mapSize - 1) * TERRAIN_TILE_SIZE); 267 267 } 268 268 … … 341 341 if (gotWater) 342 342 { 343 waterPoint.X = Clamp (waterPoint.X, 0.f, (mapSize - 1) * TERRAIN_TILE_SIZE);344 waterPoint.Z = Clamp (waterPoint.Z, 0.f, (mapSize - 1) * TERRAIN_TILE_SIZE);343 waterPoint.X = Clamp(waterPoint.X, 0.f, (mapSize - 1) * TERRAIN_TILE_SIZE); 344 waterPoint.Z = Clamp(waterPoint.Z, 0.f, (mapSize - 1) * TERRAIN_TILE_SIZE); 345 345 } 346 346 -
ps/trunk/source/graphics/Decal.cpp
r25266 r25278 46 46 j1 = ceil(std::max(std::max(corner0.Z, corner1.Z), std::max(corner2.Z, corner3.Z)) / TERRAIN_TILE_SIZE); 47 47 48 i0 = Clamp (i0, 0, m_Terrain->GetVerticesPerSide() - 1);49 j0 = Clamp (j0, 0, m_Terrain->GetVerticesPerSide() - 1);50 i1 = Clamp (i1, 0, m_Terrain->GetVerticesPerSide() - 1);51 j1 = Clamp (j1, 0, m_Terrain->GetVerticesPerSide() - 1);48 i0 = Clamp(i0, 0, m_Terrain->GetVerticesPerSide() - 1); 49 j0 = Clamp(j0, 0, m_Terrain->GetVerticesPerSide() - 1); 50 i1 = Clamp(i1, 0, m_Terrain->GetVerticesPerSide() - 1); 51 j1 = Clamp(j1, 0, m_Terrain->GetVerticesPerSide() - 1); 52 52 } 53 53 -
ps/trunk/source/graphics/SmoothedValue.h
r25266 r25278 73 73 void ClampSmoothly(float min, float max) 74 74 { 75 m_Target = Clamp (m_Target, min, max);75 m_Target = Clamp(m_Target, min, max); 76 76 } 77 77 -
ps/trunk/source/graphics/Terrain.cpp
r25266 r25278 119 119 void CTerrain::CalcPosition(ssize_t i, ssize_t j, CVector3D& pos) const 120 120 { 121 ssize_t hi = Clamp (i, 0, m_MapSize - 1);122 ssize_t hj = Clamp (j, 0, m_MapSize - 1);121 ssize_t hi = Clamp(i, 0, m_MapSize - 1); 122 ssize_t hj = Clamp(j, 0, m_MapSize - 1); 123 123 u16 height = m_Heightmap[hj*m_MapSize + hi]; 124 124 pos.X = float(i*TERRAIN_TILE_SIZE); … … 131 131 void CTerrain::CalcPositionFixed(ssize_t i, ssize_t j, CFixedVector3D& pos) const 132 132 { 133 ssize_t hi = Clamp (i, 0, m_MapSize - 1);134 ssize_t hj = Clamp (j, 0, m_MapSize - 1);133 ssize_t hi = Clamp(i, 0, m_MapSize - 1); 134 ssize_t hj = Clamp(j, 0, m_MapSize - 1); 135 135 u16 height = m_Heightmap[hj*m_MapSize + hi]; 136 136 pos.X = fixed::FromInt(i) * (int)TERRAIN_TILE_SIZE; … … 309 309 float CTerrain::GetVertexGroundLevel(ssize_t i, ssize_t j) const 310 310 { 311 i = Clamp (i, 0, m_MapSize - 1);312 j = Clamp (j, 0, m_MapSize - 1);311 i = Clamp(i, 0, m_MapSize - 1); 312 j = Clamp(j, 0, m_MapSize - 1); 313 313 return HEIGHT_SCALE * m_Heightmap[j*m_MapSize + i]; 314 314 } … … 316 316 fixed CTerrain::GetVertexGroundLevelFixed(ssize_t i, ssize_t j) const 317 317 { 318 i = Clamp (i, 0, m_MapSize - 1);319 j = Clamp (j, 0, m_MapSize - 1);318 i = Clamp(i, 0, m_MapSize - 1); 319 j = Clamp(j, 0, m_MapSize - 1); 320 320 // Convert to fixed metres (being careful to avoid intermediate overflows) 321 321 return fixed::FromInt(m_Heightmap[j*m_MapSize + i] / 2) / (int)(HEIGHT_UNITS_PER_METRE / 2); … … 325 325 { 326 326 // Clamp to size-2 so we can use the tiles (i,j)-(i+1,j+1) 327 i = Clamp (i, 0, m_MapSize - 2);328 j = Clamp (j, 0, m_MapSize - 2);327 i = Clamp(i, 0, m_MapSize - 2); 328 j = Clamp(j, 0, m_MapSize - 2); 329 329 330 330 u16 h00 = m_Heightmap[j*m_MapSize + i]; … … 481 481 { 482 482 // Clamp to size-2 so we can use the tiles (i,j)-(i+1,j+1) 483 i = Clamp (i, 0, m_MapSize - 2);484 j = Clamp (j, 0, m_MapSize - 2);483 i = Clamp(i, 0, m_MapSize - 2); 484 j = Clamp(j, 0, m_MapSize - 2); 485 485 486 486 int h00 = m_Heightmap[j*m_MapSize + i]; … … 775 775 { 776 776 // Finds the inclusive limits of the patches that include the specified range of tiles 777 ssize_t pi0 = Clamp ( i0 /PATCH_SIZE, 0, m_MapSizePatches-1);778 ssize_t pi1 = Clamp ((i1-1)/PATCH_SIZE, 0, m_MapSizePatches-1);779 ssize_t pj0 = Clamp ( j0 /PATCH_SIZE, 0, m_MapSizePatches-1);780 ssize_t pj1 = Clamp ((j1-1)/PATCH_SIZE, 0, m_MapSizePatches-1);777 ssize_t pi0 = Clamp( i0 /PATCH_SIZE, 0, m_MapSizePatches-1); 778 ssize_t pi1 = Clamp((i1-1)/PATCH_SIZE, 0, m_MapSizePatches-1); 779 ssize_t pj0 = Clamp( j0 /PATCH_SIZE, 0, m_MapSizePatches-1); 780 ssize_t pj1 = Clamp((j1-1)/PATCH_SIZE, 0, m_MapSizePatches-1); 781 781 782 782 for (ssize_t j = pj0; j <= pj1; j++) … … 794 794 { 795 795 m_HeightMipmap.Update(m_Heightmap, 796 Clamp (i0, 0, m_MapSize - 1),797 Clamp (j0, 0, m_MapSize - 1),798 Clamp (i1, 1, m_MapSize),799 Clamp (j1, 1, m_MapSize)796 Clamp(i0, 0, m_MapSize - 1), 797 Clamp(j0, 0, m_MapSize - 1), 798 Clamp(i1, 1, m_MapSize), 799 Clamp(j1, 1, m_MapSize) 800 800 ); 801 801 } … … 821 821 CBoundingBoxAligned CTerrain::GetVertexesBound(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1) 822 822 { 823 i0 = Clamp (i0, 0, m_MapSize - 1);824 j0 = Clamp (j0, 0, m_MapSize - 1);825 i1 = Clamp (i1, 0, m_MapSize - 1);826 j1 = Clamp (j1, 0, m_MapSize - 1);823 i0 = Clamp(i0, 0, m_MapSize - 1); 824 j0 = Clamp(j0, 0, m_MapSize - 1); 825 i1 = Clamp(i1, 0, m_MapSize - 1); 826 j1 = Clamp(j1, 0, m_MapSize - 1); 827 827 828 828 u16 minH = 65535; -
ps/trunk/source/maths/MathUtil.h
r25266 r25278 29 29 } 30 30 31 // TODO C++20: use the proper one.32 template<typename T>33 struct type_identity34 {35 using type = T;36 };37 template<typename T>38 using type_identity_t = typename type_identity<T>::type;39 40 31 template <typename T> 41 inline T Clamp(T value, type_identity_t<T> min, type_identity_t<T>max)32 inline T Clamp(T value, max) 42 33 { 43 34 if (value <= min) -
ps/trunk/source/renderer/SilhouetteRenderer.cpp
r25269 r25278 191 191 // given the symmetry of the bounding box 192 192 193 occluder.x0 = Clamp(x0, std::numeric_limits<u16>::min(), g_MaxCoord - 1);194 occluder.y0 = Clamp(y0, std::numeric_limits<u16>::min(), g_MaxCoord - 1);195 occluder.x1 = Clamp(x1, std::numeric_limits<u16>::min(), g_MaxCoord - 1);196 occluder.y1 = Clamp(y1, std::numeric_limits<u16>::min(), g_MaxCoord - 1);193 occluder.x0 = Clamp(x0, std::numeric_limits<u16>::min(), ); 194 occluder.y0 = Clamp(y0, std::numeric_limits<u16>::min(), ); 195 occluder.x1 = Clamp(x1, std::numeric_limits<u16>::min(), ); 196 occluder.y1 = Clamp(y1, std::numeric_limits<u16>::min(), ); 197 197 occluder.z = z0; 198 198 } … … 203 203 u16 x = g_HalfMaxCoord + static_cast<int>(g_HalfMaxCoord * svec.X / svec.W); 204 204 u16 y = g_HalfMaxCoord + static_cast<int>(g_HalfMaxCoord * svec.Y / svec.W); 205 caster.x = Clamp(x, std::numeric_limits<u16>::min(), g_MaxCoord - 1);206 caster.y = Clamp(y, std::numeric_limits<u16>::min(), g_MaxCoord - 1);205 caster.x = Clamp(x, std::numeric_limits<u16>::min(), ); 206 caster.y = Clamp(y, std::numeric_limits<u16>::min(), ); 207 207 caster.z = svec.Z / svec.W; 208 208 } -
ps/trunk/source/simulation2/components/CCmpPathfinder.cpp
r25266 r25278 614 614 // level are calculated by multiple neighboring tiles. 615 615 // TODO: add CTerrain constant instead of 1. 616 istart = Clamp (itile0 - 1, 0, m_MapSize) * Pathfinding::NAVCELLS_PER_TILE;617 iend = Clamp (itile1 + 1, 0, m_MapSize) * Pathfinding::NAVCELLS_PER_TILE;618 jstart = Clamp (jtile0 - 1, 0, m_MapSize) * Pathfinding::NAVCELLS_PER_TILE;619 jend = Clamp (jtile1 + 1, 0, m_MapSize) * Pathfinding::NAVCELLS_PER_TILE;616 �� istart = Clamp(itile0 - 1, 0, m_MapSize) * Pathfinding::NAVCELLS_PER_TILE; 617 iend = Clamp(itile1 + 1, 0, m_MapSize) * Pathfinding::NAVCELLS_PER_TILE; 618 jstart = Clamp(jtile0 - 1, 0, m_MapSize) * Pathfinding::NAVCELLS_PER_TILE; 619 jend = Clamp(jtile1 + 1, 0, m_MapSize) * Pathfinding::NAVCELLS_PER_TILE; 620 620 } 621 621
Note:
See TracChangeset
for help on using the changeset viewer.