mirror of https://github.com/axmolengine/axmol.git
Merge pull request #5123 from ricardoquesada/global_z_order
GlobalZOrder is used for render priority...
This commit is contained in:
commit
d2b3a3e2ca
|
@ -1,10 +1,11 @@
|
|||
cocos2d-x-3.0final ?.? ?
|
||||
cocos2d-x-3.0beta2 ?.? ?
|
||||
[All]
|
||||
[NEW] DrawNode supports to draw triangle, quad bezier, cubic bezier.
|
||||
[NEW] Console: added the 'textures', 'fileutils dump' and 'config' commands
|
||||
[NEW] GLCache: glActiveTexture() is cached with GL::activeTexture(). All code MUST call the cached version in order to work correctly
|
||||
[NEW] Label: Uses a struct of TTF configuration for Label::createWithTTF to reduce parameters and make this interface more easily to use.
|
||||
[NEW] Label: Integrates LabelAtlas into new Label.
|
||||
[NEW] Node: Added `setGlobalZOrder()`. Useful to change the Node's render order. Node::setZOrder() -> Node::setLocalZOrder()
|
||||
[NEW] Renderer: Added BatchCommand. This command is not "batchable" with other commands, but improves performance in about 10%
|
||||
[NEW] LuaBindings: Bindings-generator supports to bind namespace for lua.
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
e1e5a1169e92834330092c45165660c6cbd03609
|
||||
63e6598ea5798bf42bbd22c2295e65f7c739695a
|
|
@ -1 +1 @@
|
|||
1fa58d8cba77ef923c83d2860d5511d28dad6c27
|
||||
447e7ba37294e6da0df2e02f5a62f30fb15e3272
|
|
@ -153,7 +153,7 @@ void AtlasNode::draw(void)
|
|||
auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP);
|
||||
|
||||
_quadCommand.init(
|
||||
_vertexZ,
|
||||
_globalZOrder,
|
||||
_textureAtlas->getTexture()->getName(),
|
||||
shader,
|
||||
_blendFunc,
|
||||
|
|
|
@ -210,12 +210,12 @@ void ClippingNode::visit()
|
|||
|
||||
Renderer* renderer = Director::getInstance()->getRenderer();
|
||||
|
||||
_groupCommand.init(_vertexZ);
|
||||
_groupCommand.init(_globalZOrder);
|
||||
renderer->addCommand(&_groupCommand);
|
||||
|
||||
renderer->pushGroup(_groupCommand.getRenderQueueID());
|
||||
|
||||
_beforeVisitCmd.init(_vertexZ);
|
||||
_beforeVisitCmd.init(_globalZOrder);
|
||||
_beforeVisitCmd.func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this);
|
||||
renderer->addCommand(&_beforeVisitCmd);
|
||||
if (_alphaThreshold < 1)
|
||||
|
@ -238,7 +238,7 @@ void ClippingNode::visit()
|
|||
}
|
||||
_stencil->visit();
|
||||
|
||||
_afterDrawStencilCmd.init(_vertexZ);
|
||||
_afterDrawStencilCmd.init(_globalZOrder);
|
||||
_afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this);
|
||||
renderer->addCommand(&_afterDrawStencilCmd);
|
||||
|
||||
|
@ -268,7 +268,7 @@ void ClippingNode::visit()
|
|||
this->draw();
|
||||
}
|
||||
|
||||
_afterVisitCmd.init(_vertexZ);
|
||||
_afterVisitCmd.init(_globalZOrder);
|
||||
_afterVisitCmd.func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this);
|
||||
renderer->addCommand(&_afterVisitCmd);
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ void DrawNode::render()
|
|||
|
||||
void DrawNode::draw()
|
||||
{
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -666,7 +666,7 @@ void Label::onDraw()
|
|||
|
||||
void Label::draw()
|
||||
{
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -565,7 +565,7 @@ void LayerColor::updateColor()
|
|||
|
||||
void LayerColor::draw()
|
||||
{
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
|
||||
|
|
|
@ -359,7 +359,7 @@ void MotionStreak::draw()
|
|||
if(_nuPoints <= 1)
|
||||
return;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW,&_cachedMV);
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
|
||||
|
|
|
@ -108,7 +108,8 @@ Node::Node(void)
|
|||
, _inverseDirty(true)
|
||||
// children (lazy allocs)
|
||||
// lazy alloc
|
||||
, _ZOrder(0)
|
||||
, _localZOrder(0)
|
||||
, _globalZOrder(0)
|
||||
, _parent(nullptr)
|
||||
// "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true
|
||||
, _tag(Node::INVALID_TAG)
|
||||
|
@ -212,29 +213,22 @@ void Node::setSkewY(float newSkewY)
|
|||
_transformDirty = _inverseDirty = true;
|
||||
}
|
||||
|
||||
/// zOrder getter
|
||||
int Node::getZOrder() const
|
||||
{
|
||||
return _ZOrder;
|
||||
}
|
||||
|
||||
/// zOrder setter : private method
|
||||
/// used internally to alter the zOrder variable. DON'T call this method manually
|
||||
void Node::_setZOrder(int z)
|
||||
void Node::_setLocalZOrder(int z)
|
||||
{
|
||||
_ZOrder = z;
|
||||
_localZOrder = z;
|
||||
}
|
||||
|
||||
void Node::setZOrder(int z)
|
||||
void Node::setLocalZOrder(int z)
|
||||
{
|
||||
_localZOrder = z;
|
||||
if (_parent)
|
||||
{
|
||||
_parent->reorderChild(this, z);
|
||||
}
|
||||
// should set "_ZOrder" after reorderChild, because the implementation of reorderChild subclass of Node, such as Sprite,
|
||||
// will return when _ZOrder value is not changed
|
||||
_setZOrder(z);
|
||||
|
||||
|
||||
_eventDispatcher->setDirtyForNode(this);
|
||||
}
|
||||
|
||||
|
@ -246,9 +240,10 @@ float Node::getVertexZ() const
|
|||
|
||||
|
||||
/// vertexZ setter
|
||||
void Node::setVertexZ(float var)
|
||||
void Node::setVertexZ(float zOrder)
|
||||
{
|
||||
_vertexZ = var;
|
||||
_vertexZ = zOrder;
|
||||
setGlobalZOrder(zOrder);
|
||||
}
|
||||
|
||||
|
||||
|
@ -650,7 +645,7 @@ void Node::addChild(Node *child, int zOrder)
|
|||
void Node::addChild(Node *child)
|
||||
{
|
||||
CCASSERT( child != nullptr, "Argument must be non-nil");
|
||||
this->addChild(child, child->_ZOrder, child->_tag);
|
||||
this->addChild(child, child->_localZOrder, child->_tag);
|
||||
}
|
||||
|
||||
void Node::removeFromParent()
|
||||
|
@ -767,7 +762,7 @@ void Node::insertChild(Node* child, int z)
|
|||
{
|
||||
_reorderChildDirty = true;
|
||||
_children.pushBack(child);
|
||||
child->_setZOrder(z);
|
||||
child->_setLocalZOrder(z);
|
||||
}
|
||||
|
||||
void Node::reorderChild(Node *child, int zOrder)
|
||||
|
@ -775,7 +770,7 @@ void Node::reorderChild(Node *child, int zOrder)
|
|||
CCASSERT( child != nullptr, "Child must be non-nil");
|
||||
_reorderChildDirty = true;
|
||||
child->setOrderOfArrival(s_globalOrderOfArrival++);
|
||||
child->_setZOrder(zOrder);
|
||||
child->_setLocalZOrder(zOrder);
|
||||
}
|
||||
|
||||
void Node::sortAllChildren()
|
||||
|
@ -816,7 +811,7 @@ void Node::visit()
|
|||
{
|
||||
auto node = _children.at(i);
|
||||
|
||||
if ( node && node->_ZOrder < 0 )
|
||||
if ( node && node->_localZOrder < 0 )
|
||||
node->visit();
|
||||
else
|
||||
break;
|
||||
|
|
|
@ -161,43 +161,72 @@ public:
|
|||
/// @name Setters & Getters for Graphic Peroperties
|
||||
|
||||
/**
|
||||
* Sets the Z order which stands for the drawing order, and reorder this node in its parent's children array.
|
||||
*
|
||||
* The Z order of node is relative to its siblings.
|
||||
* It is not related to the OpenGL's z property. This one only affects the draw order of itself and its siblings.
|
||||
* Lower Z order number are drawn before higher numbers.
|
||||
* Please refer to `setVertexZ(float)` for the difference.
|
||||
*
|
||||
* @param zOrder Z order of this node.
|
||||
LocalZOrder is the 'key' used to sort the node relative to its siblings.
|
||||
|
||||
The Node's parent will sort all its children based ont the LocalZOrder value.
|
||||
If two nodes have the same LocalZOrder, then the node that was added first to the children's array will be in front of the other node in the array.
|
||||
|
||||
Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order )
|
||||
And Nodes that have LocalZOder values < 0 are the "left" subtree
|
||||
While Nodes with LocalZOder >=0 are the "right" subtree.
|
||||
|
||||
@see `setGlobalZOrder`
|
||||
@see `setVertexZ`
|
||||
*/
|
||||
virtual void setZOrder(int zOrder);
|
||||
/*
|
||||
* Sets the z order which stands for the drawing order
|
||||
*
|
||||
* This is an internal method. Don't call it outside the framework.
|
||||
* The difference between setZOrder(int) and _setOrder(int) is:
|
||||
* - _setZOrder(int) is a pure setter for _ZOrder memeber variable
|
||||
* - setZOrder(int) firstly changes _ZOrder, then recorder this node in its parent's chilren array.
|
||||
virtual void setLocalZOrder(int zOrder);
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE virtual void setZOrder(int zOrder) { setLocalZOrder(zOrder); }
|
||||
/* Helper function used by `setLocalZOrder`. Don't use it unless you know what you are doing.
|
||||
*/
|
||||
virtual void _setZOrder(int z);
|
||||
virtual void _setLocalZOrder(int z);
|
||||
/**
|
||||
* Gets the Z order of this node.
|
||||
* Gets the local Z order of this node.
|
||||
*
|
||||
* @see `setZOrder(int)`
|
||||
* @see `setLocalZOrder(int)`
|
||||
*
|
||||
* @return The Z order.
|
||||
* @return The local (relative to its siblings) Z order.
|
||||
*/
|
||||
virtual int getZOrder() const;
|
||||
virtual int getLocalZOrder() const { return _localZOrder; }
|
||||
CC_DEPRECATED_ATTRIBUTE virtual int getZOrder() const { return getLocalZOrder(); }
|
||||
|
||||
/**
|
||||
* Sets the real OpenGL Z vertex.
|
||||
Defines the oder in which the nodes are renderer.
|
||||
Nodes that have a Global Z Order lower, are renderer first.
|
||||
|
||||
In case two or more nodes have the same Global Z Order, the oder is not guaranteed.
|
||||
The only exception if the Nodes have a Global Z Order == 0. In that case, the Scene Graph order is used.
|
||||
|
||||
By default, all nodes have a Global Z Order = 0. That means that by default, the Scene Graph order is used to render the nodes.
|
||||
|
||||
Global Z Order is useful when you need to render nodes in an order different than the Scene Graph order.
|
||||
|
||||
Limitations: Global Z Order can't be used used by Nodes that have SpriteBatchNode as one of their acenstors.
|
||||
And if ClippingNode is one of the ancestors, then "global Z order" will be relative to the ClippingNode.
|
||||
|
||||
@see `setLocalZOrder()`
|
||||
@see `setVertexZ()`
|
||||
|
||||
@since v3.0
|
||||
*/
|
||||
virtual void setGlobalZOrder(float zOrder) { _globalZOrder = zOrder; }
|
||||
/**
|
||||
* Returns the Node's Global Z Order.
|
||||
*
|
||||
* Differences between openGL Z vertex and cocos2d Z order:
|
||||
* - OpenGL Z modifies the Z vertex, and not the Z order in the relation between parent-children
|
||||
* - OpenGL Z might require to set 2D projection
|
||||
* - cocos2d Z order works OK if all the nodes uses the same openGL Z vertex. eg: `vertexZ = 0`
|
||||
* @see `setGlobalZOrder(int)`
|
||||
*
|
||||
* @warning Use it at your own risk since it might break the cocos2d parent-children z order
|
||||
* @return The node's global Z order
|
||||
*/
|
||||
virtual float getGlobalZOrder() const { return _globalZOrder; }
|
||||
|
||||
/**
|
||||
* Sets the 'z' value in the OpenGL Depth Buffer.
|
||||
*
|
||||
* The OpenGL depth buffer and depth testing are disabled by default. You need to turn them on
|
||||
* in order to use this property correctly.
|
||||
*
|
||||
* `setVertexZ()` also sets the `setGlobalZValue()` with the vertexZ value.
|
||||
*
|
||||
* @see `setGlobalZValue()`
|
||||
*
|
||||
* @param vertexZ OpenGL Z vertex of this node.
|
||||
*/
|
||||
|
@ -1411,7 +1440,6 @@ protected:
|
|||
float _scaleX; ///< scaling factor on x-axis
|
||||
float _scaleY; ///< scaling factor on y-axis
|
||||
|
||||
float _vertexZ; ///< OpenGL real Z vertex
|
||||
|
||||
Point _position; ///< position of the node
|
||||
|
||||
|
@ -1433,8 +1461,12 @@ protected:
|
|||
mutable bool _transformDirty; ///< transform dirty flag
|
||||
mutable bool _inverseDirty; ///< inverse transform dirty flag
|
||||
|
||||
int _ZOrder; ///< z-order value that affects the draw order
|
||||
|
||||
|
||||
int _localZOrder; ///< Local order (relative to its siblings) used to sort the node
|
||||
float _globalZOrder; ///< Global order used to sort the node
|
||||
float _vertexZ; ///< OpenGL real Z vertex
|
||||
|
||||
|
||||
Vector<Node*> _children; ///< array of children nodes
|
||||
Node *_parent; ///< weak reference to parent node
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ void NodeGrid::visit()
|
|||
|
||||
Renderer* renderer = Director::getInstance()->getRenderer();
|
||||
|
||||
_groupCommand.init(_vertexZ);
|
||||
_groupCommand.init(_globalZOrder);
|
||||
renderer->addCommand(&_groupCommand);
|
||||
renderer->pushGroup(_groupCommand.getRenderQueueID());
|
||||
|
||||
|
@ -104,7 +104,7 @@ void NodeGrid::visit()
|
|||
_nodeGrid->set2DProjection();
|
||||
}
|
||||
|
||||
_gridBeginCommand.init(_vertexZ);
|
||||
_gridBeginCommand.init(_globalZOrder);
|
||||
_gridBeginCommand.func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this);
|
||||
renderer->addCommand(&_gridBeginCommand);
|
||||
|
||||
|
@ -152,7 +152,7 @@ void NodeGrid::visit()
|
|||
director->setProjection(beforeProjectionType);
|
||||
}
|
||||
|
||||
_gridEndCommand.init(_vertexZ);
|
||||
_gridEndCommand.init(_globalZOrder);
|
||||
_gridEndCommand.func = CC_CALLBACK_0(NodeGrid::onGridEndDraw, this);
|
||||
renderer->addCommand(&_gridEndCommand);
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ int ParticleBatchNode::addChildHelper(ParticleSystem* child, int z, int aTag)
|
|||
_children.insert(pos, child);
|
||||
|
||||
child->setTag(aTag);
|
||||
child->_setZOrder(z);
|
||||
child->_setLocalZOrder(z);
|
||||
|
||||
child->setParent(this);
|
||||
|
||||
|
@ -264,7 +264,7 @@ void ParticleBatchNode::reorderChild(Node * aChild, int zOrder)
|
|||
}
|
||||
}
|
||||
|
||||
child->_setZOrder(zOrder);
|
||||
child->_setLocalZOrder(zOrder);
|
||||
}
|
||||
|
||||
void ParticleBatchNode::getCurrentIndex(int* oldIndex, int* newIndex, Node* child, int z)
|
||||
|
@ -383,7 +383,7 @@ void ParticleBatchNode::draw(void)
|
|||
}
|
||||
|
||||
_batchCommand.init(
|
||||
_vertexZ,
|
||||
_globalZOrder,
|
||||
_textureAtlas->getTexture()->getName(),
|
||||
_shaderProgram,
|
||||
_blendFunc,
|
||||
|
|
|
@ -439,7 +439,7 @@ void ParticleSystemQuad::draw()
|
|||
|
||||
auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP);
|
||||
|
||||
_quadCommand.init(_vertexZ, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform);
|
||||
_quadCommand.init(_globalZOrder, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
|
||||
}
|
||||
|
||||
|
|
|
@ -555,7 +555,7 @@ void ProgressTimer::draw()
|
|||
if( ! _vertexData || ! _sprite)
|
||||
return;
|
||||
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -322,7 +322,7 @@ void RenderTexture::beginWithClear(float r, float g, float b, float a, float dep
|
|||
this->begin();
|
||||
|
||||
//clear screen
|
||||
_beginWithClearCommand.init(_vertexZ);
|
||||
_beginWithClearCommand.init(_globalZOrder);
|
||||
_beginWithClearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_beginWithClearCommand);
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ void RenderTexture::clearDepth(float depthValue)
|
|||
|
||||
this->begin();
|
||||
|
||||
_clearDepthCommand.init(_vertexZ);
|
||||
_clearDepthCommand.init(_globalZOrder);
|
||||
_clearDepthCommand.func = CC_CALLBACK_0(RenderTexture::onClearDepth, this);
|
||||
|
||||
Director::getInstance()->getRenderer()->addCommand(&_clearDepthCommand);
|
||||
|
@ -605,7 +605,7 @@ void RenderTexture::draw()
|
|||
begin();
|
||||
|
||||
//clear screen
|
||||
_clearCommand.init(_vertexZ);
|
||||
_clearCommand.init(_globalZOrder);
|
||||
_clearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_clearCommand);
|
||||
|
||||
|
@ -648,13 +648,13 @@ void RenderTexture::begin()
|
|||
(float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 );
|
||||
kmGLMultMatrix(&orthoMatrix);
|
||||
|
||||
_groupCommand.init(_vertexZ);
|
||||
_groupCommand.init(_globalZOrder);
|
||||
|
||||
Renderer *renderer = Director::getInstance()->getRenderer();
|
||||
renderer->addCommand(&_groupCommand);
|
||||
renderer->pushGroup(_groupCommand.getRenderQueueID());
|
||||
|
||||
_beginCommand.init(_vertexZ);
|
||||
_beginCommand.init(_globalZOrder);
|
||||
_beginCommand.func = CC_CALLBACK_0(RenderTexture::onBegin, this);
|
||||
|
||||
Director::getInstance()->getRenderer()->addCommand(&_beginCommand);
|
||||
|
@ -662,7 +662,7 @@ void RenderTexture::begin()
|
|||
|
||||
void RenderTexture::end()
|
||||
{
|
||||
_endCommand.init(_vertexZ);
|
||||
_endCommand.init(_globalZOrder);
|
||||
_endCommand.func = CC_CALLBACK_0(RenderTexture::onEnd, this);
|
||||
|
||||
Renderer *renderer = Director::getInstance()->getRenderer();
|
||||
|
|
|
@ -670,7 +670,7 @@ void Sprite::updateTransform(void)
|
|||
void Sprite::draw(void)
|
||||
{
|
||||
//TODO implement z order
|
||||
_quadCommand.init(_vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform);
|
||||
_quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform);
|
||||
|
||||
// if(culling())
|
||||
{
|
||||
|
@ -769,13 +769,8 @@ void Sprite::addChild(Node *child, int zOrder, int tag)
|
|||
|
||||
void Sprite::reorderChild(Node *child, int zOrder)
|
||||
{
|
||||
CCASSERT(child != nullptr, "");
|
||||
CCASSERT(_children.contains(child), "");
|
||||
|
||||
if (zOrder == child->getZOrder())
|
||||
{
|
||||
return;
|
||||
}
|
||||
CCASSERT(child != nullptr, "child must be non null");
|
||||
CCASSERT(_children.contains(child), "child does not belong to this");
|
||||
|
||||
if( _batchNode && ! _reorderChildDirty)
|
||||
{
|
||||
|
|
|
@ -357,7 +357,7 @@ void SpriteBatchNode::draw()
|
|||
child->updateTransform();
|
||||
|
||||
_batchCommand.init(
|
||||
_vertexZ,
|
||||
_globalZOrder,
|
||||
_textureAtlas->getTexture()->getName(),
|
||||
_shaderProgram,
|
||||
_blendFunc,
|
||||
|
|
|
@ -98,23 +98,23 @@ void TransitionPageTurn::draw()
|
|||
|
||||
if( _isInSceneOnTop ) {
|
||||
_outSceneProxy->visit();
|
||||
_enableOffsetCmd.init(_vertexZ);
|
||||
_enableOffsetCmd.init(_globalZOrder);
|
||||
_enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd);
|
||||
_inSceneProxy->visit();
|
||||
_disableOffsetCmd.init(_vertexZ);
|
||||
_disableOffsetCmd.init(_globalZOrder);
|
||||
_disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd);
|
||||
} else {
|
||||
_inSceneProxy->visit();
|
||||
|
||||
_enableOffsetCmd.init(_vertexZ);
|
||||
_enableOffsetCmd.init(_globalZOrder);
|
||||
_enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd);
|
||||
|
||||
_outSceneProxy->visit();
|
||||
|
||||
_disableOffsetCmd.init(_vertexZ);
|
||||
_disableOffsetCmd.init(_globalZOrder);
|
||||
_disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd);
|
||||
}
|
||||
|
|
|
@ -38,9 +38,9 @@ BatchCommand::BatchCommand()
|
|||
_shader = nullptr;
|
||||
}
|
||||
|
||||
void BatchCommand::init(float depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform)
|
||||
void BatchCommand::init(float globalOrder, GLuint textureID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform)
|
||||
{
|
||||
_depth = depth;
|
||||
_globalOrder = globalOrder;
|
||||
_textureID = textureID;
|
||||
_blendType = blendType;
|
||||
_shader = shader;
|
||||
|
@ -54,7 +54,7 @@ BatchCommand::~BatchCommand()
|
|||
{
|
||||
}
|
||||
|
||||
void BatchCommand::execute() const
|
||||
void BatchCommand::execute()
|
||||
{
|
||||
// Set material
|
||||
_shader->use();
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
void init(float depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform);
|
||||
|
||||
void execute() const;
|
||||
void execute();
|
||||
|
||||
protected:
|
||||
int32_t _materialID;
|
||||
|
|
|
@ -32,9 +32,9 @@ CustomCommand::CustomCommand()
|
|||
_type = RenderCommand::Type::CUSTOM_COMMAND;
|
||||
}
|
||||
|
||||
void CustomCommand::init(float depth)
|
||||
void CustomCommand::init(float globalOrder)
|
||||
{
|
||||
_depth = depth;
|
||||
_globalOrder = globalOrder;
|
||||
}
|
||||
|
||||
CustomCommand::~CustomCommand()
|
||||
|
@ -42,7 +42,7 @@ CustomCommand::~CustomCommand()
|
|||
|
||||
}
|
||||
|
||||
void CustomCommand::execute() const
|
||||
void CustomCommand::execute()
|
||||
{
|
||||
if(func)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
void init(float depth);
|
||||
|
||||
void execute() const;
|
||||
void execute();
|
||||
|
||||
inline bool isTranslucent() { return true; }
|
||||
std::function<void()> func;
|
||||
|
|
|
@ -91,9 +91,9 @@ GroupCommand::GroupCommand()
|
|||
_renderQueueID = GroupCommandManager::getInstance()->getGroupID();
|
||||
}
|
||||
|
||||
void GroupCommand::init(float depth)
|
||||
void GroupCommand::init(float globalOrder)
|
||||
{
|
||||
_depth = depth;
|
||||
_globalOrder = globalOrder;
|
||||
GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID);
|
||||
_renderQueueID = GroupCommandManager::getInstance()->getGroupID();
|
||||
}
|
||||
|
|
|
@ -38,9 +38,9 @@ QuadCommand::QuadCommand()
|
|||
_quads = nullptr;
|
||||
}
|
||||
|
||||
void QuadCommand::init(float depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, ssize_t quadCount, const kmMat4 &mv)
|
||||
void QuadCommand::init(float globalOrder, GLuint textureID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, ssize_t quadCount, const kmMat4 &mv)
|
||||
{
|
||||
_depth = depth;
|
||||
_globalOrder = globalOrder;
|
||||
_textureID = textureID;
|
||||
_blendType = blendType;
|
||||
_shader = shader;
|
||||
|
|
|
@ -29,7 +29,7 @@ NS_CC_BEGIN
|
|||
|
||||
RenderCommand::RenderCommand()
|
||||
: _type(RenderCommand::Type::UNKNOWN_COMMAND)
|
||||
, _depth(0)
|
||||
, _globalOrder(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ void printBits(ssize_t const size, void const * const ptr)
|
|||
|
||||
void RenderCommand::printID()
|
||||
{
|
||||
printf("Command Depth: %f\n", _depth);
|
||||
printf("Command Depth: %f\n", _globalOrder);
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -50,7 +50,7 @@ public:
|
|||
};
|
||||
|
||||
/** Get Render Command Id */
|
||||
inline float getDepth() const { return _depth; }
|
||||
inline float getGlobalOrder() const { return _globalOrder; }
|
||||
|
||||
/** Returns the Command type */
|
||||
inline Type getType() const { return _type; }
|
||||
|
@ -65,7 +65,7 @@ protected:
|
|||
Type _type;
|
||||
|
||||
// commands are sort by depth
|
||||
float _depth;
|
||||
float _globalOrder;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -34,21 +34,21 @@
|
|||
#include "CCEventDispatcher.h"
|
||||
#include "CCEventListenerCustom.h"
|
||||
#include "CCEventType.h"
|
||||
#include <algorithm> // for std::stable_sort
|
||||
#include <algorithm>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
bool compareRenderCommand(RenderCommand* a, RenderCommand* b)
|
||||
{
|
||||
return a->getDepth() < b->getDepth();
|
||||
return a->getGlobalOrder() < b->getGlobalOrder();
|
||||
}
|
||||
|
||||
void RenderQueue::push_back(RenderCommand* command)
|
||||
{
|
||||
float z = command->getDepth();
|
||||
float z = command->getGlobalOrder();
|
||||
if(z < 0)
|
||||
_queueNegZ.push_back(command);
|
||||
if(z > 0)
|
||||
else if(z > 0)
|
||||
_queuePosZ.push_back(command);
|
||||
else
|
||||
_queue0.push_back(command);
|
||||
|
@ -66,7 +66,7 @@ void RenderQueue::sort()
|
|||
std::sort(std::begin(_queuePosZ), std::end(_queuePosZ), compareRenderCommand);
|
||||
}
|
||||
|
||||
const RenderCommand* RenderQueue::operator[](ssize_t index) const
|
||||
RenderCommand* RenderQueue::operator[](ssize_t index) const
|
||||
{
|
||||
if(index < _queueNegZ.size())
|
||||
return _queueNegZ[index];
|
||||
|
@ -295,7 +295,7 @@ void Renderer::render()
|
|||
|
||||
if(commandType == RenderCommand::Type::QUAD_COMMAND)
|
||||
{
|
||||
auto cmd = static_cast<const QuadCommand*>(command);
|
||||
auto cmd = static_cast<QuadCommand*>(command);
|
||||
ssize_t cmdQuadCount = cmd->getQuadCount();
|
||||
|
||||
//Batch quads
|
||||
|
@ -317,19 +317,19 @@ void Renderer::render()
|
|||
else if(commandType == RenderCommand::Type::CUSTOM_COMMAND)
|
||||
{
|
||||
flush();
|
||||
auto cmd = static_cast<const CustomCommand*>(command);
|
||||
auto cmd = static_cast<CustomCommand*>(command);
|
||||
cmd->execute();
|
||||
}
|
||||
else if(commandType == RenderCommand::Type::BATCH_COMMAND)
|
||||
{
|
||||
flush();
|
||||
auto cmd = static_cast<const BatchCommand*>(command);
|
||||
auto cmd = static_cast<BatchCommand*>(command);
|
||||
cmd->execute();
|
||||
}
|
||||
else if(commandType == RenderCommand::Type::GROUP_COMMAND)
|
||||
{
|
||||
flush();
|
||||
auto cmd = static_cast<const GroupCommand*>(command);
|
||||
auto cmd = static_cast<GroupCommand*>(command);
|
||||
|
||||
_renderStack.top().currentIndex = i + 1;
|
||||
|
||||
|
@ -467,7 +467,7 @@ void Renderer::drawBatchedQuads()
|
|||
auto command = _renderGroups[_renderStack.top().renderQueueID][i];
|
||||
if (command->getType() == RenderCommand::Type::QUAD_COMMAND)
|
||||
{
|
||||
auto cmd = static_cast<const QuadCommand*>(command);
|
||||
auto cmd = static_cast<QuadCommand*>(command);
|
||||
if(_lastMaterialID != cmd->getMaterialID())
|
||||
{
|
||||
//Draw quads
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
void push_back(RenderCommand* command);
|
||||
ssize_t size() const;
|
||||
void sort();
|
||||
const RenderCommand* operator[](ssize_t index) const;
|
||||
RenderCommand* operator[](ssize_t index) const;
|
||||
void clear();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -156,7 +156,7 @@ void BatchNode::draw()
|
|||
void BatchNode::generateGroupCommand()
|
||||
{
|
||||
Renderer* renderer = Director::getInstance()->getRenderer();
|
||||
_groupCommand->init(_vertexZ);
|
||||
_groupCommand->init(_globalZOrder);
|
||||
renderer->addCommand(_groupCommand);
|
||||
|
||||
renderer->pushGroup(_groupCommand->getRenderQueueID());
|
||||
|
|
|
@ -145,7 +145,7 @@ void Bone::setBoneData(BoneData *boneData)
|
|||
}
|
||||
|
||||
_name = _boneData->name;
|
||||
_ZOrder = _boneData->zOrder;
|
||||
_localZOrder = _boneData->zOrder;
|
||||
|
||||
_displayManager->initDisplayList(boneData);
|
||||
}
|
||||
|
@ -283,11 +283,11 @@ void Bone::updateZOrder()
|
|||
if (_dataVersion >= VERSION_COMBINED)
|
||||
{
|
||||
int zorder = _tweenData->zOrder + _boneData->zOrder;
|
||||
setZOrder(zorder);
|
||||
setLocalZOrder(zorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
setZOrder(_tweenData->zOrder);
|
||||
setLocalZOrder(_tweenData->zOrder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,10 +374,10 @@ Tween *Bone::getTween()
|
|||
return _tween;
|
||||
}
|
||||
|
||||
void Bone::setZOrder(int zOrder)
|
||||
void Bone::setLocalZOrder(int zOrder)
|
||||
{
|
||||
if (_ZOrder != zOrder)
|
||||
Node::setZOrder(zOrder);
|
||||
if (_localZOrder != zOrder)
|
||||
Node::setLocalZOrder(zOrder);
|
||||
}
|
||||
|
||||
kmMat4 Bone::getNodeToArmatureTransform() const
|
||||
|
|
|
@ -143,7 +143,7 @@ public:
|
|||
//! Update zorder
|
||||
void updateZOrder();
|
||||
|
||||
virtual void setZOrder(int zOrder) override;
|
||||
virtual void setLocalZOrder(int zOrder) override;
|
||||
|
||||
Tween *getTween();
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ void WidgetPropertiesReader0250::setPropsForWidgetFromJsonDictionary(Widget*widg
|
|||
widget->setVisible(DICTOOL->getBooleanValue_json(options, "visible"));
|
||||
}
|
||||
int z = DICTOOL->getIntValue_json(options, "ZOrder");
|
||||
widget->setZOrder(z);
|
||||
widget->setLocalZOrder(z);
|
||||
}
|
||||
|
||||
void WidgetPropertiesReader0250::setColorPropsForWidgetFromJsonDictionary(Widget *widget, const rapidjson::Value&options)
|
||||
|
@ -1062,7 +1062,7 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(Widget*widg
|
|||
widget->setVisible(DICTOOL->getBooleanValue_json(options, "visible"));
|
||||
}
|
||||
int z = DICTOOL->getIntValue_json(options, "ZOrder");
|
||||
widget->setZOrder(z);
|
||||
widget->setLocalZOrder(z);
|
||||
|
||||
bool layout = DICTOOL->checkObjectExist_json(options, "layoutParameter");
|
||||
if (layout)
|
||||
|
|
|
@ -203,7 +203,7 @@ void SceneReader::setPropertyFromJsonDict(const rapidjson::Value &root, cocos2d:
|
|||
node->setTag(nTag);
|
||||
|
||||
int nZorder = DICTOOL->getIntValue_json(root, "zorder");
|
||||
node->setZOrder(nZorder);
|
||||
node->setLocalZOrder(nZorder);
|
||||
|
||||
float fScaleX = DICTOOL->getFloatValue_json(root, "scalex", 1.0);
|
||||
float fScaleY = DICTOOL->getFloatValue_json(root, "scaley", 1.0);
|
||||
|
|
|
@ -225,7 +225,7 @@ void Skin::draw()
|
|||
kmGLGetMatrix(KM_GL_MODELVIEW, &mv);
|
||||
|
||||
//TODO implement z order
|
||||
_quadCommand.init(_vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv);
|
||||
_quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ void Skeleton::draw()
|
|||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_oldTransMatrix);
|
||||
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -210,18 +210,18 @@ void Layout::stencilClippingVisit()
|
|||
|
||||
Renderer* renderer = Director::getInstance()->getRenderer();
|
||||
|
||||
_groupCommand.init(_vertexZ);
|
||||
_groupCommand.init(_globalZOrder);
|
||||
renderer->addCommand(&_groupCommand);
|
||||
|
||||
renderer->pushGroup(_groupCommand.getRenderQueueID());
|
||||
|
||||
_beforeVisitCmdStencil.init(_vertexZ);
|
||||
_beforeVisitCmdStencil.init(_globalZOrder);
|
||||
_beforeVisitCmdStencil.func = CC_CALLBACK_0(Layout::onBeforeVisitStencil, this);
|
||||
renderer->addCommand(&_beforeVisitCmdStencil);
|
||||
|
||||
_clippingStencil->visit();
|
||||
|
||||
_afterDrawStencilCmd.init(_vertexZ);
|
||||
_afterDrawStencilCmd.init(_globalZOrder);
|
||||
_afterDrawStencilCmd.func = CC_CALLBACK_0(Layout::onAfterDrawStencil, this);
|
||||
renderer->addCommand(&_afterDrawStencilCmd);
|
||||
|
||||
|
@ -251,7 +251,7 @@ void Layout::stencilClippingVisit()
|
|||
this->draw();
|
||||
}
|
||||
|
||||
_afterVisitCmdStencil.init(_vertexZ);
|
||||
_afterVisitCmdStencil.init(_globalZOrder);
|
||||
_afterVisitCmdStencil.func = CC_CALLBACK_0(Layout::onAfterVisitStencil, this);
|
||||
renderer->addCommand(&_afterVisitCmdStencil);
|
||||
|
||||
|
@ -336,13 +336,13 @@ void Layout::scissorClippingVisit()
|
|||
{
|
||||
Renderer* renderer = Director::getInstance()->getRenderer();
|
||||
|
||||
_beforeVisitCmdScissor.init(_vertexZ);
|
||||
_beforeVisitCmdScissor.init(_globalZOrder);
|
||||
_beforeVisitCmdScissor.func = CC_CALLBACK_0(Layout::onBeforeVisitScissor, this);
|
||||
renderer->addCommand(&_beforeVisitCmdScissor);
|
||||
|
||||
Node::visit();
|
||||
|
||||
_afterVisitCmdScissor.init(_vertexZ);
|
||||
_afterVisitCmdScissor.init(_globalZOrder);
|
||||
_afterVisitCmdScissor.func = CC_CALLBACK_0(Layout::onAfterVisitScissor, this);
|
||||
renderer->addCommand(&_afterVisitCmdScissor);
|
||||
}
|
||||
|
@ -651,14 +651,14 @@ void Layout::addBackGroundImage()
|
|||
if (_backGroundScale9Enabled)
|
||||
{
|
||||
_backGroundImage = extension::Scale9Sprite::create();
|
||||
_backGroundImage->setZOrder(-1);
|
||||
_backGroundImage->setLocalZOrder(-1);
|
||||
Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1);
|
||||
static_cast<extension::Scale9Sprite*>(_backGroundImage)->setPreferredSize(_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
_backGroundImage = Sprite::create();
|
||||
_backGroundImage->setZOrder(-1);
|
||||
_backGroundImage->setLocalZOrder(-1);
|
||||
Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1);
|
||||
}
|
||||
_backGroundImage->setPosition(Point(_size.width/2.0f, _size.height/2.0f));
|
||||
|
|
|
@ -195,7 +195,7 @@ public:
|
|||
* If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
|
||||
*
|
||||
* @param child A child node
|
||||
* @param zOrder Z order for drawing priority. Please refer to setZOrder(int)
|
||||
* @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int)
|
||||
*/
|
||||
virtual void addChild(Node * child, int zOrder) override;
|
||||
/**
|
||||
|
@ -204,7 +204,7 @@ public:
|
|||
* If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
|
||||
*
|
||||
* @param child A child node
|
||||
* @param zOrder Z order for drawing priority. Please refer to setZOrder(int)
|
||||
* @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int)
|
||||
* @param tag A interger to identify the node easily. Please refer to setTag(int)
|
||||
*/
|
||||
virtual void addChild(Node* child, int zOrder, int tag) override;
|
||||
|
|
|
@ -378,7 +378,7 @@ void ListView::refreshView()
|
|||
for (int i=0; i<length; i++)
|
||||
{
|
||||
Widget* item = _items.at(i);
|
||||
item->setZOrder(i);
|
||||
item->setLocalZOrder(i);
|
||||
remedyLayoutParameter(item);
|
||||
}
|
||||
updateInnerContainerSize();
|
||||
|
|
|
@ -242,7 +242,7 @@ public:
|
|||
* If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
|
||||
*
|
||||
* @param child A child node
|
||||
* @param zOrder Z order for drawing priority. Please refer to setZOrder(int)
|
||||
* @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int)
|
||||
*/
|
||||
virtual void addChild(Node * child, int zOrder) override;
|
||||
/**
|
||||
|
@ -251,7 +251,7 @@ public:
|
|||
* If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
|
||||
*
|
||||
* @param child A child node
|
||||
* @param zOrder Z order for drawing priority. Please refer to setZOrder(int)
|
||||
* @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int)
|
||||
* @param tag A interger to identify the node easily. Please refer to setTag(int)
|
||||
*/
|
||||
virtual void addChild(Node* child, int zOrder, int tag) override;
|
||||
|
|
|
@ -1040,7 +1040,7 @@ void Widget::copyProperties(Widget *widget)
|
|||
setBright(widget->isBright());
|
||||
setTouchEnabled(widget->isTouchEnabled());
|
||||
_touchPassedEnabled = false;
|
||||
setZOrder(widget->getZOrder());
|
||||
setLocalZOrder(widget->getLocalZOrder());
|
||||
setTag(widget->getTag());
|
||||
setName(widget->getName());
|
||||
setActionTag(widget->getActionTag());
|
||||
|
|
|
@ -212,7 +212,7 @@ public:
|
|||
* If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
|
||||
*
|
||||
* @param child A child node
|
||||
* @param zOrder Z order for drawing priority. Please refer to setZOrder(int)
|
||||
* @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int)
|
||||
*/
|
||||
virtual void addChild(Node * child, int zOrder) override;
|
||||
/**
|
||||
|
@ -221,7 +221,7 @@ public:
|
|||
* If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
|
||||
*
|
||||
* @param child A child node
|
||||
* @param zOrder Z order for drawing priority. Please refer to setZOrder(int)
|
||||
* @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int)
|
||||
* @param tag A interger to identify the node easily. Please refer to setTag(int)
|
||||
*/
|
||||
virtual void addChild(Node* child, int zOrder, int tag) override;
|
||||
|
|
|
@ -494,7 +494,7 @@ void ScrollView::addChild(Node * child, int zOrder, int tag)
|
|||
|
||||
void ScrollView::beforeDraw()
|
||||
{
|
||||
_beforeDrawCommand.init(_vertexZ);
|
||||
_beforeDrawCommand.init(_globalZOrder);
|
||||
_beforeDrawCommand.func = CC_CALLBACK_0(ScrollView::onBeforeDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_beforeDrawCommand);
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ void ScrollView::onBeforeDraw()
|
|||
|
||||
void ScrollView::afterDraw()
|
||||
{
|
||||
_afterDrawCommand.init(_vertexZ);
|
||||
_afterDrawCommand.init(_globalZOrder);
|
||||
_afterDrawCommand.func = CC_CALLBACK_0(ScrollView::onAfterDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_afterDrawCommand);
|
||||
}
|
||||
|
|
|
@ -1314,7 +1314,7 @@ void ActionFollow::onEnter()
|
|||
|
||||
void ActionFollow::draw()
|
||||
{
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionFollow::onDraw, this);
|
||||
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
|
@ -1630,7 +1630,7 @@ void ActionCatmullRomStacked::draw()
|
|||
kmGLPopMatrix();
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
|
||||
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
@ -1745,7 +1745,7 @@ void ActionCardinalSplineStacked::draw()
|
|||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
|
||||
kmGLPopMatrix();
|
||||
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCardinalSplineStacked::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
@ -2107,7 +2107,7 @@ void ActionCatmullRom::draw()
|
|||
kmGLPopMatrix();
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
|
||||
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
@ -2207,7 +2207,7 @@ void ActionCardinalSpline::draw()
|
|||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
|
||||
kmGLPopMatrix();
|
||||
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCardinalSpline::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ void Box2DTestLayer::draw()
|
|||
kmGLPushMatrix();
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV);
|
||||
|
||||
_customCommand.init(0, _vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Box2DTestLayer::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ void Box2DView::draw()
|
|||
{
|
||||
Layer::draw();
|
||||
|
||||
_customCmd.init(_vertexZ);
|
||||
_customCmd.init(_globalZOrder);
|
||||
_customCmd.func = CC_CALLBACK_0(Box2DView::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCmd);
|
||||
}
|
||||
|
|
|
@ -611,7 +611,7 @@ void RawStencilBufferTest::draw()
|
|||
|
||||
auto iter = _renderCmds.begin();
|
||||
|
||||
iter->init(_vertexZ);
|
||||
iter->init(_globalZOrder);
|
||||
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onEnableStencil, this);
|
||||
renderer->addCommand(&(*iter));
|
||||
++iter;
|
||||
|
@ -628,7 +628,7 @@ void RawStencilBufferTest::draw()
|
|||
spritePoint.y = 0;
|
||||
_sprites.at(i)->setPosition( spritePoint );
|
||||
|
||||
iter->init(_vertexZ);
|
||||
iter->init(_globalZOrder);
|
||||
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawClip, this, i, stencilPoint);
|
||||
renderer->addCommand(&(*iter));
|
||||
++iter;
|
||||
|
@ -638,7 +638,7 @@ void RawStencilBufferTest::draw()
|
|||
_sprites.at(i)->visit();
|
||||
kmGLPopMatrix();
|
||||
|
||||
iter->init(_vertexZ);
|
||||
iter->init(_globalZOrder);
|
||||
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawSprite, this, i, winPoint);
|
||||
renderer->addCommand(&(*iter));
|
||||
++iter;
|
||||
|
@ -649,7 +649,7 @@ void RawStencilBufferTest::draw()
|
|||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
iter->init(_vertexZ);
|
||||
iter->init(_globalZOrder);
|
||||
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onDisableStencil, this);
|
||||
renderer->addCommand(&(*iter));
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ DrawPrimitivesTest::DrawPrimitivesTest()
|
|||
|
||||
void DrawPrimitivesTest::draw()
|
||||
{
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -503,7 +503,7 @@ void TestChangeZorder::changeZorder(float dt)
|
|||
|
||||
Node *node = getChildByTag(currentTag);
|
||||
|
||||
node->setZOrder(CCRANDOM_0_1() * 3);
|
||||
node->setLocalZOrder(CCRANDOM_0_1() * 3);
|
||||
|
||||
currentTag ++;
|
||||
currentTag = currentTag % 3;
|
||||
|
@ -637,7 +637,7 @@ void TestParticleDisplay::onEnter()
|
|||
bone->addDisplay(p1, 0);
|
||||
bone->changeDisplayWithIndex(0, true);
|
||||
bone->setIgnoreMovementBoneData(true);
|
||||
bone->setZOrder(100);
|
||||
bone->setLocalZOrder(100);
|
||||
bone->setScale(1.2f);
|
||||
armature->addBone(bone, "bady-a3");
|
||||
|
||||
|
@ -645,7 +645,7 @@ void TestParticleDisplay::onEnter()
|
|||
bone->addDisplay(p2, 0);
|
||||
bone->changeDisplayWithIndex(0, true);
|
||||
bone->setIgnoreMovementBoneData(true);
|
||||
bone->setZOrder(100);
|
||||
bone->setLocalZOrder(100);
|
||||
bone->setScale(1.2f);
|
||||
armature->addBone(bone, "bady-a30");
|
||||
}
|
||||
|
@ -1067,7 +1067,7 @@ void TestColliderDetector::update(float delta)
|
|||
}
|
||||
void TestColliderDetector::draw()
|
||||
{
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(TestColliderDetector::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
@ -1108,7 +1108,7 @@ std::string TestBoundingBox::title() const
|
|||
}
|
||||
void TestBoundingBox::draw()
|
||||
{
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(TestBoundingBox::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ bool UIImageViewTest::init()
|
|||
_uiLayer->addChild(sprite);
|
||||
*/
|
||||
|
||||
// imageView->setZOrder(20);
|
||||
// imageView->setLocalZOrder(20);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ void Atlas1::draw()
|
|||
// GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
||||
// GL_TEXTURE_2D
|
||||
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Atlas1::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
|
||||
|
@ -526,7 +526,7 @@ Atlas4::Atlas4()
|
|||
|
||||
void Atlas4::draw()
|
||||
{
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Atlas4::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
@ -1612,7 +1612,7 @@ std::string LabelBMFontBounds::subtitle() const
|
|||
|
||||
void LabelBMFontBounds::draw()
|
||||
{
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ LabelFNTSpriteActions::LabelFNTSpriteActions()
|
|||
|
||||
void LabelFNTSpriteActions::draw()
|
||||
{
|
||||
_renderCmd.init(_vertexZ);
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
|
||||
|
||||
|
@ -912,7 +912,7 @@ std::string LabelFNTBounds::subtitle() const
|
|||
|
||||
void LabelFNTBounds::draw()
|
||||
{
|
||||
_renderCmd.init(_vertexZ);
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
|
||||
}
|
||||
|
|
|
@ -166,11 +166,11 @@ void TouchableSpriteTest::onEnter()
|
|||
target->setOpacity(255);
|
||||
if (target == sprite2)
|
||||
{
|
||||
sprite1->setZOrder(100);
|
||||
sprite1->setLocalZOrder(100);
|
||||
}
|
||||
else if(target == sprite1)
|
||||
{
|
||||
sprite1->setZOrder(0);
|
||||
sprite1->setLocalZOrder(0);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ static std::function<Layer*()> createFunctions[] =
|
|||
CL(ConvertToNode),
|
||||
CL(NodeOpaqueTest),
|
||||
CL(NodeNonOpaqueTest),
|
||||
CL(NodeGlobalZValueTest),
|
||||
};
|
||||
|
||||
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
|
||||
|
@ -905,6 +906,55 @@ std::string NodeNonOpaqueTest::subtitle() const
|
|||
return "Node rendered with GL_BLEND enabled";
|
||||
}
|
||||
|
||||
/// NodeGlobalZValueTest
|
||||
|
||||
NodeGlobalZValueTest::NodeGlobalZValueTest()
|
||||
{
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
Sprite *sprite;
|
||||
auto parent = Node::create();
|
||||
if(i==4) {
|
||||
sprite = Sprite::create("Images/grossinis_sister2.png");
|
||||
_sprite = sprite;
|
||||
_sprite->setGlobalZOrder(-1);
|
||||
}
|
||||
else
|
||||
sprite = Sprite::create("Images/grossinis_sister1.png");
|
||||
|
||||
parent->addChild(sprite);
|
||||
this->addChild(parent);
|
||||
|
||||
float w = sprite->getContentSize().width;
|
||||
sprite->setPosition(s.width/2 - w*0.7*(i-5), s.height/2);
|
||||
}
|
||||
|
||||
this->scheduleUpdate();
|
||||
}
|
||||
|
||||
void NodeGlobalZValueTest::update(float dt)
|
||||
{
|
||||
static float accum = 0;
|
||||
|
||||
accum += dt;
|
||||
if( accum > 1) {
|
||||
float z = _sprite->getGlobalZOrder();
|
||||
_sprite->setGlobalZOrder(-z);
|
||||
accum = 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::string NodeGlobalZValueTest::title() const
|
||||
{
|
||||
return "Global Z Value";
|
||||
}
|
||||
|
||||
std::string NodeGlobalZValueTest::subtitle() const
|
||||
{
|
||||
return "Center Sprite should change go from foreground to background";
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// MySprite: Used by CameraTest1 and CameraTest2
|
||||
|
@ -932,7 +982,7 @@ protected:
|
|||
|
||||
void MySprite::draw()
|
||||
{
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -249,6 +249,20 @@ protected:
|
|||
NodeNonOpaqueTest();
|
||||
};
|
||||
|
||||
class NodeGlobalZValueTest : public TestCocosNodeDemo
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(NodeGlobalZValueTest);
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
virtual void update(float dt) override;
|
||||
|
||||
protected:
|
||||
NodeGlobalZValueTest();
|
||||
Sprite *_sprite;
|
||||
};
|
||||
|
||||
class CocosNodeTestScene : public TestScene
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -470,19 +470,19 @@ RenderTextureTestDepthStencil::~RenderTextureTestDepthStencil()
|
|||
|
||||
void RenderTextureTestDepthStencil::draw()
|
||||
{
|
||||
_renderCmds[0].init(_vertexZ);
|
||||
_renderCmds[0].init(_globalZOrder);
|
||||
_renderCmds[0].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeClear, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[0]);
|
||||
|
||||
_rend->beginWithClear(0, 0, 0, 0, 0, 0);
|
||||
|
||||
_renderCmds[1].init(_vertexZ);
|
||||
_renderCmds[1].init(_globalZOrder);
|
||||
_renderCmds[1].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeStencil, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[1]);
|
||||
|
||||
_spriteDS->visit();
|
||||
|
||||
_renderCmds[2].init(_vertexZ);
|
||||
_renderCmds[2].init(_globalZOrder);
|
||||
_renderCmds[2].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[2]);
|
||||
|
||||
|
@ -490,7 +490,7 @@ void RenderTextureTestDepthStencil::draw()
|
|||
|
||||
_rend->end();
|
||||
|
||||
_renderCmds[3].init(_vertexZ);
|
||||
_renderCmds[3].init(_globalZOrder);
|
||||
_renderCmds[3].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onAfterDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[3]);
|
||||
|
||||
|
@ -638,7 +638,7 @@ SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::SimpleSprite::crea
|
|||
|
||||
void SpriteRenderTextureBug::SimpleSprite::draw()
|
||||
{
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(SpriteRenderTextureBug::SimpleSprite::onBeforeDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ void ShaderNode::setPosition(const Point &newPosition)
|
|||
|
||||
void ShaderNode::draw()
|
||||
{
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ShaderNode::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
@ -526,7 +526,7 @@ void SpriteBlur::initProgram()
|
|||
|
||||
void SpriteBlur::draw()
|
||||
{
|
||||
_customCommand.init(_vertexZ);
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(SpriteBlur::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ void ShaderSprite::initShader()
|
|||
|
||||
void ShaderSprite::draw()
|
||||
{
|
||||
_renderCommand.init(_vertexZ);
|
||||
_renderCommand.init(_globalZOrder);
|
||||
_renderCommand.func = CC_CALLBACK_0(ShaderSprite::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCommand);
|
||||
|
||||
|
|
|
@ -1794,7 +1794,7 @@ void TextureDrawAtPoint::draw()
|
|||
{
|
||||
TextureDemo::draw();
|
||||
|
||||
_renderCmd.init(_vertexZ);
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TextureDrawAtPoint::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
|
||||
|
||||
|
@ -1835,7 +1835,7 @@ void TextureDrawInRect::draw()
|
|||
{
|
||||
TextureDemo::draw();
|
||||
|
||||
_renderCmd.init(_vertexZ);
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TextureDrawInRect::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
|
||||
|
||||
|
|
|
@ -599,7 +599,7 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest()
|
|||
|
||||
void TMXOrthoObjectsTest::draw()
|
||||
{
|
||||
_renderCmd.init(_vertexZ);
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TMXOrthoObjectsTest::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ TMXIsoObjectsTest::TMXIsoObjectsTest()
|
|||
|
||||
void TMXIsoObjectsTest::draw()
|
||||
{
|
||||
_renderCmd.init(_vertexZ);
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TMXIsoObjectsTest::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
|
||||
}
|
||||
|
@ -1504,7 +1504,7 @@ TMXGIDObjectsTest::TMXGIDObjectsTest()
|
|||
|
||||
void TMXGIDObjectsTest::draw()
|
||||
{
|
||||
_renderCmd.init(_vertexZ);
|
||||
_renderCmd.init(_globalZOrder);
|
||||
_renderCmd.func = CC_CALLBACK_0(TMXGIDObjectsTest::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue