Skip to content

Commit 7a1f4d6

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into develop
Conflicts: cocos2d/CCEffect.m
2 parents 050ec5d + ff9f4aa commit 7a1f4d6

File tree

12 files changed

+340
-151
lines changed

12 files changed

+340
-151
lines changed

cocos2d-ui-tests/tests/CCRendererTest.m

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ - (void)setupMotionStreakNodeTest
330330
}
331331
}
332332

333+
static float
334+
ProgressPercent(CCTime t)
335+
{
336+
return 100.0*fmod(t, 1.0);
337+
}
338+
333339
- (void)setupProgressNodeTest
334340
{
335341
self.subTitle = @"Testing various CCProgressNode setups.";
@@ -353,7 +359,7 @@ - (void)setupProgressNodeTest
353359
[self.contentNode addChild:progress];
354360

355361
[self scheduleBlock:^(CCTimer *timer) {
356-
progress.percentage = 100.0*(0.5 + 0.5*sin(timer.invokeTime*M_PI));
362+
progress.percentage = ProgressPercent(timer.invokeTime);
357363
[timer repeatOnceWithInterval:interval];
358364
} delay:interval];
359365
}
@@ -378,7 +384,7 @@ - (void)setupProgressNodeTest
378384

379385
[self scheduleBlock:^(CCTimer *timer) {
380386
progress.midpoint = ccpAdd(ccp(0.5, 0.5), ccpMult(ccpForAngle(timer.invokeTime), 0.25));
381-
progress.percentage = 100.0*(0.5 + 0.5*sin(timer.invokeTime*M_PI));
387+
progress.percentage = ProgressPercent(timer.invokeTime);
382388

383389
[timer repeatOnceWithInterval:interval];
384390
} delay:interval];
@@ -404,7 +410,7 @@ - (void)setupProgressNodeTest
404410
[self.contentNode addChild:progress];
405411

406412
[self scheduleBlock:^(CCTimer *timer) {
407-
progress.percentage = 100.0*(0.5 + 0.5*sin(timer.invokeTime*M_PI));
413+
progress.percentage = ProgressPercent(timer.invokeTime);
408414

409415
[timer repeatOnceWithInterval:interval];
410416
} delay:interval];
@@ -430,7 +436,7 @@ - (void)setupProgressNodeTest
430436
[self.contentNode addChild:progress];
431437

432438
[self scheduleBlock:^(CCTimer *timer) {
433-
progress.percentage = 100.0*(0.5 + 0.5*sin(timer.invokeTime*M_PI));
439+
progress.percentage = ProgressPercent(timer.invokeTime);
434440

435441
[timer repeatOnceWithInterval:interval];
436442
} delay:interval];
@@ -456,7 +462,7 @@ - (void)setupProgressNodeTest
456462
[self.contentNode addChild:progress];
457463

458464
[self scheduleBlock:^(CCTimer *timer) {
459-
progress.percentage = 100.0*(0.5 + 0.5*sin(timer.invokeTime*M_PI));
465+
progress.percentage = ProgressPercent(timer.invokeTime);
460466

461467
[timer repeatOnceWithInterval:interval];
462468
} delay:interval];
@@ -482,7 +488,7 @@ - (void)setupProgressNodeTest
482488
[self.contentNode addChild:progress];
483489

484490
[self scheduleBlock:^(CCTimer *timer) {
485-
progress.percentage = 100.0*(0.5 + 0.5*sin(timer.invokeTime*M_PI));
491+
progress.percentage = ProgressPercent(timer.invokeTime);
486492

487493
[timer repeatOnceWithInterval:interval];
488494
} delay:interval];
@@ -508,7 +514,7 @@ - (void)setupProgressNodeTest
508514
[self.contentNode addChild:progress];
509515

510516
[self scheduleBlock:^(CCTimer *timer) {
511-
progress.percentage = 100.0*(0.5 + 0.5*sin(timer.invokeTime*M_PI));
517+
progress.percentage = ProgressPercent(timer.invokeTime);
512518

513519
[timer repeatOnceWithInterval:interval];
514520
} delay:interval];
@@ -534,7 +540,7 @@ - (void)setupProgressNodeTest
534540
[self.contentNode addChild:progress];
535541

536542
[self scheduleBlock:^(CCTimer *timer) {
537-
progress.percentage = 100.0*(0.5 + 0.5*sin(timer.invokeTime*M_PI));
543+
progress.percentage = ProgressPercent(timer.invokeTime);
538544

539545
[timer repeatOnceWithInterval:interval];
540546
} delay:interval];
@@ -548,6 +554,10 @@ - (void)setupDrawNodeTest
548554
CCDrawNode *draw = [CCDrawNode node];
549555

550556
[draw drawDot:ccp(100, 100) radius:50 color:[CCColor colorWithRed:0.5 green:0.0 blue:0.0 alpha:0.75]];
557+
558+
// This yellow dot should not be visible.
559+
[draw drawDot:ccp(150, 150) radius:50 color:[CCColor colorWithRed:0.5 green:0.5 blue:0.0 alpha:0.0]];
560+
551561
[draw drawSegmentFrom:ccp(100, 200) to:ccp(200, 200) radius:25 color:[CCColor colorWithRed:0.0 green:0.0 blue:0.5 alpha:0.75]];
552562

553563
CGPoint points1[] = {

cocos2d-ui-tests/tests/VertexZTest.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ - (void)setupGlobalSortTest
107107
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"Cards/cards.classic.plist"];
108108

109109
// add a card node to hold the cards
110-
_cardNode = [CCSpriteBatchNode batchNodeWithFile:@"Cards/cards.classic.png"];
110+
_cardNode = [CCNode node];
111111
_cardNode.contentSize = [CCDirector sharedDirector].viewSize;
112112

113113
[self.contentNode addChild:_cardNode];

cocos2d-ui/CCBReader/CCBAnimationManager.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ - (NSMutableArray*)findFrames:(float)time sequenceProperty:(CCBSequenceProperty*
766766

767767
CCBKeyframe* startKeyFrame = [seqProp.keyframes objectAtIndex:0];
768768
CCBKeyframe* endKeyFrame = [seqProp.keyframes objectAtIndex:0];
769-
769+
770770
NSUInteger frameCount = [seqProp.keyframes count];
771771

772772
// Find KeyFrames

cocos2d/CCDrawNode.m

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,16 @@ -(void)draw:(CCRenderer *)renderer transform:(const GLKMatrix4 *)transform
134134

135135
#pragma mark Immediate Mode
136136

137+
static inline GLKVector4
138+
Premultiply(GLKVector4 c)
139+
{
140+
return GLKVector4Make(c.r*c.a, c.g*c.a, c.b*c.a, c.a);
141+
}
142+
137143
-(void)drawDot:(CGPoint)pos radius:(CGFloat)radius color:(CCColor *)color;
138144
{
139-
GLKVector4 color4 = color.glkVector4;
145+
GLKVector4 color4 = Premultiply(color.glkVector4);
146+
140147
GLKVector2 zero2 = GLKVector2Make(0, 0);
141148

142149
CCRenderBuffer buffer = [self bufferVertexes:4 andTriangleCount:2];
@@ -159,7 +166,7 @@ -(void)drawDot:(CGPoint)pos radius:(CGFloat)radius color:(CCColor *)color;
159166

160167
-(void)drawSegmentFrom:(CGPoint)_a to:(CGPoint)_b radius:(CGFloat)radius color:(CCColor*)color;
161168
{
162-
GLKVector4 color4 = color.glkVector4;
169+
GLKVector4 color4 = Premultiply(color.glkVector4);
163170
GLKVector2 a = GLKVector2Make(_a.x, _a.y);
164171
GLKVector2 b = GLKVector2Make(_b.x, _b.y);
165172

@@ -189,8 +196,8 @@ -(void)drawSegmentFrom:(CGPoint)_a to:(CGPoint)_b radius:(CGFloat)radius color:(
189196

190197
-(void)drawPolyWithVerts:(const CGPoint *)_verts count:(NSUInteger)count fillColor:(CCColor*)fill borderWidth:(CGFloat)width borderColor:(CCColor*)line;
191198
{
192-
GLKVector4 fill4 = fill.glkVector4;
193-
GLKVector4 line4 = line.glkVector4;
199+
GLKVector4 fill4 = Premultiply(fill.glkVector4);
200+
GLKVector4 line4 = Premultiply(line.glkVector4);
194201

195202
GLKVector2 verts[count];
196203
for(int i=0; i<count; i++) verts[i] = GLKVector2Make(_verts[i].x, _verts[i].y);

cocos2d/CCEffect.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#import "CCSprite.h"
1111
#import "CCShader.h"
1212
#import "ccConfig.h"
13-
#import <ccTypes.h>
13+
#import "ccTypes.h"
1414

1515
#if CC_ENABLE_EXPERIMENTAL_EFFECTS
1616
@interface CCEffectFunction : NSObject

cocos2d/CCNode.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,27 @@ A common user pattern in building a Cocos2d game is to subclass CCNode, add it t
115115

116116
// Used to preserve sequence while sorting children with the same zOrder.
117117
NSUInteger _orderOfArrival;
118+
119+
// True when visible.
120+
BOOL _visible;
118121

122+
// True to ensure reorder.
123+
BOOL _isReorderChildDirty;
124+
125+
// DisplayColor and Color are kept separate to allow for cascading color and alpha changes through node children.
126+
// Alphas tend to be multiplied together so you can fade groups of objects that are colored differently.
127+
ccColor4F _displayColor, _color;
128+
129+
// Opacity/Color propagates into children that conform to if cascadeOpacity/cascadeColor is enabled.
130+
BOOL _cascadeColorEnabled, _cascadeOpacityEnabled;
131+
132+
@private
133+
// Physics Body.
134+
CCPhysicsBody* _physicsBody;
135+
119136
// Scheduler used to schedule timers and updates/
120137
CCScheduler *_scheduler;
121-
138+
122139
// ActionManager used to handle all the actions.
123140
CCActionManager *_actionManager;
124141

@@ -130,22 +147,6 @@ A common user pattern in building a Cocos2d game is to subclass CCNode, add it t
130147

131148
// Number of paused parent or ancestor nodes.
132149
int _pausedAncestors;
133-
134-
// True when visible.
135-
BOOL _visible;
136-
137-
// True to ensure reorder.
138-
BOOL _isReorderChildDirty;
139-
140-
// Physics Body.
141-
CCPhysicsBody* _physicsBody;
142-
143-
// DisplayColor and Color are kept separate to allow for cascading color and alpha changes through node children.
144-
// Alphas tend to be multiplied together so you can fade groups of objects that are colored differently.
145-
ccColor4F _displayColor, _color;
146-
147-
// Opacity/Color propagates into children that conform to if cascadeOpacity/cascadeColor is enabled.
148-
BOOL _cascadeColorEnabled, _cascadeOpacityEnabled;
149150
}
150151

151152

cocos2d/CCParticleSystemBase.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -502,13 +502,6 @@ -(void) update: (CCTime) dt
502502
[self stopSystem];
503503
}
504504

505-
CGPoint currentPosition = CGPointZero;
506-
if( _particlePositionType == CCParticleSystemPositionTypeFree )
507-
currentPosition = [self convertToWorldSpace:CGPointZero];
508-
509-
else if( _particlePositionType == CCParticleSystemPositionTypeRelative )
510-
currentPosition = _position;
511-
512505
if (_visible)
513506
{
514507
for(int i=0; i < _particleCount;)

cocos2d/CCProgressNode.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ -(GLKVector2)textureCoordFromAlphaPoint:(CGPoint) alpha
191191
CC_SWAP(alpha.x, alpha.y);
192192
}
193193

194+
// As of 3.1, the x alpha needs to be flipped. Not really sure why.
195+
alpha.x = 1.0 - alpha.x;
194196
return GLKVector2Make(min.x * (1.f - alpha.x) + max.x * alpha.x, min.y * (1.f - alpha.y) + max.y * alpha.y);
195197
}
196198

@@ -203,6 +205,9 @@ -(GLKVector4)vertexFromAlphaPoint:(CGPoint) alpha
203205
const CCSpriteVertexes *verts = _sprite.vertexes;
204206
GLKVector4 min = verts->br.position;
205207
GLKVector4 max = verts->tl.position;
208+
209+
// As of 3.1, the x alpha needs to be flipped. Not really sure why.
210+
alpha.x = 1.0 - alpha.x;
206211
return GLKVector4Make(min.x * (1.f - alpha.x) + max.x * alpha.x, min.y * (1.f - alpha.y) + max.y * alpha.y, 0.0f, 1.0f);
207212
}
208213

cocos2d/CCShader.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@
5757
const NSString *CCShaderUniformAlphaTestValue = @"cc_AlphaTestValue";
5858

5959

60+
// Stringify macros
61+
#define STR(s) #s
62+
#define XSTR(s) STR(s)
63+
6064
/*
61-
main texture size points/pixels
65+
main texture size points/pixels?
6266
*/
6367
static const GLchar *CCShaderHeader =
6468
"#ifndef GL_ES\n"
@@ -84,6 +88,7 @@
8488
"#ifdef GL_ES\n"
8589
"precision highp float;\n\n"
8690
"#endif\n\n"
91+
"#define CC_NODE_RENDER_SUBPIXEL " XSTR(CC_NODE_RENDER_SUBPIXEL) "\n"
8792
"attribute highp vec4 cc_Position;\n"
8893
"attribute highp vec2 cc_TexCoord1;\n"
8994
"attribute highp vec2 cc_TexCoord2;\n"
@@ -99,6 +104,10 @@
99104
static NSString *CCDefaultVShader =
100105
@"void main(){\n"
101106
@" gl_Position = cc_Position;\n"
107+
@"#if !CC_NODE_RENDER_SUBPIXEL\n"
108+
@" vec2 pixelPos = (0.5*gl_Position.xy/gl_Position.w + 0.5)*cc_ViewSizeInPixels;\n"
109+
@" gl_Position.xy = (2.0*floor(pixelPos)/cc_ViewSizeInPixels - 1.0)*gl_Position.w;\n"
110+
@"#endif\n\n"
102111
@" cc_FragColor = clamp(cc_Color, 0.0, 1.0);\n"
103112
@" cc_FragTexCoord1 = cc_TexCoord1;\n"
104113
@" cc_FragTexCoord2 = cc_TexCoord2;\n"

cocos2d/CCSprite.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,13 @@ -(void)updateDisplayedOpacity:(CGFloat)parentOpacity
435435
}
436436

437437
#if CC_ENABLE_EXPERIMENTAL_EFFECTS
438+
-(CCEffect *)effect
439+
{
440+
// work in progress, since I added mutli pass rendering for efffects, sprite are no longer working with all effects.
441+
// taking this out for now.
442+
return nil;
443+
}
444+
438445
-(void)setEffect:(CCEffect *)effect
439446
{
440447
// work in progress, since I added mutli pass rendering for efffects, sprite are no longer working with all effects.

0 commit comments

Comments
 (0)