godotccd

godotccd is a GDNative plugin for Godot Engine (3.4+) that leverages libccd for extremely fast collision checking between convex shapes like boxes, cylinders, and spheres. It offers both GJK and MPR algorithms for selection and operates independently of Godot's built-in physics system.

https://github.com/TheSHEEEP/godotccd

godotccd: Lightning-Fast Collision Detection for Godot

godotccd is a GDNative plugin designed to provide high-performance collision checking capabilities within the Godot Engine (versions 3.4 and later). It utilizes the libccd library to enable rapid collision detection between convex shapes, offering a significant speed advantage over Godot's built-in physics system in specific scenarios.

Key Features

  • Fast Collision Checking: Implements libccd, a library known for its speed in collision detection.
  • Convex Shape Support: Specifically designed for collision checks between boxes, cylinders, and spheres.
  • GJK and MPR Algorithms: Includes both Gilbert–Johnson–Keerthi (GJK) and Minkowski Portal Refinement (MPR) algorithms, allowing developers to choose the most suitable option for their needs.
  • GDNative Plugin: Seamlessly integrates with Godot Engine as a GDNative plugin.
  • Independent of Godot Physics: Operates independently of Godot's internal physics system, avoiding the overhead associated with physics frames and node setup.

Use Cases

godotccd is particularly useful in scenarios where rapid collision checks are required without relying on the full Godot physics engine. Examples include:

  • Games requiring a large number of collision checks per frame.
  • Tools and editors needing real-time collision feedback.
  • Situations where minimal overhead and maximum performance are critical.

How it Works

The plugin provides native scripts (CCDBox, CCDSphere, CCDCylinder) that represent the convex shapes. These shapes can be initialized with position, rotation, and dimensions. Collision checks are performed using either the GJK or MPR algorithms. The plugin also offers functions to retrieve collision information such as collision point, direction, and depth, though using these functions will incur a slight performance overhead.

Performance Considerations

The author recommends pre-initializing shapes to minimize the overhead of creating new native objects from GDScript. MPR is generally faster, but the performance difference may only be noticeable with a large number of collision checks. While godotccd provides very accurate results, it's possible that the collision results might not be 100% identical to Godot's built-in collision detection due to different internal math implementations.

Resource Details

tool

TheSHEEEP



3.4+