mirror of https://github.com/axmolengine/axmol.git
transform object returns the MV
code cleaner. the kmGL code is altogether
This commit is contained in:
parent
ff79c0d9ad
commit
6920bec6ef
|
@ -204,11 +204,16 @@ void ClippingNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool
|
||||||
if(!_visible)
|
if(!_visible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
kmGLPushMatrix();
|
|
||||||
|
|
||||||
bool dirty = parentTransformDirty || _transformDirty;
|
bool dirty = parentTransformDirty || _transformDirty;
|
||||||
if(dirty)
|
if(dirty)
|
||||||
transform();
|
_modelViewTransform = transform(parentTransform);
|
||||||
|
|
||||||
|
// IMPORTANT:
|
||||||
|
// To ease the migration to v3.0, we still support the kmGL stack,
|
||||||
|
// but it is deprecated and your code should not rely on it
|
||||||
|
kmGLPushMatrix();
|
||||||
|
kmGLLoadMatrix(&_modelViewTransform);
|
||||||
|
|
||||||
//Add group command
|
//Add group command
|
||||||
|
|
||||||
_groupCommand.init(_globalZOrder);
|
_groupCommand.init(_globalZOrder);
|
||||||
|
|
|
@ -693,11 +693,16 @@ void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
kmGLPushMatrix();
|
|
||||||
|
|
||||||
bool dirty = parentTransformDirty || _transformDirty;
|
bool dirty = parentTransformDirty || _transformDirty;
|
||||||
if(dirty)
|
if(dirty)
|
||||||
transform();
|
_modelViewTransform = transform(parentTransform);
|
||||||
|
|
||||||
|
// IMPORTANT:
|
||||||
|
// To ease the migration to v3.0, we still support the kmGL stack,
|
||||||
|
// but it is deprecated and your code should not rely on it
|
||||||
|
kmGLPushMatrix();
|
||||||
|
kmGLLoadMatrix(&_modelViewTransform);
|
||||||
|
|
||||||
draw(renderer, _modelViewTransform, dirty);
|
draw(renderer, _modelViewTransform, dirty);
|
||||||
|
|
||||||
kmGLPopMatrix();
|
kmGLPopMatrix();
|
||||||
|
|
|
@ -925,13 +925,17 @@ void Node::visit(Renderer* renderer, const kmMat4 &parentTransform, bool parentT
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
kmGLPushMatrix();
|
|
||||||
|
|
||||||
bool dirty = _transformDirty || parentTransformDirty;
|
bool dirty = _transformDirty || parentTransformDirty;
|
||||||
|
|
||||||
if(dirty)
|
if(dirty)
|
||||||
this->transform();
|
_modelViewTransform = this->transform(parentTransform);
|
||||||
|
|
||||||
|
|
||||||
|
// IMPORTANT:
|
||||||
|
// To ease the migration to v3.0, we still support the kmGL stack,
|
||||||
|
// but it is deprecated and your code should not rely on it
|
||||||
|
kmGLPushMatrix();
|
||||||
|
kmGLLoadMatrix(&_modelViewTransform);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
@ -967,21 +971,17 @@ void Node::visit(Renderer* renderer, const kmMat4 &parentTransform, bool parentT
|
||||||
|
|
||||||
void Node::transformAncestors()
|
void Node::transformAncestors()
|
||||||
{
|
{
|
||||||
if( _parent != nullptr )
|
// remove me
|
||||||
{
|
CCASSERT(false, "no longer supported");
|
||||||
_parent->transformAncestors();
|
|
||||||
_parent->transform();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::transform()
|
kmMat4 Node::transform(const kmMat4& parentTransform)
|
||||||
{
|
{
|
||||||
|
kmMat4 ret;
|
||||||
kmMat4 transfrom4x4 = this->getNodeToParentTransform();
|
kmMat4 transfrom4x4 = this->getNodeToParentTransform();
|
||||||
|
kmMat4Multiply(&ret, &parentTransform, &transfrom4x4);
|
||||||
|
|
||||||
kmGLMultMatrix( &transfrom4x4 );
|
return ret;
|
||||||
|
|
||||||
// saves the MV matrix
|
|
||||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewTransform);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::onEnter()
|
void Node::onEnter()
|
||||||
|
|
|
@ -1256,7 +1256,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes.
|
* Performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes.
|
||||||
*/
|
*/
|
||||||
void transform();
|
kmMat4 transform(const kmMat4 &parentTransform);
|
||||||
/**
|
/**
|
||||||
* Performs OpenGL view-matrix transformation of it's ancestors.
|
* Performs OpenGL view-matrix transformation of it's ancestors.
|
||||||
* Generally the ancestors are already transformed, but in certain cases (eg: attaching a FBO)
|
* Generally the ancestors are already transformed, but in certain cases (eg: attaching a FBO)
|
||||||
|
|
|
@ -94,7 +94,16 @@ void NodeGrid::visit(Renderer *renderer, const kmMat4 &parentTransform, bool par
|
||||||
renderer->addCommand(&_groupCommand);
|
renderer->addCommand(&_groupCommand);
|
||||||
renderer->pushGroup(_groupCommand.getRenderQueueID());
|
renderer->pushGroup(_groupCommand.getRenderQueueID());
|
||||||
|
|
||||||
|
bool dirty = parentTransformDirty || _transformDirty;
|
||||||
|
if(dirty)
|
||||||
|
_modelViewTransform = this->transform(parentTransform);
|
||||||
|
|
||||||
|
// IMPORTANT:
|
||||||
|
// To ease the migration to v3.0, we still support the kmGL stack,
|
||||||
|
// but it is deprecated and your code should not rely on it
|
||||||
kmGLPushMatrix();
|
kmGLPushMatrix();
|
||||||
|
kmGLLoadMatrix(&_modelViewTransform);
|
||||||
|
|
||||||
Director::Projection beforeProjectionType;
|
Director::Projection beforeProjectionType;
|
||||||
if(_nodeGrid && _nodeGrid->isActive())
|
if(_nodeGrid && _nodeGrid->isActive())
|
||||||
{
|
{
|
||||||
|
@ -106,10 +115,7 @@ void NodeGrid::visit(Renderer *renderer, const kmMat4 &parentTransform, bool par
|
||||||
_gridBeginCommand.func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this);
|
_gridBeginCommand.func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this);
|
||||||
renderer->addCommand(&_gridBeginCommand);
|
renderer->addCommand(&_gridBeginCommand);
|
||||||
|
|
||||||
bool dirty = parentTransformDirty || _transformDirty;
|
|
||||||
if(dirty)
|
|
||||||
this->transform();
|
|
||||||
|
|
||||||
if(_gridTarget)
|
if(_gridTarget)
|
||||||
{
|
{
|
||||||
_gridTarget->visit(renderer, _modelViewTransform, dirty);
|
_gridTarget->visit(renderer, _modelViewTransform, dirty);
|
||||||
|
|
|
@ -134,11 +134,15 @@ void ParticleBatchNode::visit(Renderer *renderer, const kmMat4 &parentTransform,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
kmGLPushMatrix();
|
|
||||||
|
|
||||||
bool dirty = parentTransformDirty || _transformDirty;
|
bool dirty = parentTransformDirty || _transformDirty;
|
||||||
if(dirty)
|
if(dirty)
|
||||||
transform();
|
_modelViewTransform = transform(parentTransform);
|
||||||
|
|
||||||
|
// IMPORTANT:
|
||||||
|
// To ease the migration to v3.0, we still support the kmGL stack,
|
||||||
|
// but it is deprecated and your code should not rely on it
|
||||||
|
kmGLPushMatrix();
|
||||||
|
kmGLLoadMatrix(&_modelViewTransform);
|
||||||
|
|
||||||
draw(renderer, _modelViewTransform, dirty);
|
draw(renderer, _modelViewTransform, dirty);
|
||||||
|
|
||||||
|
|
|
@ -370,11 +370,15 @@ void RenderTexture::visit(Renderer *renderer, const kmMat4 &parentTransform, boo
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
kmGLPushMatrix();
|
|
||||||
|
|
||||||
bool dirty = parentTransformDirty || _transformDirty;
|
bool dirty = parentTransformDirty || _transformDirty;
|
||||||
if(dirty)
|
if(dirty)
|
||||||
transform();
|
_modelViewTransform = transform(parentTransform);
|
||||||
|
|
||||||
|
// IMPORTANT:
|
||||||
|
// To ease the migration to v3.0, we still support the kmGL stack,
|
||||||
|
// but it is deprecated and your code should not rely on it
|
||||||
|
kmGLPushMatrix();
|
||||||
|
kmGLLoadMatrix(&_modelViewTransform);
|
||||||
|
|
||||||
_sprite->visit(renderer, _modelViewTransform, dirty);
|
_sprite->visit(renderer, _modelViewTransform, dirty);
|
||||||
draw(renderer, _modelViewTransform, dirty);
|
draw(renderer, _modelViewTransform, dirty);
|
||||||
|
|
|
@ -147,13 +147,17 @@ void SpriteBatchNode::visit(Renderer *renderer, const kmMat4 &parentTransform, b
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
kmGLPushMatrix();
|
|
||||||
|
|
||||||
sortAllChildren();
|
sortAllChildren();
|
||||||
|
|
||||||
bool dirty = parentTransformDirty || _transformDirty;
|
bool dirty = parentTransformDirty || _transformDirty;
|
||||||
if(dirty)
|
if(dirty)
|
||||||
transform();
|
_modelViewTransform = transform(parentTransform);
|
||||||
|
|
||||||
|
// IMPORTANT:
|
||||||
|
// To ease the migration to v3.0, we still support the kmGL stack,
|
||||||
|
// but it is deprecated and your code should not rely on it
|
||||||
|
kmGLPushMatrix();
|
||||||
|
kmGLLoadMatrix(&_modelViewTransform);
|
||||||
|
|
||||||
draw(renderer, _modelViewTransform, dirty);
|
draw(renderer, _modelViewTransform, dirty);
|
||||||
|
|
||||||
|
|
|
@ -452,11 +452,17 @@ void Armature::visit(cocos2d::Renderer *renderer, const kmMat4 &parentTransform,
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
kmGLPushMatrix();
|
|
||||||
|
|
||||||
bool dirty = parentTransformDirty || _transformDirty;
|
bool dirty = parentTransformDirty || _transformDirty;
|
||||||
if(dirty)
|
if(dirty)
|
||||||
transform();
|
_modelViewTransform = transform(parentTransform);
|
||||||
|
|
||||||
|
// IMPORTANT:
|
||||||
|
// To ease the migration to v3.0, we still support the kmGL stack,
|
||||||
|
// but it is deprecated and your code should not rely on it
|
||||||
|
kmGLPushMatrix();
|
||||||
|
kmGLLoadMatrix(&_modelViewTransform);
|
||||||
|
|
||||||
sortAllChildren();
|
sortAllChildren();
|
||||||
draw(renderer, _modelViewTransform, dirty);
|
draw(renderer, _modelViewTransform, dirty);
|
||||||
|
|
||||||
|
|
|
@ -108,11 +108,16 @@ void BatchNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool pa
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
kmGLPushMatrix();
|
|
||||||
|
|
||||||
bool dirty = parentTransformDirty || _transformDirty;
|
bool dirty = parentTransformDirty || _transformDirty;
|
||||||
if(dirty)
|
if(dirty)
|
||||||
transform();
|
_modelViewTransform = transform(parentTransform);
|
||||||
|
|
||||||
|
// IMPORTANT:
|
||||||
|
// To ease the migration to v3.0, we still support the kmGL stack,
|
||||||
|
// but it is deprecated and your code should not rely on it
|
||||||
|
kmGLPushMatrix();
|
||||||
|
kmGLLoadMatrix(&_modelViewTransform);
|
||||||
|
|
||||||
sortAllChildren();
|
sortAllChildren();
|
||||||
draw(renderer, _modelViewTransform, dirty);
|
draw(renderer, _modelViewTransform, dirty);
|
||||||
|
|
|
@ -204,10 +204,16 @@ void Layout::stencilClippingVisit(Renderer *renderer, const kmMat4 &parentTransf
|
||||||
if(!_visible)
|
if(!_visible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
kmGLPushMatrix();
|
|
||||||
bool dirty = parentTransformDirty || _transformDirty;
|
bool dirty = parentTransformDirty || _transformDirty;
|
||||||
if(dirty)
|
if(dirty)
|
||||||
transform();
|
_modelViewTransform = transform(parentTransform);
|
||||||
|
|
||||||
|
// IMPORTANT:
|
||||||
|
// To ease the migration to v3.0, we still support the kmGL stack,
|
||||||
|
// but it is deprecated and your code should not rely on it
|
||||||
|
kmGLPushMatrix();
|
||||||
|
kmGLLoadMatrix(&_modelViewTransform);
|
||||||
|
|
||||||
//Add group command
|
//Add group command
|
||||||
|
|
||||||
_groupCommand.init(_globalZOrder);
|
_groupCommand.init(_globalZOrder);
|
||||||
|
|
|
@ -560,11 +560,15 @@ void ScrollView::visit(Renderer *renderer, const kmMat4 &parentTransform, bool p
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
kmGLPushMatrix();
|
|
||||||
|
|
||||||
bool dirty = parentTransformDirty || _transformDirty;
|
bool dirty = parentTransformDirty || _transformDirty;
|
||||||
if(dirty)
|
if(dirty)
|
||||||
this->transform();
|
_modelViewTransform = this->transform(parentTransform);
|
||||||
|
|
||||||
|
// IMPORTANT:
|
||||||
|
// To ease the migration to v3.0, we still support the kmGL stack,
|
||||||
|
// but it is deprecated and your code should not rely on it
|
||||||
|
kmGLPushMatrix();
|
||||||
|
kmGLLoadMatrix(&_modelViewTransform);
|
||||||
|
|
||||||
this->beforeDraw();
|
this->beforeDraw();
|
||||||
|
|
||||||
|
|
|
@ -633,7 +633,7 @@ void RawStencilBufferTest::draw(Renderer *renderer, const kmMat4 &transform, boo
|
||||||
++iter;
|
++iter;
|
||||||
|
|
||||||
kmGLPushMatrix();
|
kmGLPushMatrix();
|
||||||
this->transform();
|
_modelViewTransform = this->transform(transform);
|
||||||
_sprites.at(i)->visit(renderer, _modelViewTransform, transformDirty);
|
_sprites.at(i)->visit(renderer, _modelViewTransform, transformDirty);
|
||||||
kmGLPopMatrix();
|
kmGLPopMatrix();
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ void RawStencilBufferTest::draw(Renderer *renderer, const kmMat4 &transform, boo
|
||||||
++iter;
|
++iter;
|
||||||
|
|
||||||
kmGLPushMatrix();
|
kmGLPushMatrix();
|
||||||
this->transform();
|
_modelViewTransform = this->transform(transform);
|
||||||
_sprites.at(i)->visit(renderer, _modelViewTransform, transformDirty);
|
_sprites.at(i)->visit(renderer, _modelViewTransform, transformDirty);
|
||||||
kmGLPopMatrix();
|
kmGLPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue