issue #1056: Updated some files.

This commit is contained in:
James Chen 2012-03-26 22:37:09 +08:00
parent 0f5efaffd2
commit 7d04254855
4 changed files with 30 additions and 19 deletions

View File

@ -304,7 +304,7 @@ void CCParticleSystemQuad::draw()
/* FIXME: It will cause crash on some devices if the last parameter is zero. /* FIXME: It will cause crash on some devices if the last parameter is zero.
I'm not familiar with opengles, but my change works. --By James Chen. I'm not familiar with opengles, but my change works. --By James Chen.
*/ */
glDrawElements(GL_TRIANGLES, (GLsizei) m_uParticleIdx*6, GL_UNSIGNED_SHORT, 0/*m_pIndices*/ /*0*/); glDrawElements(GL_TRIANGLES, (GLsizei) m_uParticleIdx*6, GL_UNSIGNED_SHORT, m_pIndices /*0*/);
glBindVertexArray( 0 ); glBindVertexArray( 0 );

View File

@ -735,11 +735,11 @@ void CCSprite::setReorderChildDirtyRecursively(void)
if ( ! m_bReorderChildDirty ) if ( ! m_bReorderChildDirty )
{ {
m_bReorderChildDirty = true; m_bReorderChildDirty = true;
CCNode* node = (CCNode*) m_pParent; CCNode* pNode = (CCNode*)m_pParent;
while (node && node != m_pobBatchNode) while (pNode && pNode != m_pobBatchNode)
{ {
((CCSprite*)node)->setReorderChildDirtyRecursively(); ((CCSprite*)pNode)->setReorderChildDirtyRecursively();
node=node->getParent(); pNode=pNode->getParent();
} }
} }
} }

View File

@ -292,12 +292,13 @@ void CCSpriteBatchNode::sortAllChildren()
void CCSpriteBatchNode::updateAtlasIndex(CCSprite* sprite, int* curIndex) void CCSpriteBatchNode::updateAtlasIndex(CCSprite* sprite, int* curIndex)
{ {
CCArray *array = sprite->getChildren(); unsigned int count = 0;
if (array == NULL) CCArray* pArray = sprite->getChildren();
if (pArray != NULL)
{ {
return; count = pArray->count();
} }
unsigned int count = array->count();
int oldIndex = 0; int oldIndex = 0;
if( count == 0 ) if( count == 0 )
@ -314,7 +315,7 @@ void CCSpriteBatchNode::updateAtlasIndex(CCSprite* sprite, int* curIndex)
{ {
bool needNewIndex=true; bool needNewIndex=true;
if (((CCSprite*) (array->data->arr[0]))->getZOrder() >= 0) if (((CCSprite*) (pArray->data->arr[0]))->getZOrder() >= 0)
{ {
//all children are in front of the parent //all children are in front of the parent
oldIndex = sprite->getAtlasIndex(); oldIndex = sprite->getAtlasIndex();
@ -330,7 +331,7 @@ void CCSpriteBatchNode::updateAtlasIndex(CCSprite* sprite, int* curIndex)
} }
CCObject* pObj = NULL; CCObject* pObj = NULL;
CCARRAY_FOREACH(array,pObj) CCARRAY_FOREACH(pArray,pObj)
{ {
CCSprite* child = (CCSprite*)pObj; CCSprite* child = (CCSprite*)pObj;
if (needNewIndex && child->getZOrder() >= 0) if (needNewIndex && child->getZOrder() >= 0)
@ -355,7 +356,7 @@ void CCSpriteBatchNode::updateAtlasIndex(CCSprite* sprite, int* curIndex)
sprite->setAtlasIndex(*curIndex); sprite->setAtlasIndex(*curIndex);
sprite->setOrderOfArrival(0); sprite->setOrderOfArrival(0);
if (oldIndex!=*curIndex) { if (oldIndex!=*curIndex) {
this->swap(oldIndex, *curIndex); swap(oldIndex, *curIndex);
} }
(*curIndex)++; (*curIndex)++;
} }
@ -391,7 +392,9 @@ void CCSpriteBatchNode::draw(void)
// Optimization: Fast Dispatch // Optimization: Fast Dispatch
if( m_pobTextureAtlas->getTotalQuads() == 0 ) if( m_pobTextureAtlas->getTotalQuads() == 0 )
{
return; return;
}
CC_NODE_DRAW_SETUP(); CC_NODE_DRAW_SETUP();

View File

@ -303,7 +303,8 @@ void CCTextureAtlas::insertQuad(ccV3F_C4B_T2F_Quad *quad, unsigned int index)
unsigned int remaining = (m_uTotalQuads-1) - index; unsigned int remaining = (m_uTotalQuads-1) - index;
// last object doesn't need to be moved // last object doesn't need to be moved
if( remaining > 0) { if( remaining > 0)
{
// texture coordinates // texture coordinates
memmove( &m_pQuads[index+1],&m_pQuads[index], sizeof(m_pQuads[0]) * remaining ); memmove( &m_pQuads[index+1],&m_pQuads[index], sizeof(m_pQuads[0]) * remaining );
} }
@ -328,9 +329,10 @@ void CCTextureAtlas::insertQuads(ccV3F_C4B_T2F_Quad* quads, unsigned int index,
// last object doesn't need to be moved // last object doesn't need to be moved
if( remaining > 0) if( remaining > 0)
{
// tex coordinates // tex coordinates
memmove( &m_pQuads[index+amount],&m_pQuads[index], sizeof(m_pQuads[0]) * remaining ); memmove( &m_pQuads[index+amount],&m_pQuads[index], sizeof(m_pQuads[0]) * remaining );
}
unsigned int max = index + amount; unsigned int max = index + amount;
@ -351,14 +353,16 @@ void CCTextureAtlas::insertQuadFromIndex(unsigned int oldIndex, unsigned int new
CCAssert( oldIndex >= 0 && oldIndex < m_uTotalQuads, "insertQuadFromIndex:atIndex: Invalid index"); CCAssert( oldIndex >= 0 && oldIndex < m_uTotalQuads, "insertQuadFromIndex:atIndex: Invalid index");
if( oldIndex == newIndex ) if( oldIndex == newIndex )
{
return; return;
}
// because it is ambigious in iphone, so we implement abs ourself // because it is ambigious in iphone, so we implement abs ourself
// unsigned int howMany = abs( oldIndex - newIndex); // unsigned int howMany = abs( oldIndex - newIndex);
unsigned int howMany = (oldIndex - newIndex) > 0 ? (oldIndex - newIndex) : (newIndex - oldIndex); unsigned int howMany = (oldIndex - newIndex) > 0 ? (oldIndex - newIndex) : (newIndex - oldIndex);
unsigned int dst = oldIndex; unsigned int dst = oldIndex;
unsigned int src = oldIndex + 1; unsigned int src = oldIndex + 1;
if( oldIndex > newIndex) { if( oldIndex > newIndex)
{
dst = newIndex+1; dst = newIndex+1;
src = newIndex; src = newIndex;
} }
@ -381,7 +385,8 @@ void CCTextureAtlas::removeQuadAtIndex(unsigned int index)
// last object doesn't need to be moved // last object doesn't need to be moved
if( remaining ) { if( remaining )
{
// texture coordinates // texture coordinates
memmove( &m_pQuads[index],&m_pQuads[index+1], sizeof(m_pQuads[0]) * remaining ); memmove( &m_pQuads[index],&m_pQuads[index+1], sizeof(m_pQuads[0]) * remaining );
} }
@ -402,7 +407,9 @@ void CCTextureAtlas::removeQuadsAtIndex(unsigned int index, unsigned int amount)
m_uTotalQuads -= amount; m_uTotalQuads -= amount;
if ( remaining ) if ( remaining )
{
memmove( &m_pQuads[index], &m_pQuads[index+amount], sizeof(m_pQuads[0]) * remaining ); memmove( &m_pQuads[index], &m_pQuads[index+amount], sizeof(m_pQuads[0]) * remaining );
}
m_bDirty = true; m_bDirty = true;
} }
@ -416,8 +423,9 @@ void CCTextureAtlas::removeAllQuads()
bool CCTextureAtlas::resizeCapacity(unsigned int newCapacity) bool CCTextureAtlas::resizeCapacity(unsigned int newCapacity)
{ {
if( newCapacity == m_uCapacity ) if( newCapacity == m_uCapacity )
{
return true; return true;
}
// update capacity and totolQuads // update capacity and totolQuads
m_uTotalQuads = MIN(m_uTotalQuads, newCapacity); m_uTotalQuads = MIN(m_uTotalQuads, newCapacity);
m_uCapacity = newCapacity; m_uCapacity = newCapacity;
@ -562,7 +570,7 @@ void CCTextureAtlas::drawNumberOfQuads(unsigned int n, unsigned int start)
#if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP #if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP
glDrawElements(GL_TRIANGLE_STRIP, (GLsizei) n*6, GL_UNSIGNED_SHORT, (GLvoid*) (m_pIndices)/*(start*6*sizeof(m_pIndices[0]))*/ ); glDrawElements(GL_TRIANGLE_STRIP, (GLsizei) n*6, GL_UNSIGNED_SHORT, (GLvoid*) (m_pIndices)/*(start*6*sizeof(m_pIndices[0]))*/ );
#else #else
glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, (GLvoid*) 0/*(m_pIndices)*//*(start*6*sizeof(m_pIndices[0]))*/ ); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, (GLvoid*) (m_pIndices)/*(start*6*sizeof(m_pIndices[0]))*/ );
#endif // CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP #endif // CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP