Skip to content

Commit 9771b08

Browse files
committed
Merge branch 'development' into pictorial-loadouts
2 parents fe5cd08 + 60f8261 commit 9771b08

File tree

6 files changed

+41
-20
lines changed

6 files changed

+41
-20
lines changed

Source/Entities/Actor.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,13 @@ void Actor::OnNewMovePath() {
10811081
// Nowhere to gooooo
10821082
m_MoveTarget = m_PrevPathTarget = m_Pos;
10831083
}
1084+
1085+
// Smash all non-airborne waypoints down to just above the ground, so they more accurately represent the ground path
1086+
std::list<Vector>::iterator finalItr = m_MovePath.end();
1087+
--finalItr;
1088+
for (std::list<Vector>::iterator lItr = m_MovePath.begin(); lItr != finalItr; ++lItr) {
1089+
(*lItr) = g_SceneMan.MovePointToGround((*lItr), m_CharHeight * 0.2, 0, g_SettingsMan.GetPathFinderGridNodeSize() * 2.5f);
1090+
}
10841091
}
10851092

10861093
void Actor::PreControllerUpdate() {
@@ -1091,7 +1098,7 @@ void Actor::PreControllerUpdate() {
10911098
}
10921099

10931100
// We update this after, because pathing requests are forced to take at least 1 frame for the sake of determinism for now.
1094-
// In future maybe we can move this back, but it doesn't make much difference (the threadpool submission overhead makes it extremely unlikely that it would complete in less time anyways)
1101+
// In future maybe we can move this back, but it doesn't make much difference
10951102
if (m_UpdateMovePath) {
10961103
UpdateMovePath();
10971104
}

Source/Lua/LuaBindingsManagers.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,10 @@ LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, SceneMan) {
345345
.def("CastObstacleRay", &LuaAdaptersSceneMan::CastObstacleRay2)
346346
.def("CastTerrainPenetrationRay", &SceneMan::CastTerrainPenetrationRay)
347347
.def("GetLastRayHitPos", &SceneMan::GetLastRayHitPos)
348-
.def("FindAltitude", (float(SceneMan::*)(const Vector&, int, int)) & SceneMan::FindAltitude)
349-
.def("FindAltitude", (float(SceneMan::*)(const Vector&, int, int, bool)) & SceneMan::FindAltitude)
350-
.def("MovePointToGround", &SceneMan::MovePointToGround)
348+
.def("FindAltitude", (float(SceneMan::*)(const Vector&, int, int)) &SceneMan::FindAltitude)
349+
.def("FindAltitude", (float(SceneMan::*)(const Vector&, int, int, bool)) &SceneMan::FindAltitude)
350+
.def("MovePointToGround", (Vector(SceneMan::*)(const Vector&, int, int)) &SceneMan::MovePointToGround)
351+
.def("MovePointToGround", (Vector(SceneMan::*)(const Vector&, int, int, int)) &SceneMan::MovePointToGround)
351352
.def("IsWithinBounds", &SceneMan::IsWithinBounds)
352353
.def("ForceBounds", (bool(SceneMan::*)(Vector&) const) & SceneMan::ForceBounds) //, out_value(_2))
353354
.def("WrapPosition", (bool(SceneMan::*)(Vector&) const) & SceneMan::WrapPosition) //, out_value(_2))

Source/Managers/MovableMan.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,11 +1384,11 @@ void MovableMan::Update() {
13841384
[&](int start, int end) {
13851385
ZoneScopedN("Actors See");
13861386
for (int i = start; i < end; ++i) {
1387-
// TODO - this null check really shouldn't be required. There's almost definitely an issue where the actor update can somehow fuck with this mid-update
1388-
// this is VERY bad, and needs investigation!
1389-
if (m_Actors[i]) {
1390-
m_Actors[i]->CastSeeRays();
1391-
}
1387+
// TODO - this null check really shouldn't be required. There's almost definitely an issue where the actor update can somehow fuck with this mid-update
1388+
// this is VERY bad, and needs investigation!
1389+
if (m_Actors[i]) {
1390+
m_Actors[i]->CastSeeRays();
1391+
}
13921392
}
13931393
});
13941394

Source/Managers/SceneMan.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,7 @@ bool SceneMan::IsPointInNoGravArea(const Vector& point) const {
22422242
return false;
22432243
}
22442244

2245-
Vector SceneMan::MovePointToGround(const Vector& from, int maxAltitude, int accuracy) {
2245+
Vector SceneMan::MovePointToGround(const Vector& from, int heightAboveGround, int accuracy, int maxDistance) {
22462246
if (IsPointInNoGravArea(from)) {
22472247
return from;
22482248
}
@@ -2253,12 +2253,11 @@ Vector SceneMan::MovePointToGround(const Vector& from, int maxAltitude, int accu
22532253
float altitude = FindAltitude(temp, g_SceneMan.GetSceneHeight(), accuracy);
22542254

22552255
// If there's no ground beneath us, do nothing
2256-
if (altitude == g_SceneMan.GetSceneHeight()) {
2256+
if (altitude == g_SceneMan.GetSceneHeight() || (maxDistance != 0 && altitude > maxDistance)) {
22572257
return temp;
22582258
}
22592259

2260-
// Only move down if we're above the maxAltitude over the ground
2261-
Vector groundPoint(temp.m_X, temp.m_Y + (altitude > maxAltitude ? altitude - maxAltitude : 0));
2260+
Vector groundPoint(temp.m_X, temp.m_Y + (altitude - heightAboveGround));
22622261
return groundPoint;
22632262
}
22642263

Source/Managers/SceneMan.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,12 +787,17 @@ namespace RTE {
787787
/// down at a certain maximum distance from the ground.
788788
/// @param from The point to start from. Should be in the air, or the same point will
789789
/// be returned (null operation)
790-
/// @param maxAltitude The max altitude in px you want the point to be above the ground. (default: 0)
791-
/// @param accuracy The accuracy within screen measurement is acceptable. Higher number (default: 0)
792-
/// here means less calculation.
790+
/// @param heightAboveGround The altitude in px you want the point to be above the ground. (default: 0)
791+
/// @param accuracy The accuracy within screen measurement is acceptable. Higher number (default: 0) here means less calculation.
792+
/// @param maxDistance The maximum distance downwards the point will be moved. Points higher than this will not be moved down.
793793
/// @return The new point screen is no higher than accuracy + max altitude over
794794
/// the terrain.
795-
Vector MovePointToGround(const Vector& from, int maxAltitude = 0, int accuracy = 0);
795+
Vector MovePointToGround(const Vector& from, int heightAboveGround, int accuracy, int maxDistance);
796+
797+
// Luabind makes this such a pain
798+
Vector MovePointToGround(const Vector& from, int heightAboveGround = 0, int accuracy = 0) {
799+
return MovePointToGround(from, heightAboveGround, accuracy, 0);
800+
}
796801

797802
/// Returns whether the integer coordinates passed in are within the
798803
/// bounds of the current Scene, considering its wrapping.

Source/System/PathFinder.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,10 @@ void PathFinder::AdjacentCost(void* state, std::vector<micropather::StateCost>*
361361
break;
362362
}
363363

364-
totalMaterialCost += 1.0F + extraUpCost + (GetMaterialTransitionCost(*currentNode->UpMaterial) * 3.0F) + radiatedCost;
364+
float f = i + 2; // Exponential cost increase for jumping higher
365+
float extraJumpCost = f * f * 0.5F; // Exponential cost increase for jumping higher
366+
367+
totalMaterialCost += 1.0F + extraUpCost + extraJumpCost + (GetMaterialTransitionCost(*currentNode->UpMaterial) * 3.0F) + radiatedCost;
365368

366369
adjCost.cost = totalMaterialCost;
367370
adjCost.state = static_cast<void*>(currentNode->Up);
@@ -385,7 +388,10 @@ void PathFinder::AdjacentCost(void* state, std::vector<micropather::StateCost>*
385388
break;
386389
}
387390

388-
totalMaterialCost += 1.4F + (extraUpCost * 1.4F) + (GetMaterialTransitionCost(*currentNode->UpRightMaterial) * 1.4F * 3.0F) + radiatedCost;
391+
float f = i + 2; // Exponential cost increase for jumping higher
392+
float extraJumpCost = f * f * 0.5F; // Exponential cost increase for jumping higher
393+
394+
totalMaterialCost += 1.4F + (extraUpCost * 1.4F) + (extraJumpCost * 1.4f) + (GetMaterialTransitionCost(*currentNode->UpRightMaterial) * 1.4F * 3.0F) + radiatedCost;
389395

390396
adjCost.cost = totalMaterialCost;
391397
adjCost.state = static_cast<void*>(currentNode->UpRight);
@@ -404,7 +410,10 @@ void PathFinder::AdjacentCost(void* state, std::vector<micropather::StateCost>*
404410
break;
405411
}
406412

407-
totalMaterialCost += 1.4F + (extraUpCost * 1.4F) + (GetMaterialTransitionCost(*currentNode->LeftUpMaterial) * 1.4F * 3.0F) + radiatedCost;
413+
float f = i + 2; // Exponential cost increase for jumping higher
414+
float extraJumpCost = f * f * 0.5F; // Exponential cost increase for jumping higher
415+
416+
totalMaterialCost += 1.4F + (extraUpCost * 1.4F) + (extraJumpCost * 1.4f) + (GetMaterialTransitionCost(*currentNode->LeftUpMaterial) * 1.4F * 3.0F) + radiatedCost;
408417

409418
adjCost.cost = totalMaterialCost;
410419
adjCost.state = static_cast<void*>(currentNode->LeftUp);

0 commit comments

Comments
 (0)