From 2b19b24a263a6756c0a06fcc4af1d7d8a105aabd Mon Sep 17 00:00:00 2001 From: Syntriax Date: Thu, 1 Feb 2024 12:26:28 +0300 Subject: [PATCH] docs(physics2d): Abstract --- .../Abstract/ICircleCollider2D.cs | 10 ++++++++ Engine.Physics2D/Abstract/ICollider2D.cs | 23 +++++++++++++++++++ .../Abstract/ICollisionDetector2D.cs | 12 ++++++++++ .../Abstract/ICollisionResolver2D.cs | 7 ++++++ Engine.Physics2D/Abstract/IPhysicsEngine2D.cs | 10 ++++++++ .../Abstract/IPhysicsMaterial2D.cs | 10 ++++++++ Engine.Physics2D/Abstract/IRigidBody2D.cs | 20 ++++++++++++++++ Engine.Physics2D/Abstract/IShapeCollider2D.cs | 11 +++++++++ 8 files changed, 103 insertions(+) diff --git a/Engine.Physics2D/Abstract/ICircleCollider2D.cs b/Engine.Physics2D/Abstract/ICircleCollider2D.cs index 2391e53..a41820f 100644 --- a/Engine.Physics2D/Abstract/ICircleCollider2D.cs +++ b/Engine.Physics2D/Abstract/ICircleCollider2D.cs @@ -2,8 +2,18 @@ using Syntriax.Engine.Physics2D.Primitives; namespace Syntriax.Engine.Physics2D.Abstract; +/// +/// Represents a with the shape of a . +/// public interface ICircleCollider2D : ICollider2D { + /// + /// The local shape of the . + /// Circle CircleLocal { get; set; } + + /// + /// The world space representation of the shape. + /// Circle CircleWorld { get; } } diff --git a/Engine.Physics2D/Abstract/ICollider2D.cs b/Engine.Physics2D/Abstract/ICollider2D.cs index 5d2a5ff..8663860 100644 --- a/Engine.Physics2D/Abstract/ICollider2D.cs +++ b/Engine.Physics2D/Abstract/ICollider2D.cs @@ -4,15 +4,38 @@ using Syntriax.Engine.Core.Abstract; namespace Syntriax.Engine.Physics2D.Abstract; +/// +/// Represents a 2D collider. +/// public interface ICollider2D : IBehaviour, IAssignableTransform { + /// + /// Event triggered when a collision is detected. + /// Action? OnCollisionDetected { get; set; } + + /// + /// Event triggered when a collision is resolved. + /// Action? OnCollisionResolved { get; set; } + /// + /// Event triggered when another triggers this . + /// Action? OnTriggered { get; set; } + /// + /// The associated with the . + /// IRigidBody2D? RigidBody2D { get; } + + /// + /// The value indicating whether the is a trigger. + /// bool IsTrigger { get; set; } + /// + /// Recalculates properties. + /// void Recalculate(); } diff --git a/Engine.Physics2D/Abstract/ICollisionDetector2D.cs b/Engine.Physics2D/Abstract/ICollisionDetector2D.cs index d76da2a..63e89e4 100644 --- a/Engine.Physics2D/Abstract/ICollisionDetector2D.cs +++ b/Engine.Physics2D/Abstract/ICollisionDetector2D.cs @@ -2,7 +2,19 @@ using Syntriax.Engine.Physics2D.Abstract; namespace Syntriax.Engine.Physics2D; +/// +/// Represents a 2D collision detector. +/// public interface ICollisionDetector2D { + /// + /// Attempts to detect a collision between two s. + /// + /// Type of the first . + /// Type of the second . + /// The first . + /// The second . + /// Information about the collision. + /// if a collision is detected, otherwise . bool TryDetect(T1 left, T2 right, out CollisionDetectionInformation collisionInformation) where T1 : ICollider2D where T2 : ICollider2D; } diff --git a/Engine.Physics2D/Abstract/ICollisionResolver2D.cs b/Engine.Physics2D/Abstract/ICollisionResolver2D.cs index 05672a0..17fd4fd 100644 --- a/Engine.Physics2D/Abstract/ICollisionResolver2D.cs +++ b/Engine.Physics2D/Abstract/ICollisionResolver2D.cs @@ -1,6 +1,13 @@ namespace Syntriax.Engine.Physics2D.Abstract; +/// +/// Represents a 2D collision resolver. +/// public interface ICollisionResolver2D { + /// + /// Resolves collisions based on collision detection information provided. + /// + /// Information about the collision. void Resolve(CollisionDetectionInformation collisionInformation); } diff --git a/Engine.Physics2D/Abstract/IPhysicsEngine2D.cs b/Engine.Physics2D/Abstract/IPhysicsEngine2D.cs index 36bd191..d2ad40e 100644 --- a/Engine.Physics2D/Abstract/IPhysicsEngine2D.cs +++ b/Engine.Physics2D/Abstract/IPhysicsEngine2D.cs @@ -1,8 +1,18 @@ namespace Syntriax.Engine.Physics2D.Abstract; +/// +/// Represents a 2D physics engine. +/// public interface IPhysicsEngine2D { + /// + /// The number of iterations the performs per step. + /// int IterationCount { get; set; } + /// + /// Advances the physics simulation by the specified time. + /// + /// The time step. void Step(float deltaTime); } diff --git a/Engine.Physics2D/Abstract/IPhysicsMaterial2D.cs b/Engine.Physics2D/Abstract/IPhysicsMaterial2D.cs index c533cda..6019a91 100644 --- a/Engine.Physics2D/Abstract/IPhysicsMaterial2D.cs +++ b/Engine.Physics2D/Abstract/IPhysicsMaterial2D.cs @@ -1,7 +1,17 @@ namespace Syntriax.Engine.Physics2D.Abstract; +/// +/// Represents a 2D physics object's responsive attributes. +/// public interface IPhysicsMaterial2D { + /// + /// The friction coefficient of the physics object. + /// float Friction { get; } + + /// + /// The restitution (bounciness) coefficient of the physics object. + /// float Restitution { get; } } diff --git a/Engine.Physics2D/Abstract/IRigidBody2D.cs b/Engine.Physics2D/Abstract/IRigidBody2D.cs index ef8a5c2..9b8b68c 100644 --- a/Engine.Physics2D/Abstract/IRigidBody2D.cs +++ b/Engine.Physics2D/Abstract/IRigidBody2D.cs @@ -3,13 +3,33 @@ using Syntriax.Engine.Core.Abstract; namespace Syntriax.Engine.Physics2D.Abstract; +/// +/// Represents a 2D rigid body in the engine. +/// public interface IRigidBody2D : IBehaviour, IAssignableTransform { + /// + /// The physics material of the . + /// IPhysicsMaterial2D Material { get; set; } + /// + /// The velocity of the . + /// Vector2D Velocity { get; set; } + + /// + /// The angular velocity (rotation rate) of the . + /// float AngularVelocity { get; set; } + /// + /// The mass of the . + /// float Mass { get; set; } + + /// + /// The value indicating whether the is static/immovable. + /// bool IsStatic { get; set; } } diff --git a/Engine.Physics2D/Abstract/IShapeCollider2D.cs b/Engine.Physics2D/Abstract/IShapeCollider2D.cs index 2cc5218..96d4d1f 100644 --- a/Engine.Physics2D/Abstract/IShapeCollider2D.cs +++ b/Engine.Physics2D/Abstract/IShapeCollider2D.cs @@ -2,8 +2,19 @@ using Syntriax.Engine.Physics2D.Primitives; namespace Syntriax.Engine.Physics2D.Abstract; + +/// +/// Represents a with a custom . +/// public interface IShapeCollider2D : ICollider2D { + /// + /// Gets or sets the local of the . + /// Shape ShapeLocal { get; set; } + + /// + /// Gets the world space representation of the . + /// Shape ShapeWorld { get; } }