seclerp / OxyEngine

:video_game: OxyEngine - 2D full-featured open-source crossplatform game engine
http://oxyengine.org
MIT License
18 stars 2 forks source link

Research Aether2D for physics support #51

Closed seclerp closed 6 years ago

seclerp commented 6 years ago

Need to research how to integrate Aether2D physics into OxyEngine

Key questions:

seclerp commented 6 years ago

Aether2D: To research list

  1. Shapes, their types, how shapes are controlled and modified
  2. Raycasting, raycasting modes
  3. Collision layers, how is it implemented and controlled
  4. Physics simulation modes
  5. Trigger colliders, their event system
rufuszero commented 6 years ago
  1. Shapes

With Aether2D first of all you need to create the World, every object belongs to some world and can interact with other objects only when inside the world. After that you can add Bodies to the world. Body is just a set of coordinates, movement and rotation forces and states. It has no physical meaning. It can be static, dynamic or kinematic. You can attach different Fixtures to the body. Fixtures are the physical objects, they only can exist in the World when attached to some Body. One Body can have multiple Fixtures attached. All the objects can be created either by calling World methods or by creating a Body, adding Fixtures to it and then calling World.Add(); method and passing your Bodies as a parameter.

World has multiple methods for creating basic and most common objects. Some of those objects are:

Velocity, rotation, friction, restitution, density and everything else is controlled by calling Body object's methods.


  1. Raycasting

Raycasting is implemented in the World class and can be used by calling World.RayCast method which accepts a callback Func delegate, - this is your raycast logic, and 2 vectors to determine the position of the raycast. Aether2D supports multiple Raycasting modes. Basic modes are Multiple, Any and Closest. Results of raycast can be obtained by saving parameters of your callback function to some variables.


  1. Collision layers

Collision layers are implemented via Collision Categories and Groups. Each fixture has 3 open properties:

You can easily control collision layers with bit masks and flags. Just set 3 fields described above for every fixture you want to have collision logic and let the engine do it's work.


  1. Physics simulation modes

Engine is capable of most common physic simulation features. It also has some good additional features like buoyancy, fluid simulation etc. Anything else can be easily implemented by modifying Pre- and PostSolve systems, which allow implementing most physical interactions developer might need.


  1. Trigger colliders

Trigger colliders are really easy in Aether2D. Each body has 2 events:

If you need simple trigger collider, Aether2D offers you Sensors. Sensors are bodies which can not collide or interact with other bodies in the world directly. They solely serve as OnCollision and OnSeparation holders and fire those events upon something going through the sensor. To make a sensor - just set body.IsSensor property to true, and it will instantly lose all of it's physical properties and collisions. You can use described above events for any type of bodies, whether they are sensors or not.

seclerp commented 6 years ago

Nicely done!