Verlet Intergration Soft Body
Loading...
Searching...
No Matches
PhysicsCSAlevlProject.PolygonSeperatedAxisCollider Class Reference

general polygon collider that uses the Separating Axis Theorem (SAT) for collision detection, which can represent any shape not self intersectiong such as rectangles, triangles, and more complex polygons. More...

Inheritance diagram for PhysicsCSAlevlProject.PolygonSeperatedAxisCollider:
PhysicsCSAlevlProject.Collider PhysicsCSAlevlProject.SeperatedAxisRectangleCollider

Public Member Functions

override Collider DeepCopy ()
 PolygonSeperatedAxisCollider (Vector2[] vertices)
override bool ContainsPoint (Vector2 point, out Vector2 closestPoint)
override void Draw (SpriteBatch spriteBatch, PrimitiveBatch primitiveBatch)
 Draws the collider.
Public Member Functions inherited from PhysicsCSAlevlProject.Collider
bool ContainsPoint (Vector2 point, out Vector2 closestPoint)
 Determines if the given point is contained within the collider and calculates the closest point on the collider to the given point. This method is used for collision detection and response, allowing the application to determine if a particle or object is colliding with the collider and to find the nearest point on the collider's surface for accurate physics interactions. The method returns true if the point is inside the collider, and false otherwise, while also providing the closest point on the collider as an output parameter. it outputs the same point if the point is outside the collider, which is used for calculating the collision response direction and magnitude based on how far the point is from the collider's surface.
Collider DeepCopy ()
 Creates a deep copy of the collider,.

Public Attributes

Vector2[] Vertices
 the vertices of the polygon collider defined in local space
Vector2[] worldVertices
 the vertices of the polygon collider defined in world space

Properties

override Vector2 Position [get, set]
 the position of the polygon collider, which is the center point of the polygon. When the position is set, it updates the position of the polygon used for drawing and recalculates the vertices and axes of the polygon based on the new position.
float angle [get, set]
 the angle of the polygon collider in radians, which determines the rotation of the polygon. When the angle is set, it updates the rotation of the polygon used for drawing and recalculates the vertices and axes of the polygon based on the new angle.
Properties inherited from PhysicsCSAlevlProject.Collider
virtual Vector2 Position [get, set]
 the position of the collider

Private Member Functions

void UpdateWorldCacheIfNeeded ()
bool IsEar (Vector2 A, Vector2 B, Vector2 C, Vector2[] points)
bool PointInTriangle (Vector2 P, Vector2 A, Vector2 B, Vector2 C)
Vector2 GetClosestPointOnLineSegment (Vector2 A, Vector2 B, Vector2 P)
float Area (Vector2 A, Vector2 B, Vector2 C)
bool IsPointInPolygon (Vector2 point, Vector2[] polygon)

Static Private Member Functions

static Rectangle CreateBroadPhase (Vector2[] vertices)

Private Attributes

List< Vector2[]> Triangles = new()
 the triangles used for drawing the polygon collider
Vector2[] _axisPrivate
 the axis of the polygon collider used for collision detection using the Separating Axis Theorem (SAT)
Vector2 _position
 the position
float _angle
 the angle of the polygon collider in radians
Rectangle _localBroadPhase
 the broadphase rectangle used for a quick check to see if a point is potentially colliding with the polygon collider
Rectangle _worldBroadPhase
 the broadphase rectangle used for a quick check to see if a point is potentially colliding with the polygon collider
bool _worldCacheDirty
 a boolean flag to indicate whether the world vertices and world broadphase cache needs to be updated

Detailed Description

general polygon collider that uses the Separating Axis Theorem (SAT) for collision detection, which can represent any shape not self intersectiong such as rectangles, triangles, and more complex polygons.

Member Function Documentation

◆ Draw()

override void PhysicsCSAlevlProject.PolygonSeperatedAxisCollider.Draw ( SpriteBatch spriteBatch,
PrimitiveBatch primitiveBatch )
inlinevirtual

Draws the collider.

Parameters
spriteBatch
primitiveBatch

Reimplemented from PhysicsCSAlevlProject.Collider.

Reimplemented in PhysicsCSAlevlProject.SeperatedAxisRectangleCollider.


The documentation for this class was generated from the following file:
  • PhysicsCSAlevlProject/Objects.Colliders.cs