Changeset 10902
- Timestamp:
- Jan 12, 2012, 1:51:10 PM (13 years ago)
- Location:
- ps/trunk/source
- Files:
-
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/source/graphics/Camera.cpp
r10593 r10902 234 234 if (gotWater) 235 235 { 236 waterPoint.X = clamp(waterPoint.X, 0.f, (float)((mapSize-1)* CELL_SIZE));237 waterPoint.Z = clamp(waterPoint.Z, 0.f, (float)((mapSize-1)* CELL_SIZE));236 waterPoint.X = clamp(waterPoint.X, 0.f, (float)((mapSize-1)*_SIZE)); 237 waterPoint.Z = clamp(waterPoint.Z, 0.f, (float)((mapSize-1)*_SIZE)); 238 238 } 239 239 … … 312 312 if (gotWater) 313 313 { 314 waterPoint.X = clamp(waterPoint.X, 0.f, (float)((mapSize-1)* CELL_SIZE));315 waterPoint.Z = clamp(waterPoint.Z, 0.f, (float)((mapSize-1)* CELL_SIZE));314 waterPoint.X = clamp(waterPoint.X, 0.f, (float)((mapSize-1)*_SIZE)); 315 waterPoint.Z = clamp(waterPoint.Z, 0.f, (float)((mapSize-1)*_SIZE)); 316 316 } 317 317 -
ps/trunk/source/graphics/Decal.cpp
r10593 r10902 41 41 corner3 = GetTransform().Transform(corner3); 42 42 43 i0 = floor(std::min(std::min(corner0.X, corner1.X), std::min(corner2.X, corner3.X)) / CELL_SIZE);44 j0 = floor(std::min(std::min(corner0.Z, corner1.Z), std::min(corner2.Z, corner3.Z)) / CELL_SIZE);45 i1 = ceil(std::max(std::max(corner0.X, corner1.X), std::max(corner2.X, corner3.X)) / CELL_SIZE);46 j1 = ceil(std::max(std::max(corner0.Z, corner1.Z), std::max(corner2.Z, corner3.Z)) / CELL_SIZE);43 i0 = floor(std::min(std::min(corner0.X, corner1.X), std::min(corner2.X, corner3.X)) / _SIZE); 44 j0 = floor(std::min(std::min(corner0.Z, corner1.Z), std::min(corner2.Z, corner3.Z)) / _SIZE); 45 i1 = ceil(std::max(std::max(corner0.X, corner1.X), std::max(corner2.X, corner3.X)) / _SIZE); 46 j1 = ceil(std::max(std::max(corner0.Z, corner1.Z), std::max(corner2.Z, corner3.Z)) / _SIZE); 47 47 48 48 i0 = clamp(i0, (ssize_t)0, m_Terrain->GetVerticesPerSide()-1); -
ps/trunk/source/graphics/GameView.cpp
r10865 r10902 62 62 // Maximum distance outside the edge of the map that the camera's 63 63 // focus point can be moved 64 static const float CAMERA_EDGE_MARGIN = 2.0f* CELL_SIZE;64 static const float CAMERA_EDGE_MARGIN = 2.0f*_SIZE; 65 65 66 66 /** -
ps/trunk/source/graphics/HFTracer.cpp
r10593 r10902 41 41 m_Heightfield(m_pTerrain->GetHeightMap()), 42 42 m_MapSize(m_pTerrain->GetVerticesPerSide()), 43 m_CellSize((float) CELL_SIZE),43 m_CellSize((float)_SIZE), 44 44 m_HeightScale(HEIGHT_SCALE) 45 45 { -
ps/trunk/source/graphics/LOSTexture.cpp
r9889 r10902 136 136 // onto texcoord ((mapsize-0.5) / texsize, (mapsize-0.5) / texsize) (i.e. middle of last texel) 137 137 138 float s = (m_MapSize-1) / (float)(m_TextureSize * (m_MapSize-1) * CELL_SIZE);138 float s = (m_MapSize-1) / (float)(m_TextureSize * (m_MapSize-1) * _SIZE); 139 139 float t = 0.5f / m_TextureSize; 140 140 m_TextureMatrix.SetZero(); -
ps/trunk/source/graphics/Terrain.cpp
r10593 r10902 113 113 ssize_t hj = clamp(j, (ssize_t)0, m_MapSize-1); 114 114 u16 height = m_Heightmap[hj*m_MapSize + hi]; 115 pos.X = float(i* CELL_SIZE);115 pos.X = float(i*_SIZE); 116 116 pos.Y = float(height*HEIGHT_SCALE); 117 pos.Z = float(j* CELL_SIZE);117 pos.Z = float(j*_SIZE); 118 118 } 119 119 … … 125 125 ssize_t hj = clamp(j, (ssize_t)0, m_MapSize-1); 126 126 u16 height = m_Heightmap[hj*m_MapSize + hi]; 127 pos.X = fixed::FromInt(i) * (int) CELL_SIZE;127 pos.X = fixed::FromInt(i) * (int)_SIZE; 128 128 pos.Y = fixed::FromInt(height) / (int)HEIGHT_UNITS_PER_METRE; 129 pos.Z = fixed::FromInt(j) * (int) CELL_SIZE;129 pos.Z = fixed::FromInt(j) * (int)_SIZE; 130 130 } 131 131 … … 227 227 { 228 228 // Clamp to size-2 so we can use the tiles (xi,zi)-(xi+1,zi+1) 229 const ssize_t xi = clamp((ssize_t)floor(x/ CELL_SIZE), (ssize_t)0, m_MapSize-2);230 const ssize_t zi = clamp((ssize_t)floor(z/ CELL_SIZE), (ssize_t)0, m_MapSize-2);231 232 const float xf = clamp(x/ CELL_SIZE-xi, 0.0f, 1.0f);233 const float zf = clamp(z/ CELL_SIZE-zi, 0.0f, 1.0f);229 const ssize_t xi = clamp((ssize_t)floor(x/_SIZE), (ssize_t)0, m_MapSize-2); 230 const ssize_t zi = clamp((ssize_t)floor(z/_SIZE), (ssize_t)0, m_MapSize-2); 231 232 const float xf = clamp(x/_SIZE-xi, 0.0f, 1.0f); 233 const float zf = clamp(z/_SIZE-zi, 0.0f, 1.0f); 234 234 235 235 float h00 = m_Heightmap[zi*m_MapSize + xi]; … … 246 246 { 247 247 // Lower-left triangle (don't use h11) 248 return -CVector3D( CELL_SIZE, (h10-h00)*HEIGHT_SCALE, 0).Cross(CVector3D(0, (h01-h00)*HEIGHT_SCALE, CELL_SIZE)).Normalized();248 return -CVector3D(_SIZE)).Normalized(); 249 249 } 250 250 else 251 251 { 252 252 // Upper-right triangle (don't use h00) 253 return -CVector3D( CELL_SIZE, (h11-h01)*HEIGHT_SCALE, 0).Cross(CVector3D(0, (h11-h10)*HEIGHT_SCALE, CELL_SIZE)).Normalized();253 return -CVector3D(_SIZE)).Normalized(); 254 254 } 255 255 } … … 259 259 { 260 260 // Upper-left triangle (don't use h10) 261 return -CVector3D( CELL_SIZE, (h11-h01)*HEIGHT_SCALE, 0).Cross(CVector3D(0, (h01-h00)*HEIGHT_SCALE, CELL_SIZE)).Normalized();261 return -CVector3D(_SIZE)).Normalized(); 262 262 } 263 263 else 264 264 { 265 265 // Lower-right triangle (don't use h01) 266 return -CVector3D( CELL_SIZE, (h10-h00)*HEIGHT_SCALE, 0).Cross(CVector3D(0, (h11-h10)*HEIGHT_SCALE, CELL_SIZE)).Normalized();266 return -CVector3D(_SIZE)).Normalized(); 267 267 } 268 268 } … … 328 328 329 329 // Compute fractional slope (being careful to avoid intermediate overflows) 330 return fixed::FromInt(delta / CELL_SIZE) / (int)HEIGHT_UNITS_PER_METRE;330 return fixed::FromInt(delta / _SIZE) / (int)HEIGHT_UNITS_PER_METRE; 331 331 } 332 332 … … 334 334 { 335 335 // Clamp to size-2 so we can use the tiles (xi,zi)-(xi+1,zi+1) 336 const ssize_t xi = clamp((ssize_t)floor(x/ CELL_SIZE), (ssize_t)0, m_MapSize-2);337 const ssize_t zi = clamp((ssize_t)floor(z/ CELL_SIZE), (ssize_t)0, m_MapSize-2);338 339 const float xf = clamp(x/ CELL_SIZE-xi, 0.0f, 1.0f);340 const float zf = clamp(z/ CELL_SIZE-zi, 0.0f, 1.0f);336 const ssize_t xi = clamp((ssize_t)floor(x/_SIZE), (ssize_t)0, m_MapSize-2); 337 const ssize_t zi = clamp((ssize_t)floor(z/_SIZE), (ssize_t)0, m_MapSize-2); 338 339 const float xf = clamp(x/_SIZE-xi, 0.0f, 1.0f); 340 const float zf = clamp(z/_SIZE-zi, 0.0f, 1.0f); 341 341 342 342 float h00 = m_Heightmap[zi*m_MapSize + xi]; … … 379 379 { 380 380 // Clamp to size-2 so we can use the tiles (xi,zi)-(xi+1,zi+1) 381 const ssize_t xi = clamp((ssize_t)(x / (int) CELL_SIZE).ToInt_RoundToZero(), (ssize_t)0, m_MapSize-2);382 const ssize_t zi = clamp((ssize_t)(z / (int) CELL_SIZE).ToInt_RoundToZero(), (ssize_t)0, m_MapSize-2);381 const ssize_t xi = clamp((ssize_t)(x / (int)_SIZE).ToInt_RoundToZero(), (ssize_t)0, m_MapSize-2); 382 const ssize_t zi = clamp((ssize_t)(z / (int)_SIZE).ToInt_RoundToZero(), (ssize_t)0, m_MapSize-2); 383 383 384 384 const fixed one = fixed::FromInt(1); 385 385 386 const fixed xf = clamp((x / (int) CELL_SIZE) - fixed::FromInt(xi), fixed::Zero(), one);387 const fixed zf = clamp((z / (int) CELL_SIZE) - fixed::FromInt(zi), fixed::Zero(), one);386 const fixed xf = clamp((x / (int)_SIZE) - fixed::FromInt(xi), fixed::Zero(), one); 387 const fixed zf = clamp((z / (int)_SIZE) - fixed::FromInt(zi), fixed::Zero(), one); 388 388 389 389 u16 h00 = m_Heightmap[zi*m_MapSize + xi]; … … 569 569 float CTerrain::FlattenArea(float x0, float x1, float z0, float z1) 570 570 { 571 const ssize_t tx0 = clamp(ssize_t(x0/ CELL_SIZE), (ssize_t)0, m_MapSize-1);572 const ssize_t tx1 = clamp(ssize_t(x1/ CELL_SIZE)+1, (ssize_t)0, m_MapSize-1);573 const ssize_t tz0 = clamp(ssize_t(z0/ CELL_SIZE), (ssize_t)0, m_MapSize-1);574 const ssize_t tz1 = clamp(ssize_t(z1/ CELL_SIZE)+1, (ssize_t)0, m_MapSize-1);571 const ssize_t tx0 = clamp(ssize_t(x0/_SIZE), (ssize_t)0, m_MapSize-1); 572 const ssize_t tx1 = clamp(ssize_t(x1/_SIZE)+1, (ssize_t)0, m_MapSize-1); 573 const ssize_t tz0 = clamp(ssize_t(z0/_SIZE), (ssize_t)0, m_MapSize-1); 574 const ssize_t tz1 = clamp(ssize_t(z1/_SIZE)+1, (ssize_t)0, m_MapSize-1); 575 575 576 576 size_t count=0; … … 646 646 647 647 CBoundingBoxAligned bound; 648 bound[0].X = (float)(i0* CELL_SIZE);648 bound[0].X = (float)(i0*_SIZE); 649 649 bound[0].Y = (float)(minH*HEIGHT_SCALE); 650 bound[0].Z = (float)(j0* CELL_SIZE);651 bound[1].X = (float)(i1* CELL_SIZE);650 bound[0].Z = (float)(j0*_SIZE); 651 bound[1].X = (float)(i1*_SIZE); 652 652 bound[1].Y = (float)(maxH*HEIGHT_SCALE); 653 bound[1].Z = (float)(j1* CELL_SIZE);653 bound[1].Z = (float)(j1*_SIZE); 654 654 return bound; 655 655 } -
ps/trunk/source/graphics/Terrain.h
r10593 r10902 37 37 38 38 /// metres [world space units] per tile in x and z 39 const ssize_t CELL_SIZE = 4;39 const ssize_t _SIZE = 4; 40 40 41 41 /// number of u16 height units per metre … … 70 70 float GetMinX() const { return 0.0f; } 71 71 float GetMinZ() const { return 0.0f; } 72 float GetMaxX() const { return (float)((m_MapSize-1) * CELL_SIZE); }73 float GetMaxZ() const { return (float)((m_MapSize-1) * CELL_SIZE); }72 float GetMaxX() const { return (float)((m_MapSize-1) * _SIZE); } 73 float GetMaxZ() const { return (float)((m_MapSize-1) * _SIZE); } 74 74 75 75 bool IsOnMap(float x, float z) const … … 114 114 static void CalcFromPosition(const CVector3D& pos, ssize_t& i, ssize_t& j) 115 115 { 116 i = (ssize_t)(pos.X/ CELL_SIZE);117 j = (ssize_t)(pos.Z/ CELL_SIZE);116 i = (ssize_t)(pos.X/_SIZE); 117 j = (ssize_t)(pos.Z/_SIZE); 118 118 } 119 119 // calculate the vertex under a given position (rounding down coordinates) 120 120 static void CalcFromPosition(float x, float z, ssize_t& i, ssize_t& j) 121 121 { 122 i = (ssize_t)(x/ CELL_SIZE);123 j = (ssize_t)(z/ CELL_SIZE);122 i = (ssize_t)(x/_SIZE); 123 j = (ssize_t)(z/_SIZE); 124 124 } 125 125 // calculate the normal at a given vertex -
ps/trunk/source/graphics/TerritoryTexture.cpp
r10083 r10902 119 119 // onto texcoord (mapsize / texsize, mapsize / texsize) (i.e. top-right of last texel) 120 120 121 float s = 1.f / (float)(m_TextureSize * CELL_SIZE);121 float s = 1.f / (float)(m_TextureSize * _SIZE); 122 122 float t = 0.f; 123 123 m_TextureMatrix.SetZero(); -
ps/trunk/source/graphics/tests/test_Terrain.h
r7497 r10902 43 43 SetVertex(terrain, 0, 1, 100); 44 44 SetVertex(terrain, 0, 2, 100); 45 SetVertex(terrain, 1, 0, 100 + CELL_SIZE*HEIGHT_UNITS_PER_METRE);46 SetVertex(terrain, 1, 1, 100 + CELL_SIZE*HEIGHT_UNITS_PER_METRE);47 SetVertex(terrain, 1, 2, 100 + CELL_SIZE*HEIGHT_UNITS_PER_METRE);48 SetVertex(terrain, 2, 0, 100 + 2* CELL_SIZE*HEIGHT_UNITS_PER_METRE);49 SetVertex(terrain, 2, 1, 100 + 2* CELL_SIZE*HEIGHT_UNITS_PER_METRE);50 SetVertex(terrain, 2, 2, 100 + 2* CELL_SIZE*HEIGHT_UNITS_PER_METRE);51 SetVertex(terrain, 3, 0, 100 + 2* CELL_SIZE*HEIGHT_UNITS_PER_METRE);52 SetVertex(terrain, 3, 1, 100 + 2* CELL_SIZE*HEIGHT_UNITS_PER_METRE);53 SetVertex(terrain, 3, 2, 100 + 2* CELL_SIZE*HEIGHT_UNITS_PER_METRE);45 SetVertex(terrain, 1, 0, 100 + _SIZE*HEIGHT_UNITS_PER_METRE); 46 SetVertex(terrain, 1, 1, 100 + _SIZE*HEIGHT_UNITS_PER_METRE); 47 SetVertex(terrain, 1, 2, 100 + _SIZE*HEIGHT_UNITS_PER_METRE); 48 SetVertex(terrain, 2, 0, 100 + 2*_SIZE*HEIGHT_UNITS_PER_METRE); 49 SetVertex(terrain, 2, 1, 100 + 2*_SIZE*HEIGHT_UNITS_PER_METRE); 50 SetVertex(terrain, 2, 2, 100 + 2*_SIZE*HEIGHT_UNITS_PER_METRE); 51 SetVertex(terrain, 3, 0, 100 + 2*_SIZE*HEIGHT_UNITS_PER_METRE); 52 SetVertex(terrain, 3, 1, 100 + 2*_SIZE*HEIGHT_UNITS_PER_METRE); 53 SetVertex(terrain, 3, 2, 100 + 2*_SIZE*HEIGHT_UNITS_PER_METRE); 54 54 55 55 } … … 57 57 void SetHighPlateau(CTerrain& terrain, int height) 58 58 { 59 SetVertex(terrain, 4, 0, 100 + height* CELL_SIZE*HEIGHT_UNITS_PER_METRE);60 SetVertex(terrain, 4, 1, 100 + height* CELL_SIZE*HEIGHT_UNITS_PER_METRE);61 SetVertex(terrain, 4, 2, 100 + height* CELL_SIZE*HEIGHT_UNITS_PER_METRE);62 SetVertex(terrain, 5, 0, 100 + height* CELL_SIZE*HEIGHT_UNITS_PER_METRE);63 SetVertex(terrain, 5, 1, 100 + height* CELL_SIZE*HEIGHT_UNITS_PER_METRE);64 SetVertex(terrain, 5, 2, 100 + height* CELL_SIZE*HEIGHT_UNITS_PER_METRE);59 SetVertex(terrain, 4, 0, 100 + height*_SIZE*HEIGHT_UNITS_PER_METRE); 60 SetVertex(terrain, 4, 1, 100 + height*_SIZE*HEIGHT_UNITS_PER_METRE); 61 SetVertex(terrain, 4, 2, 100 + height*_SIZE*HEIGHT_UNITS_PER_METRE); 62 SetVertex(terrain, 5, 0, 100 + height*_SIZE*HEIGHT_UNITS_PER_METRE); 63 SetVertex(terrain, 5, 1, 100 + height*_SIZE*HEIGHT_UNITS_PER_METRE); 64 SetVertex(terrain, 5, 2, 100 + height*_SIZE*HEIGHT_UNITS_PER_METRE); 65 65 } 66 66 … … 75 75 float ground; 76 76 77 ground = terrain.GetExactGroundLevel(0.f, 1.5f* CELL_SIZE);77 ground = terrain.GetExactGroundLevel(0.f, 1.5f*_SIZE); 78 78 TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE, 0.01f); 79 79 80 ground = terrain.GetExactGroundLevel(0.5f* CELL_SIZE, 1.5f*CELL_SIZE);81 TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+0.5f* CELL_SIZE, 0.01f);82 83 ground = terrain.GetExactGroundLevel(1.5f* CELL_SIZE, 1.5f*CELL_SIZE);84 TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+1.5f* CELL_SIZE, 0.01f);85 86 ground = terrain.GetExactGroundLevel(2.5f* CELL_SIZE, 1.5f*CELL_SIZE);87 TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+2.f* CELL_SIZE, 0.01f);88 89 ground = terrain.GetExactGroundLevel(3.5f* CELL_SIZE, 1.5f*CELL_SIZE);90 TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+11.f* CELL_SIZE, 0.01f);91 92 ground = terrain.GetExactGroundLevel(4.5f* CELL_SIZE, 1.5f*CELL_SIZE);93 TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+20.f* CELL_SIZE, 0.01f);80 ground = terrain.GetExactGroundLevel(0.5f*_SIZE); 81 TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+0.5f*_SIZE, 0.01f); 82 83 ground = terrain.GetExactGroundLevel(1.5f*_SIZE); 84 TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+1.5f*_SIZE, 0.01f); 85 86 ground = terrain.GetExactGroundLevel(2.5f*_SIZE); 87 TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+2.f*_SIZE, 0.01f); 88 89 ground = terrain.GetExactGroundLevel(3.5f*_SIZE); 90 TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+11.f*_SIZE, 0.01f); 91 92 ground = terrain.GetExactGroundLevel(4.5f*_SIZE); 93 TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+20.f*_SIZE, 0.01f); 94 94 } 95 95 … … 105 105 fixed ground; 106 106 107 ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(0.f), fixed::FromFloat(1.5f* CELL_SIZE));107 ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(0.f), fixed::FromFloat(1.5f*_SIZE)); 108 108 TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE, maxDelta); 109 109 110 ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(0.5f* CELL_SIZE), fixed::FromFloat(1.5f*CELL_SIZE));111 TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+0.5* CELL_SIZE, maxDelta);112 113 ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(1.5f* CELL_SIZE), fixed::FromFloat(1.5f*CELL_SIZE));114 TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+1.5* CELL_SIZE, maxDelta);115 116 ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(2.5f* CELL_SIZE), fixed::FromFloat(1.5f*CELL_SIZE));117 TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+2.0* CELL_SIZE, maxDelta);118 119 ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(3.5f* CELL_SIZE), fixed::FromFloat(1.5f*CELL_SIZE));120 TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+11.0* CELL_SIZE, maxDelta);121 122 ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(4.5f* CELL_SIZE), fixed::FromFloat(1.5f*CELL_SIZE));123 TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+20.0* CELL_SIZE, maxDelta);110 ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(0.5f*_SIZE)); 111 TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+0.5*_SIZE, maxDelta); 112 113 ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(1.5f*_SIZE)); 114 TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+1.5*_SIZE, maxDelta); 115 116 ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(2.5f*_SIZE)); 117 TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+2.0*_SIZE, maxDelta); 118 119 ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(3.5f*_SIZE)); 120 TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+11.0*_SIZE, maxDelta); 121 122 ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(4.5f*_SIZE)); 123 TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+20.0*_SIZE, maxDelta); 124 124 } 125 125 … … 140 140 for (int xi = 0; xi < p; ++xi) 141 141 { 142 fixed ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(xi/(float)p* CELL_SIZE), fixed::FromFloat(zi/(float)p*CELL_SIZE));142 fixed ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(xi/(float)p*_SIZE)); 143 143 TS_ASSERT_DELTA(ground.ToDouble(), 65535.0/HEIGHT_UNITS_PER_METRE, maxDelta); 144 144 } … … 232 232 EXPECT_DIRTY(false, 2, 2); 233 233 234 terrain.FlattenArea(PATCH_SIZE* CELL_SIZE, 2*PATCH_SIZE*CELL_SIZE, PATCH_SIZE*CELL_SIZE+1, 2*PATCH_SIZE*CELL_SIZE-1);234 terrain.FlattenArea(PATCH_SIZE*_SIZE-1); 235 235 236 236 EXPECT_DIRTY(true, 0, 0); -
ps/trunk/source/gui/MiniMap.cpp
r10704 r10902 150 150 151 151 // Scale world coordinates for shrunken square map 152 x = CELL_SIZE * m_MapSize * (m_MapScale * (cos(angle)*(px-0.5) - sin(angle)*(py-0.5)) + 0.5);153 z = CELL_SIZE * m_MapSize * (m_MapScale * (cos(angle)*(py-0.5) + sin(angle)*(px-0.5)) + 0.5);152 x = _SIZE * m_MapSize * (m_MapScale * (cos(angle)*(px-0.5) - sin(angle)*(py-0.5)) + 0.5); 153 z = _SIZE * m_MapSize * (m_MapScale * (cos(angle)*(py-0.5) + sin(angle)*(px-0.5)) + 0.5); 154 154 } 155 155 … … 207 207 float px=hitPt[i].X; 208 208 float pz=hitPt[i].Z; 209 ViewRect[i][0]=(m_CachedActualSize.GetWidth()*px/float( CELL_SIZE*m_MapSize));210 ViewRect[i][1]=(m_CachedActualSize.GetHeight()*pz/float( CELL_SIZE*m_MapSize));209 ViewRect[i][0]=(m_CachedActualSize.GetWidth()*px/float(_SIZE*m_MapSize)); 210 ViewRect[i][1]=(m_CachedActualSize.GetHeight()*pz/float(_SIZE*m_MapSize)); 211 211 } 212 212 … … 373 373 glPointSize(3.f); 374 374 375 float sx = (float)m_Width / ((m_MapSize - 1) * CELL_SIZE);376 float sy = (float)m_Height / ((m_MapSize - 1) * CELL_SIZE);375 float sx = (float)m_Width / ((m_MapSize - 1) * _SIZE); 376 float sy = (float)m_Height / ((m_MapSize - 1) * _SIZE); 377 377 378 378 CSimulation2::InterfaceList ents = sim->GetEntitiesWithInterface(IID_Minimap); -
ps/trunk/source/renderer/PatchRData.cpp
r10466 r10902 1125 1125 1126 1126 // Move a bit towards the center of the tile 1127 pos.X += CELL_SIZE/4.f;1128 pos.Z += CELL_SIZE/4.f;1127 pos.X += _SIZE/4.f; 1128 pos.Z += _SIZE/4.f; 1129 1129 1130 1130 float x, y; -
ps/trunk/source/simulation2/components/CCmpFootprint.cpp
r10017 r10902 27 27 #include "simulation2/components/ICmpUnitMotion.h" 28 28 #include "simulation2/MessageTypes.h" 29 #include "graphics/Terrain.h" // For CELL_SIZE29 #include "graphics/Terrain.h" // For _SIZE 30 30 #include "maths/FixedVector2D.h" 31 31 … … 172 172 { 173 173 // The spawn point should be far enough from this footprint to fit the unit, plus a little gap 174 entity_pos_t clearance = spawnedRadius + entity_pos_t::FromInt(2 + (int) CELL_SIZE*dist);174 entity_pos_t clearance = spawnedRadius + entity_pos_t::FromInt(2 + (int)_SIZE*dist); 175 175 entity_pos_t radius = m_Size0 + clearance; 176 176 … … 201 201 { 202 202 // The spawn point should be far enough from this footprint to fit the unit, plus a little gap 203 entity_pos_t clearance = spawnedRadius + entity_pos_t::FromInt(2 + (int) CELL_SIZE*dist);203 entity_pos_t clearance = spawnedRadius + entity_pos_t::FromInt(2 + (int)_SIZE*dist); 204 204 205 205 for (i32 edge = 0; edge < 4; ++edge) -
ps/trunk/source/simulation2/components/CCmpObstructionManager.cpp
r10017 r10902 228 228 // Use 8x8 tile subdivisions 229 229 // (TODO: find the optimal number instead of blindly guessing) 230 m_UnitSubdivision.Reset(x1, z1, entity_pos_t::FromInt(8* CELL_SIZE));231 m_StaticSubdivision.Reset(x1, z1, entity_pos_t::FromInt(8* CELL_SIZE));230 m_UnitSubdivision.Reset(x1, z1, entity_pos_t::FromInt(8*_SIZE)); 231 m_StaticSubdivision.Reset(x1, z1, entity_pos_t::FromInt(8*_SIZE)); 232 232 233 233 for (std::map<u32, UnitShape>::iterator it = m_UnitShapes.begin(); it != m_UnitShapes.end(); ++it) … … 691 691 static void NearestTile(entity_pos_t x, entity_pos_t z, u16& i, u16& j, u16 w, u16 h) 692 692 { 693 i = (u16)clamp((x / (int) CELL_SIZE).ToInt_RoundToZero(), 0, w-1);694 j = (u16)clamp((z / (int) CELL_SIZE).ToInt_RoundToZero(), 0, h-1);693 i = (u16)clamp((x / (int)_SIZE).ToInt_RoundToZero(), 0, w-1); 694 j = (u16)clamp((z / (int)_SIZE).ToInt_RoundToZero(), 0, h-1); 695 695 } 696 696 … … 700 700 static void TileCenter(u16 i, u16 j, entity_pos_t& x, entity_pos_t& z) 701 701 { 702 x = entity_pos_t::FromInt(i*(int) CELL_SIZE + (int)CELL_SIZE/2);703 z = entity_pos_t::FromInt(j*(int) CELL_SIZE + (int)CELL_SIZE/2);702 x = entity_pos_t::FromInt(i*(int)_SIZE/2); 703 z = entity_pos_t::FromInt(j*(int)_SIZE/2); 704 704 } 705 705 … … 724 724 // free space between buildings when there isn't. But this is just a random guess 725 725 // and needs to be tweaked until everything works nicely. 726 //entity_pos_t expandPathfinding = entity_pos_t::FromInt( CELL_SIZE / 2);726 //entity_pos_t expandPathfinding = entity_pos_t::FromInt(_SIZE / 2); 727 727 // Actually that's bad because units get stuck when the A* pathfinder thinks they're 728 728 // blocked on all sides, so it's better to underestimate … … 732 732 // potentially-obstructed tiles (so we don't blindly build on top of an obstruction), 733 733 // so we need to expand by at least 1/sqrt(2) of a tile 734 entity_pos_t expandFoundation = (entity_pos_t::FromInt( CELL_SIZE) * 3) / 4;734 entity_pos_t expandFoundation = (entity_pos_t::FromInt(_SIZE) * 3) / 4; 735 735 736 736 for (std::map<u32, StaticShape>::iterator it = m_StaticShapes.begin(); it != m_StaticShapes.end(); ++it) -
ps/trunk/source/simulation2/components/CCmpPathfinder.cpp
r10017 r10902 712 712 return false; 713 713 714 // Expand bounds by 1/sqrt(2) tile (multiply by CELL_SIZE since we want world coordinates)715 entity_pos_t expand = entity_pos_t::FromInt(2).Sqrt().Multiply(entity_pos_t::FromInt( CELL_SIZE / 2));714 // Expand bounds by 1/sqrt(2) tile (multiply by _SIZE since we want world coordinates) 715 entity_pos_t expand = entity_pos_t::FromInt(2).Sqrt().Multiply(entity_pos_t::FromInt(_SIZE / 2)); 716 716 CFixedVector2D halfSize(square.hw + expand, square.hh + expand); 717 717 CFixedVector2D halfBound = Geometry::GetHalfBoundingBox(square.u, square.v, halfSize); -
ps/trunk/source/simulation2/components/CCmpPathfinder_Common.h
r10017 r10902 278 278 void NearestTile(entity_pos_t x, entity_pos_t z, u16& i, u16& j) 279 279 { 280 i = (u16)clamp((x / (int) CELL_SIZE).ToInt_RoundToZero(), 0, m_MapSize-1);281 j = (u16)clamp((z / (int) CELL_SIZE).ToInt_RoundToZero(), 0, m_MapSize-1);280 i = (u16)clamp((x / (int)_SIZE).ToInt_RoundToZero(), 0, m_MapSize-1); 281 j = (u16)clamp((z / (int)_SIZE).ToInt_RoundToZero(), 0, m_MapSize-1); 282 282 } 283 283 … … 287 287 static void TileCenter(u16 i, u16 j, entity_pos_t& x, entity_pos_t& z) 288 288 { 289 x = entity_pos_t::FromInt(i*(int) CELL_SIZE + (int)CELL_SIZE/2);290 z = entity_pos_t::FromInt(j*(int) CELL_SIZE + (int)CELL_SIZE/2);289 x = entity_pos_t::FromInt(i*(int)_SIZE/2); 290 z = entity_pos_t::FromInt(j*(int)_SIZE/2); 291 291 } 292 292 -
ps/trunk/source/simulation2/components/CCmpPathfinder_Tile.cpp
r10846 r10902 219 219 // Allow tiles slightly more than sqrt(2) from the actual goal, 220 220 // i.e. adjacent diagonally to the target tile 221 fixed tolerance = entity_pos_t::FromInt( CELL_SIZE*3/2);221 fixed tolerance = entity_pos_t::FromInt(_SIZE*3/2); 222 222 223 223 entity_pos_t x, z; … … 388 388 // otherwise just aim at the center point. (We'll never try moving outwards to a square shape.) 389 389 if (goal.type == Goal::CIRCLE) 390 state.rGoal = (u16)(goal.hw / (int) CELL_SIZE).ToInt_RoundToZero();390 state.rGoal = (u16)(goal.hw / (int)_SIZE).ToInt_RoundToZero(); 391 391 else 392 392 state.rGoal = 0; -
ps/trunk/source/simulation2/components/CCmpPathfinder_Vertex.cpp
r10790 r10902 383 383 if (any) 384 384 { 385 CFixedVector2D v0 = CFixedVector2D(fixed::FromInt(i * (int) CELL_SIZE) - r, fixed::FromInt(j * (int)CELL_SIZE) - r);386 CFixedVector2D v1 = CFixedVector2D(fixed::FromInt((i+1) * (int) CELL_SIZE) + r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);385 CFixedVector2D v0 = CFixedVector2D(fixed::FromInt(i * (int)_SIZE) - r); 386 CFixedVector2D v1 = CFixedVector2D(fixed::FromInt((i+1) * (int)_SIZE) + r); 387 387 Edge e = { v0, v1 }; 388 388 edgesAA.push_back(e); … … 410 410 case TileEdge::BOTTOM: 411 411 { 412 v0 = CFixedVector2D(fixed::FromInt(i * (int) CELL_SIZE) - r, fixed::FromInt(j * (int)CELL_SIZE) - r);413 v1 = CFixedVector2D(fixed::FromInt((i+1) * (int) CELL_SIZE) + r, fixed::FromInt(j * (int)CELL_SIZE) - r);412 v0 = CFixedVector2D(fixed::FromInt(i * (int)_SIZE) - r); 413 v1 = CFixedVector2D(fixed::FromInt((i+1) * (int)_SIZE) - r); 414 414 vert.p.X = v0.X - EDGE_EXPAND_DELTA; vert.p.Y = v0.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TR; vertexes.push_back(vert); 415 415 vert.p.X = v1.X + EDGE_EXPAND_DELTA; vert.p.Y = v1.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TL; vertexes.push_back(vert); … … 418 418 case TileEdge::TOP: 419 419 { 420 v0 = CFixedVector2D(fixed::FromInt((i+1) * (int) CELL_SIZE) + r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);421 v1 = CFixedVector2D(fixed::FromInt(i * (int) CELL_SIZE) - r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);420 v0 = CFixedVector2D(fixed::FromInt((i+1) * (int)_SIZE) + r); 421 v1 = CFixedVector2D(fixed::FromInt(i * (int)_SIZE) + r); 422 422 vert.p.X = v0.X + EDGE_EXPAND_DELTA; vert.p.Y = v0.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BL; vertexes.push_back(vert); 423 423 vert.p.X = v1.X - EDGE_EXPAND_DELTA; vert.p.Y = v1.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BR; vertexes.push_back(vert); … … 426 426 case TileEdge::LEFT: 427 427 { 428 v0 = CFixedVector2D(fixed::FromInt(i * (int) CELL_SIZE) - r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);429 v1 = CFixedVector2D(fixed::FromInt(i * (int) CELL_SIZE) - r, fixed::FromInt(j * (int)CELL_SIZE) - r);428 v0 = CFixedVector2D(fixed::FromInt(i * (int)_SIZE) + r); 429 v1 = CFixedVector2D(fixed::FromInt(i * (int)_SIZE) - r); 430 430 vert.p.X = v0.X - EDGE_EXPAND_DELTA; vert.p.Y = v0.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BR; vertexes.push_back(vert); 431 431 vert.p.X = v1.X - EDGE_EXPAND_DELTA; vert.p.Y = v1.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TR; vertexes.push_back(vert); … … 434 434 case TileEdge::RIGHT: 435 435 { 436 v0 = CFixedVector2D(fixed::FromInt((i+1) * (int) CELL_SIZE) + r, fixed::FromInt(j * (int)CELL_SIZE) - r);437 v1 = CFixedVector2D(fixed::FromInt((i+1) * (int) CELL_SIZE) + r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);436 v0 = CFixedVector2D(fixed::FromInt((i+1) * (int)_SIZE) - r); 437 v1 = CFixedVector2D(fixed::FromInt((i+1) * (int)_SIZE) + r); 438 438 vert.p.X = v0.X + EDGE_EXPAND_DELTA; vert.p.Y = v0.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TL; vertexes.push_back(vert); 439 439 vert.p.X = v1.X + EDGE_EXPAND_DELTA; vert.p.Y = v1.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BL; vertexes.push_back(vert); -
ps/trunk/source/simulation2/components/CCmpProjectileManager.cpp
r10593 r10902 339 339 { 340 340 // Don't display projectiles outside the visible area 341 ssize_t posi = (ssize_t)(0.5f + m_Projectiles[i].pos.X / CELL_SIZE);342 ssize_t posj = (ssize_t)(0.5f + m_Projectiles[i].pos.Z / CELL_SIZE);341 ssize_t posi = (ssize_t)(0.5f + m_Projectiles[i].pos.X / _SIZE); 342 ssize_t posj = (ssize_t)(0.5f + m_Projectiles[i].pos.Z / _SIZE); 343 343 if (!losRevealAll && !los.IsVisible(posi, posj)) 344 344 continue; -
ps/trunk/source/simulation2/components/CCmpRallyPointRenderer.cpp
r10822 r10902 832 832 for(std::vector<CVector2D>::iterator it = coords.begin(); it != coords.end();) 833 833 { 834 int i = (fixed::FromFloat(it->X) / (int) CELL_SIZE).ToInt_RoundToNearest();835 int j = (fixed::FromFloat(it->Y) / (int) CELL_SIZE).ToInt_RoundToNearest();834 int i = (fixed::FromFloat(it->X) / (int)_SIZE).ToInt_RoundToNearest(); 835 int j = (fixed::FromFloat(it->Y) / (int)_SIZE).ToInt_RoundToNearest(); 836 836 837 837 bool explored = losQuerier.IsExplored(i, j); … … 957 957 958 958 bool lastVisible = losQuerier.IsExplored( 959 (fixed::FromFloat(m_Path[0].X) / (int) CELL_SIZE).ToInt_RoundToNearest(),960 (fixed::FromFloat(m_Path[0].Y) / (int) CELL_SIZE).ToInt_RoundToNearest()959 (fixed::FromFloat(m_Path[0].X) / (int) _SIZE).ToInt_RoundToNearest(), 960 (fixed::FromFloat(m_Path[0].Y) / (int) _SIZE).ToInt_RoundToNearest() 961 961 ); 962 962 size_t curSegmentStartIndex = 0; // starting node index of the current segment … … 965 965 { 966 966 // grab tile indices for this coord 967 int i = (fixed::FromFloat(m_Path[k].X) / (int) CELL_SIZE).ToInt_RoundToNearest();968 int j = (fixed::FromFloat(m_Path[k].Y) / (int) CELL_SIZE).ToInt_RoundToNearest();967 int i = (fixed::FromFloat(m_Path[k].X) / (int)_SIZE).ToInt_RoundToNearest(); 968 int j = (fixed::FromFloat(m_Path[k].Y) / (int)_SIZE).ToInt_RoundToNearest(); 969 969 970 970 bool nodeVisible = losQuerier.IsExplored(i, j); -
ps/trunk/source/simulation2/components/CCmpRangeManager.cpp
r10846 r10902 504 504 // Use 8x8 tile subdivisions 505 505 // (TODO: find the optimal number instead of blindly guessing) 506 m_Subdivision.Reset(x1, z1, entity_pos_t::FromInt(8* CELL_SIZE));506 m_Subdivision.Reset(x1, z1, entity_pos_t::FromInt(8*_SIZE)); 507 507 508 508 for (std::map<entity_id_t, EntityData>::const_iterator it = m_EntityData.begin(); it != m_EntityData.end(); ++it) … … 884 884 CFixedVector2D pos = cmpPosition->GetPosition2D(); 885 885 886 int i = (pos.X / (int) CELL_SIZE).ToInt_RoundToNearest();887 int j = (pos.Y / (int) CELL_SIZE).ToInt_RoundToNearest();886 int i = (pos.X / (int)_SIZE).ToInt_RoundToNearest(); 887 int j = (pos.Y / (int)_SIZE).ToInt_RoundToNearest(); 888 888 889 889 // Reveal flag makes all positioned entities visible … … 1091 1091 // Compute top/bottom coordinates, and clamp to exclude the 1-tile border around the map 1092 1092 // (so that we never render the sharp edge of the map) 1093 i32 j0 = ((pos.Y - visionRange)/(int) CELL_SIZE).ToInt_RoundToInfinity();1094 i32 j1 = ((pos.Y + visionRange)/(int) CELL_SIZE).ToInt_RoundToNegInfinity();1093 i32 j0 = ((pos.Y - visionRange)/(int)_SIZE).ToInt_RoundToInfinity(); 1094 i32 j1 = ((pos.Y + visionRange)/(int)_SIZE).ToInt_RoundToNegInfinity(); 1095 1095 i32 j0clamp = std::max(j0, 1); 1096 1096 i32 j1clamp = std::min(j1, m_TerrainVerticesPerSide-2); 1097 1097 1098 1098 // Translate world coordinates into fractional tile-space coordinates 1099 entity_pos_t x = pos.X / (int) CELL_SIZE;1100 entity_pos_t y = pos.Y / (int) CELL_SIZE;1101 entity_pos_t r = visionRange / (int) CELL_SIZE;1099 entity_pos_t x = pos.X / (int)_SIZE; 1100 entity_pos_t y = pos.Y / (int)_SIZE; 1101 entity_pos_t r = visionRange / (int)_SIZE; 1102 1102 entity_pos_t r2 = r.Square(); 1103 1103 … … 1176 1176 // and only have to touch tiles that have a net change.) 1177 1177 1178 i32 j0_from = ((from.Y - visionRange)/(int) CELL_SIZE).ToInt_RoundToInfinity();1179 i32 j1_from = ((from.Y + visionRange)/(int) CELL_SIZE).ToInt_RoundToNegInfinity();1180 i32 j0_to = ((to.Y - visionRange)/(int) CELL_SIZE).ToInt_RoundToInfinity();1181 i32 j1_to = ((to.Y + visionRange)/(int) CELL_SIZE).ToInt_RoundToNegInfinity();1178 i32 j0_from = ((from.Y - visionRange)/(int)_SIZE).ToInt_RoundToInfinity(); 1179 i32 j1_from = ((from.Y + visionRange)/(int)_SIZE).ToInt_RoundToNegInfinity(); 1180 i32 j0_to = ((to.Y - visionRange)/(int)_SIZE).ToInt_RoundToInfinity(); 1181 i32 j1_to = ((to.Y + visionRange)/(int)_SIZE).ToInt_RoundToNegInfinity(); 1182 1182 i32 j0clamp = std::max(std::min(j0_from, j0_to), 1); 1183 1183 i32 j1clamp = std::min(std::max(j1_from, j1_to), m_TerrainVerticesPerSide-2); 1184 1184 1185 entity_pos_t x_from = from.X / (int) CELL_SIZE;1186 entity_pos_t y_from = from.Y / (int) CELL_SIZE;1187 entity_pos_t x_to = to.X / (int) CELL_SIZE;1188 entity_pos_t y_to = to.Y / (int) CELL_SIZE;1189 entity_pos_t r = visionRange / (int) CELL_SIZE;1185 entity_pos_t x_from = from.X / (int)_SIZE; 1186 entity_pos_t y_from = from.Y / (int)_SIZE; 1187 entity_pos_t x_to = to.X / (int)_SIZE; 1188 entity_pos_t y_to = to.Y / (int)_SIZE; 1189 entity_pos_t r = visionRange / (int)_SIZE; 1190 1190 entity_pos_t r2 = r.Square(); 1191 1191 -
ps/trunk/source/simulation2/components/CCmpTerrain.cpp
r10034 r10902 69 69 { 70 70 CFixedVector3D normal; 71 m_Terrain->CalcNormalFixed((x / (int) CELL_SIZE).ToInt_RoundToZero(), (z / (int)CELL_SIZE).ToInt_RoundToZero(), normal);71 m_Terrain->CalcNormalFixed((x / (int)_SIZE).ToInt_RoundToZero(), normal); 72 72 return normal; 73 73 } … … 115 115 { 116 116 cmpObstructionManager->SetBounds(entity_pos_t::Zero(), entity_pos_t::Zero(), 117 entity_pos_t::FromInt(tiles*(int) CELL_SIZE),118 entity_pos_t::FromInt(tiles*(int) CELL_SIZE));117 entity_pos_t::FromInt(tiles*(int)_SIZE), 118 entity_pos_t::FromInt(tiles*(int)_SIZE)); 119 119 } 120 120 … … 123 123 { 124 124 cmpRangeManager->SetBounds(entity_pos_t::Zero(), entity_pos_t::Zero(), 125 entity_pos_t::FromInt(tiles*(int) CELL_SIZE),126 entity_pos_t::FromInt(tiles*(int) CELL_SIZE),125 entity_pos_t::FromInt(tiles*(int)_SIZE), 126 entity_pos_t::FromInt(tiles*(int)_SIZE), 127 127 vertices); 128 128 } -
ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp
r10801 r10902 427 427 CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), *eit); 428 428 CFixedVector2D pos = cmpPosition->GetPosition2D(); 429 u16 i = (u16)clamp((pos.X / (int) CELL_SIZE).ToInt_RoundToNegInfinity(), 0, tilesW-1);430 u16 j = (u16)clamp((pos.Y / (int) CELL_SIZE).ToInt_RoundToNegInfinity(), 0, tilesH-1);429 u16 i = (u16)clamp((pos.X / (int)_SIZE).ToInt_RoundToNegInfinity(), 0, tilesW-1); 430 u16 j = (u16)clamp((pos.Y / (int)_SIZE).ToInt_RoundToNegInfinity(), 0, tilesH-1); 431 431 432 432 CmpPtr<ICmpTerritoryInfluence> cmpTerritoryInfluence(GetSimContext(), *eit); 433 433 u32 weight = cmpTerritoryInfluence->GetWeight(); 434 u32 radius = cmpTerritoryInfluence->GetRadius() / CELL_SIZE;434 u32 radius = cmpTerritoryInfluence->GetRadius() / _SIZE; 435 435 u32 falloff = weight / radius; // earlier check for GetRadius() == 0 prevents divide-by-zero 436 436 … … 484 484 485 485 CFixedVector2D pos = cmpPosition->GetPosition2D(); 486 u16 i = (u16)clamp((pos.X / (int) CELL_SIZE).ToInt_RoundToNegInfinity(), 0, tilesW-1);487 u16 j = (u16)clamp((pos.Y / (int) CELL_SIZE).ToInt_RoundToNegInfinity(), 0, tilesH-1);486 u16 i = (u16)clamp((pos.X / (int)_SIZE).ToInt_RoundToNegInfinity(), 0, tilesW-1); 487 u16 j = (u16)clamp((pos.Y / (int)_SIZE).ToInt_RoundToNegInfinity(), 0, tilesH-1); 488 488 489 489 u8 owner = (u8)cmpOwnership->GetOwner(); … … 539 539 static void NearestTile(entity_pos_t x, entity_pos_t z, u16& i, u16& j, u16 w, u16 h) 540 540 { 541 i = (u16)clamp((x / (int) CELL_SIZE).ToInt_RoundToZero(), 0, w-1);542 j = (u16)clamp((z / (int) CELL_SIZE).ToInt_RoundToZero(), 0, h-1);541 i = (u16)clamp((x / (int)_SIZE).ToInt_RoundToZero(), 0, w-1); 542 j = (u16)clamp((z / (int)_SIZE).ToInt_RoundToZero(), 0, h-1); 543 543 } 544 544 … … 548 548 static void TileCenter(u16 i, u16 j, entity_pos_t& x, entity_pos_t& z) 549 549 { 550 x = entity_pos_t::FromInt(i*(int) CELL_SIZE + (int)CELL_SIZE/2);551 z = entity_pos_t::FromInt(j*(int) CELL_SIZE + (int)CELL_SIZE/2);550 x = entity_pos_t::FromInt(i*(int)_SIZE/2); 551 z = entity_pos_t::FromInt(j*(int)_SIZE/2); 552 552 } 553 553 … … 640 640 while (true) 641 641 { 642 points.push_back((CVector2D(ci, cj) + edgeOffsets[cdir]) * CELL_SIZE);642 points.push_back((CVector2D(ci, cj) + edgeOffsets[cdir]) * _SIZE); 643 643 644 644 // Given that we're on an edge on a continuous boundary and aiming anticlockwise, -
ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp
r10867 r10902 44 44 * position (to minimise the effects of grid-constrained movement) 45 45 */ 46 static const entity_pos_t WAYPOINT_ADVANCE_MAX = entity_pos_t::FromInt( CELL_SIZE*8);46 static const entity_pos_t WAYPOINT_ADVANCE_MAX = entity_pos_t::FromInt(_SIZE*8); 47 47 48 48 /** … … 59 59 * smaller ranges might miss some legitimate routes around large obstacles.) 60 60 */ 61 static const entity_pos_t SHORT_PATH_SEARCH_RANGE = entity_pos_t::FromInt( CELL_SIZE*10);61 static const entity_pos_t SHORT_PATH_SEARCH_RANGE = entity_pos_t::FromInt(_SIZE*10); 62 62 63 63 /** … … 66 66 * (since it might be inside an obstacle). 67 67 */ 68 static const entity_pos_t SHORT_PATH_GOAL_RADIUS = entity_pos_t::FromInt( CELL_SIZE*3/2);68 static const entity_pos_t SHORT_PATH_GOAL_RADIUS = entity_pos_t::FromInt(_SIZE*3/2); 69 69 70 70 /** … … 72 72 * for it in a straight line instead of pathfinding. 73 73 */ 74 static const entity_pos_t DIRECT_PATH_RANGE = entity_pos_t::FromInt( CELL_SIZE*4);74 static const entity_pos_t DIRECT_PATH_RANGE = entity_pos_t::FromInt(_SIZE*4); 75 75 76 76 /** … … 79 79 * more than this distance from where we last pathed to. 80 80 */ 81 static const entity_pos_t CHECK_TARGET_MOVEMENT_MIN_DELTA = entity_pos_t::FromInt( CELL_SIZE*4);81 static const entity_pos_t CHECK_TARGET_MOVEMENT_MIN_DELTA = entity_pos_t::FromInt(_SIZE*4); 82 82 83 83 /** … … 87 87 * more than this distance from where we last pathed to. 88 88 */ 89 static const entity_pos_t CHECK_TARGET_MOVEMENT_MIN_DELTA_FORMATION = entity_pos_t::FromInt( CELL_SIZE*1);89 static const entity_pos_t CHECK_TARGET_MOVEMENT_MIN_DELTA_FORMATION = entity_pos_t::FromInt(_SIZE*1); 90 90 91 91 /** … … 94 94 * moved, until we get this close to the end of our old path. 95 95 */ 96 static const entity_pos_t CHECK_TARGET_MOVEMENT_AT_MAX_DIST = entity_pos_t::FromInt( CELL_SIZE*16);96 static const entity_pos_t CHECK_TARGET_MOVEMENT_AT_MAX_DIST = entity_pos_t::FromInt(_SIZE*16); 97 97 98 98 static const CColor OVERLAY_COLOUR_LONG_PATH(1, 1, 1, 1); 99 99 static const CColor OVERLAY_COLOUR_SHORT_PATH(1, 0, 0, 1); 100 100 101 static const entity_pos_t g_GoalDelta = entity_pos_t::FromInt( CELL_SIZE)/4; // for extending the goal outwards/inwards a little bit101 static const entity_pos_t g_GoalDelta = entity_pos_t::FromInt(_SIZE)/4; // for extending the goal outwards/inwards a little bit 102 102 103 103 class CCmpUnitMotion : public ICmpUnitMotion … … 1364 1364 goal.u = obstruction.u; 1365 1365 goal.v = obstruction.v; 1366 entity_pos_t delta = std::max(goalDistance, m_Radius + entity_pos_t::FromInt( CELL_SIZE)/16); // ensure it's far enough to not intersect the building itself1366 entity_pos_t delta = std::max(goalDistance, m_Radius + entity_pos_t::FromInt(_SIZE)/16); // ensure it's far enough to not intersect the building itself 1367 1367 goal.hw = obstruction.hw + delta; 1368 1368 goal.hh = obstruction.hh + delta; … … 1412 1412 goal.u = obstruction.u; 1413 1413 goal.v = obstruction.v; 1414 entity_pos_t delta = std::max(goalDistance, m_Radius + entity_pos_t::FromInt( CELL_SIZE)/16); // ensure it's far enough to not intersect the building itself1414 entity_pos_t delta = std::max(goalDistance, m_Radius + entity_pos_t::FromInt(_SIZE)/16); // ensure it's far enough to not intersect the building itself 1415 1415 goal.hw = obstruction.hw + delta; 1416 1416 goal.hh = obstruction.hh + delta; -
ps/trunk/source/simulation2/components/ICmpRangeManager.h
r10584 r10902 23 23 #include "simulation2/helpers/Player.h" 24 24 25 #include "graphics/Terrain.h" // for CELL_SIZE25 #include "graphics/Terrain.h" // for _SIZE 26 26 27 27 /** -
ps/trunk/source/simulation2/components/tests/test_Pathfinder.h
r10426 r10902 119 119 sim2.ResetState(); 120 120 121 const entity_pos_t range = entity_pos_t::FromInt( CELL_SIZE*12);121 const entity_pos_t range = entity_pos_t::FromInt(_SIZE*12); 122 122 123 123 CmpPtr<ICmpObstructionManager> cmpObstructionMan(sim2, SYSTEM_ENTITY); -
ps/trunk/source/simulation2/components/tests/test_RangeManager.h
r10537 r10902 88 88 // in various edge cases 89 89 90 cmp->SetBounds(entity_pos_t::FromInt(0), entity_pos_t::FromInt(0), entity_pos_t::FromInt(512), entity_pos_t::FromInt(512), 512/ CELL_SIZE + 1);90 cmp->SetBounds(entity_pos_t::FromInt(0), entity_pos_t::FromInt(0), entity_pos_t::FromInt(512), entity_pos_t::FromInt(512), 512/_SIZE + 1); 91 91 cmp->Verify(); 92 92 { CMessageCreate msg(100); cmp->HandleMessage(msg, false); } -
ps/trunk/source/simulation2/helpers/Position.h
r7655 r10902 25 25 * Entity coordinate types 26 26 * 27 * The basic unit is the "meter". Terrain tiles are CELL_SIZE (=4) meters square.27 * The basic unit is the "meter". Terrain tiles are _SIZE (=4) meters square. 28 28 * To support deterministic computation across CPU architectures and compilers and 29 29 * optimisation settings, the C++ simulation code must not use floating-point arithmetic. -
ps/trunk/source/simulation2/helpers/Render.cpp
r10704 r10902 101 101 } 102 102 103 // This method splits up a straight line into a number of line segments each having a length ~= CELL_SIZE103 // This method splits up a straight line into a number of line segments each having a length ~= _SIZE 104 104 static void SplitLine(std::vector<std::pair<float, float> >& coords, float x1, float y1, float x2, float y2) 105 105 { 106 106 float length = sqrtf(SQR(x1 - x2) + SQR(y1 - y2)); 107 size_t pieces = ((int)length) / CELL_SIZE;107 size_t pieces = ((int)length) / _SIZE; 108 108 if (pieces > 0) 109 109 { -
ps/trunk/source/tools/atlas/GameInterface/ActorViewer.cpp
r10705 r10902 345 345 if (!cmpPosition.null()) 346 346 { 347 ssize_t c = CELL_SIZE * m.Terrain.GetPatchesPerSide()*PATCH_SIZE/2;347 ssize_t c = _SIZE * m.Terrain.GetPatchesPerSide()*PATCH_SIZE/2; 348 348 cmpPosition->JumpTo(entity_pos_t::FromInt(c), entity_pos_t::FromInt(c)); 349 349 cmpPosition->SetYRotation(entity_angle_t::Pi()); … … 479 479 else 480 480 centre.Y = 0.f; 481 centre.X = centre.Z = CELL_SIZE * m.Terrain.GetPatchesPerSide()*PATCH_SIZE/2;481 centre.X = centre.Z = _SIZE * m.Terrain.GetPatchesPerSide()*PATCH_SIZE/2; 482 482 483 483 CCamera camera = View::GetView_Actor()->GetCamera(); … … 542 542 z -= m.CurrentSpeed*dt; 543 543 // Wrap at the edges, so it doesn't run off into the horizon 544 ssize_t c = CELL_SIZE * m.Terrain.GetPatchesPerSide()*PATCH_SIZE/2;545 if (z < c - CELL_SIZE*PATCH_SIZE * 0.1f)546 z = c + CELL_SIZE*PATCH_SIZE * 0.1f;544 ssize_t c = _SIZE * m.Terrain.GetPatchesPerSide()*PATCH_SIZE/2; 545 if (z < c - _SIZE*PATCH_SIZE * 0.1f) 546 z = c + _SIZE*PATCH_SIZE * 0.1f; 547 547 cmpPosition->JumpTo(cmpPosition->GetPosition().X, entity_pos_t::FromFloat(z)); 548 548 } -
ps/trunk/source/tools/atlas/GameInterface/Brushes.cpp
r9362 r10902 91 91 { 92 92 CVector3D c = m_Centre; 93 if (m_W % 2) c.X += CELL_SIZE/2.f;94 if (m_H % 2) c.Z += CELL_SIZE/2.f;93 if (m_W % 2) c.X += _SIZE/2.f; 94 if (m_H % 2) c.Z += _SIZE/2.f; 95 95 ssize_t cx, cy; 96 96 CTerrain::CalcFromPosition(c, cx, cy); -
ps/trunk/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp
r10064 r10902 266 266 // to integer (rounding towards zero) will put it on the tile inside the edge 267 267 // instead of just outside 268 float mapWidth = (g_Game->GetWorld()->GetTerrain()->GetVerticesPerSide()-1)* CELL_SIZE;268 float mapWidth = (g_Game->GetWorld()->GetTerrain()->GetVerticesPerSide()-1)*_SIZE; 269 269 float delta = 1e-6f; // fraction of map width - must be > FLT_EPSILON 270 270
Note:
See TracChangeset
for help on using the changeset viewer.