Skip to content

Commit f47d156

Browse files
author
rt
committed
fix 4380
1 parent 336dd6d commit f47d156

83 files changed

Lines changed: 429 additions & 453 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

rts/ExternalAI/AICallback.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ const unsigned char* CAICallback::GetMetalMap()
10491049

10501050
float CAICallback::GetElevation(float x, float z)
10511051
{
1052-
return ground->GetHeightReal(x, z);
1052+
return CGround::GetHeightReal(x, z);
10531053
}
10541054

10551055

rts/Game/Camera/FPSController.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void CFPSController::UpdateVectors()
7272
pos.x = Clamp(pos.x, xMin, xMax);
7373
pos.z = Clamp(pos.z, zMin, zMax);
7474

75-
const float gndHeight = ground->GetHeightAboveWater(pos.x, pos.z, false);
75+
const float gndHeight = CGround::GetHeightAboveWater(pos.x, pos.z, false);
7676
const float yMin = gndHeight + 5.0f;
7777
const float yMax = 9000.0f;
7878
pos.y = Clamp(pos.y, yMin, yMax);
@@ -91,7 +91,7 @@ void CFPSController::SetPos(const float3& newPos)
9191
CCameraController::SetPos(newPos);
9292

9393
if (!gu->fpsMode) {
94-
pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false) + oldHeight;
94+
pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false) + oldHeight;
9595
}
9696
UpdateVectors();
9797
}

rts/Game/Camera/FreeController.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ void CFreeController::Update()
125125
// adjustment to match the ground slope
126126
float autoTiltVel = 0.0f;
127127
if (gndLock && (autoTilt > 0.0f)) {
128-
const float gndHeight = ground->GetHeightReal(pos.x, pos.z, false);
128+
const float gndHeight = CGround::GetHeightReal(pos.x, pos.z, false);
129129
if (pos.y < (gndHeight + gndOffset + 1.0f)) {
130130
float3 hDir;
131131
hDir.y = 0.0f;
132132
hDir.x = (float)math::sin(camera->rot.y);
133133
hDir.z = (float)math::cos(camera->rot.y);
134-
const float3 gndNormal = ground->GetSmoothNormal(pos.x, pos.z, false);
134+
const float3 gndNormal = CGround::GetSmoothNormal(pos.x, pos.z, false);
135135
const float dot = gndNormal.dot(hDir);
136136
const float gndRotX = (float)math::acos(dot) - (PI * 0.5f);
137137
const float rotXdiff = (gndRotX - camera->rot.x);
@@ -165,9 +165,9 @@ void CFreeController::Update()
165165
const float dGrav = (gravity * ft);
166166
vel.y += dGrav;
167167
if (slide > 0.0f) {
168-
const float gndHeight = ground->GetHeightReal(pos.x, pos.z, false);
168+
const float gndHeight = CGround::GetHeightReal(pos.x, pos.z, false);
169169
if (pos.y < (gndHeight + gndOffset + 1.0f)) {
170-
const float3 gndNormal = ground->GetSmoothNormal(pos.x, pos.z, false);
170+
const float3 gndNormal = CGround::GetSmoothNormal(pos.x, pos.z, false);
171171
const float dotVal = gndNormal.y;
172172
const float scale = (dotVal * slide * -dGrav);
173173
vel.x += (gndNormal.x * scale);
@@ -217,7 +217,7 @@ void CFreeController::Update()
217217
}
218218

219219
// setup ground lock
220-
const float gndHeight = ground->GetHeightReal(pos.x, pos.z, false);
220+
const float gndHeight = CGround::GetHeightReal(pos.x, pos.z, false);
221221

222222
if (KeyInput::GetKeyModState(KMOD_SHIFT)) {
223223
if (ctrlVelY > 0.0f) {
@@ -361,7 +361,7 @@ void CFreeController::MouseWheelMove(float move)
361361

362362
void CFreeController::SetPos(const float3& newPos)
363363
{
364-
const float h = ground->GetHeightReal(newPos.x, newPos.z, false);
364+
const float h = CGround::GetHeightReal(newPos.x, newPos.z, false);
365365
const float3 target = float3(newPos.x, h, newPos.z);
366366
// const float3 target = newPos;
367367
const float yDiff = pos.y - target.y;
@@ -375,7 +375,7 @@ void CFreeController::SetPos(const float3& newPos)
375375
CCameraController::SetPos(newPos);
376376
pos.y = oldPosY;
377377
if (gndOffset != 0.0f) {
378-
const float h = ground->GetHeightReal(pos.x, pos.z, false);
378+
const float h = CGround::GetHeightReal(pos.x, pos.z, false);
379379
const float absH = h + math::fabsf(gndOffset);
380380
if (pos.y < absH) {
381381
pos.y = absH;
@@ -391,7 +391,7 @@ float3 CFreeController::SwitchFrom() const
391391
{
392392
const float x = max(0.1f, min(float3::maxxpos - 0.1f, pos.x));
393393
const float z = max(0.1f, min(float3::maxzpos - 0.1f, pos.z));
394-
return float3(x, ground->GetHeightAboveWater(x, z, false) + 5.0f, z);
394+
return float3(x, CGround::GetHeightAboveWater(x, z, false) + 5.0f, z);
395395
}
396396

397397

rts/Game/Camera/OrbitController.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ COrbitController::COrbitController():
4040
void COrbitController::Init(const float3& p, const float3& tar)
4141
{
4242
const float l = (tar == ZeroVector)?
43-
std::max(ground->LineGroundCol(p, p + camera->forward * 1024.0f, false), 512.0f):
43+
std::max(CGround::LineGroundCol(p, p + camera->forward * 1024.0f, false), 512.0f):
4444
p.distance(tar);
4545

4646
const float3 t = (tar == ZeroVector)? (p + camera->forward * l): tar;
@@ -158,7 +158,7 @@ float3 COrbitController::GetDir() const
158158
void COrbitController::Orbit()
159159
{
160160
camera->SetPos(cen + GetOrbitPos());
161-
camera->SetPos((camera->GetPos() + XZVector) + (UpVector * std::max(camera->GetPos().y, ground->GetHeightReal(camera->GetPos().x, camera->GetPos().z, false))));
161+
camera->SetPos((camera->GetPos() + XZVector) + (UpVector * std::max(camera->GetPos().y, CGround::GetHeightReal(camera->GetPos().x, camera->GetPos().z, false))));
162162
camera->forward = (cen - camera->GetPos()).ANormalize();
163163
camera->up = UpVector;
164164
}
@@ -175,8 +175,8 @@ void COrbitController::Pan(int rdx, int rdy)
175175

176176

177177
// don't allow orbit center or ourselves to drop below the terrain
178-
const float camGH = ground->GetHeightReal(camera->GetPos().x, camera->GetPos().z, false);
179-
const float cenGH = ground->GetHeightReal(cen.x, cen.z, false);
178+
const float camGH = CGround::GetHeightReal(camera->GetPos().x, camera->GetPos().z, false);
179+
const float cenGH = CGround::GetHeightReal(cen.x, cen.z, false);
180180

181181
if (camera->GetPos().y < camGH) {
182182
camera->SetPos((camera->GetPos() * XZVector) + (UpVector * camGH));
@@ -225,7 +225,7 @@ void COrbitController::SetPos(const float3& newPos)
225225

226226
cen.x += dx;
227227
cen.z += dz;
228-
cen.y = ground->GetHeightReal(cen.x, cen.z, false);
228+
cen.y = CGround::GetHeightReal(cen.x, cen.z, false);
229229

230230
camera->SetPos(camera->GetPos() + float3(dx, 0.0f, dz));
231231
Init(camera->GetPos(), cen);

rts/Game/Camera/OverheadController.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ COverheadController::COverheadController()
3838
if (ground && globalRendering) {
3939
// make whole map visible
4040
const float h = std::max(pos.x / globalRendering->aspectRatio, pos.z);
41-
height = ground->GetHeightAboveWater(pos.x, pos.z, false) + (2.5f * h);
41+
height = CGround::GetHeightAboveWater(pos.x, pos.z, false) + (2.5f * h);
4242
}
4343

4444
maxHeight = 9.5f * std::max(gs->mapx, gs->mapy);
@@ -109,7 +109,7 @@ void COverheadController::MouseWheelMove(float move)
109109
}
110110

111111
float3 wantedPos = cpos + mouse->dir * dif;
112-
float newHeight = ground->LineGroundCol(wantedPos, wantedPos + dir * 15000, false);
112+
float newHeight = CGround::LineGroundCol(wantedPos, wantedPos + dir * 15000, false);
113113

114114
if (newHeight < 0.0f) {
115115
newHeight = height * (1.0f + move * 0.007f * shiftSpeed);
@@ -153,7 +153,7 @@ void COverheadController::UpdateVectors()
153153
{
154154
pos.x = Clamp(pos.x, 0.01f, gs->mapx * SQUARE_SIZE - 0.01f);
155155
pos.z = Clamp(pos.z, 0.01f, gs->mapy * SQUARE_SIZE - 0.01f);
156-
pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false);
156+
pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false);
157157
height = Clamp(height, 60.0f, maxHeight);
158158
dir = float3(0.0f, -1.0f, flipped ? zscale : -zscale).ANormalize();
159159
}

rts/Game/Camera/OverviewController.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ COverviewController::COverviewController()
1717
pos.x = gs->mapx * 0.5f * SQUARE_SIZE;
1818
pos.z = gs->mapy * 0.5f * SQUARE_SIZE;
1919
const float height = std::max(pos.x / globalRendering->aspectRatio, pos.z);
20-
pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false) + (2.5f * height);
20+
pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false) + (2.5f * height);
2121

2222
dir = float3(0.0f, -1.0f, -0.001f).ANormalize();
2323
}
@@ -49,7 +49,7 @@ void COverviewController::SetPos(const float3& newPos)
4949
float3 COverviewController::SwitchFrom() const
5050
{
5151
float3 dir = mouse->dir;
52-
float length = ground->LineGroundCol(pos, pos + dir * 50000, false);
52+
float length = CGround::LineGroundCol(pos, pos + dir * 50000, false);
5353
float3 rpos = pos + dir * length;
5454

5555
if (!globalRendering->dualScreenMode) {

rts/Game/Camera/RotOverheadController.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void CRotOverheadController::ScreenEdgeMove(float3 move)
5858

5959
void CRotOverheadController::MouseWheelMove(float move)
6060
{
61-
const float gheight = ground->GetHeightAboveWater(pos.x, pos.z, false);
61+
const float gheight = CGround::GetHeightAboveWater(pos.x, pos.z, false);
6262
float height = pos.y - gheight;
6363

6464
height *= (1.0f + (move * mouseScale));
@@ -77,15 +77,15 @@ void CRotOverheadController::UpdateVectors()
7777
pos.x = Clamp(pos.x, 0.01f, gs->mapx * SQUARE_SIZE - 0.01f);
7878
pos.z = Clamp(pos.z, 0.01f, gs->mapy * SQUARE_SIZE - 0.01f);
7979

80-
float h = ground->GetHeightAboveWater(pos.x, pos.z, false);
80+
float h = CGround::GetHeightAboveWater(pos.x, pos.z, false);
8181
pos.y = Clamp(pos.y, h + 5, 9000.0f);
8282
oldHeight = pos.y - h;
8383
}
8484

8585
void CRotOverheadController::SetPos(const float3& newPos)
8686
{
8787
CCameraController::SetPos(newPos);
88-
pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false) + oldHeight;
88+
pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false) + oldHeight;
8989
UpdateVectors();
9090
}
9191

rts/Game/Camera/SmoothController.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ SmoothController::SmoothController()
4343
if (ground && globalRendering) {
4444
// make whole map visible
4545
const float h = std::max(pos.x / globalRendering->aspectRatio, pos.z);
46-
height = ground->GetHeightAboveWater(pos.x, pos.z, false) + (2.5f * h);
46+
height = CGround::GetHeightAboveWater(pos.x, pos.z, false) + (2.5f * h);
4747
}
4848

4949
maxHeight = 9.5f * std::max(gs->mapx, gs->mapy);
@@ -155,7 +155,7 @@ void SmoothController::MouseWheelMove(float move)
155155
}
156156

157157
float3 wantedPos = cpos + mouse->dir * dif;
158-
float newHeight = ground->LineGroundCol(wantedPos, wantedPos + dir * 15000, false);
158+
float newHeight = CGround::LineGroundCol(wantedPos, wantedPos + dir * 15000, false);
159159

160160
if (newHeight < 0.0f) {
161161
newHeight = height * (1.0f + move * 0.007f * shiftSpeed);
@@ -199,7 +199,7 @@ void SmoothController::UpdateVectors()
199199
{
200200
pos.x = Clamp(pos.x, 0.01f, gs->mapx * SQUARE_SIZE - 0.01f);
201201
pos.z = Clamp(pos.z, 0.01f, gs->mapy * SQUARE_SIZE - 0.01f);
202-
pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false);
202+
pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false);
203203
height = Clamp(height, 60.0f, maxHeight);
204204
dir = float3(0.0f, -1.0f, flipped ? zscale : -zscale).ANormalize();
205205
}
@@ -212,7 +212,7 @@ void SmoothController::Update()
212212
float3 SmoothController::GetPos() const
213213
{
214214
float3 cpos = pos - dir * height;
215-
cpos.y = std::max(cpos.y, ground->GetHeightAboveWater(cpos.x, cpos.z, false) + 5.0f);
215+
cpos.y = std::max(cpos.y, CGround::GetHeightAboveWater(cpos.x, cpos.z, false) + 5.0f);
216216
return cpos;
217217
}
218218

rts/Game/Camera/TWController.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void CTWController::UpdateVectors()
7373
{
7474
pos.x = Clamp(pos.x, 0.01f, gs->mapx * SQUARE_SIZE - 0.01f);
7575
pos.z = Clamp(pos.z, 0.01f, gs->mapy * SQUARE_SIZE - 0.01f);
76-
pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false);
76+
pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false);
7777

7878
camera->rot.x = Clamp(camera->rot.x, -PI * 0.4f, -0.1f);
7979

@@ -95,8 +95,8 @@ float3 CTWController::GetPos() const
9595
float dist = -camera->rot.x * 1500;
9696

9797
float3 cpos = pos - dir * dist;
98-
if (cpos.y < ground->GetHeightAboveWater(cpos.x, cpos.z, false) + 5)
99-
cpos.y = ground->GetHeightAboveWater(cpos.x, cpos.z, false) + 5;
98+
if (cpos.y < CGround::GetHeightAboveWater(cpos.x, cpos.z, false) + 5)
99+
cpos.y = CGround::GetHeightAboveWater(cpos.x, cpos.z, false) + 5;
100100

101101
return cpos;
102102
}

rts/Game/FPSUnitController.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void FPSUnitController::Update() {
7272
// projectiles can gain extra flighttime and travel further
7373
//
7474
// NOTE: CWeapon::AttackGround checks range via TryTarget
75-
if ((targetPos.y - ground->GetHeightReal(targetPos.x, targetPos.z)) <= SQUARE_SIZE) {
75+
if ((targetPos.y - CGround::GetHeightReal(targetPos.x, targetPos.z)) <= SQUARE_SIZE) {
7676
controllee->AttackGround(targetPos, true, true, true);
7777
}
7878
}

0 commit comments

Comments
 (0)