huxingyi / meshlite

(Depreciated) meshlite is a library with focus on 3D mesh generating and processing in rust language.
MIT License
45 stars 5 forks source link

Vectors in FFI? #9

Closed WildCryptoFox closed 5 years ago

WildCryptoFox commented 5 years ago

Vectors are not #[repr(C)], and although unlikely may change in size, alignment or layout. Are you implementing vectors on both sides of the C/Rust FFI? If you don't need the vectors to grow, prefer Box<[T]>. If you need to grow the vectors, do all growing on Rust's side and update the C references if the vector reallocates as (*cost T, usize) or (*mut T, usize).

Side question: Do you plan to migrate dust3d to Rust?

huxingyi commented 5 years ago

Hi, there are different vectors in C(Qt/C++) and Rust, to keep it simple, I was using pretty simplest plain array of float to represent vector in FFI. As you can see from meshlite.h, no extra data struct definition needed.

Do you plan to migrate dust3d to Rust?

If you mean the whole project, no, at least not at current stage. I am quite happy handling UI with Qt/C++ currently, but I am looking forward to see what UI framework of Rust could come out in the future to beat the Qt/C++.

Thanks!

WildCryptoFox commented 5 years ago

If the struct is never exported, then I don't think #[repr(C)] gives you anything? Okay.

Fair enough. I noticed you're not using n{algebra,collide,physics}.org for your points and algorithms, just an FYI in case you'd like to use them and didn't realize they existed.

As for UI, I don't know the current state but gfx-rs supports both opengl and vulkan, so that is likely some factor.

Good luck! Impressive ease of modeling!