Permalink
Browse files

Issue 955, CCParticleBatchNode

This class provides batch drawing for CCParticleSystemQuad. CCParticleSystemPoint isn't supported yet. 
The structure of CCParticleBatchNode is very similar to CCSpriteBatchNode. 

All particle tests are batched in particleTestBatched, with a few batchnode specific tests as well. I've checked with Clang and for memory leaks. The limited performance testing I've done shows that if you're not fill-rate / overdraw bound, the batchnode performs a few frames higher compared to non batched drawing. How much improvement depends on the number of particle systems used and on the device as well. Improvement is less visible on older devices, because their fill-rate is a lot lower.

Pros and Cons batch drawing
+one draw call for all particle systems, more efficient 
+z-coordinate can be used for 3d effects 
+same memory requirements for buffers as non batched systems
-each quad is 16 bytes bigger, because of z coordinate

Additions:
CCParticleBatchNode.h
CCParticleBatchNode.m
ParticleTestBatched.h
ParticleTestBatched.m

Modifications:
CCParticleSystem
CCTextureAtlas
CCParticleSystemQuad
  • Loading branch information...
1 parent f696add commit 755d91f56d6371b78abf1202f55b25301b1045bf @araker araker committed Oct 2, 2011
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>${MACOSX_DEPLOYMENT_TARGET}</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
View
@@ -0,0 +1,199 @@
+
+#import "cocos2d.h"
+
+@class CCSprite;
+@class CCParticleBatchNode;
+
+//CLASS INTERFACE
+#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
+@interface AppController : NSObject <UIApplicationDelegate>
+{
+ UIWindow *window;
+}
+@end
+
+#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
+@interface cocos2dmacAppDelegate : NSObject <NSApplicationDelegate>
+{
+ NSWindow *window_;
+ MacGLView *glView_;
+}
+
+@property (assign) IBOutlet NSWindow *window;
+@property (assign) IBOutlet MacGLView *glView;
+
+- (IBAction)toggleFullScreen:(id)sender;
+
+@end
+#endif // Mac
+
+@class Emitter;
+
+@interface ParticleDemoBatch : CCLayerColor
+{
+ CCParticleSystem *emitter_;
+ CCSprite *background;
+ CCParticleBatchNode* batchNode_;
+}
+
+@property (readwrite,retain) CCParticleSystem *emitter;
+
+-(NSString*) title;
+-(NSString*) subtitle;
+
+@end
+
+@interface DemoBatchFirework : ParticleDemoBatch
+{}
+@end
+
+@interface DemoBatchFire : ParticleDemoBatch
+{}
+@end
+
+@interface DemoBatchSun : ParticleDemoBatch
+{}
+@end
+
+@interface DemoBatchGalaxy : ParticleDemoBatch
+{}
+@end
+
+@interface DemoBatchFlower : ParticleDemoBatch
+{}
+@end
+
+@interface DemoBatchBigFlower : ParticleDemoBatch
+{}
+@end
+
+@interface DemoBatchRotFlower : ParticleDemoBatch
+{}
+@end
+
+@interface DemoBatchMeteor : ParticleDemoBatch
+{}
+@end
+
+@interface DemoBatchSpiral : ParticleDemoBatch
+{}
+@end
+
+@interface DemoBatchExplosion : ParticleDemoBatch
+{}
+@end
+
+@interface DemoBatchSmoke : ParticleDemoBatch
+{}
+@end
+
+@interface DemoBatchSnow : ParticleDemoBatch
+{}
+@end
+
+@interface DemoBatchRain : ParticleDemoBatch
+{}
+@end
+
+@interface DemoBatchModernArt : ParticleDemoBatch
+{}
+@end
+
+@interface DemoBatchRing : ParticleDemoBatch
+{}
+@end
+
+@interface ParallaxParticle : ParticleDemoBatch
+{}
+@end
+
+@interface ParticleDesigner1 : ParticleDemoBatch
+{}
+@end
+
+@interface ParticleDesigner2 : ParticleDemoBatch
+{}
+@end
+
+@interface ParticleDesigner3 : ParticleDemoBatch
+{}
+@end
+
+@interface ParticleDesigner4 : ParticleDemoBatch
+{}
+@end
+
+@interface ParticleDesigner5 : ParticleDemoBatch
+{}
+@end
+
+@interface ParticleDesigner6 : ParticleDemoBatch
+{}
+@end
+
+@interface ParticleDesigner7 : ParticleDemoBatch
+{}
+@end
+
+@interface ParticleDesigner8 : ParticleDemoBatch
+{}
+@end
+
+@interface ParticleDesigner9 : ParticleDemoBatch
+{}
+@end
+
+@interface ParticleDesigner10 : ParticleDemoBatch
+{}
+@end
+
+@interface ParticleDesigner11 : ParticleDemoBatch
+{}
+@end
+
+@interface ParticleDesigner12 : ParticleDemoBatch
+{}
+@end
+
+@interface RadiusMode1 : ParticleDemoBatch
+{}
+@end
+
+@interface RadiusMode2 : ParticleDemoBatch
+{}
+@end
+
+@interface Issue704 : ParticleDemoBatch
+{}
+@end
+
+@interface Issue872 : ParticleDemoBatch
+{}
+@end
+
+@interface Issue870 : ParticleDemoBatch
+{
+ int index;
+}
+@end
+
+@interface MultipleParticleSystems : ParticleDemoBatch
+{}
+@end
+
+@interface MultipleParticleSystemsBatched : ParticleDemoBatch
+{
+}
+@end
+
+@interface AddAndDeleteParticleSystems : ParticleDemoBatch
+{
+}
+@end
+
+@interface ReorderParticleSystems : ParticleDemoBatch
+{
+}
+@end
+
+
Oops, something went wrong.

0 comments on commit 755d91f

Please sign in to comment.