axmol/core/2d/CCActionCatmullRom.cpp

511 lines
12 KiB
C++
Raw Normal View History

2012-06-08 13:55:28 +08:00
/*
* Copyright (c) 2008 Radu Gruian
* Copyright (c) 2011 Vit Valentin
* Copyright (c) 2012 cocos2d-x.org
* Copyright (c) 2013-2016 Chukong Technologies Inc.
* Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
2012-06-08 13:55:28 +08:00
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
2021-12-25 10:04:45 +08:00
* Original code by Radu Gruian:
* http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So
2012-06-08 13:55:28 +08:00
*
* Adapted to cocos2d-x by Vit Valentin
*
* Adapted from cocos2d-x to cocos2d-iphone by Ricardo Quesada
*/
2014-04-30 08:37:36 +08:00
#include "base/ccMacros.h"
#include "2d/CCActionCatmullRom.h"
2014-08-26 18:19:28 +08:00
#include "2d/CCNode.h"
2012-06-08 13:55:28 +08:00
#include <iterator>
using namespace std;
NS_AX_BEGIN;
2012-06-08 13:55:28 +08:00
/*
* Implementation of PointArray
2012-06-08 13:55:28 +08:00
*/
2013-12-27 15:06:16 +08:00
PointArray* PointArray::create(ssize_t capacity)
2012-06-08 13:55:28 +08:00
{
2021-12-08 00:11:53 +08:00
PointArray* pointArray = new PointArray();
if (pointArray->initWithCapacity(capacity))
2012-06-08 13:55:28 +08:00
{
pointArray->autorelease();
return pointArray;
2012-06-08 13:55:28 +08:00
}
delete pointArray;
return nullptr;
2012-06-08 13:55:28 +08:00
}
2013-12-27 15:06:16 +08:00
bool PointArray::initWithCapacity(ssize_t capacity)
2012-06-08 13:55:28 +08:00
{
_controlPoints.reserve(capacity);
2021-12-25 10:04:45 +08:00
2012-06-08 13:55:28 +08:00
return true;
}
PointArray* PointArray::clone() const
2012-06-08 13:55:28 +08:00
{
vector<Vec2> newArray = _controlPoints;
2021-12-25 10:04:45 +08:00
PointArray* points = new PointArray();
points->initWithCapacity(10);
points->setControlPoints(std::move(newArray));
points->autorelease();
2012-06-08 13:55:28 +08:00
return points;
}
PointArray::~PointArray()
2012-06-08 13:55:28 +08:00
{
CCLOGINFO("deallocing PointArray: %p", this);
2012-06-08 13:55:28 +08:00
}
PointArray::PointArray() {}
2012-06-08 13:55:28 +08:00
const std::vector<Vec2>& PointArray::getControlPoints() const
2012-06-08 13:55:28 +08:00
{
return _controlPoints;
}
void PointArray::setControlPoints(vector<Vec2> controlPoints)
{
_controlPoints = std::move(controlPoints);
}
2016-05-17 12:17:56 +08:00
void PointArray::addControlPoint(const Vec2& controlPoint)
2021-12-25 10:04:45 +08:00
{
_controlPoints.push_back(controlPoint);
2012-06-08 13:55:28 +08:00
}
void PointArray::insertControlPoint(const Vec2& controlPoint, ssize_t index)
2012-06-08 13:55:28 +08:00
{
_controlPoints.insert(std::next(_controlPoints.begin(), index), controlPoint);
2012-06-08 13:55:28 +08:00
}
const Vec2& PointArray::getControlPointAtIndex(ssize_t index) const
2012-06-08 13:55:28 +08:00
{
2021-12-25 10:04:45 +08:00
index = MIN(static_cast<ssize_t>(_controlPoints.size()) - 1, MAX(index, 0));
return _controlPoints.at(index);
2012-06-08 13:55:28 +08:00
}
void PointArray::replaceControlPoint(const Vec2& controlPoint, ssize_t index)
2012-06-08 13:55:28 +08:00
{
_controlPoints.at(index) = controlPoint;
2012-06-08 13:55:28 +08:00
}
2013-12-27 15:06:16 +08:00
void PointArray::removeControlPointAtIndex(ssize_t index)
2012-06-08 13:55:28 +08:00
{
vector<Vec2>::iterator iter = std::next(_controlPoints.begin(), index);
_controlPoints.erase(iter);
2012-06-08 13:55:28 +08:00
}
2013-12-27 15:06:16 +08:00
ssize_t PointArray::count() const
2012-06-08 13:55:28 +08:00
{
return _controlPoints.size();
2012-06-08 13:55:28 +08:00
}
PointArray* PointArray::reverse() const
2012-06-08 13:55:28 +08:00
{
vector<Vec2> newArray;
newArray.reserve(_controlPoints.size());
for (auto iter = _controlPoints.rbegin(), iterRend = _controlPoints.rend(); iter != iterRend; ++iter)
2012-06-08 13:55:28 +08:00
{
newArray.push_back(*iter);
2012-06-08 13:55:28 +08:00
}
2021-12-25 10:04:45 +08:00
PointArray* config = PointArray::create(0);
config->setControlPoints(std::move(newArray));
2021-12-25 10:04:45 +08:00
2012-06-08 13:55:28 +08:00
return config;
}
void PointArray::reverseInline()
2012-06-08 13:55:28 +08:00
{
const size_t l = _controlPoints.size();
2021-12-25 10:04:45 +08:00
Vec2* p1 = nullptr;
Vec2* p2 = nullptr;
2013-12-27 15:06:16 +08:00
float x, y;
2021-12-25 10:04:45 +08:00
for (size_t i = 0; i < l / 2; ++i)
2012-06-08 13:55:28 +08:00
{
p1 = &_controlPoints.at(i);
2021-12-25 10:04:45 +08:00
p2 = &_controlPoints.at(l - i - 1);
x = p1->x;
y = p1->y;
2021-12-25 10:04:45 +08:00
p1->x = p2->x;
p1->y = p2->y;
2021-12-25 10:04:45 +08:00
p2->x = x;
p2->y = y;
2012-06-08 13:55:28 +08:00
}
}
// CatmullRom Spline formula:
2021-12-25 10:04:45 +08:00
Vec2 ccCardinalSplineAt(const Vec2& p0, const Vec2& p1, const Vec2& p2, const Vec2& p3, float tension, float t)
2012-06-08 13:55:28 +08:00
{
float t2 = t * t;
float t3 = t2 * t;
2021-12-25 10:04:45 +08:00
/*
2021-12-25 10:04:45 +08:00
* Formula: s(-ttt + 2tt - t)P1 + s(-ttt + tt)P2 + (2ttt - 3tt + 1)P2 + s(ttt - 2tt + t)P3 + (-2ttt + 3tt)P3 + s(ttt
* - tt)P4
*/
2012-06-08 13:55:28 +08:00
float s = (1 - tension) / 2;
2021-12-25 10:04:45 +08:00
float b1 = s * ((-t3 + (2 * t2)) - t); // s(-t3 + 2 t2 - t)P1
float b2 = s * (-t3 + t2) + (2 * t3 - 3 * t2 + 1); // s(-t3 + t2)P2 + (2 t3 - 3 t2 + 1)P2
float b3 = s * (t3 - 2 * t2 + t) + (-2 * t3 + 3 * t2); // s(t3 - 2 t2 + t)P3 + (-2 t3 + 3 t2)P3
float b4 = s * (t3 - t2); // s(t3 - t2)P4
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);
2021-12-25 10:04:45 +08:00
return Vec2(x, y);
2012-06-08 13:55:28 +08:00
}
/* Implementation of CardinalSplineTo
2012-06-08 13:55:28 +08:00
*/
2021-12-25 10:04:45 +08:00
CardinalSplineTo* CardinalSplineTo::create(float duration, PointArray* points, float tension)
2012-06-08 13:55:28 +08:00
{
2021-12-25 10:04:45 +08:00
CardinalSplineTo* ret = new CardinalSplineTo();
2021-12-08 00:11:53 +08:00
if (ret->initWithDuration(duration, points, tension))
2012-06-08 13:55:28 +08:00
{
2021-12-08 00:11:53 +08:00
ret->autorelease();
}
2021-12-25 10:04:45 +08:00
else
2021-12-08 00:11:53 +08:00
{
2022-07-15 19:17:01 +08:00
AX_SAFE_DELETE(ret);
2012-06-08 13:55:28 +08:00
}
2012-06-08 13:55:28 +08:00
return ret;
}
2021-12-25 10:04:45 +08:00
bool CardinalSplineTo::initWithDuration(float duration, PointArray* points, float tension)
2012-06-08 13:55:28 +08:00
{
CCASSERT(points->count() > 0, "Invalid configuration. It must at least have one control point");
2012-06-08 13:55:28 +08:00
if (ActionInterval::initWithDuration(duration))
2012-06-08 13:55:28 +08:00
{
this->setPoints(points);
this->_tension = tension;
2021-12-25 10:04:45 +08:00
2012-06-08 13:55:28 +08:00
return true;
}
2021-12-25 10:04:45 +08:00
2012-06-08 13:55:28 +08:00
return false;
}
CardinalSplineTo::~CardinalSplineTo()
2012-06-08 13:55:28 +08:00
{
2022-07-15 19:17:01 +08:00
AX_SAFE_RELEASE_NULL(_points);
2012-06-08 13:55:28 +08:00
}
2021-12-25 10:04:45 +08:00
CardinalSplineTo::CardinalSplineTo() : _points(nullptr), _deltaT(0.f), _tension(0.f) {}
2012-06-08 13:55:28 +08:00
2021-12-25 10:04:45 +08:00
void CardinalSplineTo::startWithTarget(Node* target)
2012-06-08 13:55:28 +08:00
{
ActionInterval::startWithTarget(target);
2021-12-25 10:04:45 +08:00
// _deltaT = (float) 1 / _points->count();
2012-11-14 18:05:15 +08:00
// Issue #1441
2021-12-25 10:04:45 +08:00
_deltaT = (float)1 / (_points->count() - 1);
_previousPosition = target->getPosition();
_accumulatedDiff.setZero();
2012-06-08 13:55:28 +08:00
}
CardinalSplineTo* CardinalSplineTo::clone() const
{
// no copy constructor
2021-12-08 00:11:53 +08:00
auto a = new CardinalSplineTo();
a->initWithDuration(this->_duration, this->_points->clone(), this->_tension);
a->autorelease();
return a;
}
void CardinalSplineTo::update(float time)
2012-06-08 13:55:28 +08:00
{
2013-12-28 14:34:52 +08:00
ssize_t p;
2012-06-08 13:55:28 +08:00
float lt;
// eg.
// p..p..p..p..p..p..p
// 1..2..3..4..5..6..7
// want p to be 1, 2, 3, 4, 5, 6
2012-06-08 13:55:28 +08:00
if (time == 1)
{
2021-12-25 10:04:45 +08:00
p = _points->count() - 1;
2012-06-08 13:55:28 +08:00
lt = 1;
}
2021-12-25 10:04:45 +08:00
else
2012-06-08 13:55:28 +08:00
{
2021-12-25 10:04:45 +08:00
p = (ssize_t)(time / _deltaT);
lt = (time - _deltaT * p) / _deltaT;
2012-06-08 13:55:28 +08:00
}
2021-12-25 10:04:45 +08:00
// Interpolate
2021-12-25 10:04:45 +08:00
Vec2 pp0 = _points->getControlPointAtIndex(p - 1);
Vec2 pp1 = _points->getControlPointAtIndex(p + 0);
Vec2 pp2 = _points->getControlPointAtIndex(p + 1);
Vec2 pp3 = _points->getControlPointAtIndex(p + 2);
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
2014-05-15 01:07:09 +08:00
Vec2 newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, _tension, lt);
2022-07-15 19:17:01 +08:00
#if AX_ENABLE_STACKABLE_ACTIONS
// Support for stacked actions
2021-12-25 10:04:45 +08:00
Node* node = _target;
Vec2 diff = node->getPosition() - _previousPosition;
if (diff.x != 0 || diff.y != 0)
{
_accumulatedDiff = _accumulatedDiff + diff;
2021-12-25 10:04:45 +08:00
newPos = newPos + _accumulatedDiff;
}
2013-02-27 09:38:30 +08:00
#endif
2021-12-25 10:04:45 +08:00
2012-06-08 13:55:28 +08:00
this->updatePosition(newPos);
}
2021-12-25 10:04:45 +08:00
void CardinalSplineTo::updatePosition(const Vec2& newPos)
2012-06-08 13:55:28 +08:00
{
_target->setPosition(newPos);
_previousPosition = newPos;
2012-06-08 13:55:28 +08:00
}
CardinalSplineTo* CardinalSplineTo::reverse() const
2012-06-08 13:55:28 +08:00
{
2021-12-25 10:04:45 +08:00
PointArray* pReverse = _points->reverse();
return CardinalSplineTo::create(_duration, pReverse, _tension);
2012-06-08 13:55:28 +08:00
}
/* CardinalSplineBy
2012-06-08 13:55:28 +08:00
*/
2021-12-25 10:04:45 +08:00
CardinalSplineBy* CardinalSplineBy::create(float duration, PointArray* points, float tension)
2012-06-08 13:55:28 +08:00
{
2021-12-25 10:04:45 +08:00
CardinalSplineBy* ret = new CardinalSplineBy();
2021-12-08 00:11:53 +08:00
if (ret->initWithDuration(duration, points, tension))
2012-06-08 13:55:28 +08:00
{
2021-12-08 00:11:53 +08:00
ret->autorelease();
}
2021-12-25 10:04:45 +08:00
else
2021-12-08 00:11:53 +08:00
{
2022-07-15 19:17:01 +08:00
AX_SAFE_DELETE(ret);
2012-06-08 13:55:28 +08:00
}
2012-06-08 13:55:28 +08:00
return ret;
}
2021-12-25 10:04:45 +08:00
CardinalSplineBy::CardinalSplineBy() : _startPosition(0, 0) {}
2012-06-08 13:55:28 +08:00
2021-12-25 10:04:45 +08:00
void CardinalSplineBy::updatePosition(const Vec2& newPos)
2012-06-08 13:55:28 +08:00
{
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
2014-05-15 01:07:09 +08:00
Vec2 p = newPos + _startPosition;
_target->setPosition(p);
_previousPosition = p;
2012-06-08 13:55:28 +08:00
}
CardinalSplineBy* CardinalSplineBy::reverse() const
2012-06-08 13:55:28 +08:00
{
2021-12-25 10:04:45 +08:00
PointArray* copyConfig = _points->clone();
//
// convert "absolutes" to "diffs"
//
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
2014-05-15 01:07:09 +08:00
Vec2 p = copyConfig->getControlPointAtIndex(0);
2013-12-27 15:06:16 +08:00
for (ssize_t i = 1; i < copyConfig->count(); ++i)
2012-06-08 13:55:28 +08:00
{
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
2014-05-15 01:07:09 +08:00
Vec2 current = copyConfig->getControlPointAtIndex(i);
2021-12-25 10:04:45 +08:00
Vec2 diff = current - p;
2012-06-08 13:55:28 +08:00
copyConfig->replaceControlPoint(diff, i);
2021-12-25 10:04:45 +08:00
2012-06-08 13:55:28 +08:00
p = current;
}
// convert to "diffs" to "reverse absolute"
2021-12-25 10:04:45 +08:00
PointArray* pReverse = copyConfig->reverse();
// 1st element (which should be 0,0) should be here too
2021-12-25 10:04:45 +08:00
p = pReverse->getControlPointAtIndex(pReverse->count() - 1);
pReverse->removeControlPointAtIndex(pReverse->count() - 1);
p = -p;
pReverse->insertControlPoint(p, 0);
2021-12-25 10:04:45 +08:00
2013-12-27 15:06:16 +08:00
for (ssize_t i = 1; i < pReverse->count(); ++i)
2012-06-08 13:55:28 +08:00
{
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
2014-05-15 01:07:09 +08:00
Vec2 current = pReverse->getControlPointAtIndex(i);
2021-12-25 10:04:45 +08:00
current = -current;
Vec2 abs = current + p;
pReverse->replaceControlPoint(abs, i);
2021-12-25 10:04:45 +08:00
2012-06-08 13:55:28 +08:00
p = abs;
}
return CardinalSplineBy::create(_duration, pReverse, _tension);
2012-06-08 13:55:28 +08:00
}
2021-12-25 10:04:45 +08:00
void CardinalSplineBy::startWithTarget(Node* target)
{
CardinalSplineTo::startWithTarget(target);
_startPosition = target->getPosition();
2012-06-08 13:55:28 +08:00
}
CardinalSplineBy* CardinalSplineBy::clone() const
{
// no copy constructor
2021-12-08 00:11:53 +08:00
auto a = new CardinalSplineBy();
a->initWithDuration(this->_duration, this->_points->clone(), this->_tension);
a->autorelease();
return a;
}
/* CatmullRomTo
2012-06-08 13:55:28 +08:00
*/
2021-12-25 10:04:45 +08:00
CatmullRomTo* CatmullRomTo::create(float dt, PointArray* points)
2012-06-08 13:55:28 +08:00
{
2021-12-25 10:04:45 +08:00
CatmullRomTo* ret = new CatmullRomTo();
2021-12-08 00:11:53 +08:00
if (ret->initWithDuration(dt, points))
2012-06-08 13:55:28 +08:00
{
2021-12-08 00:11:53 +08:00
ret->autorelease();
}
2021-12-25 10:04:45 +08:00
else
2021-12-08 00:11:53 +08:00
{
2022-07-15 19:17:01 +08:00
AX_SAFE_DELETE(ret);
2012-06-08 13:55:28 +08:00
}
2012-06-08 13:55:28 +08:00
return ret;
}
2021-12-25 10:04:45 +08:00
bool CatmullRomTo::initWithDuration(float dt, PointArray* points)
2012-06-08 13:55:28 +08:00
{
if (CardinalSplineTo::initWithDuration(dt, points, 0.5f))
2012-06-08 13:55:28 +08:00
{
return true;
}
2021-12-25 10:04:45 +08:00
2012-06-08 13:55:28 +08:00
return false;
}
CatmullRomTo* CatmullRomTo::clone() const
{
// no copy constructor
2021-12-08 00:11:53 +08:00
auto a = new CatmullRomTo();
a->initWithDuration(this->_duration, this->_points->clone());
a->autorelease();
return a;
}
CatmullRomTo* CatmullRomTo::reverse() const
{
2021-12-25 10:04:45 +08:00
PointArray* reverse = _points->reverse();
return CatmullRomTo::create(_duration, reverse);
}
/* CatmullRomBy
2012-06-08 13:55:28 +08:00
*/
2021-12-25 10:04:45 +08:00
CatmullRomBy* CatmullRomBy::create(float dt, PointArray* points)
2012-06-08 13:55:28 +08:00
{
2021-12-25 10:04:45 +08:00
CatmullRomBy* ret = new CatmullRomBy();
2021-12-08 00:11:53 +08:00
if (ret->initWithDuration(dt, points))
2012-06-08 13:55:28 +08:00
{
2021-12-08 00:11:53 +08:00
ret->autorelease();
}
2021-12-25 10:04:45 +08:00
else
2021-12-08 00:11:53 +08:00
{
2022-07-15 19:17:01 +08:00
AX_SAFE_DELETE(ret);
2012-06-08 13:55:28 +08:00
}
return ret;
}
2021-12-25 10:04:45 +08:00
bool CatmullRomBy::initWithDuration(float dt, PointArray* points)
2012-06-08 13:55:28 +08:00
{
if (CardinalSplineTo::initWithDuration(dt, points, 0.5f))
2012-06-08 13:55:28 +08:00
{
return true;
}
2021-12-25 10:04:45 +08:00
2012-06-08 13:55:28 +08:00
return false;
}
CatmullRomBy* CatmullRomBy::clone() const
{
// no copy constructor
2021-12-08 00:11:53 +08:00
auto a = new CatmullRomBy();
a->initWithDuration(this->_duration, this->_points->clone());
a->autorelease();
return a;
}
CatmullRomBy* CatmullRomBy::reverse() const
{
2021-12-25 10:04:45 +08:00
PointArray* copyConfig = _points->clone();
//
// convert "absolutes" to "diffs"
//
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
2014-05-15 01:07:09 +08:00
Vec2 p = copyConfig->getControlPointAtIndex(0);
2013-12-27 15:06:16 +08:00
for (ssize_t i = 1; i < copyConfig->count(); ++i)
{
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
2014-05-15 01:07:09 +08:00
Vec2 current = copyConfig->getControlPointAtIndex(i);
2021-12-25 10:04:45 +08:00
Vec2 diff = current - p;
copyConfig->replaceControlPoint(diff, i);
p = current;
}
// convert to "diffs" to "reverse absolute"
2021-12-25 10:04:45 +08:00
PointArray* reverse = copyConfig->reverse();
// 1st element (which should be 0,0) should be here too
2021-12-25 10:04:45 +08:00
p = reverse->getControlPointAtIndex(reverse->count() - 1);
reverse->removeControlPointAtIndex(reverse->count() - 1);
p = -p;
2013-11-16 21:08:00 +08:00
reverse->insertControlPoint(p, 0);
2013-12-27 15:06:16 +08:00
for (ssize_t i = 1; i < reverse->count(); ++i)
{
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
2014-05-15 01:07:09 +08:00
Vec2 current = reverse->getControlPointAtIndex(i);
2021-12-25 10:04:45 +08:00
current = -current;
Vec2 abs = current + p;
2013-11-16 21:08:00 +08:00
reverse->replaceControlPoint(abs, i);
p = abs;
}
2013-11-16 21:08:00 +08:00
return CatmullRomBy::create(_duration, reverse);
}
NS_AX_END;