mirror of https://github.com/axmolengine/axmol.git
[BugFix] EVENT_PROJECTION_CHANGED means trigger an event when projection type is changed instead of when projection matrix is changed. (#19568)
This commit is contained in:
parent
6452d5faec
commit
4f81cd7356
|
@ -42,8 +42,6 @@ THE SOFTWARE.
|
||||||
#include "platform/CCFileUtils.h"
|
#include "platform/CCFileUtils.h"
|
||||||
#include "renderer/ccShaders.h"
|
#include "renderer/ccShaders.h"
|
||||||
#include "renderer/backend/ProgramState.h"
|
#include "renderer/backend/ProgramState.h"
|
||||||
#include "base/CCEventDispatcher.h"
|
|
||||||
#include "base/CCEventListenerCustom.h"
|
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
@ -304,9 +302,6 @@ Sprite::Sprite()
|
||||||
_debugDrawNode = DrawNode::create();
|
_debugDrawNode = DrawNode::create();
|
||||||
addChild(_debugDrawNode);
|
addChild(_debugDrawNode);
|
||||||
#endif //CC_SPRITE_DEBUG_DRAW
|
#endif //CC_SPRITE_DEBUG_DRAW
|
||||||
|
|
||||||
_projectionChangedEvent = Director::getInstance()->getEventDispatcher()->addCustomEventListener(Director::EVENT_PROJECTION_CHANGED, std::bind(&Sprite::onProjectionChanged, this, std::placeholders::_1));
|
|
||||||
_projectionChangedEvent->retain();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite::~Sprite()
|
Sprite::~Sprite()
|
||||||
|
@ -316,9 +311,6 @@ Sprite::~Sprite()
|
||||||
CC_SAFE_RELEASE(_spriteFrame);
|
CC_SAFE_RELEASE(_spriteFrame);
|
||||||
CC_SAFE_RELEASE(_texture);
|
CC_SAFE_RELEASE(_texture);
|
||||||
CC_SAFE_RELEASE(_programState);
|
CC_SAFE_RELEASE(_programState);
|
||||||
|
|
||||||
Director::getInstance()->getEventDispatcher()->removeEventListener(_projectionChangedEvent);
|
|
||||||
CC_SAFE_RELEASE(_projectionChangedEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -401,8 +393,6 @@ void Sprite::setProgramState(backend::ProgramState *programState)
|
||||||
pipelineDescriptor.programState = _programState;
|
pipelineDescriptor.programState = _programState;
|
||||||
|
|
||||||
_mvpMatrixLocation = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix");
|
_mvpMatrixLocation = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix");
|
||||||
setMVPMatrixUniform();
|
|
||||||
|
|
||||||
_textureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture");
|
_textureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture");
|
||||||
_alphaTextureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture1");
|
_alphaTextureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture1");
|
||||||
|
|
||||||
|
@ -1742,9 +1732,4 @@ void Sprite::setMVPMatrixUniform()
|
||||||
programState->setUniform(_mvpMatrixLocation, projectionMat.m, sizeof(projectionMat.m));
|
programState->setUniform(_mvpMatrixLocation, projectionMat.m, sizeof(projectionMat.m));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::onProjectionChanged(EventCustom* /*event*/)
|
|
||||||
{
|
|
||||||
setMVPMatrixUniform();
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -45,7 +45,6 @@ class Rect;
|
||||||
class Size;
|
class Size;
|
||||||
class Texture2D;
|
class Texture2D;
|
||||||
struct transformValues_;
|
struct transformValues_;
|
||||||
class EventListenerCustom;
|
|
||||||
|
|
||||||
#ifdef SPRITE_RENDER_IN_SUBPIXEL
|
#ifdef SPRITE_RENDER_IN_SUBPIXEL
|
||||||
#undef SPRITE_RENDER_IN_SUBPIXEL
|
#undef SPRITE_RENDER_IN_SUBPIXEL
|
||||||
|
@ -642,7 +641,6 @@ protected:
|
||||||
void updateStretchFactor();
|
void updateStretchFactor();
|
||||||
void populateTriangle(int quadIndex, const V3F_C4B_T2F_Quad& quad);
|
void populateTriangle(int quadIndex, const V3F_C4B_T2F_Quad& quad);
|
||||||
void setMVPMatrixUniform();
|
void setMVPMatrixUniform();
|
||||||
void onProjectionChanged(EventCustom* event);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Data used when the sprite is rendered using a SpriteSheet
|
// Data used when the sprite is rendered using a SpriteSheet
|
||||||
|
@ -711,8 +709,6 @@ protected:
|
||||||
|
|
||||||
bool _stretchEnabled = true;
|
bool _stretchEnabled = true;
|
||||||
|
|
||||||
EventListenerCustom* _projectionChangedEvent = nullptr;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CC_DISALLOW_COPY_AND_ASSIGN(Sprite);
|
CC_DISALLOW_COPY_AND_ASSIGN(Sprite);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue