Permalink
Browse files

compiles on Mac + cosmetic changes

  • Loading branch information...
1 parent 0c4a22f commit 44c3997a7277c82c4a1aab85d2bf6093624d58f5 @ricardoquesada ricardoquesada committed Oct 21, 2011
@@ -38,6 +38,8 @@
/* Begin PBXBuildFile section */
A02C341D13C918690081CFF7 /* grossini_pvr_rgba8888.pvr in Resources */ = {isa = PBXBuildFile; fileRef = A02C341C13C918550081CFF7 /* grossini_pvr_rgba8888.pvr */; };
+ A0AAB8241451C8C000850F2C /* CCParticleBatchNode.h in Headers */ = {isa = PBXBuildFile; fileRef = A0AAB8221451C8C000850F2C /* CCParticleBatchNode.h */; };
+ A0AAB8251451C8C000850F2C /* CCParticleBatchNode.m in Sources */ = {isa = PBXBuildFile; fileRef = A0AAB8231451C8C000850F2C /* CCParticleBatchNode.m */; };
A0B0375E13EA1A2A0073E59A /* bugs in Resources */ = {isa = PBXBuildFile; fileRef = A0B0375D13EA1A290073E59A /* bugs */; };
A0B0375F13EA1A2A0073E59A /* bugs in Resources */ = {isa = PBXBuildFile; fileRef = A0B0375D13EA1A290073E59A /* bugs */; };
E01E6A3E121EDCD3001A484F /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E01E6A3D121EDCD3001A484F /* ApplicationServices.framework */; };
@@ -3564,6 +3566,9 @@
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
A02C341C13C918550081CFF7 /* grossini_pvr_rgba8888.pvr */ = {isa = PBXFileReference; lastKnownFileType = file; path = grossini_pvr_rgba8888.pvr; sourceTree = "<group>"; };
+ A0AAB8211451C8A700850F2C /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.md; sourceTree = "<group>"; };
+ A0AAB8221451C8C000850F2C /* CCParticleBatchNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCParticleBatchNode.h; sourceTree = "<group>"; };
+ A0AAB8231451C8C000850F2C /* CCParticleBatchNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCParticleBatchNode.m; sourceTree = "<group>"; };
A0B0375D13EA1A290073E59A /* bugs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = bugs; path = Resources/Images/bugs; sourceTree = "<group>"; };
E01E663D121CA00A001A484F /* libcocos2d.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libcocos2d.a; sourceTree = BUILT_PRODUCTS_DIR; };
E01E6A3D121EDCD3001A484F /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; };
@@ -3740,7 +3745,6 @@
E076E61C1225EC1E00DE0DA2 /* AUTHORS */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AUTHORS; sourceTree = "<group>"; };
E076E61D1225EC1E00DE0DA2 /* CHANGELOG */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CHANGELOG; sourceTree = "<group>"; };
E076E61E1225EC1E00DE0DA2 /* DONORS */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DONORS; sourceTree = "<group>"; };
- E076E6211225EC1E00DE0DA2 /* README.mdown */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.mdown; sourceTree = "<group>"; };
E076E6221225EC4E00DE0DA2 /* MenuTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MenuTest.h; path = tests/MenuTest.h; sourceTree = "<group>"; };
E076E6231225EC4E00DE0DA2 /* MenuTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MenuTest.m; path = tests/MenuTest.m; sourceTree = "<group>"; };
E076E6251225EC5F00DE0DA2 /* TransitionsTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TransitionsTest.h; path = tests/TransitionsTest.h; sourceTree = "<group>"; };
@@ -4463,7 +4467,7 @@
29B97314FDCFA39411CA2CEA /* cocos2d-mac */ = {
isa = PBXGroup;
children = (
- E076E6211225EC1E00DE0DA2 /* README.mdown */,
+ A0AAB8211451C8A700850F2C /* README.md */,
E076E61C1225EC1E00DE0DA2 /* AUTHORS */,
E076EB3E1225F05200DE0DA2 /* RELEASE_NOTES */,
E076E61D1225EC1E00DE0DA2 /* CHANGELOG */,
@@ -4974,6 +4978,8 @@
E076E7741225EC9D00DE0DA2 /* Particle Nodes */ = {
isa = PBXGroup;
children = (
+ A0AAB8221451C8C000850F2C /* CCParticleBatchNode.h */,
+ A0AAB8231451C8C000850F2C /* CCParticleBatchNode.m */,
E076E6671225EC7400DE0DA2 /* CCParticleExamples.h */,
E076E6681225EC7400DE0DA2 /* CCParticleExamples.m */,
E076E6691225EC7400DE0DA2 /* CCParticleSystem.h */,
@@ -5474,6 +5480,7 @@
E02BBC80126CD870006E46A2 /* CCAnimationCache.h in Headers */,
E026452912A59F1E009D04FE /* CCParticleSystemPoint.h in Headers */,
E08AA19B12C262B3000341BD /* MacWindow.h in Headers */,
+ A0AAB8241451C8C000850F2C /* CCParticleBatchNode.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -9028,6 +9035,7 @@
E02BBC7F126CD870006E46A2 /* CCAnimationCache.m in Sources */,
E026452A12A59F1E009D04FE /* CCParticleSystemPoint.m in Sources */,
E08AA19C12C262B3000341BD /* MacWindow.m in Sources */,
+ A0AAB8251451C8C000850F2C /* CCParticleBatchNode.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
@@ -520,9 +520,9 @@ - (void) sortAllChildren
{
if (isReorderChildDirty_)
{
- int i,j,length=children_->data->num;
- id* x=children_->data->arr;
- id tempItem;
+ NSInteger i,j,length=children_->data->num;
+ CCNode ** x=children_->data->arr;
+ CCNode *tempItem;
//insertion sort
for(i=1; i<length; i++)
@@ -531,7 +531,7 @@ - (void) sortAllChildren
j = i-1;
//continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller
- while(j>=0 && ( ((CCNode*) tempItem).zOrder<((CCNode*)x[j]).zOrder || ( ((CCNode*) tempItem).zOrder== ((CCNode*)x[j]).zOrder && ((CCNode*) tempItem).mutatedIndex < ((CCNode*)x[j]).mutatedIndex ) ) )
+ while(j>=0 && ( tempItem.zOrder< x[j].zOrder || ( tempItem.zOrder == x[j].zOrder && tempItem.mutatedIndex < x[j].mutatedIndex ) ) )
{
x[j+1] = x[j];
j = j-1;
@@ -34,7 +34,7 @@
//don't use lazy sorting for particle systems
@interface CCNode (extension)
--(void) setZOrder:(uint) z;
+-(void) setZOrder:(NSUInteger) z;
@end
/** CCParticleBatchNode is like a batch node: if it contains children, it will draw them in 1 single OpenGL call
@@ -112,7 +112,7 @@
-(void) removeChildFromAtlas:(CCParticleSystem*) pSystem cleanup:(BOOL) doCleanUp;
/** disables a particle by inserting a 0'd quad into the texture atlas */
--(void) disableParticle:(uint) particleIndex;
+-(void) disableParticle:(NSUInteger) particleIndex;
/** switch between multiplied and premultiplied blending modes */
-(void) switchBlendingBetweenMultipliedAndPreMultiplied;
@@ -47,7 +47,7 @@
//need to set z-order manualy, because fast reordering of childs would be complexer / slower
@implementation CCNode (extension)
--(void) setZOrder:(uint) z
+-(void) setZOrder:(NSUInteger) z
{
zOrder_ = z;
}
@@ -231,13 +231,15 @@ -(void) addChild:(CCParticleSystem*)child z:(NSInteger)z tag:(NSInteger) aTag
}
//no lazy sorting, so don't call super addChild, call helper instead
- uint pos = [self addChildHelper:child z:z tag:aTag];
+ NSUInteger pos = [self addChildHelper:child z:z tag:aTag];
//get new atlasIndex
- uint atlasIndex;
+ NSUInteger atlasIndex;
- if (pos != 0) atlasIndex = [[children_ objectAtIndex:pos-1] atlasIndex]+[[children_ objectAtIndex:pos-1] totalParticles];
- else atlasIndex = 0;
+ if (pos != 0)
+ atlasIndex = [[children_ objectAtIndex:pos-1] atlasIndex]+[[children_ objectAtIndex:pos-1] totalParticles];
+ else
+ atlasIndex = 0;
[child useBatchNode:self];
@@ -248,15 +250,16 @@ -(void) addChild:(CCParticleSystem*)child z:(NSInteger)z tag:(NSInteger) aTag
//XXX research whether lazy sorting + freeing current quads and calloc a new block with size of capacity would be faster
//XXX or possibly using vertexZ for reordering, that would be fastest
//this helper is almost equivalent to CCNode's addChild, but doesn't make use of the lazy sorting
--(uint) addChildHelper: (CCNode*) child z:(NSInteger)z tag:(NSInteger) aTag
+-(NSUInteger) addChildHelper: (CCNode*) child z:(NSInteger)z tag:(NSInteger) aTag
{
NSAssert( child != nil, @"Argument must be non-nil");
NSAssert( child.parent == nil, @"child already added. It can't be added again");
- if( ! children_ ) children_ = [[CCArray alloc] initWithCapacity:4];
+ if( ! children_ )
+ children_ = [[CCArray alloc] initWithCapacity:4];
//don't use a lazy insert
- uint pos = [self searchNewPositionInChildrenForZ:z];
+ NSUInteger pos = [self searchNewPositionInChildrenForZ:z];
[children_ insertObject:child atIndex:pos];
@@ -287,21 +290,24 @@ -(void) reorderChild:(CCParticleSystem*)child z:(NSInteger)z
reorderDirty_ = YES;
[child retain];
- uint oldPos = [children_ indexOfObject:child];
+ NSUInteger oldPos = [children_ indexOfObject:child];
//only remove the child, not the scheduled update
[children_ removeObject:child];
- uint pos = [self searchNewPositionInChildrenForZ:z];
+ NSUInteger pos = [self searchNewPositionInChildrenForZ:z];
if (pos != oldPos)
{
- uint newIndex;
- if (pos == [children_ count]) newIndex = textureAtlas_.totalQuads;
- else newIndex = [[children_ objectAtIndex:MIN([children_ count]-1,pos)] atlasIndex];
+ NSUInteger newIndex;
+ if (pos == [children_ count])
+ newIndex = textureAtlas_.totalQuads;
+ else
+ newIndex = [[children_ objectAtIndex:MIN([children_ count]-1,pos)] atlasIndex];
//to correctly move the quads, the new index needs to be the left border of where the quads will be placed
- if (z > child.zOrder) newIndex -= child.totalParticles;
+ if (z > child.zOrder)
+ newIndex -= child.totalParticles;
//move quads in textureAtlas
[self moveSystem:child toNewIndex:newIndex];
@@ -318,7 +324,7 @@ -(void) reorderChild:(CCParticleSystem*)child z:(NSInteger)z
-(NSUInteger) searchNewPositionInChildrenForZ: (NSInteger) z
{
int i = 0;
- uint count = [children_ count];
+ NSUInteger count = [children_ count];
CCNode* child;
while (i < count)
@@ -405,7 +411,7 @@ -(void) moveSystem:(CCParticleSystem*) system toNewIndex:(NSUInteger) newIndex
}
//sets a 0'd quad into the quads array
--(void) disableParticle:(uint) particleIndex
+-(void) disableParticle:(NSUInteger) particleIndex
{
ccV3F_C4B_T2F_Quad* quad = &((textureAtlas_.quads)[particleIndex]);
quad->br.vertices.x = quad->br.vertices.y = quad->tr.vertices.x = quad->tr.vertices.y = quad->tl.vertices.x = quad->tl.vertices.y = quad->bl.vertices.x = quad->bl.vertices.y = 0.0f;
@@ -103,7 +103,7 @@ typedef struct sCCParticle {
ccTime timeToLive;
- uint atlasIndex;
+ NSUInteger atlasIndex;
union {
// Mode A: gravity, direction, radial accel, tangential accel
@@ -298,7 +298,7 @@ typedef void (*CC_UPDATE_PARTICLE_IMP)(id, SEL, tCCParticle*, CGPoint);
CCParticleBatchNode *batchNode_;
BOOL useBatchNode_;
//index of system in batch node array
- uint atlasIndex_;
+ NSUInteger atlasIndex_;
//YES if scaled or rotated
BOOL transformSystemDirty_;
@@ -410,7 +410,7 @@ typedef void (*CC_UPDATE_PARTICLE_IMP)(id, SEL, tCCParticle*, CGPoint);
*/
@property (nonatomic,readwrite) NSInteger emitterMode;
-@property (nonatomic,readwrite) uint atlasIndex;
+@property (nonatomic,readwrite) NSUInteger atlasIndex;
@property (nonatomic,readonly) BOOL useBatchNode;
@@ -610,7 +610,7 @@ -(void) update: (ccTime) dt
} else {
// life < 0
- uint currentIndex = p->atlasIndex;
+ NSUInteger currentIndex = p->atlasIndex;
if( particleIdx != particleCount-1 )
particles[particleIdx] = particles[particleCount-1];
@@ -863,7 +863,7 @@ -(void) useBatchNode:(CCParticleBatchNode*) batchNode
useBatchNode_ = YES;
//each particle needs a unique index
- for (int i = 0; i < totalParticles; i++)
+ for (NSUInteger i = 0; i < totalParticles; i++)
{
particles[i].atlasIndex=i;
}
@@ -190,7 +190,7 @@ -(void) initTexCoordsWithRect:(CGRect)pointRect
CC_SWAP( top, bottom);
ccV3F_C4B_T2F_Quad *quadCollection;
- uint start, end;
+ NSUInteger start, end;
if (useBatchNode_)
{
quadCollection = [[batchNode_ textureAtlas] quads];
@@ -204,7 +204,7 @@ -(void) initTexCoordsWithRect:(CGRect)pointRect
end = totalParticles;
}
- for(int i=start; i<end; i++) {
+ for(NSInteger i=start; i<end; i++) {
// bottom-left vertex:
quadCollection[i].bl.texCoords.u = left;
quadCollection[i].bl.texCoords.v = bottom;
View
@@ -703,9 +703,9 @@ - (void) sortAllChildren
{
if (isReorderChildDirty_)
{
- int i,j,length=children_->data->num;
- id* x=children_->data->arr;
- id tempItem;
+ NSInteger i,j,length=children_->data->num;
+ CCNode ** x=children_->data->arr;
+ CCNode * tempItem;
//insertion sort
for(i=1; i<length; i++)
@@ -714,7 +714,7 @@ - (void) sortAllChildren
j = i-1;
//continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller
- while(j>=0 && ( ((CCNode*) tempItem).zOrder<((CCNode*)x[j]).zOrder || ( ((CCNode*) tempItem).zOrder== ((CCNode*)x[j]).zOrder && ((CCNode*) tempItem).mutatedIndex < ((CCNode*)x[j]).mutatedIndex ) ) )
+ while(j>=0 && ( tempItem.zOrder < x[j].zOrder || ( tempItem.zOrder == x[j].zOrder && tempItem.mutatedIndex < x[j].mutatedIndex ) ) )
{
x[j+1] = x[j];
j = j-1;
@@ -61,7 +61,7 @@
@private
- void (*updateAtlasIndexMethod_)(id, SEL,CCSprite*,int*);
+ void (*updateAtlasIndexMethod_)(id, SEL,CCSprite*,NSInteger*);
}
@@ -46,8 +46,8 @@
@interface CCSpriteBatchNode (private)
-(void) updateBlendFunc;
--(void) updateAtlasIndex:(CCSprite*) sprite currentIndex:(int*) curIndex;
--(void) swap:(int) oldIndex withNewIndex:(int) newIndex;
+-(void) updateAtlasIndex:(CCSprite*) sprite currentIndex:(NSInteger*) curIndex;
+-(void) swap:(NSInteger) oldIndex withNewIndex:(NSInteger) newIndex;
@end
@@ -263,20 +263,17 @@ - (void) sortAllChildren
//first sort all children recursively based on zOrder
CCARRAY_FOREACH(children_, child) child->sortMethod(child,selSortMethod);
- int *index=malloc(sizeof(int));
- *index=0;
+ NSInteger index=0;
//fast dispatch, give every child a new atlasIndex based on their relative zOrder (keep parent -> child relations intact) and at the same time reorder descedants and the quads to the right index
- CCARRAY_FOREACH(children_, child) updateAtlasIndexMethod_(self,selUpdateAtlasIndex,child,index);
-
- free(index);
+ CCARRAY_FOREACH(children_, child) updateAtlasIndexMethod_(self,selUpdateAtlasIndex,child,&index);
}
isReorderChildDirty_=NO;
}
}
--(void) updateAtlasIndex:(CCSprite*) sprite currentIndex:(int*) curIndex
+-(void) updateAtlasIndex:(CCSprite*) sprite currentIndex:(NSInteger*) curIndex
{
CCArray *array = [sprite children];
NSUInteger count = [array count];
@@ -287,7 +284,8 @@ -(void) updateAtlasIndex:(CCSprite*) sprite currentIndex:(int*) curIndex
oldIndex=sprite.atlasIndex;
sprite.atlasIndex=*curIndex;
sprite.mutatedIndex=0;
- if (oldIndex!=*curIndex) [self swap:oldIndex withNewIndex:*curIndex];
+ if (oldIndex!=*curIndex)
+ [self swap:oldIndex withNewIndex:*curIndex];
(*curIndex)++;
}
else
@@ -299,7 +297,8 @@ -(void) updateAtlasIndex:(CCSprite*) sprite currentIndex:(int*) curIndex
oldIndex=sprite.atlasIndex;
sprite.atlasIndex=*curIndex;
sprite.mutatedIndex=0;
- if (oldIndex!=*curIndex) [self swap:oldIndex withNewIndex:*curIndex];
+ if (oldIndex!=*curIndex)
+ [self swap:oldIndex withNewIndex:*curIndex];
(*curIndex)++;
needNewIndex=NO;
@@ -313,7 +312,8 @@ -(void) updateAtlasIndex:(CCSprite*) sprite currentIndex:(int*) curIndex
oldIndex=sprite.atlasIndex;
sprite.atlasIndex=*curIndex;
sprite.mutatedIndex=0;
- if (oldIndex!=*curIndex) [self swap:oldIndex withNewIndex:*curIndex];
+ if (oldIndex!=*curIndex)
+ [self swap:oldIndex withNewIndex:*curIndex];
(*curIndex)++;
needNewIndex=NO;
@@ -327,13 +327,14 @@ -(void) updateAtlasIndex:(CCSprite*) sprite currentIndex:(int*) curIndex
oldIndex=sprite.atlasIndex;
sprite.atlasIndex=*curIndex;
sprite.mutatedIndex=0;
- if (oldIndex!=*curIndex) [self swap:oldIndex withNewIndex:*curIndex];
+ if (oldIndex!=*curIndex)
+ [self swap:oldIndex withNewIndex:*curIndex];
(*curIndex)++;
}
}
}
-- (void) swap:(int) oldIndex withNewIndex:(int) newIndex
+- (void) swap:(NSInteger) oldIndex withNewIndex:(NSInteger) newIndex
{
id* x=descendants_->data->arr;
ccV3F_C4B_T2F_Quad* quads=textureAtlas_.quads;
Oops, something went wrong.

0 comments on commit 44c3997

Please sign in to comment.