Squashed commit of the following:

commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5
Author: Ricardo Quesada <ricardoquesada@gmail.com>
Date:   Wed May 14 10:03:44 2014 -0700

    math renames

    `Vector2` -> `Vec2`
    `Vector3` -> `Vec3`
    `Vector4` -> `Vec4`
    `Matrix` -> `Mat4`

commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 09:24:28 2014 -0700

    raw version of rename Vector3

commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 09:07:14 2014 -0700

    rename Vector2 after merge

commit ab2ed58c129dbc30a4c0970ed94568c5d271657b
Merge: 1978d2d 86fb75a
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 09:05:30 2014 -0700

    Merge branch 'v3' into v3_renameMathClassName

    Conflicts:
    	tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp
    	tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp
    	tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp
    	tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp
    	tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp

commit 1978d2d174877172ccddc083020a1bbf43ad3b39
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 08:51:45 2014 -0700

    rename vector2 in tests/cpp-empty-test folder

commit d4e0ff13dcce62724d2fece656543f26aa28e467
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 00:58:23 2014 -0700

    rename vector2 in tests/cpp-tests cpp files

commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 00:52:57 2014 -0700

    rename vector2 in tests/cpp-tests head files

commit 6daef564400d4e28c4ce20859a68e0f583fed125
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 00:49:48 2014 -0700

    rename vector2 in extension folder

commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 00:47:22 2014 -0700

    rename vector2 in cocos/2d cpp files

commit e1f3105aae06d595661a3030f519f7cc13aefbed
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 00:44:39 2014 -0700

    rename vector2 in cocos/2d head files

commit 6708d890bfe486109120c3cd4b9fe5c078b7108f
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 00:40:59 2014 -0700

    rename vector2 in cocos/base folder

commit d3978fa5447c31ea2f3ece5469b7e746dfba4248
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 00:40:43 2014 -0700

    rename vector2 in cocos/deprecated folder

commit 4bff45139363d6b9706edbbcf9f322d48b4fd019
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 00:40:26 2014 -0700

    rename vector2 in cocos/editor-support folder

commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 00:36:48 2014 -0700

    rename vector2 in cocos/ui folder

commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 00:32:39 2014 -0700

    rename vector2 in cocos/renderer folder

commit 0bd2710dd8714cecb993880bc37affd9ecb05c27
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 00:32:15 2014 -0700

    rename vector2 in cocos/physics folder

commit b7f0581c4587348bdbc1478d5374c2325735f21d
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 00:25:01 2014 -0700

    rename vector2 in cocos/math folder

commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd
Author: Huabing.Xu <dabingnn@gmail.com>
Date:   Wed May 14 00:16:55 2014 -0700

    rename Vector2 to Vec2
    deprecate typedef Vector2
This commit is contained in:
Ricardo Quesada 2014-05-14 10:07:09 -07:00
parent 86fb75a031
commit dc711643cd
458 changed files with 6048 additions and 6046 deletions

View File

@ -215,7 +215,7 @@ bool Follow::initWithTarget(Node *followedNode, const Rect& rect/* = Rect::ZERO*
_boundaryFullyCovered = false; _boundaryFullyCovered = false;
Size winSize = Director::getInstance()->getWinSize(); Size winSize = Director::getInstance()->getWinSize();
_fullScreenSize = Vector2(winSize.width, winSize.height); _fullScreenSize = Vec2(winSize.width, winSize.height);
_halfScreenSize = _fullScreenSize * 0.5f; _halfScreenSize = _fullScreenSize * 0.5f;
if (_boundarySet) if (_boundarySet)
@ -257,9 +257,9 @@ void Follow::step(float dt)
if(_boundaryFullyCovered) if(_boundaryFullyCovered)
return; return;
Vector2 tempPos = _halfScreenSize - _followedNode->getPosition(); Vec2 tempPos = _halfScreenSize - _followedNode->getPosition();
_target->setPosition(Vector2(clampf(tempPos.x, _leftBoundary, _rightBoundary), _target->setPosition(Vec2(clampf(tempPos.x, _leftBoundary, _rightBoundary),
clampf(tempPos.y, _bottomBoundary, _topBoundary))); clampf(tempPos.y, _bottomBoundary, _topBoundary)));
} }
else else

View File

@ -277,8 +277,8 @@ protected:
bool _boundaryFullyCovered; bool _boundaryFullyCovered;
// fast access to the screen dimensions // fast access to the screen dimensions
Vector2 _halfScreenSize; Vec2 _halfScreenSize;
Vector2 _fullScreenSize; Vec2 _fullScreenSize;
// world boundaries // world boundaries
float _leftBoundary; float _leftBoundary;

View File

@ -60,12 +60,12 @@ ActionCamera * ActionCamera::reverse() const
void ActionCamera::restore() void ActionCamera::restore()
{ {
_center = Vector3(0, 0, 0); _center = Vec3(0, 0, 0);
_eye = Vector3(0, 0, FLT_EPSILON); _eye = Vec3(0, 0, FLT_EPSILON);
_up = Vector3(0, 1, 0); _up = Vec3(0, 1, 0);
} }
void ActionCamera::setEye(const Vector3& eye) void ActionCamera::setEye(const Vec3& eye)
{ {
_eye = eye; _eye = eye;
updateTransform(); updateTransform();
@ -73,17 +73,17 @@ void ActionCamera::setEye(const Vector3& eye)
void ActionCamera::setEye(float x, float y, float z) void ActionCamera::setEye(float x, float y, float z)
{ {
_eye = Vector3(x, y, z); _eye = Vec3(x, y, z);
updateTransform(); updateTransform();
} }
void ActionCamera::setCenter(const Vector3& center) void ActionCamera::setCenter(const Vec3& center)
{ {
_center = center; _center = center;
updateTransform(); updateTransform();
} }
void ActionCamera::setUp(const Vector3& up) void ActionCamera::setUp(const Vec3& up)
{ {
_up = up; _up = up;
updateTransform(); updateTransform();
@ -91,18 +91,18 @@ void ActionCamera::setUp(const Vector3& up)
void ActionCamera::updateTransform() void ActionCamera::updateTransform()
{ {
Matrix lookupMatrix; Mat4 lookupMatrix;
Matrix::createLookAt(_eye.x, _eye.y, _eye.z, _center.x, _center.y, _center.z, _up.x, _up.y, _up.z, &lookupMatrix); Mat4::createLookAt(_eye.x, _eye.y, _eye.z, _center.x, _center.y, _center.z, _up.x, _up.y, _up.z, &lookupMatrix);
Vector2 anchorPoint = _target->getAnchorPointInPoints(); Vec2 anchorPoint = _target->getAnchorPointInPoints();
bool needsTranslation = !anchorPoint.equals(Vector2::ZERO); bool needsTranslation = !anchorPoint.equals(Vec2::ZERO);
Matrix mv = Matrix::IDENTITY; Mat4 mv = Mat4::IDENTITY;
if(needsTranslation) { if(needsTranslation) {
Matrix t; Mat4 t;
Matrix::createTranslation(anchorPoint.x, anchorPoint.y, 0, &t); Mat4::createTranslation(anchorPoint.x, anchorPoint.y, 0, &t);
mv = mv * t; mv = mv * t;
} }
@ -110,8 +110,8 @@ void ActionCamera::updateTransform()
if(needsTranslation) { if(needsTranslation) {
Matrix t; Mat4 t;
Matrix::createTranslation(-anchorPoint.x, -anchorPoint.y, 0, &t); Mat4::createTranslation(-anchorPoint.x, -anchorPoint.y, 0, &t);
mv = mv * t; mv = mv * t;
} }

View File

@ -63,27 +63,27 @@ public:
virtual ActionCamera *clone() const override; virtual ActionCamera *clone() const override;
/* sets the Eye value of the Camera */ /* sets the Eye value of the Camera */
void setEye(const Vector3 &eye); void setEye(const Vec3 &eye);
void setEye(float x, float y, float z); void setEye(float x, float y, float z);
/* returns the Eye value of the Camera */ /* returns the Eye value of the Camera */
const Vector3& getEye() const { return _eye; } const Vec3& getEye() const { return _eye; }
/* sets the Center value of the Camera */ /* sets the Center value of the Camera */
void setCenter(const Vector3 &center); void setCenter(const Vec3 &center);
/* returns the Center value of the Camera */ /* returns the Center value of the Camera */
const Vector3& getCenter() const { return _center; } const Vec3& getCenter() const { return _center; }
/* sets the Up value of the Camera */ /* sets the Up value of the Camera */
void setUp(const Vector3 &up); void setUp(const Vec3 &up);
/* Returns the Up value of the Camera */ /* Returns the Up value of the Camera */
const Vector3& getUp() const { return _up; } const Vec3& getUp() const { return _up; }
protected: protected:
void restore(); void restore();
void updateTransform(); void updateTransform();
Vector3 _center; Vec3 _center;
Vector3 _eye; Vec3 _eye;
Vector3 _up; Vec3 _up;
}; };
/** /**

View File

@ -62,18 +62,18 @@ PointArray* PointArray::create(ssize_t capacity)
bool PointArray::initWithCapacity(ssize_t capacity) bool PointArray::initWithCapacity(ssize_t capacity)
{ {
_controlPoints = new vector<Vector2*>(); _controlPoints = new vector<Vec2*>();
return true; return true;
} }
PointArray* PointArray::clone() const PointArray* PointArray::clone() const
{ {
vector<Vector2*> *newArray = new vector<Vector2*>(); vector<Vec2*> *newArray = new vector<Vec2*>();
vector<Vector2*>::iterator iter; vector<Vec2*>::iterator iter;
for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter) for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter)
{ {
newArray->push_back(new Vector2((*iter)->x, (*iter)->y)); newArray->push_back(new Vec2((*iter)->x, (*iter)->y));
} }
PointArray *points = new PointArray(); PointArray *points = new PointArray();
@ -88,7 +88,7 @@ PointArray::~PointArray()
{ {
CCLOGINFO("deallocing PointArray: %p", this); CCLOGINFO("deallocing PointArray: %p", this);
vector<Vector2*>::iterator iter; vector<Vec2*>::iterator iter;
for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter) for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter)
{ {
delete *iter; delete *iter;
@ -98,17 +98,17 @@ PointArray::~PointArray()
PointArray::PointArray() :_controlPoints(nullptr){} PointArray::PointArray() :_controlPoints(nullptr){}
const std::vector<Vector2*>* PointArray::getControlPoints() const const std::vector<Vec2*>* PointArray::getControlPoints() const
{ {
return _controlPoints; return _controlPoints;
} }
void PointArray::setControlPoints(vector<Vector2*> *controlPoints) void PointArray::setControlPoints(vector<Vec2*> *controlPoints)
{ {
CCASSERT(controlPoints != nullptr, "control points should not be nullptr"); CCASSERT(controlPoints != nullptr, "control points should not be nullptr");
// delete old points // delete old points
vector<Vector2*>::iterator iter; vector<Vec2*>::iterator iter;
for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter) for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter)
{ {
delete *iter; delete *iter;
@ -118,35 +118,35 @@ void PointArray::setControlPoints(vector<Vector2*> *controlPoints)
_controlPoints = controlPoints; _controlPoints = controlPoints;
} }
void PointArray::addControlPoint(Vector2 controlPoint) void PointArray::addControlPoint(Vec2 controlPoint)
{ {
_controlPoints->push_back(new Vector2(controlPoint.x, controlPoint.y)); _controlPoints->push_back(new Vec2(controlPoint.x, controlPoint.y));
} }
void PointArray::insertControlPoint(Vector2 &controlPoint, ssize_t index) void PointArray::insertControlPoint(Vec2 &controlPoint, ssize_t index)
{ {
Vector2 *temp = new Vector2(controlPoint.x, controlPoint.y); Vec2 *temp = new Vec2(controlPoint.x, controlPoint.y);
_controlPoints->insert(_controlPoints->begin() + index, temp); _controlPoints->insert(_controlPoints->begin() + index, temp);
} }
Vector2 PointArray::getControlPointAtIndex(ssize_t index) Vec2 PointArray::getControlPointAtIndex(ssize_t index)
{ {
index = MIN(static_cast<ssize_t>(_controlPoints->size())-1, MAX(index, 0)); index = MIN(static_cast<ssize_t>(_controlPoints->size())-1, MAX(index, 0));
return *(_controlPoints->at(index)); return *(_controlPoints->at(index));
} }
void PointArray::replaceControlPoint(cocos2d::Vector2 &controlPoint, ssize_t index) void PointArray::replaceControlPoint(cocos2d::Vec2 &controlPoint, ssize_t index)
{ {
Vector2 *temp = _controlPoints->at(index); Vec2 *temp = _controlPoints->at(index);
temp->x = controlPoint.x; temp->x = controlPoint.x;
temp->y = controlPoint.y; temp->y = controlPoint.y;
} }
void PointArray::removeControlPointAtIndex(ssize_t index) void PointArray::removeControlPointAtIndex(ssize_t index)
{ {
vector<Vector2*>::iterator iter = _controlPoints->begin() + index; vector<Vec2*>::iterator iter = _controlPoints->begin() + index;
Vector2* removedPoint = *iter; Vec2* removedPoint = *iter;
_controlPoints->erase(iter); _controlPoints->erase(iter);
delete removedPoint; delete removedPoint;
} }
@ -158,13 +158,13 @@ ssize_t PointArray::count() const
PointArray* PointArray::reverse() const PointArray* PointArray::reverse() const
{ {
vector<Vector2*> *newArray = new vector<Vector2*>(); vector<Vec2*> *newArray = new vector<Vec2*>();
vector<Vector2*>::reverse_iterator iter; vector<Vec2*>::reverse_iterator iter;
Vector2 *point = nullptr; Vec2 *point = nullptr;
for (iter = _controlPoints->rbegin(); iter != _controlPoints->rend(); ++iter) for (iter = _controlPoints->rbegin(); iter != _controlPoints->rend(); ++iter)
{ {
point = *iter; point = *iter;
newArray->push_back(new Vector2(point->x, point->y)); newArray->push_back(new Vec2(point->x, point->y));
} }
PointArray *config = PointArray::create(0); PointArray *config = PointArray::create(0);
config->setControlPoints(newArray); config->setControlPoints(newArray);
@ -175,8 +175,8 @@ PointArray* PointArray::reverse() const
void PointArray::reverseInline() void PointArray::reverseInline()
{ {
size_t l = _controlPoints->size(); size_t l = _controlPoints->size();
Vector2 *p1 = nullptr; Vec2 *p1 = nullptr;
Vector2 *p2 = nullptr; Vec2 *p2 = nullptr;
float x, y; float x, y;
for (size_t i = 0; i < l/2; ++i) for (size_t i = 0; i < l/2; ++i)
{ {
@ -195,7 +195,7 @@ void PointArray::reverseInline()
} }
// CatmullRom Spline formula: // CatmullRom Spline formula:
Vector2 ccCardinalSplineAt(Vector2 &p0, Vector2 &p1, Vector2 &p2, Vector2 &p3, float tension, float t) Vec2 ccCardinalSplineAt(Vec2 &p0, Vec2 &p1, Vec2 &p2, Vec2 &p3, float tension, float t)
{ {
float t2 = t * t; float t2 = t * t;
float t3 = t2 * t; float t3 = t2 * t;
@ -213,7 +213,7 @@ Vector2 ccCardinalSplineAt(Vector2 &p0, Vector2 &p1, Vector2 &p2, Vector2 &p3, f
float x = (p0.x*b1 + p1.x*b2 + p2.x*b3 + p3.x*b4); float x = (p0.x*b1 + p1.x*b2 + p2.x*b3 + p3.x*b4);
float y = (p0.y*b1 + p1.y*b2 + p2.y*b3 + p3.y*b4); float y = (p0.y*b1 + p1.y*b2 + p2.y*b3 + p3.y*b4);
return Vector2(x,y); return Vec2(x,y);
} }
/* Implementation of CardinalSplineTo /* Implementation of CardinalSplineTo
@ -274,7 +274,7 @@ void CardinalSplineTo::startWithTarget(cocos2d::Node *target)
_deltaT = (float) 1 / (_points->count() - 1); _deltaT = (float) 1 / (_points->count() - 1);
_previousPosition = target->getPosition(); _previousPosition = target->getPosition();
_accumulatedDiff = Vector2::ZERO; _accumulatedDiff = Vec2::ZERO;
} }
CardinalSplineTo* CardinalSplineTo::clone() const CardinalSplineTo* CardinalSplineTo::clone() const
@ -307,17 +307,17 @@ void CardinalSplineTo::update(float time)
} }
// Interpolate // Interpolate
Vector2 pp0 = _points->getControlPointAtIndex(p-1); Vec2 pp0 = _points->getControlPointAtIndex(p-1);
Vector2 pp1 = _points->getControlPointAtIndex(p+0); Vec2 pp1 = _points->getControlPointAtIndex(p+0);
Vector2 pp2 = _points->getControlPointAtIndex(p+1); Vec2 pp2 = _points->getControlPointAtIndex(p+1);
Vector2 pp3 = _points->getControlPointAtIndex(p+2); Vec2 pp3 = _points->getControlPointAtIndex(p+2);
Vector2 newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, _tension, lt); Vec2 newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, _tension, lt);
#if CC_ENABLE_STACKABLE_ACTIONS #if CC_ENABLE_STACKABLE_ACTIONS
// Support for stacked actions // Support for stacked actions
Node *node = _target; Node *node = _target;
Vector2 diff = node->getPosition() - _previousPosition; Vec2 diff = node->getPosition() - _previousPosition;
if( diff.x !=0 || diff.y != 0 ) { if( diff.x !=0 || diff.y != 0 ) {
_accumulatedDiff = _accumulatedDiff + diff; _accumulatedDiff = _accumulatedDiff + diff;
newPos = newPos + _accumulatedDiff; newPos = newPos + _accumulatedDiff;
@ -327,7 +327,7 @@ void CardinalSplineTo::update(float time)
this->updatePosition(newPos); this->updatePosition(newPos);
} }
void CardinalSplineTo::updatePosition(cocos2d::Vector2 &newPos) void CardinalSplineTo::updatePosition(cocos2d::Vec2 &newPos)
{ {
_target->setPosition(newPos); _target->setPosition(newPos);
_previousPosition = newPos; _previousPosition = newPos;
@ -365,9 +365,9 @@ CardinalSplineBy::CardinalSplineBy() : _startPosition(0,0)
{ {
} }
void CardinalSplineBy::updatePosition(cocos2d::Vector2 &newPos) void CardinalSplineBy::updatePosition(cocos2d::Vec2 &newPos)
{ {
Vector2 p = newPos + _startPosition; Vec2 p = newPos + _startPosition;
_target->setPosition(p); _target->setPosition(p);
_previousPosition = p; _previousPosition = p;
} }
@ -379,11 +379,11 @@ CardinalSplineBy* CardinalSplineBy::reverse() const
// //
// convert "absolutes" to "diffs" // convert "absolutes" to "diffs"
// //
Vector2 p = copyConfig->getControlPointAtIndex(0); Vec2 p = copyConfig->getControlPointAtIndex(0);
for (ssize_t i = 1; i < copyConfig->count(); ++i) for (ssize_t i = 1; i < copyConfig->count(); ++i)
{ {
Vector2 current = copyConfig->getControlPointAtIndex(i); Vec2 current = copyConfig->getControlPointAtIndex(i);
Vector2 diff = current - p; Vec2 diff = current - p;
copyConfig->replaceControlPoint(diff, i); copyConfig->replaceControlPoint(diff, i);
p = current; p = current;
@ -404,9 +404,9 @@ CardinalSplineBy* CardinalSplineBy::reverse() const
for (ssize_t i = 1; i < pReverse->count(); ++i) for (ssize_t i = 1; i < pReverse->count(); ++i)
{ {
Vector2 current = pReverse->getControlPointAtIndex(i); Vec2 current = pReverse->getControlPointAtIndex(i);
current = -current; current = -current;
Vector2 abs = current + p; Vec2 abs = current + p;
pReverse->replaceControlPoint(abs, i); pReverse->replaceControlPoint(abs, i);
p = abs; p = abs;
@ -524,11 +524,11 @@ CatmullRomBy* CatmullRomBy::reverse() const
// //
// convert "absolutes" to "diffs" // convert "absolutes" to "diffs"
// //
Vector2 p = copyConfig->getControlPointAtIndex(0); Vec2 p = copyConfig->getControlPointAtIndex(0);
for (ssize_t i = 1; i < copyConfig->count(); ++i) for (ssize_t i = 1; i < copyConfig->count(); ++i)
{ {
Vector2 current = copyConfig->getControlPointAtIndex(i); Vec2 current = copyConfig->getControlPointAtIndex(i);
Vector2 diff = current - p; Vec2 diff = current - p;
copyConfig->replaceControlPoint(diff, i); copyConfig->replaceControlPoint(diff, i);
p = current; p = current;
@ -549,9 +549,9 @@ CatmullRomBy* CatmullRomBy::reverse() const
for (ssize_t i = 1; i < reverse->count(); ++i) for (ssize_t i = 1; i < reverse->count(); ++i)
{ {
Vector2 current = reverse->getControlPointAtIndex(i); Vec2 current = reverse->getControlPointAtIndex(i);
current = -current; current = -current;
Vector2 abs = current + p; Vec2 abs = current + p;
reverse->replaceControlPoint(abs, i); reverse->replaceControlPoint(abs, i);
p = abs; p = abs;

View File

@ -80,22 +80,22 @@ public:
/** appends a control point /** appends a control point
* @js NA * @js NA
*/ */
void addControlPoint(Vector2 controlPoint); void addControlPoint(Vec2 controlPoint);
/** inserts a controlPoint at index /** inserts a controlPoint at index
* @js NA * @js NA
*/ */
void insertControlPoint(Vector2 &controlPoint, ssize_t index); void insertControlPoint(Vec2 &controlPoint, ssize_t index);
/** replaces an existing controlPoint at index /** replaces an existing controlPoint at index
* @js NA * @js NA
*/ */
void replaceControlPoint(Vector2 &controlPoint, ssize_t index); void replaceControlPoint(Vec2 &controlPoint, ssize_t index);
/** get the value of a controlPoint at a given index /** get the value of a controlPoint at a given index
* @js NA * @js NA
*/ */
Vector2 getControlPointAtIndex(ssize_t index); Vec2 getControlPointAtIndex(ssize_t index);
/** deletes a control point at a given index /** deletes a control point at a given index
* @js NA * @js NA
@ -124,14 +124,14 @@ public:
/** /**
* @js NA * @js NA
*/ */
const std::vector<Vector2*>* getControlPoints() const; const std::vector<Vec2*>* getControlPoints() const;
/** /**
* @js NA * @js NA
*/ */
void setControlPoints(std::vector<Vector2*> *controlPoints); void setControlPoints(std::vector<Vec2*> *controlPoints);
private: private:
/** Array that contains the control points */ /** Array that contains the control points */
std::vector<Vector2*> *_controlPoints; std::vector<Vec2*> *_controlPoints;
}; };
/** Cardinal Spline path. /** Cardinal Spline path.
@ -164,7 +164,7 @@ public:
/** initializes the action with a duration and an array of points */ /** initializes the action with a duration and an array of points */
bool initWithDuration(float duration, PointArray* points, float tension); bool initWithDuration(float duration, PointArray* points, float tension);
virtual void updatePosition(Vector2 &newPos); virtual void updatePosition(Vec2 &newPos);
inline PointArray* getPoints() { return _points; } inline PointArray* getPoints() { return _points; }
/** /**
@ -189,8 +189,8 @@ protected:
PointArray *_points; PointArray *_points;
float _deltaT; float _deltaT;
float _tension; float _tension;
Vector2 _previousPosition; Vec2 _previousPosition;
Vector2 _accumulatedDiff; Vec2 _accumulatedDiff;
}; };
/** Cardinal Spline path. /** Cardinal Spline path.
@ -214,12 +214,12 @@ public:
// Overrides // Overrides
virtual void startWithTarget(Node *target) override; virtual void startWithTarget(Node *target) override;
virtual void updatePosition(Vector2 &newPos) override; virtual void updatePosition(Vec2 &newPos) override;
virtual CardinalSplineBy *clone() const override; virtual CardinalSplineBy *clone() const override;
virtual CardinalSplineBy* reverse() const override; virtual CardinalSplineBy* reverse() const override;
protected: protected:
Vector2 _startPosition; Vec2 _startPosition;
}; };
/** An action that moves the target with a CatmullRom curve to a destination point. /** An action that moves the target with a CatmullRom curve to a destination point.
@ -275,7 +275,7 @@ public:
}; };
/** Returns the Cardinal Spline position for a given set of control points, tension and time */ /** Returns the Cardinal Spline position for a given set of control points, tension and time */
extern CC_DLL Vector2 ccCardinalSplineAt(Vector2 &p0, Vector2 &p1, Vector2 &p2, Vector2 &p3, float tension, float t); extern CC_DLL Vec2 ccCardinalSplineAt(Vec2 &p0, Vec2 &p1, Vec2 &p2, Vec2 &p3, float tension, float t);
// end of actions group // end of actions group
/// @} /// @}

View File

@ -103,19 +103,19 @@ GridBase* Grid3DAction::getGrid()
return Grid3D::create(_gridSize); return Grid3D::create(_gridSize);
} }
Vector3 Grid3DAction::getVertex(const Vector2& position) const Vec3 Grid3DAction::getVertex(const Vec2& position) const
{ {
Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid(); Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid();
return g->getVertex(position); return g->getVertex(position);
} }
Vector3 Grid3DAction::getOriginalVertex(const Vector2& position) const Vec3 Grid3DAction::getOriginalVertex(const Vec2& position) const
{ {
Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid(); Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid();
return g->getOriginalVertex(position); return g->getOriginalVertex(position);
} }
void Grid3DAction::setVertex(const Vector2& position, const Vector3& vertex) void Grid3DAction::setVertex(const Vec2& position, const Vec3& vertex)
{ {
Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid(); Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid();
g->setVertex(position, vertex); g->setVertex(position, vertex);
@ -128,19 +128,19 @@ GridBase* TiledGrid3DAction::getGrid(void)
return TiledGrid3D::create(_gridSize); return TiledGrid3D::create(_gridSize);
} }
Quad3 TiledGrid3DAction::getTile(const Vector2& pos) const Quad3 TiledGrid3DAction::getTile(const Vec2& pos) const
{ {
TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid(); TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid();
return g->getTile(pos); return g->getTile(pos);
} }
Quad3 TiledGrid3DAction::getOriginalTile(const Vector2& pos) const Quad3 TiledGrid3DAction::getOriginalTile(const Vec2& pos) const
{ {
TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid(); TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid();
return g->getOriginalTile(pos); return g->getOriginalTile(pos);
} }
void TiledGrid3DAction::setTile(const Vector2& pos, const Quad3& coords) void TiledGrid3DAction::setTile(const Vec2& pos, const Quad3& coords)
{ {
TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid(); TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid();
return g->setTile(pos, coords); return g->setTile(pos, coords);

View File

@ -82,31 +82,31 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
Vector3 getVertex(const Vector2& position) const; Vec3 getVertex(const Vec2& position) const;
/** @deprecated Use getVertex() instead /** @deprecated Use getVertex() instead
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
CC_DEPRECATED_ATTRIBUTE inline Vector3 vertex(const Vector2& position) { return getVertex(position); } CC_DEPRECATED_ATTRIBUTE inline Vec3 vertex(const Vec2& position) { return getVertex(position); }
/** returns the non-transformed vertex than belongs to certain position in the grid /** returns the non-transformed vertex than belongs to certain position in the grid
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
Vector3 getOriginalVertex(const Vector2& position) const; Vec3 getOriginalVertex(const Vec2& position) const;
/** @deprecated Use getOriginalVertex() instead /** @deprecated Use getOriginalVertex() instead
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
CC_DEPRECATED_ATTRIBUTE inline Vector3 originalVertex(const Vector2& position) { return getOriginalVertex(position); } CC_DEPRECATED_ATTRIBUTE inline Vec3 originalVertex(const Vec2& position) { return getOriginalVertex(position); }
/** sets a new vertex to a certain position of the grid /** sets a new vertex to a certain position of the grid
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
void setVertex(const Vector2& position, const Vector3& vertex); void setVertex(const Vec2& position, const Vec3& vertex);
// Overrides // Overrides
virtual Grid3DAction * clone() const override = 0; virtual Grid3DAction * clone() const override = 0;
@ -126,31 +126,31 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
Quad3 getTile(const Vector2& position) const; Quad3 getTile(const Vec2& position) const;
/** @deprecated Use getTile() instead /** @deprecated Use getTile() instead
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Vector2& position) { return getTile(position); } CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Vec2& position) { return getTile(position); }
/** returns the non-transformed tile that belongs to a certain position of the grid /** returns the non-transformed tile that belongs to a certain position of the grid
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
Quad3 getOriginalTile(const Vector2& position) const; Quad3 getOriginalTile(const Vec2& position) const;
/** @deprecated Use getOriginalTile() instead /** @deprecated Use getOriginalTile() instead
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Vector2& position) { return getOriginalTile(position); } CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Vec2& position) { return getOriginalTile(position); }
/** sets a new tile to a certain position of the grid /** sets a new tile to a certain position of the grid
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
void setTile(const Vector2& position, const Quad3& coords); void setTile(const Vec2& position, const Quad3& coords);
/** returns the grid */ /** returns the grid */
virtual GridBase* getGrid(); virtual GridBase* getGrid();

View File

@ -79,10 +79,10 @@ void Waves3D::update(float time)
{ {
for (j = 0; j < _gridSize.height + 1; ++j) for (j = 0; j < _gridSize.height + 1; ++j)
{ {
Vector3 v = getOriginalVertex(Vector2(i ,j)); Vec3 v = getOriginalVertex(Vec2(i ,j));
v.z += (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * 0.01f) * _amplitude * _amplitudeRate); v.z += (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * 0.01f) * _amplitude * _amplitudeRate);
//CCLOG("v.z offset is %f\n", (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * .01f) * _amplitude * _amplitudeRate)); //CCLOG("v.z offset is %f\n", (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * .01f) * _amplitude * _amplitudeRate));
setVertex(Vector2(i, j), v); setVertex(Vec2(i, j), v);
} }
} }
} }
@ -142,32 +142,32 @@ void FlipX3D::update(float time)
angle = angle / 2.0f; // x calculates degrees from 0 to 90 angle = angle / 2.0f; // x calculates degrees from 0 to 90
float mx = cosf(angle); float mx = cosf(angle);
Vector3 v0, v1, v, diff; Vec3 v0, v1, v, diff;
v0 = getOriginalVertex(Vector2(1, 1)); v0 = getOriginalVertex(Vec2(1, 1));
v1 = getOriginalVertex(Vector2(0, 0)); v1 = getOriginalVertex(Vec2(0, 0));
float x0 = v0.x; float x0 = v0.x;
float x1 = v1.x; float x1 = v1.x;
float x; float x;
Vector2 a, b, c, d; Vec2 a, b, c, d;
if ( x0 > x1 ) if ( x0 > x1 )
{ {
// Normal Grid // Normal Grid
a = Vector2(0,0); a = Vec2(0,0);
b = Vector2(0,1); b = Vec2(0,1);
c = Vector2(1,0); c = Vec2(1,0);
d = Vector2(1,1); d = Vec2(1,1);
x = x0; x = x0;
} }
else else
{ {
// Reversed Grid // Reversed Grid
c = Vector2(0,0); c = Vec2(0,0);
d = Vector2(0,1); d = Vec2(0,1);
a = Vector2(1,0); a = Vec2(1,0);
b = Vector2(1,1); b = Vec2(1,1);
x = x1; x = x1;
} }
@ -236,32 +236,32 @@ void FlipY3D::update(float time)
angle = angle / 2.0f; // x calculates degrees from 0 to 90 angle = angle / 2.0f; // x calculates degrees from 0 to 90
float my = cosf(angle); float my = cosf(angle);
Vector3 v0, v1, v, diff; Vec3 v0, v1, v, diff;
v0 = getOriginalVertex(Vector2(1, 1)); v0 = getOriginalVertex(Vec2(1, 1));
v1 = getOriginalVertex(Vector2(0, 0)); v1 = getOriginalVertex(Vec2(0, 0));
float y0 = v0.y; float y0 = v0.y;
float y1 = v1.y; float y1 = v1.y;
float y; float y;
Vector2 a, b, c, d; Vec2 a, b, c, d;
if (y0 > y1) if (y0 > y1)
{ {
// Normal Grid // Normal Grid
a = Vector2(0,0); a = Vec2(0,0);
b = Vector2(0,1); b = Vec2(0,1);
c = Vector2(1,0); c = Vec2(1,0);
d = Vector2(1,1); d = Vec2(1,1);
y = y0; y = y0;
} }
else else
{ {
// Reversed Grid // Reversed Grid
b = Vector2(0,0); b = Vec2(0,0);
a = Vector2(0,1); a = Vec2(0,1);
d = Vector2(1,0); d = Vec2(1,0);
c = Vector2(1,1); c = Vec2(1,1);
y = y1; y = y1;
} }
@ -296,7 +296,7 @@ void FlipY3D::update(float time)
// implementation of Lens3D // implementation of Lens3D
Lens3D* Lens3D::create(float duration, const Size& gridSize, const Vector2& position, float radius) Lens3D* Lens3D::create(float duration, const Size& gridSize, const Vec2& position, float radius)
{ {
Lens3D *action = new Lens3D(); Lens3D *action = new Lens3D();
@ -315,11 +315,11 @@ Lens3D* Lens3D::create(float duration, const Size& gridSize, const Vector2& posi
return action; return action;
} }
bool Lens3D::initWithDuration(float duration, const Size& gridSize, const Vector2& position, float radius) bool Lens3D::initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius)
{ {
if (Grid3DAction::initWithDuration(duration, gridSize)) if (Grid3DAction::initWithDuration(duration, gridSize))
{ {
_position = Vector2(-1, -1); _position = Vec2(-1, -1);
setPosition(position); setPosition(position);
_radius = radius; _radius = radius;
_lensEffect = 0.7f; _lensEffect = 0.7f;
@ -341,7 +341,7 @@ Lens3D* Lens3D::clone() const
return a; return a;
} }
void Lens3D::setPosition(const Vector2& pos) void Lens3D::setPosition(const Vec2& pos)
{ {
if( !pos.equals(_position)) if( !pos.equals(_position))
{ {
@ -361,8 +361,8 @@ void Lens3D::update(float time)
{ {
for (j = 0; j < _gridSize.height + 1; ++j) for (j = 0; j < _gridSize.height + 1; ++j)
{ {
Vector3 v = getOriginalVertex(Vector2(i, j)); Vec3 v = getOriginalVertex(Vec2(i, j));
Vector2 vect = _position - Vector2(v.x, v.y); Vec2 vect = _position - Vec2(v.x, v.y);
float r = vect.getLength(); float r = vect.getLength();
if (r < _radius) if (r < _radius)
@ -380,12 +380,12 @@ void Lens3D::update(float time)
if (vect.getLength() > 0) if (vect.getLength() > 0)
{ {
vect.normalize(); vect.normalize();
Vector2 new_vect = vect * new_r; Vec2 new_vect = vect * new_r;
v.z += (_concave ? -1.0f : 1.0f) * new_vect.getLength() * _lensEffect; v.z += (_concave ? -1.0f : 1.0f) * new_vect.getLength() * _lensEffect;
} }
} }
setVertex(Vector2(i, j), v); setVertex(Vec2(i, j), v);
} }
} }
@ -395,7 +395,7 @@ void Lens3D::update(float time)
// implementation of Ripple3D // implementation of Ripple3D
Ripple3D* Ripple3D::create(float duration, const Size& gridSize, const Vector2& position, float radius, unsigned int waves, float amplitude) Ripple3D* Ripple3D::create(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude)
{ {
Ripple3D *action = new Ripple3D(); Ripple3D *action = new Ripple3D();
@ -414,7 +414,7 @@ Ripple3D* Ripple3D::create(float duration, const Size& gridSize, const Vector2&
return action; return action;
} }
bool Ripple3D::initWithDuration(float duration, const Size& gridSize, const Vector2& position, float radius, unsigned int waves, float amplitude) bool Ripple3D::initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude)
{ {
if (Grid3DAction::initWithDuration(duration, gridSize)) if (Grid3DAction::initWithDuration(duration, gridSize))
{ {
@ -430,7 +430,7 @@ bool Ripple3D::initWithDuration(float duration, const Size& gridSize, const Vect
return false; return false;
} }
void Ripple3D::setPosition(const Vector2& position) void Ripple3D::setPosition(const Vec2& position)
{ {
_position = position; _position = position;
} }
@ -453,8 +453,8 @@ void Ripple3D::update(float time)
{ {
for (j = 0; j < (_gridSize.height+1); ++j) for (j = 0; j < (_gridSize.height+1); ++j)
{ {
Vector3 v = getOriginalVertex(Vector2(i, j)); Vec3 v = getOriginalVertex(Vec2(i, j));
Vector2 vect = _position - Vector2(v.x,v.y); Vec2 vect = _position - Vec2(v.x,v.y);
float r = vect.getLength(); float r = vect.getLength();
if (r < _radius) if (r < _radius)
@ -464,7 +464,7 @@ void Ripple3D::update(float time)
v.z += (sinf( time*(float)M_PI * _waves * 2 + r * 0.1f) * _amplitude * _amplitudeRate * rate); v.z += (sinf( time*(float)M_PI * _waves * 2 + r * 0.1f) * _amplitude * _amplitudeRate * rate);
} }
setVertex(Vector2(i, j), v); setVertex(Vec2(i, j), v);
} }
} }
} }
@ -521,7 +521,7 @@ void Shaky3D::update(float time)
{ {
for (j = 0; j < (_gridSize.height+1); ++j) for (j = 0; j < (_gridSize.height+1); ++j)
{ {
Vector3 v = getOriginalVertex(Vector2(i ,j)); Vec3 v = getOriginalVertex(Vec2(i ,j));
v.x += (rand() % (_randrange*2)) - _randrange; v.x += (rand() % (_randrange*2)) - _randrange;
v.y += (rand() % (_randrange*2)) - _randrange; v.y += (rand() % (_randrange*2)) - _randrange;
if (_shakeZ) if (_shakeZ)
@ -529,7 +529,7 @@ void Shaky3D::update(float time)
v.z += (rand() % (_randrange*2)) - _randrange; v.z += (rand() % (_randrange*2)) - _randrange;
} }
setVertex(Vector2(i, j), v); setVertex(Vec2(i, j), v);
} }
} }
} }
@ -586,10 +586,10 @@ void Liquid::update(float time)
{ {
for (j = 1; j < _gridSize.height; ++j) for (j = 1; j < _gridSize.height; ++j)
{ {
Vector3 v = getOriginalVertex(Vector2(i, j)); Vec3 v = getOriginalVertex(Vec2(i, j));
v.x = (v.x + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate)); v.x = (v.x + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate));
v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.y * .01f) * _amplitude * _amplitudeRate)); v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.y * .01f) * _amplitude * _amplitudeRate));
setVertex(Vector2(i, j), v); setVertex(Vec2(i, j), v);
} }
} }
} }
@ -648,7 +648,7 @@ void Waves::update(float time)
{ {
for (j = 0; j < _gridSize.height + 1; ++j) for (j = 0; j < _gridSize.height + 1; ++j)
{ {
Vector3 v = getOriginalVertex(Vector2(i, j)); Vec3 v = getOriginalVertex(Vec2(i, j));
if (_vertical) if (_vertical)
{ {
@ -660,14 +660,14 @@ void Waves::update(float time)
v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate)); v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate));
} }
setVertex(Vector2(i, j), v); setVertex(Vec2(i, j), v);
} }
} }
} }
// implementation of Twirl // implementation of Twirl
Twirl* Twirl::create(float duration, const Size& gridSize, Vector2 position, unsigned int twirls, float amplitude) Twirl* Twirl::create(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude)
{ {
Twirl *action = new Twirl(); Twirl *action = new Twirl();
@ -686,7 +686,7 @@ Twirl* Twirl::create(float duration, const Size& gridSize, Vector2 position, uns
return action; return action;
} }
bool Twirl::initWithDuration(float duration, const Size& gridSize, Vector2 position, unsigned int twirls, float amplitude) bool Twirl::initWithDuration(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude)
{ {
if (Grid3DAction::initWithDuration(duration, gridSize)) if (Grid3DAction::initWithDuration(duration, gridSize))
{ {
@ -701,7 +701,7 @@ bool Twirl::initWithDuration(float duration, const Size& gridSize, Vector2 posit
return false; return false;
} }
void Twirl::setPosition(const Vector2& position) void Twirl::setPosition(const Vec2& position)
{ {
_position = position; _position = position;
} }
@ -718,28 +718,28 @@ Twirl *Twirl::clone() const
void Twirl::update(float time) void Twirl::update(float time)
{ {
int i, j; int i, j;
Vector2 c = _position; Vec2 c = _position;
for (i = 0; i < (_gridSize.width+1); ++i) for (i = 0; i < (_gridSize.width+1); ++i)
{ {
for (j = 0; j < (_gridSize.height+1); ++j) for (j = 0; j < (_gridSize.height+1); ++j)
{ {
Vector3 v = getOriginalVertex(Vector2(i ,j)); Vec3 v = getOriginalVertex(Vec2(i ,j));
Vector2 avg = Vector2(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f)); Vec2 avg = Vec2(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f));
float r = avg.getLength(); float r = avg.getLength();
float amp = 0.1f * _amplitude * _amplitudeRate; float amp = 0.1f * _amplitude * _amplitudeRate;
float a = r * cosf( (float)M_PI/2.0f + time * (float)M_PI * _twirls * 2 ) * amp; float a = r * cosf( (float)M_PI/2.0f + time * (float)M_PI * _twirls * 2 ) * amp;
Vector2 d = Vector2( Vec2 d = Vec2(
sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x), sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x),
cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x)); cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x));
v.x = c.x + d.x; v.x = c.x + d.x;
v.y = c.y + d.y; v.y = c.y + d.y;
setVertex(Vector2(i ,j), v); setVertex(Vec2(i ,j), v);
} }
} }
} }

View File

@ -120,7 +120,7 @@ class CC_DLL Lens3D : public Grid3DAction
{ {
public: public:
/** creates the action with center position, radius, a grid size and duration */ /** creates the action with center position, radius, a grid size and duration */
static Lens3D* create(float duration, const Size& gridSize, const Vector2& position, float radius); static Lens3D* create(float duration, const Size& gridSize, const Vec2& position, float radius);
/** Get lens center position */ /** Get lens center position */
inline float getLensEffect() const { return _lensEffect; } inline float getLensEffect() const { return _lensEffect; }
@ -129,8 +129,8 @@ public:
/** Set whether lens is concave */ /** Set whether lens is concave */
inline void setConcave(bool concave) { _concave = concave; } inline void setConcave(bool concave) { _concave = concave; }
inline const Vector2& getPosition() const { return _position; } inline const Vec2& getPosition() const { return _position; }
void setPosition(const Vector2& position); void setPosition(const Vec2& position);
// Overrides // Overrides
virtual Lens3D* clone() const override; virtual Lens3D* clone() const override;
@ -141,11 +141,11 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~Lens3D() {} virtual ~Lens3D() {}
/** initializes the action with center position, radius, a grid size and duration */ /** initializes the action with center position, radius, a grid size and duration */
bool initWithDuration(float duration, const Size& gridSize, const Vector2& position, float radius); bool initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius);
protected: protected:
/* lens center position */ /* lens center position */
Vector2 _position; Vec2 _position;
float _radius; float _radius;
/** lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect */ /** lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect */
float _lensEffect; float _lensEffect;
@ -163,12 +163,12 @@ class CC_DLL Ripple3D : public Grid3DAction
{ {
public: public:
/** creates the action with radius, number of waves, amplitude, a grid size and duration */ /** creates the action with radius, number of waves, amplitude, a grid size and duration */
static Ripple3D* create(float duration, const Size& gridSize, const Vector2& position, float radius, unsigned int waves, float amplitude); static Ripple3D* create(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude);
/** get center position */ /** get center position */
inline const Vector2& getPosition() const { return _position; } inline const Vec2& getPosition() const { return _position; }
/** set center position */ /** set center position */
void setPosition(const Vector2& position); void setPosition(const Vec2& position);
inline float getAmplitude() const { return _amplitude; } inline float getAmplitude() const { return _amplitude; }
inline void setAmplitude(float fAmplitude) { _amplitude = fAmplitude; } inline void setAmplitude(float fAmplitude) { _amplitude = fAmplitude; }
@ -185,11 +185,11 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~Ripple3D() {} virtual ~Ripple3D() {}
/** initializes the action with radius, number of waves, amplitude, a grid size and duration */ /** initializes the action with radius, number of waves, amplitude, a grid size and duration */
bool initWithDuration(float duration, const Size& gridSize, const Vector2& position, float radius, unsigned int waves, float amplitude); bool initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude);
protected: protected:
/* center position */ /* center position */
Vector2 _position; Vec2 _position;
float _radius; float _radius;
unsigned int _waves; unsigned int _waves;
float _amplitude; float _amplitude;
@ -298,12 +298,12 @@ class CC_DLL Twirl : public Grid3DAction
{ {
public: public:
/** creates the action with center position, number of twirls, amplitude, a grid size and duration */ /** creates the action with center position, number of twirls, amplitude, a grid size and duration */
static Twirl* create(float duration, const Size& gridSize, Vector2 position, unsigned int twirls, float amplitude); static Twirl* create(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude);
/** get twirl center */ /** get twirl center */
inline const Vector2& getPosition() const { return _position; } inline const Vec2& getPosition() const { return _position; }
/** set twirl center */ /** set twirl center */
void setPosition(const Vector2& position); void setPosition(const Vec2& position);
inline float getAmplitude() const { return _amplitude; } inline float getAmplitude() const { return _amplitude; }
inline void setAmplitude(float amplitude) { _amplitude = amplitude; } inline void setAmplitude(float amplitude) { _amplitude = amplitude; }
@ -321,11 +321,11 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~Twirl() {} virtual ~Twirl() {}
/** initializes the action with center position, number of twirls, amplitude, a grid size and duration */ /** initializes the action with center position, number of twirls, amplitude, a grid size and duration */
bool initWithDuration(float duration, const Size& gridSize, Vector2 position, unsigned int twirls, float amplitude); bool initWithDuration(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude);
protected: protected:
/* twirl center */ /* twirl center */
Vector2 _position; Vec2 _position;
unsigned int _twirls; unsigned int _twirls;
float _amplitude; float _amplitude;
float _amplitudeRate; float _amplitudeRate;

View File

@ -278,7 +278,7 @@ FlipY * FlipY::clone() const
// Place // Place
// //
Place* Place::create(const Vector2& pos) Place* Place::create(const Vec2& pos)
{ {
Place *ret = new Place(); Place *ret = new Place();
@ -291,7 +291,7 @@ Place* Place::create(const Vector2& pos)
return nullptr; return nullptr;
} }
bool Place::initWithPosition(const Vector2& pos) { bool Place::initWithPosition(const Vec2& pos) {
_position = pos; _position = pos;
return true; return true;
} }

View File

@ -228,7 +228,7 @@ class CC_DLL Place : public ActionInstant //<NSCopying>
public: public:
/** creates a Place action with a position */ /** creates a Place action with a position */
static Place * create(const Vector2& pos); static Place * create(const Vec2& pos);
// //
// Overrides // Overrides
@ -242,10 +242,10 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~Place(){} virtual ~Place(){}
/** Initializes a Place action with a position */ /** Initializes a Place action with a position */
bool initWithPosition(const Vector2& pos); bool initWithPosition(const Vec2& pos);
protected: protected:
Vector2 _position; Vec2 _position;
private: private:
CC_DISALLOW_COPY_AND_ASSIGN(Place); CC_DISALLOW_COPY_AND_ASSIGN(Place);

View File

@ -859,7 +859,7 @@ RotateBy* RotateBy::create(float duration, float deltaAngleX, float deltaAngleY)
return rotateBy; return rotateBy;
} }
RotateBy* RotateBy::create(float duration, const Vector3& deltaAngle3D) RotateBy* RotateBy::create(float duration, const Vec3& deltaAngle3D)
{ {
RotateBy *rotateBy = new RotateBy(); RotateBy *rotateBy = new RotateBy();
rotateBy->initWithDuration(duration, deltaAngle3D); rotateBy->initWithDuration(duration, deltaAngle3D);
@ -896,7 +896,7 @@ bool RotateBy::initWithDuration(float duration, float deltaAngleX, float deltaAn
return false; return false;
} }
bool RotateBy::initWithDuration(float duration, const Vector3& deltaAngle3D) bool RotateBy::initWithDuration(float duration, const Vec3& deltaAngle3D)
{ {
if (ActionInterval::initWithDuration(duration)) if (ActionInterval::initWithDuration(duration))
{ {
@ -942,7 +942,7 @@ void RotateBy::update(float time)
{ {
if(_is3D) if(_is3D)
{ {
Vector3 v; Vec3 v;
v.x = _startAngle3D.x + _angle3D.x * time; v.x = _startAngle3D.x + _angle3D.x * time;
v.y = _startAngle3D.y + _angle3D.y * time; v.y = _startAngle3D.y + _angle3D.y * time;
v.z = _startAngle3D.z + _angle3D.z * time; v.z = _startAngle3D.z + _angle3D.z * time;
@ -960,7 +960,7 @@ RotateBy* RotateBy::reverse() const
{ {
if(_is3D) if(_is3D)
{ {
Vector3 v; Vec3 v;
v.x = - _angle3D.x; v.x = - _angle3D.x;
v.y = - _angle3D.y; v.y = - _angle3D.y;
v.z = - _angle3D.z; v.z = - _angle3D.z;
@ -973,7 +973,7 @@ RotateBy* RotateBy::reverse() const
// MoveBy // MoveBy
// //
MoveBy* MoveBy::create(float duration, const Vector2& deltaPosition) MoveBy* MoveBy::create(float duration, const Vec2& deltaPosition)
{ {
MoveBy *ret = new MoveBy(); MoveBy *ret = new MoveBy();
ret->initWithDuration(duration, deltaPosition); ret->initWithDuration(duration, deltaPosition);
@ -982,7 +982,7 @@ MoveBy* MoveBy::create(float duration, const Vector2& deltaPosition)
return ret; return ret;
} }
bool MoveBy::initWithDuration(float duration, const Vector2& deltaPosition) bool MoveBy::initWithDuration(float duration, const Vec2& deltaPosition)
{ {
if (ActionInterval::initWithDuration(duration)) if (ActionInterval::initWithDuration(duration))
{ {
@ -1010,7 +1010,7 @@ void MoveBy::startWithTarget(Node *target)
MoveBy* MoveBy::reverse() const MoveBy* MoveBy::reverse() const
{ {
return MoveBy::create(_duration, Vector2( -_positionDelta.x, -_positionDelta.y)); return MoveBy::create(_duration, Vec2( -_positionDelta.x, -_positionDelta.y));
} }
@ -1019,10 +1019,10 @@ void MoveBy::update(float t)
if (_target) if (_target)
{ {
#if CC_ENABLE_STACKABLE_ACTIONS #if CC_ENABLE_STACKABLE_ACTIONS
Vector2 currentPos = _target->getPosition(); Vec2 currentPos = _target->getPosition();
Vector2 diff = currentPos - _previousPosition; Vec2 diff = currentPos - _previousPosition;
_startPosition = _startPosition + diff; _startPosition = _startPosition + diff;
Vector2 newPos = _startPosition + (_positionDelta * t); Vec2 newPos = _startPosition + (_positionDelta * t);
_target->setPosition(newPos); _target->setPosition(newPos);
_previousPosition = newPos; _previousPosition = newPos;
#else #else
@ -1035,7 +1035,7 @@ void MoveBy::update(float t)
// MoveTo // MoveTo
// //
MoveTo* MoveTo::create(float duration, const Vector2& position) MoveTo* MoveTo::create(float duration, const Vec2& position)
{ {
MoveTo *ret = new MoveTo(); MoveTo *ret = new MoveTo();
ret->initWithDuration(duration, position); ret->initWithDuration(duration, position);
@ -1044,7 +1044,7 @@ MoveTo* MoveTo::create(float duration, const Vector2& position)
return ret; return ret;
} }
bool MoveTo::initWithDuration(float duration, const Vector2& position) bool MoveTo::initWithDuration(float duration, const Vec2& position)
{ {
if (ActionInterval::initWithDuration(duration)) if (ActionInterval::initWithDuration(duration))
{ {
@ -1252,7 +1252,7 @@ SkewBy* SkewBy::reverse() const
// JumpBy // JumpBy
// //
JumpBy* JumpBy::create(float duration, const Vector2& position, float height, int jumps) JumpBy* JumpBy::create(float duration, const Vec2& position, float height, int jumps)
{ {
JumpBy *jumpBy = new JumpBy(); JumpBy *jumpBy = new JumpBy();
jumpBy->initWithDuration(duration, position, height, jumps); jumpBy->initWithDuration(duration, position, height, jumps);
@ -1261,7 +1261,7 @@ JumpBy* JumpBy::create(float duration, const Vector2& position, float height, in
return jumpBy; return jumpBy;
} }
bool JumpBy::initWithDuration(float duration, const Vector2& position, float height, int jumps) bool JumpBy::initWithDuration(float duration, const Vec2& position, float height, int jumps)
{ {
CCASSERT(jumps>=0, "Number of jumps must be >= 0"); CCASSERT(jumps>=0, "Number of jumps must be >= 0");
@ -1303,24 +1303,24 @@ void JumpBy::update(float t)
float x = _delta.x * t; float x = _delta.x * t;
#if CC_ENABLE_STACKABLE_ACTIONS #if CC_ENABLE_STACKABLE_ACTIONS
Vector2 currentPos = _target->getPosition(); Vec2 currentPos = _target->getPosition();
Vector2 diff = currentPos - _previousPos; Vec2 diff = currentPos - _previousPos;
_startPosition = diff + _startPosition; _startPosition = diff + _startPosition;
Vector2 newPos = _startPosition + Vector2(x,y); Vec2 newPos = _startPosition + Vec2(x,y);
_target->setPosition(newPos); _target->setPosition(newPos);
_previousPos = newPos; _previousPos = newPos;
#else #else
_target->setPosition(_startPosition + Vector2(x,y)); _target->setPosition(_startPosition + Vec2(x,y));
#endif // !CC_ENABLE_STACKABLE_ACTIONS #endif // !CC_ENABLE_STACKABLE_ACTIONS
} }
} }
JumpBy* JumpBy::reverse() const JumpBy* JumpBy::reverse() const
{ {
return JumpBy::create(_duration, Vector2(-_delta.x, -_delta.y), return JumpBy::create(_duration, Vec2(-_delta.x, -_delta.y),
_height, _jumps); _height, _jumps);
} }
@ -1328,7 +1328,7 @@ JumpBy* JumpBy::reverse() const
// JumpTo // JumpTo
// //
JumpTo* JumpTo::create(float duration, const Vector2& position, float height, int jumps) JumpTo* JumpTo::create(float duration, const Vec2& position, float height, int jumps)
{ {
JumpTo *jumpTo = new JumpTo(); JumpTo *jumpTo = new JumpTo();
jumpTo->initWithDuration(duration, position, height, jumps); jumpTo->initWithDuration(duration, position, height, jumps);
@ -1355,7 +1355,7 @@ JumpTo* JumpTo::reverse() const
void JumpTo::startWithTarget(Node *target) void JumpTo::startWithTarget(Node *target)
{ {
JumpBy::startWithTarget(target); JumpBy::startWithTarget(target);
_delta = Vector2(_delta.x - _startPosition.x, _delta.y - _startPosition.y); _delta = Vec2(_delta.x - _startPosition.x, _delta.y - _startPosition.y);
} }
// Bezier cubic formula: // Bezier cubic formula:
@ -1427,16 +1427,16 @@ void BezierBy::update(float time)
float y = bezierat(ya, yb, yc, yd, time); float y = bezierat(ya, yb, yc, yd, time);
#if CC_ENABLE_STACKABLE_ACTIONS #if CC_ENABLE_STACKABLE_ACTIONS
Vector2 currentPos = _target->getPosition(); Vec2 currentPos = _target->getPosition();
Vector2 diff = currentPos - _previousPosition; Vec2 diff = currentPos - _previousPosition;
_startPosition = _startPosition + diff; _startPosition = _startPosition + diff;
Vector2 newPos = _startPosition + Vector2(x,y); Vec2 newPos = _startPosition + Vec2(x,y);
_target->setPosition(newPos); _target->setPosition(newPos);
_previousPosition = newPos; _previousPosition = newPos;
#else #else
_target->setPosition( _startPosition + Vector2(x,y)); _target->setPosition( _startPosition + Vec2(x,y));
#endif // !CC_ENABLE_STACKABLE_ACTIONS #endif // !CC_ENABLE_STACKABLE_ACTIONS
} }
} }

View File

@ -370,7 +370,7 @@ public:
/** creates the action */ /** creates the action */
static RotateBy* create(float duration, float deltaAngle); static RotateBy* create(float duration, float deltaAngle);
static RotateBy* create(float duration, float deltaAngleZ_X, float deltaAngleZ_Y); static RotateBy* create(float duration, float deltaAngleZ_X, float deltaAngleZ_Y);
static RotateBy* create(float duration, const Vector3& deltaAngle3D); static RotateBy* create(float duration, const Vec3& deltaAngle3D);
// //
// Override // Override
@ -387,7 +387,7 @@ CC_CONSTRUCTOR_ACCESS:
/** initializes the action */ /** initializes the action */
bool initWithDuration(float duration, float deltaAngle); bool initWithDuration(float duration, float deltaAngle);
bool initWithDuration(float duration, float deltaAngleZ_X, float deltaAngleZ_Y); bool initWithDuration(float duration, float deltaAngleZ_X, float deltaAngleZ_Y);
bool initWithDuration(float duration, const Vector3& deltaAngle3D); bool initWithDuration(float duration, const Vec3& deltaAngle3D);
protected: protected:
float _angleZ_X; float _angleZ_X;
@ -396,8 +396,8 @@ protected:
float _startAngleZ_Y; float _startAngleZ_Y;
bool _is3D; bool _is3D;
Vector3 _angle3D; Vec3 _angle3D;
Vector3 _startAngle3D; Vec3 _startAngle3D;
private: private:
CC_DISALLOW_COPY_AND_ASSIGN(RotateBy); CC_DISALLOW_COPY_AND_ASSIGN(RotateBy);
@ -413,7 +413,7 @@ class CC_DLL MoveBy : public ActionInterval
{ {
public: public:
/** creates the action */ /** creates the action */
static MoveBy* create(float duration, const Vector2& deltaPosition); static MoveBy* create(float duration, const Vec2& deltaPosition);
// //
// Overrides // Overrides
@ -428,12 +428,12 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~MoveBy() {} virtual ~MoveBy() {}
/** initializes the action */ /** initializes the action */
bool initWithDuration(float duration, const Vector2& deltaPosition); bool initWithDuration(float duration, const Vec2& deltaPosition);
protected: protected:
Vector2 _positionDelta; Vec2 _positionDelta;
Vector2 _startPosition; Vec2 _startPosition;
Vector2 _previousPosition; Vec2 _previousPosition;
private: private:
CC_DISALLOW_COPY_AND_ASSIGN(MoveBy); CC_DISALLOW_COPY_AND_ASSIGN(MoveBy);
@ -448,7 +448,7 @@ class CC_DLL MoveTo : public MoveBy
{ {
public: public:
/** creates the action */ /** creates the action */
static MoveTo* create(float duration, const Vector2& position); static MoveTo* create(float duration, const Vec2& position);
// //
// Overrides // Overrides
@ -461,10 +461,10 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~MoveTo() {} virtual ~MoveTo() {}
/** initializes the action */ /** initializes the action */
bool initWithDuration(float duration, const Vector2& position); bool initWithDuration(float duration, const Vec2& position);
protected: protected:
Vector2 _endPosition; Vec2 _endPosition;
private: private:
CC_DISALLOW_COPY_AND_ASSIGN(MoveTo); CC_DISALLOW_COPY_AND_ASSIGN(MoveTo);
@ -539,7 +539,7 @@ class CC_DLL JumpBy : public ActionInterval
{ {
public: public:
/** creates the action */ /** creates the action */
static JumpBy* create(float duration, const Vector2& position, float height, int jumps); static JumpBy* create(float duration, const Vec2& position, float height, int jumps);
// //
// Overrides // Overrides
@ -554,14 +554,14 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~JumpBy() {} virtual ~JumpBy() {}
/** initializes the action */ /** initializes the action */
bool initWithDuration(float duration, const Vector2& position, float height, int jumps); bool initWithDuration(float duration, const Vec2& position, float height, int jumps);
protected: protected:
Vector2 _startPosition; Vec2 _startPosition;
Vector2 _delta; Vec2 _delta;
float _height; float _height;
int _jumps; int _jumps;
Vector2 _previousPos; Vec2 _previousPos;
private: private:
CC_DISALLOW_COPY_AND_ASSIGN(JumpBy); CC_DISALLOW_COPY_AND_ASSIGN(JumpBy);
@ -573,7 +573,7 @@ class CC_DLL JumpTo : public JumpBy
{ {
public: public:
/** creates the action */ /** creates the action */
static JumpTo* create(float duration, const Vector2& position, float height, int jumps); static JumpTo* create(float duration, const Vec2& position, float height, int jumps);
// //
// Override // Override
@ -592,11 +592,11 @@ private:
*/ */
typedef struct _ccBezierConfig { typedef struct _ccBezierConfig {
//! end position of the bezier //! end position of the bezier
Vector2 endPosition; Vec2 endPosition;
//! Bezier control point 1 //! Bezier control point 1
Vector2 controlPoint_1; Vec2 controlPoint_1;
//! Bezier control point 2 //! Bezier control point 2
Vector2 controlPoint_2; Vec2 controlPoint_2;
} ccBezierConfig; } ccBezierConfig;
/** @brief An action that moves the target with a cubic Bezier curve by a certain distance. /** @brief An action that moves the target with a cubic Bezier curve by a certain distance.
@ -630,8 +630,8 @@ CC_CONSTRUCTOR_ACCESS:
protected: protected:
ccBezierConfig _config; ccBezierConfig _config;
Vector2 _startPosition; Vec2 _startPosition;
Vector2 _previousPosition; Vec2 _previousPosition;
private: private:
CC_DISALLOW_COPY_AND_ASSIGN(BezierBy); CC_DISALLOW_COPY_AND_ASSIGN(BezierBy);

View File

@ -76,7 +76,7 @@ void PageTurn3D::update(float time)
for (int j = 0; j <= _gridSize.height; ++j) for (int j = 0; j <= _gridSize.height; ++j)
{ {
// Get original vertex // Get original vertex
Vector3 p = getOriginalVertex(Vector2(i ,j)); Vec3 p = getOriginalVertex(Vec2(i ,j));
float R = sqrtf((p.x * p.x) + ((p.y - ay) * (p.y - ay))); float R = sqrtf((p.x * p.x) + ((p.y - ay) * (p.y - ay)));
float r = R * sinTheta; float r = R * sinTheta;
@ -111,7 +111,7 @@ void PageTurn3D::update(float time)
} }
// Set new coords // Set new coords
setVertex(Vector2(i, j), p); setVertex(Vec2(i, j), p);
} }
} }

View File

@ -34,8 +34,8 @@ NS_CC_BEGIN
struct Tile struct Tile
{ {
Vector2 position; Vec2 position;
Vector2 startPosition; Vec2 startPosition;
Size delta; Size delta;
}; };
@ -91,7 +91,7 @@ void ShakyTiles3D::update(float time)
{ {
for (j = 0; j < _gridSize.height; ++j) for (j = 0; j < _gridSize.height; ++j)
{ {
Quad3 coords = getOriginalTile(Vector2(i, j)); Quad3 coords = getOriginalTile(Vec2(i, j));
// X // X
coords.bl.x += ( rand() % (_randrange*2) ) - _randrange; coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
@ -113,7 +113,7 @@ void ShakyTiles3D::update(float time)
coords.tr.z += ( rand() % (_randrange*2) ) - _randrange; coords.tr.z += ( rand() % (_randrange*2) ) - _randrange;
} }
setTile(Vector2(i, j), coords); setTile(Vec2(i, j), coords);
} }
} }
} }
@ -173,7 +173,7 @@ void ShatteredTiles3D::update(float time)
{ {
for (j = 0; j < _gridSize.height; ++j) for (j = 0; j < _gridSize.height; ++j)
{ {
Quad3 coords = getOriginalTile(Vector2(i ,j)); Quad3 coords = getOriginalTile(Vec2(i ,j));
// X // X
coords.bl.x += ( rand() % (_randrange*2) ) - _randrange; coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
@ -195,7 +195,7 @@ void ShatteredTiles3D::update(float time)
coords.tr.z += ( rand() % (_randrange*2) ) - _randrange; coords.tr.z += ( rand() % (_randrange*2) ) - _randrange;
} }
setTile(Vector2(i, j), coords); setTile(Vec2(i, j), coords);
} }
} }
@ -267,7 +267,7 @@ void ShuffleTiles::shuffle(unsigned int *array, unsigned int len)
Size ShuffleTiles::getDelta(const Size& pos) const Size ShuffleTiles::getDelta(const Size& pos) const
{ {
Vector2 pos2; Vec2 pos2;
unsigned int idx = pos.width * _gridSize.height + pos.height; unsigned int idx = pos.width * _gridSize.height + pos.height;
@ -277,11 +277,11 @@ Size ShuffleTiles::getDelta(const Size& pos) const
return Size((int)(pos2.x - pos.width), (int)(pos2.y - pos.height)); return Size((int)(pos2.x - pos.width), (int)(pos2.y - pos.height));
} }
void ShuffleTiles::placeTile(const Vector2& pos, Tile *t) void ShuffleTiles::placeTile(const Vec2& pos, Tile *t)
{ {
Quad3 coords = getOriginalTile(pos); Quad3 coords = getOriginalTile(pos);
Vector2 step = _gridNodeTarget->getGrid()->getStep(); Vec2 step = _gridNodeTarget->getGrid()->getStep();
coords.bl.x += (int)(t->position.x * step.x); coords.bl.x += (int)(t->position.x * step.x);
coords.bl.y += (int)(t->position.y * step.y); coords.bl.y += (int)(t->position.y * step.y);
@ -329,8 +329,8 @@ void ShuffleTiles::startWithTarget(Node *target)
{ {
for (j = 0; j < _gridSize.height; ++j) for (j = 0; j < _gridSize.height; ++j)
{ {
tileArray->position = Vector2((float)i, (float)j); tileArray->position = Vec2((float)i, (float)j);
tileArray->startPosition = Vector2((float)i, (float)j); tileArray->startPosition = Vec2((float)i, (float)j);
tileArray->delta = getDelta(Size(i, j)); tileArray->delta = getDelta(Size(i, j));
++tileArray; ++tileArray;
} }
@ -347,8 +347,8 @@ void ShuffleTiles::update(float time)
{ {
for (j = 0; j < _gridSize.height; ++j) for (j = 0; j < _gridSize.height; ++j)
{ {
tileArray->position = Vector2((float)tileArray->delta.width, (float)tileArray->delta.height) * time; tileArray->position = Vec2((float)tileArray->delta.width, (float)tileArray->delta.height) * time;
placeTile(Vector2(i, j), tileArray); placeTile(Vec2(i, j), tileArray);
++tileArray; ++tileArray;
} }
} }
@ -386,7 +386,7 @@ FadeOutTRTiles* FadeOutTRTiles::clone() const
float FadeOutTRTiles::testFunc(const Size& pos, float time) float FadeOutTRTiles::testFunc(const Size& pos, float time)
{ {
Vector2 n = Vector2((float)_gridSize.width, (float)_gridSize.height) * time; Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * time;
if ((n.x + n.y) == 0.0f) if ((n.x + n.y) == 0.0f)
{ {
return 1.0f; return 1.0f;
@ -395,22 +395,22 @@ float FadeOutTRTiles::testFunc(const Size& pos, float time)
return powf((pos.width + pos.height) / (n.x + n.y), 6); return powf((pos.width + pos.height) / (n.x + n.y), 6);
} }
void FadeOutTRTiles::turnOnTile(const Vector2& pos) void FadeOutTRTiles::turnOnTile(const Vec2& pos)
{ {
setTile(pos, getOriginalTile(pos)); setTile(pos, getOriginalTile(pos));
} }
void FadeOutTRTiles::turnOffTile(const Vector2& pos) void FadeOutTRTiles::turnOffTile(const Vec2& pos)
{ {
Quad3 coords; Quad3 coords;
memset(&coords, 0, sizeof(Quad3)); memset(&coords, 0, sizeof(Quad3));
setTile(pos, coords); setTile(pos, coords);
} }
void FadeOutTRTiles::transformTile(const Vector2& pos, float distance) void FadeOutTRTiles::transformTile(const Vec2& pos, float distance)
{ {
Quad3 coords = getOriginalTile(pos); Quad3 coords = getOriginalTile(pos);
Vector2 step = _gridNodeTarget->getGrid()->getStep(); Vec2 step = _gridNodeTarget->getGrid()->getStep();
coords.bl.x += (step.x / 2) * (1.0f - distance); coords.bl.x += (step.x / 2) * (1.0f - distance);
coords.bl.y += (step.y / 2) * (1.0f - distance); coords.bl.y += (step.y / 2) * (1.0f - distance);
@ -438,15 +438,15 @@ void FadeOutTRTiles::update(float time)
float distance = testFunc(Size(i, j), time); float distance = testFunc(Size(i, j), time);
if ( distance == 0 ) if ( distance == 0 )
{ {
turnOffTile(Vector2(i, j)); turnOffTile(Vec2(i, j));
} else } else
if (distance < 1) if (distance < 1)
{ {
transformTile(Vector2(i, j), distance); transformTile(Vec2(i, j), distance);
} }
else else
{ {
turnOnTile(Vector2(i, j)); turnOnTile(Vec2(i, j));
} }
} }
} }
@ -484,7 +484,7 @@ FadeOutBLTiles* FadeOutBLTiles::clone() const
float FadeOutBLTiles::testFunc(const Size& pos, float time) float FadeOutBLTiles::testFunc(const Size& pos, float time)
{ {
Vector2 n = Vector2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time); Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time);
if ((pos.width + pos.height) == 0) if ((pos.width + pos.height) == 0)
{ {
return 1.0f; return 1.0f;
@ -525,7 +525,7 @@ FadeOutUpTiles* FadeOutUpTiles::clone() const
float FadeOutUpTiles::testFunc(const Size& pos, float time) float FadeOutUpTiles::testFunc(const Size& pos, float time)
{ {
Vector2 n = Vector2((float)_gridSize.width, (float)_gridSize.height) * time; Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * time;
if (n.y == 0.0f) if (n.y == 0.0f)
{ {
return 1.0f; return 1.0f;
@ -534,10 +534,10 @@ float FadeOutUpTiles::testFunc(const Size& pos, float time)
return powf(pos.height / n.y, 6); return powf(pos.height / n.y, 6);
} }
void FadeOutUpTiles::transformTile(const Vector2& pos, float distance) void FadeOutUpTiles::transformTile(const Vec2& pos, float distance)
{ {
Quad3 coords = getOriginalTile(pos); Quad3 coords = getOriginalTile(pos);
Vector2 step = _gridNodeTarget->getGrid()->getStep(); Vec2 step = _gridNodeTarget->getGrid()->getStep();
coords.bl.y += (step.y / 2) * (1.0f - distance); coords.bl.y += (step.y / 2) * (1.0f - distance);
coords.br.y += (step.y / 2) * (1.0f - distance); coords.br.y += (step.y / 2) * (1.0f - distance);
@ -579,7 +579,7 @@ FadeOutDownTiles* FadeOutDownTiles::clone() const
float FadeOutDownTiles::testFunc(const Size& pos, float time) float FadeOutDownTiles::testFunc(const Size& pos, float time)
{ {
Vector2 n = Vector2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time); Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time);
if (pos.height == 0) if (pos.height == 0)
{ {
return 1.0f; return 1.0f;
@ -662,12 +662,12 @@ void TurnOffTiles::shuffle(unsigned int *array, unsigned int len)
} }
} }
void TurnOffTiles::turnOnTile(const Vector2& pos) void TurnOffTiles::turnOnTile(const Vec2& pos)
{ {
setTile(pos, getOriginalTile(pos)); setTile(pos, getOriginalTile(pos));
} }
void TurnOffTiles::turnOffTile(const Vector2& pos) void TurnOffTiles::turnOffTile(const Vec2& pos)
{ {
Quad3 coords; Quad3 coords;
@ -706,7 +706,7 @@ void TurnOffTiles::update(float time)
for( i = 0; i < _tilesCount; i++ ) for( i = 0; i < _tilesCount; i++ )
{ {
t = _tilesOrder[i]; t = _tilesOrder[i];
Vector2 tilePos = Vector2( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height ); Vec2 tilePos = Vec2( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height );
if ( i < l ) if ( i < l )
{ {
@ -771,7 +771,7 @@ void WavesTiles3D::update(float time)
{ {
for( j = 0; j < _gridSize.height; j++ ) for( j = 0; j < _gridSize.height; j++ )
{ {
Quad3 coords = getOriginalTile(Vector2(i, j)); Quad3 coords = getOriginalTile(Vec2(i, j));
coords.bl.z = (sinf(time * (float)M_PI *_waves * 2 + coords.bl.z = (sinf(time * (float)M_PI *_waves * 2 +
(coords.bl.y+coords.bl.x) * .01f) * _amplitude * _amplitudeRate ); (coords.bl.y+coords.bl.x) * .01f) * _amplitude * _amplitudeRate );
@ -779,7 +779,7 @@ void WavesTiles3D::update(float time)
coords.tl.z = coords.bl.z; coords.tl.z = coords.bl.z;
coords.tr.z = coords.bl.z; coords.tr.z = coords.bl.z;
setTile(Vector2(i, j), coords); setTile(Vec2(i, j), coords);
} }
} }
} }
@ -839,7 +839,7 @@ void JumpTiles3D::update(float time)
{ {
for( j = 0; j < _gridSize.height; j++ ) for( j = 0; j < _gridSize.height; j++ )
{ {
Quad3 coords = getOriginalTile(Vector2(i, j)); Quad3 coords = getOriginalTile(Vec2(i, j));
if ( ((i+j) % 2) == 0 ) if ( ((i+j) % 2) == 0 )
{ {
@ -856,7 +856,7 @@ void JumpTiles3D::update(float time)
coords.tr.z += sinz2; coords.tr.z += sinz2;
} }
setTile(Vector2(i, j), coords); setTile(Vec2(i, j), coords);
} }
} }
} }
@ -910,7 +910,7 @@ void SplitRows::update(float time)
for (j = 0; j < _gridSize.height; ++j) for (j = 0; j < _gridSize.height; ++j)
{ {
Quad3 coords = getOriginalTile(Vector2(0, j)); Quad3 coords = getOriginalTile(Vec2(0, j));
float direction = 1; float direction = 1;
if ( (j % 2 ) == 0 ) if ( (j % 2 ) == 0 )
@ -923,7 +923,7 @@ void SplitRows::update(float time)
coords.tl.x += direction * _winSize.width * time; coords.tl.x += direction * _winSize.width * time;
coords.tr.x += direction * _winSize.width * time; coords.tr.x += direction * _winSize.width * time;
setTile(Vector2(0, j), coords); setTile(Vec2(0, j), coords);
} }
} }
@ -975,7 +975,7 @@ void SplitCols::update(float time)
for (i = 0; i < _gridSize.width; ++i) for (i = 0; i < _gridSize.width; ++i)
{ {
Quad3 coords = getOriginalTile(Vector2(i, 0)); Quad3 coords = getOriginalTile(Vec2(i, 0));
float direction = 1; float direction = 1;
if ( (i % 2 ) == 0 ) if ( (i % 2 ) == 0 )
@ -988,7 +988,7 @@ void SplitCols::update(float time)
coords.tl.y += direction * _winSize.height * time; coords.tl.y += direction * _winSize.height * time;
coords.tr.y += direction * _winSize.height * time; coords.tr.y += direction * _winSize.height * time;
setTile(Vector2(i, 0), coords); setTile(Vec2(i, 0), coords);
} }
} }

View File

@ -100,7 +100,7 @@ public:
void shuffle(unsigned int *array, unsigned int len); void shuffle(unsigned int *array, unsigned int len);
Size getDelta(const Size& pos) const; Size getDelta(const Size& pos) const;
void placeTile(const Vector2& pos, Tile *t); void placeTile(const Vec2& pos, Tile *t);
// Overrides // Overrides
virtual void startWithTarget(Node *target) override; virtual void startWithTarget(Node *target) override;
@ -134,9 +134,9 @@ public:
static FadeOutTRTiles* create(float duration, const Size& gridSize); static FadeOutTRTiles* create(float duration, const Size& gridSize);
virtual float testFunc(const Size& pos, float time); virtual float testFunc(const Size& pos, float time);
void turnOnTile(const Vector2& pos); void turnOnTile(const Vec2& pos);
void turnOffTile(const Vector2& pos); void turnOffTile(const Vec2& pos);
virtual void transformTile(const Vector2& pos, float distance); virtual void transformTile(const Vec2& pos, float distance);
// Overrides // Overrides
virtual void update(float time) override; virtual void update(float time) override;
@ -180,7 +180,7 @@ public:
/** creates the action with the grid size and the duration */ /** creates the action with the grid size and the duration */
static FadeOutUpTiles* create(float duration, const Size& gridSize); static FadeOutUpTiles* create(float duration, const Size& gridSize);
virtual void transformTile(const Vector2& pos, float distance); virtual void transformTile(const Vec2& pos, float distance);
// Overrides // Overrides
virtual FadeOutUpTiles* clone() const override; virtual FadeOutUpTiles* clone() const override;
@ -227,8 +227,8 @@ public:
static TurnOffTiles* create(float duration, const Size& gridSize, unsigned int seed); static TurnOffTiles* create(float duration, const Size& gridSize, unsigned int seed);
void shuffle(unsigned int *array, unsigned int len); void shuffle(unsigned int *array, unsigned int len);
void turnOnTile(const Vector2& pos); void turnOnTile(const Vec2& pos);
void turnOffTile(const Vector2& pos); void turnOffTile(const Vec2& pos);
// Overrides // Overrides
virtual TurnOffTiles* clone() const override; virtual TurnOffTiles* clone() const override;

View File

@ -133,7 +133,7 @@ void AtlasNode::updateAtlasValues()
} }
// AtlasNode - draw // AtlasNode - draw
void AtlasNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void AtlasNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
_quadCommand.init( _quadCommand.init(
_globalZOrder, _globalZOrder,

View File

@ -69,7 +69,7 @@ public:
// Overrides // Overrides
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual Texture2D* getTexture() const override; virtual Texture2D* getTexture() const override;
virtual void setTexture(Texture2D *texture) override; virtual void setTexture(Texture2D *texture) override;
virtual bool isOpacityModifyRGB() const override; virtual bool isOpacityModifyRGB() const override;

View File

@ -196,14 +196,14 @@ void ClippingNode::drawFullScreenQuadClearStencil()
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
DrawPrimitives::drawSolidRect(Vector2(-1,-1), Vector2(1,1), Color4F(1, 1, 1, 1)); DrawPrimitives::drawSolidRect(Vec2(-1,-1), Vec2(1,1), Color4F(1, 1, 1, 1));
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
} }
void ClippingNode::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
{ {
if(!_visible) if(!_visible)
return; return;
@ -214,7 +214,7 @@ void ClippingNode::visit(Renderer *renderer, const Matrix &parentTransform, bool
_transformUpdated = false; _transformUpdated = false;
// IMPORTANT: // IMPORTANT:
// To ease the migration to v3.0, we still support the Matrix stack, // To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it // but it is deprecated and your code should not rely on it
Director* director = Director::getInstance(); Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack"); CCASSERT(nullptr != director, "Director is null when seting matrix stack");
@ -382,7 +382,7 @@ void ClippingNode::onBeforeVisit()
glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP); glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP);
// draw a fullscreen solid rectangle to clear the stencil buffer // draw a fullscreen solid rectangle to clear the stencil buffer
//ccDrawSolidRect(Vector2::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1)); //ccDrawSolidRect(Vec2::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1));
drawFullScreenQuadClearStencil(); drawFullScreenQuadClearStencil();
/////////////////////////////////// ///////////////////////////////////

View File

@ -95,7 +95,7 @@ public:
* @lua NA * @lua NA
*/ */
virtual void onExit() override; virtual void onExit() override;
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
CC_CONSTRUCTOR_ACCESS: CC_CONSTRUCTOR_ACCESS:
ClippingNode(); ClippingNode();

View File

@ -34,67 +34,67 @@
NS_CC_BEGIN NS_CC_BEGIN
// Vector2 == CGPoint in 32-bits, but not in 64-bits (OS X) // Vec2 == CGPoint in 32-bits, but not in 64-bits (OS X)
// that's why the "v2f" functions are needed // that's why the "v2f" functions are needed
static Vector2 v2fzero(0.0f,0.0f); static Vec2 v2fzero(0.0f,0.0f);
static inline Vector2 v2f(float x, float y) static inline Vec2 v2f(float x, float y)
{ {
Vector2 ret(x, y); Vec2 ret(x, y);
return ret; return ret;
} }
static inline Vector2 v2fadd(const Vector2 &v0, const Vector2 &v1) static inline Vec2 v2fadd(const Vec2 &v0, const Vec2 &v1)
{ {
return v2f(v0.x+v1.x, v0.y+v1.y); return v2f(v0.x+v1.x, v0.y+v1.y);
} }
static inline Vector2 v2fsub(const Vector2 &v0, const Vector2 &v1) static inline Vec2 v2fsub(const Vec2 &v0, const Vec2 &v1)
{ {
return v2f(v0.x-v1.x, v0.y-v1.y); return v2f(v0.x-v1.x, v0.y-v1.y);
} }
static inline Vector2 v2fmult(const Vector2 &v, float s) static inline Vec2 v2fmult(const Vec2 &v, float s)
{ {
return v2f(v.x * s, v.y * s); return v2f(v.x * s, v.y * s);
} }
static inline Vector2 v2fperp(const Vector2 &p0) static inline Vec2 v2fperp(const Vec2 &p0)
{ {
return v2f(-p0.y, p0.x); return v2f(-p0.y, p0.x);
} }
static inline Vector2 v2fneg(const Vector2 &p0) static inline Vec2 v2fneg(const Vec2 &p0)
{ {
return v2f(-p0.x, - p0.y); return v2f(-p0.x, - p0.y);
} }
static inline float v2fdot(const Vector2 &p0, const Vector2 &p1) static inline float v2fdot(const Vec2 &p0, const Vec2 &p1)
{ {
return p0.x * p1.x + p0.y * p1.y; return p0.x * p1.x + p0.y * p1.y;
} }
static inline Vector2 v2fforangle(float _a_) static inline Vec2 v2fforangle(float _a_)
{ {
return v2f(cosf(_a_), sinf(_a_)); return v2f(cosf(_a_), sinf(_a_));
} }
static inline Vector2 v2fnormalize(const Vector2 &p) static inline Vec2 v2fnormalize(const Vec2 &p)
{ {
Vector2 r = Vector2(p.x, p.y).getNormalized(); Vec2 r = Vec2(p.x, p.y).getNormalized();
return v2f(r.x, r.y); return v2f(r.x, r.y);
} }
static inline Vector2 __v2f(const Vector2 &v) static inline Vec2 __v2f(const Vec2 &v)
{ {
//#ifdef __LP64__ //#ifdef __LP64__
return v2f(v.x, v.y); return v2f(v.x, v.y);
// #else // #else
// return * ((Vector2*) &v); // return * ((Vec2*) &v);
// #endif // #endif
} }
static inline Tex2F __t(const Vector2 &v) static inline Tex2F __t(const Vec2 &v)
{ {
return *(Tex2F*)&v; return *(Tex2F*)&v;
} }
@ -205,14 +205,14 @@ bool DrawNode::init()
return true; return true;
} }
void DrawNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void DrawNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
_customCommand.init(_globalZOrder); _customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this, transform, transformUpdated); _customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this, transform, transformUpdated);
renderer->addCommand(&_customCommand); renderer->addCommand(&_customCommand);
} }
void DrawNode::onDraw(const Matrix &transform, bool transformUpdated) void DrawNode::onDraw(const Mat4 &transform, bool transformUpdated)
{ {
auto glProgram = getGLProgram(); auto glProgram = getGLProgram();
glProgram->use(); glProgram->use();
@ -252,15 +252,15 @@ void DrawNode::onDraw(const Matrix &transform, bool transformUpdated)
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();
} }
void DrawNode::drawDot(const Vector2 &pos, float radius, const Color4F &color) void DrawNode::drawDot(const Vec2 &pos, float radius, const Color4F &color)
{ {
unsigned int vertex_count = 2*3; unsigned int vertex_count = 2*3;
ensureCapacity(vertex_count); ensureCapacity(vertex_count);
V2F_C4B_T2F a = {Vector2(pos.x - radius, pos.y - radius), Color4B(color), Tex2F(-1.0, -1.0) }; V2F_C4B_T2F a = {Vec2(pos.x - radius, pos.y - radius), Color4B(color), Tex2F(-1.0, -1.0) };
V2F_C4B_T2F b = {Vector2(pos.x - radius, pos.y + radius), Color4B(color), Tex2F(-1.0, 1.0) }; V2F_C4B_T2F b = {Vec2(pos.x - radius, pos.y + radius), Color4B(color), Tex2F(-1.0, 1.0) };
V2F_C4B_T2F c = {Vector2(pos.x + radius, pos.y + radius), Color4B(color), Tex2F( 1.0, 1.0) }; V2F_C4B_T2F c = {Vec2(pos.x + radius, pos.y + radius), Color4B(color), Tex2F( 1.0, 1.0) };
V2F_C4B_T2F d = {Vector2(pos.x + radius, pos.y - radius), Color4B(color), Tex2F( 1.0, -1.0) }; V2F_C4B_T2F d = {Vec2(pos.x + radius, pos.y - radius), Color4B(color), Tex2F( 1.0, -1.0) };
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
V2F_C4B_T2F_Triangle triangle0 = {a, b, c}; V2F_C4B_T2F_Triangle triangle0 = {a, b, c};
@ -273,28 +273,28 @@ void DrawNode::drawDot(const Vector2 &pos, float radius, const Color4F &color)
_dirty = true; _dirty = true;
} }
void DrawNode::drawSegment(const Vector2 &from, const Vector2 &to, float radius, const Color4F &color) void DrawNode::drawSegment(const Vec2 &from, const Vec2 &to, float radius, const Color4F &color)
{ {
unsigned int vertex_count = 6*3; unsigned int vertex_count = 6*3;
ensureCapacity(vertex_count); ensureCapacity(vertex_count);
Vector2 a = __v2f(from); Vec2 a = __v2f(from);
Vector2 b = __v2f(to); Vec2 b = __v2f(to);
Vector2 n = v2fnormalize(v2fperp(v2fsub(b, a))); Vec2 n = v2fnormalize(v2fperp(v2fsub(b, a)));
Vector2 t = v2fperp(n); Vec2 t = v2fperp(n);
Vector2 nw = v2fmult(n, radius); Vec2 nw = v2fmult(n, radius);
Vector2 tw = v2fmult(t, radius); Vec2 tw = v2fmult(t, radius);
Vector2 v0 = v2fsub(b, v2fadd(nw, tw)); Vec2 v0 = v2fsub(b, v2fadd(nw, tw));
Vector2 v1 = v2fadd(b, v2fsub(nw, tw)); Vec2 v1 = v2fadd(b, v2fsub(nw, tw));
Vector2 v2 = v2fsub(b, nw); Vec2 v2 = v2fsub(b, nw);
Vector2 v3 = v2fadd(b, nw); Vec2 v3 = v2fadd(b, nw);
Vector2 v4 = v2fsub(a, nw); Vec2 v4 = v2fsub(a, nw);
Vector2 v5 = v2fadd(a, nw); Vec2 v5 = v2fadd(a, nw);
Vector2 v6 = v2fsub(a, v2fsub(nw, tw)); Vec2 v6 = v2fsub(a, v2fsub(nw, tw));
Vector2 v7 = v2fadd(a, v2fadd(nw, tw)); Vec2 v7 = v2fadd(a, v2fadd(nw, tw));
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
@ -346,24 +346,24 @@ void DrawNode::drawSegment(const Vector2 &from, const Vector2 &to, float radius,
_dirty = true; _dirty = true;
} }
void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor) void DrawNode::drawPolygon(Vec2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor)
{ {
CCASSERT(count >= 0, "invalid count value"); CCASSERT(count >= 0, "invalid count value");
struct ExtrudeVerts {Vector2 offset, n;}; struct ExtrudeVerts {Vec2 offset, n;};
struct ExtrudeVerts* extrude = (struct ExtrudeVerts*)malloc(sizeof(struct ExtrudeVerts)*count); struct ExtrudeVerts* extrude = (struct ExtrudeVerts*)malloc(sizeof(struct ExtrudeVerts)*count);
memset(extrude, 0, sizeof(struct ExtrudeVerts)*count); memset(extrude, 0, sizeof(struct ExtrudeVerts)*count);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
Vector2 v0 = __v2f(verts[(i-1+count)%count]); Vec2 v0 = __v2f(verts[(i-1+count)%count]);
Vector2 v1 = __v2f(verts[i]); Vec2 v1 = __v2f(verts[i]);
Vector2 v2 = __v2f(verts[(i+1)%count]); Vec2 v2 = __v2f(verts[(i+1)%count]);
Vector2 n1 = v2fnormalize(v2fperp(v2fsub(v1, v0))); Vec2 n1 = v2fnormalize(v2fperp(v2fsub(v1, v0)));
Vector2 n2 = v2fnormalize(v2fperp(v2fsub(v2, v1))); Vec2 n2 = v2fnormalize(v2fperp(v2fsub(v2, v1)));
Vector2 offset = v2fmult(v2fadd(n1, n2), 1.0/(v2fdot(n1, n2) + 1.0)); Vec2 offset = v2fmult(v2fadd(n1, n2), 1.0/(v2fdot(n1, n2) + 1.0));
struct ExtrudeVerts tmp = {offset, n2}; struct ExtrudeVerts tmp = {offset, n2};
extrude[i] = tmp; extrude[i] = tmp;
} }
@ -380,9 +380,9 @@ void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor,
float inset = (outline == false ? 0.5 : 0.0); float inset = (outline == false ? 0.5 : 0.0);
for (int i = 0; i < count-2; i++) for (int i = 0; i < count-2; i++)
{ {
Vector2 v0 = v2fsub(__v2f(verts[0 ]), v2fmult(extrude[0 ].offset, inset)); Vec2 v0 = v2fsub(__v2f(verts[0 ]), v2fmult(extrude[0 ].offset, inset));
Vector2 v1 = v2fsub(__v2f(verts[i+1]), v2fmult(extrude[i+1].offset, inset)); Vec2 v1 = v2fsub(__v2f(verts[i+1]), v2fmult(extrude[i+1].offset, inset));
Vector2 v2 = v2fsub(__v2f(verts[i+2]), v2fmult(extrude[i+2].offset, inset)); Vec2 v2 = v2fsub(__v2f(verts[i+2]), v2fmult(extrude[i+2].offset, inset));
V2F_C4B_T2F_Triangle tmp = { V2F_C4B_T2F_Triangle tmp = {
{v0, Color4B(fillColor), __t(v2fzero)}, {v0, Color4B(fillColor), __t(v2fzero)},
@ -396,20 +396,20 @@ void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor,
for(int i = 0; i < count; i++) for(int i = 0; i < count; i++)
{ {
int j = (i+1)%count; int j = (i+1)%count;
Vector2 v0 = __v2f(verts[i]); Vec2 v0 = __v2f(verts[i]);
Vector2 v1 = __v2f(verts[j]); Vec2 v1 = __v2f(verts[j]);
Vector2 n0 = extrude[i].n; Vec2 n0 = extrude[i].n;
Vector2 offset0 = extrude[i].offset; Vec2 offset0 = extrude[i].offset;
Vector2 offset1 = extrude[j].offset; Vec2 offset1 = extrude[j].offset;
if(outline) if(outline)
{ {
Vector2 inner0 = v2fsub(v0, v2fmult(offset0, borderWidth)); Vec2 inner0 = v2fsub(v0, v2fmult(offset0, borderWidth));
Vector2 inner1 = v2fsub(v1, v2fmult(offset1, borderWidth)); Vec2 inner1 = v2fsub(v1, v2fmult(offset1, borderWidth));
Vector2 outer0 = v2fadd(v0, v2fmult(offset0, borderWidth)); Vec2 outer0 = v2fadd(v0, v2fmult(offset0, borderWidth));
Vector2 outer1 = v2fadd(v1, v2fmult(offset1, borderWidth)); Vec2 outer1 = v2fadd(v1, v2fmult(offset1, borderWidth));
V2F_C4B_T2F_Triangle tmp1 = { V2F_C4B_T2F_Triangle tmp1 = {
{inner0, Color4B(borderColor), __t(v2fneg(n0))}, {inner0, Color4B(borderColor), __t(v2fneg(n0))},
@ -426,10 +426,10 @@ void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor,
*cursor++ = tmp2; *cursor++ = tmp2;
} }
else { else {
Vector2 inner0 = v2fsub(v0, v2fmult(offset0, 0.5)); Vec2 inner0 = v2fsub(v0, v2fmult(offset0, 0.5));
Vector2 inner1 = v2fsub(v1, v2fmult(offset1, 0.5)); Vec2 inner1 = v2fsub(v1, v2fmult(offset1, 0.5));
Vector2 outer0 = v2fadd(v0, v2fmult(offset0, 0.5)); Vec2 outer0 = v2fadd(v0, v2fmult(offset0, 0.5));
Vector2 outer1 = v2fadd(v1, v2fmult(offset1, 0.5)); Vec2 outer1 = v2fadd(v1, v2fmult(offset1, 0.5));
V2F_C4B_T2F_Triangle tmp1 = { V2F_C4B_T2F_Triangle tmp1 = {
{inner0, Color4B(fillColor), __t(v2fzero)}, {inner0, Color4B(fillColor), __t(v2fzero)},
@ -454,15 +454,15 @@ void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor,
free(extrude); free(extrude);
} }
void DrawNode::drawTriangle(const Vector2 &p1, const Vector2 &p2, const Vector2 &p3, const Color4F &color) void DrawNode::drawTriangle(const Vec2 &p1, const Vec2 &p2, const Vec2 &p3, const Color4F &color)
{ {
unsigned int vertex_count = 2*3; unsigned int vertex_count = 2*3;
ensureCapacity(vertex_count); ensureCapacity(vertex_count);
Color4B col = Color4B(color); Color4B col = Color4B(color);
V2F_C4B_T2F a = {Vector2(p1.x, p1.y), col, Tex2F(0.0, 0.0) }; V2F_C4B_T2F a = {Vec2(p1.x, p1.y), col, Tex2F(0.0, 0.0) };
V2F_C4B_T2F b = {Vector2(p2.x, p2.y), col, Tex2F(0.0, 0.0) }; V2F_C4B_T2F b = {Vec2(p2.x, p2.y), col, Tex2F(0.0, 0.0) };
V2F_C4B_T2F c = {Vector2(p3.x, p3.y), col, Tex2F(0.0, 0.0) }; V2F_C4B_T2F c = {Vec2(p3.x, p3.y), col, Tex2F(0.0, 0.0) };
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
V2F_C4B_T2F_Triangle triangle = {a, b, c}; V2F_C4B_T2F_Triangle triangle = {a, b, c};
@ -472,23 +472,23 @@ void DrawNode::drawTriangle(const Vector2 &p1, const Vector2 &p2, const Vector2
_dirty = true; _dirty = true;
} }
void DrawNode::drawCubicBezier(const Vector2& from, const Vector2& control1, const Vector2& control2, const Vector2& to, unsigned int segments, const Color4F &color) void DrawNode::drawCubicBezier(const Vec2& from, const Vec2& control1, const Vec2& control2, const Vec2& to, unsigned int segments, const Color4F &color)
{ {
unsigned int vertex_count = (segments + 1) * 3; unsigned int vertex_count = (segments + 1) * 3;
ensureCapacity(vertex_count); ensureCapacity(vertex_count);
Tex2F texCoord = Tex2F(0.0, 0.0); Tex2F texCoord = Tex2F(0.0, 0.0);
Color4B col = Color4B(color); Color4B col = Color4B(color);
Vector2 vertex; Vec2 vertex;
Vector2 firstVertex = Vector2(from.x, from.y); Vec2 firstVertex = Vec2(from.x, from.y);
Vector2 lastVertex = Vector2(to.x, to.y); Vec2 lastVertex = Vec2(to.x, to.y);
float t = 0; float t = 0;
for(unsigned int i = segments + 1; i > 0; i--) for(unsigned int i = segments + 1; i > 0; i--)
{ {
float x = powf(1 - t, 3) * from.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * to.x; float x = powf(1 - t, 3) * from.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * to.x;
float y = powf(1 - t, 3) * from.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * to.y; float y = powf(1 - t, 3) * from.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * to.y;
vertex = Vector2(x, y); vertex = Vec2(x, y);
V2F_C4B_T2F a = {firstVertex, col, texCoord }; V2F_C4B_T2F a = {firstVertex, col, texCoord };
V2F_C4B_T2F b = {lastVertex, col, texCoord }; V2F_C4B_T2F b = {lastVertex, col, texCoord };
@ -503,23 +503,23 @@ void DrawNode::drawCubicBezier(const Vector2& from, const Vector2& control1, con
_dirty = true; _dirty = true;
} }
void DrawNode::drawQuadraticBezier(const Vector2& from, const Vector2& control, const Vector2& to, unsigned int segments, const Color4F &color) void DrawNode::drawQuadraticBezier(const Vec2& from, const Vec2& control, const Vec2& to, unsigned int segments, const Color4F &color)
{ {
unsigned int vertex_count = (segments + 1) * 3; unsigned int vertex_count = (segments + 1) * 3;
ensureCapacity(vertex_count); ensureCapacity(vertex_count);
Tex2F texCoord = Tex2F(0.0, 0.0); Tex2F texCoord = Tex2F(0.0, 0.0);
Color4B col = Color4B(color); Color4B col = Color4B(color);
Vector2 vertex; Vec2 vertex;
Vector2 firstVertex = Vector2(from.x, from.y); Vec2 firstVertex = Vec2(from.x, from.y);
Vector2 lastVertex = Vector2(to.x, to.y); Vec2 lastVertex = Vec2(to.x, to.y);
float t = 0; float t = 0;
for(unsigned int i = segments + 1; i > 0; i--) for(unsigned int i = segments + 1; i > 0; i--)
{ {
float x = powf(1 - t, 2) * from.x + 2.0f * (1 - t) * t * control.x + t * t * to.x; float x = powf(1 - t, 2) * from.x + 2.0f * (1 - t) * t * control.x + t * t * to.x;
float y = powf(1 - t, 2) * from.y + 2.0f * (1 - t) * t * control.y + t * t * to.y; float y = powf(1 - t, 2) * from.y + 2.0f * (1 - t) * t * control.y + t * t * to.y;
vertex = Vector2(x, y); vertex = Vec2(x, y);
V2F_C4B_T2F a = {firstVertex, col, texCoord }; V2F_C4B_T2F a = {firstVertex, col, texCoord };
V2F_C4B_T2F b = {lastVertex, col, texCoord }; V2F_C4B_T2F b = {lastVertex, col, texCoord };

View File

@ -50,10 +50,10 @@ public:
static DrawNode* create(); static DrawNode* create();
/** draw a dot at a position, with a given radius and color */ /** draw a dot at a position, with a given radius and color */
void drawDot(const Vector2 &pos, float radius, const Color4F &color); void drawDot(const Vec2 &pos, float radius, const Color4F &color);
/** draw a segment with a radius and color */ /** draw a segment with a radius and color */
void drawSegment(const Vector2 &from, const Vector2 &to, float radius, const Color4F &color); void drawSegment(const Vec2 &from, const Vec2 &to, float radius, const Color4F &color);
/** draw a polygon with a fill color and line color /** draw a polygon with a fill color and line color
* @code * @code
@ -62,16 +62,16 @@ public:
* In lua:local drawPolygon(local pointTable,local tableCount,local fillColor,local width,local borderColor) * In lua:local drawPolygon(local pointTable,local tableCount,local fillColor,local width,local borderColor)
* @endcode * @endcode
*/ */
void drawPolygon(Vector2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor); void drawPolygon(Vec2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor);
/** draw a triangle with color */ /** draw a triangle with color */
void drawTriangle(const Vector2 &p1, const Vector2 &p2, const Vector2 &p3, const Color4F &color); void drawTriangle(const Vec2 &p1, const Vec2 &p2, const Vec2 &p3, const Color4F &color);
/** draw a cubic bezier curve with color and number of segments */ /** draw a cubic bezier curve with color and number of segments */
void drawCubicBezier(const Vector2& from, const Vector2& control1, const Vector2& control2, const Vector2& to, unsigned int segments, const Color4F &color); void drawCubicBezier(const Vec2& from, const Vec2& control1, const Vec2& control2, const Vec2& to, unsigned int segments, const Color4F &color);
/** draw a quadratic bezier curve with color and number of segments */ /** draw a quadratic bezier curve with color and number of segments */
void drawQuadraticBezier(const Vector2& from, const Vector2& control, const Vector2& to, unsigned int segments, const Color4F &color); void drawQuadraticBezier(const Vec2& from, const Vec2& control, const Vec2& to, unsigned int segments, const Color4F &color);
/** Clear the geometry in the node's buffer. */ /** Clear the geometry in the node's buffer. */
void clear(); void clear();
@ -89,10 +89,10 @@ public:
*/ */
void setBlendFunc(const BlendFunc &blendFunc); void setBlendFunc(const BlendFunc &blendFunc);
void onDraw(const Matrix &transform, bool transformUpdated); void onDraw(const Mat4 &transform, bool transformUpdated);
// Overrides // Overrides
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
CC_CONSTRUCTOR_ACCESS: CC_CONSTRUCTOR_ACCESS:
DrawNode(); DrawNode();

View File

@ -123,11 +123,11 @@ void free()
s_initialized = false; s_initialized = false;
} }
void drawPoint( const Vector2& point ) void drawPoint( const Vec2& point )
{ {
lazy_init(); lazy_init();
Vector2 p; Vec2 p;
p.x = point.x; p.x = point.x;
p.y = point.y; p.y = point.y;
@ -150,7 +150,7 @@ void drawPoint( const Vector2& point )
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,1); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,1);
} }
void drawPoints( const Vector2 *points, unsigned int numberOfPoints ) void drawPoints( const Vec2 *points, unsigned int numberOfPoints )
{ {
lazy_init(); lazy_init();
@ -161,13 +161,13 @@ void drawPoints( const Vector2 *points, unsigned int numberOfPoints )
s_shader->setUniformLocationWith1f(s_pointSizeLocation, s_pointSize); s_shader->setUniformLocationWith1f(s_pointSizeLocation, s_pointSize);
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
Vector2* newPoints = new Vector2[numberOfPoints]; Vec2* newPoints = new Vec2[numberOfPoints];
// iPhone and 32-bit machines optimization // iPhone and 32-bit machines optimization
if( sizeof(Vector2) == sizeof(Vector2) ) if( sizeof(Vec2) == sizeof(Vec2) )
{ {
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData((void*) points, numberOfPoints * sizeof(Vector2)); setGLBufferData((void*) points, numberOfPoints * sizeof(Vec2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, points); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, points);
@ -183,7 +183,7 @@ void drawPoints( const Vector2 *points, unsigned int numberOfPoints )
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
// Suspect Emscripten won't be emitting 64-bit code for a while yet, // Suspect Emscripten won't be emitting 64-bit code for a while yet,
// but want to make sure this continues to work even if they do. // but want to make sure this continues to work even if they do.
setGLBufferData(newPoints, numberOfPoints * sizeof(Vector2)); setGLBufferData(newPoints, numberOfPoints * sizeof(Vec2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoints); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoints);
@ -198,13 +198,13 @@ void drawPoints( const Vector2 *points, unsigned int numberOfPoints )
} }
void drawLine( const Vector2& origin, const Vector2& destination ) void drawLine( const Vec2& origin, const Vec2& destination )
{ {
lazy_init(); lazy_init();
Vector2 vertices[2] = { Vec2 vertices[2] = {
Vector2(origin.x, origin.y), Vec2(origin.x, origin.y),
Vector2(destination.x, destination.y) Vec2(destination.x, destination.y)
}; };
s_shader->use(); s_shader->use();
@ -223,27 +223,27 @@ void drawLine( const Vector2& origin, const Vector2& destination )
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,2); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,2);
} }
void drawRect( Vector2 origin, Vector2 destination ) void drawRect( Vec2 origin, Vec2 destination )
{ {
drawLine(Vector2(origin.x, origin.y), Vector2(destination.x, origin.y)); drawLine(Vec2(origin.x, origin.y), Vec2(destination.x, origin.y));
drawLine(Vector2(destination.x, origin.y), Vector2(destination.x, destination.y)); drawLine(Vec2(destination.x, origin.y), Vec2(destination.x, destination.y));
drawLine(Vector2(destination.x, destination.y), Vector2(origin.x, destination.y)); drawLine(Vec2(destination.x, destination.y), Vec2(origin.x, destination.y));
drawLine(Vector2(origin.x, destination.y), Vector2(origin.x, origin.y)); drawLine(Vec2(origin.x, destination.y), Vec2(origin.x, origin.y));
} }
void drawSolidRect( Vector2 origin, Vector2 destination, Color4F color ) void drawSolidRect( Vec2 origin, Vec2 destination, Color4F color )
{ {
Vector2 vertices[] = { Vec2 vertices[] = {
origin, origin,
Vector2(destination.x, origin.y), Vec2(destination.x, origin.y),
destination, destination,
Vector2(origin.x, destination.y) Vec2(origin.x, destination.y)
}; };
drawSolidPoly(vertices, 4, color ); drawSolidPoly(vertices, 4, color );
} }
void drawPoly( const Vector2 *poli, unsigned int numberOfPoints, bool closePolygon ) void drawPoly( const Vec2 *poli, unsigned int numberOfPoints, bool closePolygon )
{ {
lazy_init(); lazy_init();
@ -254,10 +254,10 @@ void drawPoly( const Vector2 *poli, unsigned int numberOfPoints, bool closePolyg
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
// iPhone and 32-bit machines optimization // iPhone and 32-bit machines optimization
if( sizeof(Vector2) == sizeof(Vector2) ) if( sizeof(Vec2) == sizeof(Vec2) )
{ {
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData((void*) poli, numberOfPoints * sizeof(Vector2)); setGLBufferData((void*) poli, numberOfPoints * sizeof(Vec2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli);
@ -272,13 +272,13 @@ void drawPoly( const Vector2 *poli, unsigned int numberOfPoints, bool closePolyg
{ {
// Mac on 64-bit // Mac on 64-bit
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
Vector2* newPoli = new Vector2[numberOfPoints]; Vec2* newPoli = new Vec2[numberOfPoints];
for( unsigned int i=0; i<numberOfPoints;i++) { for( unsigned int i=0; i<numberOfPoints;i++) {
newPoli[i].x = poli[i].x; newPoli[i].x = poli[i].x;
newPoli[i].y = poli[i].y; newPoli[i].y = poli[i].y;
} }
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(newPoli, numberOfPoints * sizeof(Vector2)); setGLBufferData(newPoli, numberOfPoints * sizeof(Vec2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
@ -295,7 +295,7 @@ void drawPoly( const Vector2 *poli, unsigned int numberOfPoints, bool closePolyg
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, numberOfPoints); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, numberOfPoints);
} }
void drawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F color ) void drawSolidPoly( const Vec2 *poli, unsigned int numberOfPoints, Color4F color )
{ {
lazy_init(); lazy_init();
@ -306,13 +306,13 @@ void drawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F co
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
Vector2* newPoli = new Vector2[numberOfPoints]; Vec2* newPoli = new Vec2[numberOfPoints];
// iPhone and 32-bit machines optimization // iPhone and 32-bit machines optimization
if( sizeof(Vector2) == sizeof(Vector2) ) if( sizeof(Vec2) == sizeof(Vec2) )
{ {
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData((void*) poli, numberOfPoints * sizeof(Vector2)); setGLBufferData((void*) poli, numberOfPoints * sizeof(Vec2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli);
@ -323,10 +323,10 @@ void drawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F co
// Mac on 64-bit // Mac on 64-bit
for( unsigned int i=0; i<numberOfPoints;i++) for( unsigned int i=0; i<numberOfPoints;i++)
{ {
newPoli[i] = Vector2( poli[i].x, poli[i].y ); newPoli[i] = Vec2( poli[i].x, poli[i].y );
} }
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(newPoli, numberOfPoints * sizeof(Vector2)); setGLBufferData(newPoli, numberOfPoints * sizeof(Vec2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
@ -339,7 +339,7 @@ void drawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F co
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, numberOfPoints); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, numberOfPoints);
} }
void drawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY) void drawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY)
{ {
lazy_init(); lazy_init();
@ -383,12 +383,12 @@ void drawCircle( const Vector2& center, float radius, float angle, unsigned int
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+additionalSegment); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+additionalSegment);
} }
void drawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter) void drawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter)
{ {
drawCircle(center, radius, angle, segments, drawLineToCenter, 1.0f, 1.0f); drawCircle(center, radius, angle, segments, drawLineToCenter, 1.0f, 1.0f);
} }
void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY) void drawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY)
{ {
lazy_init(); lazy_init();
@ -429,16 +429,16 @@ void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+1); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+1);
} }
void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments) void drawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments)
{ {
drawSolidCircle(center, radius, angle, segments, 1.0f, 1.0f); drawSolidCircle(center, radius, angle, segments, 1.0f, 1.0f);
} }
void drawQuadBezier(const Vector2& origin, const Vector2& control, const Vector2& destination, unsigned int segments) void drawQuadBezier(const Vec2& origin, const Vec2& control, const Vec2& destination, unsigned int segments)
{ {
lazy_init(); lazy_init();
Vector2* vertices = new Vector2[segments + 1]; Vec2* vertices = new Vec2[segments + 1];
float t = 0.0f; float t = 0.0f;
for(unsigned int i = 0; i < segments; i++) for(unsigned int i = 0; i < segments; i++)
@ -457,7 +457,7 @@ void drawQuadBezier(const Vector2& origin, const Vector2& control, const Vector2
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(vertices, (segments + 1) * sizeof(Vector2)); setGLBufferData(vertices, (segments + 1) * sizeof(Vec2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
@ -477,7 +477,7 @@ void drawCardinalSpline( PointArray *config, float tension, unsigned int segmen
{ {
lazy_init(); lazy_init();
Vector2* vertices = new Vector2[segments + 1]; Vec2* vertices = new Vec2[segments + 1];
ssize_t p; ssize_t p;
float lt; float lt;
@ -497,12 +497,12 @@ void drawCardinalSpline( PointArray *config, float tension, unsigned int segmen
} }
// Interpolate // Interpolate
Vector2 pp0 = config->getControlPointAtIndex(p-1); Vec2 pp0 = config->getControlPointAtIndex(p-1);
Vector2 pp1 = config->getControlPointAtIndex(p+0); Vec2 pp1 = config->getControlPointAtIndex(p+0);
Vector2 pp2 = config->getControlPointAtIndex(p+1); Vec2 pp2 = config->getControlPointAtIndex(p+1);
Vector2 pp3 = config->getControlPointAtIndex(p+2); Vec2 pp3 = config->getControlPointAtIndex(p+2);
Vector2 newPos = ccCardinalSplineAt( pp0, pp1, pp2, pp3, tension, lt); Vec2 newPos = ccCardinalSplineAt( pp0, pp1, pp2, pp3, tension, lt);
vertices[i].x = newPos.x; vertices[i].x = newPos.x;
vertices[i].y = newPos.y; vertices[i].y = newPos.y;
} }
@ -514,7 +514,7 @@ void drawCardinalSpline( PointArray *config, float tension, unsigned int segmen
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(vertices, (segments + 1) * sizeof(Vector2)); setGLBufferData(vertices, (segments + 1) * sizeof(Vec2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
@ -525,11 +525,11 @@ void drawCardinalSpline( PointArray *config, float tension, unsigned int segmen
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+1); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+1);
} }
void drawCubicBezier(const Vector2& origin, const Vector2& control1, const Vector2& control2, const Vector2& destination, unsigned int segments) void drawCubicBezier(const Vec2& origin, const Vec2& control1, const Vec2& control2, const Vec2& destination, unsigned int segments)
{ {
lazy_init(); lazy_init();
Vector2* vertices = new Vector2[segments + 1]; Vec2* vertices = new Vec2[segments + 1];
float t = 0; float t = 0;
for(unsigned int i = 0; i < segments; i++) for(unsigned int i = 0; i < segments; i++)
@ -548,7 +548,7 @@ void drawCubicBezier(const Vector2& origin, const Vector2& control1, const Vecto
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(vertices, (segments + 1) * sizeof(Vector2)); setGLBufferData(vertices, (segments + 1) * sizeof(Vec2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);

View File

@ -63,7 +63,7 @@ THE SOFTWARE.
- ccPointSize() - ccPointSize()
- glLineWidth() - glLineWidth()
@warning These functions draws the Line, Vector2, Polygon, immediately. They aren't batched. If you are going to make a game that depends on these primitives, I suggest creating a batch. Instead you should use DrawNode @warning These functions draws the Line, Vec2, Polygon, immediately. They aren't batched. If you are going to make a game that depends on these primitives, I suggest creating a batch. Instead you should use DrawNode
*/ */
@ -85,52 +85,52 @@ namespace DrawPrimitives
void free(); void free();
/** draws a point given x and y coordinate measured in points */ /** draws a point given x and y coordinate measured in points */
void drawPoint( const Vector2& point ); void drawPoint( const Vec2& point );
/** draws an array of points. /** draws an array of points.
@since v0.7.2 @since v0.7.2
*/ */
void drawPoints( const Vector2 *points, unsigned int numberOfPoints ); void drawPoints( const Vec2 *points, unsigned int numberOfPoints );
/** draws a line given the origin and destination point measured in points */ /** draws a line given the origin and destination point measured in points */
void drawLine( const Vector2& origin, const Vector2& destination ); void drawLine( const Vec2& origin, const Vec2& destination );
/** draws a rectangle given the origin and destination point measured in points. */ /** draws a rectangle given the origin and destination point measured in points. */
void drawRect( Vector2 origin, Vector2 destination ); void drawRect( Vec2 origin, Vec2 destination );
/** draws a solid rectangle given the origin and destination point measured in points. /** draws a solid rectangle given the origin and destination point measured in points.
@since 1.1 @since 1.1
*/ */
void drawSolidRect( Vector2 origin, Vector2 destination, Color4F color ); void drawSolidRect( Vec2 origin, Vec2 destination, Color4F color );
/** draws a polygon given a pointer to point coordinates and the number of vertices measured in points. /** draws a polygon given a pointer to point coordinates and the number of vertices measured in points.
The polygon can be closed or open The polygon can be closed or open
*/ */
void drawPoly( const Vector2 *vertices, unsigned int numOfVertices, bool closePolygon ); void drawPoly( const Vec2 *vertices, unsigned int numOfVertices, bool closePolygon );
/** draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a color. /** draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a color.
*/ */
void drawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F color ); void drawSolidPoly( const Vec2 *poli, unsigned int numberOfPoints, Color4F color );
/** draws a circle given the center, radius and number of segments. */ /** draws a circle given the center, radius and number of segments. */
void drawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY); void drawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY);
void drawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); void drawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter);
/** draws a solid circle given the center, radius and number of segments. */ /** draws a solid circle given the center, radius and number of segments. */
void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY); void drawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY);
void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments); void drawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments);
/** draws a quad bezier path /** draws a quad bezier path
@warning This function could be pretty slow. Use it only for debugging purposes. @warning This function could be pretty slow. Use it only for debugging purposes.
@since v0.8 @since v0.8
*/ */
void drawQuadBezier(const Vector2& origin, const Vector2& control, const Vector2& destination, unsigned int segments); void drawQuadBezier(const Vec2& origin, const Vec2& control, const Vec2& destination, unsigned int segments);
/** draws a cubic bezier path /** draws a cubic bezier path
@warning This function could be pretty slow. Use it only for debugging purposes. @warning This function could be pretty slow. Use it only for debugging purposes.
@since v0.8 @since v0.8
*/ */
void drawCubicBezier(const Vector2& origin, const Vector2& control1, const Vector2& control2, const Vector2& destination, unsigned int segments); void drawCubicBezier(const Vec2& origin, const Vec2& control1, const Vec2& control2, const Vec2& destination, unsigned int segments);
/** draws a Catmull Rom path. /** draws a Catmull Rom path.
@warning This function could be pretty slow. Use it only for debugging purposes. @warning This function could be pretty slow. Use it only for debugging purposes.

View File

@ -90,7 +90,7 @@ FontAtlas * FontAtlasCache::getFontAtlasTTF(const TTFConfig & config)
return nullptr; return nullptr;
} }
FontAtlas * FontAtlasCache::getFontAtlasFNT(const std::string& fontFileName, const Vector2& imageOffset /* = Vector2::ZERO */) FontAtlas * FontAtlasCache::getFontAtlasFNT(const std::string& fontFileName, const Vec2& imageOffset /* = Vec2::ZERO */)
{ {
std::string atlasName = generateFontName(fontFileName, 0, GlyphCollection::CUSTOM,false); std::string atlasName = generateFontName(fontFileName, 0, GlyphCollection::CUSTOM,false);
auto it = _atlasMap.find(atlasName); auto it = _atlasMap.find(atlasName);

View File

@ -38,7 +38,7 @@ class CC_DLL FontAtlasCache
{ {
public: public:
static FontAtlas * getFontAtlasTTF(const TTFConfig & config); static FontAtlas * getFontAtlasTTF(const TTFConfig & config);
static FontAtlas * getFontAtlasFNT(const std::string& fontFileName, const Vector2& imageOffset = Vector2::ZERO); static FontAtlas * getFontAtlasFNT(const std::string& fontFileName, const Vec2& imageOffset = Vec2::ZERO);
static FontAtlas * getFontAtlasCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap); static FontAtlas * getFontAtlasCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
static FontAtlas * getFontAtlasCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap); static FontAtlas * getFontAtlasCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap);

View File

@ -665,7 +665,7 @@ void BMFontConfiguration::parseKerningEntry(std::string line)
HASH_ADD_INT(_kerningDictionary,key, element); HASH_ADD_INT(_kerningDictionary,key, element);
} }
FontFNT * FontFNT::create(const std::string& fntFilePath, const Vector2& imageOffset /* = Vector2::ZERO */) FontFNT * FontFNT::create(const std::string& fntFilePath, const Vec2& imageOffset /* = Vec2::ZERO */)
{ {
BMFontConfiguration *newConf = FNTConfigLoadFile(fntFilePath); BMFontConfiguration *newConf = FNTConfigLoadFile(fntFilePath);
if (!newConf) if (!newConf)
@ -690,7 +690,7 @@ FontFNT * FontFNT::create(const std::string& fntFilePath, const Vector2& imageOf
return tempFont; return tempFont;
} }
FontFNT::FontFNT(BMFontConfiguration *theContfig, const Vector2& imageOffset /* = Vector2::ZERO */) FontFNT::FontFNT(BMFontConfiguration *theContfig, const Vec2& imageOffset /* = Vec2::ZERO */)
:_configuration(theContfig) :_configuration(theContfig)
,_imageOffset(CC_POINT_PIXELS_TO_POINTS(imageOffset)) ,_imageOffset(CC_POINT_PIXELS_TO_POINTS(imageOffset))
{ {

View File

@ -37,7 +37,7 @@ class FontFNT : public Font
public: public:
static FontFNT * create(const std::string& fntFilePath, const Vector2& imageOffset = Vector2::ZERO); static FontFNT * create(const std::string& fntFilePath, const Vec2& imageOffset = Vec2::ZERO);
/** Purges the cached data. /** Purges the cached data.
Removes from memory the cached configurations and the atlas name dictionary. Removes from memory the cached configurations and the atlas name dictionary.
*/ */
@ -47,7 +47,7 @@ public:
protected: protected:
FontFNT(BMFontConfiguration *theContfig, const Vector2& imageOffset = Vector2::ZERO); FontFNT(BMFontConfiguration *theContfig, const Vec2& imageOffset = Vec2::ZERO);
/** /**
* @js NA * @js NA
* @lua NA * @lua NA
@ -59,7 +59,7 @@ private:
int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const; int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const;
BMFontConfiguration * _configuration; BMFontConfiguration * _configuration;
Vector2 _imageOffset; Vec2 _imageOffset;
}; };

View File

@ -186,8 +186,8 @@ void GridBase::set2DProjection()
glViewport(0, 0, (GLsizei)(size.width), (GLsizei)(size.height) ); glViewport(0, 0, (GLsizei)(size.width), (GLsizei)(size.height) );
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
Matrix orthoMatrix; Mat4 orthoMatrix;
Matrix::createOrthographicOffCenter(0, size.width, 0, size.height, -1, 1, &orthoMatrix); Mat4::createOrthographicOffCenter(0, size.width, 0, size.height, -1, 1, &orthoMatrix);
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix); director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix);
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
@ -217,7 +217,7 @@ void GridBase::afterDraw(cocos2d::Node *target)
// if (target->getCamera()->isDirty()) // if (target->getCamera()->isDirty())
// { // {
// Vector2 offset = target->getAnchorPointInPoints(); // Vec2 offset = target->getAnchorPointInPoints();
// //
// // // //
// // XXX: Camera should be applied in the AnchorPoint // // XXX: Camera should be applied in the AnchorPoint
@ -326,11 +326,11 @@ void Grid3D::blit(void)
unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1); unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1);
// position // position
setGLBufferData(_vertices, numOfPoints * sizeof(Vector3), 0); setGLBufferData(_vertices, numOfPoints * sizeof(Vec3), 0);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0);
// texCoords // texCoords
setGLBufferData(_texCoordinates, numOfPoints * sizeof(Vector2), 1); setGLBufferData(_texCoordinates, numOfPoints * sizeof(Vec2), 1);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLIndexData(_indices, n * 12, 0); setGLIndexData(_indices, n * 12, 0);
@ -361,9 +361,9 @@ void Grid3D::calculateVertexPoints(void)
unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1); unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1);
_vertices = malloc(numOfPoints * sizeof(Vector3)); _vertices = malloc(numOfPoints * sizeof(Vec3));
_originalVertices = malloc(numOfPoints * sizeof(Vector3)); _originalVertices = malloc(numOfPoints * sizeof(Vec3));
_texCoordinates = malloc(numOfPoints * sizeof(Vector2)); _texCoordinates = malloc(numOfPoints * sizeof(Vec2));
_indices = (GLushort*)malloc(_gridSize.width * _gridSize.height * sizeof(GLushort) * 6); _indices = (GLushort*)malloc(_gridSize.width * _gridSize.height * sizeof(GLushort) * 6);
GLfloat *vertArray = (GLfloat*)_vertices; GLfloat *vertArray = (GLfloat*)_vertices;
@ -391,15 +391,15 @@ void Grid3D::calculateVertexPoints(void)
memcpy(&idxArray[6*idx], tempidx, 6*sizeof(GLushort)); memcpy(&idxArray[6*idx], tempidx, 6*sizeof(GLushort));
int l1[4] = {a*3, b*3, c*3, d*3}; int l1[4] = {a*3, b*3, c*3, d*3};
Vector3 e(x1, y1, 0); Vec3 e(x1, y1, 0);
Vector3 f(x2, y1, 0); Vec3 f(x2, y1, 0);
Vector3 g(x2, y2, 0); Vec3 g(x2, y2, 0);
Vector3 h(x1, y2, 0); Vec3 h(x1, y2, 0);
Vector3 l2[4] = {e, f, g, h}; Vec3 l2[4] = {e, f, g, h};
int tex1[4] = {a*2, b*2, c*2, d*2}; int tex1[4] = {a*2, b*2, c*2, d*2};
Vector2 Tex2F[4] = {Vector2(x1, y1), Vector2(x2, y1), Vector2(x2, y2), Vector2(x1, y2)}; Vec2 Tex2F[4] = {Vec2(x1, y1), Vec2(x2, y1), Vec2(x2, y2), Vec2(x1, y2)};
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
{ {
@ -420,34 +420,34 @@ void Grid3D::calculateVertexPoints(void)
} }
} }
memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vector3)); memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vec3));
} }
Vector3 Grid3D::getVertex(const Vector2& pos) const Vec3 Grid3D::getVertex(const Vec2& pos) const
{ {
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
int index = (pos.x * (_gridSize.height+1) + pos.y) * 3; int index = (pos.x * (_gridSize.height+1) + pos.y) * 3;
float *vertArray = (float*)_vertices; float *vertArray = (float*)_vertices;
Vector3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]); Vec3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]);
return vert; return vert;
} }
Vector3 Grid3D::getOriginalVertex(const Vector2& pos) const Vec3 Grid3D::getOriginalVertex(const Vec2& pos) const
{ {
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
int index = (pos.x * (_gridSize.height+1) + pos.y) * 3; int index = (pos.x * (_gridSize.height+1) + pos.y) * 3;
float *vertArray = (float*)_originalVertices; float *vertArray = (float*)_originalVertices;
Vector3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]); Vec3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]);
return vert; return vert;
} }
void Grid3D::setVertex(const Vector2& pos, const Vector3& vertex) void Grid3D::setVertex(const Vec2& pos, const Vec3& vertex)
{ {
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
int index = (pos.x * (_gridSize.height + 1) + pos.y) * 3; int index = (pos.x * (_gridSize.height + 1) + pos.y) * 3;
@ -461,7 +461,7 @@ void Grid3D::reuse(void)
{ {
if (_reuseGrid > 0) if (_reuseGrid > 0)
{ {
memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vector3)); memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vec3));
--_reuseGrid; --_reuseGrid;
} }
} }
@ -541,11 +541,11 @@ void TiledGrid3D::blit(void)
int numQuads = _gridSize.width * _gridSize.height; int numQuads = _gridSize.width * _gridSize.height;
// position // position
setGLBufferData(_vertices, (numQuads*4*sizeof(Vector3)), 0); setGLBufferData(_vertices, (numQuads*4*sizeof(Vec3)), 0);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0);
// texCoords // texCoords
setGLBufferData(_texCoordinates, (numQuads*4*sizeof(Vector2)), 1); setGLBufferData(_texCoordinates, (numQuads*4*sizeof(Vec2)), 1);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLIndexData(_indices, n * 12, 0); setGLIndexData(_indices, n * 12, 0);
@ -576,9 +576,9 @@ void TiledGrid3D::calculateVertexPoints(void)
CC_SAFE_FREE(_texCoordinates); CC_SAFE_FREE(_texCoordinates);
CC_SAFE_FREE(_indices); CC_SAFE_FREE(_indices);
_vertices = malloc(numQuads*4*sizeof(Vector3)); _vertices = malloc(numQuads*4*sizeof(Vec3));
_originalVertices = malloc(numQuads*4*sizeof(Vector3)); _originalVertices = malloc(numQuads*4*sizeof(Vec3));
_texCoordinates = malloc(numQuads*4*sizeof(Vector2)); _texCoordinates = malloc(numQuads*4*sizeof(Vec2));
_indices = (GLushort*)malloc(numQuads*6*sizeof(GLushort)); _indices = (GLushort*)malloc(numQuads*6*sizeof(GLushort));
GLfloat *vertArray = (GLfloat*)_vertices; GLfloat *vertArray = (GLfloat*)_vertices;
@ -643,7 +643,7 @@ void TiledGrid3D::calculateVertexPoints(void)
memcpy(_originalVertices, _vertices, numQuads * 12 * sizeof(GLfloat)); memcpy(_originalVertices, _vertices, numQuads * 12 * sizeof(GLfloat));
} }
void TiledGrid3D::setTile(const Vector2& pos, const Quad3& coords) void TiledGrid3D::setTile(const Vec2& pos, const Quad3& coords)
{ {
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3; int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
@ -651,7 +651,7 @@ void TiledGrid3D::setTile(const Vector2& pos, const Quad3& coords)
memcpy(&vertArray[idx], &coords, sizeof(Quad3)); memcpy(&vertArray[idx], &coords, sizeof(Quad3));
} }
Quad3 TiledGrid3D::getOriginalTile(const Vector2& pos) const Quad3 TiledGrid3D::getOriginalTile(const Vec2& pos) const
{ {
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3; int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
@ -663,7 +663,7 @@ Quad3 TiledGrid3D::getOriginalTile(const Vector2& pos) const
return ret; return ret;
} }
Quad3 TiledGrid3D::getTile(const Vector2& pos) const Quad3 TiledGrid3D::getTile(const Vec2& pos) const
{ {
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3; int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;

View File

@ -77,8 +77,8 @@ public:
inline void setGridSize(const Size& gridSize) { _gridSize = gridSize; } inline void setGridSize(const Size& gridSize) { _gridSize = gridSize; }
/** pixels between the grids */ /** pixels between the grids */
inline const Vector2& getStep(void) const { return _step; } inline const Vec2& getStep(void) const { return _step; }
inline void setStep(const Vector2& step) { _step = step; } inline void setStep(const Vec2& step) { _step = step; }
/** is texture flipped */ /** is texture flipped */
inline bool isTextureFlipped(void) const { return _isTextureFlipped; } inline bool isTextureFlipped(void) const { return _isTextureFlipped; }
@ -97,7 +97,7 @@ protected:
int _reuseGrid; int _reuseGrid;
Size _gridSize; Size _gridSize;
Texture2D *_texture; Texture2D *_texture;
Vector2 _step; Vec2 _step;
Grabber *_grabber; Grabber *_grabber;
bool _isTextureFlipped; bool _isTextureFlipped;
GLProgram* _shaderProgram; GLProgram* _shaderProgram;
@ -131,28 +131,28 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
Vector3 getVertex(const Vector2& pos) const; Vec3 getVertex(const Vec2& pos) const;
/** @deprecated Use getVertex() instead /** @deprecated Use getVertex() instead
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
CC_DEPRECATED_ATTRIBUTE Vector3 vertex(const Vector2& pos) const { return getVertex(pos); } CC_DEPRECATED_ATTRIBUTE Vec3 vertex(const Vec2& pos) const { return getVertex(pos); }
/** returns the original (non-transformed) vertex at a given position /** returns the original (non-transformed) vertex at a given position
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
Vector3 getOriginalVertex(const Vector2& pos) const; Vec3 getOriginalVertex(const Vec2& pos) const;
/** @deprecated Use getOriginalVertex() instead /** @deprecated Use getOriginalVertex() instead
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
CC_DEPRECATED_ATTRIBUTE Vector3 originalVertex(const Vector2& pos) const { return getOriginalVertex(pos); } CC_DEPRECATED_ATTRIBUTE Vec3 originalVertex(const Vec2& pos) const { return getOriginalVertex(pos); }
/** sets a new vertex at a given position /** sets a new vertex at a given position
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
void setVertex(const Vector2& pos, const Vector3& vertex); void setVertex(const Vec2& pos, const Vec3& vertex);
// Overrides // Overrides
virtual void blit() override; virtual void blit() override;
@ -194,28 +194,28 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
Quad3 getTile(const Vector2& pos) const; Quad3 getTile(const Vec2& pos) const;
/** returns the tile at the given position /** returns the tile at the given position
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Vector2& pos) const { return getTile(pos); } CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Vec2& pos) const { return getTile(pos); }
/** returns the original tile (untransformed) at the given position /** returns the original tile (untransformed) at the given position
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
Quad3 getOriginalTile(const Vector2& pos) const; Quad3 getOriginalTile(const Vec2& pos) const;
/** returns the original tile (untransformed) at the given position /** returns the original tile (untransformed) at the given position
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Vector2& pos) const { return getOriginalTile(pos); } CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Vec2& pos) const { return getOriginalTile(pos); }
/** sets a new tile /** sets a new tile
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
void setTile(const Vector2& pos, const Quad3& coords); void setTile(const Vec2& pos, const Quad3& coords);
// Overrides // Overrides
virtual void blit() override; virtual void blit() override;

View File

@ -129,7 +129,7 @@ Label* Label::createWithTTF(const TTFConfig& ttfConfig, const std::string& text,
return nullptr; return nullptr;
} }
Label* Label::createWithBMFont(const std::string& bmfontFilePath, const std::string& text,const TextHAlignment& alignment /* = TextHAlignment::LEFT */, int maxLineWidth /* = 0 */, const Vector2& imageOffset /* = Vector2::ZERO */) Label* Label::createWithBMFont(const std::string& bmfontFilePath, const std::string& text,const TextHAlignment& alignment /* = TextHAlignment::LEFT */, int maxLineWidth /* = 0 */, const Vec2& imageOffset /* = Vec2::ZERO */)
{ {
auto ret = new Label(nullptr,alignment); auto ret = new Label(nullptr,alignment);
@ -262,7 +262,7 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
, _insideBounds(true) , _insideBounds(true)
, _effectColorF(Color4F::BLACK) , _effectColorF(Color4F::BLACK)
{ {
setAnchorPoint(Vector2::ANCHOR_MIDDLE); setAnchorPoint(Vec2::ANCHOR_MIDDLE);
reset(); reset();
#if CC_ENABLE_CACHE_TEXTURE_DATA #if CC_ENABLE_CACHE_TEXTURE_DATA
@ -395,7 +395,7 @@ void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false *
_reusedLetter = Sprite::createWithTexture(_fontAtlas->getTexture(0)); _reusedLetter = Sprite::createWithTexture(_fontAtlas->getTexture(0));
_reusedLetter->setOpacityModifyRGB(_isOpacityModifyRGB); _reusedLetter->setOpacityModifyRGB(_isOpacityModifyRGB);
_reusedLetter->retain(); _reusedLetter->retain();
_reusedLetter->setAnchorPoint(Vector2::ANCHOR_TOP_LEFT); _reusedLetter->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
_reusedLetter->setBatchNode(this); _reusedLetter->setBatchNode(this);
} }
else else
@ -454,7 +454,7 @@ bool Label::setTTFConfig(const TTFConfig& ttfConfig)
return true; return true;
} }
bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vector2& imageOffset /* = Vector2::ZERO */) bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset /* = Vec2::ZERO */)
{ {
FontAtlas *newAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath,imageOffset); FontAtlas *newAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath,imageOffset);
@ -597,8 +597,8 @@ void Label::alignText()
for (auto index = _batchNodes.size(); index < textures.size(); ++index) for (auto index = _batchNodes.size(); index < textures.size(); ++index)
{ {
auto batchNode = SpriteBatchNode::createWithTexture(textures[index]); auto batchNode = SpriteBatchNode::createWithTexture(textures[index]);
batchNode->setAnchorPoint(Vector2::ANCHOR_TOP_LEFT); batchNode->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
batchNode->setPosition(Vector2::ZERO); batchNode->setPosition(Vec2::ZERO);
Node::addChild(batchNode,0,Node::INVALID_TAG); Node::addChild(batchNode,0,Node::INVALID_TAG);
_batchNodes.push_back(batchNode); _batchNodes.push_back(batchNode);
} }
@ -680,7 +680,7 @@ void Label::updateQuads()
} }
} }
bool Label::recordLetterInfo(const cocos2d::Vector2& point,const FontLetterDefinition& letterDef, int spriteIndex) bool Label::recordLetterInfo(const cocos2d::Vec2& point,const FontLetterDefinition& letterDef, int spriteIndex)
{ {
if (static_cast<std::size_t>(spriteIndex) >= _lettersInfo.size()) if (static_cast<std::size_t>(spriteIndex) >= _lettersInfo.size())
{ {
@ -809,7 +809,7 @@ void Label::setFontScale(float fontScale)
Node::setScale(_fontScale); Node::setScale(_fontScale);
} }
void Label::onDraw(const Matrix& transform, bool transformUpdated) void Label::onDraw(const Mat4& transform, bool transformUpdated)
{ {
CC_PROFILER_START("Label - draw"); CC_PROFILER_START("Label - draw");
@ -877,7 +877,7 @@ void Label::drawShadowWithoutBlur()
setColor(oldColor); setColor(oldColor);
} }
void Label::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void Label::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
// Don't do calculate the culling if the transform was not updated // Don't do calculate the culling if the transform was not updated
_insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds; _insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
@ -897,7 +897,7 @@ void Label::createSpriteWithFontDefinition()
texture->initWithString(_originalUTF8String.c_str(),_fontDefinition); texture->initWithString(_originalUTF8String.c_str(),_fontDefinition);
_textSprite = Sprite::createWithTexture(texture); _textSprite = Sprite::createWithTexture(texture);
_textSprite->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); _textSprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
this->setContentSize(_textSprite->getContentSize()); this->setContentSize(_textSprite->getContentSize());
texture->release(); texture->release();
if (_blendFuncDirty) if (_blendFuncDirty)
@ -1035,7 +1035,7 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
{ {
_shadowNode->setBlendFunc(_blendFunc); _shadowNode->setBlendFunc(_blendFunc);
} }
_shadowNode->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); _shadowNode->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
_shadowNode->setColor(_shadowColor); _shadowNode->setColor(_shadowColor);
_shadowNode->setOpacity(_shadowOpacity * _displayedOpacity); _shadowNode->setOpacity(_shadowOpacity * _displayedOpacity);
_shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height); _shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height);
@ -1049,7 +1049,7 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
_textSprite->visit(renderer, _modelViewTransform, parentTransformUpdated); _textSprite->visit(renderer, _modelViewTransform, parentTransformUpdated);
} }
void Label::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
{ {
if (! _visible || _originalUTF8String.empty()) if (! _visible || _originalUTF8String.empty())
{ {
@ -1088,7 +1088,7 @@ void Label::visit(Renderer *renderer, const Matrix &parentTransform, bool parent
_transformUpdated = false; _transformUpdated = false;
// IMPORTANT: // IMPORTANT:
// To ease the migration to v3.0, we still support the Matrix stack, // To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it // but it is deprecated and your code should not rely on it
Director* director = Director::getInstance(); Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack"); CCASSERT(nullptr != director, "Director is null when seting matrix stack");
@ -1161,7 +1161,7 @@ Sprite * Label::getLetter(int letterIndex)
sp = Sprite::createWithTexture(_fontAtlas->getTexture(letter.def.textureID),uvRect); sp = Sprite::createWithTexture(_fontAtlas->getTexture(letter.def.textureID),uvRect);
sp->setBatchNode(_batchNodes[letter.def.textureID]); sp->setBatchNode(_batchNodes[letter.def.textureID]);
sp->setPosition(Vector2(letter.position.x + uvRect.size.width / 2, sp->setPosition(Vec2(letter.position.x + uvRect.size.width / 2,
letter.position.y - uvRect.size.height / 2)); letter.position.y - uvRect.size.height / 2));
sp->setOpacity(_realOpacity); sp->setOpacity(_realOpacity);

View File

@ -104,7 +104,7 @@ public:
/* Creates a label with an FNT file,an initial string,horizontal alignment,max line width and the offset of image*/ /* Creates a label with an FNT file,an initial string,horizontal alignment,max line width and the offset of image*/
static Label* createWithBMFont(const std::string& bmfontFilePath, const std::string& text, static Label* createWithBMFont(const std::string& bmfontFilePath, const std::string& text,
const TextHAlignment& alignment = TextHAlignment::LEFT, int maxLineWidth = 0, const TextHAlignment& alignment = TextHAlignment::LEFT, int maxLineWidth = 0,
const Vector2& imageOffset = Vector2::ZERO); const Vec2& imageOffset = Vec2::ZERO);
static Label * createWithCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap); static Label * createWithCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
static Label * createWithCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap); static Label * createWithCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap);
@ -114,7 +114,7 @@ public:
virtual bool setTTFConfig(const TTFConfig& ttfConfig); virtual bool setTTFConfig(const TTFConfig& ttfConfig);
virtual const TTFConfig& getTTFConfig() const { return _fontConfig;} virtual const TTFConfig& getTTFConfig() const { return _fontConfig;}
virtual bool setBMFontFilePath(const std::string& bmfontFilePath, const Vector2& imageOffset = Vector2::ZERO); virtual bool setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset = Vec2::ZERO);
const std::string& getBMFontFilePath() const { return _bmFontPath;} const std::string& getBMFontFilePath() const { return _bmFontPath;}
virtual bool setCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap); virtual bool setCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
@ -237,8 +237,8 @@ public:
virtual Rect getBoundingBox() const override; virtual Rect getBoundingBox() const override;
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
CC_DEPRECATED_ATTRIBUTE static Label* create(const std::string& text, const std::string& font, float fontSize, CC_DEPRECATED_ATTRIBUTE static Label* create(const std::string& text, const std::string& font, float fontSize,
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT, const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
@ -248,13 +248,13 @@ public:
CC_DEPRECATED_ATTRIBUTE const FontDefinition& getFontDefinition() const { return _fontDefinition; } CC_DEPRECATED_ATTRIBUTE const FontDefinition& getFontDefinition() const { return _fontDefinition; }
protected: protected:
void onDraw(const Matrix& transform, bool transformUpdated); void onDraw(const Mat4& transform, bool transformUpdated);
struct LetterInfo struct LetterInfo
{ {
FontLetterDefinition def; FontLetterDefinition def;
Vector2 position; Vec2 position;
Size contentSize; Size contentSize;
int atlasIndex; int atlasIndex;
}; };
@ -279,7 +279,7 @@ protected:
virtual void setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled = false, bool useA8Shader = false); virtual void setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled = false, bool useA8Shader = false);
bool recordLetterInfo(const cocos2d::Vector2& point,const FontLetterDefinition& letterDef, int spriteIndex); bool recordLetterInfo(const cocos2d::Vec2& point,const FontLetterDefinition& letterDef, int spriteIndex);
bool recordPlaceholderInfo(int spriteIndex); bool recordPlaceholderInfo(int spriteIndex);
void setFontScale(float fontScale); void setFontScale(float fontScale);
@ -363,7 +363,7 @@ protected:
bool _shadowEnabled; bool _shadowEnabled;
Size _shadowOffset; Size _shadowOffset;
int _shadowBlurRadius; int _shadowBlurRadius;
Matrix _shadowTransform; Mat4 _shadowTransform;
Color3B _shadowColor; Color3B _shadowColor;
float _shadowOpacity; float _shadowOpacity;
Sprite* _shadowNode; Sprite* _shadowNode;

View File

@ -249,7 +249,7 @@ void LabelAtlas::updateColor()
//CCLabelAtlas - draw //CCLabelAtlas - draw
#if CC_LABELATLAS_DEBUG_DRAW #if CC_LABELATLAS_DEBUG_DRAW
void LabelAtlas::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void LabelAtlas::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
AtlasNode::draw(renderer, transform, transformUpdated); AtlasNode::draw(renderer, transform, transformUpdated);
@ -258,7 +258,7 @@ void LabelAtlas::draw(Renderer *renderer, const Matrix &transform, bool transfor
renderer->addCommand(&_customDebugDrawCommand); renderer->addCommand(&_customDebugDrawCommand);
} }
void LabelAtlas::drawDebugData(const Matrix& transform, bool transformUpdated) void LabelAtlas::drawDebugData(const Mat4& transform, bool transformUpdated)
{ {
Director* director = Director::getInstance(); Director* director = Director::getInstance();
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
@ -266,12 +266,12 @@ void LabelAtlas::drawDebugData(const Matrix& transform, bool transformUpdated)
auto size = getContentSize(); auto size = getContentSize();
Vector2 vertices[4]= Vec2 vertices[4]=
{ {
Vector2::ZERO, Vec2::ZERO,
Vector2(size.width, 0), Vec2(size.width, 0),
Vector2(size.width, size.height), Vec2(size.width, size.height),
Vector2(0, size.height) Vec2(0, size.height)
}; };
DrawPrimitives::drawPoly(vertices, 4, true); DrawPrimitives::drawPoly(vertices, 4, true);

View File

@ -84,7 +84,7 @@ public:
virtual std::string getDescription() const override; virtual std::string getDescription() const override;
#if CC_LABELATLAS_DEBUG_DRAW #if CC_LABELATLAS_DEBUG_DRAW
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
#endif #endif
protected: protected:
@ -100,7 +100,7 @@ protected:
#if CC_LABELATLAS_DEBUG_DRAW #if CC_LABELATLAS_DEBUG_DRAW
CustomCommand _customDebugDrawCommand; CustomCommand _customDebugDrawCommand;
void drawDebugData(const Matrix& transform, bool transformUpdated); void drawDebugData(const Mat4& transform, bool transformUpdated);
#endif #endif
// string to render // string to render

View File

@ -65,7 +65,7 @@ LabelBMFont * LabelBMFont::create()
} }
//LabelBMFont - Creation & Init //LabelBMFont - Creation & Init
LabelBMFont *LabelBMFont::create(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vector2& imageOffset /* = Vector2::ZERO */) LabelBMFont *LabelBMFont::create(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vec2& imageOffset /* = Vec2::ZERO */)
{ {
LabelBMFont *ret = new LabelBMFont(); LabelBMFont *ret = new LabelBMFont();
if(ret && ret->initWithString(str, fntFile, width, alignment,imageOffset)) if(ret && ret->initWithString(str, fntFile, width, alignment,imageOffset))
@ -77,7 +77,7 @@ LabelBMFont *LabelBMFont::create(const std::string& str, const std::string& fntF
return nullptr; return nullptr;
} }
bool LabelBMFont::initWithString(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vector2& imageOffset /* = Vector2::ZERO */) bool LabelBMFont::initWithString(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vec2& imageOffset /* = Vec2::ZERO */)
{ {
if (_label->setBMFontFilePath(fntFile,imageOffset)) if (_label->setBMFontFilePath(fntFile,imageOffset))
{ {
@ -95,9 +95,9 @@ bool LabelBMFont::initWithString(const std::string& str, const std::string& fntF
LabelBMFont::LabelBMFont() LabelBMFont::LabelBMFont()
{ {
_label = Label::create(); _label = Label::create();
_label->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); _label->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
this->addChild(_label); this->addChild(_label);
this->setAnchorPoint(Vector2::ANCHOR_MIDDLE); this->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
_cascadeOpacityEnabled = true; _cascadeOpacityEnabled = true;
} }
@ -152,7 +152,7 @@ void LabelBMFont::setLineBreakWithoutSpace( bool breakWithoutSpace )
} }
// LabelBMFont - FntFile // LabelBMFont - FntFile
void LabelBMFont::setFntFile(const std::string& fntFile, const Vector2& imageOffset /* = Vector2::ZERO */) void LabelBMFont::setFntFile(const std::string& fntFile, const Vec2& imageOffset /* = Vec2::ZERO */)
{ {
if (_fntFile.compare(fntFile) != 0) if (_fntFile.compare(fntFile) != 0)
{ {
@ -207,7 +207,7 @@ Rect LabelBMFont::getBoundingBox() const
return _label->getBoundingBox(); return _label->getBoundingBox();
} }
#if CC_LABELBMFONT_DEBUG_DRAW #if CC_LABELBMFONT_DEBUG_DRAW
void LabelBMFont::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void LabelBMFont::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
Node::draw(renderer, transform, transformUpdated); Node::draw(renderer, transform, transformUpdated);
@ -216,7 +216,7 @@ void LabelBMFont::draw(Renderer *renderer, const Matrix &transform, bool transfo
renderer->addCommand(&_customDebugDrawCommand); renderer->addCommand(&_customDebugDrawCommand);
} }
void LabelBMFont::drawDebugData(const Matrix& transform, bool transformUpdated) void LabelBMFont::drawDebugData(const Mat4& transform, bool transformUpdated)
{ {
Director* director = Director::getInstance(); Director* director = Director::getInstance();
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
@ -224,12 +224,12 @@ void LabelBMFont::drawDebugData(const Matrix& transform, bool transformUpdated)
auto size = getContentSize(); auto size = getContentSize();
Vector2 vertices[4]= Vec2 vertices[4]=
{ {
Vector2::ZERO, Vec2::ZERO,
Vector2(size.width, 0), Vec2(size.width, 0),
Vector2(size.width, size.height), Vec2(size.width, size.height),
Vector2(0, size.height) Vec2(0, size.height)
}; };
DrawPrimitives::drawPoly(vertices, 4, true); DrawPrimitives::drawPoly(vertices, 4, true);

View File

@ -85,14 +85,14 @@ public:
virtual ~LabelBMFont(); virtual ~LabelBMFont();
/** creates a bitmap font atlas with an initial string and the FNT file */ /** creates a bitmap font atlas with an initial string and the FNT file */
static LabelBMFont * create(const std::string& str, const std::string& fntFile, float width = 0, TextHAlignment alignment = TextHAlignment::LEFT,const Vector2& imageOffset = Vector2::ZERO); static LabelBMFont * create(const std::string& str, const std::string& fntFile, float width = 0, TextHAlignment alignment = TextHAlignment::LEFT,const Vec2& imageOffset = Vec2::ZERO);
/** Creates an label. /** Creates an label.
*/ */
static LabelBMFont * create(); static LabelBMFont * create();
/** init a bitmap font atlas with an initial string and the FNT file */ /** init a bitmap font atlas with an initial string and the FNT file */
bool initWithString(const std::string& str, const std::string& fntFile, float width = 0, TextHAlignment alignment = TextHAlignment::LEFT,const Vector2& imageOffset = Vector2::ZERO); bool initWithString(const std::string& str, const std::string& fntFile, float width = 0, TextHAlignment alignment = TextHAlignment::LEFT,const Vec2& imageOffset = Vec2::ZERO);
// super method // super method
virtual void setString(const std::string& newString) override; virtual void setString(const std::string& newString) override;
@ -107,7 +107,7 @@ public:
virtual bool isOpacityModifyRGB() const; virtual bool isOpacityModifyRGB() const;
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB); virtual void setOpacityModifyRGB(bool isOpacityModifyRGB);
void setFntFile(const std::string& fntFile, const Vector2& imageOffset = Vector2::ZERO); void setFntFile(const std::string& fntFile, const Vec2& imageOffset = Vec2::ZERO);
const std::string& getFntFile() const; const std::string& getFntFile() const;
virtual void setBlendFunc(const BlendFunc &blendFunc) override; virtual void setBlendFunc(const BlendFunc &blendFunc) override;
@ -124,13 +124,13 @@ public:
virtual std::string getDescription() const override; virtual std::string getDescription() const override;
#if CC_LABELBMFONT_DEBUG_DRAW #if CC_LABELBMFONT_DEBUG_DRAW
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
#endif #endif
private: private:
#if CC_LABELBMFONT_DEBUG_DRAW #if CC_LABELBMFONT_DEBUG_DRAW
CustomCommand _customDebugDrawCommand; CustomCommand _customDebugDrawCommand;
void drawDebugData(const Matrix& transform, bool transformUpdated); void drawDebugData(const Mat4& transform, bool transformUpdated);
#endif #endif
// name of fntFile // name of fntFile

View File

@ -39,9 +39,9 @@ NS_CC_BEGIN
LabelTTF::LabelTTF() LabelTTF::LabelTTF()
{ {
_renderLabel = Label::create(); _renderLabel = Label::create();
_renderLabel->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); _renderLabel->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
this->addChild(_renderLabel); this->addChild(_renderLabel);
this->setAnchorPoint(Vector2::ANCHOR_MIDDLE); this->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
_contentDirty = false; _contentDirty = false;
_cascadeColorEnabled = true; _cascadeColorEnabled = true;
@ -262,7 +262,7 @@ void LabelTTF::setFlippedY(bool flippedY)
} }
} }
void LabelTTF::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) void LabelTTF::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
{ {
if (_contentDirty) if (_contentDirty)
{ {

View File

@ -150,7 +150,7 @@ public:
* @lua NA * @lua NA
*/ */
virtual std::string getDescription() const override; virtual std::string getDescription() const override;
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual const Size& getContentSize() const override; virtual const Size& getContentSize() const override;
protected: protected:
Label* _renderLabel; Label* _renderLabel;

View File

@ -310,7 +310,7 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
auto strWhole = theLabel->_currentUTF16String; auto strWhole = theLabel->_currentUTF16String;
auto fontAtlas = theLabel->_fontAtlas; auto fontAtlas = theLabel->_fontAtlas;
FontLetterDefinition tempDefinition; FontLetterDefinition tempDefinition;
Vector2 letterPosition; Vec2 letterPosition;
const auto& kernings = theLabel->_horizontalKernings; const auto& kernings = theLabel->_horizontalKernings;
float clipTop = 0; float clipTop = 0;

View File

@ -65,7 +65,7 @@ Layer::Layer()
, _swallowsTouches(true) , _swallowsTouches(true)
{ {
_ignoreAnchorPointForPosition = true; _ignoreAnchorPointForPosition = true;
setAnchorPoint(Vector2(0.5f, 0.5f)); setAnchorPoint(Vec2(0.5f, 0.5f));
} }
Layer::~Layer() Layer::~Layer()
@ -584,7 +584,7 @@ void LayerColor::updateColor()
} }
} }
void LayerColor::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void LayerColor::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
_customCommand.init(_globalZOrder); _customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this, transform, transformUpdated); _customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this, transform, transformUpdated);
@ -592,15 +592,15 @@ void LayerColor::draw(Renderer *renderer, const Matrix &transform, bool transfor
for(int i = 0; i < 4; ++i) for(int i = 0; i < 4; ++i)
{ {
Vector4 pos; Vec4 pos;
pos.x = _squareVertices[i].x; pos.y = _squareVertices[i].y; pos.z = _positionZ; pos.x = _squareVertices[i].x; pos.y = _squareVertices[i].y; pos.z = _positionZ;
pos.w = 1; pos.w = 1;
_modelViewTransform.transformVector(&pos); _modelViewTransform.transformVector(&pos);
_noMVPVertices[i] = Vector3(pos.x,pos.y,pos.z)/pos.w; _noMVPVertices[i] = Vec3(pos.x,pos.y,pos.z)/pos.w;
} }
} }
void LayerColor::onDraw(const Matrix& transform, bool transformUpdated) void LayerColor::onDraw(const Mat4& transform, bool transformUpdated)
{ {
getGLProgram()->use(); getGLProgram()->use();
getGLProgram()->setUniformsForBuiltins(transform); getGLProgram()->setUniformsForBuiltins(transform);
@ -610,7 +610,7 @@ void LayerColor::onDraw(const Matrix& transform, bool transformUpdated)
// Attributes // Attributes
// //
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(_noMVPVertices, 4 * sizeof(Vector3), 0); setGLBufferData(_noMVPVertices, 4 * sizeof(Vec3), 0);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(_squareColors, 4 * sizeof(Color4F), 1); setGLBufferData(_squareColors, 4 * sizeof(Color4F), 1);
@ -640,7 +640,7 @@ LayerGradient::LayerGradient()
, _endColor(Color4B::BLACK) , _endColor(Color4B::BLACK)
, _startOpacity(255) , _startOpacity(255)
, _endOpacity(255) , _endOpacity(255)
, _alongVector(Vector2(0, -1)) , _alongVector(Vec2(0, -1))
, _compressedInterpolation(true) , _compressedInterpolation(true)
{ {
@ -662,7 +662,7 @@ LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end)
return nullptr; return nullptr;
} }
LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end, const Vector2& v) LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end, const Vec2& v)
{ {
LayerGradient * layer = new LayerGradient(); LayerGradient * layer = new LayerGradient();
if( layer && layer->initWithColor(start, end, v)) if( layer && layer->initWithColor(start, end, v))
@ -695,10 +695,10 @@ bool LayerGradient::init()
bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end) bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end)
{ {
return initWithColor(start, end, Vector2(0, -1)); return initWithColor(start, end, Vec2(0, -1));
} }
bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end, const Vector2& v) bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end, const Vec2& v)
{ {
_endColor.r = end.r; _endColor.r = end.r;
_endColor.g = end.g; _endColor.g = end.g;
@ -722,7 +722,7 @@ void LayerGradient::updateColor()
return; return;
float c = sqrtf(2.0f); float c = sqrtf(2.0f);
Vector2 u = Vector2(_alongVector.x / h, _alongVector.y / h); Vec2 u = Vec2(_alongVector.x / h, _alongVector.y / h);
// Compressed Interpolation mode // Compressed Interpolation mode
if (_compressedInterpolation) if (_compressedInterpolation)
@ -812,13 +812,13 @@ GLubyte LayerGradient::getEndOpacity() const
return _endOpacity; return _endOpacity;
} }
void LayerGradient::setVector(const Vector2& var) void LayerGradient::setVector(const Vec2& var)
{ {
_alongVector = var; _alongVector = var;
updateColor(); updateColor();
} }
const Vector2& LayerGradient::getVector() const const Vec2& LayerGradient::getVector() const
{ {
return _alongVector; return _alongVector;
} }

View File

@ -270,7 +270,7 @@ public:
// //
// Overrides // Overrides
// //
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void setContentSize(const Size & var) override; virtual void setContentSize(const Size & var) override;
/** BlendFunction. Conforms to BlendProtocol protocol */ /** BlendFunction. Conforms to BlendProtocol protocol */
@ -299,15 +299,15 @@ CC_CONSTRUCTOR_ACCESS:
bool initWithColor(const Color4B& color); bool initWithColor(const Color4B& color);
protected: protected:
void onDraw(const Matrix& transform, bool transformUpdated); void onDraw(const Mat4& transform, bool transformUpdated);
virtual void updateColor() override; virtual void updateColor() override;
BlendFunc _blendFunc; BlendFunc _blendFunc;
Vector2 _squareVertices[4]; Vec2 _squareVertices[4];
Color4F _squareColors[4]; Color4F _squareColors[4];
CustomCommand _customCommand; CustomCommand _customCommand;
Vector3 _noMVPVertices[4]; Vec3 _noMVPVertices[4];
private: private:
CC_DISALLOW_COPY_AND_ASSIGN(LayerColor); CC_DISALLOW_COPY_AND_ASSIGN(LayerColor);
@ -345,7 +345,7 @@ public:
static LayerGradient* create(const Color4B& start, const Color4B& end); static LayerGradient* create(const Color4B& start, const Color4B& end);
/** Creates a full-screen Layer with a gradient between start and end in the direction of v. */ /** Creates a full-screen Layer with a gradient between start and end in the direction of v. */
static LayerGradient* create(const Color4B& start, const Color4B& end, const Vector2& v); static LayerGradient* create(const Color4B& start, const Color4B& end, const Vec2& v);
/** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors /** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors
Default: true Default: true
@ -376,9 +376,9 @@ public:
/** Sets the directional vector that will be used for the gradient. /** Sets the directional vector that will be used for the gradient.
The default value is vertical direction (0,-1). The default value is vertical direction (0,-1).
*/ */
void setVector(const Vector2& alongVector); void setVector(const Vec2& alongVector);
/** Returns the directional vector used for the gradient */ /** Returns the directional vector used for the gradient */
const Vector2& getVector() const; const Vec2& getVector() const;
virtual std::string getDescription() const override; virtual std::string getDescription() const override;
@ -397,7 +397,7 @@ CC_CONSTRUCTOR_ACCESS:
* @js init * @js init
* @lua init * @lua init
*/ */
bool initWithColor(const Color4B& start, const Color4B& end, const Vector2& v); bool initWithColor(const Color4B& start, const Color4B& end, const Vec2& v);
protected: protected:
virtual void updateColor() override; virtual void updateColor() override;
@ -406,7 +406,7 @@ protected:
Color3B _endColor; Color3B _endColor;
GLubyte _startOpacity; GLubyte _startOpacity;
GLubyte _endOpacity; GLubyte _endOpacity;
Vector2 _alongVector; Vec2 _alongVector;
bool _compressedInterpolation; bool _compressedInterpolation;
}; };

View File

@ -138,10 +138,10 @@ bool Menu::initWithArray(const Vector<MenuItem*>& arrayOfItems)
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
this->ignoreAnchorPointForPosition(true); this->ignoreAnchorPointForPosition(true);
setAnchorPoint(Vector2(0.5f, 0.5f)); setAnchorPoint(Vec2(0.5f, 0.5f));
this->setContentSize(s); this->setContentSize(s);
setPosition(Vector2(s.width/2, s.height/2)); setPosition(Vec2(s.width/2, s.height/2));
int z=0; int z=0;
@ -315,7 +315,7 @@ void Menu::alignItemsVerticallyWithPadding(float padding)
float y = height / 2.0f; float y = height / 2.0f;
for(const auto &child : _children) { for(const auto &child : _children) {
child->setPosition(Vector2(0, y - child->getContentSize().height * child->getScaleY() / 2.0f)); child->setPosition(Vec2(0, y - child->getContentSize().height * child->getScaleY() / 2.0f));
y -= child->getContentSize().height * child->getScaleY() + padding; y -= child->getContentSize().height * child->getScaleY() + padding;
} }
} }
@ -334,7 +334,7 @@ void Menu::alignItemsHorizontallyWithPadding(float padding)
float x = -width / 2.0f; float x = -width / 2.0f;
for(const auto &child : _children) { for(const auto &child : _children) {
child->setPosition(Vector2(x + child->getContentSize().width * child->getScaleX() / 2.0f, 0)); child->setPosition(Vec2(x + child->getContentSize().width * child->getScaleX() / 2.0f, 0));
x += child->getContentSize().width * child->getScaleX() + padding; x += child->getContentSize().width * child->getScaleX() + padding;
} }
} }
@ -413,7 +413,7 @@ void Menu::alignItemsInColumnsWithArray(const ValueVector& rows)
float tmp = child->getContentSize().height; float tmp = child->getContentSize().height;
rowHeight = (unsigned int)((rowHeight >= tmp || isnan(tmp)) ? rowHeight : tmp); rowHeight = (unsigned int)((rowHeight >= tmp || isnan(tmp)) ? rowHeight : tmp);
child->setPosition(Vector2(x - winSize.width / 2, child->setPosition(Vec2(x - winSize.width / 2,
y - child->getContentSize().height / 2)); y - child->getContentSize().height / 2));
x += w; x += w;
@ -514,7 +514,7 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns)
float tmp = child->getContentSize().width; float tmp = child->getContentSize().width;
columnWidth = (unsigned int)((columnWidth >= tmp || isnan(tmp)) ? columnWidth : tmp); columnWidth = (unsigned int)((columnWidth >= tmp || isnan(tmp)) ? columnWidth : tmp);
child->setPosition(Vector2(x + columnWidths[column] / 2, child->setPosition(Vec2(x + columnWidths[column] / 2,
y - winSize.height / 2)); y - winSize.height / 2));
y -= child->getContentSize().height + 10; y -= child->getContentSize().height + 10;
@ -533,7 +533,7 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns)
MenuItem* Menu::getItemForTouch(Touch *touch) MenuItem* Menu::getItemForTouch(Touch *touch)
{ {
Vector2 touchLocation = touch->getLocation(); Vec2 touchLocation = touch->getLocation();
if (!_children.empty()) if (!_children.empty())
{ {
@ -542,9 +542,9 @@ MenuItem* Menu::getItemForTouch(Touch *touch)
MenuItem* child = dynamic_cast<MenuItem*>(*iter); MenuItem* child = dynamic_cast<MenuItem*>(*iter);
if (child && child->isVisible() && child->isEnabled()) if (child && child->isVisible() && child->isEnabled())
{ {
Vector2 local = child->convertToNodeSpace(touchLocation); Vec2 local = child->convertToNodeSpace(touchLocation);
Rect r = child->rect(); Rect r = child->rect();
r.origin = Vector2::ZERO; r.origin = Vec2::ZERO;
if (r.containsPoint(local)) if (r.containsPoint(local))
{ {

View File

@ -90,7 +90,7 @@ bool MenuItem::initWithTarget(cocos2d::Ref *target, SEL_MenuHandler selector )
bool MenuItem::initWithCallback(const ccMenuCallback& callback) bool MenuItem::initWithCallback(const ccMenuCallback& callback)
{ {
setAnchorPoint(Vector2(0.5f, 0.5f)); setAnchorPoint(Vec2(0.5f, 0.5f));
_callback = callback; _callback = callback;
_enabled = true; _enabled = true;
_selected = false; _selected = false;
@ -179,7 +179,7 @@ void MenuItemLabel::setLabel(Node* var)
{ {
if (var) if (var)
{ {
var->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT); var->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
setContentSize(var->getContentSize()); setContentSize(var->getContentSize());
addChild(var); addChild(var);
} }
@ -483,7 +483,7 @@ void MenuItemSprite::setNormalImage(Node* image)
if (image) if (image)
{ {
addChild(image, 0, kNormalTag); addChild(image, 0, kNormalTag);
image->setAnchorPoint(Vector2(0, 0)); image->setAnchorPoint(Vec2(0, 0));
} }
if (_normalImage) if (_normalImage)
@ -504,7 +504,7 @@ void MenuItemSprite::setSelectedImage(Node* image)
if (image) if (image)
{ {
addChild(image, 0, kSelectedTag); addChild(image, 0, kSelectedTag);
image->setAnchorPoint(Vector2(0, 0)); image->setAnchorPoint(Vec2(0, 0));
} }
if (_selectedImage) if (_selectedImage)
@ -524,7 +524,7 @@ void MenuItemSprite::setDisabledImage(Node* image)
if (image) if (image)
{ {
addChild(image, 0, kDisableTag); addChild(image, 0, kDisableTag);
image->setAnchorPoint(Vector2(0, 0)); image->setAnchorPoint(Vec2(0, 0));
} }
if (_disabledImage) if (_disabledImage)
@ -935,7 +935,7 @@ void MenuItemToggle::setSelectedIndex(unsigned int index)
this->addChild(item, 0, kCurrentItem); this->addChild(item, 0, kCurrentItem);
Size s = item->getContentSize(); Size s = item->getContentSize();
this->setContentSize(s); this->setContentSize(s);
item->setPosition( Vector2( s.width/2, s.height/2 ) ); item->setPosition( Vec2( s.width/2, s.height/2 ) );
} }
} }

View File

@ -41,7 +41,7 @@ MotionStreak::MotionStreak()
, _startingPositionInitialized(false) , _startingPositionInitialized(false)
, _texture(nullptr) , _texture(nullptr)
, _blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED) , _blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED)
, _positionR(Vector2::ZERO) , _positionR(Vec2::ZERO)
, _stroke(0.0f) , _stroke(0.0f)
, _fadeDelta(0.0f) , _fadeDelta(0.0f)
, _minSeg(0.0f) , _minSeg(0.0f)
@ -102,12 +102,12 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture) bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture)
{ {
Node::setPosition(Vector2::ZERO); Node::setPosition(Vec2::ZERO);
setAnchorPoint(Vector2::ZERO); setAnchorPoint(Vec2::ZERO);
ignoreAnchorPointForPosition(true); ignoreAnchorPointForPosition(true);
_startingPositionInitialized = false; _startingPositionInitialized = false;
_positionR = Vector2::ZERO; _positionR = Vec2::ZERO;
_fastMode = true; _fastMode = true;
_minSeg = (minSeg == -1.0f) ? stroke/5.0f : minSeg; _minSeg = (minSeg == -1.0f) ? stroke/5.0f : minSeg;
_minSeg *= _minSeg; _minSeg *= _minSeg;
@ -118,9 +118,9 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co
_maxPoints = (int)(fade*60.0f)+2; _maxPoints = (int)(fade*60.0f)+2;
_nuPoints = 0; _nuPoints = 0;
_pointState = (float *)malloc(sizeof(float) * _maxPoints); _pointState = (float *)malloc(sizeof(float) * _maxPoints);
_pointVertexes = (Vector2*)malloc(sizeof(Vector2) * _maxPoints); _pointVertexes = (Vec2*)malloc(sizeof(Vec2) * _maxPoints);
_vertices = (Vector2*)malloc(sizeof(Vector2) * _maxPoints * 2); _vertices = (Vec2*)malloc(sizeof(Vec2) * _maxPoints * 2);
_texCoords = (Tex2F*)malloc(sizeof(Tex2F) * _maxPoints * 2); _texCoords = (Tex2F*)malloc(sizeof(Tex2F) * _maxPoints * 2);
_colorPointer = (GLubyte*)malloc(sizeof(GLubyte) * _maxPoints * 2 * 4); _colorPointer = (GLubyte*)malloc(sizeof(GLubyte) * _maxPoints * 2 * 4);
@ -137,7 +137,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co
return true; return true;
} }
void MotionStreak::setPosition(const Vector2& position) void MotionStreak::setPosition(const Vec2& position)
{ {
if (!_startingPositionInitialized) { if (!_startingPositionInitialized) {
_startingPositionInitialized = true; _startingPositionInitialized = true;
@ -154,7 +154,7 @@ void MotionStreak::setPosition(float x, float y)
_positionR.y = y; _positionR.y = y;
} }
const Vector2& MotionStreak::getPosition() const const Vec2& MotionStreak::getPosition() const
{ {
return _positionR; return _positionR;
} }
@ -373,7 +373,7 @@ void MotionStreak::reset()
_nuPoints = 0; _nuPoints = 0;
} }
void MotionStreak::onDraw(const Matrix &transform, bool transformUpdated) void MotionStreak::onDraw(const Mat4 &transform, bool transformUpdated)
{ {
getGLProgram()->use(); getGLProgram()->use();
getGLProgram()->setUniformsForBuiltins(transform); getGLProgram()->setUniformsForBuiltins(transform);
@ -385,7 +385,7 @@ void MotionStreak::onDraw(const Matrix &transform, bool transformUpdated)
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
// Size calculations from ::initWithFade // Size calculations from ::initWithFade
setGLBufferData(_vertices, (sizeof(Vector2) * _maxPoints * 2), 0); setGLBufferData(_vertices, (sizeof(Vec2) * _maxPoints * 2), 0);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(_texCoords, (sizeof(Tex2F) * _maxPoints * 2), 1); setGLBufferData(_texCoords, (sizeof(Tex2F) * _maxPoints * 2), 1);
@ -403,7 +403,7 @@ void MotionStreak::onDraw(const Matrix &transform, bool transformUpdated)
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _nuPoints*2); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _nuPoints*2);
} }
void MotionStreak::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void MotionStreak::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
if(_nuPoints <= 1) if(_nuPoints <= 1)
return; return;

View File

@ -73,9 +73,9 @@ public:
} }
// Overrides // Overrides
virtual void setPosition(const Vector2& position) override; virtual void setPosition(const Vec2& position) override;
virtual void setPosition(float x, float y) override; virtual void setPosition(float x, float y) override;
virtual const Vector2& getPosition() const override; virtual const Vec2& getPosition() const override;
virtual void getPosition(float* x, float* y) const override; virtual void getPosition(float* x, float* y) const override;
virtual void setPositionX(float x) override; virtual void setPositionX(float x) override;
virtual void setPositionY(float y) override; virtual void setPositionY(float y) override;
@ -85,7 +85,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
/** /**
* @js NA * @js NA
* @lua NA * @lua NA
@ -120,7 +120,7 @@ CC_CONSTRUCTOR_ACCESS:
protected: protected:
//renderer callback //renderer callback
void onDraw(const Matrix &transform, bool transformUpdated); void onDraw(const Mat4 &transform, bool transformUpdated);
bool _fastMode; bool _fastMode;
bool _startingPositionInitialized; bool _startingPositionInitialized;
@ -128,7 +128,7 @@ protected:
/** texture used for the motion streak */ /** texture used for the motion streak */
Texture2D* _texture; Texture2D* _texture;
BlendFunc _blendFunc; BlendFunc _blendFunc;
Vector2 _positionR; Vec2 _positionR;
float _stroke; float _stroke;
float _fadeDelta; float _fadeDelta;
@ -139,11 +139,11 @@ protected:
unsigned int _previousNuPoints; unsigned int _previousNuPoints;
/** Pointers */ /** Pointers */
Vector2* _pointVertexes; Vec2* _pointVertexes;
float* _pointState; float* _pointState;
// Opengl // Opengl
Vector2* _vertices; Vec2* _vertices;
GLubyte* _colorPointer; GLubyte* _colorPointer;
Tex2F* _texCoords; Tex2F* _texCoords;

View File

@ -81,11 +81,11 @@ Node::Node(void)
, _scaleY(1.0f) , _scaleY(1.0f)
, _scaleZ(1.0f) , _scaleZ(1.0f)
, _positionZ(0.0f) , _positionZ(0.0f)
, _position(Vector2::ZERO) , _position(Vec2::ZERO)
, _skewX(0.0f) , _skewX(0.0f)
, _skewY(0.0f) , _skewY(0.0f)
, _anchorPointInPoints(Vector2::ZERO) , _anchorPointInPoints(Vec2::ZERO)
, _anchorPoint(Vector2::ZERO) , _anchorPoint(Vec2::ZERO)
, _contentSize(Size::ZERO) , _contentSize(Size::ZERO)
, _useAdditionalTransform(false) , _useAdditionalTransform(false)
, _transformDirty(true) , _transformDirty(true)
@ -135,7 +135,7 @@ Node::Node(void)
ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine(); ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine();
_scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone; _scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone;
#endif #endif
_transform = _inverse = _additionalTransform = Matrix::IDENTITY; _transform = _inverse = _additionalTransform = Mat4::IDENTITY;
} }
Node::~Node() Node::~Node()
@ -277,7 +277,7 @@ float Node::getRotationSkewX() const
return _rotationZ_X; return _rotationZ_X;
} }
void Node::setRotation3D(const Vector3& rotation) void Node::setRotation3D(const Vec3& rotation)
{ {
if (_rotationX == rotation.x && if (_rotationX == rotation.x &&
_rotationY == rotation.y && _rotationY == rotation.y &&
@ -301,12 +301,12 @@ void Node::setRotation3D(const Vector3& rotation)
#endif #endif
} }
Vector3 Node::getRotation3D() const Vec3 Node::getRotation3D() const
{ {
// rotation Z is decomposed in 2 to simulate Skew for Flash animations // rotation Z is decomposed in 2 to simulate Skew for Flash animations
CCASSERT(_rotationZ_X == _rotationZ_Y, "_rotationZ_X != _rotationZ_Y"); CCASSERT(_rotationZ_X == _rotationZ_Y, "_rotationZ_X != _rotationZ_Y");
return Vector3(_rotationX,_rotationY,_rotationZ_X); return Vec3(_rotationX,_rotationY,_rotationZ_X);
} }
void Node::setRotationSkewX(float rotationX) void Node::setRotationSkewX(float rotationX)
@ -410,13 +410,13 @@ void Node::setScaleY(float scaleY)
/// position getter /// position getter
const Vector2& Node::getPosition() const const Vec2& Node::getPosition() const
{ {
return _position; return _position;
} }
/// position setter /// position setter
void Node::setPosition(const Vector2& position) void Node::setPosition(const Vec2& position)
{ {
if (_position.equals(position)) if (_position.equals(position))
return; return;
@ -441,18 +441,18 @@ void Node::getPosition(float* x, float* y) const
void Node::setPosition(float x, float y) void Node::setPosition(float x, float y)
{ {
setPosition(Vector2(x, y)); setPosition(Vec2(x, y));
} }
void Node::setPosition3D(const Vector3& position) void Node::setPosition3D(const Vec3& position)
{ {
_positionZ = position.z; _positionZ = position.z;
setPosition(Vector2(position.x, position.y)); setPosition(Vec2(position.x, position.y));
} }
Vector3 Node::getPosition3D() const Vec3 Node::getPosition3D() const
{ {
Vector3 ret; Vec3 ret;
ret.x = _position.x; ret.x = _position.x;
ret.y = _position.y; ret.y = _position.y;
ret.z = _positionZ; ret.z = _positionZ;
@ -466,7 +466,7 @@ float Node::getPositionX() const
void Node::setPositionX(float x) void Node::setPositionX(float x)
{ {
setPosition(Vector2(x, _position.y)); setPosition(Vec2(x, _position.y));
} }
float Node::getPositionY() const float Node::getPositionY() const
@ -476,7 +476,7 @@ float Node::getPositionY() const
void Node::setPositionY(float y) void Node::setPositionY(float y)
{ {
setPosition(Vector2(_position.x, y)); setPosition(Vec2(_position.x, y));
} }
float Node::getPositionZ() const float Node::getPositionZ() const
@ -519,21 +519,21 @@ void Node::setVisible(bool var)
} }
} }
const Vector2& Node::getAnchorPointInPoints() const const Vec2& Node::getAnchorPointInPoints() const
{ {
return _anchorPointInPoints; return _anchorPointInPoints;
} }
/// anchorPoint getter /// anchorPoint getter
const Vector2& Node::getAnchorPoint() const const Vec2& Node::getAnchorPoint() const
{ {
return _anchorPoint; return _anchorPoint;
} }
void Node::setAnchorPoint(const Vector2& point) void Node::setAnchorPoint(const Vec2& point)
{ {
#if CC_USE_PHYSICS #if CC_USE_PHYSICS
if (_physicsBody != nullptr && !point.equals(Vector2::ANCHOR_MIDDLE)) if (_physicsBody != nullptr && !point.equals(Vec2::ANCHOR_MIDDLE))
{ {
CCLOG("Node warning: This node has a physics body, the anchor must be in the middle, you cann't change this to other value."); CCLOG("Node warning: This node has a physics body, the anchor must be in the middle, you cann't change this to other value.");
return; return;
@ -543,7 +543,7 @@ void Node::setAnchorPoint(const Vector2& point)
if( ! point.equals(_anchorPoint)) if( ! point.equals(_anchorPoint))
{ {
_anchorPoint = point; _anchorPoint = point;
_anchorPointInPoints = Vector2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y ); _anchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
_transformUpdated = _transformDirty = _inverseDirty = true; _transformUpdated = _transformDirty = _inverseDirty = true;
} }
} }
@ -560,7 +560,7 @@ void Node::setContentSize(const Size & size)
{ {
_contentSize = size; _contentSize = size;
_anchorPointInPoints = Vector2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y ); _anchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
_transformUpdated = _transformDirty = _inverseDirty = true; _transformUpdated = _transformDirty = _inverseDirty = true;
} }
} }
@ -943,18 +943,18 @@ void Node::draw()
draw(renderer, _modelViewTransform, true); draw(renderer, _modelViewTransform, true);
} }
void Node::draw(Renderer* renderer, const Matrix &transform, bool transformUpdated) void Node::draw(Renderer* renderer, const Mat4 &transform, bool transformUpdated)
{ {
} }
void Node::visit() void Node::visit()
{ {
auto renderer = Director::getInstance()->getRenderer(); auto renderer = Director::getInstance()->getRenderer();
Matrix parentTransform = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); Mat4 parentTransform = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
visit(renderer, parentTransform, true); visit(renderer, parentTransform, true);
} }
void Node::visit(Renderer* renderer, const Matrix &parentTransform, bool parentTransformUpdated) void Node::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
{ {
// quick return if not visible. children won't be drawn. // quick return if not visible. children won't be drawn.
if (!_visible) if (!_visible)
@ -969,7 +969,7 @@ void Node::visit(Renderer* renderer, const Matrix &parentTransform, bool parentT
// IMPORTANT: // IMPORTANT:
// To ease the migration to v3.0, we still support the Matrix stack, // To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it // but it is deprecated and your code should not rely on it
Director* director = Director::getInstance(); Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack"); CCASSERT(nullptr != director, "Director is null when seting matrix stack");
@ -1008,9 +1008,9 @@ void Node::visit(Renderer* renderer, const Matrix &parentTransform, bool parentT
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
} }
Matrix Node::transform(const Matrix& parentTransform) Mat4 Node::transform(const Mat4& parentTransform)
{ {
Matrix ret = this->getNodeToParentTransform(); Mat4 ret = this->getNodeToParentTransform();
ret = parentTransform * ret; ret = parentTransform * ret;
return ret; return ret;
} }
@ -1338,7 +1338,7 @@ AffineTransform Node::getNodeToParentAffineTransform() const
return ret; return ret;
} }
const Matrix& Node::getNodeToParentTransform() const const Mat4& Node::getNodeToParentTransform() const
{ {
if (_transformDirty) if (_transformDirty)
{ {
@ -1373,7 +1373,7 @@ const Matrix& Node::getNodeToParentTransform() const
// optimization: // optimization:
// inline anchor point calculation if skew is not needed // inline anchor point calculation if skew is not needed
// Adjusted transform calculation for rotational skew // Adjusted transform calculation for rotational skew
if (! needsSkewMatrix && !_anchorPointInPoints.equals(Vector2::ZERO)) if (! needsSkewMatrix && !_anchorPointInPoints.equals(Vec2::ZERO))
{ {
x += cy * -_anchorPointInPoints.x * _scaleX + -sx * -_anchorPointInPoints.y * _scaleY; x += cy * -_anchorPointInPoints.x * _scaleX + -sx * -_anchorPointInPoints.y * _scaleY;
y += sy * -_anchorPointInPoints.x * _scaleX + cx * -_anchorPointInPoints.y * _scaleY; y += sy * -_anchorPointInPoints.x * _scaleX + cx * -_anchorPointInPoints.y * _scaleY;
@ -1394,13 +1394,13 @@ const Matrix& Node::getNodeToParentTransform() const
// FIX ME: Expensive operation. // FIX ME: Expensive operation.
// FIX ME: It should be done together with the rotationZ // FIX ME: It should be done together with the rotationZ
if(_rotationY) { if(_rotationY) {
Matrix rotY; Mat4 rotY;
Matrix::createRotationY(CC_DEGREES_TO_RADIANS(_rotationY), &rotY); Mat4::createRotationY(CC_DEGREES_TO_RADIANS(_rotationY), &rotY);
_transform = _transform * rotY; _transform = _transform * rotY;
} }
if(_rotationX) { if(_rotationX) {
Matrix rotX; Mat4 rotX;
Matrix::createRotationX(CC_DEGREES_TO_RADIANS(_rotationX), &rotX); Mat4::createRotationX(CC_DEGREES_TO_RADIANS(_rotationX), &rotX);
_transform = _transform * rotX; _transform = _transform * rotX;
} }
@ -1408,7 +1408,7 @@ const Matrix& Node::getNodeToParentTransform() const
// If skew is needed, apply skew and then anchor point // If skew is needed, apply skew and then anchor point
if (needsSkewMatrix) if (needsSkewMatrix)
{ {
Matrix skewMatrix(1, (float)tanf(CC_DEGREES_TO_RADIANS(_skewY)), 0, 0, Mat4 skewMatrix(1, (float)tanf(CC_DEGREES_TO_RADIANS(_skewY)), 0, 0,
(float)tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1, 0, 0, (float)tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 0, 1); 0, 0, 0, 1);
@ -1416,9 +1416,9 @@ const Matrix& Node::getNodeToParentTransform() const
_transform = _transform * skewMatrix; _transform = _transform * skewMatrix;
// adjust anchor point // adjust anchor point
if (!_anchorPointInPoints.equals(Vector2::ZERO)) if (!_anchorPointInPoints.equals(Vec2::ZERO))
{ {
// XXX: Argh, Matrix needs a "translate" method. // XXX: Argh, Mat4 needs a "translate" method.
// XXX: Although this is faster than multiplying a vec4 * mat4 // XXX: Although this is faster than multiplying a vec4 * mat4
_transform.m[12] += _transform.m[0] * -_anchorPointInPoints.x + _transform.m[4] * -_anchorPointInPoints.y; _transform.m[12] += _transform.m[0] * -_anchorPointInPoints.x + _transform.m[4] * -_anchorPointInPoints.y;
_transform.m[13] += _transform.m[1] * -_anchorPointInPoints.x + _transform.m[5] * -_anchorPointInPoints.y; _transform.m[13] += _transform.m[1] * -_anchorPointInPoints.x + _transform.m[5] * -_anchorPointInPoints.y;
@ -1436,7 +1436,7 @@ const Matrix& Node::getNodeToParentTransform() const
return _transform; return _transform;
} }
void Node::setNodeToParentTransform(const Matrix& transform) void Node::setNodeToParentTransform(const Mat4& transform)
{ {
_transform = transform; _transform = transform;
_transformDirty = false; _transformDirty = false;
@ -1445,12 +1445,12 @@ void Node::setNodeToParentTransform(const Matrix& transform)
void Node::setAdditionalTransform(const AffineTransform& additionalTransform) void Node::setAdditionalTransform(const AffineTransform& additionalTransform)
{ {
Matrix tmp; Mat4 tmp;
CGAffineToGL(additionalTransform, tmp.m); CGAffineToGL(additionalTransform, tmp.m);
setAdditionalTransform(&tmp); setAdditionalTransform(&tmp);
} }
void Node::setAdditionalTransform(Matrix* additionalTransform) void Node::setAdditionalTransform(Mat4* additionalTransform)
{ {
if(additionalTransform == nullptr) { if(additionalTransform == nullptr) {
_useAdditionalTransform = false; _useAdditionalTransform = false;
@ -1465,13 +1465,13 @@ void Node::setAdditionalTransform(Matrix* additionalTransform)
AffineTransform Node::getParentToNodeAffineTransform() const AffineTransform Node::getParentToNodeAffineTransform() const
{ {
AffineTransform ret; AffineTransform ret;
Matrix ret4 = getParentToNodeTransform(); Mat4 ret4 = getParentToNodeTransform();
GLToCGAffine(ret4.m,&ret); GLToCGAffine(ret4.m,&ret);
return ret; return ret;
} }
const Matrix& Node::getParentToNodeTransform() const const Mat4& Node::getParentToNodeTransform() const
{ {
if ( _inverseDirty ) { if ( _inverseDirty ) {
_inverse = _transform.getInversed(); _inverse = _transform.getInversed();
@ -1492,9 +1492,9 @@ AffineTransform Node::getNodeToWorldAffineTransform() const
return t; return t;
} }
Matrix Node::getNodeToWorldTransform() const Mat4 Node::getNodeToWorldTransform() const
{ {
Matrix t = this->getNodeToParentTransform(); Mat4 t = this->getNodeToParentTransform();
for (Node *p = _parent; p != nullptr; p = p->getParent()) for (Node *p = _parent; p != nullptr; p = p->getParent())
{ {
@ -1509,59 +1509,59 @@ AffineTransform Node::getWorldToNodeAffineTransform() const
return AffineTransformInvert(this->getNodeToWorldAffineTransform()); return AffineTransformInvert(this->getNodeToWorldAffineTransform());
} }
Matrix Node::getWorldToNodeTransform() const Mat4 Node::getWorldToNodeTransform() const
{ {
return getNodeToWorldTransform().getInversed(); return getNodeToWorldTransform().getInversed();
} }
Vector2 Node::convertToNodeSpace(const Vector2& worldPoint) const Vec2 Node::convertToNodeSpace(const Vec2& worldPoint) const
{ {
Matrix tmp = getWorldToNodeTransform(); Mat4 tmp = getWorldToNodeTransform();
Vector3 vec3(worldPoint.x, worldPoint.y, 0); Vec3 vec3(worldPoint.x, worldPoint.y, 0);
Vector3 ret; Vec3 ret;
tmp.transformPoint(vec3,&ret); tmp.transformPoint(vec3,&ret);
return Vector2(ret.x, ret.y); return Vec2(ret.x, ret.y);
} }
Vector2 Node::convertToWorldSpace(const Vector2& nodePoint) const Vec2 Node::convertToWorldSpace(const Vec2& nodePoint) const
{ {
Matrix tmp = getNodeToWorldTransform(); Mat4 tmp = getNodeToWorldTransform();
Vector3 vec3(nodePoint.x, nodePoint.y, 0); Vec3 vec3(nodePoint.x, nodePoint.y, 0);
Vector3 ret; Vec3 ret;
tmp.transformPoint(vec3,&ret); tmp.transformPoint(vec3,&ret);
return Vector2(ret.x, ret.y); return Vec2(ret.x, ret.y);
} }
Vector2 Node::convertToNodeSpaceAR(const Vector2& worldPoint) const Vec2 Node::convertToNodeSpaceAR(const Vec2& worldPoint) const
{ {
Vector2 nodePoint = convertToNodeSpace(worldPoint); Vec2 nodePoint = convertToNodeSpace(worldPoint);
return nodePoint - _anchorPointInPoints; return nodePoint - _anchorPointInPoints;
} }
Vector2 Node::convertToWorldSpaceAR(const Vector2& nodePoint) const Vec2 Node::convertToWorldSpaceAR(const Vec2& nodePoint) const
{ {
Vector2 pt = nodePoint + _anchorPointInPoints; Vec2 pt = nodePoint + _anchorPointInPoints;
return convertToWorldSpace(pt); return convertToWorldSpace(pt);
} }
Vector2 Node::convertToWindowSpace(const Vector2& nodePoint) const Vec2 Node::convertToWindowSpace(const Vec2& nodePoint) const
{ {
Vector2 worldPoint = this->convertToWorldSpace(nodePoint); Vec2 worldPoint = this->convertToWorldSpace(nodePoint);
return Director::getInstance()->convertToUI(worldPoint); return Director::getInstance()->convertToUI(worldPoint);
} }
// convenience methods which take a Touch instead of Vector2 // convenience methods which take a Touch instead of Vec2
Vector2 Node::convertTouchToNodeSpace(Touch *touch) const Vec2 Node::convertTouchToNodeSpace(Touch *touch) const
{ {
Vector2 point = touch->getLocation(); Vec2 point = touch->getLocation();
return this->convertToNodeSpace(point); return this->convertToNodeSpace(point);
} }
Vector2 Node::convertTouchToNodeSpaceAR(Touch *touch) const Vec2 Node::convertTouchToNodeSpaceAR(Touch *touch) const
{ {
Vector2 point = touch->getLocation(); Vec2 point = touch->getLocation();
return this->convertToNodeSpaceAR(point); return this->convertToNodeSpaceAR(point);
} }
@ -1608,7 +1608,7 @@ void Node::updatePhysicsBodyPosition(Scene* scene)
{ {
if (scene != nullptr && scene->getPhysicsWorld() != nullptr) if (scene != nullptr && scene->getPhysicsWorld() != nullptr)
{ {
Vector2 pos = getParent() == scene ? getPosition() : scene->convertToNodeSpace(_parent->convertToWorldSpace(getPosition())); Vec2 pos = getParent() == scene ? getPosition() : scene->convertToNodeSpace(_parent->convertToWorldSpace(getPosition()));
_physicsBody->setPosition(pos); _physicsBody->setPosition(pos);
} }
else else
@ -1647,10 +1647,10 @@ void Node::setPhysicsBody(PhysicsBody* body)
// physics rotation based on body position, but node rotation based on node anthor point // physics rotation based on body position, but node rotation based on node anthor point
// it cann't support both of them, so I clear the anthor point to default. // it cann't support both of them, so I clear the anthor point to default.
if (!getAnchorPoint().equals(Vector2::ANCHOR_MIDDLE)) if (!getAnchorPoint().equals(Vec2::ANCHOR_MIDDLE))
{ {
CCLOG("Node warning: setPhysicsBody sets anchor point to Vector2::ANCHOR_MIDDLE."); CCLOG("Node warning: setPhysicsBody sets anchor point to Vec2::ANCHOR_MIDDLE.");
setAnchorPoint(Vector2::ANCHOR_MIDDLE); setAnchorPoint(Vec2::ANCHOR_MIDDLE);
} }
} }

View File

@ -273,37 +273,37 @@ public:
/** /**
* Sets the position (x,y) of the node in its parent's coordinate system. * Sets the position (x,y) of the node in its parent's coordinate system.
* *
* Usually we use `Vector2(x,y)` to compose Vector2 object. * Usually we use `Vec2(x,y)` to compose Vec2 object.
* This code snippet sets the node in the center of screen. * This code snippet sets the node in the center of screen.
@code @code
Size size = Director::getInstance()->getWinSize(); Size size = Director::getInstance()->getWinSize();
node->setPosition( Vector2(size.width/2, size.height/2) ) node->setPosition( Vec2(size.width/2, size.height/2) )
@endcode @endcode
* *
* @param position The position (x,y) of the node in OpenGL coordinates * @param position The position (x,y) of the node in OpenGL coordinates
*/ */
virtual void setPosition(const Vector2 &position); virtual void setPosition(const Vec2 &position);
/** /**
* Gets the position (x,y) of the node in its parent's coordinate system. * Gets the position (x,y) of the node in its parent's coordinate system.
* *
* @see setPosition(const Vector2&) * @see setPosition(const Vec2&)
* *
* @return The position (x,y) of the node in OpenGL coordinates * @return The position (x,y) of the node in OpenGL coordinates
* @code * @code
* In js and lua return value is table which contains x,y * In js and lua return value is table which contains x,y
* @endcode * @endcode
*/ */
virtual const Vector2& getPosition() const; virtual const Vec2& getPosition() const;
/** /**
* Sets the position (x,y) of the node in its parent's coordinate system. * Sets the position (x,y) of the node in its parent's coordinate system.
* *
* Passing two numbers (x,y) is much efficient than passing Vector2 object. * Passing two numbers (x,y) is much efficient than passing Vec2 object.
* This method is bound to Lua and JavaScript. * This method is bound to Lua and JavaScript.
* Passing a number is 10 times faster than passing a object from Lua to c++ * Passing a number is 10 times faster than passing a object from Lua to c++
* *
@code @code
// sample code in Lua // sample code in Lua
local pos = node::getPosition() -- returns Vector2 object from C++ local pos = node::getPosition() -- returns Vec2 object from C++
node:setPosition(x, y) -- pass x, y coordinate to C++ node:setPosition(x, y) -- pass x, y coordinate to C++
@endcode @endcode
* *
@ -312,7 +312,7 @@ public:
*/ */
virtual void setPosition(float x, float y); virtual void setPosition(float x, float y);
/** /**
* Gets position in a more efficient way, returns two number instead of a Vector2 object * Gets position in a more efficient way, returns two number instead of a Vec2 object
* *
* @see `setPosition(float, float)` * @see `setPosition(float, float)`
* In js,out value not return * In js,out value not return
@ -330,11 +330,11 @@ public:
/** /**
* Sets the position (X, Y, and Z) in its parent's coordinate system * Sets the position (X, Y, and Z) in its parent's coordinate system
*/ */
virtual void setPosition3D(const Vector3& position); virtual void setPosition3D(const Vec3& position);
/** /**
* returns the position (X,Y,Z) in its parent's coordinate system * returns the position (X,Y,Z) in its parent's coordinate system
*/ */
virtual Vector3 getPosition3D() const; virtual Vec3 getPosition3D() const;
/** /**
* Sets the 'z' coordinate in the position. It is the OpenGL Z vertex value. * Sets the 'z' coordinate in the position. It is the OpenGL Z vertex value.
@ -419,15 +419,15 @@ public:
* *
* @param anchorPoint The anchor point of node. * @param anchorPoint The anchor point of node.
*/ */
virtual void setAnchorPoint(const Vector2& anchorPoint); virtual void setAnchorPoint(const Vec2& anchorPoint);
/** /**
* Returns the anchor point in percent. * Returns the anchor point in percent.
* *
* @see `setAnchorPoint(const Vector2&)` * @see `setAnchorPoint(const Vec2&)`
* *
* @return The anchor point of node. * @return The anchor point of node.
*/ */
virtual const Vector2& getAnchorPoint() const; virtual const Vec2& getAnchorPoint() const;
/** /**
* Returns the anchorPoint in absolute pixels. * Returns the anchorPoint in absolute pixels.
* *
@ -436,7 +436,7 @@ public:
* *
* @return The anchor point in absolute pixels. * @return The anchor point in absolute pixels.
*/ */
virtual const Vector2& getAnchorPointInPoints() const; virtual const Vec2& getAnchorPointInPoints() const;
/** /**
@ -498,11 +498,11 @@ public:
* Sets the rotation (X,Y,Z) in degrees. * Sets the rotation (X,Y,Z) in degrees.
* Useful for 3d rotations * Useful for 3d rotations
*/ */
virtual void setRotation3D(const Vector3& rotation); virtual void setRotation3D(const Vec3& rotation);
/** /**
* returns the rotation (X,Y,Z) in degrees. * returns the rotation (X,Y,Z) in degrees.
*/ */
virtual Vector3 getRotation3D() const; virtual Vec3 getRotation3D() const;
/** /**
* Sets the X rotation (angle) of the node in degrees which performs a horizontal rotational skew. * Sets the X rotation (angle) of the node in degrees which performs a horizontal rotational skew.
@ -923,13 +923,13 @@ public:
* AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE * AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE
* But if you enable any other GL state, you should disable it after drawing your node. * But if you enable any other GL state, you should disable it after drawing your node.
*/ */
virtual void draw(Renderer *renderer, const Matrix& transform, bool transformUpdated); virtual void draw(Renderer *renderer, const Mat4& transform, bool transformUpdated);
virtual void draw() final; virtual void draw() final;
/** /**
* Visits this node's children and draw them recursively. * Visits this node's children and draw them recursively.
*/ */
virtual void visit(Renderer *renderer, const Matrix& parentTransform, bool parentTransformUpdated); virtual void visit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated);
virtual void visit() final; virtual void visit() final;
@ -1194,13 +1194,13 @@ public:
* Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates. * Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
* The matrix is in Pixels. * The matrix is in Pixels.
*/ */
virtual const Matrix& getNodeToParentTransform() const; virtual const Mat4& getNodeToParentTransform() const;
virtual AffineTransform getNodeToParentAffineTransform() const; virtual AffineTransform getNodeToParentAffineTransform() const;
/** /**
* Sets the Transformation matrix manually. * Sets the Transformation matrix manually.
*/ */
virtual void setNodeToParentTransform(const Matrix& transform); virtual void setNodeToParentTransform(const Mat4& transform);
/** @deprecated use getNodeToParentTransform() instead */ /** @deprecated use getNodeToParentTransform() instead */
CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform nodeToParentTransform() const { return getNodeToParentAffineTransform(); } CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform nodeToParentTransform() const { return getNodeToParentAffineTransform(); }
@ -1209,7 +1209,7 @@ public:
* Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates. * Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
* The matrix is in Pixels. * The matrix is in Pixels.
*/ */
virtual const Matrix& getParentToNodeTransform() const; virtual const Mat4& getParentToNodeTransform() const;
virtual AffineTransform getParentToNodeAffineTransform() const; virtual AffineTransform getParentToNodeAffineTransform() const;
/** @deprecated Use getParentToNodeTransform() instead */ /** @deprecated Use getParentToNodeTransform() instead */
@ -1218,7 +1218,7 @@ public:
/** /**
* Returns the world affine transform matrix. The matrix is in Pixels. * Returns the world affine transform matrix. The matrix is in Pixels.
*/ */
virtual Matrix getNodeToWorldTransform() const; virtual Mat4 getNodeToWorldTransform() const;
virtual AffineTransform getNodeToWorldAffineTransform() const; virtual AffineTransform getNodeToWorldAffineTransform() const;
/** @deprecated Use getNodeToWorldTransform() instead */ /** @deprecated Use getNodeToWorldTransform() instead */
@ -1227,7 +1227,7 @@ public:
/** /**
* Returns the inverse world affine transform matrix. The matrix is in Pixels. * Returns the inverse world affine transform matrix. The matrix is in Pixels.
*/ */
virtual Matrix getWorldToNodeTransform() const; virtual Mat4 getWorldToNodeTransform() const;
virtual AffineTransform getWorldToNodeAffineTransform() const; virtual AffineTransform getWorldToNodeAffineTransform() const;
@ -1241,36 +1241,36 @@ public:
/// @name Coordinate Converters /// @name Coordinate Converters
/** /**
* Converts a Vector2 to node (local) space coordinates. The result is in Points. * Converts a Vec2 to node (local) space coordinates. The result is in Points.
*/ */
Vector2 convertToNodeSpace(const Vector2& worldPoint) const; Vec2 convertToNodeSpace(const Vec2& worldPoint) const;
/** /**
* Converts a Vector2 to world space coordinates. The result is in Points. * Converts a Vec2 to world space coordinates. The result is in Points.
*/ */
Vector2 convertToWorldSpace(const Vector2& nodePoint) const; Vec2 convertToWorldSpace(const Vec2& nodePoint) const;
/** /**
* Converts a Vector2 to node (local) space coordinates. The result is in Points. * Converts a Vec2 to node (local) space coordinates. The result is in Points.
* treating the returned/received node point as anchor relative. * treating the returned/received node point as anchor relative.
*/ */
Vector2 convertToNodeSpaceAR(const Vector2& worldPoint) const; Vec2 convertToNodeSpaceAR(const Vec2& worldPoint) const;
/** /**
* Converts a local Vector2 to world space coordinates.The result is in Points. * Converts a local Vec2 to world space coordinates.The result is in Points.
* treating the returned/received node point as anchor relative. * treating the returned/received node point as anchor relative.
*/ */
Vector2 convertToWorldSpaceAR(const Vector2& nodePoint) const; Vec2 convertToWorldSpaceAR(const Vec2& nodePoint) const;
/** /**
* convenience methods which take a Touch instead of Vector2 * convenience methods which take a Touch instead of Vec2
*/ */
Vector2 convertTouchToNodeSpace(Touch * touch) const; Vec2 convertTouchToNodeSpace(Touch * touch) const;
/** /**
* converts a Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). * converts a Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative).
*/ */
Vector2 convertTouchToNodeSpaceAR(Touch * touch) const; Vec2 convertTouchToNodeSpaceAR(Touch * touch) const;
/** /**
* Sets an additional transform matrix to the node. * Sets an additional transform matrix to the node.
@ -1280,7 +1280,7 @@ public:
* @note The additional transform will be concatenated at the end of getNodeToParentTransform. * @note The additional transform will be concatenated at the end of getNodeToParentTransform.
* It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't). * It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't).
*/ */
void setAdditionalTransform(Matrix* additionalTransform); void setAdditionalTransform(Mat4* additionalTransform);
void setAdditionalTransform(const AffineTransform& additionalTransform); void setAdditionalTransform(const AffineTransform& additionalTransform);
/// @} end of Coordinate Converters /// @} end of Coordinate Converters
@ -1312,7 +1312,7 @@ public:
#if CC_USE_PHYSICS #if CC_USE_PHYSICS
/** /**
* set the PhysicsBody that let the sprite effect with physics * set the PhysicsBody that let the sprite effect with physics
* @note This method will set anchor point to Vector2::ANCHOR_MIDDLE if body not null, and you cann't change anchor point if node has a physics body. * @note This method will set anchor point to Vec2::ANCHOR_MIDDLE if body not null, and you cann't change anchor point if node has a physics body.
*/ */
void setPhysicsBody(PhysicsBody* body); void setPhysicsBody(PhysicsBody* body);
@ -1359,9 +1359,9 @@ protected:
void detachChild(Node *child, ssize_t index, bool doCleanup); void detachChild(Node *child, ssize_t index, bool doCleanup);
/// Convert cocos2d coordinates to UI windows coordinate. /// Convert cocos2d coordinates to UI windows coordinate.
Vector2 convertToWindowSpace(const Vector2& nodePoint) const; Vec2 convertToWindowSpace(const Vec2& nodePoint) const;
Matrix transform(const Matrix &parentTransform); Mat4 transform(const Mat4 &parentTransform);
virtual void updateCascadeOpacity(); virtual void updateCascadeOpacity();
virtual void disableCascadeOpacity(); virtual void disableCascadeOpacity();
@ -1385,25 +1385,25 @@ protected:
float _scaleY; ///< scaling factor on y-axis float _scaleY; ///< scaling factor on y-axis
float _scaleZ; ///< scaling factor on z-axis float _scaleZ; ///< scaling factor on z-axis
Vector2 _position; ///< position of the node Vec2 _position; ///< position of the node
float _positionZ; ///< OpenGL real Z position float _positionZ; ///< OpenGL real Z position
float _skewX; ///< skew angle on x-axis float _skewX; ///< skew angle on x-axis
float _skewY; ///< skew angle on y-axis float _skewY; ///< skew angle on y-axis
Vector2 _anchorPointInPoints; ///< anchor point in points Vec2 _anchorPointInPoints; ///< anchor point in points
Vector2 _anchorPoint; ///< anchor point normalized (NOT in points) Vec2 _anchorPoint; ///< anchor point normalized (NOT in points)
Size _contentSize; ///< untransformed size of the node Size _contentSize; ///< untransformed size of the node
Matrix _modelViewTransform; ///< ModelView transform of the Node. Mat4 _modelViewTransform; ///< ModelView transform of the Node.
// "cache" variables are allowed to be mutable // "cache" variables are allowed to be mutable
mutable Matrix _transform; ///< transform mutable Mat4 _transform; ///< transform
mutable bool _transformDirty; ///< transform dirty flag mutable bool _transformDirty; ///< transform dirty flag
mutable Matrix _inverse; ///< inverse transform mutable Mat4 _inverse; ///< inverse transform
mutable bool _inverseDirty; ///< inverse transform dirty flag mutable bool _inverseDirty; ///< inverse transform dirty flag
mutable Matrix _additionalTransform; ///< transform mutable Mat4 _additionalTransform; ///< transform
bool _useAdditionalTransform; ///< The flag to check whether the additional transform is dirty bool _useAdditionalTransform; ///< The flag to check whether the additional transform is dirty
bool _transformUpdated; ///< Whether or not the Transform object was updated since the last frame bool _transformUpdated; ///< Whether or not the Transform object was updated since the last frame
@ -1434,7 +1434,7 @@ protected:
bool _visible; ///< is this node visible bool _visible; ///< is this node visible
bool _ignoreAnchorPointForPosition; ///< true if the Anchor Vector2 will be (0,0) when you position the Node, false otherwise. bool _ignoreAnchorPointForPosition; ///< true if the Anchor Vec2 will be (0,0) when you position the Node, false otherwise.
///< Used by Layer and Scene. ///< Used by Layer and Scene.
bool _reorderChildDirty; ///< children order dirty flag bool _reorderChildDirty; ///< children order dirty flag

View File

@ -82,7 +82,7 @@ void NodeGrid::onGridEndDraw()
} }
} }
void NodeGrid::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
{ {
// quick return if not visible. children won't be drawn. // quick return if not visible. children won't be drawn.
if (!_visible) if (!_visible)
@ -100,7 +100,7 @@ void NodeGrid::visit(Renderer *renderer, const Matrix &parentTransform, bool par
_transformUpdated = false; _transformUpdated = false;
// IMPORTANT: // IMPORTANT:
// To ease the migration to v3.0, we still support the Matrix stack, // To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it // but it is deprecated and your code should not rely on it
Director* director = Director::getInstance(); Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack"); CCASSERT(nullptr != director, "Director is null when seting matrix stack");

View File

@ -54,7 +54,7 @@ public:
void setTarget(Node *target); void setTarget(Node *target);
// overrides // overrides
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
protected: protected:
NodeGrid(); NodeGrid();

View File

@ -32,7 +32,7 @@ NS_CC_BEGIN
class PointObject : public Ref class PointObject : public Ref
{ {
public: public:
static PointObject * create(Vector2 ratio, Vector2 offset) static PointObject * create(Vec2 ratio, Vec2 offset)
{ {
PointObject *ret = new PointObject(); PointObject *ret = new PointObject();
ret->initWithPoint(ratio, offset); ret->initWithPoint(ratio, offset);
@ -40,7 +40,7 @@ public:
return ret; return ret;
} }
bool initWithPoint(Vector2 ratio, Vector2 offset) bool initWithPoint(Vec2 ratio, Vec2 offset)
{ {
_ratio = ratio; _ratio = ratio;
_offset = offset; _offset = offset;
@ -48,25 +48,25 @@ public:
return true; return true;
} }
inline const Vector2& getRatio() const { return _ratio; }; inline const Vec2& getRatio() const { return _ratio; };
inline void setRatio(const Vector2& ratio) { _ratio = ratio; }; inline void setRatio(const Vec2& ratio) { _ratio = ratio; };
inline const Vector2& getOffset() const { return _offset; }; inline const Vec2& getOffset() const { return _offset; };
inline void setOffset(const Vector2& offset) { _offset = offset; }; inline void setOffset(const Vec2& offset) { _offset = offset; };
inline Node* getChild() const { return _child; }; inline Node* getChild() const { return _child; };
inline void setChild(Node* child) { _child = child; }; inline void setChild(Node* child) { _child = child; };
private: private:
Vector2 _ratio; Vec2 _ratio;
Vector2 _offset; Vec2 _offset;
Node *_child; // weak ref Node *_child; // weak ref
}; };
ParallaxNode::ParallaxNode() ParallaxNode::ParallaxNode()
{ {
_parallaxArray = ccArrayNew(5); _parallaxArray = ccArrayNew(5);
_lastPosition = Vector2(-100,-100); _lastPosition = Vec2(-100,-100);
} }
ParallaxNode::~ParallaxNode() ParallaxNode::~ParallaxNode()
@ -93,14 +93,14 @@ void ParallaxNode::addChild(Node * child, int zOrder, int tag)
CCASSERT(0,"ParallaxNode: use addChild:z:parallaxRatio:positionOffset instead"); CCASSERT(0,"ParallaxNode: use addChild:z:parallaxRatio:positionOffset instead");
} }
void ParallaxNode::addChild(Node *child, int z, const Vector2& ratio, const Vector2& offset) void ParallaxNode::addChild(Node *child, int z, const Vec2& ratio, const Vec2& offset)
{ {
CCASSERT( child != nullptr, "Argument must be non-nil"); CCASSERT( child != nullptr, "Argument must be non-nil");
PointObject *obj = PointObject::create(ratio, offset); PointObject *obj = PointObject::create(ratio, offset);
obj->setChild(child); obj->setChild(child);
ccArrayAppendObjectWithResize(_parallaxArray, (Ref*)obj); ccArrayAppendObjectWithResize(_parallaxArray, (Ref*)obj);
Vector2 pos = this->absolutePosition(); Vec2 pos = this->absolutePosition();
pos.x = -pos.x + pos.x * ratio.x + offset.x; pos.x = -pos.x + pos.x * ratio.x + offset.x;
pos.y = -pos.y + pos.y * ratio.y + offset.y; pos.y = -pos.y + pos.y * ratio.y + offset.y;
child->setPosition(pos); child->setPosition(pos);
@ -128,9 +128,9 @@ void ParallaxNode::removeAllChildrenWithCleanup(bool cleanup)
Node::removeAllChildrenWithCleanup(cleanup); Node::removeAllChildrenWithCleanup(cleanup);
} }
Vector2 ParallaxNode::absolutePosition() Vec2 ParallaxNode::absolutePosition()
{ {
Vector2 ret = _position; Vec2 ret = _position;
Node *cn = this; Node *cn = this;
while (cn->getParent() != nullptr) while (cn->getParent() != nullptr)
{ {
@ -145,11 +145,11 @@ The positions are updated at visit because:
- using a timer is not guaranteed that it will called after all the positions were updated - using a timer is not guaranteed that it will called after all the positions were updated
- overriding "draw" will only precise if the children have a z > 0 - overriding "draw" will only precise if the children have a z > 0
*/ */
void ParallaxNode::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) void ParallaxNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
{ {
// Vector2 pos = position_; // Vec2 pos = position_;
// Vector2 pos = [self convertToWorldSpace:Vector2::ZERO]; // Vec2 pos = [self convertToWorldSpace:Vec2::ZERO];
Vector2 pos = this->absolutePosition(); Vec2 pos = this->absolutePosition();
if( ! pos.equals(_lastPosition) ) if( ! pos.equals(_lastPosition) )
{ {
for( int i=0; i < _parallaxArray->num; i++ ) for( int i=0; i < _parallaxArray->num; i++ )
@ -157,7 +157,7 @@ void ParallaxNode::visit(Renderer *renderer, const Matrix &parentTransform, bool
PointObject *point = (PointObject*)_parallaxArray->arr[i]; PointObject *point = (PointObject*)_parallaxArray->arr[i];
float x = -pos.x + pos.x * point->getRatio().x + point->getOffset().x; float x = -pos.x + pos.x * point->getRatio().x + point->getOffset().x;
float y = -pos.y + pos.y * point->getRatio().y + point->getOffset().y; float y = -pos.y + pos.y * point->getRatio().y + point->getOffset().y;
point->getChild()->setPosition(Vector2(x,y)); point->getChild()->setPosition(Vec2(x,y));
} }
_lastPosition = pos; _lastPosition = pos;
} }

View File

@ -53,7 +53,7 @@ public:
// prevents compiler warning: "Included function hides overloaded virtual functions" // prevents compiler warning: "Included function hides overloaded virtual functions"
using Node::addChild; using Node::addChild;
void addChild(Node * child, int z, const Vector2& parallaxRatio, const Vector2& positionOffset); void addChild(Node * child, int z, const Vec2& parallaxRatio, const Vec2& positionOffset);
/** Sets an array of layers for the Parallax node */ /** Sets an array of layers for the Parallax node */
void setParallaxArray( struct _ccArray *parallaxArray) { _parallaxArray = parallaxArray; } void setParallaxArray( struct _ccArray *parallaxArray) { _parallaxArray = parallaxArray; }
@ -67,7 +67,7 @@ public:
virtual void addChild(Node * child, int zOrder, int tag) override; virtual void addChild(Node * child, int zOrder, int tag) override;
virtual void removeChild(Node* child, bool cleanup) override; virtual void removeChild(Node* child, bool cleanup) override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
protected: protected:
/** Adds a child to the container with a z-order, a parallax ratio and a position offset /** Adds a child to the container with a z-order, a parallax ratio and a position offset
@ -82,9 +82,9 @@ protected:
*/ */
virtual ~ParallaxNode(); virtual ~ParallaxNode();
Vector2 absolutePosition(); Vec2 absolutePosition();
Vector2 _lastPosition; Vec2 _lastPosition;
struct _ccArray* _parallaxArray; struct _ccArray* _parallaxArray;
private: private:

View File

@ -121,7 +121,7 @@ bool ParticleBatchNode::initWithFile(const std::string& fileImage, int capacity)
// override visit. // override visit.
// Don't call visit on it's children // Don't call visit on it's children
void ParticleBatchNode::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) void ParticleBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
{ {
// CAREFUL: // CAREFUL:
// This visit is almost identical to Node#visit // This visit is almost identical to Node#visit
@ -141,7 +141,7 @@ void ParticleBatchNode::visit(Renderer *renderer, const Matrix &parentTransform,
_transformUpdated = false; _transformUpdated = false;
// IMPORTANT: // IMPORTANT:
// To ease the migration to v3.0, we still support the Matrix stack, // To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it // but it is deprecated and your code should not rely on it
Director* director = Director::getInstance(); Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack"); CCASSERT(nullptr != director, "Director is null when seting matrix stack");
@ -383,7 +383,7 @@ void ParticleBatchNode::removeAllChildrenWithCleanup(bool doCleanup)
_textureAtlas->removeAllQuads(); _textureAtlas->removeAllQuads();
} }
void ParticleBatchNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void ParticleBatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
CC_PROFILER_START("CCParticleBatchNode - draw"); CC_PROFILER_START("CCParticleBatchNode - draw");

View File

@ -91,13 +91,13 @@ public:
inline void setTextureAtlas(TextureAtlas* atlas) { _textureAtlas = atlas; }; inline void setTextureAtlas(TextureAtlas* atlas) { _textureAtlas = atlas; };
// Overrides // Overrides
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
using Node::addChild; using Node::addChild;
virtual void addChild(Node * child, int zOrder, int tag) override; virtual void addChild(Node * child, int zOrder, int tag) override;
virtual void removeChild(Node* child, bool cleanup) override; virtual void removeChild(Node* child, bool cleanup) override;
virtual void reorderChild(Node * child, int zOrder) override; virtual void reorderChild(Node * child, int zOrder) override;
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual Texture2D* getTexture(void) const override; virtual Texture2D* getTexture(void) const override;
virtual void setTexture(Texture2D *texture) override; virtual void setTexture(Texture2D *texture) override;
/** /**

View File

@ -98,7 +98,7 @@ bool ParticleFire::initWithTotalParticles(int numberOfParticles)
this->_emitterMode = Mode::GRAVITY; this->_emitterMode = Mode::GRAVITY;
// Gravity Mode: gravity // Gravity Mode: gravity
this->modeA.gravity = Vector2(0,0); this->modeA.gravity = Vec2(0,0);
// Gravity Mode: radial acceleration // Gravity Mode: radial acceleration
this->modeA.radialAccel = 0; this->modeA.radialAccel = 0;
@ -114,8 +114,8 @@ bool ParticleFire::initWithTotalParticles(int numberOfParticles)
// emitter position // emitter position
Size winSize = Director::getInstance()->getWinSize(); Size winSize = Director::getInstance()->getWinSize();
this->setPosition(Vector2(winSize.width/2, 60)); this->setPosition(Vec2(winSize.width/2, 60));
this->_posVar = Vector2(40, 20); this->_posVar = Vec2(40, 20);
// life of particles // life of particles
_life = 3; _life = 3;
@ -203,7 +203,7 @@ bool ParticleFireworks::initWithTotalParticles(int numberOfParticles)
this->_emitterMode = Mode::GRAVITY; this->_emitterMode = Mode::GRAVITY;
// Gravity Mode: gravity // Gravity Mode: gravity
this->modeA.gravity = Vector2(0,-90); this->modeA.gravity = Vec2(0,-90);
// Gravity Mode: radial // Gravity Mode: radial
this->modeA.radialAccel = 0; this->modeA.radialAccel = 0;
@ -215,7 +215,7 @@ bool ParticleFireworks::initWithTotalParticles(int numberOfParticles)
// emitter position // emitter position
Size winSize = Director::getInstance()->getWinSize(); Size winSize = Director::getInstance()->getWinSize();
this->setPosition(Vector2(winSize.width/2, winSize.height/2)); this->setPosition(Vec2(winSize.width/2, winSize.height/2));
// angle // angle
this->_angle= 90; this->_angle= 90;
@ -307,7 +307,7 @@ bool ParticleSun::initWithTotalParticles(int numberOfParticles)
setEmitterMode(Mode::GRAVITY); setEmitterMode(Mode::GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Vector2(0,0)); setGravity(Vec2(0,0));
// Gravity mode: radial acceleration // Gravity mode: radial acceleration
setRadialAccel(0); setRadialAccel(0);
@ -324,8 +324,8 @@ bool ParticleSun::initWithTotalParticles(int numberOfParticles)
// emitter position // emitter position
Size winSize = Director::getInstance()->getWinSize(); Size winSize = Director::getInstance()->getWinSize();
this->setPosition(Vector2(winSize.width/2, winSize.height/2)); this->setPosition(Vec2(winSize.width/2, winSize.height/2));
setPosVar(Vector2::ZERO); setPosVar(Vec2::ZERO);
// life of particles // life of particles
_life = 1; _life = 1;
@ -411,7 +411,7 @@ bool ParticleGalaxy::initWithTotalParticles(int numberOfParticles)
setEmitterMode(Mode::GRAVITY); setEmitterMode(Mode::GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Vector2(0,0)); setGravity(Vec2(0,0));
// Gravity Mode: speed of particles // Gravity Mode: speed of particles
setSpeed(60); setSpeed(60);
@ -431,8 +431,8 @@ bool ParticleGalaxy::initWithTotalParticles(int numberOfParticles)
// emitter position // emitter position
Size winSize = Director::getInstance()->getWinSize(); Size winSize = Director::getInstance()->getWinSize();
this->setPosition(Vector2(winSize.width/2, winSize.height/2)); this->setPosition(Vec2(winSize.width/2, winSize.height/2));
setPosVar(Vector2::ZERO); setPosVar(Vec2::ZERO);
// life of particles // life of particles
_life = 4; _life = 4;
@ -520,7 +520,7 @@ bool ParticleFlower::initWithTotalParticles(int numberOfParticles)
setEmitterMode(Mode::GRAVITY); setEmitterMode(Mode::GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Vector2(0,0)); setGravity(Vec2(0,0));
// Gravity Mode: speed of particles // Gravity Mode: speed of particles
setSpeed(80); setSpeed(80);
@ -540,8 +540,8 @@ bool ParticleFlower::initWithTotalParticles(int numberOfParticles)
// emitter position // emitter position
Size winSize = Director::getInstance()->getWinSize(); Size winSize = Director::getInstance()->getWinSize();
this->setPosition(Vector2(winSize.width/2, winSize.height/2)); this->setPosition(Vec2(winSize.width/2, winSize.height/2));
setPosVar(Vector2::ZERO); setPosVar(Vec2::ZERO);
// life of particles // life of particles
_life = 4; _life = 4;
@ -628,7 +628,7 @@ bool ParticleMeteor::initWithTotalParticles(int numberOfParticles)
setEmitterMode(Mode::GRAVITY); setEmitterMode(Mode::GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Vector2(-200,200)); setGravity(Vec2(-200,200));
// Gravity Mode: speed of particles // Gravity Mode: speed of particles
setSpeed(15); setSpeed(15);
@ -648,8 +648,8 @@ bool ParticleMeteor::initWithTotalParticles(int numberOfParticles)
// emitter position // emitter position
Size winSize = Director::getInstance()->getWinSize(); Size winSize = Director::getInstance()->getWinSize();
this->setPosition(Vector2(winSize.width/2, winSize.height/2)); this->setPosition(Vec2(winSize.width/2, winSize.height/2));
setPosVar(Vector2::ZERO); setPosVar(Vec2::ZERO);
// life of particles // life of particles
_life = 2; _life = 2;
@ -737,7 +737,7 @@ bool ParticleSpiral::initWithTotalParticles(int numberOfParticles)
setEmitterMode(Mode::GRAVITY); setEmitterMode(Mode::GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Vector2(0,0)); setGravity(Vec2(0,0));
// Gravity Mode: speed of particles // Gravity Mode: speed of particles
setSpeed(150); setSpeed(150);
@ -757,8 +757,8 @@ bool ParticleSpiral::initWithTotalParticles(int numberOfParticles)
// emitter position // emitter position
Size winSize = Director::getInstance()->getWinSize(); Size winSize = Director::getInstance()->getWinSize();
this->setPosition(Vector2(winSize.width/2, winSize.height/2)); this->setPosition(Vec2(winSize.width/2, winSize.height/2));
setPosVar(Vector2::ZERO); setPosVar(Vec2::ZERO);
// life of particles // life of particles
_life = 12; _life = 12;
@ -845,7 +845,7 @@ bool ParticleExplosion::initWithTotalParticles(int numberOfParticles)
setEmitterMode(Mode::GRAVITY); setEmitterMode(Mode::GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Vector2(0,0)); setGravity(Vec2(0,0));
// Gravity Mode: speed of particles // Gravity Mode: speed of particles
setSpeed(70); setSpeed(70);
@ -865,8 +865,8 @@ bool ParticleExplosion::initWithTotalParticles(int numberOfParticles)
// emitter position // emitter position
Size winSize = Director::getInstance()->getWinSize(); Size winSize = Director::getInstance()->getWinSize();
this->setPosition(Vector2(winSize.width/2, winSize.height/2)); this->setPosition(Vec2(winSize.width/2, winSize.height/2));
setPosVar(Vector2::ZERO); setPosVar(Vec2::ZERO);
// life of particles // life of particles
_life = 5.0f; _life = 5.0f;
@ -954,7 +954,7 @@ bool ParticleSmoke::initWithTotalParticles(int numberOfParticles)
setEmitterMode(Mode::GRAVITY); setEmitterMode(Mode::GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Vector2(0,0)); setGravity(Vec2(0,0));
// Gravity Mode: radial acceleration // Gravity Mode: radial acceleration
setRadialAccel(0); setRadialAccel(0);
@ -970,8 +970,8 @@ bool ParticleSmoke::initWithTotalParticles(int numberOfParticles)
// emitter position // emitter position
Size winSize = Director::getInstance()->getWinSize(); Size winSize = Director::getInstance()->getWinSize();
this->setPosition(Vector2(winSize.width/2, 0)); this->setPosition(Vec2(winSize.width/2, 0));
setPosVar(Vector2(20, 0)); setPosVar(Vec2(20, 0));
// life of particles // life of particles
_life = 4; _life = 4;
@ -1059,7 +1059,7 @@ bool ParticleSnow::initWithTotalParticles(int numberOfParticles)
setEmitterMode(Mode::GRAVITY); setEmitterMode(Mode::GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Vector2(0,-1)); setGravity(Vec2(0,-1));
// Gravity Mode: speed of particles // Gravity Mode: speed of particles
setSpeed(5); setSpeed(5);
@ -1075,8 +1075,8 @@ bool ParticleSnow::initWithTotalParticles(int numberOfParticles)
// emitter position // emitter position
Size winSize = Director::getInstance()->getWinSize(); Size winSize = Director::getInstance()->getWinSize();
this->setPosition(Vector2(winSize.width/2, winSize.height + 10)); this->setPosition(Vec2(winSize.width/2, winSize.height + 10));
setPosVar(Vector2(winSize.width/2, 0)); setPosVar(Vec2(winSize.width/2, 0));
// angle // angle
_angle = -90; _angle = -90;
@ -1166,7 +1166,7 @@ bool ParticleRain::initWithTotalParticles(int numberOfParticles)
setEmitterMode(Mode::GRAVITY); setEmitterMode(Mode::GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Vector2(10,-10)); setGravity(Vec2(10,-10));
// Gravity Mode: radial // Gravity Mode: radial
setRadialAccel(0); setRadialAccel(0);
@ -1187,8 +1187,8 @@ bool ParticleRain::initWithTotalParticles(int numberOfParticles)
// emitter position // emitter position
Size winSize = Director::getInstance()->getWinSize(); Size winSize = Director::getInstance()->getWinSize();
this->setPosition(Vector2(winSize.width/2, winSize.height)); this->setPosition(Vec2(winSize.width/2, winSize.height));
setPosVar(Vector2(winSize.width/2, 0)); setPosVar(Vec2(winSize.width/2, 0));
// life of particles // life of particles
_life = 4.5f; _life = 4.5f;

View File

@ -97,8 +97,8 @@ ParticleSystem::ParticleSystem()
, _isActive(true) , _isActive(true)
, _particleCount(0) , _particleCount(0)
, _duration(0) , _duration(0)
, _sourcePosition(Vector2::ZERO) , _sourcePosition(Vec2::ZERO)
, _posVar(Vector2::ZERO) , _posVar(Vec2::ZERO)
, _life(0) , _life(0)
, _lifeVar(0) , _lifeVar(0)
, _angle(0) , _angle(0)
@ -120,7 +120,7 @@ ParticleSystem::ParticleSystem()
, _yCoordFlipped(1) , _yCoordFlipped(1)
, _positionType(PositionType::FREE) , _positionType(PositionType::FREE)
{ {
modeA.gravity = Vector2::ZERO; modeA.gravity = Vec2::ZERO;
modeA.speed = 0; modeA.speed = 0;
modeA.speedVar = 0; modeA.speedVar = 0;
modeA.tangentialAccel = 0; modeA.tangentialAccel = 0;
@ -257,7 +257,7 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string&
// position // position
float x = dictionary["sourcePositionx"].asFloat(); float x = dictionary["sourcePositionx"].asFloat();
float y = dictionary["sourcePositiony"].asFloat(); float y = dictionary["sourcePositiony"].asFloat();
this->setPosition( Vector2(x,y) ); this->setPosition( Vec2(x,y) );
_posVar.x = dictionary["sourcePositionVariancex"].asFloat(); _posVar.x = dictionary["sourcePositionVariancex"].asFloat();
_posVar.y = dictionary["sourcePositionVariancey"].asFloat(); _posVar.y = dictionary["sourcePositionVariancey"].asFloat();
@ -560,7 +560,7 @@ void ParticleSystem::initParticle(tParticle* particle)
// position // position
if (_positionType == PositionType::FREE) if (_positionType == PositionType::FREE)
{ {
particle->startPos = this->convertToWorldSpace(Vector2::ZERO); particle->startPos = this->convertToWorldSpace(Vec2::ZERO);
} }
else if (_positionType == PositionType::RELATIVE) else if (_positionType == PositionType::RELATIVE)
{ {
@ -573,7 +573,7 @@ void ParticleSystem::initParticle(tParticle* particle)
// Mode Gravity: A // Mode Gravity: A
if (_emitterMode == Mode::GRAVITY) if (_emitterMode == Mode::GRAVITY)
{ {
Vector2 v(cosf( a ), sinf( a )); Vec2 v(cosf( a ), sinf( a ));
float s = modeA.speed + modeA.speedVar * CCRANDOM_MINUS1_1(); float s = modeA.speed + modeA.speedVar * CCRANDOM_MINUS1_1();
// direction // direction
@ -679,10 +679,10 @@ void ParticleSystem::update(float dt)
_particleIdx = 0; _particleIdx = 0;
Vector2 currentPosition = Vector2::ZERO; Vec2 currentPosition = Vec2::ZERO;
if (_positionType == PositionType::FREE) if (_positionType == PositionType::FREE)
{ {
currentPosition = this->convertToWorldSpace(Vector2::ZERO); currentPosition = this->convertToWorldSpace(Vec2::ZERO);
} }
else if (_positionType == PositionType::RELATIVE) else if (_positionType == PositionType::RELATIVE)
{ {
@ -702,9 +702,9 @@ void ParticleSystem::update(float dt)
// Mode A: gravity, direction, tangential accel & radial accel // Mode A: gravity, direction, tangential accel & radial accel
if (_emitterMode == Mode::GRAVITY) if (_emitterMode == Mode::GRAVITY)
{ {
Vector2 tmp, radial, tangential; Vec2 tmp, radial, tangential;
radial = Vector2::ZERO; radial = Vec2::ZERO;
// radial acceleration // radial acceleration
if (p->pos.x || p->pos.y) if (p->pos.x || p->pos.y)
{ {
@ -761,11 +761,11 @@ void ParticleSystem::update(float dt)
// update values in quad // update values in quad
// //
Vector2 newPos; Vec2 newPos;
if (_positionType == PositionType::FREE || _positionType == PositionType::RELATIVE) if (_positionType == PositionType::FREE || _positionType == PositionType::RELATIVE)
{ {
Vector2 diff = currentPosition - p->startPos; Vec2 diff = currentPosition - p->startPos;
newPos = p->pos - diff; newPos = p->pos - diff;
} }
else else
@ -832,7 +832,7 @@ void ParticleSystem::updateWithNoTime(void)
this->update(0.0f); this->update(0.0f);
} }
void ParticleSystem::updateQuadWithParticle(tParticle* particle, const Vector2& newPosition) void ParticleSystem::updateQuadWithParticle(tParticle* particle, const Vec2& newPosition)
{ {
CC_UNUSED_PARAM(particle); CC_UNUSED_PARAM(particle);
CC_UNUSED_PARAM(newPosition); CC_UNUSED_PARAM(newPosition);
@ -967,13 +967,13 @@ bool ParticleSystem::getRotationIsDir() const
return modeA.rotationIsDir; return modeA.rotationIsDir;
} }
void ParticleSystem::setGravity(const Vector2& g) void ParticleSystem::setGravity(const Vec2& g)
{ {
CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity");
modeA.gravity = g; modeA.gravity = g;
} }
const Vector2& ParticleSystem::getGravity() const Vec2& ParticleSystem::getGravity()
{ {
CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity");
return modeA.gravity; return modeA.gravity;

View File

@ -45,8 +45,8 @@ class ParticleBatchNode;
Structure that contains the values of each particle Structure that contains the values of each particle
*/ */
typedef struct sParticle { typedef struct sParticle {
Vector2 pos; Vec2 pos;
Vector2 startPos; Vec2 startPos;
Color4F color; Color4F color;
Color4F deltaColor; Color4F deltaColor;
@ -63,7 +63,7 @@ typedef struct sParticle {
//! Mode A: gravity, direction, radial accel, tangential accel //! Mode A: gravity, direction, radial accel, tangential accel
struct { struct {
Vector2 dir; Vec2 dir;
float radialAccel; float radialAccel;
float tangentialAccel; float tangentialAccel;
} modeA; } modeA;
@ -78,7 +78,7 @@ typedef struct sParticle {
}tParticle; }tParticle;
//typedef void (*CC_UPDATE_PARTICLE_IMP)(id, SEL, tParticle*, Vector2); //typedef void (*CC_UPDATE_PARTICLE_IMP)(id, SEL, tParticle*, Vec2);
class Texture2D; class Texture2D;
@ -192,7 +192,7 @@ public:
bool isFull(); bool isFull();
//! should be overridden by subclasses //! should be overridden by subclasses
virtual void updateQuadWithParticle(tParticle* particle, const Vector2& newPosition); virtual void updateQuadWithParticle(tParticle* particle, const Vec2& newPosition);
//! should be overridden by subclasses //! should be overridden by subclasses
virtual void postStep(); virtual void postStep();
@ -202,8 +202,8 @@ public:
virtual void setAutoRemoveOnFinish(bool var); virtual void setAutoRemoveOnFinish(bool var);
// mode A // mode A
virtual const Vector2& getGravity(); virtual const Vec2& getGravity();
virtual void setGravity(const Vector2& g); virtual void setGravity(const Vec2& g);
virtual float getSpeed() const; virtual float getSpeed() const;
virtual void setSpeed(float speed); virtual void setSpeed(float speed);
virtual float getSpeedVar() const; virtual float getSpeedVar() const;
@ -256,12 +256,12 @@ public:
inline void setDuration(float duration) { _duration = duration; }; inline void setDuration(float duration) { _duration = duration; };
/** sourcePosition of the emitter */ /** sourcePosition of the emitter */
inline const Vector2& getSourcePosition() const { return _sourcePosition; }; inline const Vec2& getSourcePosition() const { return _sourcePosition; };
inline void setSourcePosition(const Vector2& pos) { _sourcePosition = pos; }; inline void setSourcePosition(const Vec2& pos) { _sourcePosition = pos; };
/** Position variance of the emitter */ /** Position variance of the emitter */
inline const Vector2& getPosVar() const { return _posVar; }; inline const Vec2& getPosVar() const { return _posVar; };
inline void setPosVar(const Vector2& pos) { _posVar = pos; }; inline void setPosVar(const Vec2& pos) { _posVar = pos; };
/** life, and life variation of each particle */ /** life, and life variation of each particle */
inline float getLife() const { return _life; }; inline float getLife() const { return _life; };
@ -432,7 +432,7 @@ protected:
//! Mode A:Gravity + Tangential Accel + Radial Accel //! Mode A:Gravity + Tangential Accel + Radial Accel
struct { struct {
/** Gravity value. Only available in 'Gravity' mode. */ /** Gravity value. Only available in 'Gravity' mode. */
Vector2 gravity; Vec2 gravity;
/** speed of each particle. Only available in 'Gravity' mode. */ /** speed of each particle. Only available in 'Gravity' mode. */
float speed; float speed;
/** speed variance of each particle. Only available in 'Gravity' mode. */ /** speed variance of each particle. Only available in 'Gravity' mode. */
@ -503,9 +503,9 @@ protected:
/** How many seconds the emitter will run. -1 means 'forever' */ /** How many seconds the emitter will run. -1 means 'forever' */
float _duration; float _duration;
/** sourcePosition of the emitter */ /** sourcePosition of the emitter */
Vector2 _sourcePosition; Vec2 _sourcePosition;
/** Position variance of the emitter */ /** Position variance of the emitter */
Vector2 _posVar; Vec2 _posVar;
/** life, and life variation of each particle */ /** life, and life variation of each particle */
float _life; float _life;
/** life variance of each particle */ /** life variance of each particle */

View File

@ -239,7 +239,7 @@ void ParticleSystemQuad::setTexture(Texture2D* texture)
void ParticleSystemQuad::setDisplayFrame(SpriteFrame *spriteFrame) void ParticleSystemQuad::setDisplayFrame(SpriteFrame *spriteFrame)
{ {
CCASSERT(spriteFrame->getOffsetInPixels().equals(Vector2::ZERO), CCASSERT(spriteFrame->getOffsetInPixels().equals(Vec2::ZERO),
"QuadParticle only supports SpriteFrames with no offsets"); "QuadParticle only supports SpriteFrames with no offsets");
// update texture before updating texture rect // update texture before updating texture rect
@ -265,7 +265,7 @@ void ParticleSystemQuad::initIndices()
} }
} }
void ParticleSystemQuad::updateQuadWithParticle(tParticle* particle, const Vector2& newPosition) void ParticleSystemQuad::updateQuadWithParticle(tParticle* particle, const Vec2& newPosition)
{ {
V3F_C4B_T2F_Quad *quad; V3F_C4B_T2F_Quad *quad;
@ -368,7 +368,7 @@ void ParticleSystemQuad::postStep()
} }
// overriding draw method // overriding draw method
void ParticleSystemQuad::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void ParticleSystemQuad::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
CCASSERT( _particleIdx == 0 || _particleIdx == _particleCount, "Abnormal error in particle quad"); CCASSERT( _particleIdx == 0 || _particleIdx == _particleCount, "Abnormal error in particle quad");
//quad command //quad command

View File

@ -96,7 +96,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
virtual void updateQuadWithParticle(tParticle* particle, const Vector2& newPosition) override; virtual void updateQuadWithParticle(tParticle* particle, const Vec2& newPosition) override;
/** /**
* @js NA * @js NA
* @lua NA * @lua NA
@ -106,7 +106,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
/** /**
* @js NA * @js NA

View File

@ -79,11 +79,11 @@ bool ProgressTimer::initWithSprite(Sprite* sp)
_vertexData = nullptr; _vertexData = nullptr;
_vertexDataCount = 0; _vertexDataCount = 0;
setAnchorPoint(Vector2(0.5f,0.5f)); setAnchorPoint(Vec2(0.5f,0.5f));
_type = Type::RADIAL; _type = Type::RADIAL;
_reverseDirection = false; _reverseDirection = false;
setMidpoint(Vector2(0.5f, 0.5f)); setMidpoint(Vec2(0.5f, 0.5f));
setBarChangeRate(Vector2(1,1)); setBarChangeRate(Vec2(1,1));
setSprite(sp); setSprite(sp);
// shader state // shader state
@ -156,15 +156,15 @@ void ProgressTimer::setReverseProgress(bool reverse)
/// ///
// @returns the vertex position from the texture coordinate // @returns the vertex position from the texture coordinate
/// ///
Tex2F ProgressTimer::textureCoordFromAlphaPoint(Vector2 alpha) Tex2F ProgressTimer::textureCoordFromAlphaPoint(Vec2 alpha)
{ {
Tex2F ret(0.0f, 0.0f); Tex2F ret(0.0f, 0.0f);
if (!_sprite) { if (!_sprite) {
return ret; return ret;
} }
V3F_C4B_T2F_Quad quad = _sprite->getQuad(); V3F_C4B_T2F_Quad quad = _sprite->getQuad();
Vector2 min = Vector2(quad.bl.texCoords.u,quad.bl.texCoords.v); Vec2 min = Vec2(quad.bl.texCoords.u,quad.bl.texCoords.v);
Vector2 max = Vector2(quad.tr.texCoords.u,quad.tr.texCoords.v); Vec2 max = Vec2(quad.tr.texCoords.u,quad.tr.texCoords.v);
// Fix bug #1303 so that progress timer handles sprite frame texture rotation // Fix bug #1303 so that progress timer handles sprite frame texture rotation
if (_sprite->isTextureRectRotated()) { if (_sprite->isTextureRectRotated()) {
CC_SWAP(alpha.x, alpha.y, float); CC_SWAP(alpha.x, alpha.y, float);
@ -172,15 +172,15 @@ Tex2F ProgressTimer::textureCoordFromAlphaPoint(Vector2 alpha)
return Tex2F(min.x * (1.f - alpha.x) + max.x * alpha.x, min.y * (1.f - alpha.y) + max.y * alpha.y); return Tex2F(min.x * (1.f - alpha.x) + max.x * alpha.x, min.y * (1.f - alpha.y) + max.y * alpha.y);
} }
Vector2 ProgressTimer::vertexFromAlphaPoint(Vector2 alpha) Vec2 ProgressTimer::vertexFromAlphaPoint(Vec2 alpha)
{ {
Vector2 ret(0.0f, 0.0f); Vec2 ret(0.0f, 0.0f);
if (!_sprite) { if (!_sprite) {
return ret; return ret;
} }
V3F_C4B_T2F_Quad quad = _sprite->getQuad(); V3F_C4B_T2F_Quad quad = _sprite->getQuad();
Vector2 min = Vector2(quad.bl.vertices.x,quad.bl.vertices.y); Vec2 min = Vec2(quad.bl.vertices.x,quad.bl.vertices.y);
Vector2 max = Vector2(quad.tr.vertices.x,quad.tr.vertices.y); Vec2 max = Vec2(quad.tr.vertices.x,quad.tr.vertices.y);
ret.x = min.x * (1.f - alpha.x) + max.x * alpha.x; ret.x = min.x * (1.f - alpha.x) + max.x * alpha.x;
ret.y = min.y * (1.f - alpha.y) + max.y * alpha.y; ret.y = min.y * (1.f - alpha.y) + max.y * alpha.y;
return ret; return ret;
@ -217,12 +217,12 @@ void ProgressTimer::updateProgress(void)
} }
} }
void ProgressTimer::setAnchorPoint(const Vector2& anchorPoint) void ProgressTimer::setAnchorPoint(const Vec2& anchorPoint)
{ {
Node::setAnchorPoint(anchorPoint); Node::setAnchorPoint(anchorPoint);
} }
Vector2 ProgressTimer::getMidpoint() const Vec2 ProgressTimer::getMidpoint() const
{ {
return _midpoint; return _midpoint;
} }
@ -249,9 +249,9 @@ GLubyte ProgressTimer::getOpacity() const
return _sprite->getOpacity(); return _sprite->getOpacity();
} }
void ProgressTimer::setMidpoint(const Vector2& midPoint) void ProgressTimer::setMidpoint(const Vec2& midPoint)
{ {
_midpoint = midPoint.getClampPoint(Vector2::ZERO, Vector2(1, 1)); _midpoint = midPoint.getClampPoint(Vec2::ZERO, Vec2(1, 1));
} }
/// ///
@ -275,12 +275,12 @@ void ProgressTimer::updateRadial(void)
// We find the vector to do a hit detection based on the percentage // We find the vector to do a hit detection based on the percentage
// We know the first vector is the one @ 12 o'clock (top,mid) so we rotate // We know the first vector is the one @ 12 o'clock (top,mid) so we rotate
// from that by the progress angle around the _midpoint pivot // from that by the progress angle around the _midpoint pivot
Vector2 topMid = Vector2(_midpoint.x, 1.f); Vec2 topMid = Vec2(_midpoint.x, 1.f);
Vector2 percentagePt = topMid.rotateByAngle(_midpoint, angle); Vec2 percentagePt = topMid.rotateByAngle(_midpoint, angle);
int index = 0; int index = 0;
Vector2 hit = Vector2::ZERO; Vec2 hit = Vec2::ZERO;
if (alpha == 0.f) { if (alpha == 0.f) {
// More efficient since we don't always need to check intersection // More efficient since we don't always need to check intersection
@ -302,8 +302,8 @@ void ProgressTimer::updateRadial(void)
for (int i = 0; i <= kProgressTextureCoordsCount; ++i) { for (int i = 0; i <= kProgressTextureCoordsCount; ++i) {
int pIndex = (i + (kProgressTextureCoordsCount - 1))%kProgressTextureCoordsCount; int pIndex = (i + (kProgressTextureCoordsCount - 1))%kProgressTextureCoordsCount;
Vector2 edgePtA = boundaryTexCoord(i % kProgressTextureCoordsCount); Vec2 edgePtA = boundaryTexCoord(i % kProgressTextureCoordsCount);
Vector2 edgePtB = boundaryTexCoord(pIndex); Vec2 edgePtB = boundaryTexCoord(pIndex);
// Remember that the top edge is split in half for the 12 o'clock position // Remember that the top edge is split in half for the 12 o'clock position
// Let's deal with that here by finding the correct endpoints // Let's deal with that here by finding the correct endpoints
@ -315,7 +315,7 @@ void ProgressTimer::updateRadial(void)
// s and t are returned by ccpLineIntersect // s and t are returned by ccpLineIntersect
float s = 0, t = 0; float s = 0, t = 0;
if(Vector2::isLineIntersect(edgePtA, edgePtB, _midpoint, percentagePt, &s, &t)) if(Vec2::isLineIntersect(edgePtA, edgePtB, _midpoint, percentagePt, &s, &t))
{ {
// Since our hit test is on rays we have to deal with the top edge // Since our hit test is on rays we have to deal with the top edge
@ -374,7 +374,7 @@ void ProgressTimer::updateRadial(void)
_vertexData[1].vertices = vertexFromAlphaPoint(topMid); _vertexData[1].vertices = vertexFromAlphaPoint(topMid);
for(int i = 0; i < index; ++i){ for(int i = 0; i < index; ++i){
Vector2 alphaPoint = boundaryTexCoord(i); Vec2 alphaPoint = boundaryTexCoord(i);
_vertexData[i+2].texCoords = textureCoordFromAlphaPoint(alphaPoint); _vertexData[i+2].texCoords = textureCoordFromAlphaPoint(alphaPoint);
_vertexData[i+2].vertices = vertexFromAlphaPoint(alphaPoint); _vertexData[i+2].vertices = vertexFromAlphaPoint(alphaPoint);
} }
@ -401,9 +401,9 @@ void ProgressTimer::updateBar(void)
return; return;
} }
float alpha = _percentage / 100.0f; float alpha = _percentage / 100.0f;
Vector2 alphaOffset = Vector2(1.0f * (1.0f - _barChangeRate.x) + alpha * _barChangeRate.x, 1.0f * (1.0f - _barChangeRate.y) + alpha * _barChangeRate.y) * 0.5f; Vec2 alphaOffset = Vec2(1.0f * (1.0f - _barChangeRate.x) + alpha * _barChangeRate.x, 1.0f * (1.0f - _barChangeRate.y) + alpha * _barChangeRate.y) * 0.5f;
Vector2 min = _midpoint - alphaOffset; Vec2 min = _midpoint - alphaOffset;
Vector2 max = _midpoint + alphaOffset; Vec2 max = _midpoint + alphaOffset;
if (min.x < 0.f) { if (min.x < 0.f) {
max.x += -min.x; max.x += -min.x;
@ -433,74 +433,74 @@ void ProgressTimer::updateBar(void)
CCASSERT( _vertexData, "CCProgressTimer. Not enough memory"); CCASSERT( _vertexData, "CCProgressTimer. Not enough memory");
} }
// TOPLEFT // TOPLEFT
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,max.y)); _vertexData[0].texCoords = textureCoordFromAlphaPoint(Vec2(min.x,max.y));
_vertexData[0].vertices = vertexFromAlphaPoint(Vector2(min.x,max.y)); _vertexData[0].vertices = vertexFromAlphaPoint(Vec2(min.x,max.y));
// BOTLEFT // BOTLEFT
_vertexData[1].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,min.y)); _vertexData[1].texCoords = textureCoordFromAlphaPoint(Vec2(min.x,min.y));
_vertexData[1].vertices = vertexFromAlphaPoint(Vector2(min.x,min.y)); _vertexData[1].vertices = vertexFromAlphaPoint(Vec2(min.x,min.y));
// TOPRIGHT // TOPRIGHT
_vertexData[2].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,max.y)); _vertexData[2].texCoords = textureCoordFromAlphaPoint(Vec2(max.x,max.y));
_vertexData[2].vertices = vertexFromAlphaPoint(Vector2(max.x,max.y)); _vertexData[2].vertices = vertexFromAlphaPoint(Vec2(max.x,max.y));
// BOTRIGHT // BOTRIGHT
_vertexData[3].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,min.y)); _vertexData[3].texCoords = textureCoordFromAlphaPoint(Vec2(max.x,min.y));
_vertexData[3].vertices = vertexFromAlphaPoint(Vector2(max.x,min.y)); _vertexData[3].vertices = vertexFromAlphaPoint(Vec2(max.x,min.y));
} else { } else {
if(!_vertexData) { if(!_vertexData) {
_vertexDataCount = 8; _vertexDataCount = 8;
_vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F)); _vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F));
CCASSERT( _vertexData, "CCProgressTimer. Not enough memory"); CCASSERT( _vertexData, "CCProgressTimer. Not enough memory");
// TOPLEFT 1 // TOPLEFT 1
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Vector2(0,1)); _vertexData[0].texCoords = textureCoordFromAlphaPoint(Vec2(0,1));
_vertexData[0].vertices = vertexFromAlphaPoint(Vector2(0,1)); _vertexData[0].vertices = vertexFromAlphaPoint(Vec2(0,1));
// BOTLEFT 1 // BOTLEFT 1
_vertexData[1].texCoords = textureCoordFromAlphaPoint(Vector2(0,0)); _vertexData[1].texCoords = textureCoordFromAlphaPoint(Vec2(0,0));
_vertexData[1].vertices = vertexFromAlphaPoint(Vector2(0,0)); _vertexData[1].vertices = vertexFromAlphaPoint(Vec2(0,0));
// TOPRIGHT 2 // TOPRIGHT 2
_vertexData[6].texCoords = textureCoordFromAlphaPoint(Vector2(1,1)); _vertexData[6].texCoords = textureCoordFromAlphaPoint(Vec2(1,1));
_vertexData[6].vertices = vertexFromAlphaPoint(Vector2(1,1)); _vertexData[6].vertices = vertexFromAlphaPoint(Vec2(1,1));
// BOTRIGHT 2 // BOTRIGHT 2
_vertexData[7].texCoords = textureCoordFromAlphaPoint(Vector2(1,0)); _vertexData[7].texCoords = textureCoordFromAlphaPoint(Vec2(1,0));
_vertexData[7].vertices = vertexFromAlphaPoint(Vector2(1,0)); _vertexData[7].vertices = vertexFromAlphaPoint(Vec2(1,0));
} }
// TOPRIGHT 1 // TOPRIGHT 1
_vertexData[2].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,max.y)); _vertexData[2].texCoords = textureCoordFromAlphaPoint(Vec2(min.x,max.y));
_vertexData[2].vertices = vertexFromAlphaPoint(Vector2(min.x,max.y)); _vertexData[2].vertices = vertexFromAlphaPoint(Vec2(min.x,max.y));
// BOTRIGHT 1 // BOTRIGHT 1
_vertexData[3].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,min.y)); _vertexData[3].texCoords = textureCoordFromAlphaPoint(Vec2(min.x,min.y));
_vertexData[3].vertices = vertexFromAlphaPoint(Vector2(min.x,min.y)); _vertexData[3].vertices = vertexFromAlphaPoint(Vec2(min.x,min.y));
// TOPLEFT 2 // TOPLEFT 2
_vertexData[4].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,max.y)); _vertexData[4].texCoords = textureCoordFromAlphaPoint(Vec2(max.x,max.y));
_vertexData[4].vertices = vertexFromAlphaPoint(Vector2(max.x,max.y)); _vertexData[4].vertices = vertexFromAlphaPoint(Vec2(max.x,max.y));
// BOTLEFT 2 // BOTLEFT 2
_vertexData[5].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,min.y)); _vertexData[5].texCoords = textureCoordFromAlphaPoint(Vec2(max.x,min.y));
_vertexData[5].vertices = vertexFromAlphaPoint(Vector2(max.x,min.y)); _vertexData[5].vertices = vertexFromAlphaPoint(Vec2(max.x,min.y));
} }
updateColor(); updateColor();
} }
Vector2 ProgressTimer::boundaryTexCoord(char index) Vec2 ProgressTimer::boundaryTexCoord(char index)
{ {
if (index < kProgressTextureCoordsCount) { if (index < kProgressTextureCoordsCount) {
if (_reverseDirection) { if (_reverseDirection) {
return Vector2((kProgressTextureCoords>>(7-(index<<1)))&1,(kProgressTextureCoords>>(7-((index<<1)+1)))&1); return Vec2((kProgressTextureCoords>>(7-(index<<1)))&1,(kProgressTextureCoords>>(7-((index<<1)+1)))&1);
} else { } else {
return Vector2((kProgressTextureCoords>>((index<<1)+1))&1,(kProgressTextureCoords>>(index<<1))&1); return Vec2((kProgressTextureCoords>>((index<<1)+1))&1,(kProgressTextureCoords>>(index<<1))&1);
} }
} }
return Vector2::ZERO; return Vec2::ZERO;
} }
void ProgressTimer::onDraw(const Matrix &transform, bool transformUpdated) void ProgressTimer::onDraw(const Mat4 &transform, bool transformUpdated)
{ {
getGLProgram()->use(); getGLProgram()->use();
@ -518,7 +518,7 @@ void ProgressTimer::onDraw(const Matrix &transform, bool transformUpdated)
int offset = 0; int offset = 0;
glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset);
offset += sizeof(Vector2); offset += sizeof(Vec2);
glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid*)offset);
offset += sizeof(Color4B); offset += sizeof(Color4B);
@ -551,7 +551,7 @@ void ProgressTimer::onDraw(const Matrix &transform, bool transformUpdated)
} }
} }
void ProgressTimer::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void ProgressTimer::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
if( ! _vertexData || ! _sprite) if( ! _vertexData || ! _sprite)
return; return;

View File

@ -91,28 +91,28 @@ public:
* If you're using radials type then the midpoint changes the center point * If you're using radials type then the midpoint changes the center point
* If you're using bar type the the midpoint changes the bar growth * If you're using bar type the the midpoint changes the bar growth
* it expands from the center but clamps to the sprites edge so: * it expands from the center but clamps to the sprites edge so:
* you want a left to right then set the midpoint all the way to Vector2(0,y) * you want a left to right then set the midpoint all the way to Vec2(0,y)
* you want a right to left then set the midpoint all the way to Vector2(1,y) * you want a right to left then set the midpoint all the way to Vec2(1,y)
* you want a bottom to top then set the midpoint all the way to Vector2(x,0) * you want a bottom to top then set the midpoint all the way to Vec2(x,0)
* you want a top to bottom then set the midpoint all the way to Vector2(x,1) * you want a top to bottom then set the midpoint all the way to Vec2(x,1)
*/ */
void setMidpoint(const Vector2& point); void setMidpoint(const Vec2& point);
/** Returns the Midpoint */ /** Returns the Midpoint */
Vector2 getMidpoint() const; Vec2 getMidpoint() const;
/** /**
* This allows the bar type to move the component at a specific rate * This allows the bar type to move the component at a specific rate
* Set the component to 0 to make sure it stays at 100%. * Set the component to 0 to make sure it stays at 100%.
* For example you want a left to right bar but not have the height stay 100% * For example you want a left to right bar but not have the height stay 100%
* Set the rate to be Vector2(0,1); and set the midpoint to = Vector2(0,.5f); * Set the rate to be Vec2(0,1); and set the midpoint to = Vec2(0,.5f);
*/ */
inline void setBarChangeRate(const Vector2& barChangeRate ) { _barChangeRate = barChangeRate; } inline void setBarChangeRate(const Vec2& barChangeRate ) { _barChangeRate = barChangeRate; }
/** Returns the BarChangeRate */ /** Returns the BarChangeRate */
inline Vector2 getBarChangeRate() const { return _barChangeRate; } inline Vec2 getBarChangeRate() const { return _barChangeRate; }
// Overrides // Overrides
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void setAnchorPoint(const Vector2& anchorPoint) override; virtual void setAnchorPoint(const Vec2& anchorPoint) override;
virtual void setColor(const Color3B &color) override; virtual void setColor(const Color3B &color) override;
virtual const Color3B& getColor() const override; virtual const Color3B& getColor() const override;
virtual void setOpacity(GLubyte opacity) override; virtual void setOpacity(GLubyte opacity) override;
@ -133,19 +133,19 @@ CC_CONSTRUCTOR_ACCESS:
bool initWithSprite(Sprite* sp); bool initWithSprite(Sprite* sp);
protected: protected:
void onDraw(const Matrix &transform, bool transformUpdated); void onDraw(const Mat4 &transform, bool transformUpdated);
Tex2F textureCoordFromAlphaPoint(Vector2 alpha); Tex2F textureCoordFromAlphaPoint(Vec2 alpha);
Vector2 vertexFromAlphaPoint(Vector2 alpha); Vec2 vertexFromAlphaPoint(Vec2 alpha);
void updateProgress(void); void updateProgress(void);
void updateBar(void); void updateBar(void);
void updateRadial(void); void updateRadial(void);
virtual void updateColor(void) override; virtual void updateColor(void) override;
Vector2 boundaryTexCoord(char index); Vec2 boundaryTexCoord(char index);
Type _type; Type _type;
Vector2 _midpoint; Vec2 _midpoint;
Vector2 _barChangeRate; Vec2 _barChangeRate;
float _percentage; float _percentage;
Sprite *_sprite; Sprite *_sprite;
int _vertexDataCount; int _vertexDataCount;

View File

@ -306,7 +306,7 @@ void RenderTexture::setKeepMatrix(bool keepMatrix)
_keepMatrix = keepMatrix; _keepMatrix = keepMatrix;
} }
void RenderTexture::setVirtualViewport(const Vector2& rtBegin, const Rect& fullRect, const Rect& fullViewport) void RenderTexture::setVirtualViewport(const Vec2& rtBegin, const Rect& fullRect, const Rect& fullViewport)
{ {
_rtTextureRect.origin.x = rtBegin.x; _rtTextureRect.origin.x = rtBegin.x;
_rtTextureRect.origin.y = rtBegin.y; _rtTextureRect.origin.y = rtBegin.y;
@ -383,7 +383,7 @@ void RenderTexture::clearStencil(int stencilValue)
glClearStencil(stencilClearValue); glClearStencil(stencilClearValue);
} }
void RenderTexture::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
{ {
// override visit. // override visit.
// Don't call visit on its children // Don't call visit on its children
@ -401,7 +401,7 @@ void RenderTexture::visit(Renderer *renderer, const Matrix &parentTransform, boo
CCASSERT(nullptr != director, "Director is null when seting matrix stack"); CCASSERT(nullptr != director, "Director is null when seting matrix stack");
// IMPORTANT: // IMPORTANT:
// To ease the migration to v3.0, we still support the Matrix stack, // To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it // but it is deprecated and your code should not rely on it
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
@ -535,7 +535,7 @@ void RenderTexture::onBegin()
director->setProjection(director->getProjection()); director->setProjection(director->getProjection());
#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 #if CC_TARGET_PLATFORM == CC_PLATFORM_WP8
Matrix modifiedProjection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); Mat4 modifiedProjection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
modifiedProjection = CCEGLView::sharedOpenGLView()->getReverseOrientationMatrix() * modifiedProjection; modifiedProjection = CCEGLView::sharedOpenGLView()->getReverseOrientationMatrix() * modifiedProjection;
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION,modifiedProjection); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION,modifiedProjection);
#endif #endif
@ -547,8 +547,8 @@ void RenderTexture::onBegin()
float widthRatio = size.width / texSize.width; float widthRatio = size.width / texSize.width;
float heightRatio = size.height / texSize.height; float heightRatio = size.height / texSize.height;
Matrix orthoMatrix; Mat4 orthoMatrix;
Matrix::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix); Mat4::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix);
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix); director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix);
} }
@ -654,7 +654,7 @@ void RenderTexture::onClearDepth()
glClearDepth(depthClearValue); glClearDepth(depthClearValue);
} }
void RenderTexture::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void RenderTexture::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
if (_autoDraw) if (_autoDraw)
{ {
@ -703,8 +703,8 @@ void RenderTexture::begin()
float widthRatio = size.width / texSize.width; float widthRatio = size.width / texSize.width;
float heightRatio = size.height / texSize.height; float heightRatio = size.height / texSize.height;
Matrix orthoMatrix; Mat4 orthoMatrix;
Matrix::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix); Mat4::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix);
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix); director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix);
} }

View File

@ -153,8 +153,8 @@ public:
}; };
// Overrides // Overrides
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
//flag: use stack matrix computed from scene hierarchy or generate new modelView and projection matrix //flag: use stack matrix computed from scene hierarchy or generate new modelView and projection matrix
void setKeepMatrix(bool keepMatrix); void setKeepMatrix(bool keepMatrix);
@ -163,7 +163,7 @@ public:
//fullRect: the total size of screen //fullRect: the total size of screen
//fullViewport: the total viewportSize //fullViewport: the total viewportSize
*/ */
void setVirtualViewport(const Vector2& rtBegin, const Rect& fullRect, const Rect& fullViewport); void setVirtualViewport(const Vec2& rtBegin, const Rect& fullRect, const Rect& fullViewport);
public: public:
// XXX should be procted. // XXX should be procted.
@ -224,8 +224,8 @@ protected:
void onSaveToFile(const std::string& fileName); void onSaveToFile(const std::string& fileName);
Matrix _oldTransMatrix, _oldProjMatrix; Mat4 _oldTransMatrix, _oldProjMatrix;
Matrix _transformMatrix, _projectionMatrix; Mat4 _transformMatrix, _projectionMatrix;
private: private:
CC_DISALLOW_COPY_AND_ASSIGN(RenderTexture); CC_DISALLOW_COPY_AND_ASSIGN(RenderTexture);

View File

@ -41,7 +41,7 @@ Scene::Scene()
#endif #endif
{ {
_ignoreAnchorPointForPosition = true; _ignoreAnchorPointForPosition = true;
setAnchorPoint(Vector2(0.5f, 0.5f)); setAnchorPoint(Vec2(0.5f, 0.5f));
} }
Scene::~Scene() Scene::~Scene()

View File

@ -234,10 +234,10 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
_flippedX = _flippedY = false; _flippedX = _flippedY = false;
// default transform anchor: center // default transform anchor: center
setAnchorPoint(Vector2(0.5f, 0.5f)); setAnchorPoint(Vec2(0.5f, 0.5f));
// zwoptex default values // zwoptex default values
_offsetPosition = Vector2::ZERO; _offsetPosition = Vec2::ZERO;
// clean the Quad // clean the Quad
memset(&_quad, 0, sizeof(_quad)); memset(&_quad, 0, sizeof(_quad));
@ -367,7 +367,7 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme
setVertexRect(rect); setVertexRect(rect);
setTextureCoords(rect); setTextureCoords(rect);
Vector2 relativeOffset = _unflippedOffsetPositionFromCenter; Vec2 relativeOffset = _unflippedOffsetPositionFromCenter;
// issue #732 // issue #732
if (_flippedX) if (_flippedX)
@ -399,10 +399,10 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme
float y2 = y1 + _rect.size.height; float y2 = y1 + _rect.size.height;
// Don't update Z. // Don't update Z.
_quad.bl.vertices = Vector3(x1, y1, 0); _quad.bl.vertices = Vec3(x1, y1, 0);
_quad.br.vertices = Vector3(x2, y1, 0); _quad.br.vertices = Vec3(x2, y1, 0);
_quad.tl.vertices = Vector3(x1, y2, 0); _quad.tl.vertices = Vec3(x1, y2, 0);
_quad.tr.vertices = Vector3(x2, y2, 0); _quad.tr.vertices = Vec3(x2, y2, 0);
} }
} }
@ -505,7 +505,7 @@ void Sprite::updateTransform(void)
// If it is not visible, or one of its ancestors is not visible, then do nothing: // If it is not visible, or one of its ancestors is not visible, then do nothing:
if( !_visible || ( _parent && _parent != _batchNode && static_cast<Sprite*>(_parent)->_shouldBeHidden) ) if( !_visible || ( _parent && _parent != _batchNode && static_cast<Sprite*>(_parent)->_shouldBeHidden) )
{ {
_quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vector3(0,0,0); _quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vec3(0,0,0);
_shouldBeHidden = true; _shouldBeHidden = true;
} }
else else
@ -519,8 +519,8 @@ void Sprite::updateTransform(void)
else else
{ {
CCASSERT( dynamic_cast<Sprite*>(_parent), "Logic error in Sprite. Parent must be a Sprite"); CCASSERT( dynamic_cast<Sprite*>(_parent), "Logic error in Sprite. Parent must be a Sprite");
Matrix nodeToParent = getNodeToParentTransform(); Mat4 nodeToParent = getNodeToParentTransform();
Matrix parentTransform = static_cast<Sprite*>(_parent)->_transformToBatch; Mat4 parentTransform = static_cast<Sprite*>(_parent)->_transformToBatch;
_transformToBatch = parentTransform * nodeToParent; _transformToBatch = parentTransform * nodeToParent;
} }
@ -554,10 +554,10 @@ void Sprite::updateTransform(void)
float dx = x1 * cr - y2 * sr2 + x; float dx = x1 * cr - y2 * sr2 + x;
float dy = x1 * sr + y2 * cr2 + y; float dy = x1 * sr + y2 * cr2 + y;
_quad.bl.vertices = Vector3( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ ); _quad.bl.vertices = Vec3( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ );
_quad.br.vertices = Vector3( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ ); _quad.br.vertices = Vec3( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ );
_quad.tl.vertices = Vector3( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ ); _quad.tl.vertices = Vec3( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ );
_quad.tr.vertices = Vector3( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ ); _quad.tr.vertices = Vec3( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ );
} }
// MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS // MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
@ -583,7 +583,7 @@ void Sprite::updateTransform(void)
// draw // draw
void Sprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void Sprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
// Don't do calculate the culling if the transform was not updated // Don't do calculate the culling if the transform was not updated
_insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds; _insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
@ -604,15 +604,15 @@ void Sprite::drawDebugData()
{ {
Director* director = Director::getInstance(); Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack"); CCASSERT(nullptr != director, "Director is null when seting matrix stack");
Matrix oldModelView; Mat4 oldModelView;
oldModelView = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); oldModelView = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
// draw bounding box // draw bounding box
Vector2 vertices[4] = { Vec2 vertices[4] = {
Vector2( _quad.bl.vertices.x, _quad.bl.vertices.y ), Vec2( _quad.bl.vertices.x, _quad.bl.vertices.y ),
Vector2( _quad.br.vertices.x, _quad.br.vertices.y ), Vec2( _quad.br.vertices.x, _quad.br.vertices.y ),
Vector2( _quad.tr.vertices.x, _quad.tr.vertices.y ), Vec2( _quad.tr.vertices.x, _quad.tr.vertices.y ),
Vector2( _quad.tl.vertices.x, _quad.tl.vertices.y ), Vec2( _quad.tl.vertices.x, _quad.tl.vertices.y ),
}; };
DrawPrimitives::drawPoly(vertices, 4, true); DrawPrimitives::drawPoly(vertices, 4, true);
@ -742,7 +742,7 @@ void Sprite::setDirtyRecursively(bool bValue)
} \ } \
} }
void Sprite::setPosition(const Vector2& pos) void Sprite::setPosition(const Vec2& pos)
{ {
Node::setPosition(pos); Node::setPosition(pos);
SET_DIRTY_RECURSIVELY(); SET_DIRTY_RECURSIVELY();
@ -815,7 +815,7 @@ void Sprite::setPositionZ(float fVertexZ)
SET_DIRTY_RECURSIVELY(); SET_DIRTY_RECURSIVELY();
} }
void Sprite::setAnchorPoint(const Vector2& anchor) void Sprite::setAnchorPoint(const Vec2& anchor)
{ {
Node::setAnchorPoint(anchor); Node::setAnchorPoint(anchor);
SET_DIRTY_RECURSIVELY(); SET_DIRTY_RECURSIVELY();
@ -996,15 +996,15 @@ void Sprite::setBatchNode(SpriteBatchNode *spriteBatchNode)
float y1 = _offsetPosition.y; float y1 = _offsetPosition.y;
float x2 = x1 + _rect.size.width; float x2 = x1 + _rect.size.width;
float y2 = y1 + _rect.size.height; float y2 = y1 + _rect.size.height;
_quad.bl.vertices = Vector3( x1, y1, 0 ); _quad.bl.vertices = Vec3( x1, y1, 0 );
_quad.br.vertices = Vector3( x2, y1, 0 ); _quad.br.vertices = Vec3( x2, y1, 0 );
_quad.tl.vertices = Vector3( x1, y2, 0 ); _quad.tl.vertices = Vec3( x1, y2, 0 );
_quad.tr.vertices = Vector3( x2, y2, 0 ); _quad.tr.vertices = Vec3( x2, y2, 0 );
} else { } else {
// using batch // using batch
_transformToBatch = Matrix::IDENTITY; _transformToBatch = Mat4::IDENTITY;
setTextureAtlas(_batchNode->getTextureAtlas()); // weak ref setTextureAtlas(_batchNode->getTextureAtlas()); // weak ref
} }
} }

View File

@ -317,7 +317,7 @@ public:
/** /**
* Gets the offset position of the sprite. Calculated automatically by editors like Zwoptex. * Gets the offset position of the sprite. Calculated automatically by editors like Zwoptex.
*/ */
inline const Vector2& getOffsetPosition(void) const { return _offsetPosition; } inline const Vec2& getOffsetPosition(void) const { return _offsetPosition; }
/** /**
@ -402,7 +402,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
virtual void setPosition(const Vector2& pos) override; virtual void setPosition(const Vec2& pos) override;
virtual void setPosition(float x, float y) override; virtual void setPosition(float x, float y) override;
virtual void setRotation(float rotation) override; virtual void setRotation(float rotation) override;
virtual void setRotationSkewX(float rotationX) override; virtual void setRotationSkewX(float rotationX) override;
@ -417,10 +417,10 @@ public:
virtual void sortAllChildren() override; virtual void sortAllChildren() override;
virtual void setScale(float scale) override; virtual void setScale(float scale) override;
virtual void setPositionZ(float positionZ) override; virtual void setPositionZ(float positionZ) override;
virtual void setAnchorPoint(const Vector2& anchor) override; virtual void setAnchorPoint(const Vec2& anchor) override;
virtual void ignoreAnchorPointForPosition(bool value) override; virtual void ignoreAnchorPointForPosition(bool value) override;
virtual void setVisible(bool bVisible) override; virtual void setVisible(bool bVisible) override;
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void setOpacityModifyRGB(bool modify) override; virtual void setOpacityModifyRGB(bool modify) override;
virtual bool isOpacityModifyRGB(void) const override; virtual bool isOpacityModifyRGB(void) const override;
/// @} /// @}
@ -535,7 +535,7 @@ protected:
bool _dirty; /// Whether the sprite needs to be updated bool _dirty; /// Whether the sprite needs to be updated
bool _recursiveDirty; /// Whether all of the sprite's children needs to be updated bool _recursiveDirty; /// Whether all of the sprite's children needs to be updated
bool _shouldBeHidden; /// should not be drawn because one of the ancestors is not visible bool _shouldBeHidden; /// should not be drawn because one of the ancestors is not visible
Matrix _transformToBatch; Mat4 _transformToBatch;
// //
// Data used when the sprite is self-rendered // Data used when the sprite is self-rendered
@ -556,8 +556,8 @@ protected:
bool _rectRotated; /// Whether the texture is rotated bool _rectRotated; /// Whether the texture is rotated
// Offset Position (used by Zwoptex) // Offset Position (used by Zwoptex)
Vector2 _offsetPosition; Vec2 _offsetPosition;
Vector2 _unflippedOffsetPositionFromCenter; Vec2 _unflippedOffsetPositionFromCenter;
// vertex coords, texture coords and color info // vertex coords, texture coords and color info
V3F_C4B_T2F_Quad _quad; V3F_C4B_T2F_Quad _quad;

View File

@ -132,7 +132,7 @@ SpriteBatchNode::~SpriteBatchNode()
// override visit // override visit
// don't call visit on it's children // don't call visit on it's children
void SpriteBatchNode::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
{ {
CC_PROFILER_START_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit"); CC_PROFILER_START_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit");
@ -156,7 +156,7 @@ void SpriteBatchNode::visit(Renderer *renderer, const Matrix &parentTransform, b
_transformUpdated = false; _transformUpdated = false;
// IMPORTANT: // IMPORTANT:
// To ease the migration to v3.0, we still support the Matrix stack, // To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it // but it is deprecated and your code should not rely on it
Director* director = Director::getInstance(); Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack"); CCASSERT(nullptr != director, "Director is null when seting matrix stack");
@ -356,7 +356,7 @@ void SpriteBatchNode::reorderBatch(bool reorder)
_reorderChildDirty=reorder; _reorderChildDirty=reorder;
} }
void SpriteBatchNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void SpriteBatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
// Optimization: Fast Dispatch // Optimization: Fast Dispatch
if( _textureAtlas->getTotalQuads() == 0 ) if( _textureAtlas->getTotalQuads() == 0 )

View File

@ -134,7 +134,7 @@ public:
*/ */
virtual const BlendFunc& getBlendFunc() const override; virtual const BlendFunc& getBlendFunc() const override;
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
using Node::addChild; using Node::addChild;
virtual void addChild(Node * child, int zOrder, int tag) override; virtual void addChild(Node * child, int zOrder, int tag) override;
@ -143,7 +143,7 @@ public:
virtual void removeChild(Node *child, bool cleanup) override; virtual void removeChild(Node *child, bool cleanup) override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void sortAllChildren() override; virtual void sortAllChildren() override;
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual std::string getDescription() const override; virtual std::string getDescription() const override;
/** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array. /** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array.

View File

@ -50,7 +50,7 @@ SpriteFrame* SpriteFrame::createWithTexture(Texture2D *texture, const Rect& rect
return spriteFrame; return spriteFrame;
} }
SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize) SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize)
{ {
SpriteFrame *spriteFrame = new SpriteFrame(); SpriteFrame *spriteFrame = new SpriteFrame();
spriteFrame->initWithTexture(texture, rect, rotated, offset, originalSize); spriteFrame->initWithTexture(texture, rect, rotated, offset, originalSize);
@ -59,7 +59,7 @@ SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect
return spriteFrame; return spriteFrame;
} }
SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize) SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize)
{ {
SpriteFrame *spriteFrame = new SpriteFrame(); SpriteFrame *spriteFrame = new SpriteFrame();
spriteFrame->initWithTextureFilename(filename, rect, rotated, offset, originalSize); spriteFrame->initWithTextureFilename(filename, rect, rotated, offset, originalSize);
@ -71,16 +71,16 @@ SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect,
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect) bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect)
{ {
Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS(rect); Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS(rect);
return initWithTexture(texture, rectInPixels, false, Vector2::ZERO, rectInPixels.size); return initWithTexture(texture, rectInPixels, false, Vec2::ZERO, rectInPixels.size);
} }
bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect) bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect)
{ {
Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS( rect ); Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS( rect );
return initWithTextureFilename(filename, rectInPixels, false, Vector2::ZERO, rectInPixels.size); return initWithTextureFilename(filename, rectInPixels, false, Vec2::ZERO, rectInPixels.size);
} }
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize) bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize)
{ {
_texture = texture; _texture = texture;
@ -100,7 +100,7 @@ bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rot
return true; return true;
} }
bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize) bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize)
{ {
_texture = nullptr; _texture = nullptr;
_textureFilename = filename; _textureFilename = filename;
@ -143,23 +143,23 @@ void SpriteFrame::setRectInPixels(const Rect& rectInPixels)
_rect = CC_RECT_PIXELS_TO_POINTS(rectInPixels); _rect = CC_RECT_PIXELS_TO_POINTS(rectInPixels);
} }
const Vector2& SpriteFrame::getOffset() const const Vec2& SpriteFrame::getOffset() const
{ {
return _offset; return _offset;
} }
void SpriteFrame::setOffset(const Vector2& offsets) void SpriteFrame::setOffset(const Vec2& offsets)
{ {
_offset = offsets; _offset = offsets;
_offsetInPixels = CC_POINT_POINTS_TO_PIXELS( _offset ); _offsetInPixels = CC_POINT_POINTS_TO_PIXELS( _offset );
} }
const Vector2& SpriteFrame::getOffsetInPixels() const const Vec2& SpriteFrame::getOffsetInPixels() const
{ {
return _offsetInPixels; return _offsetInPixels;
} }
void SpriteFrame::setOffsetInPixels(const Vector2& offsetInPixels) void SpriteFrame::setOffsetInPixels(const Vec2& offsetInPixels)
{ {
_offsetInPixels = offsetInPixels; _offsetInPixels = offsetInPixels;
_offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels ); _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels );

View File

@ -64,7 +64,7 @@ public:
/** Create a SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels. /** Create a SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels.
The originalSize is the size in pixels of the frame before being trimmed. The originalSize is the size in pixels of the frame before being trimmed.
*/ */
static SpriteFrame* create(const std::string& filename, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize); static SpriteFrame* create(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
/** Create a SpriteFrame with a texture, rect in points. /** Create a SpriteFrame with a texture, rect in points.
It is assumed that the frame was not trimmed. It is assumed that the frame was not trimmed.
@ -74,7 +74,7 @@ public:
/** Create a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. /** Create a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
The originalSize is the size in points of the frame before being trimmed. The originalSize is the size in points of the frame before being trimmed.
*/ */
static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize); static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
/** /**
* @js NA * @js NA
* @lua NA * @lua NA
@ -94,14 +94,14 @@ public:
/** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. /** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
The originalSize is the size in points of the frame before being trimmed. The originalSize is the size in points of the frame before being trimmed.
*/ */
bool initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize); bool initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
/** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. /** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
The originalSize is the size in pixels of the frame before being trimmed. The originalSize is the size in pixels of the frame before being trimmed.
@since v1.1 @since v1.1
*/ */
bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize); bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
// attributes // attributes
@ -117,9 +117,9 @@ public:
void setRect(const Rect& rect); void setRect(const Rect& rect);
/** get offset of the frame */ /** get offset of the frame */
const Vector2& getOffsetInPixels(void) const; const Vec2& getOffsetInPixels(void) const;
/** set offset of the frame */ /** set offset of the frame */
void setOffsetInPixels(const Vector2& offsetInPixels); void setOffsetInPixels(const Vec2& offsetInPixels);
/** get original size of the trimmed image */ /** get original size of the trimmed image */
inline const Size& getOriginalSizeInPixels(void) const { return _originalSizeInPixels; } inline const Size& getOriginalSizeInPixels(void) const { return _originalSizeInPixels; }
@ -136,19 +136,19 @@ public:
/** set texture of the frame, the texture is retained */ /** set texture of the frame, the texture is retained */
void setTexture(Texture2D* pobTexture); void setTexture(Texture2D* pobTexture);
const Vector2& getOffset(void) const; const Vec2& getOffset(void) const;
void setOffset(const Vector2& offsets); void setOffset(const Vec2& offsets);
// Overrides // Overrides
virtual SpriteFrame *clone() const override; virtual SpriteFrame *clone() const override;
protected: protected:
Vector2 _offset; Vec2 _offset;
Size _originalSize; Size _originalSize;
Rect _rectInPixels; Rect _rectInPixels;
bool _rotated; bool _rotated;
Rect _rect; Rect _rect;
Vector2 _offsetInPixels; Vec2 _offsetInPixels;
Size _originalSizeInPixels; Size _originalSizeInPixels;
Texture2D *_texture; Texture2D *_texture;
std::string _textureFilename; std::string _textureFilename;

View File

@ -132,7 +132,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
spriteFrame->initWithTexture(texture, spriteFrame->initWithTexture(texture,
Rect(x, y, w, h), Rect(x, y, w, h),
false, false,
Vector2(ox, oy), Vec2(ox, oy),
Size((float)ow, (float)oh) Size((float)ow, (float)oh)
); );
} }
@ -147,7 +147,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
rotated = frameDict["rotated"].asBool(); rotated = frameDict["rotated"].asBool();
} }
Vector2 offset = PointFromString(frameDict["offset"].asString()); Vec2 offset = PointFromString(frameDict["offset"].asString());
Size sourceSize = SizeFromString(frameDict["sourceSize"].asString()); Size sourceSize = SizeFromString(frameDict["sourceSize"].asString());
// create frame // create frame
@ -163,7 +163,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
{ {
// get values // get values
Size spriteSize = SizeFromString(frameDict["spriteSize"].asString()); Size spriteSize = SizeFromString(frameDict["spriteSize"].asString());
Vector2 spriteOffset = PointFromString(frameDict["spriteOffset"].asString()); Vec2 spriteOffset = PointFromString(frameDict["spriteOffset"].asString());
Size spriteSourceSize = SizeFromString(frameDict["spriteSourceSize"].asString()); Size spriteSourceSize = SizeFromString(frameDict["spriteSourceSize"].asString());
Rect textureRect = RectFromString(frameDict["textureRect"].asString()); Rect textureRect = RectFromString(frameDict["textureRect"].asString());
bool textureRotated = frameDict["textureRotated"].asBool(); bool textureRotated = frameDict["textureRotated"].asBool();

View File

@ -83,7 +83,7 @@ bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *la
_layerOrientation = mapInfo->getOrientation(); _layerOrientation = mapInfo->getOrientation();
// offset (after layer orientation is set); // offset (after layer orientation is set);
Vector2 offset = this->calculateLayerOffset(layerInfo->_offset); Vec2 offset = this->calculateLayerOffset(layerInfo->_offset);
this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset)); this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset));
_atlasIndexArray = ccCArrayNew(totalNumberOfTiles); _atlasIndexArray = ccCArrayNew(totalNumberOfTiles);
@ -176,7 +176,7 @@ void TMXLayer::setupTiles()
// XXX: gid == 0 --> empty tile // XXX: gid == 0 --> empty tile
if (gid != 0) if (gid != 0)
{ {
this->appendTileForGID(gid, Vector2(x, y)); this->appendTileForGID(gid, Vec2(x, y));
} }
} }
} }
@ -223,25 +223,25 @@ void TMXLayer::parseInternalProperties()
} }
} }
void TMXLayer::setupTileSprite(Sprite* sprite, Vector2 pos, int gid) void TMXLayer::setupTileSprite(Sprite* sprite, Vec2 pos, int gid)
{ {
sprite->setPosition(getPositionAt(pos)); sprite->setPosition(getPositionAt(pos));
sprite->setPositionZ((float)getVertexZForPos(pos)); sprite->setPositionZ((float)getVertexZForPos(pos));
sprite->setAnchorPoint(Vector2::ZERO); sprite->setAnchorPoint(Vec2::ZERO);
sprite->setOpacity(_opacity); sprite->setOpacity(_opacity);
//issue 1264, flip can be undone as well //issue 1264, flip can be undone as well
sprite->setFlippedX(false); sprite->setFlippedX(false);
sprite->setFlippedY(false); sprite->setFlippedY(false);
sprite->setRotation(0.0f); sprite->setRotation(0.0f);
sprite->setAnchorPoint(Vector2(0,0)); sprite->setAnchorPoint(Vec2(0,0));
// Rotation in tiled is achieved using 3 flipped states, flipping across the horizontal, vertical, and diagonal axes of the tiles. // Rotation in tiled is achieved using 3 flipped states, flipping across the horizontal, vertical, and diagonal axes of the tiles.
if (gid & kTMXTileDiagonalFlag) if (gid & kTMXTileDiagonalFlag)
{ {
// put the anchor in the middle for ease of rotation. // put the anchor in the middle for ease of rotation.
sprite->setAnchorPoint(Vector2(0.5f,0.5f)); sprite->setAnchorPoint(Vec2(0.5f,0.5f));
sprite->setPosition(Vector2(getPositionAt(pos).x + sprite->getContentSize().height/2, sprite->setPosition(Vec2(getPositionAt(pos).x + sprite->getContentSize().height/2,
getPositionAt(pos).y + sprite->getContentSize().width/2 ) ); getPositionAt(pos).y + sprite->getContentSize().width/2 ) );
int flag = gid & (kTMXTileHorizontalFlag | kTMXTileVerticalFlag ); int flag = gid & (kTMXTileHorizontalFlag | kTMXTileVerticalFlag );
@ -305,7 +305,7 @@ Sprite* TMXLayer::reusedTileWithRect(Rect rect)
} }
// TMXLayer - obtaining tiles/gids // TMXLayer - obtaining tiles/gids
Sprite * TMXLayer::getTileAt(const Vector2& pos) Sprite * TMXLayer::getTileAt(const Vec2& pos)
{ {
CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
@ -329,7 +329,7 @@ Sprite * TMXLayer::getTileAt(const Vector2& pos)
tile->setBatchNode(this); tile->setBatchNode(this);
tile->setPosition(getPositionAt(pos)); tile->setPosition(getPositionAt(pos));
tile->setPositionZ((float)getVertexZForPos(pos)); tile->setPositionZ((float)getVertexZForPos(pos));
tile->setAnchorPoint(Vector2::ZERO); tile->setAnchorPoint(Vec2::ZERO);
tile->setOpacity(_opacity); tile->setOpacity(_opacity);
ssize_t indexForZ = atlasIndexForExistantZ(z); ssize_t indexForZ = atlasIndexForExistantZ(z);
@ -340,7 +340,7 @@ Sprite * TMXLayer::getTileAt(const Vector2& pos)
return tile; return tile;
} }
uint32_t TMXLayer::getTileGIDAt(const Vector2& pos, TMXTileFlags* flags/* = nullptr*/) uint32_t TMXLayer::getTileGIDAt(const Vec2& pos, TMXTileFlags* flags/* = nullptr*/)
{ {
CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
@ -359,7 +359,7 @@ uint32_t TMXLayer::getTileGIDAt(const Vector2& pos, TMXTileFlags* flags/* = null
} }
// TMXLayer - adding helper methods // TMXLayer - adding helper methods
Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Vector2& pos) Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Vec2& pos)
{ {
if (gid != 0 && (static_cast<int>((gid & kTMXFlippedMask)) - _tileSet->_firstGid) >= 0) if (gid != 0 && (static_cast<int>((gid & kTMXFlippedMask)) - _tileSet->_firstGid) >= 0)
{ {
@ -399,7 +399,7 @@ Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Vector2& pos)
return nullptr; return nullptr;
} }
Sprite * TMXLayer::updateTileForGID(uint32_t gid, const Vector2& pos) Sprite * TMXLayer::updateTileForGID(uint32_t gid, const Vec2& pos)
{ {
Rect rect = _tileSet->getRectForGID(gid); Rect rect = _tileSet->getRectForGID(gid);
rect = Rect(rect.origin.x / _contentScaleFactor, rect.origin.y / _contentScaleFactor, rect.size.width/ _contentScaleFactor, rect.size.height/ _contentScaleFactor); rect = Rect(rect.origin.x / _contentScaleFactor, rect.origin.y / _contentScaleFactor, rect.size.width/ _contentScaleFactor, rect.size.height/ _contentScaleFactor);
@ -421,7 +421,7 @@ Sprite * TMXLayer::updateTileForGID(uint32_t gid, const Vector2& pos)
// used only when parsing the map. useless after the map was parsed // used only when parsing the map. useless after the map was parsed
// since lot's of assumptions are no longer true // since lot's of assumptions are no longer true
Sprite * TMXLayer::appendTileForGID(uint32_t gid, const Vector2& pos) Sprite * TMXLayer::appendTileForGID(uint32_t gid, const Vec2& pos)
{ {
if (gid != 0 && (static_cast<int>((gid & kTMXFlippedMask)) - _tileSet->_firstGid) >= 0) if (gid != 0 && (static_cast<int>((gid & kTMXFlippedMask)) - _tileSet->_firstGid) >= 0)
{ {
@ -485,12 +485,12 @@ ssize_t TMXLayer::atlasIndexForNewZ(int z)
} }
// TMXLayer - adding / remove tiles // TMXLayer - adding / remove tiles
void TMXLayer::setTileGID(uint32_t gid, const Vector2& pos) void TMXLayer::setTileGID(uint32_t gid, const Vec2& pos)
{ {
setTileGID(gid, pos, (TMXTileFlags)0); setTileGID(gid, pos, (TMXTileFlags)0);
} }
void TMXLayer::setTileGID(uint32_t gid, const Vector2& pos, TMXTileFlags flags) void TMXLayer::setTileGID(uint32_t gid, const Vec2& pos, TMXTileFlags flags)
{ {
CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
@ -564,7 +564,7 @@ void TMXLayer::removeChild(Node* node, bool cleanup)
SpriteBatchNode::removeChild(sprite, cleanup); SpriteBatchNode::removeChild(sprite, cleanup);
} }
void TMXLayer::removeTileAt(const Vector2& pos) void TMXLayer::removeTileAt(const Vec2& pos)
{ {
CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
@ -606,28 +606,28 @@ void TMXLayer::removeTileAt(const Vector2& pos)
} }
//CCTMXLayer - obtaining positions, offset //CCTMXLayer - obtaining positions, offset
Vector2 TMXLayer::calculateLayerOffset(const Vector2& pos) Vec2 TMXLayer::calculateLayerOffset(const Vec2& pos)
{ {
Vector2 ret = Vector2::ZERO; Vec2 ret = Vec2::ZERO;
switch (_layerOrientation) switch (_layerOrientation)
{ {
case TMXOrientationOrtho: case TMXOrientationOrtho:
ret = Vector2( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height); ret = Vec2( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height);
break; break;
case TMXOrientationIso: case TMXOrientationIso:
ret = Vector2((_mapTileSize.width /2) * (pos.x - pos.y), ret = Vec2((_mapTileSize.width /2) * (pos.x - pos.y),
(_mapTileSize.height /2 ) * (-pos.x - pos.y)); (_mapTileSize.height /2 ) * (-pos.x - pos.y));
break; break;
case TMXOrientationHex: case TMXOrientationHex:
CCASSERT(pos.equals(Vector2::ZERO), "offset for hexagonal map not implemented yet"); CCASSERT(pos.equals(Vec2::ZERO), "offset for hexagonal map not implemented yet");
break; break;
} }
return ret; return ret;
} }
Vector2 TMXLayer::getPositionAt(const Vector2& pos) Vec2 TMXLayer::getPositionAt(const Vec2& pos)
{ {
Vector2 ret = Vector2::ZERO; Vec2 ret = Vec2::ZERO;
switch (_layerOrientation) switch (_layerOrientation)
{ {
case TMXOrientationOrtho: case TMXOrientationOrtho:
@ -644,19 +644,19 @@ Vector2 TMXLayer::getPositionAt(const Vector2& pos)
return ret; return ret;
} }
Vector2 TMXLayer::getPositionForOrthoAt(const Vector2& pos) Vec2 TMXLayer::getPositionForOrthoAt(const Vec2& pos)
{ {
return Vector2(pos.x * _mapTileSize.width, return Vec2(pos.x * _mapTileSize.width,
(_layerSize.height - pos.y - 1) * _mapTileSize.height); (_layerSize.height - pos.y - 1) * _mapTileSize.height);
} }
Vector2 TMXLayer::getPositionForIsoAt(const Vector2& pos) Vec2 TMXLayer::getPositionForIsoAt(const Vec2& pos)
{ {
return Vector2(_mapTileSize.width /2 * (_layerSize.width + pos.x - pos.y - 1), return Vec2(_mapTileSize.width /2 * (_layerSize.width + pos.x - pos.y - 1),
_mapTileSize.height /2 * ((_layerSize.height * 2 - pos.x - pos.y) - 2)); _mapTileSize.height /2 * ((_layerSize.height * 2 - pos.x - pos.y) - 2));
} }
Vector2 TMXLayer::getPositionForHexAt(const Vector2& pos) Vec2 TMXLayer::getPositionForHexAt(const Vec2& pos)
{ {
float diffY = 0; float diffY = 0;
if ((int)pos.x % 2 == 1) if ((int)pos.x % 2 == 1)
@ -664,12 +664,12 @@ Vector2 TMXLayer::getPositionForHexAt(const Vector2& pos)
diffY = -_mapTileSize.height/2 ; diffY = -_mapTileSize.height/2 ;
} }
Vector2 xy = Vector2(pos.x * _mapTileSize.width*3/4, Vec2 xy = Vec2(pos.x * _mapTileSize.width*3/4,
(_layerSize.height - pos.y - 1) * _mapTileSize.height + diffY); (_layerSize.height - pos.y - 1) * _mapTileSize.height + diffY);
return xy; return xy;
} }
int TMXLayer::getVertexZForPos(const Vector2& pos) int TMXLayer::getVertexZForPos(const Vec2& pos)
{ {
int ret = 0; int ret = 0;
int maxVal = 0; int maxVal = 0;

View File

@ -102,16 +102,16 @@ public:
The Sprite can be treated like any other Sprite: rotated, scaled, translated, opacity, color, etc. The Sprite can be treated like any other Sprite: rotated, scaled, translated, opacity, color, etc.
You can remove either by calling: You can remove either by calling:
- layer->removeChild(sprite, cleanup); - layer->removeChild(sprite, cleanup);
- or layer->removeTileAt(Vector2(x,y)); - or layer->removeTileAt(Vec2(x,y));
*/ */
Sprite* getTileAt(const Vector2& tileCoordinate); Sprite* getTileAt(const Vec2& tileCoordinate);
CC_DEPRECATED_ATTRIBUTE Sprite* tileAt(const Vector2& tileCoordinate) { return getTileAt(tileCoordinate); }; CC_DEPRECATED_ATTRIBUTE Sprite* tileAt(const Vec2& tileCoordinate) { return getTileAt(tileCoordinate); };
/** returns the tile gid at a given tile coordinate. It also returns the tile flags. /** returns the tile gid at a given tile coordinate. It also returns the tile flags.
This method requires the the tile map has not been previously released (eg. don't call [layer releaseMap]) This method requires the the tile map has not been previously released (eg. don't call [layer releaseMap])
*/ */
uint32_t getTileGIDAt(const Vector2& tileCoordinate, TMXTileFlags* flags = nullptr); uint32_t getTileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags = nullptr);
CC_DEPRECATED_ATTRIBUTE uint32_t tileGIDAt(const Vector2& tileCoordinate, TMXTileFlags* flags = nullptr){ CC_DEPRECATED_ATTRIBUTE uint32_t tileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags = nullptr){
return getTileGIDAt(tileCoordinate, flags); return getTileGIDAt(tileCoordinate, flags);
}; };
@ -119,7 +119,7 @@ public:
The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1.
If a tile is already placed at that position, then it will be removed. If a tile is already placed at that position, then it will be removed.
*/ */
void setTileGID(uint32_t gid, const Vector2& tileCoordinate); void setTileGID(uint32_t gid, const Vec2& tileCoordinate);
/** sets the tile gid (gid = tile global id) at a given tile coordinate. /** sets the tile gid (gid = tile global id) at a given tile coordinate.
The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1.
@ -128,14 +128,14 @@ public:
Use withFlags if the tile flags need to be changed as well Use withFlags if the tile flags need to be changed as well
*/ */
void setTileGID(uint32_t gid, const Vector2& tileCoordinate, TMXTileFlags flags); void setTileGID(uint32_t gid, const Vec2& tileCoordinate, TMXTileFlags flags);
/** removes a tile at given tile coordinate */ /** removes a tile at given tile coordinate */
void removeTileAt(const Vector2& tileCoordinate); void removeTileAt(const Vec2& tileCoordinate);
/** returns the position in points of a given tile coordinate */ /** returns the position in points of a given tile coordinate */
Vector2 getPositionAt(const Vector2& tileCoordinate); Vec2 getPositionAt(const Vec2& tileCoordinate);
CC_DEPRECATED_ATTRIBUTE Vector2 positionAt(const Vector2& tileCoordinate) { return getPositionAt(tileCoordinate); }; CC_DEPRECATED_ATTRIBUTE Vec2 positionAt(const Vec2& tileCoordinate) { return getPositionAt(tileCoordinate); };
/** return the value for the specific property name */ /** return the value for the specific property name */
Value getProperty(const std::string& propertyName) const; Value getProperty(const std::string& propertyName) const;
@ -193,22 +193,22 @@ public:
virtual std::string getDescription() const override; virtual std::string getDescription() const override;
private: private:
Vector2 getPositionForIsoAt(const Vector2& pos); Vec2 getPositionForIsoAt(const Vec2& pos);
Vector2 getPositionForOrthoAt(const Vector2& pos); Vec2 getPositionForOrthoAt(const Vec2& pos);
Vector2 getPositionForHexAt(const Vector2& pos); Vec2 getPositionForHexAt(const Vec2& pos);
Vector2 calculateLayerOffset(const Vector2& offset); Vec2 calculateLayerOffset(const Vec2& offset);
/* optimization methods */ /* optimization methods */
Sprite* appendTileForGID(uint32_t gid, const Vector2& pos); Sprite* appendTileForGID(uint32_t gid, const Vec2& pos);
Sprite* insertTileForGID(uint32_t gid, const Vector2& pos); Sprite* insertTileForGID(uint32_t gid, const Vec2& pos);
Sprite* updateTileForGID(uint32_t gid, const Vector2& pos); Sprite* updateTileForGID(uint32_t gid, const Vec2& pos);
/* The layer recognizes some special properties, like cc_vertez */ /* The layer recognizes some special properties, like cc_vertez */
void parseInternalProperties(); void parseInternalProperties();
void setupTileSprite(Sprite* sprite, Vector2 pos, int gid); void setupTileSprite(Sprite* sprite, Vec2 pos, int gid);
Sprite* reusedTileWithRect(Rect rect); Sprite* reusedTileWithRect(Rect rect);
int getVertexZForPos(const Vector2& pos); int getVertexZForPos(const Vec2& pos);
// index // index
ssize_t atlasIndexForExistantZ(int z); ssize_t atlasIndexForExistantZ(int z);

View File

@ -34,7 +34,7 @@ NS_CC_BEGIN
TMXObjectGroup::TMXObjectGroup() TMXObjectGroup::TMXObjectGroup()
: _groupName("") : _groupName("")
, _positionOffset(Vector2::ZERO) , _positionOffset(Vec2::ZERO)
{ {
} }

View File

@ -71,10 +71,10 @@ public:
CC_DEPRECATED_ATTRIBUTE ValueMap objectNamed(const std::string& objectName) const { return getObject(objectName); }; CC_DEPRECATED_ATTRIBUTE ValueMap objectNamed(const std::string& objectName) const { return getObject(objectName); };
/** Gets the offset position of child objects */ /** Gets the offset position of child objects */
inline const Vector2& getPositionOffset() const { return _positionOffset; }; inline const Vec2& getPositionOffset() const { return _positionOffset; };
/** Sets the offset position of child objects */ /** Sets the offset position of child objects */
inline void setPositionOffset(const Vector2& offset) { _positionOffset = offset; }; inline void setPositionOffset(const Vec2& offset) { _positionOffset = offset; };
/** Gets the list of properties stored in a dictionary */ /** Gets the list of properties stored in a dictionary */
inline const ValueMap& getProperties() const { return _properties; }; inline const ValueMap& getProperties() const { return _properties; };
@ -98,7 +98,7 @@ protected:
/** name of the group */ /** name of the group */
std::string _groupName; std::string _groupName;
/** offset position of child objects */ /** offset position of child objects */
Vector2 _positionOffset; Vec2 _positionOffset;
/** list of properties stored in a dictionary */ /** list of properties stored in a dictionary */
ValueMap _properties; ValueMap _properties;
/** array of the objects */ /** array of the objects */

View File

@ -45,7 +45,7 @@ TMXLayerInfo::TMXLayerInfo()
: _name("") : _name("")
, _tiles(nullptr) , _tiles(nullptr)
, _ownTiles(true) , _ownTiles(true)
, _offset(Vector2::ZERO) , _offset(Vec2::ZERO)
{ {
} }
@ -348,7 +348,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
float x = attributeDict["x"].asFloat(); float x = attributeDict["x"].asFloat();
float y = attributeDict["y"].asFloat(); float y = attributeDict["y"].asFloat();
layer->_offset = Vector2(x,y); layer->_offset = Vec2(x,y);
tmxMapInfo->getLayers().pushBack(layer); tmxMapInfo->getLayers().pushBack(layer);
layer->release(); layer->release();
@ -361,7 +361,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
{ {
TMXObjectGroup *objectGroup = new TMXObjectGroup(); TMXObjectGroup *objectGroup = new TMXObjectGroup();
objectGroup->setGroupName(attributeDict["name"].asString()); objectGroup->setGroupName(attributeDict["name"].asString());
Vector2 positionOffset; Vec2 positionOffset;
positionOffset.x = attributeDict["x"].asFloat() * tmxMapInfo->getTileSize().width; positionOffset.x = attributeDict["x"].asFloat() * tmxMapInfo->getTileSize().width;
positionOffset.y = attributeDict["y"].asFloat() * tmxMapInfo->getTileSize().height; positionOffset.y = attributeDict["y"].asFloat() * tmxMapInfo->getTileSize().height;
objectGroup->setPositionOffset(positionOffset); objectGroup->setPositionOffset(positionOffset);
@ -452,7 +452,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
// Y // Y
int y = attributeDict["y"].asInt(); int y = attributeDict["y"].asInt();
Vector2 p(x + objectGroup->getPositionOffset().x, _mapSize.height * _tileSize.height - y - objectGroup->getPositionOffset().x - attributeDict["height"].asInt()); Vec2 p(x + objectGroup->getPositionOffset().x, _mapSize.height * _tileSize.height - y - objectGroup->getPositionOffset().x - attributeDict["height"].asInt());
p = CC_POINT_PIXELS_TO_POINTS(p); p = CC_POINT_PIXELS_TO_POINTS(p);
dict["x"] = Value(p.x); dict["x"] = Value(p.x);
dict["y"] = Value(p.y); dict["y"] = Value(p.y);

View File

@ -112,7 +112,7 @@ public:
bool _visible; bool _visible;
unsigned char _opacity; unsigned char _opacity;
bool _ownTiles; bool _ownTiles;
Vector2 _offset; Vec2 _offset;
}; };
/** @brief TMXTilesetInfo contains the information about the tilesets like: /** @brief TMXTilesetInfo contains the information about the tilesets like:

View File

@ -263,7 +263,7 @@ void TextFieldTTF::setTextColor(const Color4B &color)
Label::setTextColor(_colorText); Label::setTextColor(_colorText);
} }
void TextFieldTTF::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) void TextFieldTTF::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
{ {
if (_delegate && _delegate->onVisit(this,renderer,parentTransform,parentTransformUpdated)) if (_delegate && _delegate->onVisit(this,renderer,parentTransform,parentTransformUpdated))
{ {

View File

@ -86,7 +86,7 @@ public:
/** /**
@brief If the sender doesn't want to draw, return true. @brief If the sender doesn't want to draw, return true.
*/ */
virtual bool onVisit(TextFieldTTF * sender,Renderer *renderer, const Matrix &transform, bool transformUpdated) virtual bool onVisit(TextFieldTTF * sender,Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
CC_UNUSED_PARAM(sender); CC_UNUSED_PARAM(sender);
return false; return false;
@ -165,7 +165,7 @@ public:
virtual void setSecureTextEntry(bool value); virtual void setSecureTextEntry(bool value);
virtual bool isSecureTextEntry(); virtual bool isSecureTextEntry();
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override; virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
protected: protected:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -1142,7 +1142,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
// implementation Texture2D (Drawing) // implementation Texture2D (Drawing)
void Texture2D::drawAtPoint(const Vector2& point) void Texture2D::drawAtPoint(const Vec2& point)
{ {
GLfloat coordinates[] = { GLfloat coordinates[] = {
0.0f, _maxT, 0.0f, _maxT,

View File

@ -219,7 +219,7 @@ public:
These functions require GL_TEXTURE_2D and both GL_VERTEX_ARRAY and GL_TEXTURE_COORD_ARRAY client states to be enabled. These functions require GL_TEXTURE_2D and both GL_VERTEX_ARRAY and GL_TEXTURE_COORD_ARRAY client states to be enabled.
*/ */
/** draws a texture at a given point */ /** draws a texture at a given point */
void drawAtPoint(const Vector2& point); void drawAtPoint(const Vec2& point);
/** draws a texture inside a rect */ /** draws a texture inside a rect */
void drawInRect(const Rect& rect); void drawInRect(const Rect& rect);

View File

@ -125,7 +125,7 @@ void TileMapAtlas::loadTGAfile(const std::string& file)
} }
// TileMapAtlas - Atlas generation / updates // TileMapAtlas - Atlas generation / updates
void TileMapAtlas::setTile(const Color3B& tile, const Vector2& position) void TileMapAtlas::setTile(const Color3B& tile, const Vec2& position)
{ {
CCASSERT(_TGAInfo != nullptr, "tgaInfo must not be nil"); CCASSERT(_TGAInfo != nullptr, "tgaInfo must not be nil");
CCASSERT(position.x < _TGAInfo->width, "Invalid position.x"); CCASSERT(position.x < _TGAInfo->width, "Invalid position.x");
@ -151,7 +151,7 @@ void TileMapAtlas::setTile(const Color3B& tile, const Vector2& position)
} }
} }
Color3B TileMapAtlas::getTileAt(const Vector2& position) const Color3B TileMapAtlas::getTileAt(const Vec2& position) const
{ {
CCASSERT( _TGAInfo != nullptr, "tgaInfo must not be nil"); CCASSERT( _TGAInfo != nullptr, "tgaInfo must not be nil");
CCASSERT( position.x < _TGAInfo->width, "Invalid position.x"); CCASSERT( position.x < _TGAInfo->width, "Invalid position.x");
@ -163,7 +163,7 @@ Color3B TileMapAtlas::getTileAt(const Vector2& position) const
return value; return value;
} }
void TileMapAtlas::updateAtlasValueAt(const Vector2& pos, const Color3B& value, int index) void TileMapAtlas::updateAtlasValueAt(const Vec2& pos, const Color3B& value, int index)
{ {
CCASSERT( index >= 0 && index < _textureAtlas->getCapacity(), "updateAtlasValueAt: Invalid index"); CCASSERT( index >= 0 && index < _textureAtlas->getCapacity(), "updateAtlasValueAt: Invalid index");
@ -244,7 +244,7 @@ void TileMapAtlas::updateAtlasValues()
if( value.r != 0 ) if( value.r != 0 )
{ {
this->updateAtlasValueAt(Vector2(x,y), value, total); this->updateAtlasValueAt(Vec2(x,y), value, total);
std::string key = StringUtils::toString(x) + "," + StringUtils::toString(y); std::string key = StringUtils::toString(x) + "," + StringUtils::toString(y);
_posToAtlasIndex[key] = total; _posToAtlasIndex[key] = total;

View File

@ -78,12 +78,12 @@ public:
/** returns a tile from position x,y. /** returns a tile from position x,y.
For the moment only channel R is used For the moment only channel R is used
*/ */
Color3B getTileAt(const Vector2& position) const; Color3B getTileAt(const Vec2& position) const;
CC_DEPRECATED_ATTRIBUTE Color3B tileAt(const Vector2& position) const { return getTileAt(position); }; CC_DEPRECATED_ATTRIBUTE Color3B tileAt(const Vec2& position) const { return getTileAt(position); };
/** sets a tile at position x,y. /** sets a tile at position x,y.
For the moment only channel R is used For the moment only channel R is used
*/ */
void setTile(const Color3B& tile, const Vector2& position); void setTile(const Color3B& tile, const Vec2& position);
/** dealloc the map from memory */ /** dealloc the map from memory */
void releaseMap(); void releaseMap();
@ -93,7 +93,7 @@ public:
protected: protected:
void loadTGAfile(const std::string& file); void loadTGAfile(const std::string& file);
void calculateItemsToRender(); void calculateItemsToRender();
void updateAtlasValueAt(const Vector2& pos, const Color3B& value, int index); void updateAtlasValueAt(const Vec2& pos, const Color3B& value, int index);
void updateAtlasValues(); void updateAtlasValues();

View File

@ -103,7 +103,7 @@ void TransitionScene::sceneOrder()
_isInSceneOnTop = true; _isInSceneOnTop = true;
} }
void TransitionScene::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void TransitionScene::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
Scene::draw(renderer, transform, transformUpdated); Scene::draw(renderer, transform, transformUpdated);
@ -120,13 +120,13 @@ void TransitionScene::finish()
{ {
// clean up // clean up
_inScene->setVisible(true); _inScene->setVisible(true);
_inScene->setPosition(Vector2(0,0)); _inScene->setPosition(Vec2(0,0));
_inScene->setScale(1.0f); _inScene->setScale(1.0f);
_inScene->setRotation(0.0f); _inScene->setRotation(0.0f);
_inScene->setAdditionalTransform(nullptr); _inScene->setAdditionalTransform(nullptr);
_outScene->setVisible(false); _outScene->setVisible(false);
_outScene->setPosition(Vector2(0,0)); _outScene->setPosition(Vec2(0,0));
_outScene->setScale(1.0f); _outScene->setScale(1.0f);
_outScene->setRotation(0.0f); _outScene->setRotation(0.0f);
_outScene->setAdditionalTransform(nullptr); _outScene->setAdditionalTransform(nullptr);
@ -255,8 +255,8 @@ void TransitionRotoZoom:: onEnter()
_inScene->setScale(0.001f); _inScene->setScale(0.001f);
_outScene->setScale(1.0f); _outScene->setScale(1.0f);
_inScene->setAnchorPoint(Vector2(0.5f, 0.5f)); _inScene->setAnchorPoint(Vec2(0.5f, 0.5f));
_outScene->setAnchorPoint(Vector2(0.5f, 0.5f)); _outScene->setAnchorPoint(Vec2(0.5f, 0.5f));
ActionInterval *rotozoom = (ActionInterval*)(Sequence::create ActionInterval *rotozoom = (ActionInterval*)(Sequence::create
( (
@ -310,11 +310,11 @@ void TransitionJumpZoom::onEnter()
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
_inScene->setScale(0.5f); _inScene->setScale(0.5f);
_inScene->setPosition(Vector2(s.width, 0)); _inScene->setPosition(Vec2(s.width, 0));
_inScene->setAnchorPoint(Vector2(0.5f, 0.5f)); _inScene->setAnchorPoint(Vec2(0.5f, 0.5f));
_outScene->setAnchorPoint(Vector2(0.5f, 0.5f)); _outScene->setAnchorPoint(Vec2(0.5f, 0.5f));
ActionInterval *jump = JumpBy::create(_duration/4, Vector2(-s.width,0), s.width/4, 2); ActionInterval *jump = JumpBy::create(_duration/4, Vec2(-s.width,0), s.width/4, 2);
ActionInterval *scaleIn = ScaleTo::create(_duration/4, 1.0f); ActionInterval *scaleIn = ScaleTo::create(_duration/4, 1.0f);
ActionInterval *scaleOut = ScaleTo::create(_duration/4, 0.5f); ActionInterval *scaleOut = ScaleTo::create(_duration/4, 0.5f);
@ -379,7 +379,7 @@ void TransitionMoveInL::onEnter()
ActionInterval* TransitionMoveInL::action() ActionInterval* TransitionMoveInL::action()
{ {
return MoveTo::create(_duration, Vector2(0,0)); return MoveTo::create(_duration, Vec2(0,0));
} }
ActionInterval* TransitionMoveInL::easeActionWithAction(ActionInterval* action) ActionInterval* TransitionMoveInL::easeActionWithAction(ActionInterval* action)
@ -391,7 +391,7 @@ ActionInterval* TransitionMoveInL::easeActionWithAction(ActionInterval* action)
void TransitionMoveInL::initScenes() void TransitionMoveInL::initScenes()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
_inScene->setPosition(Vector2(-s.width,0)); _inScene->setPosition(Vec2(-s.width,0));
} }
// //
@ -419,7 +419,7 @@ TransitionMoveInR* TransitionMoveInR::create(float t, Scene* scene)
void TransitionMoveInR::initScenes() void TransitionMoveInR::initScenes()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
_inScene->setPosition( Vector2(s.width,0) ); _inScene->setPosition( Vec2(s.width,0) );
} }
// //
@ -447,7 +447,7 @@ TransitionMoveInT* TransitionMoveInT::create(float t, Scene* scene)
void TransitionMoveInT::initScenes() void TransitionMoveInT::initScenes()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
_inScene->setPosition( Vector2(0,s.height) ); _inScene->setPosition( Vec2(0,s.height) );
} }
// //
@ -475,7 +475,7 @@ TransitionMoveInB* TransitionMoveInB::create(float t, Scene* scene)
void TransitionMoveInB::initScenes() void TransitionMoveInB::initScenes()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
_inScene->setPosition( Vector2(0,-s.height) ); _inScene->setPosition( Vec2(0,-s.height) );
} }
@ -523,13 +523,13 @@ void TransitionSlideInL::sceneOrder()
void TransitionSlideInL:: initScenes() void TransitionSlideInL:: initScenes()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
_inScene->setPosition( Vector2(-(s.width-ADJUST_FACTOR),0) ); _inScene->setPosition( Vec2(-(s.width-ADJUST_FACTOR),0) );
} }
ActionInterval* TransitionSlideInL::action() ActionInterval* TransitionSlideInL::action()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
return MoveBy::create(_duration, Vector2(s.width-ADJUST_FACTOR,0)); return MoveBy::create(_duration, Vec2(s.width-ADJUST_FACTOR,0));
} }
ActionInterval* TransitionSlideInL::easeActionWithAction(ActionInterval* action) ActionInterval* TransitionSlideInL::easeActionWithAction(ActionInterval* action)
@ -579,14 +579,14 @@ void TransitionSlideInR::sceneOrder()
void TransitionSlideInR::initScenes() void TransitionSlideInR::initScenes()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
_inScene->setPosition( Vector2(s.width-ADJUST_FACTOR,0) ); _inScene->setPosition( Vec2(s.width-ADJUST_FACTOR,0) );
} }
ActionInterval* TransitionSlideInR:: action() ActionInterval* TransitionSlideInR:: action()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
return MoveBy::create(_duration, Vector2(-(s.width-ADJUST_FACTOR),0)); return MoveBy::create(_duration, Vec2(-(s.width-ADJUST_FACTOR),0));
} }
@ -620,14 +620,14 @@ void TransitionSlideInT::sceneOrder()
void TransitionSlideInT::initScenes() void TransitionSlideInT::initScenes()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
_inScene->setPosition( Vector2(0,s.height-ADJUST_FACTOR) ); _inScene->setPosition( Vec2(0,s.height-ADJUST_FACTOR) );
} }
ActionInterval* TransitionSlideInT::action() ActionInterval* TransitionSlideInT::action()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
return MoveBy::create(_duration, Vector2(0,-(s.height-ADJUST_FACTOR))); return MoveBy::create(_duration, Vec2(0,-(s.height-ADJUST_FACTOR)));
} }
// //
@ -660,14 +660,14 @@ void TransitionSlideInB::sceneOrder()
void TransitionSlideInB:: initScenes() void TransitionSlideInB:: initScenes()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
_inScene->setPosition( Vector2(0,-(s.height-ADJUST_FACTOR)) ); _inScene->setPosition( Vec2(0,-(s.height-ADJUST_FACTOR)) );
} }
ActionInterval* TransitionSlideInB:: action() ActionInterval* TransitionSlideInB:: action()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
return MoveBy::create(_duration, Vector2(0,s.height-ADJUST_FACTOR)); return MoveBy::create(_duration, Vec2(0,s.height-ADJUST_FACTOR));
} }
// //
@ -699,8 +699,8 @@ void TransitionShrinkGrow::onEnter()
_inScene->setScale(0.001f); _inScene->setScale(0.001f);
_outScene->setScale(1.0f); _outScene->setScale(1.0f);
_inScene->setAnchorPoint(Vector2(2/3.0f,0.5f)); _inScene->setAnchorPoint(Vec2(2/3.0f,0.5f));
_outScene->setAnchorPoint(Vector2(1/3.0f,0.5f)); _outScene->setAnchorPoint(Vec2(1/3.0f,0.5f));
ActionInterval* scaleOut = ScaleTo::create(_duration, 0.01f); ActionInterval* scaleOut = ScaleTo::create(_duration, 0.01f);
ActionInterval* scaleIn = ScaleTo::create(_duration, 1.0f); ActionInterval* scaleIn = ScaleTo::create(_duration, 1.0f);
@ -1261,7 +1261,7 @@ TransitionCrossFade* TransitionCrossFade::create(float t, Scene* scene)
return nullptr; return nullptr;
} }
void TransitionCrossFade::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void TransitionCrossFade::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
// override draw since both scenes (textures) are rendered in 1 scene // override draw since both scenes (textures) are rendered in 1 scene
} }
@ -1284,9 +1284,9 @@ void TransitionCrossFade::onEnter()
return; return;
} }
inTexture->getSprite()->setAnchorPoint( Vector2(0.5f,0.5f) ); inTexture->getSprite()->setAnchorPoint( Vec2(0.5f,0.5f) );
inTexture->setPosition( Vector2(size.width/2, size.height/2) ); inTexture->setPosition( Vec2(size.width/2, size.height/2) );
inTexture->setAnchorPoint( Vector2(0.5f,0.5f) ); inTexture->setAnchorPoint( Vec2(0.5f,0.5f) );
// render inScene to its texturebuffer // render inScene to its texturebuffer
inTexture->begin(); inTexture->begin();
@ -1295,9 +1295,9 @@ void TransitionCrossFade::onEnter()
// create the second render texture for outScene // create the second render texture for outScene
RenderTexture* outTexture = RenderTexture::create((int)size.width, (int)size.height); RenderTexture* outTexture = RenderTexture::create((int)size.width, (int)size.height);
outTexture->getSprite()->setAnchorPoint( Vector2(0.5f,0.5f) ); outTexture->getSprite()->setAnchorPoint( Vec2(0.5f,0.5f) );
outTexture->setPosition( Vector2(size.width/2, size.height/2) ); outTexture->setPosition( Vec2(size.width/2, size.height/2) );
outTexture->setAnchorPoint( Vector2(0.5f,0.5f) ); outTexture->setAnchorPoint( Vec2(0.5f,0.5f) );
// render outScene to its texturebuffer // render outScene to its texturebuffer
outTexture->begin(); outTexture->begin();
@ -1410,7 +1410,7 @@ void TransitionTurnOffTiles::onExit()
TransitionScene::onExit(); TransitionScene::onExit();
} }
void TransitionTurnOffTiles::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void TransitionTurnOffTiles::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
Scene::draw(renderer, transform, transformUpdated); Scene::draw(renderer, transform, transformUpdated);
@ -1490,7 +1490,7 @@ void TransitionSplitCols::switchTargetToInscene()
_gridProxy->setTarget(_inScene); _gridProxy->setTarget(_inScene);
} }
void TransitionSplitCols::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void TransitionSplitCols::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
Scene::draw(renderer, transform, transformUpdated); Scene::draw(renderer, transform, transformUpdated);
_gridProxy->visit(renderer, transform, transformUpdated); _gridProxy->visit(renderer, transform, transformUpdated);
@ -1606,7 +1606,7 @@ void TransitionFadeTR::onExit()
TransitionScene::onExit(); TransitionScene::onExit();
} }
void TransitionFadeTR::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void TransitionFadeTR::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
Scene::draw(renderer, transform, transformUpdated); Scene::draw(renderer, transform, transformUpdated);

View File

@ -91,7 +91,7 @@ public:
// //
// Overrides // Overrides
// //
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void onEnter() override; virtual void onEnter() override;
virtual void onExit() override; virtual void onExit() override;
virtual void cleanup() override; virtual void cleanup() override;
@ -613,7 +613,7 @@ public :
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
/** /**
* @js NA * @js NA
* @lua NA * @lua NA
@ -651,7 +651,7 @@ public :
virtual void onEnter() override; virtual void onEnter() override;
virtual void onExit() override; virtual void onExit() override;
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override; virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
protected: protected:
TransitionTurnOffTiles(); TransitionTurnOffTiles();
@ -684,7 +684,7 @@ public:
virtual void onEnter() override; virtual void onEnter() override;
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override; virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
virtual void onExit() override; virtual void onExit() override;
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
protected: protected:
TransitionSplitCols(); TransitionSplitCols();
virtual ~TransitionSplitCols(); virtual ~TransitionSplitCols();
@ -735,7 +735,7 @@ public:
virtual void onEnter() override; virtual void onEnter() override;
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override; virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
virtual void onExit() override; virtual void onExit() override;
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
protected: protected:
TransitionFadeTR(); TransitionFadeTR();
virtual ~TransitionFadeTR(); virtual ~TransitionFadeTR();

View File

@ -92,7 +92,7 @@ void TransitionPageTurn::onDisablePolygonOffset()
glPolygonOffset(0, 0); glPolygonOffset(0, 0);
} }
void TransitionPageTurn::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) void TransitionPageTurn::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{ {
Scene::draw(renderer, transform, transformUpdated); Scene::draw(renderer, transform, transformUpdated);

View File

@ -72,7 +72,7 @@ public:
// //
// Overrides // Overrides
// //
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
/** /**
* Creates a base transition with duration and incoming scene. * Creates a base transition with duration and incoming scene.

View File

@ -73,9 +73,9 @@ void TransitionProgress::onEnter()
// create the second render texture for outScene // create the second render texture for outScene
RenderTexture *texture = RenderTexture::create((int)size.width, (int)size.height); RenderTexture *texture = RenderTexture::create((int)size.width, (int)size.height);
texture->getSprite()->setAnchorPoint(Vector2(0.5f,0.5f)); texture->getSprite()->setAnchorPoint(Vec2(0.5f,0.5f));
texture->setPosition(Vector2(size.width/2, size.height/2)); texture->setPosition(Vec2(size.width/2, size.height/2));
texture->setAnchorPoint(Vector2(0.5f,0.5f)); texture->setAnchorPoint(Vec2(0.5f,0.5f));
// render outScene to its texturebuffer // render outScene to its texturebuffer
texture->beginWithClear(0, 0, 0, 1); texture->beginWithClear(0, 0, 0, 1);
@ -145,8 +145,8 @@ ProgressTimer* TransitionProgressRadialCCW::progressTimerNodeWithRenderTexture(R
// Return the radial type that we want to use // Return the radial type that we want to use
node->setReverseDirection(false); node->setReverseDirection(false);
node->setPercentage(100); node->setPercentage(100);
node->setPosition(Vector2(size.width/2, size.height/2)); node->setPosition(Vec2(size.width/2, size.height/2));
node->setAnchorPoint(Vector2(0.5f,0.5f)); node->setAnchorPoint(Vec2(0.5f,0.5f));
return node; return node;
} }
@ -189,8 +189,8 @@ ProgressTimer* TransitionProgressRadialCW::progressTimerNodeWithRenderTexture(Re
// Return the radial type that we want to use // Return the radial type that we want to use
node->setReverseDirection(true); node->setReverseDirection(true);
node->setPercentage(100); node->setPercentage(100);
node->setPosition(Vector2(size.width/2, size.height/2)); node->setPosition(Vec2(size.width/2, size.height/2));
node->setAnchorPoint(Vector2(0.5f,0.5f)); node->setAnchorPoint(Vec2(0.5f,0.5f));
return node; return node;
} }
@ -218,12 +218,12 @@ ProgressTimer* TransitionProgressHorizontal::progressTimerNodeWithRenderTexture(
node->getSprite()->setFlippedY(true); node->getSprite()->setFlippedY(true);
node->setType( ProgressTimer::Type::BAR); node->setType( ProgressTimer::Type::BAR);
node->setMidpoint(Vector2(1, 0)); node->setMidpoint(Vec2(1, 0));
node->setBarChangeRate(Vector2(1,0)); node->setBarChangeRate(Vec2(1,0));
node->setPercentage(100); node->setPercentage(100);
node->setPosition(Vector2(size.width/2, size.height/2)); node->setPosition(Vec2(size.width/2, size.height/2));
node->setAnchorPoint(Vector2(0.5f,0.5f)); node->setAnchorPoint(Vec2(0.5f,0.5f));
return node; return node;
} }
@ -251,12 +251,12 @@ ProgressTimer* TransitionProgressVertical::progressTimerNodeWithRenderTexture(Re
node->getSprite()->setFlippedY(true); node->getSprite()->setFlippedY(true);
node->setType(ProgressTimer::Type::BAR); node->setType(ProgressTimer::Type::BAR);
node->setMidpoint(Vector2(0, 0)); node->setMidpoint(Vec2(0, 0));
node->setBarChangeRate(Vector2(0,1)); node->setBarChangeRate(Vec2(0,1));
node->setPercentage(100); node->setPercentage(100);
node->setPosition(Vector2(size.width/2, size.height/2)); node->setPosition(Vec2(size.width/2, size.height/2));
node->setAnchorPoint(Vector2(0.5f,0.5f)); node->setAnchorPoint(Vec2(0.5f,0.5f));
return node; return node;
} }
@ -297,12 +297,12 @@ ProgressTimer* TransitionProgressInOut::progressTimerNodeWithRenderTexture(Rende
node->getSprite()->setFlippedY(true); node->getSprite()->setFlippedY(true);
node->setType( ProgressTimer::Type::BAR); node->setType( ProgressTimer::Type::BAR);
node->setMidpoint(Vector2(0.5f, 0.5f)); node->setMidpoint(Vec2(0.5f, 0.5f));
node->setBarChangeRate(Vector2(1, 1)); node->setBarChangeRate(Vec2(1, 1));
node->setPercentage(0); node->setPercentage(0);
node->setPosition(Vector2(size.width/2, size.height/2)); node->setPosition(Vec2(size.width/2, size.height/2));
node->setAnchorPoint(Vector2(0.5f,0.5f)); node->setAnchorPoint(Vec2(0.5f,0.5f));
return node; return node;
} }
@ -331,12 +331,12 @@ ProgressTimer* TransitionProgressOutIn::progressTimerNodeWithRenderTexture(Rende
node->getSprite()->setFlippedY(true); node->getSprite()->setFlippedY(true);
node->setType( ProgressTimer::Type::BAR ); node->setType( ProgressTimer::Type::BAR );
node->setMidpoint(Vector2(0.5f, 0.5f)); node->setMidpoint(Vec2(0.5f, 0.5f));
node->setBarChangeRate(Vector2(1, 1)); node->setBarChangeRate(Vec2(1, 1));
node->setPercentage(100); node->setPercentage(100);
node->setPosition(Vector2(size.width/2, size.height/2)); node->setPosition(Vec2(size.width/2, size.height/2));
node->setAnchorPoint(Vector2(0.5f,0.5f)); node->setAnchorPoint(Vec2(0.5f,0.5f));
return node; return node;
} }

View File

@ -29,7 +29,7 @@
NS_CC_BEGIN NS_CC_BEGIN
void ccVertexLineToPolygon(Vector2 *points, float stroke, Vector2 *vertices, unsigned int offset, unsigned int nuPoints) void ccVertexLineToPolygon(Vec2 *points, float stroke, Vec2 *vertices, unsigned int offset, unsigned int nuPoints)
{ {
nuPoints += offset; nuPoints += offset;
if(nuPoints<=1) return; if(nuPoints<=1) return;
@ -42,8 +42,8 @@ void ccVertexLineToPolygon(Vector2 *points, float stroke, Vector2 *vertices, uns
for(unsigned int i = offset; i<nuPoints; i++) for(unsigned int i = offset; i<nuPoints; i++)
{ {
idx = i*2; idx = i*2;
Vector2 p1 = points[i]; Vec2 p1 = points[i];
Vector2 perpVector; Vec2 perpVector;
if(i == 0) if(i == 0)
perpVector = (p1 - points[i+1]).getNormalized().getPerp(); perpVector = (p1 - points[i+1]).getNormalized().getPerp();
@ -51,11 +51,11 @@ void ccVertexLineToPolygon(Vector2 *points, float stroke, Vector2 *vertices, uns
perpVector = (points[i-1] - p1).getNormalized().getPerp(); perpVector = (points[i-1] - p1).getNormalized().getPerp();
else else
{ {
Vector2 p2 = points[i+1]; Vec2 p2 = points[i+1];
Vector2 p0 = points[i-1]; Vec2 p0 = points[i-1];
Vector2 p2p1 = (p2 - p1).getNormalized(); Vec2 p2p1 = (p2 - p1).getNormalized();
Vector2 p0p1 = (p0 - p1).getNormalized(); Vec2 p0p1 = (p0 - p1).getNormalized();
// Calculate angle between vectors // Calculate angle between vectors
float angle = acosf(p2p1.dot(p0p1)); float angle = acosf(p2p1.dot(p0p1));
@ -69,8 +69,8 @@ void ccVertexLineToPolygon(Vector2 *points, float stroke, Vector2 *vertices, uns
} }
perpVector = perpVector * stroke; perpVector = perpVector * stroke;
vertices[idx] = Vector2(p1.x+perpVector.x, p1.y+perpVector.y); vertices[idx] = Vec2(p1.x+perpVector.x, p1.y+perpVector.y);
vertices[idx+1] = Vector2(p1.x-perpVector.x, p1.y-perpVector.y); vertices[idx+1] = Vec2(p1.x-perpVector.x, p1.y-perpVector.y);
} }
@ -81,13 +81,13 @@ void ccVertexLineToPolygon(Vector2 *points, float stroke, Vector2 *vertices, uns
idx = i*2; idx = i*2;
const unsigned int idx1 = idx+2; const unsigned int idx1 = idx+2;
Vector2 p1 = vertices[idx]; Vec2 p1 = vertices[idx];
Vector2 p2 = vertices[idx+1]; Vec2 p2 = vertices[idx+1];
Vector2 p3 = vertices[idx1]; Vec2 p3 = vertices[idx1];
Vector2 p4 = vertices[idx1+1]; Vec2 p4 = vertices[idx1+1];
float s; float s;
//BOOL fixVertex = !ccpLineIntersect(Vector2(p1.x, p1.y), Vector2(p4.x, p4.y), Vector2(p2.x, p2.y), Vector2(p3.x, p3.y), &s, &t); //BOOL fixVertex = !ccpLineIntersect(Vec2(p1.x, p1.y), Vec2(p4.x, p4.y), Vec2(p2.x, p2.y), Vec2(p3.x, p3.y), &s, &t);
bool fixVertex = !ccVertexLineIntersect(p1.x, p1.y, p4.x, p4.y, p2.x, p2.y, p3.x, p3.y, &s); bool fixVertex = !ccVertexLineIntersect(p1.x, p1.y, p4.x, p4.y, p2.x, p2.y, p3.x, p3.y, &s);
if(!fixVertex) if(!fixVertex)
if (s<0.0f || s>1.0f) if (s<0.0f || s>1.0f)

View File

@ -38,7 +38,7 @@ NS_CC_BEGIN
/** @file CCVertex.h */ /** @file CCVertex.h */
/** converts a line to a polygon */ /** converts a line to a polygon */
void CC_DLL ccVertexLineToPolygon(Vector2 *points, float stroke, Vector2 *vertices, unsigned int offset, unsigned int nuPoints); void CC_DLL ccVertexLineToPolygon(Vec2 *points, float stroke, Vec2 *vertices, unsigned int offset, unsigned int nuPoints);
/** returns whether or not the line intersects */ /** returns whether or not the line intersects */
bool CC_DLL ccVertexLineIntersect(float Ax, float Ay, bool CC_DLL ccVertexLineIntersect(float Ax, float Ay,

View File

@ -178,16 +178,16 @@ Size GLViewProtocol::getVisibleSize() const
} }
} }
Vector2 GLViewProtocol::getVisibleOrigin() const Vec2 GLViewProtocol::getVisibleOrigin() const
{ {
if (_resolutionPolicy == ResolutionPolicy::NO_BORDER) if (_resolutionPolicy == ResolutionPolicy::NO_BORDER)
{ {
return Vector2((_designResolutionSize.width - _screenSize.width/_scaleX)/2, return Vec2((_designResolutionSize.width - _screenSize.width/_scaleX)/2,
(_designResolutionSize.height - _screenSize.height/_scaleY)/2); (_designResolutionSize.height - _screenSize.height/_scaleY)/2);
} }
else else
{ {
return Vector2::ZERO; return Vec2::ZERO;
} }
} }

View File

@ -113,7 +113,7 @@ public:
/** /**
* Get the visible origin point of opengl viewport. * Get the visible origin point of opengl viewport.
*/ */
virtual Vector2 getVisibleOrigin() const; virtual Vec2 getVisibleOrigin() const;
/** /**
* Get the visible rectangle of opengl viewport. * Get the visible rectangle of opengl viewport.

View File

@ -548,7 +548,7 @@ void GLView::onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int
if(GLFW_PRESS == action) if(GLFW_PRESS == action)
{ {
_captured = true; _captured = true;
if (this->getViewPortRect().equals(Rect::ZERO) || this->getViewPortRect().containsPoint(Vector2(_mouseX,_mouseY))) if (this->getViewPortRect().equals(Rect::ZERO) || this->getViewPortRect().containsPoint(Vec2(_mouseX,_mouseY)))
{ {
intptr_t id = 0; intptr_t id = 0;
this->handleTouchesBegin(1, &id, &_mouseX, &_mouseY); this->handleTouchesBegin(1, &id, &_mouseX, &_mouseY);

View File

@ -165,11 +165,11 @@ void WinRTWindow::ResizeWindow()
GLView::sharedOpenGLView()->UpdateForWindowSizeChange(); GLView::sharedOpenGLView()->UpdateForWindowSizeChange();
} }
cocos2d::Vector2 WinRTWindow::GetCCPoint(PointerEventArgs^ args) { cocos2d::Vec2 WinRTWindow::GetCCPoint(PointerEventArgs^ args) {
auto p = args->CurrentPoint; auto p = args->CurrentPoint;
float x = getScaledDPIValue(p->Position.X); float x = getScaledDPIValue(p->Position.X);
float y = getScaledDPIValue(p->Position.Y); float y = getScaledDPIValue(p->Position.Y);
Vector2 pt(x, y); Vec2 pt(x, y);
float zoomFactor = GLView::sharedOpenGLView()->getFrameZoomFactor(); float zoomFactor = GLView::sharedOpenGLView()->getFrameZoomFactor();
@ -264,7 +264,7 @@ void WinRTWindow::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ ar
{ {
float direction = (float)args->CurrentPoint->Properties->MouseWheelDelta; float direction = (float)args->CurrentPoint->Properties->MouseWheelDelta;
int id = 0; int id = 0;
Vector2 p(0.0f,0.0f); Vec2 p(0.0f,0.0f);
GLView::sharedOpenGLView()->handleTouchesBegin(1, &id, &p.x, &p.y); GLView::sharedOpenGLView()->handleTouchesBegin(1, &id, &p.x, &p.y);
p.y += direction; p.y += direction;
GLView::sharedOpenGLView()->handleTouchesMove(1, &id, &p.x, &p.y); GLView::sharedOpenGLView()->handleTouchesMove(1, &id, &p.x, &p.y);
@ -288,7 +288,7 @@ void GLView::OnPointerPressed(PointerEventArgs^ args)
{ {
#if 0 #if 0
int id = args->CurrentPoint->PointerId; int id = args->CurrentPoint->PointerId;
Vector2 pt = GetPoint(args); Vec2 pt = GetPoint(args);
handleTouchesBegin(1, &id, &pt.x, &pt.y); handleTouchesBegin(1, &id, &pt.x, &pt.y);
#endif #endif
} }
@ -302,7 +302,7 @@ void GLView::OnPointerMoved(PointerEventArgs^ args)
if (m_lastPointValid) if (m_lastPointValid)
{ {
int id = args->CurrentPoint->PointerId; int id = args->CurrentPoint->PointerId;
Vector2 p = GetPoint(args); Vec2 p = GetPoint(args);
handleTouchesMove(1, &id, &p.x, &p.y); handleTouchesMove(1, &id, &p.x, &p.y);
} }
m_lastPoint = currentPoint->Position; m_lastPoint = currentPoint->Position;
@ -319,7 +319,7 @@ void GLView::OnPointerReleased(PointerEventArgs^ args)
{ {
#if 0 #if 0
int id = args->CurrentPoint->PointerId; int id = args->CurrentPoint->PointerId;
Vector2 pt = GetPoint(args); Vec2 pt = GetPoint(args);
handleTouchesEnd(1, &id, &pt.x, &pt.y); handleTouchesEnd(1, &id, &pt.x, &pt.y);
#endif // 0 #endif // 0
@ -330,7 +330,7 @@ void GLView::OnPointerReleased(PointerEventArgs^ args)
void WinRTWindow::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args) void WinRTWindow::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
{ {
int id = args->CurrentPoint->PointerId; int id = args->CurrentPoint->PointerId;
Vector2 pt = GetCCPoint(args); Vec2 pt = GetCCPoint(args);
GLView::sharedOpenGLView()->handleTouchesBegin(1, &id, &pt.x, &pt.y); GLView::sharedOpenGLView()->handleTouchesBegin(1, &id, &pt.x, &pt.y);
} }
@ -342,7 +342,7 @@ void WinRTWindow::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
if (m_lastPointValid) if (m_lastPointValid)
{ {
int id = args->CurrentPoint->PointerId; int id = args->CurrentPoint->PointerId;
Vector2 p = GetCCPoint(args); Vec2 p = GetCCPoint(args);
GLView::sharedOpenGLView()->handleTouchesMove(1, &id, &p.x, &p.y); GLView::sharedOpenGLView()->handleTouchesMove(1, &id, &p.x, &p.y);
} }
m_lastPoint = currentPoint->Position; m_lastPoint = currentPoint->Position;
@ -357,7 +357,7 @@ void WinRTWindow::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
void WinRTWindow::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args) void WinRTWindow::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
{ {
int id = args->CurrentPoint->PointerId; int id = args->CurrentPoint->PointerId;
Vector2 pt = GetCCPoint(args); Vec2 pt = GetCCPoint(args);
GLView::sharedOpenGLView()->handleTouchesEnd(1, &id, &pt.x, &pt.y); GLView::sharedOpenGLView()->handleTouchesEnd(1, &id, &pt.x, &pt.y);
} }

View File

@ -56,7 +56,7 @@ public:
private: private:
cocos2d::Vector2 GetCCPoint(Windows::UI::Core::PointerEventArgs^ args); cocos2d::Vec2 GetCCPoint(Windows::UI::Core::PointerEventArgs^ args);
void OnTextKeyDown(Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e); void OnTextKeyDown(Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
void OnTextKeyUp(Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e); void OnTextKeyUp(Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);

View File

@ -190,7 +190,7 @@ void GLView::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
void GLView::OnPointerPressed(PointerEventArgs^ args) void GLView::OnPointerPressed(PointerEventArgs^ args)
{ {
int id = args->CurrentPoint->PointerId; int id = args->CurrentPoint->PointerId;
Vector2 pt = GetPoint(args); Vec2 pt = GetPoint(args);
handleTouchesBegin(1, &id, &pt.x, &pt.y); handleTouchesBegin(1, &id, &pt.x, &pt.y);
} }
@ -199,7 +199,7 @@ void GLView::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
{ {
float direction = (float)args->CurrentPoint->Properties->MouseWheelDelta; float direction = (float)args->CurrentPoint->Properties->MouseWheelDelta;
int id = 0; int id = 0;
Vector2 p(0.0f,0.0f); Vec2 p(0.0f,0.0f);
handleTouchesBegin(1, &id, &p.x, &p.y); handleTouchesBegin(1, &id, &p.x, &p.y);
p.y += direction; p.y += direction;
handleTouchesMove(1, &id, &p.x, &p.y); handleTouchesMove(1, &id, &p.x, &p.y);
@ -229,7 +229,7 @@ void GLView::OnPointerMoved( PointerEventArgs^ args)
if (m_lastPointValid) if (m_lastPointValid)
{ {
int id = args->CurrentPoint->PointerId; int id = args->CurrentPoint->PointerId;
Vector2 p = GetPoint(args); Vec2 p = GetPoint(args);
handleTouchesMove(1, &id, &p.x, &p.y); handleTouchesMove(1, &id, &p.x, &p.y);
} }
m_lastPoint = currentPoint->Position; m_lastPoint = currentPoint->Position;
@ -249,7 +249,7 @@ void GLView::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
void GLView::OnPointerReleased(PointerEventArgs^ args) void GLView::OnPointerReleased(PointerEventArgs^ args)
{ {
int id = args->CurrentPoint->PointerId; int id = args->CurrentPoint->PointerId;
Vector2 pt = GetPoint(args); Vec2 pt = GetPoint(args);
handleTouchesEnd(1, &id, &pt.x, &pt.y); handleTouchesEnd(1, &id, &pt.x, &pt.y);
} }
@ -429,9 +429,9 @@ void GLView::UpdateOrientationMatrix()
} }
} }
cocos2d::Vector2 GLView::TransformToOrientation(Windows::Foundation::Point p) cocos2d::Vec2 GLView::TransformToOrientation(Windows::Foundation::Point p)
{ {
cocos2d::Vector2 returnValue; cocos2d::Vec2 returnValue;
float x = p.X; float x = p.X;
float y = p.Y; float y = p.Y;
@ -440,16 +440,16 @@ cocos2d::Vector2 GLView::TransformToOrientation(Windows::Foundation::Point p)
{ {
case DisplayOrientations::Portrait: case DisplayOrientations::Portrait:
default: default:
returnValue = Vector2(x, y); returnValue = Vec2(x, y);
break; break;
case DisplayOrientations::Landscape: case DisplayOrientations::Landscape:
returnValue = Vector2(y, m_width - x); returnValue = Vec2(y, m_width - x);
break; break;
case DisplayOrientations::PortraitFlipped: case DisplayOrientations::PortraitFlipped:
returnValue = Vector2(m_width - x, m_height - y); returnValue = Vec2(m_width - x, m_height - y);
break; break;
case DisplayOrientations::LandscapeFlipped: case DisplayOrientations::LandscapeFlipped:
returnValue = Vector2(m_height - y, x); returnValue = Vec2(m_height - y, x);
break; break;
} }
@ -464,7 +464,7 @@ cocos2d::Vector2 GLView::TransformToOrientation(Windows::Foundation::Point p)
return returnValue; return returnValue;
} }
Vector2 GLView::GetPoint(PointerEventArgs^ args) { Vec2 GLView::GetPoint(PointerEventArgs^ args) {
return TransformToOrientation(args->CurrentPoint->Position); return TransformToOrientation(args->CurrentPoint->Position);

View File

@ -146,8 +146,8 @@ private:
void UpdateWindowSize(); void UpdateWindowSize();
void UpdateOrientationMatrix(); void UpdateOrientationMatrix();
cocos2d::Vector2 TransformToOrientation(Windows::Foundation::Point point); cocos2d::Vec2 TransformToOrientation(Windows::Foundation::Point point);
cocos2d::Vector2 GetPoint(Windows::UI::Core::PointerEventArgs^ args); cocos2d::Vec2 GetPoint(Windows::UI::Core::PointerEventArgs^ args);
Windows::Foundation::Rect m_windowBounds; Windows::Foundation::Rect m_windowBounds;
Windows::Foundation::EventRegistrationToken m_eventToken; Windows::Foundation::EventRegistrationToken m_eventToken;

View File

@ -330,9 +330,9 @@ void Direct3DBase::ComputeOrientationMatrices()
} }
} }
Vector2 Direct3DBase::TransformToOrientation(Vector2 point, bool dipsToPixels) Vec2 Direct3DBase::TransformToOrientation(Vec2 point, bool dipsToPixels)
{ {
Vector2 returnValue; Vec2 returnValue;
switch (m_orientation) switch (m_orientation)
{ {
@ -340,20 +340,20 @@ Vector2 Direct3DBase::TransformToOrientation(Vector2 point, bool dipsToPixels)
returnValue = point; returnValue = point;
break; break;
case DisplayOrientations::Landscape: case DisplayOrientations::Landscape:
returnValue = Vector2(point.Y, m_windowBounds.Width - point.X); returnValue = Vec2(point.Y, m_windowBounds.Width - point.X);
break; break;
case DisplayOrientations::PortraitFlipped: case DisplayOrientations::PortraitFlipped:
returnValue = Vector2(m_windowBounds.Width - point.X, m_windowBounds.Height - point.Y); returnValue = Vec2(m_windowBounds.Width - point.X, m_windowBounds.Height - point.Y);
break; break;
case DisplayOrientations::LandscapeFlipped: case DisplayOrientations::LandscapeFlipped:
returnValue = Vector2(m_windowBounds.Height -point.Y, point.X); returnValue = Vec2(m_windowBounds.Height -point.Y, point.X);
break; break;
default: default:
throw ref new Platform::FailureException(); throw ref new Platform::FailureException();
break; break;
} }
return dipsToPixels ? Vector2(ConvertDipsToPixels(returnValue.X), return dipsToPixels ? Vec2(ConvertDipsToPixels(returnValue.X),
ConvertDipsToPixels(returnValue.Y)) ConvertDipsToPixels(returnValue.Y))
: returnValue; : returnValue;
} }

View File

@ -24,7 +24,7 @@ public:
virtual void Present(); virtual void Present();
virtual float ConvertDipsToPixels(float dips); virtual float ConvertDipsToPixels(float dips);
virtual void ComputeOrientationMatrices(); virtual void ComputeOrientationMatrices();
virtual Windows::Foundation::Vector2 TransformToOrientation(Windows::Foundation::Vector2 point, bool dipsToPixels=true); virtual Windows::Foundation::Vec2 TransformToOrientation(Windows::Foundation::Vec2 point, bool dipsToPixels=true);
float getOrientedWindowWidth() {return m_orientedScreenSize.Width;}; float getOrientedWindowWidth() {return m_orientedScreenSize.Width;};
float getOrientedWindowHeight() {return m_orientedScreenSize.Height;}; float getOrientedWindowHeight() {return m_orientedScreenSize.Height;};

View File

@ -288,14 +288,14 @@ void Director::drawScene()
// draw the scene // draw the scene
if (_runningScene) if (_runningScene)
{ {
_runningScene->visit(_renderer, Matrix::IDENTITY, false); _runningScene->visit(_renderer, Mat4::IDENTITY, false);
_eventDispatcher->dispatchEvent(_eventAfterVisit); _eventDispatcher->dispatchEvent(_eventAfterVisit);
} }
// draw the notifications node // draw the notifications node
if (_notificationNode) if (_notificationNode)
{ {
_notificationNode->visit(_renderer, Matrix::IDENTITY, false); _notificationNode->visit(_renderer, Mat4::IDENTITY, false);
} }
if (_displayStats) if (_displayStats)
@ -449,9 +449,9 @@ void Director::initMatrixStack()
_textureMatrixStack.pop(); _textureMatrixStack.pop();
} }
_modelViewMatrixStack.push(Matrix::IDENTITY); _modelViewMatrixStack.push(Mat4::IDENTITY);
_projectionMatrixStack.push(Matrix::IDENTITY); _projectionMatrixStack.push(Mat4::IDENTITY);
_textureMatrixStack.push(Matrix::IDENTITY); _textureMatrixStack.push(Mat4::IDENTITY);
} }
void Director::resetMatrixStack() void Director::resetMatrixStack()
@ -483,15 +483,15 @@ void Director::loadIdentityMatrix(MATRIX_STACK_TYPE type)
{ {
if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type) if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type)
{ {
_modelViewMatrixStack.top() = Matrix::IDENTITY; _modelViewMatrixStack.top() = Mat4::IDENTITY;
} }
else if(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION == type) else if(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION == type)
{ {
_projectionMatrixStack.top() = Matrix::IDENTITY; _projectionMatrixStack.top() = Mat4::IDENTITY;
} }
else if(MATRIX_STACK_TYPE::MATRIX_STACK_TEXTURE == type) else if(MATRIX_STACK_TYPE::MATRIX_STACK_TEXTURE == type)
{ {
_textureMatrixStack.top() = Matrix::IDENTITY; _textureMatrixStack.top() = Mat4::IDENTITY;
} }
else else
{ {
@ -499,7 +499,7 @@ void Director::loadIdentityMatrix(MATRIX_STACK_TYPE type)
} }
} }
void Director::loadMatrix(MATRIX_STACK_TYPE type, const Matrix& mat) void Director::loadMatrix(MATRIX_STACK_TYPE type, const Mat4& mat)
{ {
if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type) if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type)
{ {
@ -519,7 +519,7 @@ void Director::loadMatrix(MATRIX_STACK_TYPE type, const Matrix& mat)
} }
} }
void Director::multiplyMatrix(MATRIX_STACK_TYPE type, const Matrix& mat) void Director::multiplyMatrix(MATRIX_STACK_TYPE type, const Mat4& mat)
{ {
if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type) if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type)
{ {
@ -559,9 +559,9 @@ void Director::pushMatrix(MATRIX_STACK_TYPE type)
} }
} }
Matrix Director::getMatrix(MATRIX_STACK_TYPE type) Mat4 Director::getMatrix(MATRIX_STACK_TYPE type)
{ {
Matrix result; Mat4 result;
if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type) if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type)
{ {
result = _modelViewMatrixStack.top(); result = _modelViewMatrixStack.top();
@ -608,8 +608,8 @@ void Director::setProjection(Projection projection)
multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, getOpenGLView()->getOrientationMatrix()); multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, getOpenGLView()->getOrientationMatrix());
} }
#endif #endif
Matrix orthoMatrix; Mat4 orthoMatrix;
Matrix::createOrthographicOffCenter(0, size.width, 0, size.height, -1024, 1024, &orthoMatrix); Mat4::createOrthographicOffCenter(0, size.width, 0, size.height, -1024, 1024, &orthoMatrix);
multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix); multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix);
loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
break; break;
@ -619,7 +619,7 @@ void Director::setProjection(Projection projection)
{ {
float zeye = this->getZEye(); float zeye = this->getZEye();
Matrix matrixPerspective, matrixLookup; Mat4 matrixPerspective, matrixLookup;
loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
@ -632,12 +632,12 @@ void Director::setProjection(Projection projection)
} }
#endif #endif
// issue #1334 // issue #1334
Matrix::createPerspective(60, (GLfloat)size.width/size.height, 10, zeye+size.height/2, &matrixPerspective); Mat4::createPerspective(60, (GLfloat)size.width/size.height, 10, zeye+size.height/2, &matrixPerspective);
multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, matrixPerspective); multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, matrixPerspective);
Vector3 eye(size.width/2, size.height/2, zeye), center(size.width/2, size.height/2, 0.0f), up(0.0f, 1.0f, 0.0f); Vec3 eye(size.width/2, size.height/2, zeye), center(size.width/2, size.height/2, 0.0f), up(0.0f, 1.0f, 0.0f);
Matrix::createLookAt(eye, center, up, &matrixLookup); Mat4::createLookAt(eye, center, up, &matrixLookup);
multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, matrixLookup); multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, matrixLookup);
loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
@ -712,14 +712,14 @@ void Director::setDepthTest(bool on)
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();
} }
static void GLToClipTransform(Matrix *transformOut) static void GLToClipTransform(Mat4 *transformOut)
{ {
if(nullptr == transformOut) return; if(nullptr == transformOut) return;
Director* director = Director::getInstance(); Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack"); CCASSERT(nullptr != director, "Director is null when seting matrix stack");
Matrix projection; Mat4 projection;
projection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); projection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 #if CC_TARGET_PLATFORM == CC_PLATFORM_WP8
@ -727,44 +727,44 @@ static void GLToClipTransform(Matrix *transformOut)
projection = Director::getInstance()->getOpenGLView()->getReverseOrientationMatrix() * projection; projection = Director::getInstance()->getOpenGLView()->getReverseOrientationMatrix() * projection;
#endif #endif
Matrix modelview; Mat4 modelview;
modelview = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); modelview = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
*transformOut = projection * modelview; *transformOut = projection * modelview;
} }
Vector2 Director::convertToGL(const Vector2& uiPoint) Vec2 Director::convertToGL(const Vec2& uiPoint)
{ {
Matrix transform; Mat4 transform;
GLToClipTransform(&transform); GLToClipTransform(&transform);
Matrix transformInv = transform.getInversed(); Mat4 transformInv = transform.getInversed();
// Calculate z=0 using -> transform*[0, 0, 0, 1]/w // Calculate z=0 using -> transform*[0, 0, 0, 1]/w
float zClip = transform.m[14]/transform.m[15]; float zClip = transform.m[14]/transform.m[15];
Size glSize = _openGLView->getDesignResolutionSize(); Size glSize = _openGLView->getDesignResolutionSize();
Vector4 clipCoord(2.0f*uiPoint.x/glSize.width - 1.0f, 1.0f - 2.0f*uiPoint.y/glSize.height, zClip, 1); Vec4 clipCoord(2.0f*uiPoint.x/glSize.width - 1.0f, 1.0f - 2.0f*uiPoint.y/glSize.height, zClip, 1);
Vector4 glCoord; Vec4 glCoord;
//transformInv.transformPoint(clipCoord, &glCoord); //transformInv.transformPoint(clipCoord, &glCoord);
transformInv.transformVector(clipCoord, &glCoord); transformInv.transformVector(clipCoord, &glCoord);
float factor = 1.0/glCoord.w; float factor = 1.0/glCoord.w;
return Vector2(glCoord.x * factor, glCoord.y * factor); return Vec2(glCoord.x * factor, glCoord.y * factor);
} }
Vector2 Director::convertToUI(const Vector2& glPoint) Vec2 Director::convertToUI(const Vec2& glPoint)
{ {
Matrix transform; Mat4 transform;
GLToClipTransform(&transform); GLToClipTransform(&transform);
Vector4 clipCoord; Vec4 clipCoord;
// Need to calculate the zero depth from the transform. // Need to calculate the zero depth from the transform.
Vector4 glCoord(glPoint.x, glPoint.y, 0.0, 1); Vec4 glCoord(glPoint.x, glPoint.y, 0.0, 1);
transform.transformVector(glCoord, &clipCoord); transform.transformVector(glCoord, &clipCoord);
Size glSize = _openGLView->getDesignResolutionSize(); Size glSize = _openGLView->getDesignResolutionSize();
float factor = 1.0/glCoord.w; float factor = 1.0/glCoord.w;
return Vector2(glSize.width*(clipCoord.x*0.5 + 0.5) * factor, glSize.height*(-clipCoord.y*0.5 + 0.5) * factor); return Vec2(glSize.width*(clipCoord.x*0.5 + 0.5) * factor, glSize.height*(-clipCoord.y*0.5 + 0.5) * factor);
} }
const Size& Director::getWinSize(void) const const Size& Director::getWinSize(void) const
@ -789,7 +789,7 @@ Size Director::getVisibleSize() const
} }
} }
Vector2 Director::getVisibleOrigin() const Vec2 Director::getVisibleOrigin() const
{ {
if (_openGLView) if (_openGLView)
{ {
@ -797,7 +797,7 @@ Vector2 Director::getVisibleOrigin() const
} }
else else
{ {
return Vector2::ZERO; return Vec2::ZERO;
} }
} }
@ -1080,7 +1080,7 @@ void Director::showStats()
prevVerts = currentVerts; prevVerts = currentVerts;
} }
Matrix identity = Matrix::IDENTITY; Mat4 identity = Mat4::IDENTITY;
_drawnVerticesLabel->visit(_renderer, identity, false); _drawnVerticesLabel->visit(_renderer, identity, false);
_drawnBatchesLabel->visit(_renderer, identity, false); _drawnBatchesLabel->visit(_renderer, identity, false);
@ -1165,9 +1165,9 @@ void Director::createStatsLabel()
Texture2D::setDefaultAlphaPixelFormat(currentFormat); Texture2D::setDefaultAlphaPixelFormat(currentFormat);
const int height_spacing = 22 / CC_CONTENT_SCALE_FACTOR(); const int height_spacing = 22 / CC_CONTENT_SCALE_FACTOR();
_drawnVerticesLabel->setPosition(Vector2(0, height_spacing*2) + CC_DIRECTOR_STATS_POSITION); _drawnVerticesLabel->setPosition(Vec2(0, height_spacing*2) + CC_DIRECTOR_STATS_POSITION);
_drawnBatchesLabel->setPosition(Vector2(0, height_spacing*1) + CC_DIRECTOR_STATS_POSITION); _drawnBatchesLabel->setPosition(Vec2(0, height_spacing*1) + CC_DIRECTOR_STATS_POSITION);
_FPSLabel->setPosition(Vector2(0, height_spacing*0)+CC_DIRECTOR_STATS_POSITION); _FPSLabel->setPosition(Vec2(0, height_spacing*0)+CC_DIRECTOR_STATS_POSITION);
} }
void Director::setContentScaleFactor(float scaleFactor) void Director::setContentScaleFactor(float scaleFactor)

Some files were not shown because too many files have changed in this diff Show More