Projects > cpp > Issues > Bug #4634

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

Unify math library

Bug #4634 [Closed]
ricardo 2014-04-01 22:07 . Updated over 9 years ago

Currently cocos2d-x has two math libraries:

  • kazmath
  • CCGeometry

Problem:

  • we don't need 2 math libraries. We need one that is capable of doing both 2d and 3d math.
  • kazmath is a complete 2d + 3d math library but it is not using objects, and the API is not user friendly
  • CGGeometry is useful for 2d, but it is not a 3d math library, and it is not trivial to add support for 3d in it.

Solution:

Replace kazmath and CCGeometry with a good, object oriented, mobile-optimized math library like Gameplay's math library.

Scope:

The cocos2d API should be replaced:

  • Point should be replaced by Vector2
  • Vertex3 should be replaced by Vector3
  • kmMat4 should be replaced by Matrix

But it should be backwards compatible (whenever it makes sense).

eg: Point could be defined as:

1
typedef Point Vector2;

Additionally, the API should be optimized for 2D... at least for the moment.
So, getPosition() should return a const &Vector2 (since position is stored internally in a Vector2... but getPosition3() should return a Vector3 (no const&).

...at least for the moment.

ricardo 2014-04-01 22:22
  • Description updated (diff)
ricardo 2014-04-03 04:33

@winipcfg
glm is a complete math library.
But Gameplay's is faster (our team did so perf. tests before) and also easier to integrate. eg: we don't want to use the glm namespace.

zhangxm 2014-04-05 02:31
  • Assignee set to dabingnn
  • Priority changed from Normal to Urgent
zhangxm 2014-05-20 06:07
  • Status changed from New to Closed

Atom PDF

Status:Closed
Start date:2014-04-01
Priority:Urgent
Due date:
Assignee:dabingnn
% Done:

0%

Category:-
Target version:v3.1