RandyGaul / qu3e

Lightweight and Simple 3D Open Source Physics Engine in C++
zlib License
928 stars 111 forks source link

C API? #21

Open rweichler opened 8 years ago

rweichler commented 8 years ago

Any chance of getting one for this library? I'm using another language and can only interface with C.

RandyGaul commented 8 years ago

I'd be happy with an alternate C api. I don't have the time to do this myself but the code here is written in a way that lends itself to a port. It could be straight-forward of a task. If anyone coming along and reading here, contributing a C api could be a great way to contribute to the library! I'd be happy to take a look at and merge a pull request for this.

rweichler commented 8 years ago

Oh wow thanks for the fast response. I'll take a look and see if I can port it myself, then.

RandyGaul commented 8 years ago

Cool! I would suggest looking mostly at q3scene.h and q3body.h, and then perhaps wrapping whatever you like in a C api, perhaps in a header (like q3_c.h or something). The math is already in C format. The only other file I could imagine someone would want exposed is q3Box.h, but scene and body are the main two. I think that's all anyone would need to know to as far as the API goes :)

rweichler commented 8 years ago

Good to know!

Another question: Is it trivial to implement variable timestep? It seems like I just have to pass in a dt in q3Scene::Step() and set it here: https://github.com/RandyGaul/qu3e/blob/a7c7199d3a0c4ebbe4cc966b8fc9dfa708b8925c/src/scene/q3Scene.cpp#L89

Would this work as expected? Or would there be side effects?

RandyGaul commented 8 years ago

You can add in variable timestep if you like. The only downside is the lack of floating point determinism (which may or may not matter depending on what you're doing).