axmol/extensions/cocostudio/CCBone.cpp

474 lines
12 KiB
C++
Raw Normal View History

2013-06-06 12:02:54 +08:00
/****************************************************************************
2020-10-17 16:32:16 +08:00
Copyright (c) 2013-2017 Chukong Technologies Inc.
2021-07-16 11:04:38 +08:00
Copyright (c) 2021 Bytedance Inc.
2013-06-06 12:02:54 +08:00
2022-08-08 18:02:17 +08:00
https://axys1.github.io/
2013-06-06 12:02:54 +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.
****************************************************************************/
#include "CCBone.h"
#include "CCArmature.h"
#include "CCArmatureDataManager.h"
#include "CCTransformHelp.h"
#include "CCDisplayManager.h"
2013-06-06 12:02:54 +08:00
USING_NS_AX;
2021-12-25 10:04:45 +08:00
namespace cocostudio
{
2013-06-06 12:02:54 +08:00
2021-12-25 10:04:45 +08:00
Bone* Bone::create()
2013-06-06 12:02:54 +08:00
{
2021-12-25 10:04:45 +08:00
Bone* pBone = new Bone();
2021-12-08 00:11:53 +08:00
if (pBone->init())
2013-06-06 12:02:54 +08:00
{
pBone->autorelease();
return pBone;
}
2022-07-15 19:17:01 +08:00
AX_SAFE_DELETE(pBone);
return nullptr;
2013-06-06 12:02:54 +08:00
}
2013-06-07 10:52:32 +08:00
2021-12-26 23:26:34 +08:00
Bone* Bone::create(std::string_view name)
2013-06-06 12:02:54 +08:00
{
2013-06-07 10:52:32 +08:00
2021-12-25 10:04:45 +08:00
Bone* pBone = new Bone();
2021-12-08 00:11:53 +08:00
if (pBone->init(name))
2013-06-06 12:02:54 +08:00
{
pBone->autorelease();
return pBone;
}
2022-07-15 19:17:01 +08:00
AX_SAFE_DELETE(pBone);
return nullptr;
2013-06-06 12:02:54 +08:00
}
Bone::Bone()
2021-07-16 11:04:38 +08:00
: _tweenData(nullptr)
, _parentBone(nullptr)
, _armature(nullptr)
, _childArmature(nullptr)
, _boneData(nullptr)
, _tween(nullptr)
, _displayManager(nullptr)
, _ignoreMovementBoneData(false)
, _worldTransform(Mat4::IDENTITY)
, _boneTransformDirty(true)
, _blendFunc(BlendFunc::ALPHA_PREMULTIPLIED)
, _blendDirty(false)
, _worldInfo(nullptr)
, _armatureParentBone(nullptr)
, _dataVersion(0)
{}
2013-06-06 12:02:54 +08:00
2020-10-17 16:32:16 +08:00
Bone::~Bone(void)
2013-06-06 12:02:54 +08:00
{
2022-07-15 19:17:01 +08:00
AX_SAFE_DELETE(_tweenData);
AX_SAFE_DELETE(_tween);
AX_SAFE_DELETE(_displayManager);
AX_SAFE_DELETE(_worldInfo);
2013-06-07 10:52:32 +08:00
2022-07-15 19:17:01 +08:00
AX_SAFE_RELEASE_NULL(_boneData);
2013-06-07 10:52:32 +08:00
2022-07-15 19:17:01 +08:00
AX_SAFE_RELEASE(_childArmature);
2013-06-06 12:02:54 +08:00
}
bool Bone::init()
2013-06-06 12:02:54 +08:00
{
2020-10-17 16:32:16 +08:00
return Bone::init(nullptr);
2013-06-06 12:02:54 +08:00
}
2021-12-26 23:26:34 +08:00
bool Bone::init(std::string_view name)
2013-06-06 12:02:54 +08:00
{
bool bRet = false;
do
{
2013-06-07 10:52:32 +08:00
_name = name;
2013-06-06 12:02:54 +08:00
2022-07-15 19:17:01 +08:00
AX_SAFE_DELETE(_tweenData);
2021-12-08 00:11:53 +08:00
_tweenData = new FrameData();
2013-06-06 12:02:54 +08:00
2022-07-15 19:17:01 +08:00
AX_SAFE_DELETE(_tween);
2021-12-08 00:11:53 +08:00
_tween = new Tween();
2013-09-16 14:56:59 +08:00
_tween->init(this);
2013-06-07 10:52:32 +08:00
2022-07-15 19:17:01 +08:00
AX_SAFE_DELETE(_displayManager);
2021-12-08 00:11:53 +08:00
_displayManager = new DisplayManager();
2013-09-16 12:21:18 +08:00
_displayManager->init(this);
2013-06-07 10:52:32 +08:00
2022-07-15 19:17:01 +08:00
AX_SAFE_DELETE(_worldInfo);
2021-12-08 00:11:53 +08:00
_worldInfo = new BaseData();
2013-06-07 10:52:32 +08:00
2022-07-15 19:17:01 +08:00
AX_SAFE_DELETE(_boneData);
2021-12-25 10:04:45 +08:00
_boneData = new BoneData();
2013-06-06 12:02:54 +08:00
bRet = true;
2021-12-25 10:04:45 +08:00
} while (0);
2013-06-06 12:02:54 +08:00
return bRet;
}
2021-12-25 10:04:45 +08:00
void Bone::setBoneData(BoneData* boneData)
2013-06-06 12:02:54 +08:00
{
2022-07-16 10:43:05 +08:00
AXASSERT(nullptr != boneData, "_boneData must not be nullptr");
2013-06-07 10:52:32 +08:00
if (_boneData != boneData)
{
2022-07-15 19:17:01 +08:00
AX_SAFE_RETAIN(boneData);
AX_SAFE_RELEASE(_boneData);
_boneData = boneData;
}
2013-06-07 10:52:32 +08:00
2013-09-16 12:21:18 +08:00
_name = _boneData->name;
_setLocalZOrder(_boneData->zOrder);
2013-06-07 10:52:32 +08:00
2013-09-16 12:21:18 +08:00
_displayManager->initDisplayList(boneData);
2013-06-06 12:02:54 +08:00
}
2013-06-07 10:52:32 +08:00
2021-12-25 10:04:45 +08:00
BoneData* Bone::getBoneData() const
2013-06-06 12:02:54 +08:00
{
2013-09-16 12:21:18 +08:00
return _boneData;
2013-06-06 12:02:54 +08:00
}
2013-06-07 10:52:32 +08:00
2021-12-25 10:04:45 +08:00
void Bone::setArmature(Armature* armature)
{
2013-09-15 20:24:25 +08:00
_armature = armature;
if (_armature)
2013-09-13 18:07:37 +08:00
{
2013-09-16 14:56:59 +08:00
_tween->setAnimation(_armature->getAnimation());
2021-12-25 10:04:45 +08:00
_dataVersion = _armature->getArmatureData()->dataVersion;
2013-10-30 09:41:40 +08:00
_armatureParentBone = _armature->getParentBone();
}
else
{
_armatureParentBone = nullptr;
2013-09-13 18:07:37 +08:00
}
}
2021-12-25 10:04:45 +08:00
Armature* Bone::getArmature() const
{
2013-09-15 20:24:25 +08:00
return _armature;
}
void Bone::update(float delta)
2013-06-06 12:02:54 +08:00
{
2013-09-15 20:24:25 +08:00
if (_parentBone)
2013-09-16 12:21:18 +08:00
_boneTransformDirty = _boneTransformDirty || _parentBone->isTransformDirty();
2013-06-07 10:52:32 +08:00
2013-10-30 09:41:40 +08:00
if (_armatureParentBone && !_boneTransformDirty)
2013-10-29 16:57:06 +08:00
{
2013-10-30 09:41:40 +08:00
_boneTransformDirty = _armatureParentBone->isTransformDirty();
2013-10-29 16:57:06 +08:00
}
2013-09-16 12:21:18 +08:00
if (_boneTransformDirty)
2013-06-07 10:52:32 +08:00
{
_worldInfo->copy(_tweenData);
2013-10-30 09:41:40 +08:00
if (_dataVersion >= VERSION_COMBINED)
2013-09-13 18:07:37 +08:00
{
TransformHelp::nodeConcat(*_worldInfo, *_boneData);
_worldInfo->scaleX -= 1;
_worldInfo->scaleY -= 1;
2013-09-13 18:07:37 +08:00
}
2013-06-07 10:52:32 +08:00
2021-12-25 10:04:45 +08:00
_worldInfo->x = _worldInfo->x + _position.x;
_worldInfo->y = _worldInfo->y + _position.y;
_worldInfo->scaleX = _worldInfo->scaleX * _scaleX;
_worldInfo->scaleY = _worldInfo->scaleY * _scaleY;
2022-07-15 19:17:01 +08:00
_worldInfo->skewX = _worldInfo->skewX + _skewX + AX_DEGREES_TO_RADIANS(_rotationZ_X);
_worldInfo->skewY = _worldInfo->skewY + _skewY - AX_DEGREES_TO_RADIANS(_rotationZ_Y);
2013-06-07 10:52:32 +08:00
2021-12-25 10:04:45 +08:00
if (_parentBone)
2013-06-07 10:52:32 +08:00
{
2013-10-30 09:41:40 +08:00
applyParentTransform(_parentBone);
2013-06-07 10:52:32 +08:00
}
2013-10-29 16:57:06 +08:00
else
{
2013-10-30 09:41:40 +08:00
if (_armatureParentBone)
2013-10-29 16:57:06 +08:00
{
2013-10-30 09:41:40 +08:00
applyParentTransform(_armatureParentBone);
2013-10-29 16:57:06 +08:00
}
}
2013-10-30 09:41:40 +08:00
TransformHelp::nodeToMatrix(*_worldInfo, _worldTransform);
if (_armatureParentBone)
{
2013-12-11 03:07:15 +08:00
_worldTransform = TransformConcat(_worldTransform, _armature->getNodeToParentTransform());
2013-10-30 09:41:40 +08:00
}
2013-06-07 10:52:32 +08:00
}
2013-10-30 09:41:40 +08:00
DisplayFactory::updateDisplay(this, delta, _boneTransformDirty || _armature->getArmatureTransformDirty());
2013-06-07 10:52:32 +08:00
2021-12-25 10:04:45 +08:00
for (const auto& obj : _children)
{
Bone* childBone = static_cast<Bone*>(obj);
childBone->update(delta);
}
2013-06-07 10:52:32 +08:00
2013-09-16 12:21:18 +08:00
_boneTransformDirty = false;
2013-06-06 12:02:54 +08:00
}
2021-12-25 10:04:45 +08:00
void Bone::applyParentTransform(Bone* parent)
2013-10-30 09:41:40 +08:00
{
2021-12-25 10:04:45 +08:00
float x = _worldInfo->x;
float y = _worldInfo->y;
_worldInfo->x = x * parent->_worldTransform.m[0] + y * parent->_worldTransform.m[4] + parent->_worldInfo->x;
_worldInfo->y = x * parent->_worldTransform.m[1] + y * parent->_worldTransform.m[5] + parent->_worldInfo->y;
2013-10-30 09:41:40 +08:00
_worldInfo->scaleX = _worldInfo->scaleX * parent->_worldInfo->scaleX;
_worldInfo->scaleY = _worldInfo->scaleY * parent->_worldInfo->scaleY;
2021-12-25 10:04:45 +08:00
_worldInfo->skewX = _worldInfo->skewX + parent->_worldInfo->skewX;
_worldInfo->skewY = _worldInfo->skewY + parent->_worldInfo->skewY;
2013-10-30 09:41:40 +08:00
}
2014-04-03 16:19:49 +08:00
void Bone::setBlendFunc(const BlendFunc& blendFunc)
{
2014-04-03 10:34:20 +08:00
if (_blendFunc.src != blendFunc.src || _blendFunc.dst != blendFunc.dst)
{
2021-12-25 10:04:45 +08:00
_blendFunc = blendFunc;
_blendDirty = true;
}
}
2021-12-25 10:04:45 +08:00
void Bone::updateDisplayedColor(const Color3B& parentColor)
2013-06-06 12:02:54 +08:00
{
2022-07-15 19:17:01 +08:00
#ifdef AX_STUDIO_ENABLED_VIEW
_realColor = Color3B(255, 255, 255);
2022-07-15 19:17:01 +08:00
#endif // AX_STUDIO_ENABLED_VIEW
Node::updateDisplayedColor(parentColor);
2013-06-06 12:02:54 +08:00
}
2019-11-25 01:35:26 +08:00
void Bone::updateDisplayedOpacity(uint8_t parentOpacity)
2013-06-06 12:02:54 +08:00
{
2022-07-15 19:17:01 +08:00
#ifdef AX_STUDIO_ENABLED_VIEW
_realOpacity = 255;
2022-07-15 19:17:01 +08:00
#endif // AX_STUDIO_ENABLED_VIEW
Node::updateDisplayedOpacity(parentOpacity);
2013-10-30 09:41:40 +08:00
}
void Bone::updateColor()
2013-06-06 12:02:54 +08:00
{
2021-12-25 10:04:45 +08:00
Node* display = _displayManager->getDisplayRenderNode();
if (display != nullptr)
2013-06-07 10:52:32 +08:00
{
2021-12-25 10:04:45 +08:00
display->setColor(Color3B(_displayedColor.r * _tweenData->r / 255, _displayedColor.g * _tweenData->g / 255,
_displayedColor.b * _tweenData->b / 255));
display->setOpacity(_displayedOpacity * _tweenData->a / 255);
2013-06-07 10:52:32 +08:00
}
2013-06-06 12:02:54 +08:00
}
void Bone::updateZOrder()
2013-09-13 18:07:37 +08:00
{
2013-10-30 09:41:40 +08:00
if (_dataVersion >= VERSION_COMBINED)
2013-09-13 18:07:37 +08:00
{
2013-09-16 12:21:18 +08:00
int zorder = _tweenData->zOrder + _boneData->zOrder;
setLocalZOrder(zorder);
2013-09-13 18:07:37 +08:00
}
else
{
setLocalZOrder(_tweenData->zOrder);
2013-09-13 18:07:37 +08:00
}
}
2013-06-06 12:02:54 +08:00
2021-12-25 10:04:45 +08:00
void Bone::addChildBone(Bone* child)
2013-06-06 12:02:54 +08:00
{
2022-07-16 10:43:05 +08:00
AXASSERT(nullptr != child, "Argument must be non-nil");
AXASSERT(nullptr == child->_parentBone, "child already added. It can't be added again");
2013-06-07 10:52:32 +08:00
2021-12-25 10:04:45 +08:00
if (_children.empty())
2013-06-06 12:02:54 +08:00
{
_children.reserve(4);
2013-06-07 10:52:32 +08:00
}
2022-07-15 19:17:01 +08:00
if (_children.getIndex(child) == AX_INVALID_INDEX)
2013-06-07 10:52:32 +08:00
{
_children.pushBack(child);
2013-06-07 10:52:32 +08:00
child->setParentBone(this);
2013-06-06 12:02:54 +08:00
}
}
2021-12-25 10:04:45 +08:00
void Bone::removeChildBone(Bone* bone, bool recursion)
2013-06-06 12:02:54 +08:00
{
2022-07-15 19:17:01 +08:00
if (!_children.empty() && _children.getIndex(bone) != AX_INVALID_INDEX)
2013-06-07 10:52:32 +08:00
{
2021-12-25 10:04:45 +08:00
if (recursion)
2013-06-07 10:52:32 +08:00
{
auto ccbones = bone->_children;
2021-12-25 10:04:45 +08:00
for (auto&& object : ccbones)
2013-06-07 10:52:32 +08:00
{
2021-12-25 10:04:45 +08:00
Bone* ccBone = static_cast<Bone*>(object);
bone->removeChildBone(ccBone, recursion);
2013-06-07 10:52:32 +08:00
}
}
bone->setParentBone(nullptr);
2013-06-07 10:52:32 +08:00
bone->getDisplayManager()->setCurrentDecorativeDisplay(nullptr);
2013-06-07 10:52:32 +08:00
_children.eraseObject(bone);
2013-06-07 10:52:32 +08:00
}
2013-06-06 12:02:54 +08:00
}
void Bone::removeFromParent(bool recursion)
2013-06-06 12:02:54 +08:00
{
if (nullptr != _parentBone)
2013-06-07 10:52:32 +08:00
{
2013-09-15 20:24:25 +08:00
_parentBone->removeChildBone(this, recursion);
2013-06-07 10:52:32 +08:00
}
2013-06-06 12:02:54 +08:00
}
2021-12-25 10:04:45 +08:00
void Bone::setParentBone(Bone* parent)
2013-06-06 12:02:54 +08:00
{
2013-09-15 20:24:25 +08:00
_parentBone = parent;
2013-06-06 12:02:54 +08:00
}
2021-12-25 10:04:45 +08:00
Bone* Bone::getParentBone()
2013-06-06 12:02:54 +08:00
{
2013-09-15 20:24:25 +08:00
return _parentBone;
2013-06-06 12:02:54 +08:00
}
2021-12-25 10:04:45 +08:00
void Bone::setChildArmature(Armature* armature)
2013-06-06 12:02:54 +08:00
{
2013-09-16 12:21:18 +08:00
if (_childArmature != armature)
2013-09-13 18:07:37 +08:00
{
if (armature == nullptr && _childArmature)
2013-10-30 09:41:40 +08:00
{
_childArmature->setParentBone(nullptr);
2013-10-30 09:41:40 +08:00
}
2022-07-15 19:17:01 +08:00
AX_SAFE_RETAIN(armature);
AX_SAFE_RELEASE(_childArmature);
2013-09-16 12:21:18 +08:00
_childArmature = armature;
2013-09-13 18:07:37 +08:00
}
}
2021-12-25 10:04:45 +08:00
Armature* Bone::getChildArmature() const
2013-09-13 18:07:37 +08:00
{
2013-09-16 12:21:18 +08:00
return _childArmature;
2013-06-06 12:02:54 +08:00
}
2021-12-25 10:04:45 +08:00
Tween* Bone::getTween()
2013-09-13 18:07:37 +08:00
{
2013-09-16 14:56:59 +08:00
return _tween;
2013-09-13 18:07:37 +08:00
}
2013-06-06 12:02:54 +08:00
void Bone::setLocalZOrder(int zOrder)
2013-06-06 12:02:54 +08:00
{
if (getLocalZOrder() != zOrder)
Node::setLocalZOrder(zOrder);
2013-06-06 12:02:54 +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
Mat4 Bone::getNodeToArmatureTransform() const
2013-06-06 12:02:54 +08:00
{
2013-09-16 12:21:18 +08:00
return _worldTransform;
2013-06-06 12:02:54 +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
Mat4 Bone::getNodeToWorldTransform() const
2013-06-06 12:02:54 +08:00
{
2013-12-11 03:07:15 +08:00
return TransformConcat(_worldTransform, _armature->getNodeToWorldTransform());
2013-06-07 10:52:32 +08:00
}
2021-12-25 10:04:45 +08:00
Node* Bone::getDisplayRenderNode()
2013-06-07 10:52:32 +08:00
{
2013-09-16 12:21:18 +08:00
return _displayManager->getDisplayRenderNode();
2013-06-07 10:52:32 +08:00
}
2013-10-30 09:41:40 +08:00
DisplayType Bone::getDisplayRenderNodeType()
{
return _displayManager->getDisplayRenderNodeType();
}
2021-12-25 10:04:45 +08:00
void Bone::addDisplay(DisplayData* displayData, int index)
2013-06-07 10:52:32 +08:00
{
2013-09-16 12:21:18 +08:00
_displayManager->addDisplay(displayData, index);
2013-06-07 10:52:32 +08:00
}
2021-12-25 10:04:45 +08:00
void Bone::addDisplay(Node* display, int index)
2013-06-07 10:52:32 +08:00
{
2013-09-16 12:21:18 +08:00
_displayManager->addDisplay(display, index);
2013-06-06 12:02:54 +08:00
}
2013-10-30 09:41:40 +08:00
void Bone::removeDisplay(int index)
{
_displayManager->removeDisplay(index);
}
void Bone::changeDisplayByIndex(int index, bool force)
2013-06-06 12:02:54 +08:00
{
2014-01-02 11:07:31 +08:00
changeDisplayWithIndex(index, force);
2013-06-06 12:02:54 +08:00
}
2021-12-26 23:26:34 +08:00
void Bone::changeDisplayByName(std::string_view name, bool force)
2014-01-02 11:07:31 +08:00
{
changeDisplayWithName(name, force);
}
void Bone::changeDisplayWithIndex(int index, bool force)
{
_displayManager->changeDisplayWithIndex(index, force);
}
2021-12-26 23:26:34 +08:00
void Bone::changeDisplayWithName(std::string_view name, bool force)
{
2014-01-02 11:07:31 +08:00
_displayManager->changeDisplayWithName(name, force);
}
ColliderDetector* Bone::getColliderDetector() const
2013-06-06 12:02:54 +08:00
{
2021-12-25 10:04:45 +08:00
if (DecorativeDisplay* decoDisplay = _displayManager->getCurrentDecorativeDisplay())
2013-09-13 18:07:37 +08:00
{
2021-12-25 10:04:45 +08:00
if (ColliderDetector* detector = decoDisplay->getColliderDetector())
2013-09-13 18:07:37 +08:00
{
return detector;
2013-09-13 18:07:37 +08:00
}
}
return nullptr;
2013-06-06 12:02:54 +08:00
}
#if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT
2021-12-25 10:04:45 +08:00
void Bone::setColliderFilter(ColliderFilter* filter)
2013-11-01 14:36:44 +08:00
{
2013-12-18 22:36:10 +08:00
auto array = _displayManager->getDecorativeDisplayList();
for (auto&& object : array)
2013-11-01 14:36:44 +08:00
{
2021-12-25 10:04:45 +08:00
DecorativeDisplay* decoDisplay = static_cast<DecorativeDisplay*>(object);
if (ColliderDetector* detector = decoDisplay->getColliderDetector())
2013-11-01 14:36:44 +08:00
{
detector->setColliderFilter(filter);
}
}
}
2021-12-25 10:04:45 +08:00
ColliderFilter* Bone::getColliderFilter()
2013-11-01 14:36:44 +08:00
{
2021-12-25 10:04:45 +08:00
if (DecorativeDisplay* decoDisplay = _displayManager->getCurrentDecorativeDisplay())
2013-11-01 14:36:44 +08:00
{
2021-12-25 10:04:45 +08:00
if (ColliderDetector* detector = decoDisplay->getColliderDetector())
2013-11-01 14:36:44 +08:00
{
return detector->getColliderFilter();
}
}
return nullptr;
2013-11-01 14:36:44 +08:00
}
#endif
2013-11-01 14:36:44 +08:00
2021-12-25 10:04:45 +08:00
} // namespace cocostudio