Skip to content

Rename most rigid_body names to body#718

Merged
Jondolf merged 2 commits into
mainfrom
rigid-body-to-body
May 4, 2025
Merged

Rename most rigid_body names to body#718
Jondolf merged 2 commits into
mainfrom
rigid-body-to-body

Conversation

@Jondolf

@Jondolf Jondolf commented May 4, 2025

Copy link
Copy Markdown
Member

Objective

We have a lot of properties called rigid_body. In a lot of cases, really the relevant part is that it is just a physics "body", and the rigid_ qualifier is largely unnecessary. Typically, it's enough to just use body for properties, and it can result in cleaner names.

Solution

Rename rigid_body to just body for OnCollisionStart, OnCollisionEnd, ColliderOf, and many internal variables and types.

Despite using body for a lot of property names, I think we should still probably keep the Rigid prefix for types such as RigidBody.


Migration Guide

ColliderQuery::rigid_body has been renamed to of (for ColliderOf) and there is a new body helper to get the contained entity directly.

@Jondolf Jondolf added M-Migration-Guide A breaking change to Avian's public API that needs to be noted in a migration guide C-Code-Quality Improvements to code readability, maintainability, or best practices labels May 4, 2025
@Jondolf Jondolf merged commit bb4ad39 into main May 4, 2025
5 checks passed
@Jondolf Jondolf deleted the rigid-body-to-body branch May 4, 2025 15:59
Jondolf added a commit that referenced this pull request May 4, 2025
# Objective

Follow-up to #718.

`ContactPair` has `entity1`, `entity2`, `body_entity1`, and `body_entity2`, while `ContactConstraint` has `entity1`, `entity2`, `collider_entity1`, and `collider_entity2`. The `entity` specifiers are kind of unnecessary, and it'd be nice if the names were more consistent and `entity1` and `entity2` were more explicit about whether they are the collider or body entities.

## Solution

Rename the properties such that both `ContactPair` and `ContactConstraint` have `collider1`, `collider2`, `body1`, and `body2`.

---

## Migration Guide

- `ContactPair`: The `entity1` and `entity2` properties are now `collider1` and `collider2`, and `body_entity1` and `body_entity2` are now `body1` and `body2`.
- `ContactConstraint`: The `entity1` and `entity2` properties are now `body1` and `body2`, and `collider_entity1` and `collider_entity2` are now `collider1` and `collider2`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Code-Quality Improvements to code readability, maintainability, or best practices M-Migration-Guide A breaking change to Avian's public API that needs to be noted in a migration guide

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant