@@ -304,25 +304,28 @@ void PathFinder::AdjacentCost(void* state, std::vector<micropather::StateCost>*
304
304
const float costRadiationMultiplier = 0 .2F ;
305
305
float radiatedCost = 0 .0F ; // GetNodeAverageTransitionCost(*node) * costRadiationMultiplier;
306
306
307
+ bool isInNoGrav = g_SceneMan.IsPointInNoGravArea (node->Pos );
308
+ bool allowDiagonal = !isInNoGrav; // We don't allow diagonals in nograv to improve automover behaviour
309
+
307
310
if (node->Down && node->Down ->m_Navigatable ) {
308
311
adjCost.cost = 1 .0F + GetMaterialTransitionCost (*node->DownMaterial ) + radiatedCost;
309
312
adjCost.state = static_cast <void *>(node->Down );
310
313
adjacentList->push_back (adjCost);
311
314
}
312
315
313
- if (node->RightDown && node->RightDown ->m_Navigatable ) {
316
+ if (node->RightDown && node->RightDown ->m_Navigatable && !isInNoGrav ) {
314
317
adjCost.cost = 1 .4F + (GetMaterialTransitionCost (*node->RightDownMaterial ) * 1 .4F ) + radiatedCost;
315
318
adjCost.state = static_cast <void *>(node->RightDown );
316
319
adjacentList->push_back (adjCost);
317
320
}
318
321
319
- if (node->DownLeft && node->DownLeft ->m_Navigatable ) {
322
+ if (node->DownLeft && node->DownLeft ->m_Navigatable && !isInNoGrav ) {
320
323
adjCost.cost = 1 .4F + (GetMaterialTransitionCost (*node->DownLeftMaterial ) * 1 .4F ) + radiatedCost;
321
324
adjCost.state = static_cast <void *>(node->DownLeft );
322
325
adjacentList->push_back (adjCost);
323
326
}
324
327
325
- if (NodeIsOnSolidGround (*node)) {
328
+ if (isInNoGrav || NodeIsOnSolidGround (*node)) {
326
329
// Cost to discourage us from going up
327
330
const float extraUpCost = 3 .0F ;
328
331
@@ -369,7 +372,7 @@ void PathFinder::AdjacentCost(void* state, std::vector<micropather::StateCost>*
369
372
}
370
373
371
374
// Jumping diagonally
372
- if (s_JumpHeight < FLT_MAX && node->UpRight ) {
375
+ if (s_JumpHeight < FLT_MAX && node->UpRight && !isInNoGrav ) {
373
376
const PathNode* currentNode = node->UpRight ;
374
377
float totalMaterialCost = 1 .4F + (extraUpCost * 1 .4F ) + (GetMaterialTransitionCost (*node->UpRightMaterial ) * 1 .4F * 3 .0F ) + radiatedCost;
375
378
for (int i = 0 ; i < diagonalJumpHeightInNodes; ++i) {
@@ -388,7 +391,7 @@ void PathFinder::AdjacentCost(void* state, std::vector<micropather::StateCost>*
388
391
}
389
392
}
390
393
391
- if (s_JumpHeight < FLT_MAX && node->LeftUp ) {
394
+ if (s_JumpHeight < FLT_MAX && node->LeftUp && !isInNoGrav ) {
392
395
const PathNode* currentNode = node->LeftUp ;
393
396
float totalMaterialCost = 1 .4F + (extraUpCost * 1 .4F ) + (GetMaterialTransitionCost (*node->LeftUpMaterial ) * 1 .4F * 3 .0F ) + radiatedCost;
394
397
for (int i = 0 ; i < diagonalJumpHeightInNodes; ++i) {
@@ -408,13 +411,13 @@ void PathFinder::AdjacentCost(void* state, std::vector<micropather::StateCost>*
408
411
}
409
412
410
413
// Add cost for digging at 45 degrees and for digging upwards.
411
- if (node->UpRight && node->UpRight ->m_Navigatable ) {
414
+ if (node->UpRight && node->UpRight ->m_Navigatable && !isInNoGrav ) {
412
415
adjCost.cost = 1 .4F + (extraUpCost * 1 .4F ) + (GetMaterialTransitionCost (*node->UpRightMaterial ) * 1 .4F * 3 .0F ) + radiatedCost; // Three times more expensive when digging.
413
416
adjCost.state = static_cast <void *>(node->UpRight );
414
417
adjacentList->push_back (adjCost);
415
418
}
416
419
417
- if (node->LeftUp && node->LeftUp ->m_Navigatable ) {
420
+ if (node->LeftUp && node->LeftUp ->m_Navigatable && !isInNoGrav ) {
418
421
adjCost.cost = 1 .4F + (extraUpCost * 1 .4F ) + (GetMaterialTransitionCost (*node->LeftUpMaterial ) * 1 .4F * 3 .0F ) + radiatedCost; // Three times more expensive when digging.
419
422
adjCost.state = static_cast <void *>(node->LeftUp );
420
423
adjacentList->push_back (adjCost);
@@ -431,7 +434,7 @@ bool PathFinder::PositionsAreTheSamePathNode(const Vector& pos1, const Vector& p
431
434
}
432
435
433
436
bool PathFinder::NodeIsOnSolidGround (const PathNode& node) const {
434
- return s_JumpHeight == FLT_MAX || (node.Down && node.DownMaterial ->GetIntegrity () > c_PathFindingDefaultDigStrength) || g_SceneMan. IsPointInNoGravArea (node. Pos ) ;
437
+ return s_JumpHeight == FLT_MAX || (node.Down && node.DownMaterial ->GetIntegrity () > c_PathFindingDefaultDigStrength);
435
438
}
436
439
437
440
float PathFinder::GetMaterialTransitionCost (const Material& material) const {
0 commit comments