Demindiro / godot_rapier3d

Godot bindings for the Rapier3D physics engine
MIT License
42 stars 2 forks source link

What's the purpose of rapier3d_standalone? #18

Open geekrelief opened 3 years ago

geekrelief commented 3 years ago

I'm playing around with the IntegrationParameters and noticed rapier3d_standalone is taking 20 seconds out of the 30 seconds to compile. So I commented it out, and it doesn't seem to affect running things in Godot.

Demindiro commented 3 years ago

rapier3d_standalone is the dynamic library (cdylib) that is used by Godot while rapier3d is a Rust library that can be directly included in other Rust libraries.

I do it that way so that a game can be shipped with one big library instead of many smaller libraries (which all include duplicate code from stdlib, godot-rust ...)

Debug builds should compile quite a bit faster. For release builds LTO is enabled and codegen-units is set to 1 since it produces slightly better code. While debug builds do make FFI slower it shouldn't affect Rapier itself too much since dependencies are still compiled with opt-level = 3.

geekrelief commented 3 years ago

Thanks for the explanation. Forgive me if this is common knowledge for Rust programmers. I'm still making my way through the Rust book. But I just tried searching through it, and I just realized 'cdylib' isn't even covered in it. Though it is in the Rust Reference.

Do you think your comment should be in the README?

Demindiro commented 3 years ago

Thanks for the explanation. Forgive me if this is common knowledge for Rust programmers. I'm still making my way through the Rust book. But I just tried searching through it, and I just realized 'cdylib' isn't even covered in it. Though it is in the Rust Reference.

I guess cdylib isn't covered because it's specifically intended for FFI, which does have a chapter in the Rustonomicon (though the only mention of cdylib seems to be in panic_handler...).

Do you think your comment should be in the README?

I think a separate file describing the layout / architecture of this project (like ARCHITECTURE or maybe CONTRIBUTING) would be more appropriate.