nfengine icon indicating copy to clipboard operation
nfengine copied to clipboard

Improve math module in nfCommon

Open Witek902 opened this issue 10 years ago • 2 comments

  • [x] Write non-SSE versions of all the functions (FPU only).
  • [x] Some of the functions could be turned into operators and methods. For example global function Matrix MatrixInverse(const Matrix& m) should be converted to methods: void Matrix::Invert() and Matrix Matrix::Inverted() const.
  • [x] Convert Quaternion into a class and get rid of global functions like QuaternionMultiply - they should be methods.
  • [ ] Add missing functions:
    • [ ] vector conversions
    • [ ] vector element shuffling/selecting/etc.
    • [ ] intersection functions
  • [ ] Write fast SSE and AVX versions of some Intersection functions, e.g. IntersectFrustumSpheres, IntersectFrustumFrustums, IntersectFrustumBoxes, etc. Will be useful for fast frustum culling.
  • [x] Write math operators for Float2, Float2 and Float4
  • [ ] Geometry
    • [ ] Implement "packed" versions of all gemetry shapes for storing data in most efficient way. For example PackedRay would be 2x Float3, while Ray contains 3x Vector (inversed direction is cached for performance reasons).
    • [ ] more 3D shapes:
      • [ ] OrientedBox
      • [ ] Line (infinite)
      • [ ] LineSection
      • [ ] BezierCurve
      • [ ] Cylinder
    • [ ] introduce 2D shapes:
      • [ ] Box2
      • [ ] OrientedBox2
      • [ ] Line2 (infinite)
      • [ ] LineSection2
      • [ ] Ray2
      • [ ] BezierCurve2
      • [ ] Triangle2
      • [ ] Circle2
  • [ ] Algebra
    • [x] Matrix2
    • [x] Matrix3
    • [x] Solving system of equations with 2, 3 and 4 variables (case for 3 variables is hardcoded somewhere, it must be done in more generic way).
    • [ ] Solving quadratic and cubic equations.
  • Split this task into multiple if needed.
  • Remember to write unit tests.

Witek902 avatar Aug 07 '14 20:08 Witek902

When stumbling across Math code in nfCommon, I noticed, that entire Math module still has its separate namespace (NFE::Math), even though it is a part of nfCommon library. IMO we should do something about it. Either:

  • Change namespace to NFE::Common
  • Move Math to separate, nfMath library and extract tests for it

Personally, I think that second option would be easier if we don't want to modify entire project's code. Math is separated from nfCommon (no module includes nfCommon.hpp), it can be compiled separately. Additionally, using it in other projects, if any, would be easier. Question is, do we want another library to link against.

lookeypl avatar Feb 21 '15 22:02 lookeypl

Additionally to this issue, please make sure, that Math will be compileable under Linux.

lookeypl avatar Feb 27 '15 12:02 lookeypl