Menu

#272 irrMath.h new s64/f64 and replace

closed-rejected
nobody
None
5
2014-04-07
2013-10-23
No

Little rewriting of the irrMath.h. It supports now s64 and f64 and some unused functions were replaced (s32_min, s32_max, s32_clamp, round_ -> now floor_, ceil_, round_ to be more logic with the min_, abs_ functions).
There also is a file where the functions s32_min, s32_max and s32_clamp were used and are now replaced by the min_, max_ and clamp_

Changes:
-max/min(const T& a, const T& b, const T& c)
max/min(const T& a, const T& b) is directly inlined

-clamp(const T& value, const T& low, const T& high)
max/min(const T& a, const T& b) is directly inlined

-iszero(const (u32, s32, new s64) a, const (u32, s32, new s64) tolerance = 0)
now iszero(const (u32, s32, new s64) a, const (u32, s32, new s64) tolerance = (ROUNDING_ERROR_S32, ROUNDING_ERROR_S32, ROUNDING_ERROR_S64)

-isnotzero(const f64 a, const f64 tolerance = ROUNDING_ERROR_f64)
New

-reciprocal_squareroot(const s64 x)
New

-reciprocal_squareroot(const f32 f)
New fast reciprocal_squareroot for fast math

-reciprocal_squareroot(const f64 x)
New fast reciprocal_squareroot for fast math

-floor32(f32 x), ceil32 ( f32 x ) and round32(f32 x)
are replaced by floor_, ceil_ and round_ and are also for s64.

-s32_min, s32_max and s32_clamp
are replaced by min_/max_/clamp functions.

3 Attachments

Discussion

  • Anonymous

    Anonymous - 2013-10-27

    A lot of corrections in this patch.

     

    Last edit: Anonymous 2013-10-29
  • Anonymous

    Anonymous - 2013-11-01

    Total redesign of the classes (line/vector/matrix/quaternion/ ...) to support floating and double precision. Someone should rewrite what I've done because the matrixOps returns strange results and vector2d/vector3d have errors due to precision of the tests I presume.
    So here is the list of changes:

    DoubleFloatIrrlicht

    Lots of changes for single and double precision on Irrlicht.

    --- aabbox3d<t> ---</t>

    -Add equals() functions.
    -Operator equality now use equals().
    -Specialisation for getInterpolated().
    -Specialisation for intersectsWithLine().
    -Add of typedef aabbox3d<s64> aabbox3dl and typedef aabbox3d<f64> aabbox3dd.</f64></s64>

    --- dimension2d<t> ---</t>

    -Specialisation for getInterpolated().
    -Add of typedef dimension2d<s64> dimension2dl.</s64>

    --- irrMath.h ---

    -New const u32 ROUNDING_ERROR_U32 = 0 and const f64 HALF_PI64 = PI64 / 2.0.
    /// ! \\ Now ROUNDING_ERROR_f32 and f64 are called ROUNDING_ERROR_F32 and F64.
    -New min_ for 2/3 types (The output will be the first type).
    -New max_ for 2/3 types (The output will be the first type).
    -In clamp(), min_ and max_ direct inlining of code.
    -Add equals() functions.
    -Add iszero() funcitons.
    -Add isnotzero() functions.
    -Suppression of s32_min/s32_max and s32_clamp.
    -New reciprocal_squareroot() with new algorithm for fast math.
    -New floor_/ceil_/round_/fract_ and suppression of the floor32/ceil32/round32.

    --- line2d<t> ---</t>

    -Add equals() functions.
    -Operator equality now use equals().
    -Specialisation for intersectWith().
    -Specialisation for getAngleWith().
    -Specialisation for getClosestPoint().

    -Add of typedef line2d<s64> line2dl and typedef line2d<f64> line2dd.</f64></s64>

    --- line3d<t> ---</t>

    -Add equals() functions.
    -Operator equality now use equals().
    -Add of typedef line3d<s64> line3dl and typedef line3d<f64> line3dd.</f64></s64>

    --- CMatrix4<t> ---</t>

    / This should be rewritten with template default /

    -Add equals() functions.
    -Operator equality now use equals().
    -Specialisation for setRotationRadians().
    -Specialisation for setInverseRotationRadians().
    -Specialisation for setRotationDegrees().
    -Specialisation for setInverseRotationDegrees().
    -Specialisation for getRotationDegrees().
    -Specialisation for setRotationAxisRadians().
    /// ! \\ I messed up isIdentity_integer_base().
    -Specialisation for buildProjectionMatrixPerspectiveFovRH().
    -Specialisation for buildProjectionMatrixPerspectiveFovLH().
    -Specialisation for buildProjectionMatrixPerspectiveFovInfinityLH().
    -Specialisation for buildProjectionMatrixOrthoRH().
    -Specialisation for buildProjectionMatrixOrthoLH().
    -Specialisation for buildProjectionMatrixPerspectiveRH().
    -Specialisation for buildProjectionMatrixPerspectiveLH().
    -Specialisation for buildShadowMatrix().
    -Specialisation for buildNDCToDCMatrix().
    -Specialisation for buildTextureTransform().
    -Specialisation for setTextureRotationCenter().
    -Add of typedef CMatrix4<s32> matrix4i, CMatrix4<s64> matrix4l and typedef CMatrix4<f64> matrix4d.</f64></s64></s32>

    --- plane3d<t> ---</t>

    -Add equals() functions.
    -Operator equality now use equals().
    -Specialisation for getIntersectionWithPlane().
    -Add of typedef plane3d<s64> plane3dl and typedef plane3d<f64> plane3dd.</f64></s64>

    --- CQuaternion<t> ---</t>

    /// ! \\ The class "quaternion" is recalled "CQuaternion" to be more logical with CMatrix4

    / This should be rewritten with template default /

    -Add equals() functions.
    -Operator equality now use equals().
    -Specialisation for getMatrix().
    -Specialisation for getMatrixCenter().
    -Specialisation for getMatrix_transposed().
    -Specialisation for set().
    -Specialisation for slerp().
    -Specialisation for fromAngleAxis().
    -Specialisation for toAngleAxis().
    -Specialisation for toEuler().
    -Specialisation for rotationFromTo().
    -Add of typedef CQuaternion<s32> quaternioni, typedef CQuaternion<s64> quaternionl,
    typedef CQuaternion<f32> quaternion and typedef CQuaternion<f64> quaterniond.</f64></f32></s64></s32>

    --- rect<t> ---</t>

    -Add equals() functions.
    -Operator equality now use equals().
    -Add operator <= and >=.
    -Add of typedef rect<u32> rectu, typedef rect<s64> rectl and typedef rect<f64> rectd.</f64></s64></u32>

    --- triangle3d<t> ---</t>

    -Add equals() functions.
    -Operator equality now use equals().
    -Specialisation for isPointInsideFast().
    -Specialisation for getIntersectionOfPlaneWithLine().
    -Add of typedef triangle3d<s64> triangle3dl and typedef triangle3d<f64> triangle3dd.</f64></s64>

    --- vector2d<t> ---</t>

    / This should be rewritten with template default /

    -Add equals() functions.
    -Operator equality now use equals().
    -Changes in the operatos > and <.
    -Specialisation for rotateBy().
    -Specialisation for getAngleTrig().
    -Specialisation for getAngle().
    -Specialisation for getAngleWith().
    -Specialisation for getInterpolated().
    -Specialisation for getInterpolated_quadratic().
    -Specialisation for interpolate().
    -Add of typedef vector2d<s64> vector2dl and typedef vector2d<f64> vector2dd.</f64></s64>

    --- vector3d<t> ---</t>

    / This should be rewritten with template default /

    -Add equals() functions.
    -Operator equality now use equals().
    -Changes in the operatos > and <.
    -Specialisation for rotateXZBy().
    -Specialisation for rotateXYBy().
    -Specialisation for rotateYZBy().
    -Specialisation for getInterpolated().
    -Specialisation for getInterpolated_quadratic().
    -Specialisation for interpolate().
    -Specialisation for getHorizontalAngle().
    -Specialisation for getSphericalCoordinateAngles().
    -Specialisation for rotationToDirection().
    -Add of typedef vector3d<s64> vector3dl and typedef vector3d<f64> vector3dd.</f64></s64>

     
  • Michael Zeilfelder

    Sorry, but again no chance I'm applying this. First of all - you did again mix all kind of changes together - most of which are no bugs at all.

    If you write patches:
    - Don't ever "fix" whitespace stuff just because you like it better another way. I don't say all whitespace patches are bad, but mostly they are about taste - and adding that to patches makes a patch harder to read for no good reason.
    - Moving around stuff. Yeah, I get you like inlines at another place. But this does not improve the engine or has anything to do with your other changes.
    - Don't rename functions unless you have a really good reason (and even then think again 2-3 more times). Every renamed function breaks applications using the old names. There is nothing library users hate more than having their applications getting broken on engine updates. And in this case there is even a good reason why the functions are called ceil32 instead of just ceil_, etc. It's because the name is meant to show that the return type is changed here (and all the optimizations are about that).So ceil32 is not just a ceil function but it's a ceil function which uses some optimizations for conversions to 32-bit integers. So in short changing that would be very bad idea!
    - Same goes for removing default parameters. I have no idea why you even want to remove them, but you should realized that doing so will break user applications
    - I have no clue why you re-order functions except to confuse readers of a patch...

    Now there are problem, like real bugs: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=49533
    Which is why that stuff will have to be changed - but definitely not in a way that breaks user applications for no gain whatsoever.

    Pretty much the same for your floatingDouble.patch. Do you really expect us to evalute a patch with over 11.000(!) lines where you mix rewrites that change nothing with whitespace changes, with - maybe some real changes mixed in somewhere in between? I'm fine if you want to rewrite the Irrlicht classes to suit your tastes ... but don't expect us to spend days on figuring out patches which for the most part don't even change things.

     
  • Michael Zeilfelder

    • status: open --> closed-rejected
     

Log in to post a comment.