mirror of https://github.com/axmolengine/axmol.git
fix add display
This commit is contained in:
parent
e1acbb6af4
commit
90d7abb3ca
|
@ -261,18 +261,12 @@ void Armature::addBone(Bone *bone, const char *parentName)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (_parentBone)
|
||||
_parentBone->addChildBone(bone);
|
||||
else
|
||||
_topBoneList->addObject(bone);
|
||||
_topBoneList->addObject(bone);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_parentBone)
|
||||
_parentBone->addChildBone(bone);
|
||||
else
|
||||
_topBoneList->addObject(bone);
|
||||
_topBoneList->addObject(bone);
|
||||
}
|
||||
|
||||
bone->setArmature(this);
|
||||
|
@ -338,7 +332,7 @@ Dictionary *Armature::getBoneDic()
|
|||
return _boneDic;
|
||||
}
|
||||
|
||||
const AffineTransform& Armature::getNodeToParentTransform() const
|
||||
const AffineTransform &Armature::getNodeToParentTransform() const
|
||||
{
|
||||
if (_transformDirty)
|
||||
{
|
||||
|
@ -387,16 +381,16 @@ const AffineTransform& Armature::getNodeToParentTransform() const
|
|||
// Build Transform Matrix
|
||||
// Adjusted transform calculation for rotational skew
|
||||
_transform = AffineTransformMake( cy * _scaleX, sy * _scaleX,
|
||||
-sx * _scaleY, cx * _scaleY,
|
||||
x, y );
|
||||
-sx * _scaleY, cx * _scaleY,
|
||||
x, y );
|
||||
|
||||
// XXX: Try to inline skew
|
||||
// If skew is needed, apply skew and then anchor point
|
||||
if (needsSkewMatrix)
|
||||
{
|
||||
AffineTransform skewMatrix = AffineTransformMake(1.0f, tanf(CC_DEGREES_TO_RADIANS(_skewY)),
|
||||
tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1.0f,
|
||||
0.0f, 0.0f );
|
||||
tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1.0f,
|
||||
0.0f, 0.0f );
|
||||
_transform = AffineTransformConcat(skewMatrix, _transform);
|
||||
|
||||
// adjust anchor point
|
||||
|
@ -452,7 +446,7 @@ void Armature::update(float dt)
|
|||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_topBoneList, object)
|
||||
{
|
||||
static_cast<Bone*>(object)->update(dt);
|
||||
static_cast<Bone *>(object)->update(dt);
|
||||
}
|
||||
|
||||
_armatureTransformDirty = false;
|
||||
|
@ -523,6 +517,8 @@ void Armature::draw()
|
|||
}
|
||||
}
|
||||
armature->draw();
|
||||
|
||||
_atlas = armature->getTextureAtlas();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -679,7 +675,7 @@ Bone *Armature::getBoneAtPoint(float x, float y)
|
|||
|
||||
for(int i = length - 1; i >= 0; i--)
|
||||
{
|
||||
bs = static_cast<Bone*>( _children->getObjectAtIndex(i) );
|
||||
bs = static_cast<Bone *>( _children->getObjectAtIndex(i) );
|
||||
if(bs->getDisplayManager()->containPoint(x, y))
|
||||
{
|
||||
return bs;
|
||||
|
|
|
@ -165,6 +165,13 @@ void Bone::update(float delta)
|
|||
if (_parentBone)
|
||||
_boneTransformDirty = _boneTransformDirty || _parentBone->isTransformDirty();
|
||||
|
||||
CCBone *armatureParentBone = _armature->getParentBone();
|
||||
if (armatureParentBone && !_boneTransformDirty)
|
||||
{
|
||||
_boneTransformDirty = armatureParentBone->isTransformDirty();
|
||||
}
|
||||
|
||||
|
||||
if (_boneTransformDirty)
|
||||
{
|
||||
if (_armature->getArmatureData()->dataVersion >= VERSION_COMBINED)
|
||||
|
@ -182,6 +189,13 @@ void Bone::update(float delta)
|
|||
{
|
||||
_worldTransform = AffineTransformConcat(_worldTransform, _parentBone->_worldTransform);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (armatureParentBone)
|
||||
{
|
||||
_worldTransform = CCAffineTransformConcat(_worldTransform, armatureParentBone->getNodeToArmatureTransform());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DisplayFactory::updateDisplay(this, _displayManager->getCurrentDecorativeDisplay(), delta, _boneTransformDirty || _armature->getArmatureTransformDirty());
|
||||
|
@ -211,15 +225,15 @@ void Bone::updateDisplayedOpacity(GLubyte parentOpacity)
|
|||
updateColor();
|
||||
}
|
||||
|
||||
void Bone::setColor(const Color3B& color)
|
||||
void Bone::setColor(const Color3B &color)
|
||||
{
|
||||
CCNodeRGBA::setColor(color);
|
||||
updateColor();
|
||||
updateColor();
|
||||
}
|
||||
void Bone::setOpacity(GLubyte opacity)
|
||||
{
|
||||
CCNodeRGBA::setOpacity(opacity);
|
||||
updateColor();
|
||||
updateColor();
|
||||
}
|
||||
|
||||
void Bone::updateColor()
|
||||
|
|
|
@ -135,6 +135,7 @@ void DisplayManager::addDisplay(Node *display, int index)
|
|||
if (SpriteDisplayData *spriteDisplayData = (SpriteDisplayData *)decoDisplay->getDisplayData())
|
||||
{
|
||||
skin->setSkinData(spriteDisplayData->skinData);
|
||||
((CCSpriteDisplayData *)displayData)->skinData = spriteDisplayData->skinData;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -256,8 +257,8 @@ void DisplayManager::setCurrentDecorativeDisplay(DecorativeDisplay *decoDisplay)
|
|||
|
||||
if (RGBAProtocol *rgbaProtocaol = dynamic_cast<RGBAProtocol *>(_displayRenderNode))
|
||||
{
|
||||
rgbaProtocaol->setColor(_bone->getDisplayedColor());
|
||||
rgbaProtocaol->setOpacity(_bone->getDisplayedOpacity());
|
||||
rgbaProtocaol->setColor(_bone->getDisplayedColor());
|
||||
rgbaProtocaol->setOpacity(_bone->getDisplayedOpacity());
|
||||
}
|
||||
|
||||
_displayRenderNode->retain();
|
||||
|
|
|
@ -84,10 +84,10 @@ bool Skin::initWithSpriteFrameName(const char *pszSpriteFrameName)
|
|||
|
||||
if (ret)
|
||||
{
|
||||
TextureAtlas *atlas = SpriteFrameCacheHelper::getInstance()->getTexureAtlasWithTexture(_texture);
|
||||
setTextureAtlas(atlas);
|
||||
TextureAtlas *atlas = SpriteFrameCacheHelper::getInstance()->getTexureAtlasWithTexture(_texture);
|
||||
setTextureAtlas(atlas);
|
||||
|
||||
_displayName = pszSpriteFrameName;
|
||||
_displayName = pszSpriteFrameName;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -99,10 +99,10 @@ bool Skin::initWithFile(const char *pszFilename)
|
|||
|
||||
if (ret)
|
||||
{
|
||||
TextureAtlas *atlas = SpriteFrameCacheHelper::getInstance()->getTexureAtlasWithTexture(_texture);
|
||||
setTextureAtlas(atlas);
|
||||
TextureAtlas *atlas = SpriteFrameCacheHelper::getInstance()->getTexureAtlasWithTexture(_texture);
|
||||
setTextureAtlas(atlas);
|
||||
|
||||
_displayName = pszFilename;
|
||||
_displayName = pszFilename;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -118,6 +118,7 @@ void Skin::setSkinData(const BaseData &var)
|
|||
setPosition(Point(_skinData.x, _skinData.y));
|
||||
|
||||
_skinTransform = getNodeToParentTransform();
|
||||
updateArmatureTransform();
|
||||
}
|
||||
|
||||
const BaseData &Skin::getSkinData() const
|
||||
|
|
|
@ -136,7 +136,7 @@ static const char *CONFIG_FILE_PATH = "config_file_path";
|
|||
NS_CC_EXT_ARMATURE_BEGIN
|
||||
|
||||
|
||||
std::vector<std::string> s_arrConfigFileList;
|
||||
std::vector<std::string> s_arrConfigFileList;
|
||||
float s_PositionReadScale = 1;
|
||||
static float s_FlashToolVersion = VERSION_2_0;
|
||||
static float s_CocoStudioVersion = VERSION_COMBINED;
|
||||
|
@ -169,8 +169,8 @@ void DataReaderHelper::loadData()
|
|||
}
|
||||
else
|
||||
{
|
||||
std::unique_lock<std::mutex> lk(_sleepMutex);
|
||||
_sleepCondition.wait(lk);
|
||||
std::unique_lock<std::mutex> lk(_sleepMutex);
|
||||
_sleepCondition.wait(lk);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -243,12 +243,12 @@ void DataReaderHelper::clear()
|
|||
}
|
||||
|
||||
DataReaderHelper::DataReaderHelper()
|
||||
: _loadingThread(nullptr)
|
||||
, _asyncStructQueue(nullptr)
|
||||
, _dataQueue(nullptr)
|
||||
, need_quit(false)
|
||||
, _asyncRefCount(0)
|
||||
, _asyncRefTotalCount(0)
|
||||
: _loadingThread(nullptr)
|
||||
, _asyncStructQueue(nullptr)
|
||||
, _dataQueue(nullptr)
|
||||
, need_quit(false)
|
||||
, _asyncRefCount(0)
|
||||
, _asyncRefTotalCount(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -257,11 +257,11 @@ DataReaderHelper::~DataReaderHelper()
|
|||
{
|
||||
need_quit = true;
|
||||
|
||||
_sleepCondition.notify_one();
|
||||
if (_loadingThread) _loadingThread->join();
|
||||
_sleepCondition.notify_one();
|
||||
if (_loadingThread) _loadingThread->join();
|
||||
|
||||
CC_SAFE_DELETE(_loadingThread);
|
||||
_dataReaderHelper = NULL;
|
||||
CC_SAFE_DELETE(_loadingThread);
|
||||
_dataReaderHelper = NULL;
|
||||
}
|
||||
|
||||
void DataReaderHelper::addDataFromFile(const char *filePath)
|
||||
|
@ -354,15 +354,15 @@ void DataReaderHelper::addDataFromFileAsync(const char *filePath, Object *target
|
|||
_asyncStructQueue = new std::queue<AsyncStruct *>();
|
||||
_dataQueue = new std::queue<DataInfo *>();
|
||||
|
||||
// create a new thread to load images
|
||||
_loadingThread = new std::thread(&DataReaderHelper::loadData, this);
|
||||
// create a new thread to load images
|
||||
_loadingThread = new std::thread(&DataReaderHelper::loadData, this);
|
||||
|
||||
need_quit = false;
|
||||
}
|
||||
|
||||
if (0 == _asyncRefCount)
|
||||
{
|
||||
Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(DataReaderHelper::addDataAsyncCallBack), this, 0, false);
|
||||
Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(DataReaderHelper::addDataAsyncCallBack), this, 0, false);
|
||||
}
|
||||
|
||||
++_asyncRefCount;
|
||||
|
@ -854,26 +854,26 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
|
|||
}
|
||||
|
||||
|
||||
//! Change rotation range from (-180 -- 180) to (-infinity -- infinity)
|
||||
CCFrameData **frames = (CCFrameData **)movBoneData->frameList.data->arr;
|
||||
for (int i = movBoneData->frameList.count() - 1; i >= 0; i--)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
float difSkewX = frames[i]->skewX - frames[i - 1]->skewX;
|
||||
float difSkewY = frames[i]->skewY - frames[i - 1]->skewY;
|
||||
//! Change rotation range from (-180 -- 180) to (-infinity -- infinity)
|
||||
CCFrameData **frames = (CCFrameData **)movBoneData->frameList.data->arr;
|
||||
for (int i = movBoneData->frameList.count() - 1; i >= 0; i--)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
float difSkewX = frames[i]->skewX - frames[i - 1]->skewX;
|
||||
float difSkewY = frames[i]->skewY - frames[i - 1]->skewY;
|
||||
|
||||
if (difSkewX < -M_PI || difSkewX > M_PI)
|
||||
{
|
||||
frames[i - 1]->skewX = difSkewX < 0 ? frames[i - 1]->skewX - 2 * M_PI : frames[i - 1]->skewX + 2 * M_PI;
|
||||
}
|
||||
if (difSkewX < -M_PI || difSkewX > M_PI)
|
||||
{
|
||||
frames[i - 1]->skewX = difSkewX < 0 ? frames[i - 1]->skewX - 2 * M_PI : frames[i - 1]->skewX + 2 * M_PI;
|
||||
}
|
||||
|
||||
if (difSkewY < -M_PI || difSkewY > M_PI)
|
||||
{
|
||||
frames[i - 1]->skewY = difSkewY < 0 ? frames[i - 1]->skewY - 2 * M_PI : frames[i - 1]->skewY + 2 * M_PI;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (difSkewY < -M_PI || difSkewY > M_PI)
|
||||
{
|
||||
frames[i - 1]->skewY = difSkewY < 0 ? frames[i - 1]->skewY - 2 * M_PI : frames[i - 1]->skewY + 2 * M_PI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
|
@ -1429,29 +1429,29 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(cs::JsonDictionary &json)
|
|||
}
|
||||
|
||||
|
||||
if (s_CocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE)
|
||||
{
|
||||
//! Change rotation range from (-180 -- 180) to (-infinity -- infinity)
|
||||
CCFrameData **frames = (CCFrameData **)movementBoneData->frameList.data->arr;
|
||||
for (int i = movementBoneData->frameList.count() - 1; i >= 0; i--)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
float difSkewX = frames[i]->skewX - frames[i - 1]->skewX;
|
||||
float difSkewY = frames[i]->skewY - frames[i - 1]->skewY;
|
||||
if (s_CocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE)
|
||||
{
|
||||
//! Change rotation range from (-180 -- 180) to (-infinity -- infinity)
|
||||
CCFrameData **frames = (CCFrameData **)movementBoneData->frameList.data->arr;
|
||||
for (int i = movementBoneData->frameList.count() - 1; i >= 0; i--)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
float difSkewX = frames[i]->skewX - frames[i - 1]->skewX;
|
||||
float difSkewY = frames[i]->skewY - frames[i - 1]->skewY;
|
||||
|
||||
if (difSkewX < -M_PI || difSkewX > M_PI)
|
||||
{
|
||||
frames[i - 1]->skewX = difSkewX < 0 ? frames[i - 1]->skewX - 2 * M_PI : frames[i - 1]->skewX + 2 * M_PI;
|
||||
}
|
||||
if (difSkewX < -M_PI || difSkewX > M_PI)
|
||||
{
|
||||
frames[i - 1]->skewX = difSkewX < 0 ? frames[i - 1]->skewX - 2 * M_PI : frames[i - 1]->skewX + 2 * M_PI;
|
||||
}
|
||||
|
||||
if (difSkewY < -M_PI || difSkewY > M_PI)
|
||||
{
|
||||
frames[i - 1]->skewY = difSkewY < 0 ? frames[i - 1]->skewY - 2 * M_PI : frames[i - 1]->skewY + 2 * M_PI;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (difSkewY < -M_PI || difSkewY > M_PI)
|
||||
{
|
||||
frames[i - 1]->skewY = difSkewY < 0 ? frames[i - 1]->skewY - 2 * M_PI : frames[i - 1]->skewY + 2 * M_PI;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (s_CocoStudioVersion < VERSION_COMBINED)
|
||||
{
|
||||
|
@ -1478,7 +1478,7 @@ FrameData *DataReaderHelper::decodeFrame(cs::JsonDictionary &json)
|
|||
frameData->tweenEasing = (CCTweenType)json.getItemIntValue(A_TWEEN_EASING, Linear);
|
||||
frameData->displayIndex = json.getItemIntValue(A_DISPLAY_INDEX, 0);
|
||||
frameData->blendType = (BlendType)json.getItemIntValue(A_BLEND_TYPE, 0);
|
||||
frameData->isTween = (bool)json.getItemBoolvalue(A_TWEEN_FRAME, true);
|
||||
frameData->isTween = (bool)json.getItemBoolvalue(A_TWEEN_FRAME, true);
|
||||
|
||||
const char *event = json.getItemStringValue(A_EVENT);
|
||||
if (event != NULL)
|
||||
|
@ -1531,7 +1531,7 @@ TextureData *DataReaderHelper::decodeTexture(cs::JsonDictionary &json)
|
|||
ContourData *DataReaderHelper::decodeContour(cs::JsonDictionary &json)
|
||||
{
|
||||
ContourData *contourData = new ContourData();
|
||||
contourData->init();
|
||||
contourData->init();
|
||||
|
||||
int length = json.getArrayItemCount(VERTEX_POINT);
|
||||
for (int i = length - 1; i >= 0; i--)
|
||||
|
|
Loading…
Reference in New Issue