Page MenuHome

Use float in moto.
ClosedPublic

Authored by Porteries Tristan (panzergame) on Nov 7 2015, 10:57 PM.

Details

Summary

Use float in moto instead of double.
This switch allow future optimization like SSE and OpenGL call which are very bad with double.

Diff Detail

Repository
rB Blender

Event Timeline

I have not tested yet. I will do this night.

My concerns: Floating-point literals in C++ are of type double. If the Floating-point literals don't use the "*.**f" format then MOTO will use the overloaded double functions, e.g. in MT_Matrix4x4.h we have:

/**
 * Initialize all fields with the values pointed at by m. A
 * contigous block of 16 values is read.  */
  MT_Matrix4x4(const float *m) { setValue(m); }
/**
 * Initialize all fields with the values pointed at by m. A
 * contigous block of 16 values is read.  */
  MT_Matrix4x4(const double *m) { setValue(m); }

and we will have a lot warnings about precision lost from double to float.

Possible solutions:

  • format ALL the floating-point literals correctly.
  • Remove overloaded double functions from MOTO (easier).
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp
269

float casting it is not necessary now

I applied a modified version of this patch for blender 2.49b (for KRUM game) and we had the following problems with the IK animation (possibly related to precission lost):

I have IK bones in one chain that are affected from different not IK bones, The second IK bone in the IK chain is glitching constantly in the game. Not glitching in the editor and not glitching in the game engine, when just that mob is on the screen with no other content.

The solution was to leave the IK library using doubles.

I've just replaced Moto with Eigen in the IK solver, so that shouldn't be affected by this change now.

Jorge Bernal (lordloki) edited edge metadata.

Ok, then no issue from my part. LGTM.

After commit this patch, It is possible that we need to do some cleaning work (0.0 -> 0.0f) over all the gameengine code to avoid non desired conversions/promotions.

This revision is now accepted and ready to land.Dec 11 2015, 9:50 AM

@Jorge Bernal (lordloki): you can commit.
There's no reasons to keep moto now, i will move to eigen in UPBGE.

Well, moving moto to eigen is not the best way, it's long, hard and doesn't work for all case. I tryed for 2 days to do it, i abandon after a patch of 4000 insertions and deletion. if someone want to continue the conversion the patch is : https://developer.blender.org/differential/diff/5560/

As brecht said : only the BGE use moto now, so we can modifiy moto without issues like implement SSE, replace MT_assert by BLI_assert, cleanup the code or use templates. @Jorge Bernal (lordloki) : what do you think about it ?

hey, you are not the first that fail in the BGE Moto-Eigen conversion :-). I think that Moguri and me tried it sometime ago but as you said it is a long and tedious task.

Anyway, I have been doing tests with complex blends and i have no issue with this patch. I'm going to commit now and we can clean float conversion-promotions after.

This revision was automatically updated to reflect the committed changes.