mirror of https://github.com/axmolengine/axmol.git
Merge pull request #5452 from dabingnn/develop_CC_SPRITE_DEBUG_DRAW
closed #3818: fix CC_SPRITE_DEBUG_DRAW feature
This commit is contained in:
commit
dfde6938d2
|
@ -47,7 +47,6 @@ THE SOFTWARE.
|
||||||
#include "CCProfiling.h"
|
#include "CCProfiling.h"
|
||||||
#include "CCDirector.h"
|
#include "CCDirector.h"
|
||||||
#include "renderer/CCRenderer.h"
|
#include "renderer/CCRenderer.h"
|
||||||
#include "renderer/CCQuadCommand.h"
|
|
||||||
#include "renderer/CCFrustum.h"
|
#include "renderer/CCFrustum.h"
|
||||||
|
|
||||||
// external
|
// external
|
||||||
|
@ -590,17 +589,6 @@ void Sprite::updateTransform(void)
|
||||||
arrayMakeObjectsPerformSelector(_children, updateTransform, Sprite*);
|
arrayMakeObjectsPerformSelector(_children, updateTransform, Sprite*);
|
||||||
}*/
|
}*/
|
||||||
Node::updateTransform();
|
Node::updateTransform();
|
||||||
|
|
||||||
#if CC_SPRITE_DEBUG_DRAW
|
|
||||||
// draw bounding box
|
|
||||||
Point vertices[4] = {
|
|
||||||
Point( _quad.bl.vertices.x, _quad.bl.vertices.y ),
|
|
||||||
Point( _quad.br.vertices.x, _quad.br.vertices.y ),
|
|
||||||
Point( _quad.tr.vertices.x, _quad.tr.vertices.y ),
|
|
||||||
Point( _quad.tl.vertices.x, _quad.tl.vertices.y ),
|
|
||||||
};
|
|
||||||
DrawPrimitives::drawPoly(vertices, 4, true);
|
|
||||||
#endif // CC_SPRITE_DEBUG_DRAW
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw
|
// draw
|
||||||
|
@ -611,8 +599,31 @@ void Sprite::draw(void)
|
||||||
{
|
{
|
||||||
_quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform);
|
_quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform);
|
||||||
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
|
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
|
||||||
|
#if CC_SPRITE_DEBUG_DRAW
|
||||||
|
_customDebugDrawCommand.init(_globalZOrder);
|
||||||
|
_customDebugDrawCommand.func = CC_CALLBACK_0(Sprite::drawDebugData, this);
|
||||||
|
Director::getInstance()->getRenderer()->addCommand(&_customDebugDrawCommand);
|
||||||
|
#endif //CC_SPRITE_DEBUG_DRAW
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if CC_SPRITE_DEBUG_DRAW
|
||||||
|
void Sprite::drawDebugData()
|
||||||
|
{
|
||||||
|
kmMat4 oldModelView;
|
||||||
|
kmGLGetMatrix(KM_GL_MODELVIEW, &oldModelView);
|
||||||
|
kmGLLoadMatrix(&_modelViewTransform);
|
||||||
|
// draw bounding box
|
||||||
|
Point vertices[4] = {
|
||||||
|
Point( _quad.bl.vertices.x, _quad.bl.vertices.y ),
|
||||||
|
Point( _quad.br.vertices.x, _quad.br.vertices.y ),
|
||||||
|
Point( _quad.tr.vertices.x, _quad.tr.vertices.y ),
|
||||||
|
Point( _quad.tl.vertices.x, _quad.tl.vertices.y ),
|
||||||
|
};
|
||||||
|
DrawPrimitives::drawPoly(vertices, 4, true);
|
||||||
|
|
||||||
|
kmGLLoadMatrix(&oldModelView);
|
||||||
|
}
|
||||||
|
#endif //CC_SPRITE_DEBUG_DRAW
|
||||||
|
|
||||||
// Culling function from cocos2d-iphone CCSprite.m file
|
// Culling function from cocos2d-iphone CCSprite.m file
|
||||||
bool Sprite::culling() const
|
bool Sprite::culling() const
|
||||||
|
|
|
@ -39,6 +39,7 @@ THE SOFTWARE.
|
||||||
#endif // EMSCRIPTEN
|
#endif // EMSCRIPTEN
|
||||||
#include "CCPhysicsBody.h"
|
#include "CCPhysicsBody.h"
|
||||||
#include "renderer/CCQuadCommand.h"
|
#include "renderer/CCQuadCommand.h"
|
||||||
|
#include "renderer/CCCustomCommand.h"
|
||||||
#include "kazmath/kazmath.h"
|
#include "kazmath/kazmath.h"
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
@ -546,7 +547,10 @@ protected:
|
||||||
BlendFunc _blendFunc; /// It's required for TextureProtocol inheritance
|
BlendFunc _blendFunc; /// It's required for TextureProtocol inheritance
|
||||||
Texture2D* _texture; /// Texture2D object that is used to render the sprite
|
Texture2D* _texture; /// Texture2D object that is used to render the sprite
|
||||||
QuadCommand _quadCommand; /// quad command
|
QuadCommand _quadCommand; /// quad command
|
||||||
|
#if CC_SPRITE_DEBUG_DRAW
|
||||||
|
CustomCommand _customDebugDrawCommand;
|
||||||
|
void drawDebugData();
|
||||||
|
#endif //CC_SPRITE_DEBUG_DRAW
|
||||||
//
|
//
|
||||||
// Shared data
|
// Shared data
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue