"Floor check" raycasts ignore platforms/stairs based on the bottom pos of the collider instead of the lowest limb, fixed IndoorsSteeringManager node diff checks

This commit is contained in:
Regalis
2016-11-17 20:00:03 +02:00
parent 089b0dbcee
commit a4f00310dc
2 changed files with 7 additions and 14 deletions
@@ -97,7 +97,7 @@ namespace Barotrauma
diff.Y = 0.0f; diff.Y = 0.0f;
} }
if (diff.Length() < 0.01) return -host.Steering; if (diff.LengthSquared() < 0.001f) return -host.Steering;
return Vector2.Normalize(diff) * speed; return Vector2.Normalize(diff) * speed;
} }
@@ -147,10 +147,8 @@ namespace Barotrauma
var collider = character.AnimController.Collider; var collider = character.AnimController.Collider;
Vector2 colliderBottom = character.AnimController.GetColliderBottom(); if (Math.Abs(collider.SimPosition.X - currentPath.CurrentNode.SimPosition.X) < collider.radius * 2 &&
if (Math.Abs(collider.SimPosition.X - currentPath.CurrentNode.SimPosition.X) < collider.radius*2 && Math.Abs(collider.SimPosition.Y - currentPath.CurrentNode.SimPosition.Y) < collider.height / 2 + collider.radius)
currentPath.CurrentNode.SimPosition.Y > colliderBottom.Y &&
currentPath.CurrentNode.SimPosition.Y < colliderBottom.Y + collider.height + collider.radius*2)
{ {
currentPath.SkipToNextNode(); currentPath.SkipToNextNode();
} }
@@ -167,8 +165,7 @@ namespace Barotrauma
diff.X = 0.0f; diff.X = 0.0f;
//at the same height as the waypoint //at the same height as the waypoint
if (currentPath.CurrentNode.SimPosition.Y > colliderBottom.Y && if (Math.Abs(collider.SimPosition.Y - currentPath.CurrentNode.SimPosition.Y) < collider.height / 2 + collider.radius)
currentPath.CurrentNode.SimPosition.Y < colliderBottom.Y + collider.height + collider.radius * 2)
{ {
float heightFromFloor = character.AnimController.GetColliderBottom().Y - character.AnimController.FloorY; float heightFromFloor = character.AnimController.GetColliderBottom().Y - character.AnimController.FloorY;
@@ -980,11 +980,7 @@ namespace Barotrauma
Vector2 rayEnd = rayStart; Vector2 rayEnd = rayStart;
rayEnd.Y -= Collider.height * 0.5f + Collider.radius + colliderHeightFromFloor*1.2f; rayEnd.Y -= Collider.height * 0.5f + Collider.radius + colliderHeightFromFloor*1.2f;
var lowestLimb = FindLowestLimb(); Vector2 colliderBottomDisplay = ConvertUnits.ToDisplayUnits(GetColliderBottom());
//TODO: use something like this instead of lowest limb, whenever we get to that
//float footY = Collider.SimPosition.Y + Collider.height * 0.5f + Collider.radius + ConvertUnits.ToSimUnits(45.0f);
if (!inWater && levitatingCollider) if (!inWater && levitatingCollider)
{ {
float closestFraction = 1.0f; float closestFraction = 1.0f;
@@ -995,11 +991,11 @@ namespace Barotrauma
{ {
case Physics.CollisionStairs: case Physics.CollisionStairs:
Structure structure = fixture.Body.UserData as Structure; Structure structure = fixture.Body.UserData as Structure;
if (lowestLimb.Position.Y<structure.Rect.Y-structure.Rect.Height+30 && TargetMovement.Y < 0.5f) return -1; if (colliderBottomDisplay.Y < structure.Rect.Y - structure.Rect.Height + 30 && TargetMovement.Y < 0.5f) return -1;
break; break;
case Physics.CollisionPlatform: case Physics.CollisionPlatform:
Structure platform = fixture.Body.UserData as Structure; Structure platform = fixture.Body.UserData as Structure;
if (IgnorePlatforms || lowestLimb.Position.Y < platform.Rect.Y-16) return -1; if (IgnorePlatforms || colliderBottomDisplay.Y < platform.Rect.Y - 16) return -1;
break; break;
case Physics.CollisionWall: case Physics.CollisionWall:
break; break;