Bug #4634

By ricardo Posted 2014-04-01 22:22

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:

```c++
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.

Back