bevy_rapier icon indicating copy to clipboard operation
bevy_rapier copied to clipboard

Flip writeback to iterate over rapier's bodies

Open Aceeri opened this issue 2 years ago • 3 comments

Unsure of whether this will have a noticeable performance improvement currently. I would like to do some benchmarks on how writeback performs.

I think the bigger thing here would be to not use bevy's transform propagation/GlobalTransform and instead adapt it to our case where we update a PhysicsTransform that is more akin to the old pre-0.8 bevy GlobalTransform. This would also allow us to not update unrelated entities.

Aceeri avatar Sep 27 '23 00:09 Aceeri

It seems that this gives a ~22% performance increase in the writeback system when profiling the boxes3 example. So seems worthwhile from initial benchmarks.

Aceeri avatar Sep 28 '23 15:09 Aceeri

Thank you for this PR! Is there a particular reason why the .tracy files were pushed?

I’m very surprised this improves performances. Doesn’t bevy recommend iterating on bodies rather than random access through Query::get? Does bevy’s Query::iter_mut involves a large overhead?

sebcrozet avatar Sep 30 '23 15:09 sebcrozet

.tracy files were unintentional sorry about that!

Yeah I wasn't expecting this to do anything honestly, I was just testing this out for the sake of the TODO comment. I'll probably investigate a bit more later on because realistically this shouldn't have any performance effect.

Aceeri avatar Oct 03 '23 17:10 Aceeri