A 2D Physics Engine
Find a file
OfficerYoda bfd8bd0fa5
Final Merge... (for now)
Final Pull... (for now)
2025-01-21 18:19:38 +01:00
.idea Running PerformanceTester with args 2025-01-07 21:01:54 +01:00
diagrams moved every diagram with visual into own folder 2025-01-21 16:51:36 +01:00
src Overhauled README 2025-01-21 18:10:48 +01:00
.gitignore Project restructuring 2024-11-27 18:12:54 +01:00
LICENSE Created LICENSE 2024-07-02 18:05:47 +02:00
pom.xml Building Project in Version 17 2025-01-06 23:41:21 +01:00
README.md Overhauled README 2025-01-21 18:10:48 +01:00

Fhysics

This project is a physics engine implemented in Kotlin. It provides functionality for movement, rotation and collision detection of rigid-bodies in a 2D environment. The engine is designed to be customizable at runtime through the provided user interface.

Table of Contents

Status

This project is completed. The engine is fully functional and can be used to simulate physics in a 2D environment. Future updates may include additional features, optimizations and bug fixes.

Features

  • Object collisions considering friction, rotation, and elasticity
  • Border collisions considering friction, rotation, and elasticity
  • Gravity (directional or towards a point)
  • Various shapes (circle, rectangle, convex and concave polygons)
  • QuadTree data structure for efficient collision detection
  • Real-time simulation and visualization
  • Customizable physics parameters (e.g., gravity strength/direction; collision elasticity & friction coefficients ( per object); ...)
  • User interface for easier interactions and visual elements
  • Debug visuals for debugging and deeper insights of the inner workings of the engine
  • Camera controls for panning and zooming

Why the Name?

As a big Star Wars fan, I initially wanted to call it "Force-Physics," but that felt too lengthy. Inspired by NVIDIA's "PhysX" engine, I decided to shorten it while maintaining the phonetic sound of "physics." Hence, "Fhysics" was born.

Controls

Mouse

  • LeftClick: Spawn circle/rectangle (when in circle/rectangle creation mode)
  • LeftClick: Add vertex to polygon (when in polygon creation mode)
  • LeftClick + Drag: Create rectangle from start point to release point (when in rectangle creation mode)
  • LeftClick + Drag (on object): Drag the object with the mouse
  • LeftClick (on object): Select object
  • RightClick: Reset polygon creation
  • RightClick + Drag: Pan camera
  • Scroll: Zoom camera

Keyboard

  • P: Toggle simulation pause/play
  • Enter: Step the simulation forward (when paused)
  • S: Print selected object details
  • Delete: Remove selected object
  • Z: Reset camera zoom and position
  • H: Decrease QuadTree capacity by 1
  • J: Decrease QuadTree capacity by 5
  • K: Increase QuadTree capacity by 5
  • L: Increase QuadTree capacity by 1
  • Q: Print QuadTree structure

Screenshots

10k Circles All the Objects 2
Polygon Creation Debug-QuadTree

Special Thanks

License

This project is licensed under the terms of the MIT license. See the LICENSE file for the full information.