dimforge / rapier

2D and 3D physics engines focused on performance.
https://rapier.rs
Apache License 2.0
3.77k stars 235 forks source link

Feature: Add support for custom friction and bounce CombineRules #622

Open Ughuuu opened 2 months ago

Ughuuu commented 2 months ago

I have a use case where in Godot they use friction and bounce like so:

real_t combine_bounce(GodotBody3D *A, GodotBody3D *B) {
    return CLAMP(A->get_bounce() + B->get_bounce(), 0, 1);
}

real_t combine_friction(GodotBody3D *A, GodotBody3D *B) {
    return ABS(MIN(A->get_friction(), B->get_friction()));
}

So bounce they sum them, and then either take 0 or 1(bounce can be negative on some objects) Friction they take the min and then take abs(agian, friction can be negative, and in such a case that is the value you always take). Weird case, but am thinking how could I do this in rapier? Maybe if I could override the combine function from CoefficientCombineRule, I could make it work.

Ughuuu commented 6 days ago

Any updates on this? I would be willing to implement it if there was some guidance as to what is wanted for this (eg. a callback, more enum types for different friction/bounce actions? etc)