Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a basic lines-based debug-renderer #315

Merged
merged 9 commits into from
Apr 28, 2022
Merged

Add a basic lines-based debug-renderer #315

merged 9 commits into from
Apr 28, 2022

Conversation

sebcrozet
Copy link
Member

This adds a basic debug-renderer to Rapier (hidden behind a new debug-render cargo feature).
This exposes a DebugRenderPipeline that can render rigid-bodies, colliders, and joints as long as the user provides a way to render lines. The main objective here is to provide a very easy ways for users to see what the physics engine sees.

The line renderer interface is fairly straightforward:

pub trait DebugRenderBackend {
    fn draw_line(
        &mut self,
        object: DebugRenderObject,
        a: Point<Real>,
        b: Point<Real>,
        color: [f32; 4],
    );

The most naive backend could simply draw the segment [a, b] using the given color. More elaborate backend way want to color things based on the way the object is rendered.

The color given to this method is computed from a style which can be modified by the user:

#[derive(Clone, Debug, PartialEq)]
pub struct DebugRenderStyle {
    pub subdivisions: u32,
    pub collider_dynamic_color: DebugColor,
    pub collider_fixed_color: DebugColor,
    pub collider_kinematic_color: DebugColor,
    pub collider_parentless_color: DebugColor,
    pub impulse_joint_anchor_color: DebugColor,
    pub impulse_joint_separation_color: DebugColor,
    pub multibody_joint_anchor_color: DebugColor,
    pub multibody_joint_separation_color: DebugColor,
    pub sleep_color_multiplier: [f32; 4],
    pub rigid_body_axes_length: f32,
}

Here is an example of this debug-rendering:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant