2013-06-06 12:02:54 +08:00
|
|
|
/****************************************************************************
|
2019-11-25 01:35:26 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
|
|
Copyright (c) 2019-2020 simdsoft, @HALX99
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-08-03 17:51:40 +08:00
|
|
|
#include "cocostudio/CCArmature.h"
|
|
|
|
#include "cocostudio/CCArmatureDataManager.h"
|
|
|
|
#include "cocostudio/CCArmatureDefine.h"
|
|
|
|
#include "cocostudio/CCDataReaderHelper.h"
|
|
|
|
#include "cocostudio/CCDatas.h"
|
|
|
|
#include "cocostudio/CCSkin.h"
|
2014-01-17 13:35:58 +08:00
|
|
|
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "renderer/CCRenderer.h"
|
|
|
|
#include "renderer/CCGroupCommand.h"
|
|
|
|
#include "base/CCDirector.h"
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
#if ENABLE_PHYSICS_BOX2D_DETECT
|
|
|
|
#include "Box2D/Box2D.h"
|
|
|
|
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
2016-03-01 05:53:00 +08:00
|
|
|
#include "chipmunk/chipmunk.h"
|
2013-09-13 18:07:37 +08:00
|
|
|
#endif
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
using namespace cocos2d;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
|
|
|
|
namespace cocostudio {
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Armature *Armature::create()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
Armature *armature = new (std::nothrow) Armature();
|
2013-06-06 12:02:54 +08:00
|
|
|
if (armature && armature->init())
|
|
|
|
{
|
|
|
|
armature->autorelease();
|
|
|
|
return armature;
|
|
|
|
}
|
|
|
|
CC_SAFE_DELETE(armature);
|
2013-11-05 15:32:13 +08:00
|
|
|
return nullptr;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-12-23 14:05:46 +08:00
|
|
|
Armature *Armature::create(const std::string& name)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
Armature *armature = new (std::nothrow) Armature();
|
2013-09-13 18:07:37 +08:00
|
|
|
if (armature && armature->init(name))
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
armature->autorelease();
|
|
|
|
return armature;
|
|
|
|
}
|
|
|
|
CC_SAFE_DELETE(armature);
|
2013-11-05 15:32:13 +08:00
|
|
|
return nullptr;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-12-23 14:05:46 +08:00
|
|
|
Armature *Armature::create(const std::string& name, Bone *parentBone)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
Armature *armature = new (std::nothrow) Armature();
|
2013-06-07 10:52:32 +08:00
|
|
|
if (armature && armature->init(name, parentBone))
|
|
|
|
{
|
|
|
|
armature->autorelease();
|
|
|
|
return armature;
|
|
|
|
}
|
|
|
|
CC_SAFE_DELETE(armature);
|
2013-11-05 15:32:13 +08:00
|
|
|
return nullptr;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Armature::Armature()
|
2013-11-05 15:32:13 +08:00
|
|
|
: _armatureData(nullptr)
|
|
|
|
, _batchNode(nullptr)
|
|
|
|
, _parentBone(nullptr)
|
2013-09-15 20:24:25 +08:00
|
|
|
, _armatureTransformDirty(true)
|
2013-11-05 15:32:13 +08:00
|
|
|
, _animation(nullptr)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-25 01:35:26 +08:00
|
|
|
Armature::~Armature()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-12-16 14:34:09 +08:00
|
|
|
_boneDic.clear();
|
|
|
|
_topBoneList.clear();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_DELETE(_animation);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
bool Armature::init()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2014-01-07 20:53:44 +08:00
|
|
|
return init("");
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-23 14:05:46 +08:00
|
|
|
bool Armature::init(const std::string& name)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
bool bRet = false;
|
|
|
|
do
|
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
removeAllChildren();
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_DELETE(_animation);
|
2014-08-28 07:31:57 +08:00
|
|
|
_animation = new (std::nothrow) ArmatureAnimation();
|
2013-06-15 14:03:30 +08:00
|
|
|
_animation->init(this);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-12-16 14:34:09 +08:00
|
|
|
_boneDic.clear();
|
|
|
|
_topBoneList.clear();
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2014-07-23 20:07:33 +08:00
|
|
|
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-12-23 14:05:46 +08:00
|
|
|
_name = name;
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-09-16 15:16:05 +08:00
|
|
|
ArmatureDataManager *armatureDataManager = ArmatureDataManager::getInstance();
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-12-24 11:05:53 +08:00
|
|
|
if(!_name.empty())
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-20 14:15:53 +08:00
|
|
|
AnimationData *animationData = armatureDataManager->getAnimationData(name);
|
2013-09-16 12:02:57 +08:00
|
|
|
CCASSERT(animationData, "AnimationData not exist! ");
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_animation->setAnimationData(animationData);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
ArmatureData *armatureData = armatureDataManager->getArmatureData(name);
|
2015-07-14 15:28:36 +08:00
|
|
|
CCASSERT(armatureData, "armatureData doesn't exists!");
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_armatureData = armatureData;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-12-18 22:07:33 +08:00
|
|
|
for (auto& element : armatureData->boneDataDic)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2016-02-03 23:12:37 +08:00
|
|
|
Bone *bone = createBone(element.first);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
//! init bone's Tween to 1st movement's 1st frame
|
2013-06-07 10:52:32 +08:00
|
|
|
do
|
|
|
|
{
|
2016-02-03 23:12:37 +08:00
|
|
|
MovementData *movData = animationData->getMovement(animationData->movementNames.at(0));
|
2013-06-06 12:02:54 +08:00
|
|
|
CC_BREAK_IF(!movData);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2016-02-03 23:12:37 +08:00
|
|
|
MovementBoneData *movBoneData = movData->getMovementBoneData(bone->getName());
|
2013-12-13 19:40:38 +08:00
|
|
|
CC_BREAK_IF(!movBoneData || movBoneData->frameList.size() <= 0);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
FrameData *frameData = movBoneData->getFrameData(0);
|
2013-06-06 12:02:54 +08:00
|
|
|
CC_BREAK_IF(!frameData);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
bone->getTweenData()->copy(frameData);
|
2014-01-02 11:07:31 +08:00
|
|
|
bone->changeDisplayWithIndex(frameData->displayIndex, false);
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
|
|
|
while (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
update(0);
|
|
|
|
updateOffsetPoint();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_name = "new_armature";
|
2013-06-20 14:15:53 +08:00
|
|
|
_armatureData = ArmatureData::create();
|
2013-06-15 14:03:30 +08:00
|
|
|
_armatureData->name = _name;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
AnimationData *animationData = AnimationData::create();
|
2013-06-15 14:03:30 +08:00
|
|
|
animationData->name = _name;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2016-02-03 23:12:37 +08:00
|
|
|
armatureDataManager->addArmatureData(_name, _armatureData);
|
|
|
|
armatureDataManager->addAnimationData(_name, animationData);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_animation->setAnimationData(animationData);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-07 10:52:32 +08:00
|
|
|
setCascadeOpacityEnabled(true);
|
|
|
|
setCascadeColorEnabled(true);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
bRet = true;
|
|
|
|
}
|
|
|
|
while (0);
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2013-12-23 14:05:46 +08:00
|
|
|
bool Armature::init(const std::string& name, Bone *parentBone)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_parentBone = parentBone;
|
2013-06-07 10:52:32 +08:00
|
|
|
return init(name);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-23 14:05:46 +08:00
|
|
|
Bone *Armature::createBone(const std::string& boneName)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-20 14:15:53 +08:00
|
|
|
Bone *existedBone = getBone(boneName);
|
2013-11-05 15:32:13 +08:00
|
|
|
if(existedBone != nullptr)
|
2013-06-07 10:52:32 +08:00
|
|
|
return existedBone;
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
BoneData *boneData = (BoneData *)_armatureData->getBoneData(boneName);
|
2013-06-07 10:52:32 +08:00
|
|
|
std::string parentName = boneData->parentName;
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-11-05 15:32:13 +08:00
|
|
|
Bone *bone = nullptr;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2015-09-01 11:26:09 +08:00
|
|
|
if( !parentName.empty())
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2016-02-03 23:12:37 +08:00
|
|
|
createBone(parentName);
|
2013-06-20 14:15:53 +08:00
|
|
|
bone = Bone::create(boneName);
|
2016-02-03 23:12:37 +08:00
|
|
|
addBone(bone, parentName);
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-20 14:15:53 +08:00
|
|
|
bone = Bone::create(boneName);
|
2013-06-06 12:02:54 +08:00
|
|
|
addBone(bone, "");
|
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
bone->setBoneData(boneData);
|
2014-01-02 11:07:31 +08:00
|
|
|
bone->getDisplayManager()->changeDisplayWithIndex(-1, false);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
return bone;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-23 14:05:46 +08:00
|
|
|
void Armature::addBone(Bone *bone, const std::string& parentName)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-11-05 15:32:13 +08:00
|
|
|
CCASSERT( bone != nullptr, "Argument must be non-nil");
|
2013-12-16 14:34:09 +08:00
|
|
|
CCASSERT(_boneDic.at(bone->getName()) == nullptr, "bone already added. It can't be added again");
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-12-24 11:05:53 +08:00
|
|
|
if (!parentName.empty())
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-12-16 14:34:09 +08:00
|
|
|
Bone *boneParent = _boneDic.at(parentName);
|
2013-06-06 12:02:54 +08:00
|
|
|
if (boneParent)
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
|
|
|
boneParent->addChildBone(bone);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-16 14:34:09 +08:00
|
|
|
_topBoneList.pushBack(bone);
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
else
|
|
|
|
{
|
2013-12-16 14:34:09 +08:00
|
|
|
_topBoneList.pushBack(bone);
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
bone->setArmature(this);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-12-16 14:34:09 +08:00
|
|
|
_boneDic.insert(bone->getName(), bone);
|
2013-06-06 12:02:54 +08:00
|
|
|
addChild(bone);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
void Armature::removeBone(Bone *bone, bool recursion)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-11-05 15:32:13 +08:00
|
|
|
CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!");
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-11-05 15:32:13 +08:00
|
|
|
bone->setArmature(nullptr);
|
2013-06-06 12:02:54 +08:00
|
|
|
bone->removeFromParent(recursion);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-12-16 14:34:09 +08:00
|
|
|
if (_topBoneList.contains(bone))
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2013-12-17 18:06:11 +08:00
|
|
|
_topBoneList.eraseObject(bone);
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
2013-12-16 14:34:09 +08:00
|
|
|
_boneDic.erase(bone->getName());
|
2013-06-08 22:08:22 +08:00
|
|
|
removeChild(bone, true);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-23 14:05:46 +08:00
|
|
|
Bone *Armature::getBone(const std::string& name) const
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-12-16 14:34:09 +08:00
|
|
|
return _boneDic.at(name);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-23 14:05:46 +08:00
|
|
|
void Armature::changeBoneParent(Bone *bone, const std::string& parentName)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-11-05 15:32:13 +08:00
|
|
|
CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!");
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
if(bone->getParentBone())
|
|
|
|
{
|
2013-12-12 14:45:30 +08:00
|
|
|
bone->getParentBone()->getChildren().eraseObject(bone);
|
2013-11-05 15:32:13 +08:00
|
|
|
bone->setParentBone(nullptr);
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-12-24 11:05:53 +08:00
|
|
|
if (!parentName.empty())
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2013-12-16 14:34:09 +08:00
|
|
|
Bone *boneParent = _boneDic.at(parentName);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-06-07 10:52:32 +08:00
|
|
|
if (boneParent)
|
|
|
|
{
|
|
|
|
boneParent->addChildBone(bone);
|
2013-12-16 14:34:09 +08:00
|
|
|
if (_topBoneList.contains(bone))
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-12-17 18:06:11 +08:00
|
|
|
_topBoneList.eraseObject(bone);
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-16 14:34:09 +08:00
|
|
|
_topBoneList.pushBack(bone);
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
|
|
|
}
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-12-16 14:34:09 +08:00
|
|
|
const cocos2d::Map<std::string, Bone*>& Armature::getBoneDic() const
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _boneDic;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
const Mat4& Armature::getNodeToParentTransform() const
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_transformDirty)
|
2013-09-15 20:24:25 +08:00
|
|
|
_armatureTransformDirty = true;
|
2013-09-13 18:07:37 +08:00
|
|
|
|
2013-12-19 10:00:55 +08:00
|
|
|
return Node::getNodeToParentTransform();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
void Armature::updateOffsetPoint()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
// Set contentsize and Calculate anchor point.
|
2013-07-17 09:16:04 +08:00
|
|
|
Rect rect = getBoundingBox();
|
2013-06-07 10:52:32 +08:00
|
|
|
setContentSize(rect.size);
|
2015-04-20 01:40:52 +08:00
|
|
|
_offsetPoint.set(-rect.origin.x, -rect.origin.y);
|
2013-09-13 18:07:37 +08:00
|
|
|
if (rect.size.width != 0 && rect.size.height != 0)
|
|
|
|
{
|
2014-05-15 01:07:09 +08:00
|
|
|
setAnchorPoint(Vec2(_offsetPoint.x / rect.size.width, _offsetPoint.y / rect.size.height));
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
void Armature::setAnchorPoint(const Vec2& point)
|
2013-12-19 15:43:32 +08:00
|
|
|
{
|
|
|
|
if( ! point.equals(_anchorPoint))
|
|
|
|
{
|
|
|
|
_anchorPoint = point;
|
2015-04-20 01:40:52 +08:00
|
|
|
_anchorPointInPoints.set(_contentSize.width * _anchorPoint.x - _offsetPoint.x, _contentSize.height * _anchorPoint.y - _offsetPoint.y);
|
|
|
|
_realAnchorPointInPoints.set(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y);
|
2013-12-19 15:43:32 +08:00
|
|
|
_transformDirty = _inverseDirty = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
const Vec2& Armature::getAnchorPointInPoints() const
|
2013-12-19 15:43:32 +08:00
|
|
|
{
|
|
|
|
return _realAnchorPointInPoints;
|
|
|
|
}
|
|
|
|
|
2014-09-24 11:20:36 +08:00
|
|
|
const Vec2& Armature::getOffsetPoints() const
|
|
|
|
{
|
2014-09-24 15:14:47 +08:00
|
|
|
return _offsetPoint;
|
2014-09-24 11:20:36 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
void Armature::setAnimation(ArmatureAnimation *animation)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-09-15 20:24:25 +08:00
|
|
|
_animation = animation;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-11-05 19:53:38 +08:00
|
|
|
ArmatureAnimation *Armature::getAnimation() const
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-15 20:24:25 +08:00
|
|
|
return _animation;
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-11-05 19:53:38 +08:00
|
|
|
bool Armature::getArmatureTransformDirty() const
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-15 20:24:25 +08:00
|
|
|
return _armatureTransformDirty;
|
2013-09-14 19:54:49 +08:00
|
|
|
}
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
void Armature::update(float dt)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_animation->update(dt);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-12-20 05:34:41 +08:00
|
|
|
for(const auto &bone : _topBoneList) {
|
2013-12-18 22:07:33 +08:00
|
|
|
bone->update(dt);
|
2013-12-20 05:34:41 +08:00
|
|
|
}
|
2013-09-13 18:07:37 +08:00
|
|
|
|
2013-09-15 20:24:25 +08:00
|
|
|
_armatureTransformDirty = false;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2014-05-31 07:42:05 +08:00
|
|
|
void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-11-05 15:32:13 +08:00
|
|
|
if (_parentBone == nullptr && _batchNode == nullptr)
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2014-03-06 07:49:08 +08:00
|
|
|
// CC_NODE_DRAW_SETUP();
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
|
|
|
|
2013-12-17 17:00:01 +08:00
|
|
|
|
2013-12-18 22:07:33 +08:00
|
|
|
for (auto& object : _children)
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
if (Bone *bone = dynamic_cast<Bone *>(object))
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-10-30 09:41:40 +08:00
|
|
|
Node *node = bone->getDisplayRenderNode();
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-11-05 15:32:13 +08:00
|
|
|
if (nullptr == node)
|
2013-09-13 18:07:37 +08:00
|
|
|
continue;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-10-30 09:41:40 +08:00
|
|
|
switch (bone->getDisplayRenderNodeType())
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
case CS_DISPLAY_SPRITE:
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2013-09-16 12:21:18 +08:00
|
|
|
Skin *skin = static_cast<Skin *>(node);
|
2013-09-13 18:07:37 +08:00
|
|
|
skin->updateTransform();
|
2013-12-17 17:00:01 +08:00
|
|
|
|
2014-07-09 14:25:51 +08:00
|
|
|
BlendFunc func = bone->getBlendFunc();
|
2013-12-17 17:00:01 +08:00
|
|
|
|
2014-07-23 20:07:33 +08:00
|
|
|
if (func.src != BlendFunc::ALPHA_PREMULTIPLIED.src || func.dst != BlendFunc::ALPHA_PREMULTIPLIED.dst)
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2013-12-17 18:06:11 +08:00
|
|
|
skin->setBlendFunc(bone->getBlendFunc());
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
2014-06-30 10:11:43 +08:00
|
|
|
else
|
|
|
|
{
|
2014-07-23 21:35:08 +08:00
|
|
|
if (_blendFunc == BlendFunc::ALPHA_PREMULTIPLIED && !skin->getTexture()->hasPremultipliedAlpha())
|
2014-07-23 20:07:33 +08:00
|
|
|
{
|
2014-07-23 21:35:08 +08:00
|
|
|
skin->setBlendFunc(_blendFunc.ALPHA_NON_PREMULTIPLIED);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
skin->setBlendFunc(_blendFunc);
|
2014-07-23 20:07:33 +08:00
|
|
|
}
|
2014-06-30 10:11:43 +08:00
|
|
|
}
|
2014-05-31 07:42:05 +08:00
|
|
|
skin->draw(renderer, transform, flags);
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
2013-09-13 18:07:37 +08:00
|
|
|
break;
|
|
|
|
case CS_DISPLAY_ARMATURE:
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2014-05-31 07:42:05 +08:00
|
|
|
node->draw(renderer, transform, flags);
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2014-05-31 07:42:05 +08:00
|
|
|
node->visit(renderer, transform, flags);
|
2014-03-06 07:49:08 +08:00
|
|
|
// CC_NODE_DRAW_SETUP();
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
|
|
|
break;
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
|
|
|
}
|
2013-09-13 18:07:37 +08:00
|
|
|
else if(Node *node = dynamic_cast<Node *>(object))
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2014-05-31 07:42:05 +08:00
|
|
|
node->visit(renderer, transform, flags);
|
2014-03-06 07:49:08 +08:00
|
|
|
// CC_NODE_DRAW_SETUP();
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
|
|
|
}
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-12-26 15:49:20 +08:00
|
|
|
void Armature::onEnter()
|
|
|
|
{
|
|
|
|
Node::onEnter();
|
|
|
|
scheduleUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Armature::onExit()
|
|
|
|
{
|
|
|
|
Node::onExit();
|
|
|
|
unscheduleUpdate();
|
|
|
|
}
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
|
2014-05-31 07:42:05 +08:00
|
|
|
void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
// quick return if not visible. children won't be drawn.
|
2015-06-18 10:32:30 +08:00
|
|
|
if (!_visible)
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-31 07:42:05 +08:00
|
|
|
uint32_t flags = processParentFlags(parentTransform, parentFlags);
|
2014-03-01 03:20:53 +08:00
|
|
|
|
2015-06-18 10:32:30 +08:00
|
|
|
if (isVisitableByVisitingCamera())
|
|
|
|
{
|
|
|
|
// IMPORTANT:
|
|
|
|
// 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
|
|
|
|
Director* director = Director::getInstance();
|
2015-09-22 16:08:23 +08:00
|
|
|
CCASSERT(nullptr != director, "Director is null when setting matrix stack");
|
2015-06-18 10:32:30 +08:00
|
|
|
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
|
|
|
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
|
|
|
|
|
|
|
|
|
|
|
sortAllChildren();
|
|
|
|
draw(renderer, _modelViewTransform, flags);
|
|
|
|
|
|
|
|
// FIX ME: Why need to set _orderOfArrival to 0??
|
|
|
|
// Please refer to https://github.com/cocos2d/cocos2d-x/pull/6920
|
|
|
|
// setOrderOfArrival(0);
|
|
|
|
|
|
|
|
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
|
|
|
}
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-07-17 09:16:04 +08:00
|
|
|
Rect Armature::getBoundingBox() const
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
float minx, miny, maxx, maxy = 0;
|
|
|
|
|
|
|
|
bool first = true;
|
|
|
|
|
2013-07-12 14:30:26 +08:00
|
|
|
Rect boundingBox = Rect(0, 0, 0, 0);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-12-20 09:54:50 +08:00
|
|
|
for (const auto& object : _children)
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
if (Bone *bone = dynamic_cast<Bone *>(object))
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
Rect r = bone->getDisplayManager()->getBoundingBox();
|
2014-05-26 16:16:06 +08:00
|
|
|
if (r.equals(Rect::ZERO))
|
|
|
|
continue;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
if(first)
|
|
|
|
{
|
|
|
|
minx = r.getMinX();
|
|
|
|
miny = r.getMinY();
|
|
|
|
maxx = r.getMaxX();
|
|
|
|
maxy = r.getMaxY();
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
first = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
minx = r.getMinX() < boundingBox.getMinX() ? r.getMinX() : boundingBox.getMinX();
|
|
|
|
miny = r.getMinY() < boundingBox.getMinY() ? r.getMinY() : boundingBox.getMinY();
|
|
|
|
maxx = r.getMaxX() > boundingBox.getMaxX() ? r.getMaxX() : boundingBox.getMaxX();
|
|
|
|
maxy = r.getMaxY() > boundingBox.getMaxY() ? r.getMaxY() : boundingBox.getMaxY();
|
|
|
|
}
|
|
|
|
|
|
|
|
boundingBox.setRect(minx, miny, maxx - minx, maxy - miny);
|
|
|
|
}
|
2013-12-18 22:07:33 +08:00
|
|
|
|
2013-12-20 09:54:50 +08:00
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-12-11 03:07:15 +08:00
|
|
|
return RectApplyTransform(boundingBox, getNodeToParentTransform());
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-11-05 19:53:38 +08:00
|
|
|
Bone *Armature::getBoneAtPoint(float x, float y) const
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-12-05 10:35:10 +08:00
|
|
|
long length = _children.size();
|
2013-08-20 08:09:28 +08:00
|
|
|
Bone *bs;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-11-28 16:02:03 +08:00
|
|
|
for(long i = length - 1; i >= 0; i--)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-12-05 10:35:10 +08:00
|
|
|
bs = static_cast<Bone*>( _children.at(i) );
|
2013-08-20 08:09:28 +08:00
|
|
|
if(bs->getDisplayManager()->containPoint(x, y))
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-08-20 08:09:28 +08:00
|
|
|
return bs;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
2013-11-05 15:32:13 +08:00
|
|
|
return nullptr;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-10-30 09:41:40 +08:00
|
|
|
|
|
|
|
void Armature::setParentBone(Bone *parentBone)
|
|
|
|
{
|
|
|
|
_parentBone = parentBone;
|
2013-12-16 14:34:09 +08:00
|
|
|
|
2013-12-18 22:07:33 +08:00
|
|
|
for (auto& element : _boneDic)
|
2013-10-30 09:41:40 +08:00
|
|
|
{
|
2013-12-16 14:34:09 +08:00
|
|
|
element.second->setArmature(this);
|
2013-10-30 09:41:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-05 19:53:38 +08:00
|
|
|
Bone *Armature::getParentBone() const
|
2013-10-30 09:41:40 +08:00
|
|
|
{
|
|
|
|
return _parentBone;
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:40:49 +08:00
|
|
|
#if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT
|
|
|
|
|
2014-10-17 16:28:37 +08:00
|
|
|
void Armature::setColliderFilter(ColliderFilter *filter)
|
2013-11-01 14:36:44 +08:00
|
|
|
{
|
2013-12-18 22:07:33 +08:00
|
|
|
for (auto& element : _boneDic)
|
2013-11-01 14:36:44 +08:00
|
|
|
{
|
2013-12-16 14:34:09 +08:00
|
|
|
element.second->setColliderFilter(filter);
|
2013-11-01 14:36:44 +08:00
|
|
|
}
|
|
|
|
}
|
2013-12-06 13:40:49 +08:00
|
|
|
#elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
|
|
|
|
|
2014-10-17 16:28:37 +08:00
|
|
|
void Armature::drawContour()
|
2013-12-06 13:40:49 +08:00
|
|
|
{
|
2013-12-18 22:07:33 +08:00
|
|
|
for(auto& element : _boneDic)
|
2013-12-06 13:40:49 +08:00
|
|
|
{
|
2013-12-16 14:34:09 +08:00
|
|
|
Bone *bone = element.second;
|
|
|
|
ColliderDetector *detector = bone->getColliderDetector();
|
|
|
|
|
|
|
|
if (!detector)
|
2013-12-06 13:40:49 +08:00
|
|
|
continue;
|
|
|
|
|
2013-12-16 14:34:09 +08:00
|
|
|
const cocos2d::Vector<ColliderBody*>& bodyList = detector->getColliderBodyList();
|
|
|
|
|
2013-12-18 22:07:33 +08:00
|
|
|
for (auto& object : bodyList)
|
2013-12-06 13:40:49 +08:00
|
|
|
{
|
|
|
|
ColliderBody *body = static_cast<ColliderBody*>(object);
|
2014-05-15 01:07:09 +08:00
|
|
|
const std::vector<Vec2> &vertexList = body->getCalculatedVertexList();
|
2013-12-06 13:40:49 +08:00
|
|
|
|
2013-12-17 19:32:16 +08:00
|
|
|
unsigned long length = vertexList.size();
|
2014-08-28 07:31:57 +08:00
|
|
|
Vec2 *points = new (std::nothrow) Vec2[length];
|
2013-12-17 19:32:16 +08:00
|
|
|
for (unsigned long i = 0; i<length; i++)
|
2013-12-06 13:40:49 +08:00
|
|
|
{
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 p = vertexList.at(i);
|
2013-12-13 19:40:38 +08:00
|
|
|
points[i].x = p.x;
|
|
|
|
points[i].y = p.y;
|
2013-12-06 13:40:49 +08:00
|
|
|
}
|
2014-10-17 16:28:37 +08:00
|
|
|
|
|
|
|
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
|
|
|
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
|
|
#elif _MSC_VER >= 1400 //vs 2005 or higher
|
|
|
|
#pragma warning (push)
|
|
|
|
#pragma warning (disable: 4996)
|
|
|
|
#endif
|
2019-11-25 01:35:26 +08:00
|
|
|
cocos2d::log("TODO in %s %s %d", __FILE__, __FUNCTION__, __LINE__);
|
2013-12-06 13:40:49 +08:00
|
|
|
|
2014-10-17 16:28:37 +08:00
|
|
|
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
|
|
|
|
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
|
|
|
|
#elif _MSC_VER >= 1400 //vs 2005 or higher
|
|
|
|
#pragma warning (pop)
|
|
|
|
#endif
|
|
|
|
|
2014-01-17 13:35:58 +08:00
|
|
|
delete []points;
|
2013-12-06 13:40:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2013-11-01 14:36:44 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
#if ENABLE_PHYSICS_BOX2D_DETECT
|
2013-11-05 19:53:38 +08:00
|
|
|
b2Body *Armature::getBody() const
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-09-15 20:24:25 +08:00
|
|
|
return _body;
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
void Armature::setBody(b2Body *body)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-09-15 20:24:25 +08:00
|
|
|
if (_body == body)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-15 20:24:25 +08:00
|
|
|
_body = body;
|
|
|
|
_body->SetUserData(this);
|
2013-09-13 18:07:37 +08:00
|
|
|
|
2013-12-18 22:36:10 +08:00
|
|
|
for(auto& object : _children)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
if (Bone *bone = dynamic_cast<Bone *>(object))
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-12-18 22:36:10 +08:00
|
|
|
auto displayList = bone->getDisplayManager()->getDecorativeDisplayList();
|
2013-09-13 18:07:37 +08:00
|
|
|
|
2013-11-06 15:25:44 +08:00
|
|
|
for(auto displayObject : displayList)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-11-06 15:25:44 +08:00
|
|
|
ColliderDetector *detector = static_cast<DecorativeDisplay *>(displayObject)->getColliderDetector();
|
2013-11-05 15:32:13 +08:00
|
|
|
if (detector != nullptr)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-09-15 20:24:25 +08:00
|
|
|
detector->setBody(_body);
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
b2Fixture *Armature::getShapeList()
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-09-15 20:24:25 +08:00
|
|
|
if (_body)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-09-15 20:24:25 +08:00
|
|
|
return _body->GetFixtureList();
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-05 15:32:13 +08:00
|
|
|
return nullptr;
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
2013-11-05 19:53:38 +08:00
|
|
|
cpBody *Armature::getBody() const
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-09-15 20:24:25 +08:00
|
|
|
return _body;
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
void Armature::setBody(cpBody *body)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-09-15 20:24:25 +08:00
|
|
|
if (_body == body)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-15 20:24:25 +08:00
|
|
|
_body = body;
|
|
|
|
_body->data = this;
|
2013-09-13 18:07:37 +08:00
|
|
|
|
2013-12-20 09:54:50 +08:00
|
|
|
for (const auto& object : _children)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
if (Bone *bone = dynamic_cast<Bone *>(object))
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-12-18 22:36:10 +08:00
|
|
|
auto displayList = bone->getDisplayManager()->getDecorativeDisplayList();
|
2013-09-13 18:07:37 +08:00
|
|
|
|
2013-12-20 09:54:50 +08:00
|
|
|
for (const auto& displayObject : displayList)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-12-20 09:54:50 +08:00
|
|
|
auto detector = displayObject->getColliderDetector();
|
2013-11-05 15:32:13 +08:00
|
|
|
if (detector != nullptr)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-12-18 22:36:10 +08:00
|
|
|
detector->setBody(body);
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
2013-12-18 22:07:33 +08:00
|
|
|
});
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
cpShape *Armature::getShapeList()
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-09-15 20:24:25 +08:00
|
|
|
if (_body)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-09-15 20:24:25 +08:00
|
|
|
return _body->shapeList_private;
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-05 15:32:13 +08:00
|
|
|
return nullptr;
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
}
|