Skip to content

Commit 0a5fce0

Browse files
committed
Merge branch 'v3.4' into develop
Conflicts: cocos2d/CCEffectDropShadow.m
2 parents 9fb24c2 + 19ce086 commit 0a5fce0

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
lines changed

Resources/Images/powered_normals.png

34.6 KB
Loading

cocos2d-ui-tests/tests/CCEffectsTest.m

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ -(void)setupSimpleLightingTest
298298

299299
[self.contentNode.scene.lights flushGroupNames];
300300

301-
NSString *normalMapImage = @"Images/ShinyTorusNormals.png";
302-
NSString *diffuseImage = @"Images/ShinyTorusColor.png";
301+
NSString *normalMapImage = @"Images/powered_normals.png";
302+
NSString *diffuseImage = @"Images/powered.png";
303303

304304
void (^setupBlock)(CGPoint position, CCLightType type, float lightDepth, NSString *title) = ^void(CGPoint position, CCLightType type, float lightDepth, NSString *title)
305305
{
@@ -327,6 +327,13 @@ -(void)setupSimpleLightingTest
327327
sprite.effect = lightingEffect;
328328
sprite.scale = 0.5f;
329329

330+
[sprite runAction:[CCActionRepeatForever actionWithAction:[CCActionSequence actions:
331+
[CCActionDelay actionWithDuration:1.0],
332+
[CCActionRotateBy actionWithDuration:4.0 angle:360.0],
333+
[CCActionDelay actionWithDuration:8.0],
334+
nil
335+
]]];
336+
330337
CCNode *root = [[CCNode alloc] init];
331338
root.positionType = CCPositionTypeNormalized;
332339
root.position = position;
@@ -348,14 +355,15 @@ -(void)setupSimpleLightingTest
348355

349356
[light runAction:[CCActionRepeatForever actionWithAction:[CCActionSequence actions:
350357
[CCActionMoveTo actionWithDuration:1.0 position:ccp(1.0f, 1.0f)],
358+
[CCActionDelay actionWithDuration:4.0],
351359
[CCActionMoveTo actionWithDuration:2.0 position:ccp(0.0f, 0.0f)],
352360
[CCActionRotateBy actionWithDuration:5.0 angle:360.0],
353361
[CCActionMoveTo actionWithDuration:1.0 position:ccp(0.5f, 0.5f)],
354362
nil
355363
]]];
356364
};
357-
setupBlock(ccp(0.25f, 0.5f), CCLightPoint, 250.0f, @"Point Light\nPosition matters, orientation does not.");
358-
setupBlock(ccp(0.75f, 0.5f), CCLightDirectional, 1.0f, @"Directional Light\nPosition does not matter, orientation does.");
365+
setupBlock(ccp(0.25f, 0.5f), CCLightPoint, 50.0f, @"Point Light\nPosition matters, orientation does not.");
366+
setupBlock(ccp(0.75f, 0.5f), CCLightDirectional, 0.5f, @"Directional Light\nPosition does not matter, orientation does.");
359367
}
360368

361369
-(void)setupLightingParameterTest

cocos2d-ui/CCBReader/CCAnimationManager.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ - (CCActionInterval*)actionFromKeyframe0:(CCBKeyframe*)kf0 andKeyframe1:(CCBKeyf
238238
return [CCActionHide action];
239239
}
240240
} else if ([name isEqualToString:@"spriteFrame"]) {
241-
return [CCActionSpriteFrame actionWithSpriteFrame:kf1.value];
241+
// TODO is this a mild bug?
242+
// What happens if an easing curve is applied to this?
243+
return (CCActionInterval *)[CCActionSpriteFrame actionWithSpriteFrame:kf1.value];
242244
} else if ([node isKindOfClass:[CCLightNode class]]) {
243245
if ([name isEqualToString:@"intensity"] ||
244246
[name isEqualToString:@"specularIntensity"] ||

cocos2d/CCActionInterval.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ - (CCActionInterval *) reverse
390390
#pragma mark - CCSpawn
391391

392392
@implementation CCActionSpawn
393+
393394
+(instancetype) actions: (CCActionFiniteTime*) action1, ...
394395
{
395396
va_list args;

cocos2d/CCEffectDropShadow.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,11 @@ + (NSArray *)buildRenderPassesWithInterface:(CCEffectDropShadow *)interface
284284
passInputs.shaderUniforms[pass.uniformTranslationTable[@"u_blurDirection"]] = [NSValue valueWithGLKVector2:dur];
285285
passInputs.shaderUniforms[pass.uniformTranslationTable[@"u_composite"]] = [NSNumber numberWithFloat:1.0f];
286286

287-
GLKVector2 offset = GLKVector2Make(weakInterface.shadowOffset.x / passInputs.previousPassTexture.contentSize.width, weakInterface.shadowOffset.y / passInputs.previousPassTexture.contentSize.height);
287+
CGPoint offset = weakInterface.shadowOffset;
288+
offset.x /= passInputs.previousPassTexture.contentSize.width;
289+
offset.y /= passInputs.previousPassTexture.contentSize.height;
288290

289-
passInputs.shaderUniforms[pass.uniformTranslationTable[@"u_shadowOffset"]] = [NSValue valueWithGLKVector2:offset];
291+
passInputs.shaderUniforms[pass.uniformTranslationTable[@"u_shadowOffset"]] = [NSValue valueWithCGPoint:offset];
290292
passInputs.shaderUniforms[pass.uniformTranslationTable[@"u_shadowColor"]] = [NSValue valueWithGLKVector4:weakInterface.shadowColor.glkVector4];
291293

292294
} copy]];

cocos2d/CCEffectLighting.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,9 @@ +(NSArray *)buildRenderPassesWithInterface:(CCEffectLighting *)interface
243243
GLKMatrix4 nodeLocalToWorld = passInputs.sprite.nodeToWorldMatrix;
244244
GLKMatrix4 ndcToWorld = GLKMatrix4Multiply(nodeLocalToWorld, passInputs.ndcToNodeLocal);
245245

246-
247-
GLKMatrix2 tangentMatrix = CCEffectUtilsMatrix2InvertAndTranspose(GLKMatrix4GetMatrix2(nodeLocalToWorld), nil);
248-
GLKVector2 reflectTangent = GLKVector2Normalize(CCEffectUtilsMatrix2MultiplyVector2(tangentMatrix, GLKVector2Make(1.0f, 0.0f)));
249-
GLKVector2 reflectBinormal = GLKVector2Make(-reflectTangent.y, reflectTangent.x);
246+
// Tangent and binormal vectors are the x/y basis vectors from the nodeLocalToWorldMatrix
247+
GLKVector2 reflectTangent = GLKVector2Normalize(GLKVector2Make(nodeLocalToWorld.m[0], nodeLocalToWorld.m[1]));
248+
GLKVector2 reflectBinormal = GLKVector2Normalize(GLKVector2Make(nodeLocalToWorld.m[4], nodeLocalToWorld.m[5]));
250249

251250
passInputs.shaderUniforms[pass.uniformTranslationTable[@"u_worldSpaceTangent"]] = [NSValue valueWithGLKVector2:reflectTangent];
252251
passInputs.shaderUniforms[pass.uniformTranslationTable[@"u_worldSpaceBinormal"]] = [NSValue valueWithGLKVector2:reflectBinormal];

0 commit comments

Comments
 (0)