private CollisionFlags ScanSurfaces(Vector2 maxSurfaceDistance, out SurfaceAngles surfaceAngle) { var positiveAngle = 0f; var negativeAngle = 0f; var position = attachedRigidbody.position; var corners = new RectCorners(CheckBounds, position, SkinWidth); var collisionFlags = (CollisionFlags)0; // Vertical resolving var checkVertical = new Vector2( 0, maxSurfaceDistance.x + SkinWidth ); var steps = (int)(CheckBounds.width * Resolution); var stepSize = new Vector2(CheckBounds.width / steps, 0); collisionFlags |= Scan( corners.TopLeft, corners.BottomLeft, checkVertical, steps, stepSize, CollisionFlags.Above, CollisionFlags.Below, ref negativeAngle, ref positiveAngle); // Assign vertical values surfaceAngle.GroundAngle = negativeAngle; surfaceAngle.CeilingAngle = positiveAngle; // Horizontal resolving var checkHorizontal = new Vector2( maxSurfaceDistance.x + SkinWidth, 0 ); steps = (int)(CheckBounds.height * Resolution); stepSize = new Vector2(0, CheckBounds.height / steps); collisionFlags |= Scan( corners.BottomRight, corners.BottomLeft, checkHorizontal, steps, stepSize, CollisionFlags.Right, CollisionFlags.Left, ref negativeAngle, ref positiveAngle); // Assign vertical values surfaceAngle.LeftWallAngle = negativeAngle; surfaceAngle.RightWallAngle = positiveAngle; return(collisionFlags); }
public SurfaceInfo(CollisionFlags collisions, SurfaceAngles surfaceAngles) { Collisions = collisions; SurfaceAngles = surfaceAngles; }