Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
Aabb.cs
1using System.Drawing;
2
4
9public readonly struct Aabb
10{
14 public float MinX { get; }
15
19 public float MinY { get; }
20
24 public float MaxX { get; }
25
29 public float MaxY { get; }
30
34 public float Width => MaxX - MinX;
35
39 public float Height => MaxY - MinY;
40
44 public PointF Center => new(
45 MinX + Width * 0.5f,
46 MinY + Height * 0.5f);
47
56 public Aabb(float minX, float minY, float maxX, float maxY)
57 {
58 if (maxX < minX)
59 throw new ArgumentException("maxX < minX");
60
61 if (maxY < minY)
62 throw new ArgumentException("maxY < minY");
63
64 MinX = minX;
65 MinY = minY;
66 MaxX = maxX;
67 MaxY = maxY;
68 }
69
75 public static Aabb FromRectangle(Rectangle r) =>
76 new(r.Left, r.Top, r.Right, r.Bottom);
77
83 public static Aabb FromRectangleF(RectangleF r) =>
84 new(r.Left, r.Top, r.Right, r.Bottom);
85
91 public bool Intersects(in Aabb other) =>
92 !(other.MinX >= MaxX || other.MaxX <= MinX ||
93 other.MinY >= MaxY || other.MaxY <= MinY);
94
99 public Rectangle ToRectangle() =>
100 Rectangle.FromLTRB(
101 (int)MinX, (int)MinY,
102 (int)MaxX, (int)MaxY);
103}
float MinX
Gets the minimum X coordinate of the bounding box.
Definition Aabb.cs:14
bool Intersects(in Aabb other)
Determines whether this bounding box intersects with another bounding box.
Rectangle ToRectangle()
Converts this bounding box to a Rectangle by casting the floating-point coordinates to integers.
static Aabb FromRectangle(Rectangle r)
Creates an Aabb from a Rectangle.
Aabb(float minX, float minY, float maxX, float maxY)
Initializes a new instance of the Aabb struct with the specified boundaries.
Definition Aabb.cs:56
PointF Center
Gets the center point of the bounding box.
Definition Aabb.cs:44
float Width
Gets the width of the bounding box.
Definition Aabb.cs:34
static Aabb FromRectangleF(RectangleF r)
Creates an Aabb from a RectangleF.
float MaxY
Gets the maximum Y coordinate of the bounding box.
Definition Aabb.cs:29
float MinY
Gets the minimum Y coordinate of the bounding box.
Definition Aabb.cs:19
float Height
Gets the height of the bounding box.
Definition Aabb.cs:39
float MaxX
Gets the maximum X coordinate of the bounding box.
Definition Aabb.cs:24