opentomb / OpenTomb

An open-source Tomb Raider 1-5 engine remake
http://opentomb.github.io/
GNU Lesser General Public License v3.0
1.4k stars 146 forks source link

Which math library should be used? #171

Open vvs- opened 9 years ago

vvs- commented 9 years ago

There are too many alternatives already: old vmath, Bullet and Matrix4. Also, there is GLM and who knows what else. They introduce incompatibilities and bugs. The project should decide and make a clear statement of direction.

cochrane commented 9 years ago

In theory I would like to use bullet's library, because we don't really have the option of not using it. It's what bullet spits out so we better get used to it.

The main problem is its lack of a true 4x4 matrix. btTransform is not suitable for graphics stuff, in particular projection matrices, as we learned a while back.

We could add our own btTransform4 for this purpose and use standard bullet for the rest.

Lwmte commented 9 years ago

As we already use Bullet physics, I would use it. Although the problem with bullet is it's too complicated for OpenGL matrix operations. When in old engine revisions I could do anything on matrix directly, in Bullet I have to call "extraction" method first, and also specify row or column or whatever... It is too unintuitive and just too complicated (and I also believe it's slower).

I support Cochrane here. Only thing I'm concerned about is the way to add btTransform4. Please, don't return to built-in source code! :smile:

cochrane commented 9 years ago

Some more notes:

Only thing I'm concerned about is the way to add btTransform4. Please, don't return to built-in source code!

We could just add btTransform4.h to main OpenTomb. All we need is a function to create one from a btTransform, and this is actually trivial. The main difference over the current matrix4 would be to use btScalar instead of float, get rid of the own float4 (and ray4 and uint4, which aren't used here anyway), and probably get rid of the SSE code as well because in my experience that never provided any notable benefit.

vvs- commented 9 years ago

I feel that everyone is in favor of developing a new library on top of Bullet. That's fine as long as there is someone up to the task :eyeglasses:

stohrendorf commented 9 years ago

I have tried GLM a few times in my local checkout, and it seems pretty good, although it requires a major code rewrite. About bullet: As far as I can tell, this is only used for physics, isn't it? So here's my proposal: Do everything strongly related to physics with bullet, everything else with GLM, and write a few tiny conversion function between GLM and bullet. That way every library can do what it's designed for, and we only need to create that thin glue between the libs, which should ideally be limited to vectors (positional and rotational), although a few matrix operations would be convenient I think.

Lwmte commented 9 years ago

Then we also need to remove 'btScalar' from using anywhere where standard 'float' should be used as well.

Also, then Bullet should be absolutely removed from rendering process, which is not the case right now.

stohrendorf commented 9 years ago

As we have seen, bullet isn't suited for rendering, so I'd consider that an improvement.

cochrane commented 9 years ago

Adding a new third-party library to do stuff we can already do? Okay, if you insist, but I'm not overly enthusiastic about that idea.

Lwmte commented 9 years ago

And why all the neat matrix stuff was removed from vmath.cpp/h which was a second-party library after all, only to replace it with third-party one?

I just don't know to which extent we would use some extra math functions, as everything worked pretty well before with vmath.cpp/h. Only if we're planning some fun with geometry, rendering, or what? I'm not experienced in this field.