Rigidbody Physics Refactor #100442

Open
opened 2022-08-16 16:47:44 +02:00 by Sonny Campbell · 8 comments
Member

Goal
The goal is to simplify the rigidbody physics code.

This ticket is being raised after discussions with @ZedDB about this issue https://developer.blender.org/T91369 and the related tickets regarding rigidbody physics crashes. I attempted to resolve those crashes on their own, but really struggled to find a sensible way to resolve some of the memory management issues that were occuring. @ZedDB mentioned that this was an area of the code in need of a redesign for some time, and with comments like below predicting this could be an issue, we decided it could be a good time to start tackling it.

image.png

Approach
I want to start with some smaller low hanging fruit, that wouldn't change any logic but will improve the readability of the code.

  • There is some dead code that can be removed

  • BKE_rigidbody_calc_center_of_mass - probably worth keeping the logic but hiding with a #if 0

  • BKE_rigidbody_world_groups_relink is only used by BKE_scene_groups_relink which doesn't seem to be used anywhere else.

  • It would make things much easier to follow by separating the simulation logic from the rididbody creation/deletion logic, into a separate rigidbody_simulation.c file.

  • There is a lot of general tidy-up that would make the code more readable and easier to understand.

Once these tasks are completed we can start thinking about any larger design issues that need to be addressed - like with the memory management of the constraints. With more readable code, and a better understanding of the logic from the refactoring process, it should be a more solvable problem.

**Goal** The goal is to simplify the rigidbody physics code. This ticket is being raised after discussions with @ZedDB about this issue https://developer.blender.org/T91369 and the related tickets regarding rigidbody physics crashes. I attempted to resolve those crashes on their own, but really struggled to find a sensible way to resolve some of the memory management issues that were occuring. @ZedDB mentioned that this was an area of the code in need of a redesign for some time, and with comments like below predicting this could be an issue, we decided it could be a good time to start tackling it. ![image.png](https://archive.blender.org/developer/F13394253/image.png) **Approach** I want to start with some smaller low hanging fruit, that wouldn't change any logic but will improve the readability of the code. - [ ] There is some dead code that can be removed - `BKE_rigidbody_calc_center_of_mass` - probably worth keeping the logic but hiding with a `#if 0` - `BKE_rigidbody_world_groups_relink` is only used by `BKE_scene_groups_relink` which doesn't seem to be used anywhere else. - [ ] It would make things much easier to follow by separating the simulation logic from the rididbody creation/deletion logic, into a separate `rigidbody_simulation.c` file. - [ ] There is a lot of general tidy-up that would make the code more readable and easier to understand. Once these tasks are completed we can start thinking about any larger design issues that need to be addressed - like with the memory management of the constraints. With more readable code, and a better understanding of the logic from the refactoring process, it should be a more solvable problem.
Sonny Campbell self-assigned this 2022-08-16 16:47:44 +02:00
Author
Member

Added subscribers: @ZedDB, @SonnyCampbell_Unity

Added subscribers: @ZedDB, @SonnyCampbell_Unity

Just to have it in writing here:
I'm fine with these steps. I don't think any of the other developers will have any issues with these either.

Just to have it in writing here: I'm fine with these steps. I don't think any of the other developers will have any issues with these either.

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

Added subscriber: @mod_moder

Added subscriber: @mod_moder
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123

Added subscriber: @vinegarshots

Added subscriber: @vinegarshots

Glad to see this here. I'm working on a project that requires a rigid body chain with a bunch of rigid body constraints, and it's almost impossible to complete due to the nonstop crashing :(

Glad to see this here. I'm working on a project that requires a rigid body chain with a bunch of rigid body constraints, and it's almost impossible to complete due to the nonstop crashing :(
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Bastien Montagne added this to the Core project 2023-02-09 15:42:54 +01:00
Bastien Montagne removed this from the Core project 2023-02-09 18:20:30 +01:00
Philipp Oeser removed the
Interest
Nodes & Physics
label 2023-02-10 08:43:48 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#100442
No description provided.