Fixed circular physics bodies not being rendered in debugdraw if the radius is less than 1.28f

This commit is contained in:
Joonas Rikkonen
2018-02-06 16:25:07 +02:00
parent af9980090b
commit 3cbff6bd7b
@@ -67,7 +67,7 @@ namespace Barotrauma
{ {
switch (BodyShape) switch (BodyShape)
{ {
case PhysicsBody.Shape.Rectangle: case Shape.Rectangle:
{ {
float maxSize = Math.Max(ConvertUnits.ToDisplayUnits(width), ConvertUnits.ToDisplayUnits(height)); float maxSize = Math.Max(ConvertUnits.ToDisplayUnits(width), ConvertUnits.ToDisplayUnits(height));
if (maxSize > 128.0f) if (maxSize > 128.0f)
@@ -84,7 +84,7 @@ namespace Barotrauma
(int)ConvertUnits.ToDisplayUnits(height * bodyShapeTextureScale)); (int)ConvertUnits.ToDisplayUnits(height * bodyShapeTextureScale));
break; break;
} }
case PhysicsBody.Shape.Capsule: case Shape.Capsule:
{ {
float maxSize = Math.Max(ConvertUnits.ToDisplayUnits(radius), ConvertUnits.ToDisplayUnits(Math.Max(height, width))); float maxSize = Math.Max(ConvertUnits.ToDisplayUnits(radius), ConvertUnits.ToDisplayUnits(Math.Max(height, width)));
if (maxSize > 128.0f) if (maxSize > 128.0f)
@@ -101,18 +101,22 @@ namespace Barotrauma
(int)ConvertUnits.ToDisplayUnits(Math.Max(height, width) * bodyShapeTextureScale)); (int)ConvertUnits.ToDisplayUnits(Math.Max(height, width) * bodyShapeTextureScale));
break; break;
} }
case PhysicsBody.Shape.Circle: case Shape.Circle:
if (ConvertUnits.ToDisplayUnits(radius)> 128.0f) if (ConvertUnits.ToDisplayUnits(radius) > 128.0f)
{ {
bodyShapeTextureScale = 128.0f / ConvertUnits.ToDisplayUnits(radius); bodyShapeTextureScale = 128.0f / ConvertUnits.ToDisplayUnits(radius);
} }
else
{
bodyShapeTextureScale = 1.0f;
}
bodyShapeTexture = GUI.CreateCircle((int)ConvertUnits.ToDisplayUnits(radius * bodyShapeTextureScale)); bodyShapeTexture = GUI.CreateCircle((int)ConvertUnits.ToDisplayUnits(radius * bodyShapeTextureScale));
break; break;
} }
} }
float rot = -DrawRotation; float rot = -DrawRotation;
if (bodyShape == PhysicsBody.Shape.Capsule && width > height) if (bodyShape == Shape.Capsule && width > height)
{ {
rot -= MathHelper.PiOver2; rot -= MathHelper.PiOver2;
} }