saharan / OimoPhysics

A cross-platform 3D physics engine
MIT License
863 stars 68 forks source link

Cannot use as haxe library? #12

Closed Smoozilla closed 5 years ago

Smoozilla commented 6 years ago

I would like to use this library to compile to native android via lime, yet I've found the code is riddled with build macros to turn it into a JavaScript file.

Can I use this library directly in a Haxe project? Thanks.

saharan commented 6 years ago

You can use OimoPhysics for all platforms, directly. These macros help compile it into a JS file, but never prevent from compiling it into other formats than JS. Otherwise it's a bug so I'd try to fix it. Thanks,

Smoozilla commented 6 years ago

Thank you for the reply, and the project.

I'm having difficulty trying to compile the library to JavaScript, I would like to bypass all the macros and ultimately compile into Typescript, something similar to this process: https://bitbucket.org/yar3333/haxe-nodegen

Can you advise me the best way to get this compiled as a Typescript library? I am using the physics on the server side as well, and among other reasons, it would be ideal.

Thanks again!

saharan commented 6 years ago

I think it's difficult to bypass all the macros in the codes, especially build macros that edit the syntax tree (parsed by the compiler) to add or remove local/class fields before its semantic analysis is done.

I'm not good at TypeScript so I don't know what is the best way to convert it, but some advice is like:

Actually the current heavy usage of build macros somewhat differs from what I expected first; it was adopted in order to make the most of SIMD in JavaScript in future, and now SIMD in JavaScript is not likely to be widely introduced :( So I may get rid of those macros in the next major update and implement some more memory management systems instead.

Thanks!

Smoozilla commented 6 years ago

Again thank you for everything, this rendition of OIMO is by far my favorite physics engine available in JavaScript.

I am running it on the node side, and sticking to pure NodeJS for the project, transpiling for the client. I've done a few edits on the offered binary and it works fine, though not as elegant as if it were a node module I could npm install. TypeScript would be nice but personally at this point I'm far enough into the JavaScript I'd like to revoke my TS vote. :grin: