diff --git a/CHANGELOG b/CHANGELOG index 733222002d..243d244a1c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,9 +1,29 @@ -cocos2d-x-3.6beta0 Apr.14 2015 - [NEW] 3D: added texturecub supported +cocos2d-x-3.6alpha0 Apr.8 2015 + [NEW] 3D: added texturecub support + [NEW] 3D: added skybox support + [NEW] 3D: added node animation support + [NEW] 3D: added terrian support + [NEW] 3rd: updated libcurl to v7.4 on all supported platforms except WP8/WP8.1 universal + [NEW] 3rd: updated chipmunk to v6.2.2 + [NEW] 3rd: updated openssl to v1.0.11 + [NEW] 3rd: updated freetype to v2.5.5 + [NEW] 3rd: updated png to v1.6.16 on all supported platforms except WP8/WP8.1 universal because it is not needed on these two platforms [NEW] Animate3D: added `Animate3D::setHighQuality()` to set animation quality + [NEW] Label: added disableEffect() + [NEW] Lua-binding: used luajit arm64 version on iOS 64-bit devices + [NEW] Sprite3D: getAABBRecursively return own aabb combining childeren's + [NEW] Vec3: added `Vec3::add(float, float, float)` and `Vec3::setZero()` [FIX] Audio: memory leak + [FIX] Audio: crashed on iOS 5.1.1 + [FIX] C++: lag issue if `Director::setContentScaleFactor` is called frequently + [FIX] C++: CDT builder is enabled by default in cpp template on Android + [FIX] Label: shadow color is incorrect + [FIX] MenuItem: crash if `MenuItem::onExit` is called multiple times + [FIX] Particle3D: particles' rotation affect particle system's rotation [FIX] Sprite3D: memory leak + [FIX] Vec3: use inline function to improve performance + [FIX] WebView: loadHTMLString() can not work if it is invoked in the same frame of creating a webview on iOS cocos2d-x-3.5 Mar.23 2015 [NEW] EditBox: support Color4B diff --git a/CMakeLists.txt b/CMakeLists.txt index 986ac107d3..135d3d23ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,16 +29,16 @@ cmake_minimum_required(VERSION 2.8) # also from cmake's Modules dir, to not clash with per-project files. cmake_policy(SET CMP0017 NEW) -# Use new behaviour with cmake >= 3.0: +# Use new behaviour with cmake >= 3.1: # Only interpret if() arguments as variables or keywords when unquoted. -if(CMAKE_VERSION VERSION_GREATER 3) +if(CMAKE_VERSION VERSION_GREATER 3.1) cmake_policy(SET CMP0054 NEW) endif() project (Cocos2d-X) # The version number -set(COCOS2D_X_VERSION 3.5) +set(COCOS2D_X_VERSION 3.6alpha0) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/") include(CocosBuildHelpers) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index fce0a94bc0..163b5b96d1 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1154,6 +1154,7 @@ 1AC0269D1914068200FA920D /* ConvertUTF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC026991914068200FA920D /* ConvertUTF.h */; }; 29031E0719BFE8D400EFA1DF /* libchipmunk.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 29031E0619BFE8D400EFA1DF /* libchipmunk.a */; }; 29031E0919BFE8DE00EFA1DF /* libchipmunk.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 29031E0819BFE8DE00EFA1DF /* libchipmunk.a */; }; + 2905E9CD1ACD3D8C00092DD2 /* libz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2905E9CC1ACD3D8C00092DD2 /* libz.a */; }; 292DB13D19B4574100A80320 /* UIEditBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 292DB12F19B4574100A80320 /* UIEditBox.cpp */; }; 292DB13E19B4574100A80320 /* UIEditBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 292DB12F19B4574100A80320 /* UIEditBox.cpp */; }; 292DB13F19B4574100A80320 /* UIEditBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 292DB13019B4574100A80320 /* UIEditBox.h */; }; @@ -1799,7 +1800,6 @@ B21770421977ECF8009EE11B /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B21770411977ECF8009EE11B /* ApplicationServices.framework */; }; B21770451977ED14009EE11B /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B21770431977ED07009EE11B /* Cocoa.framework */; }; B21770471977ED34009EE11B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B21770461977ED34009EE11B /* QuartzCore.framework */; }; - B21770491977ED4C009EE11B /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = B21770481977ED4C009EE11B /* libz.dylib */; }; B217704E1977ED9F009EE11B /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = B217704C1977ED8B009EE11B /* libsqlite3.dylib */; }; B230ED7119B417AE00364AA8 /* CCTrianglesCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B230ED6F19B417AE00364AA8 /* CCTrianglesCommand.cpp */; }; B230ED7219B417AE00364AA8 /* CCTrianglesCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B230ED6F19B417AE00364AA8 /* CCTrianglesCommand.cpp */; }; @@ -2987,6 +2987,7 @@ 1AD71EEF180E27CF00808F54 /* CCPhysicsSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsSprite.h; sourceTree = ""; }; 29031E0619BFE8D400EFA1DF /* libchipmunk.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libchipmunk.a; path = prebuilt/mac/libchipmunk.a; sourceTree = ""; }; 29031E0819BFE8DE00EFA1DF /* libchipmunk.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libchipmunk.a; path = prebuilt/ios/libchipmunk.a; sourceTree = ""; }; + 2905E9CC1ACD3D8C00092DD2 /* libz.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libz.a; path = ../external/zlib/prebuilt/mac/libz.a; sourceTree = ""; }; 2905F9E918CF08D000240AA3 /* CocosGUI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocosGUI.cpp; sourceTree = ""; }; 2905F9EA18CF08D000240AA3 /* CocosGUI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosGUI.h; sourceTree = ""; }; 2905F9EB18CF08D000240AA3 /* GUIDefine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIDefine.h; sourceTree = ""; }; @@ -4028,10 +4029,10 @@ files = ( 29031E0719BFE8D400EFA1DF /* libchipmunk.a in Frameworks */, 15AE1C1A19AAE3C800C27E9E /* libwebsockets.a in Frameworks */, + 2905E9CD1ACD3D8C00092DD2 /* libz.a in Frameworks */, 292F1A6B1A5250F700E479F8 /* libssl.a in Frameworks */, 292F1A631A52447100E479F8 /* libcrypto.a in Frameworks */, B217704E1977ED9F009EE11B /* libsqlite3.dylib in Frameworks */, - B21770491977ED4C009EE11B /* libz.dylib in Frameworks */, B21770471977ED34009EE11B /* QuartzCore.framework in Frameworks */, B21770451977ED14009EE11B /* Cocoa.framework in Frameworks */, B21770421977ECF8009EE11B /* ApplicationServices.framework in Frameworks */, @@ -4129,6 +4130,7 @@ 1551A341158F2AB200E66CFE /* Frameworks */ = { isa = PBXGroup; children = ( + 2905E9CC1ACD3D8C00092DD2 /* libz.a */, 292F1A661A524F2700E479F8 /* libssl.dylib */, B217704C1977ED8B009EE11B /* libsqlite3.dylib */, B217704A1977ED55009EE11B /* libcurl.dylib */, @@ -9353,10 +9355,11 @@ "\"$(SRCROOT)/../external/websockets/prebuilt/mac\"", "\"$(SRCROOT)/../external/chipmunk/prebuilt/mac\"", "\"$(SRCROOT)/../external/curl/prebuilt/mac\"", + "\"$(SRCROOT)/../external/zlib/prebuilt/mac\"", ); MACH_O_TYPE = staticlib; OTHER_LDFLAGS = ""; - USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/png/include/mac $(SRCROOT)/../external/tiff/include/mac $(SRCROOT)/../external/webp/include/mac $(SRCROOT)/../external/jpeg/include/mac $(SRCROOT)/../external/freetype2/include/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external/websockets/include/mac $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../external/curl/include/mac"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/png/include/mac $(SRCROOT)/../external/tiff/include/mac $(SRCROOT)/../external/webp/include/mac $(SRCROOT)/../external/jpeg/include/mac $(SRCROOT)/../external/freetype2/include/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external/websockets/include/mac $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../external/curl/include/mac $(SRCROOT)/../external/freetype2/include/mac/freetype2"; }; name = Debug; }; @@ -9389,10 +9392,11 @@ "\"$(SRCROOT)/../external/websockets/prebuilt/mac\"", "\"$(SRCROOT)/../external/chipmunk/prebuilt/mac\"", "\"$(SRCROOT)/../external/curl/prebuilt/mac\"", + "\"$(SRCROOT)/../external/zlib/prebuilt/mac\"", ); MACH_O_TYPE = staticlib; OTHER_LDFLAGS = ""; - USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/png/include/mac $(SRCROOT)/../external/tiff/include/mac $(SRCROOT)/../external/webp/include/mac $(SRCROOT)/../external/jpeg/include/mac $(SRCROOT)/../external/freetype2/include/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external/websockets/include/mac $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../external/curl/include/mac"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/png/include/mac $(SRCROOT)/../external/tiff/include/mac $(SRCROOT)/../external/webp/include/mac $(SRCROOT)/../external/jpeg/include/mac $(SRCROOT)/../external/freetype2/include/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external/websockets/include/mac $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../external/curl/include/mac $(SRCROOT)/../external/freetype2/include/mac/freetype2"; }; name = Release; }; @@ -9422,7 +9426,7 @@ ); SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/freetype2/include/ios $(SRCROOT)/../external/curl/include/ios $(SRCROOT)/../external/webp/include/ios $(SRCROOT)/../external/tiff/include/ios $(SRCROOT)/../external/jpeg/include/ios $(SRCROOT)/../external/png/include/ios $(SRCROOT)/../external/websockets/include/ios $(SRCROOT)/../external/chipmunk/include/chipmunk"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/freetype2/include/ios $(SRCROOT)/../external/curl/include/ios $(SRCROOT)/../external/webp/include/ios $(SRCROOT)/../external/tiff/include/ios $(SRCROOT)/../external/jpeg/include/ios $(SRCROOT)/../external/png/include/ios $(SRCROOT)/../external/websockets/include/ios $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../external/freetype2/include/ios/freetype2"; VALID_ARCHS = "arm64 armv7"; }; name = Debug; @@ -9454,7 +9458,7 @@ ); SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/freetype2/include/ios $(SRCROOT)/../external/curl/include/ios $(SRCROOT)/../external/webp/include/ios $(SRCROOT)/../external/tiff/include/ios $(SRCROOT)/../external/jpeg/include/ios $(SRCROOT)/../external/png/include/ios $(SRCROOT)/../external/websockets/include/ios $(SRCROOT)/../external/chipmunk/include/chipmunk"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/freetype2/include/ios $(SRCROOT)/../external/curl/include/ios $(SRCROOT)/../external/webp/include/ios $(SRCROOT)/../external/tiff/include/ios $(SRCROOT)/../external/jpeg/include/ios $(SRCROOT)/../external/png/include/ios $(SRCROOT)/../external/websockets/include/ios $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../external/freetype2/include/ios/freetype2"; VALID_ARCHS = "arm64 armv7"; }; name = Release; diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj b/build/cocos2d_tests.xcodeproj/project.pbxproj index bae53e5f60..7f122a6290 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj @@ -38,6 +38,8 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 1502702D1AD3BDBC0089CD03 /* TerrainTest in Resources */ = {isa = PBXBuildFile; fileRef = B603F1B31AC8FBFB00A9579C /* TerrainTest */; }; + 1502702E1AD3BDC90089CD03 /* TerrainTest in Resources */ = {isa = PBXBuildFile; fileRef = B603F1B31AC8FBFB00A9579C /* TerrainTest */; }; 150F918819DA409E00B89F57 /* lua_test_bindings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 150F918619DA409E00B89F57 /* lua_test_bindings.cpp */; }; 150F918919DA409F00B89F57 /* lua_test_bindings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 150F918619DA409E00B89F57 /* lua_test_bindings.cpp */; }; 15427B79198B879900DC375D /* libluacocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15EFA665198B33EE000C57D3 /* libluacocos2d iOS.a */; }; @@ -4376,6 +4378,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 1502702E1AD3BDC90089CD03 /* TerrainTest in Resources */, 157B08EC1A90864100B7BEA4 /* Particle3D in Resources */, 15B13E5219F0FD4D008A1ADC /* Manifests in Resources */, 156EAE071977D0BD00F53709 /* ActionTimeline in Resources */, @@ -4421,6 +4424,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 1502702D1AD3BDBC0089CD03 /* TerrainTest in Resources */, 157B08ED1A90865600B7BEA4 /* Particle3D in Resources */, 15B3709A19EE5EED00ABE682 /* Manifests in Resources */, 15AECE0F195C1FDD00907DB0 /* cocosvideo.mp4 in Resources */, @@ -5557,6 +5561,12 @@ "$(inherited)", "$(SRCROOT)/../external/curl/prebuilt/ios", ); + "OTHER_LDFLAGS[sdk=iphonesimulator*][arch=x86_64]" = ( + "-pagezero_size", + 10000, + "-image_base", + 100000000, + ); SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto"; @@ -5578,6 +5588,12 @@ "$(inherited)", "$(SRCROOT)/../external/curl/prebuilt/ios", ); + "OTHER_LDFLAGS[sdk=iphonesimulator*][arch=x86_64]" = ( + "-pagezero_size", + 10000, + "-image_base", + 100000000, + ); SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto"; @@ -5639,6 +5655,12 @@ "$(SRCROOT)/../external/curl/prebuilt/ios", "/Users/cocos2d/MyWork/cocos2d-x-develop/external/curl/prebuilt/ios", ); + "OTHER_LDFLAGS[sdk=iphonesimulator*][arch=x86_64]" = ( + "-pagezero_size", + 10000, + "-image_base", + 100000000, + ); SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto"; @@ -5660,6 +5682,12 @@ "$(SRCROOT)/../external/curl/prebuilt/ios", "/Users/cocos2d/MyWork/cocos2d-x-develop/external/curl/prebuilt/ios", ); + "OTHER_LDFLAGS[sdk=iphonesimulator*][arch=x86_64]" = ( + "-pagezero_size", + 10000, + "-image_base", + 100000000, + ); SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto"; diff --git a/cmake/Modules/CocosUsePrebuiltLibs.cmake b/cmake/Modules/CocosUsePrebuiltLibs.cmake index 8be727e40f..f4c1d426df 100644 --- a/cmake/Modules/CocosUsePrebuiltLibs.cmake +++ b/cmake/Modules/CocosUsePrebuiltLibs.cmake @@ -58,7 +58,7 @@ set(_OpenalSoft_inc_paths AL) set(_OpenalSoft_libs OpenAL32) set(_zlib_inc zlib.h) -set(_zlib_libs libzlib) +set(_zlib_libs z libzlib libz) set(_fmod_prefix FMODEX) set(_fmod_inc fmod.h) @@ -77,7 +77,7 @@ set(all_prebuilt_libs if(MACOSX) - list(APPEND all_prebuilt_libs glfw3) + list(APPEND all_prebuilt_libs glfw3 zlib) endif() # We use MSVC instead of WINDOWS because it can be mingw that can't use our prebuilt libs diff --git a/cocos/2d/CCActionCamera.cpp b/cocos/2d/CCActionCamera.cpp index 33f2a720d5..7d0ad0547e 100644 --- a/cocos/2d/CCActionCamera.cpp +++ b/cocos/2d/CCActionCamera.cpp @@ -60,9 +60,9 @@ ActionCamera * ActionCamera::reverse() const void ActionCamera::restore() { - _center = Vec3(0, 0, 0); - _eye = Vec3(0, 0, FLT_EPSILON); - _up = Vec3(0, 1, 0); + _center.setZero(); + _eye.set(0.0f, 0.0f, FLT_EPSILON); + _up.set(0.0f, 1.0f, 0.0f); } void ActionCamera::setEye(const Vec3& eye) @@ -73,7 +73,7 @@ void ActionCamera::setEye(const Vec3& eye) void ActionCamera::setEye(float x, float y, float z) { - _eye = Vec3(x, y, z); + _eye.set(x, y, z); updateTransform(); } diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index e72f5c9e21..2d04abb00f 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -83,7 +83,8 @@ static inline Vec2 v2fforangle(float _a_) static inline Vec2 v2fnormalize(const Vec2 &p) { - Vec2 r = Vec2(p.x, p.y).getNormalized(); + Vec2 r(p.x, p.y); + r.normalize(); return v2f(r.x, r.y); } diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 27acb319fd..0f7612d3d9 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -752,28 +752,28 @@ void Label::enableOutline(const Color4B& outlineColor,int outlineSize /* = -1 */ { CCASSERT(_currentLabelType == LabelType::STRING_TEXTURE || _currentLabelType == LabelType::TTF, "Only supported system font and TTF!"); - _effectColor = outlineColor; - _effectColorF.r = _effectColor.r / 255.0f; - _effectColorF.g = _effectColor.g / 255.0f; - _effectColorF.b = _effectColor.b / 255.0f; - _effectColorF.a = _effectColor.a / 255.0f; - - if (outlineSize > 0) + if (outlineSize > 0 || _currLabelEffect == LabelEffect::OUTLINE) { - _outlineSize = outlineSize; if (_currentLabelType == LabelType::TTF) { - if (_fontConfig.outlineSize != outlineSize) - { - auto config = _fontConfig; - config.outlineSize = outlineSize; - setTTFConfig(config); - updateShaderProgram(); + _effectColorF.r = outlineColor.r / 255.0f; + _effectColorF.g = outlineColor.g / 255.0f; + _effectColorF.b = outlineColor.b / 255.0f; + _effectColorF.a = outlineColor.a / 255.0f; + + if (outlineSize > 0 && _fontConfig.outlineSize != outlineSize) + { + _fontConfig.outlineSize = outlineSize; + setTTFConfig(_fontConfig); } } - - _currLabelEffect = LabelEffect::OUTLINE; - _contentDirty = true; + else if (_effectColor != outlineColor || _outlineSize != outlineSize) + { + _effectColor = outlineColor; + _outlineSize = outlineSize; + _currLabelEffect = LabelEffect::OUTLINE; + _contentDirty = true; + } } } @@ -782,11 +782,6 @@ void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const _shadowEnabled = true; _shadowDirty = true; - _shadowColor.r = shadowColor.r; - _shadowColor.g = shadowColor.g; - _shadowColor.b = shadowColor.b; - _shadowOpacity = shadowColor.a / 255.0f; - auto contentScaleFactor = CC_CONTENT_SCALE_FACTOR(); _shadowOffset.width = offset.width * contentScaleFactor; _shadowOffset.height = offset.height * contentScaleFactor; @@ -795,27 +790,75 @@ void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const if (_textSprite && _shadowNode) { - _shadowNode->setColor(_shadowColor); - _shadowNode->setOpacity(_shadowOpacity * _displayedOpacity); - _shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height); + if (shadowColor != _shadowColor4F) + { + Node::removeChild(_shadowNode, true); + _shadowNode = nullptr; + createShadowSpriteForSystemFont(); + } + else + { + _shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height); + } } + + _shadowColor3B.r = shadowColor.r; + _shadowColor3B.g = shadowColor.g; + _shadowColor3B.b = shadowColor.b; + _shadowOpacity = shadowColor.a; + + _shadowColor4F.r = shadowColor.r / 255.0f; + _shadowColor4F.g = shadowColor.g / 255.0f; + _shadowColor4F.b = shadowColor.b / 255.0f; + _shadowColor4F.a = shadowColor.a / 255.0f; } void Label::disableEffect() { - if (_currLabelEffect == LabelEffect::OUTLINE) + disableEffect(LabelEffect::GLOW); + disableEffect(LabelEffect::OUTLINE); + disableEffect(LabelEffect::SHADOW); +} + +void Label::disableEffect(LabelEffect effect) +{ + switch (effect) { - _fontConfig.outlineSize = 0; - setTTFConfig(_fontConfig); - } - _currLabelEffect = LabelEffect::NORMAL; - updateShaderProgram(); - _contentDirty = true; - _shadowEnabled = false; - if (_shadowNode) - { - Node::removeChild(_shadowNode,true); - _shadowNode = nullptr; + case cocos2d::LabelEffect::NORMAL: + break; + case cocos2d::LabelEffect::OUTLINE: + if (_currLabelEffect == LabelEffect::OUTLINE) + { + if (_currentLabelType == LabelType::TTF) + { + _fontConfig.outlineSize = 0; + setTTFConfig(_fontConfig); + } + + _currLabelEffect = LabelEffect::NORMAL; + _contentDirty = true; + } + break; + case cocos2d::LabelEffect::SHADOW: + if (_shadowEnabled) + { + _shadowEnabled = false; + if (_shadowNode) + { + Node::removeChild(_shadowNode, true); + _shadowNode = nullptr; + } + } + break; + case cocos2d::LabelEffect::GLOW: + if (_currLabelEffect == LabelEffect::GLOW) + { + _currLabelEffect = LabelEffect::NORMAL; + updateShaderProgram(); + } + break; + default: + break; } } @@ -827,8 +870,6 @@ void Label::setFontScale(float fontScale) void Label::onDraw(const Mat4& transform, bool transformUpdated) { - CC_PROFILER_START("Label - draw"); - // Optimization: Fast Dispatch if( _batchNodes.size() == 1 && _textureAtlas->getTotalQuads() == 0 ) { @@ -839,21 +880,57 @@ void Label::onDraw(const Mat4& transform, bool transformUpdated) glprogram->use(); GL::blendFunc( _blendFunc.src, _blendFunc.dst ); + if (_shadowEnabled) + { + if (_currentLabelType == LabelType::TTF) + { + glprogram->setUniformLocationWith4f(_uniformTextColor, + _shadowColor4F.r, _shadowColor4F.g, _shadowColor4F.b, _shadowColor4F.a); + glprogram->setUniformLocationWith4f(_uniformEffectColor, + _shadowColor4F.r, _shadowColor4F.g, _shadowColor4F.b, _shadowColor4F.a); + + getGLProgram()->setUniformsForBuiltins(_shadowTransform); + for (const auto &child : _children) + { + child->updateTransform(); + } + for (const auto& batchNode : _batchNodes) + { + batchNode->getTextureAtlas()->drawQuads(); + } + } + else + { + Color3B oldColor = _realColor; + GLubyte oldOPacity = _displayedOpacity; + _displayedOpacity = _shadowOpacity; + setColor(_shadowColor3B); + + getGLProgram()->setUniformsForBuiltins(_shadowTransform); + for (const auto &child : _children) + { + child->updateTransform(); + } + for (const auto& batchNode : _batchNodes) + { + batchNode->getTextureAtlas()->drawQuads(); + } + + _displayedOpacity = oldOPacity; + setColor(oldColor); + } + } + if (_currentLabelType == LabelType::TTF) { glprogram->setUniformLocationWith4f(_uniformTextColor, _textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a); - } - if (_currLabelEffect == LabelEffect::OUTLINE || _currLabelEffect == LabelEffect::GLOW) - { - glprogram->setUniformLocationWith4f(_uniformEffectColor, - _effectColorF.r,_effectColorF.g,_effectColorF.b,_effectColorF.a); - } - - if(_shadowEnabled && _shadowBlurRadius <= 0) - { - drawShadowWithoutBlur(); + if (_currLabelEffect == LabelEffect::OUTLINE || _currLabelEffect == LabelEffect::GLOW) + { + glprogram->setUniformLocationWith4f(_uniformEffectColor, + _effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a); + } } glprogram->setUniformsForBuiltins(transform); @@ -868,29 +945,6 @@ void Label::onDraw(const Mat4& transform, bool transformUpdated) { batchNode->getTextureAtlas()->drawQuads(); } - - CC_PROFILER_STOP("Label - draw"); -} - -void Label::drawShadowWithoutBlur() -{ - Color3B oldColor = _realColor; - GLubyte oldOPacity = _displayedOpacity; - _displayedOpacity = _shadowOpacity * _displayedOpacity; - setColor(_shadowColor); - - getGLProgram()->setUniformsForBuiltins(_shadowTransform); - for(const auto &child: _children) - { - child->updateTransform(); - } - for (const auto& batchNode:_batchNodes) - { - batchNode->getTextureAtlas()->drawQuads(); - } - - _displayedOpacity = oldOPacity; - setColor(oldColor); } void Label::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) @@ -910,26 +964,53 @@ void Label::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) } } -void Label::setCameraMask(unsigned short mask, bool applyChildren) -{ - SpriteBatchNode::setCameraMask(mask, applyChildren); - - if (_textSprite) - { - _textSprite->setCameraMask(mask, applyChildren); - } - if (_shadowNode) - { - _shadowNode->setCameraMask(mask, applyChildren); - } -} - -void Label::createSpriteWithFontDefinition() +void Label::createSpriteForSystemFont() { _currentLabelType = LabelType::STRING_TEXTURE; + if (!_compatibleMode) + { + _fontDefinition._fontName = _systemFont; + _fontDefinition._fontSize = _systemFontSize; + + _fontDefinition._alignment = _hAlignment; + _fontDefinition._vertAlignment = _vAlignment; + + _fontDefinition._dimensions.width = _labelWidth; + _fontDefinition._dimensions.height = _labelHeight; + + _fontDefinition._fontFillColor.r = _textColor.r; + _fontDefinition._fontFillColor.g = _textColor.g; + _fontDefinition._fontFillColor.b = _textColor.b; + _fontDefinition._fontAlpha = _textColor.a; + + _fontDefinition._shadow._shadowEnabled = false; + + if (_currLabelEffect == LabelEffect::OUTLINE && _outlineSize > 0) + { + _fontDefinition._stroke._strokeEnabled = true; + _fontDefinition._stroke._strokeSize = _outlineSize; + _fontDefinition._stroke._strokeColor.r = _effectColor.r; + _fontDefinition._stroke._strokeColor.g = _effectColor.g; + _fontDefinition._stroke._strokeColor.b = _effectColor.b; + _fontDefinition._stroke._strokeAlpha = _effectColor.a; + } + else + { + _fontDefinition._stroke._strokeEnabled = false; + } + +#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) + if (_fontDefinition._stroke._strokeEnabled) + { + CCLOGERROR("Currently only supported on iOS and Android!"); + } + _fontDefinition._stroke._strokeEnabled = false; +#endif + } + auto texture = new (std::nothrow) Texture2D; - texture->initWithString(_originalUTF8String.c_str(),_fontDefinition); + texture->initWithString(_originalUTF8String.c_str(), _fontDefinition); _textSprite = Sprite::createWithTexture(texture); //set camera mask using label's camera mask, because _textSprite may be null when setting camera mask to label @@ -942,12 +1023,65 @@ void Label::createSpriteWithFontDefinition() _textSprite->setBlendFunc(_blendFunc); } - Node::addChild(_textSprite,0,Node::INVALID_TAG); + Node::addChild(_textSprite, 0, Node::INVALID_TAG); _textSprite->updateDisplayedColor(_displayedColor); _textSprite->updateDisplayedOpacity(_displayedOpacity); } +void Label::createShadowSpriteForSystemFont() +{ + if (!_fontDefinition._stroke._strokeEnabled && _fontDefinition._fontFillColor == _shadowColor4F + && (_fontDefinition._fontAlpha == _shadowColor4F.a * 255)) + { + _shadowNode = Sprite::createWithTexture(_textSprite->getTexture()); + } + else + { + auto shadowFontDefinition = _fontDefinition; + shadowFontDefinition._fontFillColor.r = _shadowColor4F.r * 255; + shadowFontDefinition._fontFillColor.g = _shadowColor4F.g * 255; + shadowFontDefinition._fontFillColor.b = _shadowColor4F.b * 255; + shadowFontDefinition._fontAlpha = _shadowColor4F.a * 255; + + shadowFontDefinition._stroke._strokeColor = shadowFontDefinition._fontFillColor; + shadowFontDefinition._stroke._strokeAlpha = shadowFontDefinition._fontAlpha; + + auto texture = new (std::nothrow) Texture2D; + texture->initWithString(_originalUTF8String.c_str(), shadowFontDefinition); + _shadowNode = Sprite::createWithTexture(texture); + texture->release(); + } + + if (_shadowNode) + { + if (_blendFuncDirty) + { + _shadowNode->setBlendFunc(_blendFunc); + } + _shadowNode->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); + _shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height); + Node::addChild(_shadowNode, 0, Node::INVALID_TAG); + + _shadowNode->updateDisplayedColor(_displayedColor); + _shadowNode->updateDisplayedOpacity(_displayedOpacity); + } +} + +void Label::setCameraMask(unsigned short mask, bool applyChildren) +{ + SpriteBatchNode::setCameraMask(mask, applyChildren); + + if (_textSprite) + { + _textSprite->setCameraMask(mask, applyChildren); + } + if (_shadowNode) + { + _shadowNode->setCameraMask(mask, applyChildren); + } +} + void Label::setFontDefinition(const FontDefinition& textDefinition) { _fontDefinition = textDefinition; @@ -968,140 +1102,62 @@ void Label::setFontDefinition(const FontDefinition& textDefinition) void Label::updateContent() { - std::u16string utf16String; - if (StringUtils::UTF8ToUTF16(_originalUTF8String, utf16String)) + if (_systemFontDirty) { - _currentUTF16String = utf16String; - } + if (_fontAtlas) + { + _batchNodes.clear(); + _batchNodes.push_back(this); - computeStringNumLines(); - if (_fontAtlas) - { - computeHorizontalKernings(_currentUTF16String); + FontAtlasCache::releaseFontAtlas(_fontAtlas); + _fontAtlas = nullptr; + } + + _systemFontDirty = false; } if (_textSprite) { - Node::removeChild(_textSprite,true); + Node::removeChild(_textSprite, true); _textSprite = nullptr; if (_shadowNode) { - Node::removeChild(_shadowNode,true); + Node::removeChild(_shadowNode, true); _shadowNode = nullptr; } } if (_fontAtlas) { + std::u16string utf16String; + if (StringUtils::UTF8ToUTF16(_originalUTF8String, utf16String)) + { + _currentUTF16String = utf16String; + } + + computeStringNumLines(); + computeHorizontalKernings(_currentUTF16String); alignText(); } else { - if (!_compatibleMode) + createSpriteForSystemFont(); + if (_shadowEnabled) { - _fontDefinition._fontName = _systemFont; - _fontDefinition._fontSize = _systemFontSize; - - _fontDefinition._alignment = _hAlignment; - _fontDefinition._vertAlignment = _vAlignment; - - _fontDefinition._dimensions.width = _labelWidth; - _fontDefinition._dimensions.height = _labelHeight; - - _fontDefinition._fontFillColor.r = _textColor.r; - _fontDefinition._fontFillColor.g = _textColor.g; - _fontDefinition._fontFillColor.b = _textColor.b; - _fontDefinition._fontAlpha = _textColor.a; - - _fontDefinition._shadow._shadowEnabled = false; - - if (_currLabelEffect == LabelEffect::OUTLINE && _outlineSize > 0) - { - _fontDefinition._stroke._strokeEnabled = true; - _fontDefinition._stroke._strokeSize = _outlineSize; - _fontDefinition._stroke._strokeColor.r = _effectColor.r; - _fontDefinition._stroke._strokeColor.g = _effectColor.g; - _fontDefinition._stroke._strokeColor.b = _effectColor.b; - _fontDefinition._stroke._strokeAlpha = _effectColor.a; - } - else - { - _fontDefinition._stroke._strokeEnabled = false; - } - -#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) - if (_fontDefinition._stroke._strokeEnabled) - { - CCLOGERROR("Currently only supported on iOS and Android!"); - } - _fontDefinition._stroke._strokeEnabled = false; -#endif + createShadowSpriteForSystemFont(); } - - createSpriteWithFontDefinition(); } _contentDirty = false; } -void Label::updateFont() -{ - if (_fontAtlas) - { - _batchNodes.clear(); - _batchNodes.push_back(this); - - FontAtlasCache::releaseFontAtlas(_fontAtlas); - _fontAtlas = nullptr; - } - - _contentDirty = true; - _systemFontDirty = false; -} - -void Label::drawTextSprite(Renderer *renderer, uint32_t parentFlags) -{ - if (_fontDefinition._fontFillColor.r != _textColor.r || _fontDefinition._fontFillColor.g != _textColor.g - || _fontDefinition._fontFillColor.b != _textColor.b) - { - updateContent(); - } - - if (_shadowEnabled && _shadowNode == nullptr) - { - _shadowNode = Sprite::createWithTexture(_textSprite->getTexture()); - if (_shadowNode) - { - if (_blendFuncDirty) - { - _shadowNode->setBlendFunc(_blendFunc); - } - //set camera mask using label's mask. Because _shadowNode may be null when setting the label's camera mask - _shadowNode->setCameraMask(getCameraMask()); - _shadowNode->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); - _shadowNode->setColor(_shadowColor); - _shadowNode->setOpacity(_shadowOpacity * _displayedOpacity); - _shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height); - Node::addChild(_shadowNode,0,Node::INVALID_TAG); - } - } - if (_shadowNode) - { - _shadowNode->visit(renderer, _modelViewTransform, parentFlags); - } - _textSprite->visit(renderer, _modelViewTransform, parentFlags); -} - void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { if (! _visible || _originalUTF8String.empty()) { return; } - if (_systemFontDirty) - { - updateFont(); - } - if (_contentDirty) + + if (_systemFontDirty || _contentDirty) { updateContent(); } @@ -1140,7 +1196,11 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t pare if (_textSprite) { - drawTextSprite(renderer, flags); + if (_shadowNode) + { + _shadowNode->visit(renderer, _modelViewTransform, parentFlags); + } + _textSprite->visit(renderer, _modelViewTransform, parentFlags); } else { @@ -1343,6 +1403,15 @@ void Label::setTextColor(const Color4B &color) _textColorF.g = _textColor.g / 255.0f; _textColorF.b = _textColor.b / 255.0f; _textColorF.a = _textColor.a / 255.0f; + + if (_currentLabelType == LabelType::STRING_TEXTURE) + { + if (_fontDefinition._fontFillColor.r != _textColor.r || _fontDefinition._fontFillColor.g != _textColor.g + || _fontDefinition._fontFillColor.b != _textColor.b || _fontDefinition._fontAlpha != _textColor.a) + { + _contentDirty = true; + } + } } void Label::updateColor() @@ -1390,11 +1459,7 @@ std::string Label::getDescription() const const Size& Label::getContentSize() const { - if (_systemFontDirty) - { - const_cast(this)->updateFont(); - } - if (_contentDirty) + if (_systemFontDirty || _contentDirty) { const_cast(this)->updateContent(); } diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index 4445630ef4..a6abe88469 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -335,6 +335,13 @@ public: */ virtual void disableEffect(); + /** + * Disable effect to Label. + * + * @see `LabelEffect` + */ + virtual void disableEffect(LabelEffect effect); + /** Sets the Label's text horizontal alignment.*/ void setAlignment(TextHAlignment hAlignment) { setAlignment(hAlignment,_vAlignment);} @@ -528,13 +535,10 @@ protected: virtual void updateShaderProgram(); - void drawShadowWithoutBlur(); + void createSpriteForSystemFont(); - void drawTextSprite(Renderer *renderer, uint32_t parentFlags); + void createShadowSpriteForSystemFont(); - void createSpriteWithFontDefinition(); - - void updateFont(); void reset(); std::string _bmFontPath; @@ -597,8 +601,9 @@ protected: Size _shadowOffset; int _shadowBlurRadius; Mat4 _shadowTransform; - Color3B _shadowColor; - float _shadowOpacity; + Color4F _shadowColor4F; + Color3B _shadowColor3B; + GLubyte _shadowOpacity; Sprite* _shadowNode; int _outlineSize; diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 7ebbcc1a52..48bac7da87 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -367,20 +367,21 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme setVertexRect(rect); setTextureCoords(rect); - Vec2 relativeOffset = _unflippedOffsetPositionFromCenter; + float relativeOffsetX = _unflippedOffsetPositionFromCenter.x; + float relativeOffsetY = _unflippedOffsetPositionFromCenter.y; // issue #732 if (_flippedX) { - relativeOffset.x = -relativeOffset.x; + relativeOffsetX = -relativeOffsetX; } if (_flippedY) { - relativeOffset.y = -relativeOffset.y; + relativeOffsetY = -relativeOffsetY; } - _offsetPosition.x = relativeOffset.x + (_contentSize.width - _rect.size.width) / 2; - _offsetPosition.y = relativeOffset.y + (_contentSize.height - _rect.size.height) / 2; + _offsetPosition.x = relativeOffsetX + (_contentSize.width - _rect.size.width) / 2; + _offsetPosition.y = relativeOffsetY + (_contentSize.height - _rect.size.height) / 2; // rendering using batch node if (_batchNode) @@ -393,16 +394,16 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme // self rendering // Atlas: Vertex - float x1 = 0 + _offsetPosition.x; - float y1 = 0 + _offsetPosition.y; + float x1 = 0.0f + _offsetPosition.x; + float y1 = 0.0f + _offsetPosition.y; float x2 = x1 + _rect.size.width; float y2 = y1 + _rect.size.height; // Don't update Z. - _quad.bl.vertices = Vec3(x1, y1, 0); - _quad.br.vertices = Vec3(x2, y1, 0); - _quad.tl.vertices = Vec3(x1, y2, 0); - _quad.tr.vertices = Vec3(x2, y2, 0); + _quad.bl.vertices.set(x1, y1, 0.0f); + _quad.br.vertices.set(x2, y1, 0.0f); + _quad.tl.vertices.set(x1, y2, 0.0f); + _quad.tr.vertices.set(x2, y2, 0.0f); } } @@ -507,7 +508,10 @@ void Sprite::updateTransform(void) // If it is not visible, or one of its ancestors is not visible, then do nothing: if( !_visible || ( _parent && _parent != _batchNode && static_cast(_parent)->_shouldBeHidden) ) { - _quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vec3(0,0,0); + _quad.br.vertices.setZero(); + _quad.tl.vertices.setZero(); + _quad.tr.vertices.setZero(); + _quad.bl.vertices.setZero(); _shouldBeHidden = true; } else @@ -556,10 +560,10 @@ void Sprite::updateTransform(void) float dx = x1 * cr - y2 * sr2 + x; float dy = x1 * sr + y2 * cr2 + y; - _quad.bl.vertices = Vec3( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ ); - _quad.br.vertices = Vec3( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ ); - _quad.tl.vertices = Vec3( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ ); - _quad.tr.vertices = Vec3( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ ); + _quad.bl.vertices.set(RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ); + _quad.br.vertices.set(RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ); + _quad.tl.vertices.set(RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ); + _quad.tr.vertices.set(RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ); } // MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS @@ -1016,10 +1020,10 @@ void Sprite::setBatchNode(SpriteBatchNode *spriteBatchNode) float y1 = _offsetPosition.y; float x2 = x1 + _rect.size.width; float y2 = y1 + _rect.size.height; - _quad.bl.vertices = Vec3( x1, y1, 0 ); - _quad.br.vertices = Vec3( x2, y1, 0 ); - _quad.tl.vertices = Vec3( x1, y2, 0 ); - _quad.tr.vertices = Vec3( x2, y2, 0 ); + _quad.bl.vertices.set( x1, y1, 0 ); + _quad.br.vertices.set(x2, y1, 0); + _quad.tl.vertices.set(x1, y2, 0); + _quad.tr.vertices.set(x2, y2, 0); } else { diff --git a/cocos/2d/CCTMXLayer.cpp b/cocos/2d/CCTMXLayer.cpp index 044cb42665..d64a51a27d 100644 --- a/cocos/2d/CCTMXLayer.cpp +++ b/cocos/2d/CCTMXLayer.cpp @@ -621,7 +621,7 @@ Vec2 TMXLayer::calculateLayerOffset(const Vec2& pos) case TMXOrientationStaggered: { float diffX = 0; - if ((int)abs(pos.y) % 2 == 1) + if ((int)std::abs(pos.y) % 2 == 1) { diffX = _mapTileSize.width/2; } diff --git a/cocos/2d/cocos2d_headers.props b/cocos/2d/cocos2d_headers.props index a6d48bbaa3..2088c06b67 100644 --- a/cocos/2d/cocos2d_headers.props +++ b/cocos/2d/cocos2d_headers.props @@ -7,7 +7,7 @@ - $(EngineRoot)cocos\editor-support;$(EngineRoot)cocos;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES + $(EngineRoot)cocos\editor-support;$(EngineRoot)cocos;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES;$(EngineRoot)external\freetype2\include\win32\freetype2;$(EngineRoot)external\freetype2\include\win32\ _VARIADIC_MAX=10;%(PreprocessorDefinitions) diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index cded43a3e1..7d74f8cb6f 100755 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -480,7 +480,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - @@ -1036,7 +1035,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index 11a84c92a7..c80e36f980 100755 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -1240,7 +1240,6 @@ audioengine - cocostudio\TimelineAction @@ -2944,7 +2943,6 @@ audioengine - cocostudio\TimelineAction diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems index 6720cba446..00d15716a2 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems @@ -341,7 +341,6 @@ - @@ -914,7 +913,6 @@ - diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters index 88195990e1..bb797c3e11 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters @@ -703,9 +703,6 @@ cocostudio\TimelineAction - - cocostudio\TimelineAction - cocostudio\TimelineAction @@ -2344,9 +2341,6 @@ cocostudio\TimelineAction - - cocostudio\TimelineAction - cocostudio\TimelineAction diff --git a/cocos/2d/libcocos2d_wp8.vcxproj b/cocos/2d/libcocos2d_wp8.vcxproj index a580c92e97..caec1c8145 100644 --- a/cocos/2d/libcocos2d_wp8.vcxproj +++ b/cocos/2d/libcocos2d_wp8.vcxproj @@ -502,7 +502,6 @@ - @@ -1147,7 +1146,6 @@ - diff --git a/cocos/2d/libcocos2d_wp8.vcxproj.filters b/cocos/2d/libcocos2d_wp8.vcxproj.filters index 516cc1989c..01c31705ae 100644 --- a/cocos/2d/libcocos2d_wp8.vcxproj.filters +++ b/cocos/2d/libcocos2d_wp8.vcxproj.filters @@ -962,9 +962,6 @@ cocostudio\TimelineAction - - cocostudio\TimelineAction - cocostudio\TimelineAction @@ -2633,9 +2630,6 @@ cocostudio\TimelineAction - - cocostudio\TimelineAction - cocostudio\TimelineAction diff --git a/cocos/2d/winrt_8.1_props/cocos2d_winrt_8.1.props b/cocos/2d/winrt_8.1_props/cocos2d_winrt_8.1.props index 9c757fc37e..4ac1f12050 100644 --- a/cocos/2d/winrt_8.1_props/cocos2d_winrt_8.1.props +++ b/cocos/2d/winrt_8.1_props/cocos2d_winrt_8.1.props @@ -7,7 +7,7 @@ - $(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\angle\include;$(EngineRoot)external\freetype2\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\curl\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\websockets\include\$(COCOS2D_PLATFORM);$(EngineRoot)cocos\platform\winrt;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\editor-support;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\sqlite3\include;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)extensions;$(EngineRoot)external;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\unzip;$(EngineRoot)external\tinyxml2;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\xxhash;%(AdditionalIncludeDirectories); + $(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\angle\include;$(EngineRoot)external\freetype2\include\$(COCOS2D_PLATFORM)\freetype;$(EngineRoot)external\curl\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\websockets\include\$(COCOS2D_PLATFORM);$(EngineRoot)cocos\platform\winrt;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\editor-support;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\sqlite3\include;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)extensions;$(EngineRoot)external;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\unzip;$(EngineRoot)external\tinyxml2;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\xxhash;%(AdditionalIncludeDirectories) WINRT;_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions) diff --git a/cocos/2d/wp8_props/cocos2d_wp8.props b/cocos/2d/wp8_props/cocos2d_wp8.props index 0ffe8f2ed3..6eae8ad021 100644 --- a/cocos/2d/wp8_props/cocos2d_wp8.props +++ b/cocos/2d/wp8_props/cocos2d_wp8.props @@ -10,7 +10,7 @@ - $(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\angle\include;$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\zlib\include;$(EngineRoot)external\freetype2\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\curl\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\websockets\include\$(COCOS2D_PLATFORM);$(EngineRoot)cocos\platform\wp8;$(EngineRoot)cocos\platform\winrt;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\editor-support;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\sqlite3\include;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)extensions;$(EngineRoot)external;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\unzip;$(EngineRoot)external\tinyxml2;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\xxhash;%(AdditionalIncludeDirectories); + $(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\angle\include;$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\zlib\include;$(EngineRoot)external\freetype2\include\$(COCOS2D_PLATFORM)\freetype;$(EngineRoot)external\curl\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\websockets\include\$(COCOS2D_PLATFORM);$(EngineRoot)cocos\platform\wp8;$(EngineRoot)cocos\platform\winrt;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\editor-support;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\sqlite3\include;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)extensions;$(EngineRoot)external;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\unzip;$(EngineRoot)external\tinyxml2;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\xxhash;%(AdditionalIncludeDirectories) WP8;_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions) diff --git a/cocos/3d/CCAnimationCurve.inl b/cocos/3d/CCAnimationCurve.inl index 41380f8c89..12d67cc996 100644 --- a/cocos/3d/CCAnimationCurve.inl +++ b/cocos/3d/CCAnimationCurve.inl @@ -33,7 +33,7 @@ void AnimationCurve::evaluate(float time, float* dst, EvaluateTyp break; case EvaluateType::INT_NEAR: { - float* src = t > 0.5f ? toValue : fromValue; + float* src = fabs(t) > 0.5f ? toValue : fromValue; memcpy(dst, src, _componentSizeByte); } break; diff --git a/cocos/3d/CCBillBoard.cpp b/cocos/3d/CCBillBoard.cpp index c46dfe4075..95ec6aacd9 100644 --- a/cocos/3d/CCBillBoard.cpp +++ b/cocos/3d/CCBillBoard.cpp @@ -173,7 +173,7 @@ bool BillBoard::calculateBillbaordTransform() switch (_mode) { case Mode::VIEW_POINT_ORIENTED: - camDir = Vec3(localToWorld.m[12] - camWorldMat.m[12], localToWorld.m[13] - camWorldMat.m[13], localToWorld.m[14] - camWorldMat.m[14]); + camDir.set(localToWorld.m[12] - camWorldMat.m[12], localToWorld.m[13] - camWorldMat.m[13], localToWorld.m[14] - camWorldMat.m[14]); break; case Mode::VIEW_PLANE_ORIENTED: camWorldMat.transformVector(Vec3(0.0f, 0.0f, -1.0f), &camDir); @@ -196,7 +196,7 @@ bool BillBoard::calculateBillbaordTransform() Mat4 rotationMatrix; rotationMatrix.setIdentity(); - Vec3 upAxis = Vec3(rotationMatrix.m[4],rotationMatrix.m[5],rotationMatrix.m[6]); + Vec3 upAxis(rotationMatrix.m[4],rotationMatrix.m[5],rotationMatrix.m[6]); Vec3 x, y; camWorldMat.transformVector(upAxis, &y); Vec3::cross(camDir, y, &x); diff --git a/cocos/3d/CCBundle3D.cpp b/cocos/3d/CCBundle3D.cpp index 7973e8dcc1..f289c02648 100644 --- a/cocos/3d/CCBundle3D.cpp +++ b/cocos/3d/CCBundle3D.cpp @@ -751,8 +751,8 @@ bool Bundle3D::loadMeshDatasJson(MeshDatas& meshdatas) const rapidjson::Value& mesh_part_aabb = mesh_part[AABBS]; if (mesh_part.HasMember(AABBS) && mesh_part_aabb.Size() == 6) { - Vec3 min = Vec3(mesh_part_aabb[(rapidjson::SizeType)0].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)1].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)2].GetDouble()); - Vec3 max = Vec3(mesh_part_aabb[(rapidjson::SizeType)3].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)4].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)5].GetDouble()); + Vec3 min(mesh_part_aabb[(rapidjson::SizeType)0].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)1].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)2].GetDouble()); + Vec3 max(mesh_part_aabb[(rapidjson::SizeType)3].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)4].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)5].GetDouble()); meshData->subMeshAABB.push_back(AABB(min, max)); } else @@ -1436,7 +1436,7 @@ bool Bundle3D::loadAnimationDataJson(const std::string& id, Animation3DData* ani { const rapidjson::Value& bone_keyframe_translation = bone_keyframe[TRANSLATION]; float keytime = bone_keyframe[KEYTIME].GetDouble(); - Vec3 val = Vec3(bone_keyframe_translation[(rapidjson::SizeType)0].GetDouble(), bone_keyframe_translation[1].GetDouble(), bone_keyframe_translation[2].GetDouble()); + Vec3 val(bone_keyframe_translation[(rapidjson::SizeType)0].GetDouble(), bone_keyframe_translation[1].GetDouble(), bone_keyframe_translation[2].GetDouble()); animationdata->_translationKeys[bone_name].push_back(Animation3DData::Vec3Key(keytime,val)); } @@ -1452,7 +1452,7 @@ bool Bundle3D::loadAnimationDataJson(const std::string& id, Animation3DData* ani { const rapidjson::Value& bone_keyframe_scale = bone_keyframe[SCALE]; float keytime = bone_keyframe[KEYTIME].GetDouble(); - Vec3 val = Vec3(bone_keyframe_scale[(rapidjson::SizeType)0].GetDouble(), bone_keyframe_scale[1].GetDouble(), bone_keyframe_scale[2].GetDouble()); + Vec3 val(bone_keyframe_scale[(rapidjson::SizeType)0].GetDouble(), bone_keyframe_scale[1].GetDouble(), bone_keyframe_scale[2].GetDouble()); animationdata->_scaleKeys[bone_name].push_back(Animation3DData::Vec3Key(keytime,val)); } } @@ -2102,11 +2102,11 @@ cocos2d::AABB Bundle3D::calculateAABB( const std::vector& vertex, int str { AABB aabb; stride /= 4; - for(const auto& it : index) - { - Vec3 point = Vec3(vertex[it * stride ], vertex[ it * stride + 1], vertex[it * stride + 2 ]); - aabb.updateMinMax(&point, 1); - } + for (const auto& it : index) + { + Vec3 point(vertex[it * stride], vertex[it * stride + 1], vertex[it * stride + 2]); + aabb.updateMinMax(&point, 1); + } return aabb; } diff --git a/cocos/3d/CCOBB.cpp b/cocos/3d/CCOBB.cpp index 826e40d2bf..401300872e 100755 --- a/cocos/3d/CCOBB.cpp +++ b/cocos/3d/CCOBB.cpp @@ -209,9 +209,9 @@ OBB::OBB(const AABB& aabb) _center = (aabb._min + aabb._max); _center.scale(0.5f); - _xAxis = Vec3(1.0f, 0.0f, 0.0f); - _yAxis = Vec3(0.0f, 1.0f, 0.0f); - _zAxis = Vec3(0.0f, 0.0f, 1.0f); + _xAxis.set(1.0f, 0.0f, 0.0f); + _yAxis.set(0.0f, 1.0f, 0.0f); + _zAxis.set(0.0f, 0.0f, 1.0f); _extents = aabb._max - aabb._min; _extents.scale(0.5f); @@ -249,9 +249,9 @@ OBB::OBB(const Vec3* verts, int num) matTransform.transpose(); - _xAxis = Vec3(matTransform.m[0], matTransform.m[1], matTransform.m[2]); - _yAxis = Vec3(matTransform.m[4], matTransform.m[5], matTransform.m[6]); - _zAxis = Vec3(matTransform.m[8], matTransform.m[9], matTransform.m[10]); + _xAxis.set(matTransform.m[0], matTransform.m[1], matTransform.m[2]); + _yAxis.set(matTransform.m[4], matTransform.m[5], matTransform.m[6]); + _zAxis.set(matTransform.m[8], matTransform.m[9], matTransform.m[10]); _center = 0.5f * (vecMax + vecMin); _center *= matTransform; diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index 8f9ad8988b..08f12ec863 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -820,6 +820,22 @@ const BlendFunc& Sprite3D::getBlendFunc() const return _blend; } +AABB Sprite3D::getAABBRecursively() +{ + AABB aabb; + const Vector& children = getChildren(); + for (const auto& iter : children) + { + Sprite3D* child = dynamic_cast(iter); + if(child) + { + aabb.merge(child->getAABBRecursively()); + } + } + aabb.merge(getAABB()); + return aabb; +} + const AABB& Sprite3D::getAABB() const { Mat4 nodeToWorldTransform(getNodeToWorldTransform()); @@ -832,15 +848,18 @@ const AABB& Sprite3D::getAABB() const else { _aabb.reset(); - Mat4 transform(nodeToWorldTransform); - for (const auto& it : _meshes) { - if (it->isVisible()) - _aabb.merge(it->getAABB()); + if (_meshes.size()) + { + Mat4 transform(nodeToWorldTransform); + for (const auto& it : _meshes) { + if (it->isVisible()) + _aabb.merge(it->getAABB()); + } + + _aabb.transform(transform); + _nodeToWorldTransform = nodeToWorldTransform; + _aabbDirty = false; } - - _aabb.transform(transform); - _nodeToWorldTransform = nodeToWorldTransform; - _aabbDirty = false; } return _aabb; diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index 51467a91e3..147b7c43f8 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -135,6 +135,14 @@ public: */ const AABB& getAABB() const; + /* + * Get AABB Recursively + * Because some times we may have an empty Sprite3D Node as parent, but + * the Sprite3D don't contain any meshes, so getAABB() + * will return a wrong value at that time. + */ + AABB getAABBRecursively(); + /** * Executes an action, and returns the action that is executed. For Sprite3D special logic are needed to take care of Fading. * diff --git a/cocos/Android.mk b/cocos/Android.mk index c77400fb78..5bc5446d65 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -221,7 +221,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) \ LOCAL_EXPORT_LDLIBS := -lGLESv2 \ -llog \ - -lz \ -landroid LOCAL_STATIC_LIBRARIES := cocos_freetype2_static @@ -230,6 +229,7 @@ LOCAL_STATIC_LIBRARIES += cocos_jpeg_static LOCAL_STATIC_LIBRARIES += cocos_tiff_static LOCAL_STATIC_LIBRARIES += cocos_webp_static LOCAL_STATIC_LIBRARIES += cocos_chipmunk_static +LOCAL_STATIC_LIBRARIES += cocos_zlib_static LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dxandroid_static @@ -260,6 +260,7 @@ include $(BUILD_STATIC_LIBRARY) $(call import-module,freetype2/prebuilt/android) $(call import-module,platform/android) $(call import-module,png/prebuilt/android) +$(call import-module,zlib/prebuilt/android) $(call import-module,jpeg/prebuilt/android) $(call import-module,tiff/prebuilt/android) $(call import-module,webp/prebuilt/android) diff --git a/cocos/audio/apple/AudioEngine-inl.mm b/cocos/audio/apple/AudioEngine-inl.mm index e01b99586e..0f9bc4df00 100644 --- a/cocos/audio/apple/AudioEngine-inl.mm +++ b/cocos/audio/apple/AudioEngine-inl.mm @@ -141,11 +141,31 @@ namespace cocos2d { @implementation AudioEngineSessionHandler +void AudioEngineInterruptionListenerCallback(void* user_data, UInt32 interruption_state) +{ + if (kAudioSessionBeginInterruption == interruption_state) + { + alcMakeContextCurrent(nullptr); + } + else if (kAudioSessionEndInterruption == interruption_state) + { + OSStatus result = AudioSessionSetActive(true); + if (result) NSLog(@"Error setting audio session active! %d\n", result); + + alcMakeContextCurrent(s_ALContext); + } +} + -(id) init { if (self == [super init]) { + if ([[[UIDevice currentDevice] systemVersion] intValue] > 5) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleInterruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]]; + } + else { + AudioSessionInitialize(NULL, NULL, AudioEngineInterruptionListenerCallback, self); + } } return self; } diff --git a/cocos/cocos2d.cpp b/cocos/cocos2d.cpp index 6732f6baf6..1629bd42bf 100644 --- a/cocos/cocos2d.cpp +++ b/cocos/cocos2d.cpp @@ -31,7 +31,7 @@ NS_CC_BEGIN CC_DLL const char* cocos2dVersion() { - return "cocos2d-x 3.5"; + return "cocos2d-x 3.6alpha0"; } NS_CC_END diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index a28d39b8e3..2888e7b54b 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -30,7 +30,7 @@ THE SOFTWARE. // 0x00 HI ME LO // 00 03 03 00 -#define COCOS2D_VERSION 0x00030500 +#define COCOS2D_VERSION 0x00030600 // // all cocos2d include files diff --git a/cocos/deprecated/CCDeprecated.cpp b/cocos/deprecated/CCDeprecated.cpp index 5a3c2acee0..a0b5619b89 100644 --- a/cocos/deprecated/CCDeprecated.cpp +++ b/cocos/deprecated/CCDeprecated.cpp @@ -578,19 +578,19 @@ Vec4* kmVec4Transform(Vec4* pOut, const Vec4* pV, const Mat4* pM) return pOut; } -const Vec3 KM_VEC3_NEG_Z = Vec3(0, 0, -1); -const Vec3 KM_VEC3_POS_Z = Vec3(0, 0, 1); -const Vec3 KM_VEC3_POS_Y = Vec3(0, 1, 0); -const Vec3 KM_VEC3_NEG_Y = Vec3(0, -1, 0); -const Vec3 KM_VEC3_NEG_X = Vec3(-1, 0, 0); -const Vec3 KM_VEC3_POS_X = Vec3(1, 0, 0); -const Vec3 KM_VEC3_ZERO = Vec3(0, 0, 0); +const Vec3 KM_VEC3_NEG_Z(0, 0, -1); +const Vec3 KM_VEC3_POS_Z(0, 0, 1); +const Vec3 KM_VEC3_POS_Y(0, 1, 0); +const Vec3 KM_VEC3_NEG_Y(0, -1, 0); +const Vec3 KM_VEC3_NEG_X(-1, 0, 0); +const Vec3 KM_VEC3_POS_X(1, 0, 0); +const Vec3 KM_VEC3_ZERO(0, 0, 0); -const Vec2 KM_VEC2_POS_Y = Vec2(0, 1); -const Vec2 KM_VEC2_NEG_Y = Vec2(0, -1); -const Vec2 KM_VEC2_NEG_X = Vec2(-1, 0); -const Vec2 KM_VEC2_POS_X = Vec2(1, 0); -const Vec2 KM_VEC2_ZERO = Vec2(0, 0); +const Vec2 KM_VEC2_POS_Y(0, 1); +const Vec2 KM_VEC2_NEG_Y(0, -1); +const Vec2 KM_VEC2_NEG_X(-1, 0); +const Vec2 KM_VEC2_POS_X(1, 0); +const Vec2 KM_VEC2_ZERO(0, 0); NS_CC_END diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.cpp deleted file mode 100644 index 6ed0ef0e47..0000000000 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.cpp +++ /dev/null @@ -1,473 +0,0 @@ -/**************************************************************************** -Copyright (c) 2013 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#include "CCNodeReader.h" -#include "CCActionTimelineCache.h" -#include "CCActionTimeline.h" - -#include "cocostudio/CCSGUIReader.h" - -using namespace cocos2d; -using namespace ui; - -namespace cocostudio { -namespace timeline{ - - -static const char* ClassName_Node = "Node"; -static const char* ClassName_SubGraph = "SubGraph"; -static const char* ClassName_Sprite = "Sprite"; -static const char* ClassName_Particle = "Particle"; - -static const char* ClassName_Panel = "Panel"; -static const char* ClassName_Button = "Button"; -static const char* ClassName_CheckBox = "CheckBox"; -static const char* ClassName_ImageView = "ImageView"; -static const char* ClassName_TextAtlas = "TextAtlas"; -static const char* ClassName_LabelAtlas = "LabelAtlas"; -static const char* ClassName_LabelBMFont= "LabelBMFont"; -static const char* ClassName_TextBMFont = "TextBMFont"; -static const char* ClassName_Text = "Text"; -static const char* ClassName_LoadingBar = "LoadingBar"; -static const char* ClassName_TextField = "TextField"; -static const char* ClassName_Slider = "Slider"; -static const char* ClassName_Layout = "Layout"; -static const char* ClassName_ScrollView = "ScrollView"; -static const char* ClassName_ListView = "ListView"; -static const char* ClassName_PageView = "PageView"; -static const char* ClassName_Widget = "Widget"; -static const char* ClassName_Label = "Label"; - - -static const char* NODE = "nodeTree"; -static const char* CHILDREN = "children"; -static const char* CLASSNAME = "classname"; -static const char* FILE_PATH = "fileName"; -static const char* PLIST_FILE = "plistFile"; -static const char* TAG = "tag"; -static const char* ACTION_TAG = "actionTag"; - -static const char* OPTIONS = "options"; - -static const char* WIDTH = "width"; -static const char* HEIGHT = "height"; -static const char* X = "x"; -static const char* Y = "y"; -static const char* SCALE_X = "scaleX"; -static const char* SCALE_Y = "scaleY"; -static const char* SKEW_X = "skewX"; -static const char* SKEW_Y = "skewY"; -static const char* ROTATION = "rotation"; -static const char* ROTATION_SKEW_X = "rotationSkewX"; -static const char* ROTATION_SKEW_Y = "rotationSkewY"; -static const char* ANCHOR_X = "anchorPointX"; -static const char* ANCHOR_Y = "anchorPointY"; -static const char* ALPHA = "opacity"; -static const char* RED = "colorR"; -static const char* GREEN = "colorG"; -static const char* BLUE = "colorB"; -static const char* ZORDER = "ZOrder"; -static const char* PARTICLE_NUM = "particleNum"; -static const char* FLIPX = "flipX"; -static const char* FLIPY = "flipY"; -static const char* VISIBLE = "visible"; - -static const char* TEXTURES = "textures"; -static const char* TEXTURES_PNG = "texturesPng"; - - -// NodeReader -static NodeReader* _sharedNodeReader = nullptr; - -NodeReader* NodeReader::getInstance() -{ - if (! _sharedNodeReader) - { - _sharedNodeReader = new (std::nothrow) NodeReader(); - _sharedNodeReader->init(); - } - - return _sharedNodeReader; -} - -void NodeReader::destroyInstance() -{ - CC_SAFE_DELETE(_sharedNodeReader); -} - -NodeReader::NodeReader() - : _recordJsonPath(true) - , _jsonPath("") -{ -} - -void NodeReader::purge() -{ -} - -void NodeReader::init() -{ - using namespace std::placeholders; - - _funcs.insert(Pair(ClassName_Node, std::bind(&NodeReader::loadSimpleNode, this, _1))); - _funcs.insert(Pair(ClassName_SubGraph, std::bind(&NodeReader::loadSubGraph, this, _1))); - _funcs.insert(Pair(ClassName_Sprite, std::bind(&NodeReader::loadSprite, this, _1))); - _funcs.insert(Pair(ClassName_Particle, std::bind(&NodeReader::loadParticle, this, _1))); - _funcs.insert(Pair(ClassName_LabelAtlas,std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_LabelBMFont,std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_Panel, std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_Button, std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_CheckBox, std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_ImageView, std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_TextAtlas, std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_TextBMFont,std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_Text, std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_LoadingBar,std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_TextField, std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_Slider, std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_Layout, std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_ScrollView,std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_ListView, std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_PageView, std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_Widget, std::bind(&NodeReader::loadWidget, this, _1))); - _funcs.insert(Pair(ClassName_Label, std::bind(&NodeReader::loadWidget, this, _1))); - -} - -Node* NodeReader::createNode(const std::string& filename) -{ - if(_recordJsonPath) - { - std::string jsonPath = filename.substr(0, filename.find_last_of('/') + 1); - GUIReader::getInstance()->setFilePath(jsonPath); - - _jsonPath = jsonPath; - } - else - { - GUIReader::getInstance()->setFilePath(""); - _jsonPath = ""; - } - - Node* node = loadNodeWithFile(filename); - - return node; -} - -Node* NodeReader::loadNodeWithFile(const std::string& fileName) -{ - // Read content from file - std::string contentStr = FileUtils::getInstance()->getStringFromFile(fileName); - - Node* node = loadNodeWithContent(contentStr); - - // Load animation data from file - ActionTimelineCache::getInstance()->loadAnimationActionWithContent(fileName, contentStr); - - return node; -} - -Node* NodeReader::loadNodeWithContent(const std::string& content) -{ - rapidjson::Document doc; - doc.Parse<0>(content.c_str()); - if (doc.HasParseError()) - { - CCLOG("GetParseError %s\n", doc.GetParseError()); - } - - // decode plist - int length = DICTOOL->getArrayCount_json(doc, TEXTURES); - - for(int i=0; igetStringValueFromArray_json(doc, TEXTURES, i); - std::string png = DICTOOL->getStringValueFromArray_json(doc, TEXTURES_PNG, i); - plist = _jsonPath + plist; - png = _jsonPath + png; - SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plist, png); - } - - // decode node tree - const rapidjson::Value& subJson = DICTOOL->getSubDictionary_json(doc, NODE); - Node* root = loadNode(subJson); - root->release(); - - return root; -} - -Node* NodeReader::loadNode(const rapidjson::Value& json) -{ - Node* node = nullptr; - std::string nodeType = DICTOOL->getStringValue_json(json, CLASSNAME); - - NodeCreateFunc func = _funcs[nodeType]; - if (func != nullptr) - { - const rapidjson::Value& options = DICTOOL->getSubDictionary_json(json, OPTIONS); - node = func(options); - } - - if(node) - { - int length = DICTOOL->getArrayCount_json(json, CHILDREN, 0); - for (int i = 0; igetSubDictionary_json(json, CHILDREN, i); - Node* child = loadNode(dic); - if (child) - { - auto widgetChild = dynamic_cast(child); - if (widgetChild - && dynamic_cast(node) - && !dynamic_cast(node)) - { - if (widgetChild->getPositionType() == ui::Widget::PositionType::PERCENT) - { - widgetChild->setPositionPercent(Vec2(widgetChild->getPositionPercent().x + node->getAnchorPoint().x, widgetChild->getPositionPercent().y + node->getAnchorPoint().y)); - } - widgetChild->setPosition(Vec2(widgetChild->getPositionX() + node->getAnchorPointInPoints().x, widgetChild->getPositionY() + node->getAnchorPointInPoints().y)); - } - - node->addChild(child); - child->release(); - } - } - } - else - { - CCLOG("Not supported NodeType: %s", nodeType.c_str()); - } - - return node; -} - -void NodeReader::initNode(Node* node, const rapidjson::Value& json) -{ - float width = DICTOOL->getFloatValue_json(json, WIDTH); - float height = DICTOOL->getFloatValue_json(json, HEIGHT); - float x = DICTOOL->getFloatValue_json(json, X); - float y = DICTOOL->getFloatValue_json(json, Y); - float scalex = DICTOOL->getFloatValue_json(json, SCALE_X, 1); - float scaley = DICTOOL->getFloatValue_json(json, SCALE_Y, 1); - float rotation = DICTOOL->getFloatValue_json(json, ROTATION); - float rotationSkewX = DICTOOL->getFloatValue_json(json, ROTATION_SKEW_X); - float rotationSkewY = DICTOOL->getFloatValue_json(json, ROTATION_SKEW_Y); - float skewx = DICTOOL->getFloatValue_json(json, SKEW_X); - float skewy = DICTOOL->getFloatValue_json(json, SKEW_Y); - float anchorx = DICTOOL->getFloatValue_json(json, ANCHOR_X, 0.5f); - float anchory = DICTOOL->getFloatValue_json(json, ANCHOR_Y, 0.5f); - GLubyte alpha = (GLubyte)DICTOOL->getIntValue_json(json, ALPHA, 255); - GLubyte red = (GLubyte)DICTOOL->getIntValue_json(json, RED, 255); - GLubyte green = (GLubyte)DICTOOL->getIntValue_json(json, GREEN, 255); - GLubyte blue = (GLubyte)DICTOOL->getIntValue_json(json, BLUE, 255); - int zorder = DICTOOL->getIntValue_json(json, ZORDER); - int tag = DICTOOL->getIntValue_json(json, TAG); - int actionTag = DICTOOL->getIntValue_json(json, ACTION_TAG); - bool visible = DICTOOL->getBooleanValue_json(json, VISIBLE); - - if(x != 0 || y != 0) - node->setPosition(x, y); - if(scalex != 1) - node->setScaleX(scalex); - if(scaley != 1) - node->setScaleY(scaley); - if (rotation != 0) - node->setRotation(rotation); - if(rotationSkewX != 0) - node->setRotationSkewX(rotationSkewX); - if(rotationSkewY != 0) - node->setRotationSkewY(rotationSkewY); - if(skewx != 0) - node->setSkewX(skewx); - if(skewy != 0) - node->setSkewY(skewy); - if(anchorx != 0.5f || anchory != 0.5f) - node->setAnchorPoint(Point(anchorx, anchory)); - if(width != 0 || height != 0) - node->setContentSize(Size(width, height)); - if(zorder != 0) - node->setLocalZOrder(zorder); - if(visible != true) - node->setVisible(visible); - - if(alpha != 255) - { - node->setOpacity(alpha); - } - if(red != 255 || green != 255 || blue != 255) - { - node->setColor(Color3B(red, green, blue)); - } - - - node->setTag(tag); - node->setUserObject(ActionTimelineData::create(actionTag)); -} - -Node* NodeReader::loadSimpleNode(const rapidjson::Value& json) -{ - Node* node = Node::create(); - node->retain(); - initNode(node, json); - - return node; -} - -Node* NodeReader::loadSubGraph(const rapidjson::Value& json) -{ - const char* filePath = DICTOOL->getStringValue_json(json, FILE_PATH); - - Node* node = nullptr; - if (filePath && strcmp("", filePath) != 0) - { - node = createNode(filePath); - } - else - { - node = Node::create(); - } - - node->retain(); - - initNode(node, json); - - return node; -} - -Node* NodeReader::loadSprite(const rapidjson::Value& json) -{ - const char* filePath = DICTOOL->getStringValue_json(json, FILE_PATH); - Sprite *sprite = nullptr; - - if(filePath != nullptr) - { - std::string path = filePath; - - SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(path); - if(!spriteFrame) - { - path = _jsonPath + path; - sprite = Sprite::create(path); - } - else - { - sprite = Sprite::createWithSpriteFrame(spriteFrame); - } - - if(!sprite) - { - sprite = CCSprite::create(); - CCLOG("filePath is empty. Create a sprite with no texture"); - } - } - else - { - sprite = Sprite::create(); - } - - sprite->retain(); - - initNode(sprite, json); - - bool flipX = DICTOOL->getBooleanValue_json(json, FLIPX); - bool flipY = DICTOOL->getBooleanValue_json(json, FLIPY); - - if(flipX != false) - sprite->setFlippedX(flipX); - if(flipY != false) - sprite->setFlippedY(flipY); - - return sprite; -} - -Node* NodeReader::loadParticle(const rapidjson::Value& json) -{ - const char* filePath = DICTOOL->getStringValue_json(json, PLIST_FILE); - int num = DICTOOL->getIntValue_json(json, PARTICLE_NUM); - - ParticleSystemQuad* particle = ParticleSystemQuad::create(filePath); - particle->setTotalParticles(num); - particle->retain(); - - initNode(particle, json); - - return particle; -} - -Node* NodeReader::loadWidget(const rapidjson::Value& json) -{ - const char* str = DICTOOL->getStringValue_json(json, CLASSNAME); - if(str == nullptr) - return nullptr; - - std::string classname = str; - - if (classname == "Panel") - { - classname = "Layout"; - } - else if (classname == "TextArea") - { - classname = "Text"; - } - else if (classname == "TextButton") - { - classname = "Button"; - } - else if (classname == "Label") - { - classname = "Text"; - } - else if (classname == "LabelAtlas") - { - classname = "TextAtlas"; - } - else if (classname == "LabelBMFont") - { - classname = "TextBMFont"; - } - - std::string readerName = classname; - readerName.append("Reader"); - - Widget* widget = dynamic_cast(ObjectFactory::getInstance()->createObject(classname)); - widget->retain(); - - WidgetReaderProtocol* reader = dynamic_cast(ObjectFactory::getInstance()->createObject(readerName)); - - WidgetPropertiesReader0300* guiReader = new (std::nothrow) WidgetPropertiesReader0300(); - guiReader->setPropsForAllWidgetFromJsonDictionary(reader, widget, json); - CC_SAFE_DELETE(guiReader); - - int actionTag = DICTOOL->getIntValue_json(json, ACTION_TAG); - widget->setUserObject(ActionTimelineData::create(actionTag)); - - initNode(widget, json); - - return widget; -} - -} -} diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.h b/cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.h deleted file mode 100644 index 28e358ab5e..0000000000 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -Copyright (c) 2013 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __CC_NODE_CACHE_H__ -#define __CC_NODE_CACHE_H__ - -#include -#include "cocostudio/DictionaryHelper.h" -#include "cocostudio/CocosStudioExport.h" -#include "2d/CCNode.h" - -namespace cocostudio { - - -namespace timeline{ - -class CC_STUDIO_DLL NodeReader -{ -public: - static NodeReader* getInstance(); - static void destroyInstance(); - - NodeReader(); - void purge(); - - void init(); - - cocos2d::Node* createNode(const std::string& filename); - - cocos2d::Node* loadNodeWithFile(const std::string& fileName); - cocos2d::Node* loadNodeWithContent(const std::string& content); - - void setRecordJsonPath(bool record) { _recordJsonPath = record; } - bool isRecordJsonPath() const { return _recordJsonPath; } - - void setJsonPath(std::string jsonPath) { _jsonPath = jsonPath; } - std::string getJsonPath() const { return _jsonPath; } - -protected: - - cocos2d::Node* loadNode(const rapidjson::Value& json); - - void locateNodeWithMulresPosition(cocos2d::Node* node, const rapidjson::Value& json); - - void initNode(cocos2d::Node* node, const rapidjson::Value& json); - - // load nodes - cocos2d::Node* loadSimpleNode(const rapidjson::Value& json); - cocos2d::Node* loadSubGraph (const rapidjson::Value& json); - cocos2d::Node* loadSprite (const rapidjson::Value& json); - cocos2d::Node* loadParticle (const rapidjson::Value& json); - - // load gui - cocos2d::Node* loadWidget(const rapidjson::Value& json); - - typedef std::function NodeCreateFunc; - typedef std::pair Pair; - - std::unordered_map _funcs; - - bool _recordJsonPath; - - std::string _jsonPath; -}; - -} -} - - -#endif /*__CC_NODE_CACHE_H__*/ diff --git a/cocos/editor-support/cocostudio/Android.mk b/cocos/editor-support/cocostudio/Android.mk index 6914cfa01c..8ced24200a 100644 --- a/cocos/editor-support/cocostudio/Android.mk +++ b/cocos/editor-support/cocostudio/Android.mk @@ -65,7 +65,6 @@ WidgetReader/Node3DReader/Node3DReader.cpp \ WidgetReader/Sprite3DReader/Sprite3DReader.cpp \ WidgetReader/UserCameraReader/UserCameraReader.cpp \ WidgetReader/Particle3DReader/Particle3DReader.cpp \ -ActionTimeline/CCNodeReader.cpp \ ActionTimeline/CCActionTimelineCache.cpp \ ActionTimeline/CCFrame.cpp \ ActionTimeline/CCTimeLine.cpp \ diff --git a/cocos/editor-support/cocostudio/CCSkin.cpp b/cocos/editor-support/cocostudio/CCSkin.cpp index ea21fc2252..48fb5e0f8b 100644 --- a/cocos/editor-support/cocostudio/CCSkin.cpp +++ b/cocos/editor-support/cocostudio/CCSkin.cpp @@ -42,8 +42,6 @@ namespace cocostudio { #define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__)) #endif -#define SET_VERTEX3F(_v_, _x_, _y_, _z_) (_v_).x = (_x_); (_v_).y = (_y_); (_v_).z = (_z_); - Skin *Skin::create() { Skin *skin = new (std::nothrow) Skin(); @@ -152,7 +150,10 @@ void Skin::updateTransform() // If it is not visible, or one of its ancestors is not visible, then do nothing: if( !_visible) { - _quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vec3(0, 0, 0); + _quad.br.vertices.setZero(); + _quad.tl.vertices.setZero(); + _quad.tr.vertices.setZero(); + _quad.bl.vertices.setZero(); } else { @@ -188,10 +189,10 @@ void Skin::updateTransform() float dx = x1 * cr - y2 * sr2 + x; float dy = x1 * sr + y2 * cr2 + y; - SET_VERTEX3F( _quad.bl.vertices, RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ ); - SET_VERTEX3F( _quad.br.vertices, RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ ); - SET_VERTEX3F( _quad.tl.vertices, RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ ); - SET_VERTEX3F( _quad.tr.vertices, RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ ); + _quad.bl.vertices.set(RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ); + _quad.br.vertices.set(RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ); + _quad.tl.vertices.set(RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ); + _quad.tr.vertices.set(RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ); } // MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS diff --git a/cocos/editor-support/cocostudio/CSParseBinary_generated.h b/cocos/editor-support/cocostudio/CSParseBinary_generated.h index b2485fbbef..165c865f67 100644 --- a/cocos/editor-support/cocostudio/CSParseBinary_generated.h +++ b/cocos/editor-support/cocostudio/CSParseBinary_generated.h @@ -53,6 +53,7 @@ struct Color; struct ColorVector; struct FlatSize; struct CapInsets; +struct BlendFunc; struct ResourceData; MANUALLY_ALIGNED_STRUCT(4) RotationSkew { @@ -175,6 +176,20 @@ MANUALLY_ALIGNED_STRUCT(4) CapInsets { }; STRUCT_END(CapInsets, 16); +MANUALLY_ALIGNED_STRUCT(4) BlendFunc { + private: + int32_t src_; + int32_t dst_; + + public: + BlendFunc(int32_t src, int32_t dst) + : src_(flatbuffers::EndianScalar(src)), dst_(flatbuffers::EndianScalar(dst)) { } + + int32_t src() const { return flatbuffers::EndianScalar(src_); } + int32_t dst() const { return flatbuffers::EndianScalar(dst_); } +}; +STRUCT_END(BlendFunc, 8); + struct CSParseBinary : private flatbuffers::Table { const flatbuffers::String *version() const { return GetPointer(4); } const flatbuffers::Vector> *textures() const { return GetPointer> *>(6); } @@ -585,12 +600,14 @@ inline flatbuffers::Offset CreateSingleNodeOptions(flatbuffer struct SpriteOptions : private flatbuffers::Table { const WidgetOptions *nodeOptions() const { return GetPointer(4); } const ResourceData *fileNameData() const { return GetPointer(6); } + const BlendFunc *blendFunc() const { return GetStruct(8); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* nodeOptions */) && verifier.VerifyTable(nodeOptions()) && VerifyField(verifier, 6 /* fileNameData */) && verifier.VerifyTable(fileNameData()) && + VerifyField(verifier, 8 /* blendFunc */) && verifier.EndTable(); } }; @@ -600,18 +617,21 @@ struct SpriteOptionsBuilder { flatbuffers::uoffset_t start_; void add_nodeOptions(flatbuffers::Offset nodeOptions) { fbb_.AddOffset(4, nodeOptions); } void add_fileNameData(flatbuffers::Offset fileNameData) { fbb_.AddOffset(6, fileNameData); } + void add_blendFunc(const BlendFunc *blendFunc) { fbb_.AddStruct(8, blendFunc); } SpriteOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SpriteOptionsBuilder &operator=(const SpriteOptionsBuilder &); flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 2)); + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); return o; } }; inline flatbuffers::Offset CreateSpriteOptions(flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset fileNameData = 0) { + flatbuffers::Offset fileNameData = 0, + const BlendFunc *blendFunc = 0) { SpriteOptionsBuilder builder_(_fbb); + builder_.add_blendFunc(blendFunc); builder_.add_fileNameData(fileNameData); builder_.add_nodeOptions(nodeOptions); return builder_.Finish(); @@ -620,12 +640,14 @@ inline flatbuffers::Offset CreateSpriteOptions(flatbuffers::FlatB struct ParticleSystemOptions : private flatbuffers::Table { const WidgetOptions *nodeOptions() const { return GetPointer(4); } const ResourceData *fileNameData() const { return GetPointer(6); } + const BlendFunc *blendFunc() const { return GetStruct(8); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* nodeOptions */) && verifier.VerifyTable(nodeOptions()) && VerifyField(verifier, 6 /* fileNameData */) && verifier.VerifyTable(fileNameData()) && + VerifyField(verifier, 8 /* blendFunc */) && verifier.EndTable(); } }; @@ -635,18 +657,21 @@ struct ParticleSystemOptionsBuilder { flatbuffers::uoffset_t start_; void add_nodeOptions(flatbuffers::Offset nodeOptions) { fbb_.AddOffset(4, nodeOptions); } void add_fileNameData(flatbuffers::Offset fileNameData) { fbb_.AddOffset(6, fileNameData); } + void add_blendFunc(const BlendFunc *blendFunc) { fbb_.AddStruct(8, blendFunc); } ParticleSystemOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ParticleSystemOptionsBuilder &operator=(const ParticleSystemOptionsBuilder &); flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 2)); + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); return o; } }; inline flatbuffers::Offset CreateParticleSystemOptions(flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset fileNameData = 0) { + flatbuffers::Offset fileNameData = 0, + const BlendFunc *blendFunc = 0) { ParticleSystemOptionsBuilder builder_(_fbb); + builder_.add_blendFunc(blendFunc); builder_.add_fileNameData(fileNameData); builder_.add_nodeOptions(nodeOptions); return builder_.Finish(); @@ -1011,6 +1036,14 @@ struct TextOptions : private flatbuffers::Table { int32_t vAlignment() const { return GetField(20, 0); } uint8_t touchScaleEnable() const { return GetField(22, 0); } uint8_t isCustomSize() const { return GetField(24, 0); } + uint8_t outlineEnabled() const { return GetField(26, 0); } + const Color *outlineColor() const { return GetStruct(28); } + int32_t outlineSize() const { return GetField(30, 1); } + uint8_t shadowEnabled() const { return GetField(32, 0); } + const Color *shadowColor() const { return GetStruct(34); } + float shadowOffsetX() const { return GetField(36, 2); } + float shadowOffsetY() const { return GetField(38, -2); } + int32_t shadowBlurRadius() const { return GetField(40, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* widgetOptions */) && @@ -1028,6 +1061,14 @@ struct TextOptions : private flatbuffers::Table { VerifyField(verifier, 20 /* vAlignment */) && VerifyField(verifier, 22 /* touchScaleEnable */) && VerifyField(verifier, 24 /* isCustomSize */) && + VerifyField(verifier, 26 /* outlineEnabled */) && + VerifyField(verifier, 28 /* outlineColor */) && + VerifyField(verifier, 30 /* outlineSize */) && + VerifyField(verifier, 32 /* shadowEnabled */) && + VerifyField(verifier, 34 /* shadowColor */) && + VerifyField(verifier, 36 /* shadowOffsetX */) && + VerifyField(verifier, 38 /* shadowOffsetY */) && + VerifyField(verifier, 40 /* shadowBlurRadius */) && verifier.EndTable(); } }; @@ -1046,10 +1087,18 @@ struct TextOptionsBuilder { void add_vAlignment(int32_t vAlignment) { fbb_.AddElement(20, vAlignment, 0); } void add_touchScaleEnable(uint8_t touchScaleEnable) { fbb_.AddElement(22, touchScaleEnable, 0); } void add_isCustomSize(uint8_t isCustomSize) { fbb_.AddElement(24, isCustomSize, 0); } + void add_outlineEnabled(uint8_t outlineEnabled) { fbb_.AddElement(26, outlineEnabled, 0); } + void add_outlineColor(const Color *outlineColor) { fbb_.AddStruct(28, outlineColor); } + void add_outlineSize(int32_t outlineSize) { fbb_.AddElement(30, outlineSize, 1); } + void add_shadowEnabled(uint8_t shadowEnabled) { fbb_.AddElement(32, shadowEnabled, 0); } + void add_shadowColor(const Color *shadowColor) { fbb_.AddStruct(34, shadowColor); } + void add_shadowOffsetX(float shadowOffsetX) { fbb_.AddElement(36, shadowOffsetX, 2); } + void add_shadowOffsetY(float shadowOffsetY) { fbb_.AddElement(38, shadowOffsetY, -2); } + void add_shadowBlurRadius(int32_t shadowBlurRadius) { fbb_.AddElement(40, shadowBlurRadius, 0); } TextOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } TextOptionsBuilder &operator=(const TextOptionsBuilder &); flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 11)); + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 19)); return o; } }; @@ -1065,8 +1114,22 @@ inline flatbuffers::Offset CreateTextOptions(flatbuffers::FlatBuffe int32_t hAlignment = 0, int32_t vAlignment = 0, uint8_t touchScaleEnable = 0, - uint8_t isCustomSize = 0) { + uint8_t isCustomSize = 0, + uint8_t outlineEnabled = 0, + const Color *outlineColor = 0, + int32_t outlineSize = 1, + uint8_t shadowEnabled = 0, + const Color *shadowColor = 0, + float shadowOffsetX = 2, + float shadowOffsetY = -2, + int32_t shadowBlurRadius = 0) { TextOptionsBuilder builder_(_fbb); + builder_.add_shadowBlurRadius(shadowBlurRadius); + builder_.add_shadowOffsetY(shadowOffsetY); + builder_.add_shadowOffsetX(shadowOffsetX); + builder_.add_shadowColor(shadowColor); + builder_.add_outlineSize(outlineSize); + builder_.add_outlineColor(outlineColor); builder_.add_vAlignment(vAlignment); builder_.add_hAlignment(hAlignment); builder_.add_areaHeight(areaHeight); @@ -1076,6 +1139,8 @@ inline flatbuffers::Offset CreateTextOptions(flatbuffers::FlatBuffe builder_.add_fontName(fontName); builder_.add_fontResource(fontResource); builder_.add_widgetOptions(widgetOptions); + builder_.add_shadowEnabled(shadowEnabled); + builder_.add_outlineEnabled(outlineEnabled); builder_.add_isCustomSize(isCustomSize); builder_.add_touchScaleEnable(touchScaleEnable); return builder_.Finish(); @@ -1685,7 +1750,7 @@ inline flatbuffers::Offset CreateListViewOptions(flatbuffers::F struct ProjectNodeOptions : private flatbuffers::Table { const WidgetOptions *nodeOptions() const { return GetPointer(4); } const flatbuffers::String *fileName() const { return GetPointer(6); } - float innerActionSpeed() const { return GetField(8, 0); } + float innerActionSpeed() const { return GetField(8, 1.0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* nodeOptions */) && @@ -1702,7 +1767,7 @@ struct ProjectNodeOptionsBuilder { flatbuffers::uoffset_t start_; void add_nodeOptions(flatbuffers::Offset nodeOptions) { fbb_.AddOffset(4, nodeOptions); } void add_fileName(flatbuffers::Offset fileName) { fbb_.AddOffset(6, fileName); } - void add_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement(8, innerActionSpeed, 0); } + void add_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement(8, innerActionSpeed, 1.0); } ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &); flatbuffers::Offset Finish() { @@ -1714,7 +1779,7 @@ struct ProjectNodeOptionsBuilder { inline flatbuffers::Offset CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset nodeOptions = 0, flatbuffers::Offset fileName = 0, - float innerActionSpeed = 0) { + float innerActionSpeed = 1.0) { ProjectNodeOptionsBuilder builder_(_fbb); builder_.add_innerActionSpeed(innerActionSpeed); builder_.add_fileName(fileName); diff --git a/cocos/editor-support/cocostudio/CocoStudio.cpp b/cocos/editor-support/cocostudio/CocoStudio.cpp index 894ecc94a4..646166a545 100644 --- a/cocos/editor-support/cocostudio/CocoStudio.cpp +++ b/cocos/editor-support/cocostudio/CocoStudio.cpp @@ -63,5 +63,11 @@ namespace cocostudio Particle3DReader::destroyInstance(); cocos2d::CSLoader::destroyInstance(); + + + ArmatureDataManager::destroyInstance(); + SceneReader::destroyInstance(); + ActionManagerEx::destroyInstance(); + GUIReader::destroyInstance(); } } \ No newline at end of file diff --git a/cocos/editor-support/cocostudio/WidgetReader/ParticleReader/ParticleReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ParticleReader/ParticleReader.cpp index 63d3e9ec51..beae5bc194 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ParticleReader/ParticleReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ParticleReader/ParticleReader.cpp @@ -79,6 +79,8 @@ namespace cocostudio std::string plistFile = ""; int resourceType = 0; + cocos2d::BlendFunc blendFunc = cocos2d::BlendFunc::ALPHA_PREMULTIPLIED; + // child elements const tinyxml2::XMLElement* child = objectData->FirstChildElement(); while (child) @@ -110,16 +112,40 @@ namespace cocostudio attribute = attribute->Next(); } } + else if (name == "BlendFunc") + { + const tinyxml2::XMLAttribute* attribute = child->FirstAttribute(); + + while (attribute) + { + name = attribute->Name(); + std::string value = attribute->Value(); + + if (name == "Src") + { + blendFunc.src = atoi(value.c_str()); + } + else if (name == "Dst") + { + blendFunc.dst = atoi(value.c_str()); + } + + attribute = attribute->Next(); + } + } child = child->NextSiblingElement(); } + flatbuffers::BlendFunc f_blendFunc(blendFunc.src, blendFunc.dst); + auto options = CreateParticleSystemOptions(*builder, nodeOptions, CreateResourceData(*builder, builder->CreateString(path), builder->CreateString(plistFile), - resourceType)); + resourceType), + &f_blendFunc); return *(Offset*)(&options); } @@ -127,7 +153,18 @@ namespace cocostudio void ParticleReader::setPropsWithFlatBuffers(cocos2d::Node *node, const flatbuffers::Table *particleOptions) { + auto particle = static_cast(node); auto options = (ParticleSystemOptions*)particleOptions; + + auto f_blendFunc = options->blendFunc(); + if (f_blendFunc) + { + cocos2d::BlendFunc blendFunc = cocos2d::BlendFunc::ALPHA_PREMULTIPLIED; + blendFunc.src = f_blendFunc->src(); + blendFunc.dst = f_blendFunc->dst(); + particle->setBlendFunc(blendFunc); + } + auto nodeReader = NodeReader::getInstance(); nodeReader->setPropsWithFlatBuffers(node, (Table*)options->nodeOptions()); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/SpriteReader/SpriteReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/SpriteReader/SpriteReader.cpp index 56eb65df47..de217b8bb3 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/SpriteReader/SpriteReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/SpriteReader/SpriteReader.cpp @@ -80,6 +80,8 @@ namespace cocostudio std::string plistFile = ""; int resourceType = 0; + cocos2d::BlendFunc blendFunc = cocos2d::BlendFunc::ALPHA_PREMULTIPLIED; + // FileData const tinyxml2::XMLElement* child = objectData->FirstChildElement(); while (child) @@ -121,17 +123,40 @@ namespace cocostudio fbs->_textures.push_back(builder->CreateString(texture)); } } + else if (name == "BlendFunc") + { + const tinyxml2::XMLAttribute* attribute = child->FirstAttribute(); + + while (attribute) + { + name = attribute->Name(); + std::string value = attribute->Value(); + + if (name == "Src") + { + blendFunc.src = atoi(value.c_str()); + } + else if (name == "Dst") + { + blendFunc.dst = atoi(value.c_str()); + } + + attribute = attribute->Next(); + } + } child = child->NextSiblingElement(); } + + flatbuffers::BlendFunc f_blendFunc(blendFunc.src, blendFunc.dst); auto options = CreateSpriteOptions(*builder, nodeOptions, CreateResourceData(*builder, builder->CreateString(path), builder->CreateString(plistFile), - resourceType) - ); + resourceType), + &f_blendFunc); return *(Offset
*)(&options); } @@ -208,6 +233,15 @@ namespace cocostudio sprite->addChild(label); } + auto f_blendFunc = options->blendFunc(); + if (f_blendFunc) + { + cocos2d::BlendFunc blendFunc = cocos2d::BlendFunc::ALPHA_PREMULTIPLIED; + blendFunc.src = f_blendFunc->src(); + blendFunc.dst = f_blendFunc->dst(); + sprite->setBlendFunc(blendFunc); + } + auto nodeReader = NodeReader::getInstance(); nodeReader->setPropsWithFlatBuffers(node, (Table*)(options->nodeOptions())); diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp index a49119f261..88055deca7 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp @@ -164,6 +164,13 @@ namespace cocostudio int areaHeight = 0; int h_alignment = 0; int v_alignment = 0; + bool outlineEnabled = false; + Color4B outlineColor = Color4B::BLACK; + int outlineSize = 1; + bool shadowEnabled = false; + Color4B shadowColor = Color4B::BLACK; + Size shadowOffset = Size(2, -2); + int shadowBlurRadius = 0; std::string path = ""; std::string plistFile = ""; @@ -234,6 +241,30 @@ namespace cocostudio { isCustomSize = (value == "True") ? true : false; } + else if (name == "OutlineEnabled") + { + outlineEnabled = (value == "True") ? true : false; + } + else if (name == "OutlineSize") + { + outlineSize = atoi(value.c_str()); + } + else if (name == "ShadowEnabled") + { + shadowEnabled = (value == "True") ? true : false; + } + else if (name == "ShadowOffsetX") + { + shadowOffset.width = atof(value.c_str()); + } + else if (name == "ShadowOffsetY") + { + shadowOffset.height = atof(value.c_str()); + } + else if (name == "ShadowBlurRadius") + { + shadowBlurRadius = atoi(value.c_str()); + } attribute = attribute->Next(); } @@ -269,10 +300,71 @@ namespace cocostudio attribute = attribute->Next(); } } + else if (name == "OutlineColor") + { + attribute = child->FirstAttribute(); + + while (attribute) + { + name = attribute->Name(); + std::string value = attribute->Value(); + + if (name == "A") + { + outlineColor.a = atoi(value.c_str()); + } + else if (name == "R") + { + outlineColor.r = atoi(value.c_str()); + } + else if (name == "G") + { + outlineColor.g = atoi(value.c_str()); + } + else if (name == "B") + { + outlineColor.b = atoi(value.c_str()); + } + + attribute = attribute->Next(); + } + } + else if (name == "ShadowColor") + { + attribute = child->FirstAttribute(); + + while (attribute) + { + name = attribute->Name(); + std::string value = attribute->Value(); + + if (name == "A") + { + shadowColor.a = atoi(value.c_str()); + } + else if (name == "R") + { + shadowColor.r = atoi(value.c_str()); + } + else if (name == "G") + { + shadowColor.g = atoi(value.c_str()); + } + else if (name == "B") + { + shadowColor.b = atoi(value.c_str()); + } + + attribute = attribute->Next(); + } + } child = child->NextSiblingElement(); } + flatbuffers::Color f_outlineColor(outlineColor.a, outlineColor.r, outlineColor.g, outlineColor.b); + flatbuffers::Color f_shadowColor(shadowColor.a, shadowColor.r, shadowColor.g, shadowColor.b); + auto options = CreateTextOptions(*builder, widgetOptions, CreateResourceData(*builder, @@ -287,7 +379,15 @@ namespace cocostudio h_alignment, v_alignment, touchScaleEnabled, - isCustomSize); + isCustomSize, + outlineEnabled, + &f_outlineColor, + outlineSize, + shadowEnabled, + &f_shadowColor, + shadowOffset.width, + shadowOffset.height, + shadowBlurRadius); return *(Offset
*)(&options); } @@ -348,6 +448,29 @@ namespace cocostudio } } + bool outlineEnabled = options->outlineEnabled(); + if (outlineEnabled) + { + auto f_outlineColor = options->outlineColor(); + if (f_outlineColor) + { + Color4B outlineColor(f_outlineColor->a(), f_outlineColor->r(), f_outlineColor->g(), f_outlineColor->b()); + label->enableOutline(outlineColor, options->outlineSize()); + } + } + + bool shadowEnabled = options->shadowEnabled(); + if (shadowEnabled) + { + auto f_shadowColor = options->shadowColor(); + if (f_shadowColor) + { + Color4B shadowColor(f_shadowColor->a(), f_shadowColor->r(), f_shadowColor->g(), f_shadowColor->b()); + label->enableShadow(shadowColor, Size(options->shadowOffsetX(), options->shadowOffsetY()), options->shadowBlurRadius()); + } + } + + auto widgetReader = WidgetReader::getInstance(); widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); diff --git a/cocos/math/Vec3.cpp b/cocos/math/Vec3.cpp index 63955842c0..b760cebd31 100644 --- a/cocos/math/Vec3.cpp +++ b/cocos/math/Vec3.cpp @@ -68,16 +68,6 @@ Vec3::~Vec3() { } -bool Vec3::isZero() const -{ - return x == 0.0f && y == 0.0f && z == 0.0f; -} - -bool Vec3::isOne() const -{ - return x == 1.0f && y == 1.0f && z == 1.0f; -} - float Vec3::angle(const Vec3& v1, const Vec3& v2) { float dx = v1.y * v2.z - v1.z * v2.y; @@ -87,13 +77,6 @@ float Vec3::angle(const Vec3& v1, const Vec3& v2) return atan2f(sqrt(dx * dx + dy * dy + dz * dz) + MATH_FLOAT_SMALL, dot(v1, v2)); } -void Vec3::add(const Vec3& v) -{ - x += v.x; - y += v.y; - z += v.z; -} - void Vec3::add(const Vec3& v1, const Vec3& v2, Vec3* dst) { GP_ASSERT(dst); @@ -196,23 +179,6 @@ float Vec3::dot(const Vec3& v1, const Vec3& v2) return (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z); } -float Vec3::length() const -{ - return sqrt(x * x + y * y + z * z); -} - -float Vec3::lengthSquared() const -{ - return (x * x + y * y + z * z); -} - -void Vec3::negate() -{ - x = -x; - y = -y; - z = -z; -} - void Vec3::normalize() { float n = x * x + y * y + z * z; @@ -238,50 +204,6 @@ Vec3 Vec3::getNormalized() const return v; } -void Vec3::scale(float scalar) -{ - x *= scalar; - y *= scalar; - z *= scalar; -} - -void Vec3::set(float xx, float yy, float zz) -{ - this->x = xx; - this->y = yy; - this->z = zz; -} - -void Vec3::set(const float* array) -{ - GP_ASSERT(array); - - x = array[0]; - y = array[1]; - z = array[2]; -} - -void Vec3::set(const Vec3& v) -{ - this->x = v.x; - this->y = v.y; - this->z = v.z; -} - -void Vec3::set(const Vec3& p1, const Vec3& p2) -{ - x = p2.x - p1.x; - y = p2.y - p1.y; - z = p2.z - p1.z; -} - -void Vec3::subtract(const Vec3& v) -{ - x -= v.x; - y -= v.y; - z -= v.z; -} - void Vec3::subtract(const Vec3& v1, const Vec3& v2, Vec3* dst) { GP_ASSERT(dst); @@ -299,10 +221,10 @@ void Vec3::smooth(const Vec3& target, float elapsedTime, float responseTime) } } -const Vec3 Vec3::ZERO = Vec3(0.0f, 0.0f, 0.0f); -const Vec3 Vec3::ONE = Vec3(1.0f, 1.0f, 1.0f); -const Vec3 Vec3::UNIT_X = Vec3(1.0f, 0.0f, 0.0f); -const Vec3 Vec3::UNIT_Y = Vec3(0.0f, 1.0f, 0.0f); -const Vec3 Vec3::UNIT_Z = Vec3(0.0f, 0.0f, 1.0f); +const Vec3 Vec3::ZERO(0.0f, 0.0f, 0.0f); +const Vec3 Vec3::ONE(1.0f, 1.0f, 1.0f); +const Vec3 Vec3::UNIT_X(1.0f, 0.0f, 0.0f); +const Vec3 Vec3::UNIT_Y(0.0f, 1.0f, 0.0f); +const Vec3 Vec3::UNIT_Z(0.0f, 0.0f, 1.0f); NS_CC_MATH_END diff --git a/cocos/math/Vec3.h b/cocos/math/Vec3.h index 62cc570afe..95fedaad5b 100644 --- a/cocos/math/Vec3.h +++ b/cocos/math/Vec3.h @@ -118,14 +118,14 @@ public: * * @return true if this vector contains all zeros, false otherwise. */ - bool isZero() const; + inline bool isZero() const; /** * Indicates whether this vector contains all ones. * * @return true if this vector contains all ones, false otherwise. */ - bool isOne() const; + inline bool isOne() const; /** * Returns the angle (in radians) between the specified vectors. @@ -143,7 +143,17 @@ public: * * @param v The vector to add. */ - void add(const Vec3& v); + inline void add(const Vec3& v); + + + /** + * Adds the elements of this vector to the specified values. + * + * @param xx The add x coordinate. + * @param yy The add y coordinate. + * @param zz The add z coordinate. + */ + inline void add(float xx, float yy, float zz); /** * Adds the specified vectors and stores the result in dst. @@ -241,7 +251,7 @@ public: * * @see lengthSquared */ - float length() const; + inline float length() const; /** * Returns the squared length of this vector. @@ -255,12 +265,12 @@ public: * * @see length */ - float lengthSquared() const; + inline float lengthSquared() const; /** * Negates this vector. */ - void negate(); + inline void negate(); /** * Normalizes this vector. @@ -285,7 +295,7 @@ public: * * @param scalar The scalar value. */ - void scale(float scalar); + inline void scale(float scalar); /** * Sets the elements of this vector to the specified values. @@ -294,26 +304,31 @@ public: * @param yy The new y coordinate. * @param zz The new z coordinate. */ - void set(float xx, float yy, float zz); + inline void set(float xx, float yy, float zz); /** * Sets the elements of this vector from the values in the specified array. * * @param array An array containing the elements of the vector in the order x, y, z. */ - void set(const float* array); + inline void set(const float* array); /** * Sets the elements of this vector to those in the specified vector. * * @param v The vector to copy. */ - void set(const Vec3& v); + inline void set(const Vec3& v); /** * Sets this vector to the directional vector between the specified points. */ - void set(const Vec3& p1, const Vec3& p2); + inline void set(const Vec3& p1, const Vec3& p2); + + /** + * Sets the elements of this vector to zero. + */ + inline void setZero(); /** * Subtracts this vector and the specified vector as (this - v) @@ -321,7 +336,7 @@ public: * * @param v The vector to subtract. */ - void subtract(const Vec3& v); + inline void subtract(const Vec3& v); /** * Subtracts the specified vectors and stores the result in dst. diff --git a/cocos/math/Vec3.inl b/cocos/math/Vec3.inl index e99ee2a774..bf3422108c 100644 --- a/cocos/math/Vec3.inl +++ b/cocos/math/Vec3.inl @@ -23,6 +23,97 @@ NS_CC_MATH_BEGIN + +inline bool Vec3::isZero() const +{ + return x == 0.0f && y == 0.0f && z == 0.0f; +} + +inline bool Vec3::isOne() const +{ + return x == 1.0f && y == 1.0f && z == 1.0f; +} + +inline void Vec3::add(const Vec3& v) +{ + x += v.x; + y += v.y; + z += v.z; +} + +inline void Vec3::add(float xx, float yy, float zz) +{ + x += xx; + y += yy; + z += zz; +} + +inline float Vec3::length() const +{ + return sqrt(x * x + y * y + z * z); +} + +inline float Vec3::lengthSquared() const +{ + return (x * x + y * y + z * z); +} + +inline void Vec3::negate() +{ + x = -x; + y = -y; + z = -z; +} + +inline void Vec3::scale(float scalar) +{ + x *= scalar; + y *= scalar; + z *= scalar; +} + +inline void Vec3::set(float xx, float yy, float zz) +{ + this->x = xx; + this->y = yy; + this->z = zz; +} + +inline void Vec3::set(const float* array) +{ + GP_ASSERT(array); + + x = array[0]; + y = array[1]; + z = array[2]; +} + +inline void Vec3::set(const Vec3& v) +{ + this->x = v.x; + this->y = v.y; + this->z = v.z; +} + +inline void Vec3::set(const Vec3& p1, const Vec3& p2) +{ + x = p2.x - p1.x; + y = p2.y - p1.y; + z = p2.z - p1.z; +} + +inline void Vec3::setZero() +{ + x = y = z = 0.0f; +} + +inline void Vec3::subtract(const Vec3& v) +{ + x -= v.x; + y -= v.y; + z -= v.z; +} + inline const Vec3 Vec3::operator+(const Vec3& v) const { Vec3 result(*this); diff --git a/cocos/platform/CCFileUtils.cpp b/cocos/platform/CCFileUtils.cpp index 738aedb986..687065359d 100644 --- a/cocos/platform/CCFileUtils.cpp +++ b/cocos/platform/CCFileUtils.cpp @@ -713,7 +713,7 @@ std::string FileUtils::getNewFilename(const std::string &filename) const return newFileName; } -std::string FileUtils::getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) +std::string FileUtils::getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) const { std::string file = filename; std::string file_path = ""; @@ -735,7 +735,7 @@ std::string FileUtils::getPathForFilename(const std::string& filename, const std return path; } -std::string FileUtils::fullPathForFilename(const std::string &filename) +std::string FileUtils::fullPathForFilename(const std::string &filename) const { if (filename.empty()) { @@ -926,7 +926,7 @@ void FileUtils::loadFilenameLookupDictionaryFromFile(const std::string &filename } } -std::string FileUtils::getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename) +std::string FileUtils::getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename) const { // get directory+filename, safely adding '/' as necessary std::string ret = directory; @@ -948,7 +948,7 @@ std::string FileUtils::searchFullPathForFilename(const std::string& filename) co { return filename; } - std::string path = const_cast(this)->fullPathForFilename(filename); + std::string path = fullPathForFilename(filename); if (0 == path.compare(filename)) { return ""; @@ -1010,7 +1010,7 @@ bool FileUtils::isDirectoryExistInternal(const std::string& dirPath) const } -bool FileUtils::isDirectoryExist(const std::string& dirPath) +bool FileUtils::isDirectoryExist(const std::string& dirPath) const { CCASSERT(!dirPath.empty(), "Invalid path"); @@ -1035,7 +1035,7 @@ bool FileUtils::isDirectoryExist(const std::string& dirPath) fullpath = searchIt + dirPath + resolutionIt; if (isDirectoryExistInternal(fullpath)) { - const_cast(this)->_fullPathCache.insert(std::make_pair(dirPath, fullpath)); + _fullPathCache.insert(std::make_pair(dirPath, fullpath)); return true; } } @@ -1359,7 +1359,7 @@ void FileUtils::setPopupNotify(bool notify) s_popupNotify = notify; } -bool FileUtils::isPopupNotify() +bool FileUtils::isPopupNotify() const { return s_popupNotify; } diff --git a/cocos/platform/CCFileUtils.h b/cocos/platform/CCFileUtils.h index 53dc6aac44..62474c2a62 100644 --- a/cocos/platform/CCFileUtils.h +++ b/cocos/platform/CCFileUtils.h @@ -166,7 +166,7 @@ public: @since v2.1 */ - virtual std::string fullPathForFilename(const std::string &filename); + virtual std::string fullPathForFilename(const std::string &filename) const; /** * Loads the filenameLookup dictionary from the contents of a filename. @@ -311,7 +311,7 @@ public: /** Checks whether to pop up a message box when failed to load an image. * @return True if pop up a message box when failed to load an image, false if not. */ - virtual bool isPopupNotify(); + virtual bool isPopupNotify() const; /** * Converts the contents of a file to a ValueMap. @@ -360,7 +360,7 @@ public: * @param dirPath The path of the directory, it could be a relative or an absolute path. * @return True if the directory exists, false if not. */ - virtual bool isDirectoryExist(const std::string& dirPath); + virtual bool isDirectoryExist(const std::string& dirPath) const; /** * Creates a directory. @@ -455,7 +455,7 @@ protected: * @param searchPath The search path. * @return The full path of the file. It will return an empty string if the full path of the file doesn't exist. */ - virtual std::string getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath); + virtual std::string getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) const; /** * Gets full path for the directory and the filename. @@ -467,13 +467,12 @@ protected: * @param filename The name of the file. * @return The full path of the file, if the file can't be found, it will return an empty string. */ - virtual std::string getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename); + virtual std::string getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename) const; /** * Returns the fullpath for a given filename. - * This is an alternative for fullPathForFilename, there are two main differences: - * First, it returns empty string instead of the original filename when no file found for the given name. - * Secondly, it's a const function. + * This is an alternative for fullPathForFilename + * It returns empty string instead of the original filename when no file found for the given name. * @param filename The file name to look up for * @return The full path for the file, if not found, the return value will be an empty string */ @@ -514,7 +513,7 @@ protected: * The full path cache. When a file is found, it will be added into this cache. * This variable is used for improving the performance of file search. */ - std::unordered_map _fullPathCache; + mutable std::unordered_map _fullPathCache; /** * Writable path. diff --git a/cocos/platform/CCImage.cpp b/cocos/platform/CCImage.cpp index 5d8f86e89a..d2fcf9b9ce 100644 --- a/cocos/platform/CCImage.cpp +++ b/cocos/platform/CCImage.cpp @@ -635,7 +635,6 @@ bool Image::isS3TC(const unsigned char * data, ssize_t dataLen) if (strncmp(header->fileCode, "DDS", 3) != 0) { - CCLOG("cocos2d: the file is not a dds file!"); return false; } return true; @@ -647,7 +646,6 @@ bool Image::isATITC(const unsigned char *data, ssize_t dataLen) if (strncmp(&header->identifier[1], "KTX", 3) != 0) { - CCLOG("cocos3d: the file is not a ktx file!"); return false; } return true; @@ -742,6 +740,7 @@ Image::Format Image::detectFormat(const unsigned char * data, ssize_t dataLen) } else { + CCLOG("cocos2d: can't detect image format"); return Format::UNKNOWN; } } diff --git a/cocos/platform/apple/CCFileUtils-apple.h b/cocos/platform/apple/CCFileUtils-apple.h index 41c24328cc..9838947bfc 100644 --- a/cocos/platform/apple/CCFileUtils-apple.h +++ b/cocos/platform/apple/CCFileUtils-apple.h @@ -47,7 +47,7 @@ public: FileUtilsApple(); /* override funtions */ virtual std::string getWritablePath() const override; - virtual std::string getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename) override; + virtual std::string getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename) const override; virtual ValueMap getValueMapFromFile(const std::string& filename) override; virtual ValueMap getValueMapFromData(const char* filedata, int filesize); diff --git a/cocos/platform/apple/CCFileUtils-apple.mm b/cocos/platform/apple/CCFileUtils-apple.mm index 08bbb5567d..a12f4f7966 100644 --- a/cocos/platform/apple/CCFileUtils-apple.mm +++ b/cocos/platform/apple/CCFileUtils-apple.mm @@ -392,7 +392,7 @@ bool FileUtilsApple::isFileExistInternal(const std::string& filePath) const return ret; } -std::string FileUtilsApple::getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename) +std::string FileUtilsApple::getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename) const { if (directory[0] != '/') { diff --git a/cocos/platform/ios/CCApplication-ios.mm b/cocos/platform/ios/CCApplication-ios.mm index 0d515a575f..b085e00ed6 100644 --- a/cocos/platform/ios/CCApplication-ios.mm +++ b/cocos/platform/ios/CCApplication-ios.mm @@ -104,67 +104,27 @@ LanguageType Application::getCurrentLanguage() NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage]; NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode]; - LanguageType ret = LanguageType::ENGLISH; - if ([languageCode isEqualToString:@"zh"]) - { - ret = LanguageType::CHINESE; - } - else if ([languageCode isEqualToString:@"en"]) - { - ret = LanguageType::ENGLISH; - } - else if ([languageCode isEqualToString:@"fr"]){ - ret = LanguageType::FRENCH; - } - else if ([languageCode isEqualToString:@"it"]){ - ret = LanguageType::ITALIAN; - } - else if ([languageCode isEqualToString:@"de"]){ - ret = LanguageType::GERMAN; - } - else if ([languageCode isEqualToString:@"es"]){ - ret = LanguageType::SPANISH; - } - else if ([languageCode isEqualToString:@"nl"]){ - ret = LanguageType::DUTCH; - } - else if ([languageCode isEqualToString:@"ru"]){ - ret = LanguageType::RUSSIAN; - } - else if ([languageCode isEqualToString:@"ko"]){ - ret = LanguageType::KOREAN; - } - else if ([languageCode isEqualToString:@"ja"]){ - ret = LanguageType::JAPANESE; - } - else if ([languageCode isEqualToString:@"hu"]){ - ret = LanguageType::HUNGARIAN; - } - else if ([languageCode isEqualToString:@"pt"]){ - ret = LanguageType::PORTUGUESE; - } - else if ([languageCode isEqualToString:@"ar"]){ - ret = LanguageType::ARABIC; - } - else if ([languageCode isEqualToString:@"nb"]){ - ret = LanguageType::NORWEGIAN; - } - else if ([languageCode isEqualToString:@"pl"]){ - ret = LanguageType::POLISH; - } - else if ([languageCode isEqualToString:@"tr"]){ - ret = LanguageType::TURKISH; - } - else if ([languageCode isEqualToString:@"uk"]){ - ret = LanguageType::UKRAINIAN; - } - else if ([languageCode isEqualToString:@"ro"]){ - ret = LanguageType::ROMANIAN; - } - else if ([languageCode isEqualToString:@"bg"]){ - ret = LanguageType::BULGARIAN; - } - return ret; + if ([languageCode isEqualToString:@"zh"]) return LanguageType::CHINESE; + if ([languageCode isEqualToString:@"en"]) return LanguageType::ENGLISH; + if ([languageCode isEqualToString:@"fr"]) return LanguageType::FRENCH; + if ([languageCode isEqualToString:@"it"]) return LanguageType::ITALIAN; + if ([languageCode isEqualToString:@"de"]) return LanguageType::GERMAN; + if ([languageCode isEqualToString:@"es"]) return LanguageType::SPANISH; + if ([languageCode isEqualToString:@"nl"]) return LanguageType::DUTCH; + if ([languageCode isEqualToString:@"ru"]) return LanguageType::RUSSIAN; + if ([languageCode isEqualToString:@"ko"]) return LanguageType::KOREAN; + if ([languageCode isEqualToString:@"ja"]) return LanguageType::JAPANESE; + if ([languageCode isEqualToString:@"hu"]) return LanguageType::HUNGARIAN; + if ([languageCode isEqualToString:@"pt"]) return LanguageType::PORTUGUESE; + if ([languageCode isEqualToString:@"ar"]) return LanguageType::ARABIC; + if ([languageCode isEqualToString:@"nb"]) return LanguageType::NORWEGIAN; + if ([languageCode isEqualToString:@"pl"]) return LanguageType::POLISH; + if ([languageCode isEqualToString:@"tr"]) return LanguageType::TURKISH; + if ([languageCode isEqualToString:@"uk"]) return LanguageType::UKRAINIAN; + if ([languageCode isEqualToString:@"ro"]) return LanguageType::ROMANIAN; + if ([languageCode isEqualToString:@"bg"]) return LanguageType::BULGARIAN; + return LanguageType::ENGLISH; + } Application::Platform Application::getTargetPlatform() diff --git a/cocos/platform/mac/CCApplication-mac.mm b/cocos/platform/mac/CCApplication-mac.mm index 8593d58b7e..001f7f515c 100644 --- a/cocos/platform/mac/CCApplication-mac.mm +++ b/cocos/platform/mac/CCApplication-mac.mm @@ -160,65 +160,27 @@ LanguageType Application::getCurrentLanguage() NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage]; NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode]; - LanguageType ret = LanguageType::ENGLISH; - if ([languageCode isEqualToString:@"zh"]){ - ret = LanguageType::CHINESE; - } - else if ([languageCode isEqualToString:@"en"]){ - ret = LanguageType::ENGLISH; - } - else if ([languageCode isEqualToString:@"fr"]){ - ret = LanguageType::FRENCH; - } - else if ([languageCode isEqualToString:@"it"]){ - ret = LanguageType::ITALIAN; - } - else if ([languageCode isEqualToString:@"de"]){ - ret = LanguageType::GERMAN; - } - else if ([languageCode isEqualToString:@"es"]){ - ret = LanguageType::SPANISH; - } - else if ([languageCode isEqualToString:@"nl"]){ - ret = LanguageType::DUTCH; - } - else if ([languageCode isEqualToString:@"ru"]){ - ret = LanguageType::RUSSIAN; - } - else if ([languageCode isEqualToString:@"ko"]){ - ret = LanguageType::KOREAN; - } - else if ([languageCode isEqualToString:@"ja"]){ - ret = LanguageType::JAPANESE; - } - else if ([languageCode isEqualToString:@"hu"]){ - ret = LanguageType::HUNGARIAN; - } - else if ([languageCode isEqualToString:@"pt"]){ - ret = LanguageType::PORTUGUESE; - } - else if ([languageCode isEqualToString:@"ar"]){ - ret = LanguageType::ARABIC; - } - else if ([languageCode isEqualToString:@"nb"]){ - ret = LanguageType::NORWEGIAN; - } - else if ([languageCode isEqualToString:@"pl"]){ - ret = LanguageType::POLISH; - } - else if ([languageCode isEqualToString:@"tr"]){ - ret = LanguageType::TURKISH; - } - else if ([languageCode isEqualToString:@"uk"]){ - ret = LanguageType::UKRAINIAN; - } - else if ([languageCode isEqualToString:@"ro"]){ - ret = LanguageType::ROMANIAN; - } - else if ([languageCode isEqualToString:@"bg"]){ - ret = LanguageType::BULGARIAN; - } - return ret; + if ([languageCode isEqualToString:@"zh"]) return LanguageType::CHINESE; + if ([languageCode isEqualToString:@"en"]) return LanguageType::ENGLISH; + if ([languageCode isEqualToString:@"fr"]) return LanguageType::FRENCH; + if ([languageCode isEqualToString:@"it"]) return LanguageType::ITALIAN; + if ([languageCode isEqualToString:@"de"]) return LanguageType::GERMAN; + if ([languageCode isEqualToString:@"es"]) return LanguageType::SPANISH; + if ([languageCode isEqualToString:@"nl"]) return LanguageType::DUTCH; + if ([languageCode isEqualToString:@"ru"]) return LanguageType::RUSSIAN; + if ([languageCode isEqualToString:@"ko"]) return LanguageType::KOREAN; + if ([languageCode isEqualToString:@"ja"]) return LanguageType::JAPANESE; + if ([languageCode isEqualToString:@"hu"]) return LanguageType::HUNGARIAN; + if ([languageCode isEqualToString:@"pt"]) return LanguageType::PORTUGUESE; + if ([languageCode isEqualToString:@"ar"]) return LanguageType::ARABIC; + if ([languageCode isEqualToString:@"nb"]) return LanguageType::NORWEGIAN; + if ([languageCode isEqualToString:@"pl"]) return LanguageType::POLISH; + if ([languageCode isEqualToString:@"tr"]) return LanguageType::TURKISH; + if ([languageCode isEqualToString:@"uk"]) return LanguageType::UKRAINIAN; + if ([languageCode isEqualToString:@"ro"]) return LanguageType::ROMANIAN; + if ([languageCode isEqualToString:@"bg"]) return LanguageType::BULGARIAN; + return LanguageType::ENGLISH; + } bool Application::openURL(const std::string &url) diff --git a/cocos/platform/win32/CCFileUtils-win32.cpp b/cocos/platform/win32/CCFileUtils-win32.cpp index 3403d6f8fa..7ed1ed8c1f 100644 --- a/cocos/platform/win32/CCFileUtils-win32.cpp +++ b/cocos/platform/win32/CCFileUtils-win32.cpp @@ -264,7 +264,7 @@ unsigned char* FileUtilsWin32::getFileData(const std::string& filename, const ch return pBuffer; } -std::string FileUtilsWin32::getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) +std::string FileUtilsWin32::getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) const { std::string unixFileName = convertPathFormatToUnixStyle(filename); std::string unixResolutionDirectory = convertPathFormatToUnixStyle(resolutionDirectory); @@ -273,7 +273,7 @@ std::string FileUtilsWin32::getPathForFilename(const std::string& filename, cons return FileUtils::getPathForFilename(unixFileName, unixResolutionDirectory, unixSearchPath); } -std::string FileUtilsWin32::getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) +std::string FileUtilsWin32::getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) const { std::string unixDirectory = convertPathFormatToUnixStyle(strDirectory); std::string unixFilename = convertPathFormatToUnixStyle(strFilename); diff --git a/cocos/platform/win32/CCFileUtils-win32.h b/cocos/platform/win32/CCFileUtils-win32.h index 9495888be4..17f6c1ec01 100644 --- a/cocos/platform/win32/CCFileUtils-win32.h +++ b/cocos/platform/win32/CCFileUtils-win32.h @@ -85,7 +85,7 @@ protected: * @param searchPath The search path. * @return The full path of the file. It will return an empty string if the full path of the file doesn't exist. */ - virtual std::string getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) override; + virtual std::string getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) const override; /** * Gets full path for the directory and the filename. @@ -97,7 +97,7 @@ protected: * @param filename The name of the file. * @return The full path of the file, if the file can't be found, it will return an empty string. */ - virtual std::string getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename) override; + virtual std::string getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename) const override; }; diff --git a/cocos/platform/winrt/CCFileUtilsWinRT.cpp b/cocos/platform/winrt/CCFileUtilsWinRT.cpp index 736a597504..e2468df9a2 100644 --- a/cocos/platform/winrt/CCFileUtilsWinRT.cpp +++ b/cocos/platform/winrt/CCFileUtilsWinRT.cpp @@ -84,7 +84,7 @@ bool CCFileUtilsWinRT::init() return FileUtils::init(); } -std::string CCFileUtilsWinRT::getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) +std::string CCFileUtilsWinRT::getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) const { std::string unixFileName = convertPathFormatToUnixStyle(filename); std::string unixResolutionDirectory = convertPathFormatToUnixStyle(resolutionDirectory); @@ -93,7 +93,7 @@ std::string CCFileUtilsWinRT::getPathForFilename(const std::string& filename, co return FileUtils::getPathForFilename(unixFileName, unixResolutionDirectory, unixSearchPath); } -std::string CCFileUtilsWinRT::getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) +std::string CCFileUtilsWinRT::getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) const { std::string unixDirectory = convertPathFormatToUnixStyle(strDirectory); std::string unixFilename = convertPathFormatToUnixStyle(strFilename); diff --git a/cocos/platform/winrt/CCFileUtilsWinRT.h b/cocos/platform/winrt/CCFileUtilsWinRT.h index e2054cc91b..90b450a084 100644 --- a/cocos/platform/winrt/CCFileUtilsWinRT.h +++ b/cocos/platform/winrt/CCFileUtilsWinRT.h @@ -49,8 +49,8 @@ public: bool init(); virtual std::string getWritablePath() const; virtual bool isAbsolutePath(const std::string& strPath) const; - virtual std::string getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) override; - virtual std::string getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) override; + virtual std::string getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) const override; + virtual std::string getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) const override; virtual std::string getStringFromFile(const std::string& filename) override; static std::string getAppPath(); diff --git a/cocos/platform/winrt/CCFreeTypeFont.h b/cocos/platform/winrt/CCFreeTypeFont.h index 8f2ce1129e..abc9dfa8a0 100644 --- a/cocos/platform/winrt/CCFreeTypeFont.h +++ b/cocos/platform/winrt/CCFreeTypeFont.h @@ -35,10 +35,10 @@ THE SOFTWARE. #define generic GenericFromFreeTypeLibrary #define internal InternalFromFreeTypeLibrary #include -#include -#include -#include -#include +#include +#include +#include +#include #undef generic #undef internal diff --git a/cocos/renderer/CCMeshCommand.cpp b/cocos/renderer/CCMeshCommand.cpp index a8e8b4bde9..3905c2233a 100644 --- a/cocos/renderer/CCMeshCommand.cpp +++ b/cocos/renderer/CCMeshCommand.cpp @@ -423,7 +423,7 @@ void MeshCommand::setLightUniforms() Vec3 dir = dirLight->getDirectionInWorld(); dir.normalize(); const Color3B &col = dirLight->getDisplayedColor(); - s_dirLightUniformColorValues[enabledDirLightNum] = Vec3(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); + s_dirLightUniformColorValues[enabledDirLightNum].set(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); s_dirLightUniformDirValues[enabledDirLightNum] = dir; ++enabledDirLightNum; } @@ -437,8 +437,8 @@ void MeshCommand::setLightUniforms() auto pointLight = static_cast(light); Mat4 mat= pointLight->getNodeToWorldTransform(); const Color3B &col = pointLight->getDisplayedColor(); - s_pointLightUniformColorValues[enabledPointLightNum] = Vec3(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); - s_pointLightUniformPositionValues[enabledPointLightNum] = Vec3(mat.m[12], mat.m[13], mat.m[14]); + s_pointLightUniformColorValues[enabledPointLightNum].set(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); + s_pointLightUniformPositionValues[enabledPointLightNum].set(mat.m[12], mat.m[13], mat.m[14]); s_pointLightUniformRangeInverseValues[enabledPointLightNum] = 1.0f / pointLight->getRange(); ++enabledPointLightNum; } @@ -453,8 +453,8 @@ void MeshCommand::setLightUniforms() dir.normalize(); Mat4 mat= light->getNodeToWorldTransform(); const Color3B &col = spotLight->getDisplayedColor(); - s_spotLightUniformColorValues[enabledSpotLightNum] = Vec3(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); - s_spotLightUniformPositionValues[enabledSpotLightNum] = Vec3(mat.m[12], mat.m[13], mat.m[14]); + s_spotLightUniformColorValues[enabledSpotLightNum].set(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); + s_spotLightUniformPositionValues[enabledSpotLightNum].set(mat.m[12], mat.m[13], mat.m[14]); s_spotLightUniformDirValues[enabledSpotLightNum] = dir; s_spotLightUniformInnerAngleCosValues[enabledSpotLightNum] = spotLight->getCosInnerAngle(); s_spotLightUniformOuterAngleCosValues[enabledSpotLightNum] = spotLight->getCosOuterAngle(); @@ -467,7 +467,7 @@ void MeshCommand::setLightUniforms() { auto ambLight = static_cast(light); const Color3B &col = ambLight->getDisplayedColor(); - ambientColor += Vec3(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); + ambientColor.add(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); } break; default: diff --git a/cocos/scripting/lua-bindings/auto/api/Label.lua b/cocos/scripting/lua-bindings/auto/api/Label.lua index 5d280171be..5102674cfb 100644 --- a/cocos/scripting/lua-bindings/auto/api/Label.lua +++ b/cocos/scripting/lua-bindings/auto/api/Label.lua @@ -38,11 +38,13 @@ -- @return float#float ret (return value: float) -------------------------------- --- Disable all effect to Label. --- @function [parent=#Label] disableEffect +-- @overload self, int +-- @overload self +-- @function [parent=#Label] disableEffect -- @param self +-- @param #int effect -- @return Label#Label self (return value: cc.Label) - + -------------------------------- -- Sets a new TTF configuration to Label.
-- see `TTFConfig` diff --git a/cocos/scripting/lua-bindings/auto/api/Terrain.lua b/cocos/scripting/lua-bindings/auto/api/Terrain.lua new file mode 100644 index 0000000000..193806ea1f --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/Terrain.lua @@ -0,0 +1,134 @@ + +-------------------------------- +-- @module Terrain +-- @extend Node +-- @parent_module cc + +-------------------------------- +-- initialize heightMap data +-- @function [parent=#Terrain] initHeightMap +-- @param self +-- @param #char heightMap +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- set the MaxDetailAmount. +-- @function [parent=#Terrain] setMaxDetailMapAmount +-- @param self +-- @param #int maxValue +-- @return Terrain#Terrain self (return value: cc.Terrain) + +-------------------------------- +-- show the wireline instead of the surface,Debug Use only.
+-- Note only support desktop platform +-- @function [parent=#Terrain] setDrawWire +-- @param self +-- @param #bool boolValue +-- @return Terrain#Terrain self (return value: cc.Terrain) + +-------------------------------- +-- Switch frustum Culling Flag
+-- Note frustum culling will remarkable improve your terrain rendering performance. +-- @function [parent=#Terrain] setIsEnableFrustumCull +-- @param self +-- @param #bool boolValue +-- @return Terrain#Terrain self (return value: cc.Terrain) + +-------------------------------- +-- set the Detail Map +-- @function [parent=#Terrain] setDetailMap +-- @param self +-- @param #unsigned int index +-- @param #cc.Terrain::DetailMap detailMap +-- @return Terrain#Terrain self (return value: cc.Terrain) + +-------------------------------- +-- reset the heightmap data. +-- @function [parent=#Terrain] resetHeightMap +-- @param self +-- @param #char heightMap +-- @return Terrain#Terrain self (return value: cc.Terrain) + +-------------------------------- +-- set the alpha map +-- @function [parent=#Terrain] setAlphaMap +-- @param self +-- @param #cc.Texture2D newAlphaMapTexture +-- @return Terrain#Terrain self (return value: cc.Terrain) + +-------------------------------- +-- set the skirt height ratio +-- @function [parent=#Terrain] setSkirtHeightRatio +-- @param self +-- @param #float ratio +-- @return Terrain#Terrain self (return value: cc.Terrain) + +-------------------------------- +-- Convert a world Space position (X,Z) to terrain space position (X,Z) +-- @function [parent=#Terrain] convertToTerrainSpace +-- @param self +-- @param #vec2_table worldSpace +-- @return vec2_table#vec2_table ret (return value: vec2_table) + +-------------------------------- +-- initialize alphaMap ,detailMaps textures +-- @function [parent=#Terrain] initTextures +-- @param self +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- initialize all Properties which terrain need +-- @function [parent=#Terrain] initProperties +-- @param self +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- Set threshold distance of each LOD level,must equal or gereater than the chunk size
+-- Note when invoke initHeightMap, the LOD distance will be automatic calculated. +-- @function [parent=#Terrain] setLODDistance +-- @param self +-- @param #float lod1 +-- @param #float lod2 +-- @param #float lod3 +-- @return Terrain#Terrain self (return value: cc.Terrain) + +-------------------------------- +-- get the normal of the specified pistion in terrain
+-- return the normal vector of the specified position of the terrain.
+-- note the fast normal calculation may not get precise normal vector. +-- @function [parent=#Terrain] getNormal +-- @param self +-- @param #int pixelX +-- @param #int pixelY +-- @return vec3_table#vec3_table ret (return value: vec3_table) + +-------------------------------- +-- get height from the raw height filed +-- @function [parent=#Terrain] getImageHeight +-- @param self +-- @param #int pixelX +-- @param #int pixelY +-- @return float#float ret (return value: float) + +-------------------------------- +-- get the terrain's maximum height. +-- @function [parent=#Terrain] getMaxHeight +-- @param self +-- @return float#float ret (return value: float) + +-------------------------------- +-- get the terrain's mininal height. +-- @function [parent=#Terrain] getMinHeight +-- @param self +-- @return float#float ret (return value: float) + +-------------------------------- +-- +-- @function [parent=#Terrain] draw +-- @param self +-- @param #cc.Renderer renderer +-- @param #mat4_table transform +-- @param #unsigned int flags +-- @return Terrain#Terrain self (return value: cc.Terrain) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/TransitionScene.lua b/cocos/scripting/lua-bindings/auto/api/TransitionScene.lua index d23f226b0c..260978a23f 100644 --- a/cocos/scripting/lua-bindings/auto/api/TransitionScene.lua +++ b/cocos/scripting/lua-bindings/auto/api/TransitionScene.lua @@ -4,12 +4,24 @@ -- @extend Scene -- @parent_module cc +-------------------------------- +-- +-- @function [parent=#TransitionScene] getInScene +-- @param self +-- @return Scene#Scene ret (return value: cc.Scene) + -------------------------------- -- Called after the transition finishes. -- @function [parent=#TransitionScene] finish -- @param self -- @return TransitionScene#TransitionScene self (return value: cc.TransitionScene) +-------------------------------- +-- +-- @function [parent=#TransitionScene] getDuration +-- @param self +-- @return float#float ret (return value: float) + -------------------------------- -- Used by some transitions to hide the outer scene. -- @function [parent=#TransitionScene] hideOutShowIn diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua index 2c5598932b..9b0dc4aa3c 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua @@ -51,4 +51,9 @@ -- @field [parent=#cc] Skybox#Skybox Skybox preloaded module +-------------------------------------------------------- +-- the cc Terrain +-- @field [parent=#cc] Terrain#Terrain Terrain preloaded module + + return nil diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp index f98a0d603c..63ed4d4103 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp @@ -3408,6 +3408,845 @@ int lua_register_cocos2dx_3d_Skybox(lua_State* tolua_S) g_typeCast["Skybox"] = "cc.Skybox"; return 1; } + +int lua_cocos2dx_3d_Terrain_initHeightMap(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_initHeightMap'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + const char* arg0; + + std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "cc.Terrain:initHeightMap"); arg0 = arg0_tmp.c_str(); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_initHeightMap'", nullptr); + return 0; + } + bool ret = cobj->initHeightMap(arg0); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:initHeightMap",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_initHeightMap'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_setMaxDetailMapAmount(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_setMaxDetailMapAmount'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + int arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Terrain:setMaxDetailMapAmount"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_setMaxDetailMapAmount'", nullptr); + return 0; + } + cobj->setMaxDetailMapAmount(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:setMaxDetailMapAmount",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_setMaxDetailMapAmount'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_setDrawWire(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_setDrawWire'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Terrain:setDrawWire"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_setDrawWire'", nullptr); + return 0; + } + cobj->setDrawWire(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:setDrawWire",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_setDrawWire'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_setIsEnableFrustumCull(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_setIsEnableFrustumCull'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Terrain:setIsEnableFrustumCull"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_setIsEnableFrustumCull'", nullptr); + return 0; + } + cobj->setIsEnableFrustumCull(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:setIsEnableFrustumCull",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_setIsEnableFrustumCull'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_setDetailMap(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_setDetailMap'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + unsigned int arg0; + cocos2d::Terrain::DetailMap arg1; + + ok &= luaval_to_uint32(tolua_S, 2,&arg0, "cc.Terrain:setDetailMap"); + + #pragma warning NO CONVERSION TO NATIVE FOR DetailMap + ok = false; + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_setDetailMap'", nullptr); + return 0; + } + cobj->setDetailMap(arg0, arg1); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:setDetailMap",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_setDetailMap'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_resetHeightMap(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_resetHeightMap'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + const char* arg0; + + std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "cc.Terrain:resetHeightMap"); arg0 = arg0_tmp.c_str(); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_resetHeightMap'", nullptr); + return 0; + } + cobj->resetHeightMap(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:resetHeightMap",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_resetHeightMap'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_setAlphaMap(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_setAlphaMap'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Texture2D* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_setAlphaMap'", nullptr); + return 0; + } + cobj->setAlphaMap(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:setAlphaMap",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_setAlphaMap'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_setSkirtHeightRatio(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_setSkirtHeightRatio'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + double arg0; + + ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Terrain:setSkirtHeightRatio"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_setSkirtHeightRatio'", nullptr); + return 0; + } + cobj->setSkirtHeightRatio(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:setSkirtHeightRatio",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_setSkirtHeightRatio'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_convertToTerrainSpace(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_convertToTerrainSpace'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Vec2 arg0; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "cc.Terrain:convertToTerrainSpace"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_convertToTerrainSpace'", nullptr); + return 0; + } + cocos2d::Vec2 ret = cobj->convertToTerrainSpace(arg0); + vec2_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:convertToTerrainSpace",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_convertToTerrainSpace'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_initTextures(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_initTextures'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_initTextures'", nullptr); + return 0; + } + bool ret = cobj->initTextures(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:initTextures",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_initTextures'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_initProperties(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_initProperties'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_initProperties'", nullptr); + return 0; + } + bool ret = cobj->initProperties(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:initProperties",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_initProperties'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_setLODDistance(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_setLODDistance'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 3) + { + double arg0; + double arg1; + double arg2; + + ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Terrain:setLODDistance"); + + ok &= luaval_to_number(tolua_S, 3,&arg1, "cc.Terrain:setLODDistance"); + + ok &= luaval_to_number(tolua_S, 4,&arg2, "cc.Terrain:setLODDistance"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_setLODDistance'", nullptr); + return 0; + } + cobj->setLODDistance(arg0, arg1, arg2); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:setLODDistance",argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_setLODDistance'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_getNormal(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_getNormal'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + int arg0; + int arg1; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Terrain:getNormal"); + + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "cc.Terrain:getNormal"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_getNormal'", nullptr); + return 0; + } + cocos2d::Vec3 ret = cobj->getNormal(arg0, arg1); + vec3_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:getNormal",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_getNormal'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_getImageHeight(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_getImageHeight'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + int arg0; + int arg1; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Terrain:getImageHeight"); + + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "cc.Terrain:getImageHeight"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_getImageHeight'", nullptr); + return 0; + } + double ret = cobj->getImageHeight(arg0, arg1); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:getImageHeight",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_getImageHeight'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_getMaxHeight(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_getMaxHeight'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_getMaxHeight'", nullptr); + return 0; + } + double ret = cobj->getMaxHeight(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:getMaxHeight",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_getMaxHeight'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Terrain_getMinHeight(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Terrain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_getMinHeight'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_getMinHeight'", nullptr); + return 0; + } + double ret = cobj->getMinHeight(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:getMinHeight",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Terrain_getMinHeight'.",&tolua_err); +#endif + + return 0; +} +static int lua_cocos2dx_3d_Terrain_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (Terrain)"); + return 0; +} + +int lua_register_cocos2dx_3d_Terrain(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.Terrain"); + tolua_cclass(tolua_S,"Terrain","cc.Terrain","cc.Node",nullptr); + + tolua_beginmodule(tolua_S,"Terrain"); + tolua_function(tolua_S,"initHeightMap",lua_cocos2dx_3d_Terrain_initHeightMap); + tolua_function(tolua_S,"setMaxDetailMapAmount",lua_cocos2dx_3d_Terrain_setMaxDetailMapAmount); + tolua_function(tolua_S,"setDrawWire",lua_cocos2dx_3d_Terrain_setDrawWire); + tolua_function(tolua_S,"setIsEnableFrustumCull",lua_cocos2dx_3d_Terrain_setIsEnableFrustumCull); + tolua_function(tolua_S,"setDetailMap",lua_cocos2dx_3d_Terrain_setDetailMap); + tolua_function(tolua_S,"resetHeightMap",lua_cocos2dx_3d_Terrain_resetHeightMap); + tolua_function(tolua_S,"setAlphaMap",lua_cocos2dx_3d_Terrain_setAlphaMap); + tolua_function(tolua_S,"setSkirtHeightRatio",lua_cocos2dx_3d_Terrain_setSkirtHeightRatio); + tolua_function(tolua_S,"convertToTerrainSpace",lua_cocos2dx_3d_Terrain_convertToTerrainSpace); + tolua_function(tolua_S,"initTextures",lua_cocos2dx_3d_Terrain_initTextures); + tolua_function(tolua_S,"initProperties",lua_cocos2dx_3d_Terrain_initProperties); + tolua_function(tolua_S,"setLODDistance",lua_cocos2dx_3d_Terrain_setLODDistance); + tolua_function(tolua_S,"getNormal",lua_cocos2dx_3d_Terrain_getNormal); + tolua_function(tolua_S,"getImageHeight",lua_cocos2dx_3d_Terrain_getImageHeight); + tolua_function(tolua_S,"getMaxHeight",lua_cocos2dx_3d_Terrain_getMaxHeight); + tolua_function(tolua_S,"getMinHeight",lua_cocos2dx_3d_Terrain_getMinHeight); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::Terrain).name(); + g_luaType[typeName] = "cc.Terrain"; + g_typeCast["Terrain"] = "cc.Terrain"; + return 1; +} TOLUA_API int register_all_cocos2dx_3d(lua_State* tolua_S) { tolua_open(tolua_S); @@ -3420,6 +4259,7 @@ TOLUA_API int register_all_cocos2dx_3d(lua_State* tolua_S) lua_register_cocos2dx_3d_AttachNode(tolua_S); lua_register_cocos2dx_3d_TextureCube(tolua_S); lua_register_cocos2dx_3d_Sprite3DCache(tolua_S); + lua_register_cocos2dx_3d_Terrain(tolua_S); lua_register_cocos2dx_3d_Skybox(tolua_S); lua_register_cocos2dx_3d_BillBoard(tolua_S); lua_register_cocos2dx_3d_Animation3D(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp index 91b8d97322..52618ba4a0 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp @@ -68,6 +68,23 @@ int register_all_cocos2dx_3d(lua_State* tolua_S); + + + + + + + + + + + + + + + + + diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 9adc9c5ed1..6277804a01 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -38637,39 +38637,43 @@ int lua_cocos2dx_Label_disableEffect(lua_State* tolua_S) int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; - #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif - #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); - #if COCOS2D_DEBUG >= 1 - if (!cobj) + if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_disableEffect'", nullptr); return 0; } #endif - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_disableEffect'", nullptr); - return 0; + do{ + if (argc == 1) { + cocos2d::LabelEffect arg0; + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Label:disableEffect"); + + if (!ok) { break; } + cobj->disableEffect(arg0); + lua_settop(tolua_S, 1); + return 1; } - cobj->disableEffect(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:disableEffect",argc, 0); + }while(0); + ok = true; + do{ + if (argc == 0) { + cobj->disableEffect(); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:disableEffect",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -42303,6 +42307,53 @@ int lua_register_cocos2dx_TransitionEaseScene(lua_State* tolua_S) return 1; } +int lua_cocos2dx_TransitionScene_getInScene(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::TransitionScene* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.TransitionScene",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::TransitionScene*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionScene_getInScene'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_TransitionScene_getInScene'", nullptr); + return 0; + } + cocos2d::Scene* ret = cobj->getInScene(); + object_to_luaval(tolua_S, "cc.Scene",(cocos2d::Scene*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TransitionScene:getInScene",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionScene_getInScene'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_TransitionScene_finish(lua_State* tolua_S) { int argc = 0; @@ -42350,6 +42401,53 @@ int lua_cocos2dx_TransitionScene_finish(lua_State* tolua_S) return 0; } +int lua_cocos2dx_TransitionScene_getDuration(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::TransitionScene* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.TransitionScene",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::TransitionScene*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionScene_getDuration'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_TransitionScene_getDuration'", nullptr); + return 0; + } + double ret = cobj->getDuration(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TransitionScene:getDuration",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionScene_getDuration'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_TransitionScene_hideOutShowIn(lua_State* tolua_S) { int argc = 0; @@ -42447,7 +42545,9 @@ int lua_register_cocos2dx_TransitionScene(lua_State* tolua_S) tolua_cclass(tolua_S,"TransitionScene","cc.TransitionScene","cc.Scene",nullptr); tolua_beginmodule(tolua_S,"TransitionScene"); + tolua_function(tolua_S,"getInScene",lua_cocos2dx_TransitionScene_getInScene); tolua_function(tolua_S,"finish",lua_cocos2dx_TransitionScene_finish); + tolua_function(tolua_S,"getDuration",lua_cocos2dx_TransitionScene_getDuration); tolua_function(tolua_S,"hideOutShowIn",lua_cocos2dx_TransitionScene_hideOutShowIn); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionScene_create); tolua_endmodule(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 11c73aff0e..6c0779d5aa 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -1632,6 +1632,8 @@ int register_all_cocos2dx(lua_State* tolua_S); + + diff --git a/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp b/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp index ee0717712a..34d17b1a82 100644 --- a/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp @@ -116,7 +116,7 @@ tolua_lerror: return 0; } -int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* tolua_S) +int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* L) { int argc = 0; bool ok = true; @@ -125,39 +125,39 @@ int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(L,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; #endif - argc = lua_gettop(tolua_S)-1; + argc = lua_gettop(L)-1; do { if (argc == 3) { std::string modelPath; - ok &= luaval_to_std_string(tolua_S, 2,&modelPath, "cc.Sprite3D:createAsync"); + ok &= luaval_to_std_string(L, 2,&modelPath, "cc.Sprite3D:createAsync"); if (!ok) break; std::string texturePath; - ok &= luaval_to_std_string(tolua_S, 3,&texturePath, "cc.Sprite3D:createAsync"); + ok &= luaval_to_std_string(L, 3,&texturePath, "cc.Sprite3D:createAsync"); if (!ok) break; #if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(tolua_S,4,"LUA_FUNCTION",0,&tolua_err)) { + if (!toluafix_isfunction(L,4,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif - LUA_FUNCTION handler = toluafix_ref_function(tolua_S,4,0); + LUA_FUNCTION handler = toluafix_ref_function(L,4,0); cocos2d::Sprite3D::createAsync(modelPath, texturePath, [=](cocos2d::Sprite3D* sprite, void* callbackparam){ int id = (sprite) ? (int)sprite->_ID : -1; int* luaID = (sprite) ? &sprite->_luaID : nullptr; - toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)sprite,"cc.Sprite3D"); + toluafix_pushusertype_ccobject(L, id, luaID, (void*)sprite,"cc.Sprite3D"); LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 1); }, nullptr); - lua_settop(tolua_S, 1); + lua_settop(L, 1); return 1; } } while (0); @@ -167,34 +167,34 @@ int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* tolua_S) if (argc == 2) { std::string modelPath; - ok &= luaval_to_std_string(tolua_S, 2,&modelPath, "cc.Sprite3D:createAsync"); + ok &= luaval_to_std_string(L, 2,&modelPath, "cc.Sprite3D:createAsync"); if (!ok) break; #if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err)) { + if (!toluafix_isfunction(L, 3, "LUA_FUNCTION", 0, &tolua_err)) { goto tolua_lerror; } #endif - LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 3, 0); + LUA_FUNCTION handler = toluafix_ref_function(L, 3, 0); cocos2d::Sprite3D::createAsync(modelPath, [=](cocos2d::Sprite3D* sprite, void* callbackparam){ int id = (sprite) ? (int)sprite->_ID : -1; int* luaID = (sprite) ? &sprite->_luaID : nullptr; - toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)sprite,"cc.Sprite3D"); + toluafix_pushusertype_ccobject(L, id, luaID, (void*)sprite,"cc.Sprite3D"); LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 1); }, nullptr); - lua_settop(tolua_S, 1); + lua_settop(L, 1); return 1; } } while (0); ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite3D:createAsync",argc, 3); + luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite3D:createAsync",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_createAsync'.",&tolua_err); + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_createAsync'.",&tolua_err); #endif return 0; } @@ -212,12 +212,327 @@ static void extendSprite3D(lua_State* L) lua_pop(L, 1); } +bool luaval_to_terraindata(lua_State* L, int lo, cocos2d::Terrain::TerrainData* outValue , const char* funcName = "") +{ + if (nullptr == L || nullptr == outValue) + return false; + + bool ok = true; + tolua_Error tolua_err; + if (!tolua_istable(L, lo, 0, &tolua_err)) + { +#if COCOS2D_DEBUG >=1 + luaval_to_native_err(L,"#ferror:",&tolua_err,funcName); + ok = false; +#endif + } + + if (ok) + { + lua_pushstring(L, "chunkSize"); + lua_gettable(L,lo); + if (!lua_isnil(L, -1)) + { + luaval_to_size(L, -1, &(outValue->chunkSize)); + } + else + { + outValue->chunkSize = cocos2d::Size(32, 32); + } + lua_pop(L, 1); + + lua_pushstring(L, "heightMapSrc"); + lua_gettable(L,lo); + outValue->heightMapSrc = tolua_tocppstring(L, -1, ""); + lua_pop(L,1); + + lua_pushstring(L, "alphaMapSrc"); + lua_gettable(L,lo); + outValue->alphaMapSrc = const_cast(tolua_tocppstring(L, -1, "")); + lua_pop(L,1); + + lua_pushstring(L, "detailMaps"); + lua_gettable(L,lo); + if (lua_istable(L, -1)) + { + size_t len = lua_objlen(L, -1); + for (size_t i = 0; i < len; i++) + { + lua_pushnumber(L,i + 1); + lua_gettable(L,-2); + if (lua_istable(L, -1)) + { + lua_pushstring(L, "detailMapSrc"); + lua_gettable(L,-2); + outValue->detailMaps[i].detailMapSrc = tolua_tocppstring(L, -1, ""); + lua_pop(L,1); + + lua_pushstring(L, "detailMapSize"); + lua_gettable(L,-2); + outValue->detailMaps[i].detailMapSize = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); + lua_pop(L,1); + } + lua_pop(L, 1); + } + } + lua_pop(L,1); + + lua_pushstring(L, "mapHeight"); + lua_gettable(L,lo); + outValue->mapHeight = lua_isnil(L,-1) ? 2.0f : (float)lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "mapScale"); + lua_gettable(L,lo); + outValue->mapScale = lua_isnil(L,-1) ? 0.1f : (float)lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "_detailMapAmount"); + lua_gettable(L,lo); + outValue->_detailMapAmount = lua_isnil(L,-1) ? 0 : (int)lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "skirtHeightRatio"); + lua_gettable(L,lo); + outValue->skirtHeightRatio = lua_isnil(L,-1) ? 1.0f : (float)lua_tonumber(L,-1); + lua_pop(L,1); + } + + return ok; +} + +void terraindata_to_luaval(lua_State* L,const cocos2d::Terrain::TerrainData& inValue) +{ + if (nullptr == L) + return; + + lua_newtable(L); + lua_pushstring(L, "chunkSize"); + size_to_luaval(L, inValue.chunkSize); + lua_rawset(L, -3); + + if (inValue.heightMapSrc.length() > 0) + { + lua_pushstring(L, "heightMapSrc"); + lua_pushstring(L, inValue.heightMapSrc.c_str()); + lua_rawset(L, -3); + } + + if (nullptr != inValue.alphaMapSrc) + { + lua_pushstring(L, "alphaMapSrc"); + lua_pushstring(L, inValue.alphaMapSrc); + lua_rawset(L, -3); + } + + lua_pushstring(L, "detailMaps"); + lua_newtable(L); + for (int i = 0; i < 4; i++) + { + + lua_pushnumber(L, (lua_Number) i + 1); + lua_newtable(L); + + lua_pushstring(L, "detailMapSrc"); + lua_pushstring(L, inValue.detailMaps[i].detailMapSrc.c_str()); + lua_rawset(L, -3); + + lua_pushstring(L, "detailMapSize"); + lua_pushnumber(L, (lua_Number)inValue.detailMaps[i].detailMapSize); + lua_rawset(L, -3); + + lua_rawset(L, -3); + } + lua_rawset(L, -3); + + + lua_pushstring(L, "mapHeight"); + lua_pushnumber(L, (lua_Number)inValue.mapHeight); + lua_rawset(L, -3); + + lua_pushstring(L, "mapScale"); + lua_pushnumber(L, (lua_Number)inValue.mapScale); + lua_rawset(L, -3); + + lua_pushstring(L, "_detailMapAmount"); + lua_pushnumber(L, (lua_Number)inValue._detailMapAmount); + lua_rawset(L, -3); + + lua_pushstring(L, "skirtHeightRatio"); + lua_pushnumber(L, (lua_Number)inValue.skirtHeightRatio); + lua_rawset(L, -3); +} + +int lua_cocos2dx_3d_Terrain_create(lua_State* L) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(L,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(L) - 1; + + if (argc == 1) + { + cocos2d::Terrain::TerrainData arg0; + ok &= luaval_to_terraindata(L, 2, &arg0); + if(!ok) + { + tolua_error(L,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_create'", nullptr); + return 0; + } + cocos2d::Terrain* ret = cocos2d::Terrain::create(arg0); + object_to_luaval(L, "cc.Terrain",(cocos2d::Terrain*)ret); + return 1; + } + if (argc == 2) + { + cocos2d::Terrain::TerrainData arg0; + cocos2d::Terrain::CrackFixedType arg1; + + ok &= luaval_to_terraindata(L, 2, &arg0); + ok &= luaval_to_int32(L, 3,(int *)&arg1, "cc.Terrain:create"); + if(!ok) + { + tolua_error(L,"invalid arguments in function 'lua_cocos2dx_3d_Terrain_create'", nullptr); + return 0; + } + cocos2d::Terrain* ret = cocos2d::Terrain::create(arg0, arg1); + object_to_luaval(L, "cc.Terrain",(cocos2d::Terrain*)ret); + return 1; + } + luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Terrain:create",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_Terrain_create'.",&tolua_err); +#endif + return 0; +} + +int lua_cocos2dx_3d_Terrain_getHeight(lua_State* L) +{ + int argc = 0; + cocos2d::Terrain* cobj = nullptr; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"cc.Terrain",0,&tolua_err)) goto tolua_lerror; +#endif + cobj = (cocos2d::Terrain*)tolua_tousertype(L,1,0); +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_3d_Terrain_getHeight'", nullptr); + return 0; + } +#endif + argc = lua_gettop(L)-1; + do{ + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= luaval_to_vec2(L, 2, &arg0, "cc.Terrain:getHeight"); + + if (!ok) { break; } + double ret = cobj->getHeight(arg0); + tolua_pushnumber(L,(lua_Number)ret); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 2) { + cocos2d::Vec2 arg0; + ok &= luaval_to_vec2(L, 2, &arg0, "cc.Terrain:getHeight"); + + if (!ok) { break; } + cocos2d::Vec3* arg1; + ok &= luaval_to_object(L, 3, "cc.Vec3",&arg1); + + if (!ok) { break; } + double ret = cobj->getHeight(arg0, arg1); + tolua_pushnumber(L,(lua_Number)ret); + vec3_to_luaval(L, *arg1); + return 2; + } + }while(0); + ok = true; + do{ + if (argc == 2) { + double arg0; + ok &= luaval_to_number(L, 2,&arg0, "cc.Terrain:getHeight"); + + if (!ok) { break; } + double arg1; + ok &= luaval_to_number(L, 3,&arg1, "cc.Terrain:getHeight"); + + if (!ok) { break; } + double ret = cobj->getHeight(arg0, arg1); + tolua_pushnumber(L,(lua_Number)ret); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 3) { + double arg0; + ok &= luaval_to_number(L, 2,&arg0, "cc.Terrain:getHeight"); + + if (!ok) { break; } + double arg1; + ok &= luaval_to_number(L, 3,&arg1, "cc.Terrain:getHeight"); + + if (!ok) { break; } + cocos2d::Vec3 arg2; + ok &= luaval_to_vec3(L, 4, &arg2); + + if (!ok) { break; } + double ret = cobj->getHeight(arg0, arg1, &arg2); + tolua_pushnumber(L,(lua_Number)ret); + vec3_to_luaval(L, arg2); + return 2; + } + }while(0); + ok = true; + luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Terrain:getHeight",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_Terrain_getHeight'.",&tolua_err); +#endif + + return 0; +} + +static void extendTerrain(lua_State* L) +{ + lua_pushstring(L, "cc.Terrain"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "create", lua_cocos2dx_3d_Terrain_create); + tolua_function(L, "getHeight", lua_cocos2dx_3d_Terrain_getHeight); + } + lua_pop(L, 1); +} + static int register_all_cocos2dx_3d_manual(lua_State* L) { if (nullptr == L) return 0; extendSprite3D(L); + extendTerrain(L); return 0; } diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp index 14327c67c9..93a5c0c8a1 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp @@ -7088,6 +7088,56 @@ tolua_lerror: return 0; } +int lua_cocos2dx_Application_is64BitIOSDevice(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Application* cobj = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Application",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Application*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Application_is64BitIOSDevice'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + bool is64BitIOSDevice = false; + Application::Platform platform = cocos2d::Application::getInstance()->getTargetPlatform(); + if (Application::Platform::OS_IPHONE == platform || Application::Platform::OS_IPAD == platform) + { +#if defined(__arm64__) + is64BitIOSDevice = true; +#endif + } + + tolua_pushboolean(tolua_S, is64BitIOSDevice); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Application:is64BitIOSDevice",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Application_is64BitIOSDevice'.",&tolua_err); +#endif + + return 0; +} + static void extendApplication(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.Application"); @@ -7095,6 +7145,7 @@ static void extendApplication(lua_State* tolua_S) if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "isIOS64bit", lua_cocos2dx_Application_isIOS64bit); + tolua_function(tolua_S, "is64BitIOSDevice", lua_cocos2dx_Application_is64BitIOSDevice); } lua_pop(tolua_S, 1); } diff --git a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj index 959abc3bc2..d552c61e9d 100644 --- a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj @@ -203,7 +203,6 @@ 15C1C2EE19874CBE00A46ACC /* tolua_fix.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AACE7B418BC45C200215002 /* tolua_fix.h */; }; 15EFA1F61989E528000C57D3 /* lua_cocos2dx_experimental_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15622967197780DE009C9067 /* lua_cocos2dx_experimental_auto.cpp */; }; 15EFA1F71989E582000C57D3 /* lua_cocos2dx_experimental_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15622968197780DE009C9067 /* lua_cocos2dx_experimental_auto.hpp */; }; - 15EFA5D8198B2DAA000C57D3 /* liblua.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D9BAFA1974D30000EC35BB /* liblua.a */; }; 15EFA5D9198B2DAA000C57D3 /* libluajit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA1F318CD8F540087CE3A /* libluajit.a */; }; 15EFA617198B2E2B000C57D3 /* lua_cocos2dx_experimental_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15622967197780DE009C9067 /* lua_cocos2dx_experimental_auto.cpp */; }; 15EFA618198B2E2B000C57D3 /* lua_cocos2dx_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AACE74918BC45C200215002 /* lua_cocos2dx_auto.cpp */; }; @@ -452,7 +451,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 15EFA5D8198B2DAA000C57D3 /* liblua.a in Frameworks */, 15EFA5D9198B2DAA000C57D3 /* libluajit.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1310,12 +1308,7 @@ ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; - LIBRARY_SEARCH_PATHS = ( - "$(SRCROOT)/../../../../external/lua/luajit/prebuilt/ios", - "$(SRCROOT)/../../../../external/lua/lua/prebuilt/ios", - ); - "OTHER_LDFLAGS[sdk=iphonesimulator7.1]" = "-llua"; - "OTHER_LDFLAGS[sdk=iphonesimulator8.0]" = "-llua"; + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../../../../external/lua/luajit/prebuilt/ios"; PRODUCT_NAME = "libluacocos2d iOS"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1337,12 +1330,7 @@ ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; - LIBRARY_SEARCH_PATHS = ( - "$(SRCROOT)/../../../../external/lua/luajit/prebuilt/ios", - "$(SRCROOT)/../../../../external/lua/lua/prebuilt/ios", - ); - "OTHER_LDFLAGS[sdk=iphonesimulator7.1]" = "-llua"; - "OTHER_LDFLAGS[sdk=iphonesimulator8.0]" = "-llua"; + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../../../../external/lua/luajit/prebuilt/ios"; PRODUCT_NAME = "libluacocos2d iOS"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/cocos/scripting/lua-bindings/script/3d/3dConstants.lua b/cocos/scripting/lua-bindings/script/3d/3dConstants.lua new file mode 100644 index 0000000000..cd7a90f2a4 --- /dev/null +++ b/cocos/scripting/lua-bindings/script/3d/3dConstants.lua @@ -0,0 +1,9 @@ +if nil == cc.Terrain then + return +end + +cc.Terrain.CrackFixedType = +{ + SKIRT = 0, + INCREASE_LOWER = 1, +} diff --git a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua index 316c3ed0a7..5ea571a54c 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua @@ -441,6 +441,22 @@ function cc.quaternion(_x, _y ,_z,_w) return { x = _x, y = _y, z = _z, w = _w } end +function cc.quaternion_createFromAxisAngle(axis, angle) + + local halfAngle = angle * 0.5 + local sinHalfAngle = math.sin(halfAngle) + + local normal = cc.vec3(axis.x, axis.y, axis.z) + normal = cc.vec3normalize(normal) + local dst = cc.vec3(0.0, 0.0, 0.0) + dst.x = normal.x * sinHalfAngle + dst.y = normal.y * sinHalfAngle + dst.z = normal.z * sinHalfAngle + dst.w = math.cos(halfAngle) + + return dst +end + function cc.blendFunc(_src, _dst) return {src = _src, dst = _dst} end diff --git a/cocos/ui/UIWebViewImpl-ios.mm b/cocos/ui/UIWebViewImpl-ios.mm index f1dc8d993a..0ffbd31028 100644 --- a/cocos/ui/UIWebViewImpl-ios.mm +++ b/cocos/ui/UIWebViewImpl-ios.mm @@ -164,6 +164,7 @@ static std::string getFixedBaseUrl(const std::string& baseUrl) } - (void)loadHTMLString:(const std::string &)string baseURL:(const std::string &)baseURL { + if (!self.uiWebView) {[self setupWebView];} [self.uiWebView loadHTMLString:@(string.c_str()) baseURL:[NSURL URLWithString:@(getFixedBaseUrl(baseURL).c_str())]]; } @@ -211,6 +212,7 @@ static std::string getFixedBaseUrl(const std::string& baseUrl) } - (void)setScalesPageToFit:(const bool)scalesPageToFit { + if (!self.uiWebView) {[self setupWebView];} self.uiWebView.scalesPageToFit = scalesPageToFit; } diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index dca3cf3535..9b5339353a 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -1,4 +1,4 @@ -# cocos2d-x v3.5 Release Notes # +# cocos2d-x v3.6 Release Notes # **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* @@ -13,7 +13,7 @@ - [Windows](#windows) - [Linux](#linux) - [How to start a new game](#how-to-start-a-new-game) -- [v3.6beta0](#v36beta0) +- [v3.6alpha0](#v36alpha0) - [Highlights of v3.6beta0](#highlights-of-v36beta0) - [Features in detail](#features-in-detail-1) - [3D TextureCube](#3d-texturecube) @@ -110,9 +110,15 @@ Run Please refer to this document: [ReadMe](../README.md) -# v3.6beta0 +# v3.6alpha0 + +## Highlights of v3.6alpha0 + +* 3D: added skybox support +* 3D: added terrian support +* uses luajit v2.1-20150331 on 64-bit iOS devices +* added test automation support for cpp-tests -## Highlights of v3.6beta0 ## Features in detail ### 3D TextureCube @@ -191,3 +197,13 @@ if (animation) ``` The animation quality is also configurable in config.plist, the key is cocos2d.x.3d.animate_high_quality. All the created `Animate3D` base on this key if exist. You can modify it using the above method. + +### luajit arm64 + +The version of the luajit is [v2.1-20150331](https://github.com/openresty/luajit2/releases). We have consulted the author of luajit, he said it was stability enough to be used. We will update to v2.1 when it is released. + +Using luajit arm64 version is that because it can improve the performance. In previous versions of cocos2d-x, it uses lua on iOS 64-bit devices. + +Bytecode of luajit and luajit arm64 are not compatible, which means you can not use one version of bytecode on iOS 32-bit devices and iOS 64-bit devices. + +As there is not mandatory requirement of having arm64 bit bin on Android, so we don't use luajit arm64 on Android as its bytecode is not compatible with luajit arm32. diff --git a/extensions/Particle3D/CCParticle3DRender.cpp b/extensions/Particle3D/CCParticle3DRender.cpp index f61c4f4233..5e0f8cb158 100755 --- a/extensions/Particle3D/CCParticle3DRender.cpp +++ b/extensions/Particle3D/CCParticle3DRender.cpp @@ -269,8 +269,7 @@ void Particle3DModelRender::render(Renderer* renderer, const Mat4 &transform, Pa for (auto iter : activeParticleList) { auto particle = iter; - q *= particle->orientation; - Mat4::createRotation(q, &rotMat); + Mat4::createRotation(q * particle->orientation, &rotMat); sclMat.m[0] = particle->width / _spriteSize.x; sclMat.m[5] = particle->height / _spriteSize.y; sclMat.m[10] = particle->depth / _spriteSize.z; diff --git a/extensions/Particle3D/PU/CCPUBeamRender.cpp b/extensions/Particle3D/PU/CCPUBeamRender.cpp index 201a60cc48..193835162f 100644 --- a/extensions/Particle3D/PU/CCPUBeamRender.cpp +++ b/extensions/Particle3D/PU/CCPUBeamRender.cpp @@ -272,8 +272,8 @@ void PUBeamRender::prepare() for (size_t numDev = 0; numDev < _numberOfSegments; ++numDev) { // Initialise the positions - visualData->half[numDev] = Vec3::ZERO; - visualData->destinationHalf[numDev] = Vec3::ZERO; + visualData->half[numDev].setZero(); + visualData->destinationHalf[numDev].setZero(); } _allVisualData.push_back(visualData); // Managed by this renderer _visualData.push_back(visualData); // Used to assign to a particle diff --git a/extensions/Particle3D/PU/CCPUBillboardChain.cpp b/extensions/Particle3D/PU/CCPUBillboardChain.cpp index d8b83687f6..86e7792c52 100644 --- a/extensions/Particle3D/PU/CCPUBillboardChain.cpp +++ b/extensions/Particle3D/PU/CCPUBillboardChain.cpp @@ -418,7 +418,7 @@ void PUBillboardChain::updateVertexBuffer(const Mat4 &camMat) //Vector3 eyePos = mParentNode->_getDerivedOrientation().Inverse() * // (camPos - mParentNode->_getDerivedPosition()) / mParentNode->_getDerivedScale(); - Vec3 eyePos = Vec3(camMat.m[12], camMat.m[13], camMat.m[14]); + Vec3 eyePos(camMat.m[12], camMat.m[13], camMat.m[14]); Vec3 chainTangent; for (ChainSegmentList::iterator segi = _chainSegmentList.begin(); diff --git a/extensions/Particle3D/PU/CCPUCircleEmitter.cpp b/extensions/Particle3D/PU/CCPUCircleEmitter.cpp index 9d8118e185..9d0f16b8a8 100644 --- a/extensions/Particle3D/PU/CCPUCircleEmitter.cpp +++ b/extensions/Particle3D/PU/CCPUCircleEmitter.cpp @@ -173,7 +173,6 @@ void PUCircleEmitter::initParticleDirection(PUParticle3D* particle) { Mat4 rotMat; Mat4::createRotation(_orientation, &rotMat); - particle->direction = Vec3(_x, 0, _z); particle->direction = rotMat * Vec3(_x, 0, _z); } } diff --git a/extensions/Particle3D/PU/CCPUDynamicAttribute.cpp b/extensions/Particle3D/PU/CCPUDynamicAttribute.cpp index 4e1c6d5c67..515d1d6370 100644 --- a/extensions/Particle3D/PU/CCPUDynamicAttribute.cpp +++ b/extensions/Particle3D/PU/CCPUDynamicAttribute.cpp @@ -423,7 +423,7 @@ float PUDynamicAttributeOscillate::getValue (float x) case OSCT_SQUARE: { float val = sin(_phase + _frequency * x * M_PI * 2.0f); - if (abs(val) < 0.00001f) + if (std::abs(val) < 0.00001f) val = val >0? 1: -1; return _base + _amplitude * val; } diff --git a/extensions/Particle3D/PU/CCPUFlockCenteringAffector.cpp b/extensions/Particle3D/PU/CCPUFlockCenteringAffector.cpp index e320da8c6c..d2e00e7086 100644 --- a/extensions/Particle3D/PU/CCPUFlockCenteringAffector.cpp +++ b/extensions/Particle3D/PU/CCPUFlockCenteringAffector.cpp @@ -62,7 +62,7 @@ void PUFlockCenteringAffector::preUpdateAffector( float deltaTime ) { _average = getDerivedPosition(); // Set to position of the affector } - _sum = Vec3::ZERO; + _sum.setZero(); _count = 0; } diff --git a/extensions/Particle3D/PU/CCPUForceField.cpp b/extensions/Particle3D/PU/CCPUForceField.cpp index a1f3c2ea79..8bccf2c527 100644 --- a/extensions/Particle3D/PU/CCPUForceField.cpp +++ b/extensions/Particle3D/PU/CCPUForceField.cpp @@ -27,7 +27,7 @@ NS_CC_BEGIN -const Vec3 PUForceFieldCalculationFactory::DEFAULT_WORLDSIZE = Vec3(500.0f, 500.0f, 500.0f); +const Vec3 PUForceFieldCalculationFactory::DEFAULT_WORLDSIZE(500.0f, 500.0f, 500.0f); //----------------------------------------------------------------------- unsigned short PUForceFieldCalculationFactory::getOctaves(void) const diff --git a/extensions/Particle3D/PU/CCPUForceFieldAffector.cpp b/extensions/Particle3D/PU/CCPUForceFieldAffector.cpp index b059a2753d..54ace4661d 100644 --- a/extensions/Particle3D/PU/CCPUForceFieldAffector.cpp +++ b/extensions/Particle3D/PU/CCPUForceFieldAffector.cpp @@ -37,8 +37,8 @@ const double PUForceFieldAffector::DEFAULT_FREQUENCY = 1.0f; const double PUForceFieldAffector::DEFAULT_AMPLITUDE = 1.0f; const double PUForceFieldAffector::DEFAULT_PERSISTENCE = 3.0f; const unsigned int PUForceFieldAffector::DEFAULT_FORCEFIELDSIZE = 64; -const Vec3 PUForceFieldAffector::DEFAULT_WORLDSIZE = Vec3(500.0f, 500.0f, 500.0f); -const Vec3 PUForceFieldAffector::DEFAULT_MOVEMENT = Vec3(500.0f, 0.0f, 0.0f); +const Vec3 PUForceFieldAffector::DEFAULT_WORLDSIZE(500.0f, 500.0f, 500.0f); +const Vec3 PUForceFieldAffector::DEFAULT_MOVEMENT(500.0f, 0.0f, 0.0f); const float PUForceFieldAffector::DEFAULT_MOVEMENT_FREQUENCY = 5.0f; //----------------------------------------------------------------------- diff --git a/extensions/Particle3D/PU/CCPUInterParticleCollider.cpp b/extensions/Particle3D/PU/CCPUInterParticleCollider.cpp index 1f9de4ea28..01802a1ea3 100644 --- a/extensions/Particle3D/PU/CCPUInterParticleCollider.cpp +++ b/extensions/Particle3D/PU/CCPUInterParticleCollider.cpp @@ -108,8 +108,8 @@ bool PUParticle3DInterParticleCollider::validateAndExecuteSphereCollision (PUPar // The new velocity is based on the angle between original direction and new direction. // Note, that this usually means that the velocity decreases. - float velocity1 = Vec3(abs(vp1->direction.x), abs(vp1->direction.y), abs(vp1->direction.z)).dot(n); - float velocity2 = Vec3(abs(vp2->direction.x), abs(vp2->direction.y), abs(vp2->direction.z)).dot(n); + float velocity1 = Vec3(std::abs(vp1->direction.x), std::abs(vp1->direction.y), std::abs(vp1->direction.z)).dot(n); + float velocity2 = Vec3(std::abs(vp2->direction.x), std::abs(vp2->direction.y), std::abs(vp2->direction.z)).dot(n); vp1->direction = velocity1 * vp2->mass * n; vp2->direction = velocity2 * vp1->mass * -n; } diff --git a/extensions/Particle3D/PU/CCPULineEmitter.cpp b/extensions/Particle3D/PU/CCPULineEmitter.cpp index c41ca05d84..acf8e0654a 100644 --- a/extensions/Particle3D/PU/CCPULineEmitter.cpp +++ b/extensions/Particle3D/PU/CCPULineEmitter.cpp @@ -68,7 +68,7 @@ void PULineEmitter::notifyRescaled(const Vec3& scale) // Scale the internal attributes and use them, otherwise this results in too many calculations per particle PUEmitter::notifyRescaled(scale); float scaleLength = scale.length(); - _scaledEnd = Vec3(_end.x * scale.x, _end.y * scale.y, _end.z * scale.z); + _scaledEnd.set(_end.x * scale.x, _end.y * scale.y, _end.z * scale.z); _scaledMaxDeviation = _maxDeviation * scaleLength; _scaledMinIncrement = _minIncrement * scaleLength; _scaledMaxIncrement = (_maxIncrement - _minIncrement) * scaleLength; @@ -108,7 +108,7 @@ const Vec3& PULineEmitter::getEnd(void) const void PULineEmitter::setEnd(const Vec3& end) { _end = end; - _scaledEnd = Vec3(_end.x * _emitterScale.x, _end.y * _emitterScale.y, _end.z * _emitterScale.z); + _scaledEnd.set(_end.x * _emitterScale.x, _end.y * _emitterScale.y, _end.z * _emitterScale.z); _length = _end.length(); } //----------------------------------------------------------------------- diff --git a/extensions/Particle3D/PU/CCPUMeshSurfaceEmitter.cpp b/extensions/Particle3D/PU/CCPUMeshSurfaceEmitter.cpp index f3e3b8a9e1..e50f158104 100644 --- a/extensions/Particle3D/PU/CCPUMeshSurfaceEmitter.cpp +++ b/extensions/Particle3D/PU/CCPUMeshSurfaceEmitter.cpp @@ -111,30 +111,24 @@ const PUTriangle::PositionAndNormal PUTriangle::getRandomEdgePositionAndNormal ( float mult = CCRANDOM_0_1(); float randomVal = CCRANDOM_0_1() * 3.0f; PositionAndNormal pAndN; - pAndN.position = Vec3::ZERO; - pAndN.normal = Vec3::ZERO; + pAndN.position.setZero(); + pAndN.normal.setZero(); if (randomVal < 1) { - pAndN.position = Vec3( v2.x + mult*(v1.x - v2.x), - v2.y + mult*(v1.y - v2.y), - v2.z + mult*(v1.z - v2.z)); + pAndN.position.set(v2.x + mult*(v1.x - v2.x), v2.y + mult*(v1.y - v2.y), v2.z + mult*(v1.z - v2.z)); pAndN.normal = en1; } else { if (randomVal < 2) { - pAndN.position = Vec3( v3.x + mult*(v2.x - v3.x), - v3.y + mult*(v2.y - v3.y), - v3.z + mult*(v2.z - v3.z)); + pAndN.position.set(v3.x + mult*(v2.x - v3.x), v3.y + mult*(v2.y - v3.y), v3.z + mult*(v2.z - v3.z)); pAndN.normal = en2; } else { - pAndN.position = Vec3( v1.x + mult*(v3.x - v1.x), - v1.y + mult*(v3.y - v1.y), - v1.z + mult*(v3.z - v1.z)); + pAndN.position.set(v1.x + mult*(v3.x - v1.x), v1.y + mult*(v3.y - v1.y), v1.z + mult*(v3.z - v1.z)); pAndN.normal = en3; } } @@ -146,8 +140,8 @@ const PUTriangle::PositionAndNormal PUTriangle::getRandomVertexAndNormal (void) { float randomVal = CCRANDOM_0_1() * 3.0f; PositionAndNormal pAndN; - pAndN.position = Vec3::ZERO; - pAndN.normal = Vec3::ZERO; + pAndN.position.setZero(); + pAndN.normal.setZero(); if (randomVal < 1) { @@ -209,7 +203,7 @@ inline float MeshInfo::getGaussianRandom (float high, float cutoff) } while (w >= 1.0f); w = sqrt((-2.0f * ::log(w)) / w); - y1 = abs(x1 * w); + y1 = std::abs(x1 * w); y1 = y1 > cutoff ? cutoff : y1; y1 *= high / cutoff; return y1; @@ -240,8 +234,8 @@ const PUTriangle::PositionAndNormal MeshInfo::getRandomPositionAndNormal (const { PUTriangle triangle = getTriangle(triangleIndex); PUTriangle::PositionAndNormal pAndN; - pAndN.position = Vec3::ZERO; - pAndN.normal = Vec3::ZERO; + pAndN.position.setZero(); + pAndN.normal.setZero(); if (mDistribution == MSD_HOMOGENEOUS || mDistribution == MSD_HETEROGENEOUS_1 || mDistribution == MSD_HETEROGENEOUS_2) { pAndN.position = triangle.getRandomTrianglePosition(); @@ -448,8 +442,8 @@ void PUMeshSurfaceEmitter::unPrepare() void PUMeshSurfaceEmitter::initParticlePosition(PUParticle3D* particle) { PUTriangle::PositionAndNormal pAndN; - pAndN.position = Vec3::ZERO; - pAndN.normal = Vec3::ZERO; + pAndN.position.setZero(); + pAndN.normal.setZero(); _directionSet = false; if (_meshInfo && _meshInfo->getTriangleCount()) diff --git a/extensions/Particle3D/PU/CCPUParticleSystem3D.cpp b/extensions/Particle3D/PU/CCPUParticleSystem3D.cpp index b04b4b3f22..fca4090944 100755 --- a/extensions/Particle3D/PU/CCPUParticleSystem3D.cpp +++ b/extensions/Particle3D/PU/CCPUParticleSystem3D.cpp @@ -896,7 +896,7 @@ void PUParticleSystem3D::emitParticles( ParticlePool &pool, PUEmitter* emitter, initParticleForEmission(particle); - particle->position += Vec3(particle->direction.x * scale.x * _particleSystemScaleVelocity * timePoint + particle->position.add(particle->direction.x * scale.x * _particleSystemScaleVelocity * timePoint , particle->direction.y * scale.y * _particleSystemScaleVelocity * timePoint , particle->direction.z * scale.z * _particleSystemScaleVelocity * timePoint); // Increment time fragment @@ -1313,7 +1313,7 @@ void PUParticleSystem3D::processMotion( PUParticle3D* particle, float timeElapse Vec3 scale = getDerivedScale(); // Update the position with the direction. - particle->position += Vec3(particle->direction.x * scale.x * _particleSystemScaleVelocity * timeElapsed + particle->position.add(particle->direction.x * scale.x * _particleSystemScaleVelocity * timeElapsed , particle->direction.y * scale.y * _particleSystemScaleVelocity * timeElapsed , particle->direction.z * scale.z * _particleSystemScaleVelocity * timeElapsed); } diff --git a/extensions/Particle3D/PU/CCPUPathFollower.cpp b/extensions/Particle3D/PU/CCPUPathFollower.cpp index 704ee8b6ff..d79f39e761 100644 --- a/extensions/Particle3D/PU/CCPUPathFollower.cpp +++ b/extensions/Particle3D/PU/CCPUPathFollower.cpp @@ -63,7 +63,7 @@ void PUPathFollower::updatePUAffector( PUParticle3D *particle, float deltaTime ) float timeFractionPlusDelta = (timeLeft + deltaTime ) / particle->totalTimeToLive; timeFractionPlusDelta = timeFractionPlusDelta < 1.0f ? timeFractionPlusDelta : 1.0f; Vec3 inter = _spline.interpolate(timeFractionPlusDelta) - _spline.interpolate(timeFraction); - particle->position += Vec3(_affectorScale.x * inter.x, _affectorScale.y * inter.y, _affectorScale.z * inter.z); + particle->position.add(_affectorScale.x * inter.x, _affectorScale.y * inter.y, _affectorScale.z * inter.z); } } } diff --git a/extensions/Particle3D/PU/CCPUPlane.cpp b/extensions/Particle3D/PU/CCPUPlane.cpp index 504ecf71f8..6b2ad5ecc2 100644 --- a/extensions/Particle3D/PU/CCPUPlane.cpp +++ b/extensions/Particle3D/PU/CCPUPlane.cpp @@ -29,7 +29,8 @@ NS_CC_BEGIN //----------------------------------------------------------------------- PUPlane::PUPlane () { - normal = Vec3::ZERO; + // Vec3 default constructor zero + //normal = Vec3::ZERO; d = 0.0; } //----------------------------------------------------------------------- diff --git a/extensions/Particle3D/PU/CCPURandomiser.cpp b/extensions/Particle3D/PU/CCPURandomiser.cpp index 879699764b..f5834f86a6 100644 --- a/extensions/Particle3D/PU/CCPURandomiser.cpp +++ b/extensions/Particle3D/PU/CCPURandomiser.cpp @@ -124,7 +124,7 @@ void PURandomiser::updatePUAffector( PUParticle3D *particle, float deltaTime ) if (_randomDirection) { // Random direction: Change the direction after each update - particle->direction += Vec3(CCRANDOM_MINUS1_1() * _maxDeviationX, + particle->direction.add(CCRANDOM_MINUS1_1() * _maxDeviationX, CCRANDOM_MINUS1_1() * _maxDeviationY, CCRANDOM_MINUS1_1() * _maxDeviationZ); } @@ -135,7 +135,7 @@ void PURandomiser::updatePUAffector( PUParticle3D *particle, float deltaTime ) return; // Random position: Add the position deviation after each update - particle->position += Vec3(CCRANDOM_MINUS1_1() * _maxDeviationX * _affectorScale.x, + particle->position.add(CCRANDOM_MINUS1_1() * _maxDeviationX * _affectorScale.x, CCRANDOM_MINUS1_1() * _maxDeviationY * _affectorScale.y, CCRANDOM_MINUS1_1() * _maxDeviationZ * _affectorScale.z); } diff --git a/extensions/Particle3D/PU/CCPURender.cpp b/extensions/Particle3D/PU/CCPURender.cpp index d75374e9a5..ecdc91c6b6 100644 --- a/extensions/Particle3D/PU/CCPURender.cpp +++ b/extensions/Particle3D/PU/CCPURender.cpp @@ -159,7 +159,7 @@ void PUParticle3DQuadRender::render(Renderer* renderer, const Mat4 &transform, P up.normalize(); backward = direction; }else if (_type == ORIENTED_SHAPE){ - up = Vec3(particle->orientation.x, particle->orientation.y, particle->orientation.z); + up.set(particle->orientation.x, particle->orientation.y, particle->orientation.z); up.normalize(); Vec3::cross(up, backward, &right); right.normalize(); @@ -470,8 +470,7 @@ void PUParticle3DModelRender::render( Renderer* renderer, const Mat4 &transform, for (auto iter : activeParticleList) { auto particle = static_cast(iter); - q *= particle->orientation; - Mat4::createRotation(q, &rotMat); + Mat4::createRotation(q * particle->orientation, &rotMat); sclMat.m[0] = particle->width / _spriteSize.x; sclMat.m[5] = particle->height / _spriteSize.y; sclMat.m[10] = particle->depth / _spriteSize.z; @@ -867,7 +866,7 @@ void PUSphereRender::buildBuffers( unsigned short count ) float z0 = r0 * cosf(segment * stepSegmentAngle); // Vertex - vi.position = Vec3(x0, y0, z0); + vi.position.set(x0, y0, z0); // Colour vi.color = Vec4::ONE; diff --git a/extensions/Particle3D/PU/CCPURibbonTrail.cpp b/extensions/Particle3D/PU/CCPURibbonTrail.cpp index 1c96b44597..b88d831f6d 100644 --- a/extensions/Particle3D/PU/CCPURibbonTrail.cpp +++ b/extensions/Particle3D/PU/CCPURibbonTrail.cpp @@ -285,7 +285,7 @@ void PURibbonTrail::updateTrail(size_t index, const Node* node) // Vary the head elem, but bake new version if that exceeds element len Mat4 toWMat = node->getNodeToWorldTransform(); - Vec3 newPos = Vec3(toWMat.m[12], toWMat.m[13], toWMat.m[14]); + Vec3 newPos(toWMat.m[12], toWMat.m[13], toWMat.m[14]); if (_parentNode) { Mat4 toLMat = _parentNode->getWorldToNodeTransform() * toWMat; @@ -394,7 +394,7 @@ void PURibbonTrail::resetTrail(size_t index, const Node* node) // Create new element, v coord is always 0.0f // need to convert to take parent node's position into account Mat4 toWMat = node->getNodeToWorldTransform(); - Vec3 position = Vec3(toWMat.m[12], toWMat.m[13], toWMat.m[14]); + Vec3 position(toWMat.m[12], toWMat.m[13], toWMat.m[14]); if (_parentNode) { Mat4 toLMat = _parentNode->getWorldToNodeTransform() * toWMat; diff --git a/extensions/Particle3D/PU/CCPUSphereSurfaceEmitter.cpp b/extensions/Particle3D/PU/CCPUSphereSurfaceEmitter.cpp index 0785dd126b..7c3695e2cf 100644 --- a/extensions/Particle3D/PU/CCPUSphereSurfaceEmitter.cpp +++ b/extensions/Particle3D/PU/CCPUSphereSurfaceEmitter.cpp @@ -53,9 +53,7 @@ void PUSphereSurfaceEmitter::initParticlePosition(PUParticle3D* particle) { // Generate a random unit vector to calculate a point on the sphere. This unit vector is // also used as direction vector if mAutoDirection has been set. - _randomVector = Vec3(CCRANDOM_MINUS1_1(), - CCRANDOM_MINUS1_1(), - CCRANDOM_MINUS1_1()); + _randomVector.set(CCRANDOM_MINUS1_1(), CCRANDOM_MINUS1_1(), CCRANDOM_MINUS1_1()); _randomVector.normalize(); //ParticleSystem* sys = mParentTechnique->getParentSystem(); //if (sys) diff --git a/extensions/Particle3D/PU/CCPUVelocityMatchingAffector.cpp b/extensions/Particle3D/PU/CCPUVelocityMatchingAffector.cpp index 50c34a409d..deb015a925 100644 --- a/extensions/Particle3D/PU/CCPUVelocityMatchingAffector.cpp +++ b/extensions/Particle3D/PU/CCPUVelocityMatchingAffector.cpp @@ -80,8 +80,8 @@ void PUVelocityMatchingAffector::updatePUAffector( PUParticle3D *particle, float // return; // unsigned int size = static_cast(cell.size()); - // Vec3 sumDirection = Vec3::ZERO; - // Vec3 diff = Vec3::ZERO; + // Vec3 sumDirection; + // Vec3 diff; // unsigned int count = 0; // for (unsigned int i = 0; i < size; ++i) // { diff --git a/external/config.json b/external/config.json index a3658712fb..65c0b887d6 100644 --- a/external/config.json +++ b/external/config.json @@ -1,5 +1,5 @@ { - "version":"v3-deps-35", + "version":"v3-deps-38", "zip_file_size":"87419231", "repo_name":"cocos2d-x-3rd-party-libs-bin", "repo_parent":"https://github.com/cocos2d/", diff --git a/external/zlib/include/zconf.h b/external/zlib/include/zconf.h new file mode 100755 index 0000000000..996fff2921 --- /dev/null +++ b/external/zlib/include/zconf.h @@ -0,0 +1,511 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2013 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + * Even better than compiling with -DZ_PREFIX would be to use configure to set + * this permanently in zconf.h using "./configure --zprefix". + */ +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ +# define Z_PREFIX_SET + +/* all linked symbols */ +# define _dist_code z__dist_code +# define _length_code z__length_code +# define _tr_align z__tr_align +# define _tr_flush_bits z__tr_flush_bits +# define _tr_flush_block z__tr_flush_block +# define _tr_init z__tr_init +# define _tr_stored_block z__tr_stored_block +# define _tr_tally z__tr_tally +# define adler32 z_adler32 +# define adler32_combine z_adler32_combine +# define adler32_combine64 z_adler32_combine64 +# ifndef Z_SOLO +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# endif +# define crc32 z_crc32 +# define crc32_combine z_crc32_combine +# define crc32_combine64 z_crc32_combine64 +# define deflate z_deflate +# define deflateBound z_deflateBound +# define deflateCopy z_deflateCopy +# define deflateEnd z_deflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateInit_ z_deflateInit_ +# define deflateParams z_deflateParams +# define deflatePending z_deflatePending +# define deflatePrime z_deflatePrime +# define deflateReset z_deflateReset +# define deflateResetKeep z_deflateResetKeep +# define deflateSetDictionary z_deflateSetDictionary +# define deflateSetHeader z_deflateSetHeader +# define deflateTune z_deflateTune +# define deflate_copyright z_deflate_copyright +# define get_crc_table z_get_crc_table +# ifndef Z_SOLO +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzgetc z_gzgetc +# define gzgetc_ z_gzgetc_ +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# ifdef _WIN32 +# define gzopen_w z_gzopen_w +# endif +# define gzprintf z_gzprintf +# define gzvprintf z_gzvprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzwrite z_gzwrite +# endif +# define inflate z_inflate +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define inflateBackInit_ z_inflateBackInit_ +# define inflateCopy z_inflateCopy +# define inflateEnd z_inflateEnd +# define inflateGetHeader z_inflateGetHeader +# define inflateInit2_ z_inflateInit2_ +# define inflateInit_ z_inflateInit_ +# define inflateMark z_inflateMark +# define inflatePrime z_inflatePrime +# define inflateReset z_inflateReset +# define inflateReset2 z_inflateReset2 +# define inflateSetDictionary z_inflateSetDictionary +# define inflateGetDictionary z_inflateGetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateUndermine z_inflateUndermine +# define inflateResetKeep z_inflateResetKeep +# define inflate_copyright z_inflate_copyright +# define inflate_fast z_inflate_fast +# define inflate_table z_inflate_table +# ifndef Z_SOLO +# define uncompress z_uncompress +# endif +# define zError z_zError +# ifndef Z_SOLO +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# endif +# define zlibCompileFlags z_zlibCompileFlags +# define zlibVersion z_zlibVersion + +/* all zlib typedefs in zlib.h and zconf.h */ +# define Byte z_Byte +# define Bytef z_Bytef +# define alloc_func z_alloc_func +# define charf z_charf +# define free_func z_free_func +# ifndef Z_SOLO +# define gzFile z_gzFile +# endif +# define gz_header z_gz_header +# define gz_headerp z_gz_headerp +# define in_func z_in_func +# define intf z_intf +# define out_func z_out_func +# define uInt z_uInt +# define uIntf z_uIntf +# define uLong z_uLong +# define uLongf z_uLongf +# define voidp z_voidp +# define voidpc z_voidpc +# define voidpf z_voidpf + +/* all zlib structs in zlib.h and zconf.h */ +# define gz_header_s z_gz_header_s +# define internal_state z_internal_state + +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +#if defined(ZLIB_CONST) && !defined(z_const) +# define z_const const +#else +# define z_const +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +#ifndef Z_ARG /* function prototypes for stdarg */ +# if defined(STDC) || defined(Z_HAVE_STDARG_H) +# define Z_ARG(args) args +# else +# define Z_ARG(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) +# include +# if (UINT_MAX == 0xffffffffUL) +# define Z_U4 unsigned +# elif (ULONG_MAX == 0xffffffffUL) +# define Z_U4 unsigned long +# elif (USHRT_MAX == 0xffffffffUL) +# define Z_U4 unsigned short +# endif +#endif + +#ifdef Z_U4 + typedef Z_U4 z_crc_t; +#else + typedef unsigned long z_crc_t; +#endif + +#if 1 /* was set to #if 1 by ./configure */ +# define Z_HAVE_UNISTD_H +#endif + +#if 1 /* was set to #if 1 by ./configure */ +# define Z_HAVE_STDARG_H +#endif + +#ifdef STDC +# ifndef Z_SOLO +# include /* for off_t */ +# endif +#endif + +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +# include /* for va_list */ +# endif +#endif + +#ifdef _WIN32 +# ifndef Z_SOLO +# include /* for wchar_t */ +# endif +#endif + +/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and + * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even + * though the former does not conform to the LFS document), but considering + * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as + * equivalently requesting no 64-bit operations + */ +#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 +# undef _LARGEFILE64_SOURCE +#endif + +#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) +# define Z_HAVE_UNISTD_H +#endif +#ifndef Z_SOLO +# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) +# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ +# ifdef VMS +# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif +# endif +#endif + +#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 +# define Z_LFS64 +#endif + +#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) +# define Z_LARGE64 +#endif + +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) +# define Z_WANT64 +#endif + +#if !defined(SEEK_SET) && !defined(Z_SOLO) +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif + +#ifndef z_off_t +# define z_off_t long +#endif + +#if !defined(_WIN32) && defined(Z_LARGE64) +# define z_off64_t off64_t +#else +# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +# define z_off64_t __int64 +# else +# define z_off64_t z_off_t +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) + #pragma map(deflateInit_,"DEIN") + #pragma map(deflateInit2_,"DEIN2") + #pragma map(deflateEnd,"DEEND") + #pragma map(deflateBound,"DEBND") + #pragma map(inflateInit_,"ININ") + #pragma map(inflateInit2_,"ININ2") + #pragma map(inflateEnd,"INEND") + #pragma map(inflateSync,"INSY") + #pragma map(inflateSetDictionary,"INSEDI") + #pragma map(compressBound,"CMBND") + #pragma map(inflate_table,"INTABL") + #pragma map(inflate_fast,"INFA") + #pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/external/zlib/include/zlib.h b/external/zlib/include/zlib.h new file mode 100755 index 0000000000..3e0c7672ac --- /dev/null +++ b/external/zlib/include/zlib.h @@ -0,0 +1,1768 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.8, April 28th, 2013 + + Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 + (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.8" +#define ZLIB_VERNUM 0x1280 +#define ZLIB_VER_MAJOR 1 +#define ZLIB_VER_MINOR 2 +#define ZLIB_VER_REVISION 8 +#define ZLIB_VER_SUBREVISION 0 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed data. + This version of the library supports only one compression method (deflation) + but other algorithms will be added later and will have the same stream + interface. + + Compression can be done in a single step if the buffers are large enough, + or can be done by repeated calls of the compression function. In the latter + case, the application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never crash + even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + z_const Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total number of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total number of bytes output so far */ + + z_const char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has dropped + to zero. It must update next_out and avail_out when avail_out has dropped + to zero. The application must initialize zalloc, zfree and opaque before + calling the init function. All other fields are set by the compression + library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this if + the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers + returned by zalloc for objects of exactly 65536 bytes *must* have their + offset normalized to zero. The default allocation function provided by this + library ensures this (see zutil.c). To reduce memory requirements and avoid + any allocation of 64K objects, at the expense of compression ratio, compile + the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or progress + reports. After compression, total_in holds the total size of the + uncompressed data and may be saved for use in the decompressor (particularly + if the decompressor wants to decompress everything in a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +#define Z_TREES 6 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is not + compatible with the zlib.h header file used by the application. This check + is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. If + zalloc and zfree are set to Z_NULL, deflateInit updates them to use default + allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at all + (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION + requests a default compromise between speed and compression (currently + equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if level is not a valid compression level, or + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). msg is set to null + if there is no error message. deflateInit does not perform any compression: + this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). Some + output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating avail_in or avail_out accordingly; avail_out should + never be zero before the call. The application can consume the compressed + output when it wants, for example when the output buffer is full (avail_out + == 0), or after each call of deflate(). If deflate returns Z_OK and with + zero avail_out, it must be called again after making room in the output + buffer because there might be more output pending. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumulate before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In + particular avail_in is zero after the call if enough output space has been + provided before the call.) Flushing may degrade compression for some + compression algorithms and so it should be used only when necessary. This + completes the current deflate block and follows it with an empty stored block + that is three bits plus filler bits to the next byte, followed by four bytes + (00 00 ff ff). + + If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the + output buffer, but the output is not aligned to a byte boundary. All of the + input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. + This completes the current deflate block and follows it with an empty fixed + codes block that is 10 bits long. This assures that enough bytes are output + in order for the decompressor to finish the block before the empty fixed code + block. + + If flush is set to Z_BLOCK, a deflate block is completed and emitted, as + for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to + seven bits of the current block are held to be written as the next byte after + the next deflate block is completed. In this case, the decompressor may not + be provided enough bits at this point in order to complete decompression of + the data provided so far to the compressor. It may need to wait for the next + block to be emitted. This is for advanced applications that need to control + the emission of deflate blocks. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there was + enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the stream + are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least the + value returned by deflateBound (see below). Then deflate is guaranteed to + return Z_STREAM_END. If not enough output space is provided, deflate will + not return Z_STREAM_END, and it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect the + compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, msg + may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the + exact value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit() does not process any header information -- that is deferred + until inflate() is called. +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing will + resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there is + no more input data or no more space in the output buffer (see below about + the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating the next_* and avail_* values accordingly. The + application can consume the uncompressed output when it wants, for example + when the output buffer is full (avail_out == 0), or after each call of + inflate(). If inflate returns Z_OK and with zero avail_out, it must be + called again after making room in the output buffer because there might be + more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, + Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() + stop if and when it gets to the next deflate block boundary. When decoding + the zlib or gzip format, this will cause inflate() to return immediately + after the header and before the first block. When doing a raw inflate, + inflate() will go ahead and process the first block, and will return when it + gets to the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 if + inflate() is currently decoding the last block in the deflate stream, plus + 128 if inflate() returned immediately after decoding an end-of-block code or + decoding the complete header up to just before the first byte of the deflate + stream. The end-of-block will not be indicated until all of the uncompressed + data from that block has been written to strm->next_out. The number of + unused bits may in general be greater than seven, except when bit 7 of + data_type is set, in which case the number of unused bits will be less than + eight. data_type is set as noted here every time inflate() returns for all + flush options, and so can be used to determine the amount of currently + consumed input in bits. + + The Z_TREES option behaves as Z_BLOCK does, but it also returns when the + end of each deflate block header is reached, before any actual data in that + block is decoded. This allows the caller to determine the length of the + deflate block header for later use in random access within a deflate block. + 256 is added to the value of strm->data_type when inflate() returns + immediately after reaching the end of the deflate block header. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step (a + single call of inflate), the parameter flush should be set to Z_FINISH. In + this case all pending input is processed and all pending output is flushed; + avail_out must be large enough to hold all of the uncompressed data for the + operation to complete. (The size of the uncompressed data may have been + saved by the compressor for this purpose.) The use of Z_FINISH is not + required to perform an inflation in one step. However it may be used to + inform inflate that a faster approach can be used for the single inflate() + call. Z_FINISH also informs inflate to not maintain a sliding window if the + stream completes, which reduces inflate's memory footprint. If the stream + does not complete, either because not all of the stream is provided or not + enough output space is provided, then a sliding window will be allocated and + inflate() can be called again to continue the operation as if Z_NO_FLUSH had + been used. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the effects of the flush parameter in this implementation are + on the return value of inflate() as noted below, when inflate() returns early + when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of + memory for a sliding window when Z_FINISH is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the Adler-32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the Adler-32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() can decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically, if requested when + initializing with inflateInit2(). Any information contained in the gzip + header is not retained, so applications that need that information should + instead use raw inflate, see inflateInit2() below, or inflateBack() and + perform their own processing of the gzip header and trailer. When processing + gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output + producted so far. The CRC-32 is checked against the gzip trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may + then call inflateSync() to look for a good compression block if a partial + recovery of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by the + caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), no + header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but is + slow and reduces compression ratio; memLevel=9 uses maximum memory for + optimal speed. The default value is 8. See zconf.h for total memory usage + as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as + fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The + strategy parameter only affects the compression ratio but not the + correctness of the compressed output even if it is not set appropriately. + Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler + decoder for special applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid + method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is + incompatible with the version assumed by the caller (ZLIB_VERSION). msg is + set to null if there is no error message. deflateInit2 does not perform any + compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. When using the zlib format, this + function must be called immediately after deflateInit, deflateInit2 or + deflateReset, and before any call of deflate. When doing raw deflate, this + function must be called either before any call of deflate, or immediately + after the completion of a deflate block, i.e. after all input has been + consumed and all output has been delivered when using any of the flush + options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The + compressor and decompressor must use exactly the same dictionary (see + inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size + provided in deflateInit or deflateInit2. Thus the strings most likely to be + useful should be put at the end of the dictionary, not at the front. In + addition, the current implementation of deflate will use at most the window + size minus 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if not at a block boundary for raw deflate). deflateSetDictionary does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and can + consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. The + stream will keep the same compression level and any other attributes that + may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different strategy. + If the compression level is changed, the input available so far is + compressed with the old level (and may be flushed); the new level will take + effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to be + compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if + strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() or + deflateInit2(), and after deflateSetHeader(), if used. This would be used + to allocate an output buffer for deflation in a single pass, and so would be + called before deflate(). If that first deflate() call is provided the + sourceLen input bytes, an output buffer allocated to the size returned by + deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed + to return Z_STREAM_END. Note that it is possible for the compressed size to + be larger than the value returned by deflateBound() if flush options other + than Z_FINISH or Z_NO_FLUSH are used. +*/ + +ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, + unsigned *pending, + int *bits)); +/* + deflatePending() returns the number of bytes and bits of output that have + been generated, but not yet provided in the available output. The bytes not + provided would be due to the available output space having being consumed. + The number of bits of output not provided are between 0 and 7, where they + await more bits to join them in order to fill out a full byte. If pending + or bits are Z_NULL, then those values are not set. + + deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. + */ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the bits + leftover from a previous deflate stream when appending to it. As such, this + function can only be used for raw deflate, and must be used before the first + deflate() call after a deflateInit2() or deflateReset(). bits must be less + than or equal to 16, and that many of the least significant bits of value + will be inserted in the output. + + deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough + room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be zero to request that inflate use the window size in + the zlib header of the compressed stream. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a + crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit2 does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit2() does not process any header information -- that is + deferred until inflate() is called. +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called at any + time to set the dictionary. If the provided dictionary is smaller than the + window and there is already data in the window, then the provided dictionary + will amend what's there. The application must insure that the dictionary + that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, + Bytef *dictionary, + uInt *dictLength)); +/* + Returns the sliding dictionary being maintained by inflate. dictLength is + set to the number of bytes in the dictionary, and that many bytes are copied + to dictionary. dictionary must have enough space, where 32768 bytes is + always enough. If inflateGetDictionary() is called with dictionary equal to + Z_NULL, then only the dictionary length is returned, and nothing is copied. + Similary, if dictLength is Z_NULL, then it is not set. + + inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the + stream state is inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a possible full flush point (see above + for the description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync searches for a 00 00 FF FF pattern in the compressed data. + All full flush points have this pattern, but not all occurrences of this + pattern are full flush points. + + inflateSync returns Z_OK if a possible full flush point has been found, + Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point + has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. + In the success case, the application may save the current current value of + total_in which indicates where valid compressed data was found. In the + error case, the application may repeatedly call inflateSync, providing more + input each time, until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. The + stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, + int windowBits)); +/* + This function is the same as inflateReset, but it also permits changing + the wrap and window size requests. The windowBits parameter is interpreted + the same as it is for inflateInit2. + + inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL), or if + the windowBits parameter is invalid. +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + If bits is negative, then the input stream bit buffer is emptied. Then + inflatePrime() can be called again to put bits in the buffer. This is used + to clear out bits leftover after feeding inflate a block description prior + to feeding inflate codes. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); +/* + This function returns two values, one in the lower 16 bits of the return + value, and the other in the remaining upper bits, obtained by shifting the + return value down 16 bits. If the upper value is -1 and the lower value is + zero, then inflate() is currently decoding information outside of a block. + If the upper value is -1 and the lower value is non-zero, then inflate is in + the middle of a stored block, with the lower value equaling the number of + bytes from the input remaining to copy. If the upper value is not -1, then + it is the number of bits back from the current bit position in the input of + the code (literal or length/distance pair) currently being processed. In + that case the lower value is the number of bytes already emitted for that + code. + + A code is being processed if inflate is waiting for more input to complete + decoding of the code, or if it has completed decoding but is waiting for + more output space to write the literal or match data. + + inflateMark() is used to mark locations in the input data for random + access, which may be at bit positions, and to note those cases where the + output of a code may span boundaries of random access blocks. The current + location in the input stream can be determined from avail_in and data_type + as noted in the description for the Z_BLOCK flush parameter for inflate. + + inflateMark returns the value noted above or -1 << 16 if the provided + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be + used to force inflate() to return immediately after header processing is + complete and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When any + of extra, name, or comment are not Z_NULL and the respective field is not + present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the parameters are invalid, Z_MEM_ERROR if the internal state could not be + allocated, or Z_VERSION_ERROR if the version of the library does not match + the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, + z_const unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is potentially more efficient than + inflate() for file i/o applications, in that it avoids copying between the + output and the sliding window by simply making the window itself the output + buffer. inflate() can be faster on modern CPUs when used with large + buffers. inflateBack() trusts the application to not change the output + buffer passed by the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free the + allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects only + the raw deflate stream to decompress. This is different from the normal + behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format error + in the deflate stream (in which case strm->msg is set to indicate the nature + of the error), or Z_STREAM_ERROR if the stream was not properly initialized. + In the case of Z_BUF_ERROR, an input or output error can be distinguished + using strm->next_in which will be Z_NULL only if in() returned an error. If + strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning + non-zero. (in() will always be called before out(), so strm->next_in is + assured to be defined if out() returns non-zero.) Note that inflateBack() + cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + +#ifndef Z_SOLO + + /* utility functions */ + +/* + The following utility functions are implemented on top of the basic + stream-oriented functions. To simplify the interface, some default options + are assumed (compression level and memory usage, standard memory allocation + functions). The source code of these utility functions can be modified if + you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before a + compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be large enough to hold the entire + uncompressed data. (The size of the uncompressed data must have been saved + previously by the compressor and transmitted to the decompressor by some + mechanism outside the scope of this compression library.) Upon exit, destLen + is the actual size of the uncompressed buffer. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In + the case where there is not enough room, uncompress() will fill the output + buffer with the uncompressed data up to that point. +*/ + + /* gzip file access functions */ + +/* + This library supports reading and writing files in gzip (.gz) format with + an interface similar to that of stdio, using the functions that start with + "gz". The gzip format is different from the zlib format. gzip is a gzip + wrapper, documented in RFC 1952, wrapped around a deflate stream. +*/ + +typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ + +/* +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); + + Opens a gzip (.gz) file for reading or writing. The mode parameter is as + in fopen ("rb" or "wb") but can also include a compression level ("wb9") or + a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only + compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' + for fixed code compression as in "wb9F". (See the description of + deflateInit2 for more information about the strategy parameter.) 'T' will + request transparent writing or appending with no compression and not using + the gzip format. + + "a" can be used instead of "w" to request that the gzip stream that will + be written be appended to the file. "+" will result in an error, since + reading and writing to the same gzip file is not supported. The addition of + "x" when writing will create the file exclusively, which fails if the file + already exists. On systems that support it, the addition of "e" when + reading or writing will set the flag to close the file on an execve() call. + + These functions, as well as gzip, will read and decode a sequence of gzip + streams in a file. The append function of gzopen() can be used to create + such a file. (Also see gzflush() for another way to do this.) When + appending, gzopen does not test whether the file begins with a gzip stream, + nor does it look for the end of the gzip streams to begin appending. gzopen + will simply append a gzip stream to the existing file. + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. When + reading, this will be detected automatically by looking for the magic two- + byte gzip header. + + gzopen returns NULL if the file could not be opened, if there was + insufficient memory to allocate the gzFile state, or if an invalid mode was + specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). + errno can be checked to determine if the reason gzopen failed was that the + file could not be opened. +*/ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen associates a gzFile with the file descriptor fd. File descriptors + are obtained from calls like open, dup, creat, pipe or fileno (if the file + has been previously opened with fopen). The mode parameter is as in gzopen. + + The next call of gzclose on the returned gzFile will also close the file + descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor + fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, + mode);. The duplicated descriptor should be saved to avoid a leak, since + gzdopen does not close fd if it fails. If you are using fileno() to get the + file descriptor from a FILE *, then you will have to use dup() to avoid + double-close()ing the file descriptor. Both gzclose() and fclose() will + close the associated file descriptor, so they need to have different file + descriptors. + + gzdopen returns NULL if there was insufficient memory to allocate the + gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not + provided, or '+' was provided), or if fd is -1. The file descriptor is not + used until the next gz* read, write, seek, or close operation, so gzdopen + will not detect if fd is invalid (unless fd is -1). +*/ + +ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); +/* + Set the internal buffer size used by this library's functions. The + default buffer size is 8192 bytes. This function must be called after + gzopen() or gzdopen(), and before any other calls that read or write the + file. The buffer memory allocation is always deferred to the first read or + write. Two buffers are allocated, either both of the specified size when + writing, or one of the specified size and the other twice that size when + reading. A larger buffer size of, for example, 64K or 128K bytes will + noticeably increase the speed of decompression (reading). + + The new buffer size also affects the maximum length for gzprintf(). + + gzbuffer() returns 0 on success, or -1 on failure, such as being called + too late. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. If + the input file is not in gzip format, gzread copies the given number of + bytes into the buffer directly from the file. + + After reaching the end of a gzip stream in the input, gzread will continue + to read, looking for another gzip stream. Any number of gzip streams may be + concatenated in the input file, and will all be decompressed by gzread(). + If something other than a gzip stream is encountered after a gzip stream, + that remaining trailing garbage is ignored (and no error is returned). + + gzread can be used to read a gzip file that is being concurrently written. + Upon reaching the end of the input, gzread will return with the available + data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then + gzclearerr can be used to clear the end of file indicator in order to permit + gzread to be tried again. Z_OK indicates that a gzip stream was completed + on the last gzread. Z_BUF_ERROR indicates that the input file ended in the + middle of a gzip stream. Note that gzread does not return -1 in the event + of an incomplete gzip stream. This error is deferred until gzclose(), which + will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip + stream. Alternatively, gzerror can be used before gzclose to detect this + case. + + gzread returns the number of uncompressed bytes actually read, less than + len for end of file, or -1 for error. +*/ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes written or 0 in case of + error. +*/ + +ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the arguments to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written, or 0 in case of error. The number of + uncompressed bytes written is limited to 8191, or one less than the buffer + size given to gzbuffer(). The caller should assure that this limit is not + exceeded. If it is exceeded, then gzprintf() will return an error (0) with + nothing written. In this case, there may also be a buffer overflow with + unpredictable consequences, which is possible only if zlib was compiled with + the insecure functions sprintf() or vsprintf() because the secure snprintf() + or vsnprintf() functions were not available. This can be determined using + zlibCompileFlags(). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or a + newline character is read and transferred to buf, or an end-of-file + condition is encountered. If any characters are read or if len == 1, the + string is terminated with a null character. If no characters are read due + to an end-of-file or len < 1, then the buffer is left untouched. + + gzgets returns buf which is a null-terminated string, or it returns NULL + for end-of-file or in case of error. If there was an error, the contents at + buf are indeterminate. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. gzputc + returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte or -1 + in case of end of file or error. This is implemented as a macro for speed. + As such, it does not do all of the checking the other functions do. I.e. + it does not check to see if file is NULL, nor whether the structure file + points to has been clobbered or not. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read as the first character + on the next read. At least one character of push-back is allowed. + gzungetc() returns the character pushed, or -1 on failure. gzungetc() will + fail if c is -1, and may fail if a character has been pushed but not read + yet. If gzungetc is used immediately after gzopen or gzdopen, at least the + output buffer size of pushed characters is allowed. (See gzbuffer above.) + The pushed character will be discarded if the stream is repositioned with + gzseek() or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter flush + is as in the deflate() function. The return value is the zlib error number + (see function gzerror below). gzflush is only permitted when writing. + + If the flush parameter is Z_FINISH, the remaining data is written and the + gzip stream is completed in the output. If gzwrite() is called again, a new + gzip stream will be started in the output. gzread() is able to read such + concatented gzip streams. + + gzflush should be called only when strictly necessary because it will + degrade compression if called too often. +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); + + Sets the starting position for the next gzread or gzwrite on the given + compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); + + Returns the starting position for the next gzread or gzwrite on the given + compressed file. This position represents a number of bytes in the + uncompressed data stream, and is zero when starting, even if appending or + reading a gzip stream from the middle of a file using gzdopen(). + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); + + Returns the current offset in the file being read or written. This offset + includes the count of bytes that precede the gzip stream, for example when + appending or when using gzdopen() for reading. When reading, the offset + does not include as yet unused buffered input. This information can be used + for a progress indicator. On error, gzoffset() returns -1. +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns true (1) if the end-of-file indicator has been set while reading, + false (0) otherwise. Note that the end-of-file indicator is set only if the + read tried to go past the end of the input, but came up short. Therefore, + just like feof(), gzeof() may return false even if there is no more data to + read, in the event that the last read request was for the exact number of + bytes remaining in the input file. This will happen if the input file size + is an exact multiple of the buffer size. + + If gzeof() returns true, then the read functions will return no more data, + unless the end-of-file indicator is reset by gzclearerr() and the input file + has grown since the previous end of file was detected. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns true (1) if file is being copied directly while reading, or false + (0) if file is a gzip stream being decompressed. + + If the input file is empty, gzdirect() will return true, since the input + does not contain a gzip stream. + + If gzdirect() is used immediately after gzopen() or gzdopen() it will + cause buffers to be allocated to allow reading the file to determine if it + is a gzip file. Therefore if gzbuffer() is used, it should be called before + gzdirect(). + + When writing, gzdirect() returns true (1) if transparent writing was + requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: + gzdirect() is not needed when writing. Transparent writing must be + explicitly requested, so the application already knows the answer. When + linking statically, using gzdirect() will include all of the zlib code for + gzip file reading and decompression, which may not be desired.) +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file and + deallocates the (de)compression state. Note that once file is closed, you + cannot call gzerror with file, since its structures have been deallocated. + gzclose must not be called more than once on the same file, just as free + must not be called more than once on the same allocation. + + gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a + file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the + last read ended in the middle of a gzip stream, or Z_OK on success. +*/ + +ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); +/* + Same as gzclose(), but gzclose_r() is only for use when reading, and + gzclose_w() is only for use when writing or appending. The advantage to + using these instead of gzclose() is that they avoid linking in zlib + compression or decompression code that is not used when only reading or only + writing respectively. If gzclose() is used, then both compression and + decompression code will be included the application when linking to a static + zlib library. +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the given + compressed file. errnum is set to zlib error number. If an error occurred + in the file system and not in the compression library, errnum is set to + Z_ERRNO and the application may consult errno to get the exact error code. + + The application must not modify the returned string. Future calls to + this function may invalidate the previously returned string. If file is + closed, then the string previously returned by gzerror will no longer be + available. + + gzerror() should be used to distinguish errors from end-of-file for those + functions above that do not distinguish those cases in their return values. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + +#endif /* !Z_SOLO */ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the compression + library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is Z_NULL, this function returns the + required initial value for the checksum. + + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. + + Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +/* +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); + + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note + that the z_off_t type (like off_t) is a signed integer. If len2 is + negative, the result has no meaning or utility. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is Z_NULL, this function returns the required + initial value for the crc. Pre- and post-conditioning (one's complement) is + performed within this function so it shouldn't be done by the application. + + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +/* +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ + (int)sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, (int)sizeof(z_stream)) + +#ifndef Z_SOLO + +/* gzgetc() macro and its supporting function and exposed data structure. Note + * that the real internal state is much larger than the exposed structure. + * This abbreviated structure exposes just enough for the gzgetc() macro. The + * user should not mess with these exposed elements, since their names or + * behavior could change in the future, perhaps even capriciously. They can + * only be used by the gzgetc() macro. You have been warned. + */ +struct gzFile_s { + unsigned have; + unsigned char *next; + z_off64_t pos; +}; +ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ +#ifdef Z_PREFIX_SET +# undef z_gzgetc +# define z_gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) +#else +# define gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) +#endif + +/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or + * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if + * both are true, the application gets the *64 functions, and the regular + * functions are changed to 64 bits) -- in case these are set on systems + * without large file support, _LFS64_LARGEFILE must also be true + */ +#ifdef Z_LARGE64 + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); + ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); +#endif + +#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) +# ifdef Z_PREFIX_SET +# define z_gzopen z_gzopen64 +# define z_gzseek z_gzseek64 +# define z_gztell z_gztell64 +# define z_gzoffset z_gzoffset64 +# define z_adler32_combine z_adler32_combine64 +# define z_crc32_combine z_crc32_combine64 +# else +# define gzopen gzopen64 +# define gzseek gzseek64 +# define gztell gztell64 +# define gzoffset gzoffset64 +# define adler32_combine adler32_combine64 +# define crc32_combine crc32_combine64 +# endif +# ifndef Z_LARGE64 + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); +# endif +#else + ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); +#endif + +#else /* Z_SOLO */ + + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); + +#endif /* !Z_SOLO */ + +/* hack for buggy compilers */ +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; +#endif + +/* undocumented functions */ +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); +ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); +ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); +ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); +ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); +#if defined(_WIN32) && !defined(Z_SOLO) +ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, + const char *mode)); +#endif +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, + const char *format, + va_list va)); +# endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/external/zlib/prebuilt/android/Android.mk b/external/zlib/prebuilt/android/Android.mk new file mode 100755 index 0000000000..19399169a0 --- /dev/null +++ b/external/zlib/prebuilt/android/Android.mk @@ -0,0 +1,8 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_MODULE := cocos_zlib_static +LOCAL_MODULE_FILENAME := zlib +LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libz.a +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include +include $(PREBUILT_STATIC_LIBRARY) diff --git a/external/zlib/prebuilt/android/armeabi-v7a/libz.a b/external/zlib/prebuilt/android/armeabi-v7a/libz.a new file mode 100755 index 0000000000..268c1193be Binary files /dev/null and b/external/zlib/prebuilt/android/armeabi-v7a/libz.a differ diff --git a/external/zlib/prebuilt/android/armeabi/libz.a b/external/zlib/prebuilt/android/armeabi/libz.a new file mode 100755 index 0000000000..54f68523f4 Binary files /dev/null and b/external/zlib/prebuilt/android/armeabi/libz.a differ diff --git a/external/zlib/prebuilt/android/x86/libz.a b/external/zlib/prebuilt/android/x86/libz.a new file mode 100755 index 0000000000..b55a516f6b Binary files /dev/null and b/external/zlib/prebuilt/android/x86/libz.a differ diff --git a/external/zlib/prebuilt/mac/libz.a b/external/zlib/prebuilt/mac/libz.a new file mode 100755 index 0000000000..294579d029 Binary files /dev/null and b/external/zlib/prebuilt/mac/libz.a differ diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index fc4c6c8c95..3cdf679e8d 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -281,6 +281,8 @@ "cocos/3d/CCSprite3D.h", "cocos/3d/CCSprite3DMaterial.cpp", "cocos/3d/CCSprite3DMaterial.h", + "cocos/3d/CCTerrain.cpp", + "cocos/3d/CCTerrain.h", "cocos/3d/CCTextureCube.cpp", "cocos/3d/CCTextureCube.h", "cocos/3d/CMakeLists.txt", @@ -557,8 +559,6 @@ "cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineNode.h", "cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp", "cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h", - "cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.cpp", - "cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.h", "cocos/editor-support/cocostudio/ActionTimeline/CCTimeLine.cpp", "cocos/editor-support/cocostudio/ActionTimeline/CCTimeLine.h", "cocos/editor-support/cocostudio/ActionTimeline/CCTimelineMacro.h", @@ -1124,6 +1124,8 @@ "cocos/renderer/ccShader_3D_PositionTex.vert", "cocos/renderer/ccShader_3D_Skybox.frag", "cocos/renderer/ccShader_3D_Skybox.vert", + "cocos/renderer/ccShader_3D_Terrain.frag", + "cocos/renderer/ccShader_3D_Terrain.vert", "cocos/renderer/ccShader_Label.vert", "cocos/renderer/ccShader_Label_df.frag", "cocos/renderer/ccShader_Label_df_glow.frag", @@ -1765,7 +1767,6 @@ "external/curl/include/android/curl/multi.h", "external/curl/include/android/curl/stdcheaders.h", "external/curl/include/android/curl/typecheck-gcc.h", - "external/curl/include/android/curl/types.h", "external/curl/include/ios/curl/curl.h", "external/curl/include/ios/curl/curlbuild-32.h", "external/curl/include/ios/curl/curlbuild-64.h", @@ -1778,8 +1779,6 @@ "external/curl/include/ios/curl/stdcheaders.h", "external/curl/include/ios/curl/typecheck-gcc.h", "external/curl/include/mac/curl/curl.h", - "external/curl/include/mac/curl/curlbuild-32.h", - "external/curl/include/mac/curl/curlbuild-64.h", "external/curl/include/mac/curl/curlbuild.h", "external/curl/include/mac/curl/curlrules.h", "external/curl/include/mac/curl/curlver.h", @@ -1842,8 +1841,8 @@ "external/curl/prebuilt/mac/libssl.a", "external/curl/prebuilt/win32/libcurl.dll", "external/curl/prebuilt/win32/libcurl_imp.lib", - "external/curl/prebuilt/win32/libeay32.dll", - "external/curl/prebuilt/win32/ssleay32.dll", + "external/curl/prebuilt/win32/libeay32.lib", + "external/curl/prebuilt/win32/ssleay32.lib", "external/curl/prebuilt/winrt_8.1/arm/libcurl.dll", "external/curl/prebuilt/winrt_8.1/arm/libcurl.lib", "external/curl/prebuilt/winrt_8.1/arm/libeay32.dll", @@ -1886,145 +1885,108 @@ "external/flatbuffers/idl_gen_text.cpp", "external/flatbuffers/idl_parser.cpp", "external/flatbuffers/util.h", - "external/freetype2/include/android/freetype2/freetype/config/ftconfig.h", - "external/freetype2/include/android/freetype2/freetype/config/ftheader.h", - "external/freetype2/include/android/freetype2/freetype/config/ftmodule.h", - "external/freetype2/include/android/freetype2/freetype/config/ftoption.h", - "external/freetype2/include/android/freetype2/freetype/config/ftstdlib.h", - "external/freetype2/include/android/freetype2/freetype/freetype.h", - "external/freetype2/include/android/freetype2/freetype/ftadvanc.h", - "external/freetype2/include/android/freetype2/freetype/ftautoh.h", - "external/freetype2/include/android/freetype2/freetype/ftbbox.h", - "external/freetype2/include/android/freetype2/freetype/ftbdf.h", - "external/freetype2/include/android/freetype2/freetype/ftbitmap.h", - "external/freetype2/include/android/freetype2/freetype/ftbzip2.h", - "external/freetype2/include/android/freetype2/freetype/ftcache.h", - "external/freetype2/include/android/freetype2/freetype/ftcffdrv.h", - "external/freetype2/include/android/freetype2/freetype/ftchapters.h", - "external/freetype2/include/android/freetype2/freetype/ftcid.h", - "external/freetype2/include/android/freetype2/freetype/fterrdef.h", - "external/freetype2/include/android/freetype2/freetype/fterrors.h", - "external/freetype2/include/android/freetype2/freetype/ftgasp.h", - "external/freetype2/include/android/freetype2/freetype/ftglyph.h", - "external/freetype2/include/android/freetype2/freetype/ftgxval.h", - "external/freetype2/include/android/freetype2/freetype/ftgzip.h", - "external/freetype2/include/android/freetype2/freetype/ftimage.h", - "external/freetype2/include/android/freetype2/freetype/ftincrem.h", - "external/freetype2/include/android/freetype2/freetype/ftlcdfil.h", - "external/freetype2/include/android/freetype2/freetype/ftlist.h", - "external/freetype2/include/android/freetype2/freetype/ftlzw.h", - "external/freetype2/include/android/freetype2/freetype/ftmac.h", - "external/freetype2/include/android/freetype2/freetype/ftmm.h", - "external/freetype2/include/android/freetype2/freetype/ftmodapi.h", - "external/freetype2/include/android/freetype2/freetype/ftmoderr.h", - "external/freetype2/include/android/freetype2/freetype/ftotval.h", - "external/freetype2/include/android/freetype2/freetype/ftoutln.h", - "external/freetype2/include/android/freetype2/freetype/ftpfr.h", - "external/freetype2/include/android/freetype2/freetype/ftrender.h", - "external/freetype2/include/android/freetype2/freetype/ftsizes.h", - "external/freetype2/include/android/freetype2/freetype/ftsnames.h", - "external/freetype2/include/android/freetype2/freetype/ftstroke.h", - "external/freetype2/include/android/freetype2/freetype/ftsynth.h", - "external/freetype2/include/android/freetype2/freetype/ftsystem.h", - "external/freetype2/include/android/freetype2/freetype/fttrigon.h", - "external/freetype2/include/android/freetype2/freetype/ftttdrv.h", - "external/freetype2/include/android/freetype2/freetype/fttypes.h", - "external/freetype2/include/android/freetype2/freetype/ftwinfnt.h", - "external/freetype2/include/android/freetype2/freetype/ftxf86.h", - "external/freetype2/include/android/freetype2/freetype/t1tables.h", - "external/freetype2/include/android/freetype2/freetype/ttnameid.h", - "external/freetype2/include/android/freetype2/freetype/tttables.h", - "external/freetype2/include/android/freetype2/freetype/tttags.h", - "external/freetype2/include/android/freetype2/freetype/ttunpat.h", - "external/freetype2/include/android/ft2build.h", - "external/freetype2/include/ios/freetype/config/ftconfig.h", - "external/freetype2/include/ios/freetype/config/ftheader.h", - "external/freetype2/include/ios/freetype/config/ftmodule.h", - "external/freetype2/include/ios/freetype/config/ftoption.h", - "external/freetype2/include/ios/freetype/config/ftstdlib.h", - "external/freetype2/include/ios/freetype/freetype.h", - "external/freetype2/include/ios/freetype/ftadvanc.h", - "external/freetype2/include/ios/freetype/ftautoh.h", - "external/freetype2/include/ios/freetype/ftbbox.h", - "external/freetype2/include/ios/freetype/ftbdf.h", - "external/freetype2/include/ios/freetype/ftbitmap.h", - "external/freetype2/include/ios/freetype/ftbzip2.h", - "external/freetype2/include/ios/freetype/ftcache.h", - "external/freetype2/include/ios/freetype/ftcffdrv.h", - "external/freetype2/include/ios/freetype/ftchapters.h", - "external/freetype2/include/ios/freetype/ftcid.h", - "external/freetype2/include/ios/freetype/fterrdef.h", - "external/freetype2/include/ios/freetype/fterrors.h", - "external/freetype2/include/ios/freetype/ftgasp.h", - "external/freetype2/include/ios/freetype/ftglyph.h", - "external/freetype2/include/ios/freetype/ftgxval.h", - "external/freetype2/include/ios/freetype/ftgzip.h", - "external/freetype2/include/ios/freetype/ftimage.h", - "external/freetype2/include/ios/freetype/ftincrem.h", - "external/freetype2/include/ios/freetype/ftlcdfil.h", - "external/freetype2/include/ios/freetype/ftlist.h", - "external/freetype2/include/ios/freetype/ftlzw.h", - "external/freetype2/include/ios/freetype/ftmac.h", - "external/freetype2/include/ios/freetype/ftmm.h", - "external/freetype2/include/ios/freetype/ftmodapi.h", - "external/freetype2/include/ios/freetype/ftmoderr.h", - "external/freetype2/include/ios/freetype/ftotval.h", - "external/freetype2/include/ios/freetype/ftoutln.h", - "external/freetype2/include/ios/freetype/ftpfr.h", - "external/freetype2/include/ios/freetype/ftrender.h", - "external/freetype2/include/ios/freetype/ftsizes.h", - "external/freetype2/include/ios/freetype/ftsnames.h", - "external/freetype2/include/ios/freetype/ftstroke.h", - "external/freetype2/include/ios/freetype/ftsynth.h", - "external/freetype2/include/ios/freetype/ftsystem.h", - "external/freetype2/include/ios/freetype/fttrigon.h", - "external/freetype2/include/ios/freetype/ftttdrv.h", - "external/freetype2/include/ios/freetype/fttypes.h", - "external/freetype2/include/ios/freetype/ftwinfnt.h", - "external/freetype2/include/ios/freetype/ftxf86.h", - "external/freetype2/include/ios/freetype/internal/autohint.h", - "external/freetype2/include/ios/freetype/internal/ftcalc.h", - "external/freetype2/include/ios/freetype/internal/ftdebug.h", - "external/freetype2/include/ios/freetype/internal/ftdriver.h", - "external/freetype2/include/ios/freetype/internal/ftgloadr.h", - "external/freetype2/include/ios/freetype/internal/ftmemory.h", - "external/freetype2/include/ios/freetype/internal/ftobjs.h", - "external/freetype2/include/ios/freetype/internal/ftpic.h", - "external/freetype2/include/ios/freetype/internal/ftrfork.h", - "external/freetype2/include/ios/freetype/internal/ftserv.h", - "external/freetype2/include/ios/freetype/internal/ftstream.h", - "external/freetype2/include/ios/freetype/internal/fttrace.h", - "external/freetype2/include/ios/freetype/internal/ftvalid.h", - "external/freetype2/include/ios/freetype/internal/internal.h", - "external/freetype2/include/ios/freetype/internal/psaux.h", - "external/freetype2/include/ios/freetype/internal/pshints.h", - "external/freetype2/include/ios/freetype/internal/services/svbdf.h", - "external/freetype2/include/ios/freetype/internal/services/svcid.h", - "external/freetype2/include/ios/freetype/internal/services/svgldict.h", - "external/freetype2/include/ios/freetype/internal/services/svgxval.h", - "external/freetype2/include/ios/freetype/internal/services/svkern.h", - "external/freetype2/include/ios/freetype/internal/services/svmm.h", - "external/freetype2/include/ios/freetype/internal/services/svotval.h", - "external/freetype2/include/ios/freetype/internal/services/svpfr.h", - "external/freetype2/include/ios/freetype/internal/services/svpostnm.h", - "external/freetype2/include/ios/freetype/internal/services/svprop.h", - "external/freetype2/include/ios/freetype/internal/services/svpscmap.h", - "external/freetype2/include/ios/freetype/internal/services/svpsinfo.h", - "external/freetype2/include/ios/freetype/internal/services/svsfnt.h", - "external/freetype2/include/ios/freetype/internal/services/svttcmap.h", - "external/freetype2/include/ios/freetype/internal/services/svtteng.h", - "external/freetype2/include/ios/freetype/internal/services/svttglyf.h", - "external/freetype2/include/ios/freetype/internal/services/svwinfnt.h", - "external/freetype2/include/ios/freetype/internal/services/svxf86nm.h", - "external/freetype2/include/ios/freetype/internal/sfnt.h", - "external/freetype2/include/ios/freetype/internal/t1types.h", - "external/freetype2/include/ios/freetype/internal/tttypes.h", - "external/freetype2/include/ios/freetype/t1tables.h", - "external/freetype2/include/ios/freetype/ttnameid.h", - "external/freetype2/include/ios/freetype/tttables.h", - "external/freetype2/include/ios/freetype/tttags.h", - "external/freetype2/include/ios/freetype/ttunpat.h", - "external/freetype2/include/ios/ft2build.h", + "external/freetype2/include/android/freetype2/config/ftconfig.h", + "external/freetype2/include/android/freetype2/config/ftheader.h", + "external/freetype2/include/android/freetype2/config/ftmodule.h", + "external/freetype2/include/android/freetype2/config/ftoption.h", + "external/freetype2/include/android/freetype2/config/ftstdlib.h", + "external/freetype2/include/android/freetype2/freetype.h", + "external/freetype2/include/android/freetype2/ft2build.h", + "external/freetype2/include/android/freetype2/ftadvanc.h", + "external/freetype2/include/android/freetype2/ftautoh.h", + "external/freetype2/include/android/freetype2/ftbbox.h", + "external/freetype2/include/android/freetype2/ftbdf.h", + "external/freetype2/include/android/freetype2/ftbitmap.h", + "external/freetype2/include/android/freetype2/ftbzip2.h", + "external/freetype2/include/android/freetype2/ftcache.h", + "external/freetype2/include/android/freetype2/ftcffdrv.h", + "external/freetype2/include/android/freetype2/ftchapters.h", + "external/freetype2/include/android/freetype2/ftcid.h", + "external/freetype2/include/android/freetype2/fterrdef.h", + "external/freetype2/include/android/freetype2/fterrors.h", + "external/freetype2/include/android/freetype2/ftgasp.h", + "external/freetype2/include/android/freetype2/ftglyph.h", + "external/freetype2/include/android/freetype2/ftgxval.h", + "external/freetype2/include/android/freetype2/ftgzip.h", + "external/freetype2/include/android/freetype2/ftimage.h", + "external/freetype2/include/android/freetype2/ftincrem.h", + "external/freetype2/include/android/freetype2/ftlcdfil.h", + "external/freetype2/include/android/freetype2/ftlist.h", + "external/freetype2/include/android/freetype2/ftlzw.h", + "external/freetype2/include/android/freetype2/ftmac.h", + "external/freetype2/include/android/freetype2/ftmm.h", + "external/freetype2/include/android/freetype2/ftmodapi.h", + "external/freetype2/include/android/freetype2/ftmoderr.h", + "external/freetype2/include/android/freetype2/ftotval.h", + "external/freetype2/include/android/freetype2/ftoutln.h", + "external/freetype2/include/android/freetype2/ftpfr.h", + "external/freetype2/include/android/freetype2/ftrender.h", + "external/freetype2/include/android/freetype2/ftsizes.h", + "external/freetype2/include/android/freetype2/ftsnames.h", + "external/freetype2/include/android/freetype2/ftstroke.h", + "external/freetype2/include/android/freetype2/ftsynth.h", + "external/freetype2/include/android/freetype2/ftsystem.h", + "external/freetype2/include/android/freetype2/fttrigon.h", + "external/freetype2/include/android/freetype2/ftttdrv.h", + "external/freetype2/include/android/freetype2/fttypes.h", + "external/freetype2/include/android/freetype2/ftwinfnt.h", + "external/freetype2/include/android/freetype2/ftxf86.h", + "external/freetype2/include/android/freetype2/t1tables.h", + "external/freetype2/include/android/freetype2/ttnameid.h", + "external/freetype2/include/android/freetype2/tttables.h", + "external/freetype2/include/android/freetype2/tttags.h", + "external/freetype2/include/android/freetype2/ttunpat.h", + "external/freetype2/include/ios/freetype2/config/ftconfig.h", + "external/freetype2/include/ios/freetype2/config/ftheader.h", + "external/freetype2/include/ios/freetype2/config/ftmodule.h", + "external/freetype2/include/ios/freetype2/config/ftoption.h", + "external/freetype2/include/ios/freetype2/config/ftstdlib.h", + "external/freetype2/include/ios/freetype2/freetype.h", + "external/freetype2/include/ios/freetype2/ft2build.h", + "external/freetype2/include/ios/freetype2/ftadvanc.h", + "external/freetype2/include/ios/freetype2/ftautoh.h", + "external/freetype2/include/ios/freetype2/ftbbox.h", + "external/freetype2/include/ios/freetype2/ftbdf.h", + "external/freetype2/include/ios/freetype2/ftbitmap.h", + "external/freetype2/include/ios/freetype2/ftbzip2.h", + "external/freetype2/include/ios/freetype2/ftcache.h", + "external/freetype2/include/ios/freetype2/ftcffdrv.h", + "external/freetype2/include/ios/freetype2/ftchapters.h", + "external/freetype2/include/ios/freetype2/ftcid.h", + "external/freetype2/include/ios/freetype2/fterrdef.h", + "external/freetype2/include/ios/freetype2/fterrors.h", + "external/freetype2/include/ios/freetype2/ftgasp.h", + "external/freetype2/include/ios/freetype2/ftglyph.h", + "external/freetype2/include/ios/freetype2/ftgxval.h", + "external/freetype2/include/ios/freetype2/ftgzip.h", + "external/freetype2/include/ios/freetype2/ftimage.h", + "external/freetype2/include/ios/freetype2/ftincrem.h", + "external/freetype2/include/ios/freetype2/ftlcdfil.h", + "external/freetype2/include/ios/freetype2/ftlist.h", + "external/freetype2/include/ios/freetype2/ftlzw.h", + "external/freetype2/include/ios/freetype2/ftmac.h", + "external/freetype2/include/ios/freetype2/ftmm.h", + "external/freetype2/include/ios/freetype2/ftmodapi.h", + "external/freetype2/include/ios/freetype2/ftmoderr.h", + "external/freetype2/include/ios/freetype2/ftotval.h", + "external/freetype2/include/ios/freetype2/ftoutln.h", + "external/freetype2/include/ios/freetype2/ftpfr.h", + "external/freetype2/include/ios/freetype2/ftrender.h", + "external/freetype2/include/ios/freetype2/ftsizes.h", + "external/freetype2/include/ios/freetype2/ftsnames.h", + "external/freetype2/include/ios/freetype2/ftstroke.h", + "external/freetype2/include/ios/freetype2/ftsynth.h", + "external/freetype2/include/ios/freetype2/ftsystem.h", + "external/freetype2/include/ios/freetype2/fttrigon.h", + "external/freetype2/include/ios/freetype2/ftttdrv.h", + "external/freetype2/include/ios/freetype2/fttypes.h", + "external/freetype2/include/ios/freetype2/ftwinfnt.h", + "external/freetype2/include/ios/freetype2/ftxf86.h", + "external/freetype2/include/ios/freetype2/t1tables.h", + "external/freetype2/include/ios/freetype2/ttnameid.h", + "external/freetype2/include/ios/freetype2/tttables.h", + "external/freetype2/include/ios/freetype2/tttags.h", + "external/freetype2/include/ios/freetype2/ttunpat.h", "external/freetype2/include/linux/freetype/config/ftconfig.h", "external/freetype2/include/linux/freetype/config/ftheader.h", "external/freetype2/include/linux/freetype/config/ftmodule.h", @@ -2032,11 +1994,13 @@ "external/freetype2/include/linux/freetype/config/ftstdlib.h", "external/freetype2/include/linux/freetype/freetype.h", "external/freetype2/include/linux/freetype/ftadvanc.h", + "external/freetype2/include/linux/freetype/ftautoh.h", "external/freetype2/include/linux/freetype/ftbbox.h", "external/freetype2/include/linux/freetype/ftbdf.h", "external/freetype2/include/linux/freetype/ftbitmap.h", "external/freetype2/include/linux/freetype/ftbzip2.h", "external/freetype2/include/linux/freetype/ftcache.h", + "external/freetype2/include/linux/freetype/ftcffdrv.h", "external/freetype2/include/linux/freetype/ftchapters.h", "external/freetype2/include/linux/freetype/ftcid.h", "external/freetype2/include/linux/freetype/fterrdef.h", @@ -2064,227 +2028,155 @@ "external/freetype2/include/linux/freetype/ftsynth.h", "external/freetype2/include/linux/freetype/ftsystem.h", "external/freetype2/include/linux/freetype/fttrigon.h", + "external/freetype2/include/linux/freetype/ftttdrv.h", "external/freetype2/include/linux/freetype/fttypes.h", "external/freetype2/include/linux/freetype/ftwinfnt.h", "external/freetype2/include/linux/freetype/ftxf86.h", - "external/freetype2/include/linux/freetype/internal/autohint.h", - "external/freetype2/include/linux/freetype/internal/ftcalc.h", - "external/freetype2/include/linux/freetype/internal/ftdebug.h", - "external/freetype2/include/linux/freetype/internal/ftdriver.h", - "external/freetype2/include/linux/freetype/internal/ftgloadr.h", - "external/freetype2/include/linux/freetype/internal/ftmemory.h", - "external/freetype2/include/linux/freetype/internal/ftobjs.h", - "external/freetype2/include/linux/freetype/internal/ftpic.h", - "external/freetype2/include/linux/freetype/internal/ftrfork.h", - "external/freetype2/include/linux/freetype/internal/ftserv.h", - "external/freetype2/include/linux/freetype/internal/ftstream.h", - "external/freetype2/include/linux/freetype/internal/fttrace.h", - "external/freetype2/include/linux/freetype/internal/ftvalid.h", - "external/freetype2/include/linux/freetype/internal/internal.h", - "external/freetype2/include/linux/freetype/internal/psaux.h", - "external/freetype2/include/linux/freetype/internal/pshints.h", - "external/freetype2/include/linux/freetype/internal/services/svbdf.h", - "external/freetype2/include/linux/freetype/internal/services/svcid.h", - "external/freetype2/include/linux/freetype/internal/services/svgldict.h", - "external/freetype2/include/linux/freetype/internal/services/svgxval.h", - "external/freetype2/include/linux/freetype/internal/services/svkern.h", - "external/freetype2/include/linux/freetype/internal/services/svmm.h", - "external/freetype2/include/linux/freetype/internal/services/svotval.h", - "external/freetype2/include/linux/freetype/internal/services/svpfr.h", - "external/freetype2/include/linux/freetype/internal/services/svpostnm.h", - "external/freetype2/include/linux/freetype/internal/services/svpscmap.h", - "external/freetype2/include/linux/freetype/internal/services/svpsinfo.h", - "external/freetype2/include/linux/freetype/internal/services/svsfnt.h", - "external/freetype2/include/linux/freetype/internal/services/svttcmap.h", - "external/freetype2/include/linux/freetype/internal/services/svtteng.h", - "external/freetype2/include/linux/freetype/internal/services/svttglyf.h", - "external/freetype2/include/linux/freetype/internal/services/svwinfnt.h", - "external/freetype2/include/linux/freetype/internal/services/svxf86nm.h", - "external/freetype2/include/linux/freetype/internal/sfnt.h", - "external/freetype2/include/linux/freetype/internal/t1types.h", - "external/freetype2/include/linux/freetype/internal/tttypes.h", "external/freetype2/include/linux/freetype/t1tables.h", "external/freetype2/include/linux/freetype/ttnameid.h", "external/freetype2/include/linux/freetype/tttables.h", "external/freetype2/include/linux/freetype/tttags.h", "external/freetype2/include/linux/freetype/ttunpat.h", "external/freetype2/include/linux/ft2build.h", - "external/freetype2/include/mac/freetype/config/ftconfig.h", - "external/freetype2/include/mac/freetype/config/ftheader.h", - "external/freetype2/include/mac/freetype/config/ftmodule.h", - "external/freetype2/include/mac/freetype/config/ftoption.h", - "external/freetype2/include/mac/freetype/config/ftstdlib.h", - "external/freetype2/include/mac/freetype/freetype.h", - "external/freetype2/include/mac/freetype/ftadvanc.h", - "external/freetype2/include/mac/freetype/ftautoh.h", - "external/freetype2/include/mac/freetype/ftbbox.h", - "external/freetype2/include/mac/freetype/ftbdf.h", - "external/freetype2/include/mac/freetype/ftbitmap.h", - "external/freetype2/include/mac/freetype/ftbzip2.h", - "external/freetype2/include/mac/freetype/ftcache.h", - "external/freetype2/include/mac/freetype/ftcffdrv.h", - "external/freetype2/include/mac/freetype/ftchapters.h", - "external/freetype2/include/mac/freetype/ftcid.h", - "external/freetype2/include/mac/freetype/fterrdef.h", - "external/freetype2/include/mac/freetype/fterrors.h", - "external/freetype2/include/mac/freetype/ftgasp.h", - "external/freetype2/include/mac/freetype/ftglyph.h", - "external/freetype2/include/mac/freetype/ftgxval.h", - "external/freetype2/include/mac/freetype/ftgzip.h", - "external/freetype2/include/mac/freetype/ftimage.h", - "external/freetype2/include/mac/freetype/ftincrem.h", - "external/freetype2/include/mac/freetype/ftlcdfil.h", - "external/freetype2/include/mac/freetype/ftlist.h", - "external/freetype2/include/mac/freetype/ftlzw.h", - "external/freetype2/include/mac/freetype/ftmac.h", - "external/freetype2/include/mac/freetype/ftmm.h", - "external/freetype2/include/mac/freetype/ftmodapi.h", - "external/freetype2/include/mac/freetype/ftmoderr.h", - "external/freetype2/include/mac/freetype/ftotval.h", - "external/freetype2/include/mac/freetype/ftoutln.h", - "external/freetype2/include/mac/freetype/ftpfr.h", - "external/freetype2/include/mac/freetype/ftrender.h", - "external/freetype2/include/mac/freetype/ftsizes.h", - "external/freetype2/include/mac/freetype/ftsnames.h", - "external/freetype2/include/mac/freetype/ftstroke.h", - "external/freetype2/include/mac/freetype/ftsynth.h", - "external/freetype2/include/mac/freetype/ftsystem.h", - "external/freetype2/include/mac/freetype/fttrigon.h", - "external/freetype2/include/mac/freetype/ftttdrv.h", - "external/freetype2/include/mac/freetype/fttypes.h", - "external/freetype2/include/mac/freetype/ftwinfnt.h", - "external/freetype2/include/mac/freetype/ftxf86.h", - "external/freetype2/include/mac/freetype/internal/autohint.h", - "external/freetype2/include/mac/freetype/internal/ftcalc.h", - "external/freetype2/include/mac/freetype/internal/ftdebug.h", - "external/freetype2/include/mac/freetype/internal/ftdriver.h", - "external/freetype2/include/mac/freetype/internal/ftgloadr.h", - "external/freetype2/include/mac/freetype/internal/ftmemory.h", - "external/freetype2/include/mac/freetype/internal/ftobjs.h", - "external/freetype2/include/mac/freetype/internal/ftpic.h", - "external/freetype2/include/mac/freetype/internal/ftrfork.h", - "external/freetype2/include/mac/freetype/internal/ftserv.h", - "external/freetype2/include/mac/freetype/internal/ftstream.h", - "external/freetype2/include/mac/freetype/internal/fttrace.h", - "external/freetype2/include/mac/freetype/internal/ftvalid.h", - "external/freetype2/include/mac/freetype/internal/internal.h", - "external/freetype2/include/mac/freetype/internal/psaux.h", - "external/freetype2/include/mac/freetype/internal/pshints.h", - "external/freetype2/include/mac/freetype/internal/services/svbdf.h", - "external/freetype2/include/mac/freetype/internal/services/svcid.h", - "external/freetype2/include/mac/freetype/internal/services/svgldict.h", - "external/freetype2/include/mac/freetype/internal/services/svgxval.h", - "external/freetype2/include/mac/freetype/internal/services/svkern.h", - "external/freetype2/include/mac/freetype/internal/services/svmm.h", - "external/freetype2/include/mac/freetype/internal/services/svotval.h", - "external/freetype2/include/mac/freetype/internal/services/svpfr.h", - "external/freetype2/include/mac/freetype/internal/services/svpostnm.h", - "external/freetype2/include/mac/freetype/internal/services/svprop.h", - "external/freetype2/include/mac/freetype/internal/services/svpscmap.h", - "external/freetype2/include/mac/freetype/internal/services/svpsinfo.h", - "external/freetype2/include/mac/freetype/internal/services/svsfnt.h", - "external/freetype2/include/mac/freetype/internal/services/svttcmap.h", - "external/freetype2/include/mac/freetype/internal/services/svtteng.h", - "external/freetype2/include/mac/freetype/internal/services/svttglyf.h", - "external/freetype2/include/mac/freetype/internal/services/svwinfnt.h", - "external/freetype2/include/mac/freetype/internal/services/svxf86nm.h", - "external/freetype2/include/mac/freetype/internal/sfnt.h", - "external/freetype2/include/mac/freetype/internal/t1types.h", - "external/freetype2/include/mac/freetype/internal/tttypes.h", - "external/freetype2/include/mac/freetype/t1tables.h", - "external/freetype2/include/mac/freetype/ttnameid.h", - "external/freetype2/include/mac/freetype/tttables.h", - "external/freetype2/include/mac/freetype/tttags.h", - "external/freetype2/include/mac/freetype/ttunpat.h", - "external/freetype2/include/mac/ft2build.h", - "external/freetype2/include/win32/freetype/config/ftconfig.h", - "external/freetype2/include/win32/freetype/config/ftheader.h", - "external/freetype2/include/win32/freetype/config/ftmodule.h", - "external/freetype2/include/win32/freetype/config/ftoption.h", - "external/freetype2/include/win32/freetype/config/ftstdlib.h", - "external/freetype2/include/win32/freetype/freetype.h", - "external/freetype2/include/win32/freetype/ftadvanc.h", - "external/freetype2/include/win32/freetype/ftautoh.h", - "external/freetype2/include/win32/freetype/ftbbox.h", - "external/freetype2/include/win32/freetype/ftbdf.h", - "external/freetype2/include/win32/freetype/ftbitmap.h", - "external/freetype2/include/win32/freetype/ftbzip2.h", - "external/freetype2/include/win32/freetype/ftcache.h", - "external/freetype2/include/win32/freetype/ftcffdrv.h", - "external/freetype2/include/win32/freetype/ftchapters.h", - "external/freetype2/include/win32/freetype/ftcid.h", - "external/freetype2/include/win32/freetype/fterrdef.h", - "external/freetype2/include/win32/freetype/fterrors.h", - "external/freetype2/include/win32/freetype/ftgasp.h", - "external/freetype2/include/win32/freetype/ftglyph.h", - "external/freetype2/include/win32/freetype/ftgxval.h", - "external/freetype2/include/win32/freetype/ftgzip.h", - "external/freetype2/include/win32/freetype/ftimage.h", - "external/freetype2/include/win32/freetype/ftincrem.h", - "external/freetype2/include/win32/freetype/ftlcdfil.h", - "external/freetype2/include/win32/freetype/ftlist.h", - "external/freetype2/include/win32/freetype/ftlzw.h", - "external/freetype2/include/win32/freetype/ftmac.h", - "external/freetype2/include/win32/freetype/ftmm.h", - "external/freetype2/include/win32/freetype/ftmodapi.h", - "external/freetype2/include/win32/freetype/ftmoderr.h", - "external/freetype2/include/win32/freetype/ftotval.h", - "external/freetype2/include/win32/freetype/ftoutln.h", - "external/freetype2/include/win32/freetype/ftpfr.h", - "external/freetype2/include/win32/freetype/ftrender.h", - "external/freetype2/include/win32/freetype/ftsizes.h", - "external/freetype2/include/win32/freetype/ftsnames.h", - "external/freetype2/include/win32/freetype/ftstroke.h", - "external/freetype2/include/win32/freetype/ftsynth.h", - "external/freetype2/include/win32/freetype/ftsystem.h", - "external/freetype2/include/win32/freetype/fttrigon.h", - "external/freetype2/include/win32/freetype/ftttdrv.h", - "external/freetype2/include/win32/freetype/fttypes.h", - "external/freetype2/include/win32/freetype/ftwinfnt.h", - "external/freetype2/include/win32/freetype/ftxf86.h", - "external/freetype2/include/win32/freetype/internal/autohint.h", - "external/freetype2/include/win32/freetype/internal/ftcalc.h", - "external/freetype2/include/win32/freetype/internal/ftdebug.h", - "external/freetype2/include/win32/freetype/internal/ftdriver.h", - "external/freetype2/include/win32/freetype/internal/ftgloadr.h", - "external/freetype2/include/win32/freetype/internal/ftmemory.h", - "external/freetype2/include/win32/freetype/internal/ftobjs.h", - "external/freetype2/include/win32/freetype/internal/ftpic.h", - "external/freetype2/include/win32/freetype/internal/ftrfork.h", - "external/freetype2/include/win32/freetype/internal/ftserv.h", - "external/freetype2/include/win32/freetype/internal/ftstream.h", - "external/freetype2/include/win32/freetype/internal/fttrace.h", - "external/freetype2/include/win32/freetype/internal/ftvalid.h", - "external/freetype2/include/win32/freetype/internal/internal.h", - "external/freetype2/include/win32/freetype/internal/psaux.h", - "external/freetype2/include/win32/freetype/internal/pshints.h", - "external/freetype2/include/win32/freetype/internal/services/svbdf.h", - "external/freetype2/include/win32/freetype/internal/services/svcid.h", - "external/freetype2/include/win32/freetype/internal/services/svgldict.h", - "external/freetype2/include/win32/freetype/internal/services/svgxval.h", - "external/freetype2/include/win32/freetype/internal/services/svkern.h", - "external/freetype2/include/win32/freetype/internal/services/svmm.h", - "external/freetype2/include/win32/freetype/internal/services/svotval.h", - "external/freetype2/include/win32/freetype/internal/services/svpfr.h", - "external/freetype2/include/win32/freetype/internal/services/svpostnm.h", - "external/freetype2/include/win32/freetype/internal/services/svprop.h", - "external/freetype2/include/win32/freetype/internal/services/svpscmap.h", - "external/freetype2/include/win32/freetype/internal/services/svpsinfo.h", - "external/freetype2/include/win32/freetype/internal/services/svsfnt.h", - "external/freetype2/include/win32/freetype/internal/services/svttcmap.h", - "external/freetype2/include/win32/freetype/internal/services/svtteng.h", - "external/freetype2/include/win32/freetype/internal/services/svttglyf.h", - "external/freetype2/include/win32/freetype/internal/services/svwinfnt.h", - "external/freetype2/include/win32/freetype/internal/services/svxf86nm.h", - "external/freetype2/include/win32/freetype/internal/sfnt.h", - "external/freetype2/include/win32/freetype/internal/t1types.h", - "external/freetype2/include/win32/freetype/internal/tttypes.h", - "external/freetype2/include/win32/freetype/t1tables.h", - "external/freetype2/include/win32/freetype/ttnameid.h", - "external/freetype2/include/win32/freetype/tttables.h", - "external/freetype2/include/win32/freetype/tttags.h", - "external/freetype2/include/win32/freetype/ttunpat.h", - "external/freetype2/include/win32/ft2build.h", + "external/freetype2/include/mac/freetype2/config/ftconfig.h", + "external/freetype2/include/mac/freetype2/config/ftheader.h", + "external/freetype2/include/mac/freetype2/config/ftmodule.h", + "external/freetype2/include/mac/freetype2/config/ftoption.h", + "external/freetype2/include/mac/freetype2/config/ftstdlib.h", + "external/freetype2/include/mac/freetype2/freetype.h", + "external/freetype2/include/mac/freetype2/ft2build.h", + "external/freetype2/include/mac/freetype2/ftadvanc.h", + "external/freetype2/include/mac/freetype2/ftautoh.h", + "external/freetype2/include/mac/freetype2/ftbbox.h", + "external/freetype2/include/mac/freetype2/ftbdf.h", + "external/freetype2/include/mac/freetype2/ftbitmap.h", + "external/freetype2/include/mac/freetype2/ftbzip2.h", + "external/freetype2/include/mac/freetype2/ftcache.h", + "external/freetype2/include/mac/freetype2/ftcffdrv.h", + "external/freetype2/include/mac/freetype2/ftchapters.h", + "external/freetype2/include/mac/freetype2/ftcid.h", + "external/freetype2/include/mac/freetype2/fterrdef.h", + "external/freetype2/include/mac/freetype2/fterrors.h", + "external/freetype2/include/mac/freetype2/ftgasp.h", + "external/freetype2/include/mac/freetype2/ftglyph.h", + "external/freetype2/include/mac/freetype2/ftgxval.h", + "external/freetype2/include/mac/freetype2/ftgzip.h", + "external/freetype2/include/mac/freetype2/ftimage.h", + "external/freetype2/include/mac/freetype2/ftincrem.h", + "external/freetype2/include/mac/freetype2/ftlcdfil.h", + "external/freetype2/include/mac/freetype2/ftlist.h", + "external/freetype2/include/mac/freetype2/ftlzw.h", + "external/freetype2/include/mac/freetype2/ftmac.h", + "external/freetype2/include/mac/freetype2/ftmm.h", + "external/freetype2/include/mac/freetype2/ftmodapi.h", + "external/freetype2/include/mac/freetype2/ftmoderr.h", + "external/freetype2/include/mac/freetype2/ftotval.h", + "external/freetype2/include/mac/freetype2/ftoutln.h", + "external/freetype2/include/mac/freetype2/ftpfr.h", + "external/freetype2/include/mac/freetype2/ftrender.h", + "external/freetype2/include/mac/freetype2/ftsizes.h", + "external/freetype2/include/mac/freetype2/ftsnames.h", + "external/freetype2/include/mac/freetype2/ftstroke.h", + "external/freetype2/include/mac/freetype2/ftsynth.h", + "external/freetype2/include/mac/freetype2/ftsystem.h", + "external/freetype2/include/mac/freetype2/fttrigon.h", + "external/freetype2/include/mac/freetype2/ftttdrv.h", + "external/freetype2/include/mac/freetype2/fttypes.h", + "external/freetype2/include/mac/freetype2/ftwinfnt.h", + "external/freetype2/include/mac/freetype2/ftxf86.h", + "external/freetype2/include/mac/freetype2/t1tables.h", + "external/freetype2/include/mac/freetype2/ttnameid.h", + "external/freetype2/include/mac/freetype2/tttables.h", + "external/freetype2/include/mac/freetype2/tttags.h", + "external/freetype2/include/mac/freetype2/ttunpat.h", + "external/freetype2/include/win32/freetype2/config/ftconfig.h", + "external/freetype2/include/win32/freetype2/config/ftheader.h", + "external/freetype2/include/win32/freetype2/config/ftmodule.h", + "external/freetype2/include/win32/freetype2/config/ftoption.h", + "external/freetype2/include/win32/freetype2/config/ftstdlib.h", + "external/freetype2/include/win32/freetype2/freetype.h", + "external/freetype2/include/win32/freetype2/ft2build.h", + "external/freetype2/include/win32/freetype2/ftadvanc.h", + "external/freetype2/include/win32/freetype2/ftautoh.h", + "external/freetype2/include/win32/freetype2/ftbbox.h", + "external/freetype2/include/win32/freetype2/ftbdf.h", + "external/freetype2/include/win32/freetype2/ftbitmap.h", + "external/freetype2/include/win32/freetype2/ftbzip2.h", + "external/freetype2/include/win32/freetype2/ftcache.h", + "external/freetype2/include/win32/freetype2/ftcffdrv.h", + "external/freetype2/include/win32/freetype2/ftchapters.h", + "external/freetype2/include/win32/freetype2/ftcid.h", + "external/freetype2/include/win32/freetype2/fterrdef.h", + "external/freetype2/include/win32/freetype2/fterrors.h", + "external/freetype2/include/win32/freetype2/ftgasp.h", + "external/freetype2/include/win32/freetype2/ftglyph.h", + "external/freetype2/include/win32/freetype2/ftgxval.h", + "external/freetype2/include/win32/freetype2/ftgzip.h", + "external/freetype2/include/win32/freetype2/ftimage.h", + "external/freetype2/include/win32/freetype2/ftincrem.h", + "external/freetype2/include/win32/freetype2/ftlcdfil.h", + "external/freetype2/include/win32/freetype2/ftlist.h", + "external/freetype2/include/win32/freetype2/ftlzw.h", + "external/freetype2/include/win32/freetype2/ftmac.h", + "external/freetype2/include/win32/freetype2/ftmm.h", + "external/freetype2/include/win32/freetype2/ftmodapi.h", + "external/freetype2/include/win32/freetype2/ftmoderr.h", + "external/freetype2/include/win32/freetype2/ftotval.h", + "external/freetype2/include/win32/freetype2/ftoutln.h", + "external/freetype2/include/win32/freetype2/ftpfr.h", + "external/freetype2/include/win32/freetype2/ftrender.h", + "external/freetype2/include/win32/freetype2/ftsizes.h", + "external/freetype2/include/win32/freetype2/ftsnames.h", + "external/freetype2/include/win32/freetype2/ftstroke.h", + "external/freetype2/include/win32/freetype2/ftsynth.h", + "external/freetype2/include/win32/freetype2/ftsystem.h", + "external/freetype2/include/win32/freetype2/fttrigon.h", + "external/freetype2/include/win32/freetype2/ftttdrv.h", + "external/freetype2/include/win32/freetype2/fttypes.h", + "external/freetype2/include/win32/freetype2/ftwinfnt.h", + "external/freetype2/include/win32/freetype2/ftxf86.h", + "external/freetype2/include/win32/freetype2/internal/autohint.h", + "external/freetype2/include/win32/freetype2/internal/ftcalc.h", + "external/freetype2/include/win32/freetype2/internal/ftdebug.h", + "external/freetype2/include/win32/freetype2/internal/ftdriver.h", + "external/freetype2/include/win32/freetype2/internal/ftgloadr.h", + "external/freetype2/include/win32/freetype2/internal/ftmemory.h", + "external/freetype2/include/win32/freetype2/internal/ftobjs.h", + "external/freetype2/include/win32/freetype2/internal/ftpic.h", + "external/freetype2/include/win32/freetype2/internal/ftrfork.h", + "external/freetype2/include/win32/freetype2/internal/ftserv.h", + "external/freetype2/include/win32/freetype2/internal/ftstream.h", + "external/freetype2/include/win32/freetype2/internal/fttrace.h", + "external/freetype2/include/win32/freetype2/internal/ftvalid.h", + "external/freetype2/include/win32/freetype2/internal/internal.h", + "external/freetype2/include/win32/freetype2/internal/psaux.h", + "external/freetype2/include/win32/freetype2/internal/pshints.h", + "external/freetype2/include/win32/freetype2/internal/services/svbdf.h", + "external/freetype2/include/win32/freetype2/internal/services/svcid.h", + "external/freetype2/include/win32/freetype2/internal/services/svgldict.h", + "external/freetype2/include/win32/freetype2/internal/services/svgxval.h", + "external/freetype2/include/win32/freetype2/internal/services/svkern.h", + "external/freetype2/include/win32/freetype2/internal/services/svmm.h", + "external/freetype2/include/win32/freetype2/internal/services/svotval.h", + "external/freetype2/include/win32/freetype2/internal/services/svpfr.h", + "external/freetype2/include/win32/freetype2/internal/services/svpostnm.h", + "external/freetype2/include/win32/freetype2/internal/services/svprop.h", + "external/freetype2/include/win32/freetype2/internal/services/svpscmap.h", + "external/freetype2/include/win32/freetype2/internal/services/svpsinfo.h", + "external/freetype2/include/win32/freetype2/internal/services/svsfnt.h", + "external/freetype2/include/win32/freetype2/internal/services/svttcmap.h", + "external/freetype2/include/win32/freetype2/internal/services/svtteng.h", + "external/freetype2/include/win32/freetype2/internal/services/svttglyf.h", + "external/freetype2/include/win32/freetype2/internal/services/svwinfnt.h", + "external/freetype2/include/win32/freetype2/internal/services/svxf86nm.h", + "external/freetype2/include/win32/freetype2/internal/sfnt.h", + "external/freetype2/include/win32/freetype2/internal/t1types.h", + "external/freetype2/include/win32/freetype2/internal/tttypes.h", + "external/freetype2/include/win32/freetype2/t1tables.h", + "external/freetype2/include/win32/freetype2/ttnameid.h", + "external/freetype2/include/win32/freetype2/tttables.h", + "external/freetype2/include/win32/freetype2/tttags.h", + "external/freetype2/include/win32/freetype2/ttunpat.h", "external/freetype2/include/winrt/README.txt", "external/freetype2/include/winrt/freetype/config/ftconfig.h", "external/freetype2/include/winrt/freetype/config/ftheader.h", @@ -3115,6 +3007,13 @@ "external/xxhash/xxhash.h", "external/xxtea/xxtea.cpp", "external/xxtea/xxtea.h", + "external/zlib/include/zconf.h", + "external/zlib/include/zlib.h", + "external/zlib/prebuilt/android/Android.mk", + "external/zlib/prebuilt/android/armeabi-v7a/libz.a", + "external/zlib/prebuilt/android/armeabi/libz.a", + "external/zlib/prebuilt/android/x86/libz.a", + "external/zlib/prebuilt/mac/libz.a", "licenses/LICENSE_AA-EDT.txt", "licenses/LICENSE_CCBReader.txt", "licenses/LICENSE_CCControlExtension.txt", @@ -5376,6 +5275,7 @@ "cocos/scripting/lua-bindings/auto/api/TableView.lua", "cocos/scripting/lua-bindings/auto/api/TableViewCell.lua", "cocos/scripting/lua-bindings/auto/api/TargetedAction.lua", + "cocos/scripting/lua-bindings/auto/api/Terrain.lua", "cocos/scripting/lua-bindings/auto/api/Text.lua", "cocos/scripting/lua-bindings/auto/api/TextAtlas.lua", "cocos/scripting/lua-bindings/auto/api/TextBMFont.lua", @@ -5561,6 +5461,7 @@ "cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj", "cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj", "cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters", + "cocos/scripting/lua-bindings/script/3d/3dConstants.lua", "cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua", "cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua", "cocos/scripting/lua-bindings/script/cocos2d/DeprecatedCocos2dClass.lua", diff --git a/templates/cpp-template-default/proj.android/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder.launch b/templates/cpp-template-default/proj.android/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder.launch new file mode 100644 index 0000000000..e82f6ae046 --- /dev/null +++ b/templates/cpp-template-default/proj.android/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder.launch @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/cpp-template-default/proj.android/.project b/templates/cpp-template-default/proj.android/.project index d2f0733b87..409ec287cf 100644 --- a/templates/cpp-template-default/proj.android/.project +++ b/templates/cpp-template-default/proj.android/.project @@ -22,68 +22,12 @@ - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, - ?children? - ?children?=?name?=entry\\\\\\\|\\\|\|?name?=outputEntries\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - ${ProjDirPath}/build_native.py -b release - - - org.eclipse.cdt.make.core.buildCommand - python - - - org.eclipse.cdt.make.core.buildLocation - ${ProjDirPath} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder.launch diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj b/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj index 054ed3ee3b..318dcdeb93 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj +++ b/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj @@ -871,6 +871,14 @@ "$(_COCOS_LIB_IOS_BEGIN)", "$(_COCOS_LIB_IOS_END)", ); + "OTHER_LDFLAGS[sdk=iphonesimulator*][arch=x86_64]" = ( + "$(_COCOS_LIB_IOS_BEGIN)", + "$(_COCOS_LIB_IOS_END)", + "-pagezero_size", + 10000, + "-image_base", + 100000000, + ); SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../cocos2d-x/cocos/platform/ios $(_COCOS_HEADER_IOS_BEGIN) $(_COCOS_HEADER_IOS_END)"; @@ -902,6 +910,14 @@ "$(_COCOS_LIB_IOS_BEGIN)", "$(_COCOS_LIB_IOS_END)", ); + "OTHER_LDFLAGS[sdk=iphonesimulator*][arch=x86_64]" = ( + "$(_COCOS_LIB_IOS_BEGIN)", + "$(_COCOS_LIB_IOS_END)", + "-pagezero_size", + 10000, + "-image_base", + 100000000, + ); SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../cocos2d-x/cocos/platform/ios $(_COCOS_HEADER_IOS_BEGIN) $(_COCOS_HEADER_IOS_END)"; diff --git a/tests/cpp-tests/Classes/AppDelegate.cpp b/tests/cpp-tests/Classes/AppDelegate.cpp index c88d8bf264..8d59326042 100644 --- a/tests/cpp-tests/Classes/AppDelegate.cpp +++ b/tests/cpp-tests/Classes/AppDelegate.cpp @@ -33,6 +33,7 @@ USING_NS_CC; AppDelegate::AppDelegate() +: _testController(nullptr) { } @@ -179,13 +180,21 @@ bool AppDelegate::applicationDidFinishLaunching() // This function will be called when the app is inactive. When comes a phone call,it's be invoked too void AppDelegate::applicationDidEnterBackground() { - _testController->onEnterBackground(); + if (_testController) + { + _testController->onEnterBackground(); + } + Director::getInstance()->stopAnimation(); } // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { - _testController->onEnterForeground(); + if (_testController) + { + _testController->onEnterForeground(); + } + Director::getInstance()->startAnimation(); } diff --git a/tests/cpp-tests/Classes/BaseTest.cpp b/tests/cpp-tests/Classes/BaseTest.cpp index 4f6a812c59..50463a7499 100644 --- a/tests/cpp-tests/Classes/BaseTest.cpp +++ b/tests/cpp-tests/Classes/BaseTest.cpp @@ -163,7 +163,7 @@ TableViewCell* TestList::tableCellAtIndex(TableView *table, ssize_t idx) cell = TableViewCell::create(); auto label = Label::createWithTTF(_childTestNames[idx], "fonts/arial.ttf", 20.0f); label->setTag(1024); - label->setPosition(200, 25); + label->setPosition(200, 15); cell->addChild(label); } else @@ -177,7 +177,7 @@ TableViewCell* TestList::tableCellAtIndex(TableView *table, ssize_t idx) Size TestList::tableCellSizeForIndex(TableView *table, ssize_t idx) { - return Size(400, 50); + return Size(400, 30); } ssize_t TestList::numberOfCellsInTableView(TableView *table) diff --git a/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.cpp b/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.cpp index 42c21cb2f4..09efbb27fb 100644 --- a/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.cpp +++ b/tests/cpp-tests/Classes/ChipmunkTest/ChipmunkTest.cpp @@ -4,6 +4,8 @@ // http://www.cocos2d-x.org // +#include "chipmunk.h" + #include "ChipmunkTest.h" diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp index 63a0d43254..fb906490d4 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp @@ -233,7 +233,7 @@ bool NodeInRect::init() bool NodeInRect::detect() { Node *pNode = SceneReader::getInstance()->getNodeByTag(_tag); - if (pNode != nullptr && abs(pNode->getPositionX() - _origin.x) <= _size.width && abs(pNode->getPositionY() - _origin.y) <= _size.height) + if (pNode != nullptr && std::abs(pNode->getPositionX() - _origin.x) <= _size.width && std::abs(pNode->getPositionY() - _origin.y) <= _size.height) { return true; } diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp index 931d016ff0..e764d5c903 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp @@ -1191,7 +1191,7 @@ LabelShadowTest::LabelShadowTest() shadowLabelOutline->setPosition( Vec2(size.width/2, size.height*0.5f) ); shadowLabelOutline->setTextColor( Color4B::RED ); shadowLabelOutline->enableOutline(Color4B::YELLOW,1); - shadowLabelOutline->enableShadow(Color4B::BLACK); + shadowLabelOutline->enableShadow(Color4B::GREEN); addChild(shadowLabelOutline); shadowLabelBMFont = Label::createWithBMFont("fonts/bitmapFontTest.fnt", "BMFont:Shadow"); @@ -1234,7 +1234,7 @@ void LabelShadowTest::sliderEvent(Ref *pSender, ui::Slider::EventType type) auto offset = Size(slider->getPercent()-50,50 - slider2->getPercent()); shadowLabelTTF->enableShadow(Color4B::BLACK,offset); shadowLabelBMFont->enableShadow(Color4B::GREEN,offset); - shadowLabelOutline->enableShadow(Color4B::BLACK,offset); + shadowLabelOutline->enableShadow(Color4B::GREEN,offset); } } diff --git a/tests/cpp-tests/Classes/TextInputTest/TextInputTest.cpp b/tests/cpp-tests/Classes/TextInputTest/TextInputTest.cpp index 7704d17070..b00eac5ae7 100644 --- a/tests/cpp-tests/Classes/TextInputTest/TextInputTest.cpp +++ b/tests/cpp-tests/Classes/TextInputTest/TextInputTest.cpp @@ -95,8 +95,8 @@ void KeyboardNotificationLayer::onTouchEnded(Touch *touch, Event *event) auto endPos = touch->getLocation(); float delta = 5.0f; - if (::abs(endPos.x - _beginPos.x) > delta - || ::abs(endPos.y - _beginPos.y) > delta) + if (std::abs(endPos.x - _beginPos.x) > delta + || std::abs(endPos.y - _beginPos.y) > delta) { // not click _beginPos.x = _beginPos.y = -1; diff --git a/tests/cpp-tests/Classes/controller.cpp b/tests/cpp-tests/Classes/controller.cpp index 3891629770..4bfb59e0d0 100644 --- a/tests/cpp-tests/Classes/controller.cpp +++ b/tests/cpp-tests/Classes/controller.cpp @@ -36,6 +36,7 @@ public: addTest("Console", []() { return new ConsoleTests(); }); addTest("Curl", []() { return new CurlTests(); }); addTest("Current Language", []() { return new CurrentLanguageTests(); }); + addTest("CocosStudio3D Test", []() { return new CocosStudio3DTests(); }); addTest("EventDispatcher", []() { return new EventDispatcherTests(); }); addTest("Effects - Advanced", []() { return new EffectAdvanceTests(); }); addTest("Effects - Basic", [](){return new EffectTests(); }); @@ -56,9 +57,11 @@ public: addTest("Node: Node", [](){return new CocosNodeTests(); }); addTest("Node: Parallax", [](){return new ParallaxTests(); }); addTest("Node: Particles", [](){return new ParticleTests(); }); + addTest("Node: Particle3D (PU)", [](){return new Particle3DTests(); }); addTest("Node: Physics", []() { return new PhysicsTests(); }); addTest("Node: RenderTexture", [](){return new RenderTextureTests(); }); addTest("Node: Scene", [](){return new SceneTests(); }); + addTest("Node: Spine", [](){return new SpineTests(); }); addTest("Node: Sprite", [](){return new SpriteTests(); }); addTest("Node: Sprite3D", [](){ return new Sprite3DTests(); }); addTest("Node: Terrain", [](){ return new TerrainTests(); }); @@ -136,7 +139,7 @@ void TestController::traverseTestList(TestList* testList) if (testList == _rootTestList) { _sleepUniqueLock = std::unique_lock(_sleepMutex); - _sleepCondition.wait_for(_sleepUniqueLock, std::chrono::milliseconds(2500)); + _sleepCondition.wait_for(_sleepUniqueLock, std::chrono::milliseconds(500)); //disable touch } else @@ -355,8 +358,16 @@ bool TestController::checkTest(TestCase* testCase) void TestController::handleCrash() { - logEx("TestController::handleCrash"); - stopAutoTest(); + logEx("%sCatch an crash event", LOG_TAG); + + if (!_stopAutoTest) + { + stopAutoTest(); + } + +#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX + exit(1); +#endif } void TestController::onEnterBackground() @@ -396,11 +407,15 @@ void TestController::logEx(const char * format, ...) static TestController* s_testController = nullptr; +static void initCrashCatch(); + TestController* TestController::getInstance() { if (s_testController == nullptr) { s_testController = new (std::nothrow) TestController; + + initCrashCatch(); } return s_testController; @@ -420,3 +435,71 @@ bool TestController::blockTouchBegan(Touch* touch, Event* event) { return !_stopAutoTest; } + +//================================================================================================== +#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 +#include + +static long __stdcall windowExceptionFilter(_EXCEPTION_POINTERS* excp) +{ + if (s_testController) + { + s_testController->handleCrash(); + } + + return EXCEPTION_EXECUTE_HANDLER; +} + +static void initCrashCatch() +{ + SetUnhandledExceptionFilter(windowExceptionFilter); +} + +#elif CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID + +#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID +static int s_fatal_signals[] = { + SIGILL, + SIGABRT, + SIGBUS, + SIGFPE, + SIGSEGV, + SIGSTKFLT, + SIGPIPE, +}; +#else +static int s_fatal_signals[] = { + SIGABRT, + SIGBUS, + SIGFPE, + SIGILL, + SIGSEGV, + SIGTRAP, + SIGTERM, + SIGKILL, +}; +#endif + +static void signalHandler(int sig) +{ + if (s_testController) + { + s_testController->handleCrash(); + } +} + +static void initCrashCatch() +{ + for (auto sig : s_fatal_signals) { + signal(sig, signalHandler); + } +} + +#else + +static void initCrashCatch() +{ + +} + +#endif diff --git a/tests/cpp-tests/Classes/controller.h b/tests/cpp-tests/Classes/controller.h index eb6f57275e..16c09bd03d 100644 --- a/tests/cpp-tests/Classes/controller.h +++ b/tests/cpp-tests/Classes/controller.h @@ -47,7 +47,6 @@ public: static TestController* getInstance(); static void destroyInstance(); - TestController(); ~TestController(); void startAutoTest(); @@ -59,10 +58,18 @@ public: void onEnterForeground(); bool blockTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event); + private: - static void logEx(const char * format, ...); + TestController(); + + void traverseTestList(TestList* testList); + void traverseTestSuite(TestSuite* testSuite); + bool checkTest(TestCase* testCase); + + void logEx(const char * format, ...); bool _stopAutoTest; + bool _isRunInBackground; TestList* _rootTestList; @@ -76,13 +83,6 @@ private: cocos2d::EventListenerTouchOneByOne* _touchListener; std::string _logIndentation; - - bool _isRunInBackground; - - void traverseTestList(TestList* testList); - void traverseTestSuite(TestSuite* testSuite); - - bool checkTest(TestCase* testCase); }; #endif diff --git a/tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeAndEncryptTest-arm64.luac b/tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeAndEncryptTest-arm64.luac new file mode 100644 index 0000000000..c3acf48a20 Binary files /dev/null and b/tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeAndEncryptTest-arm64.luac differ diff --git a/tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeEncryptTest.lua b/tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeEncryptTest.lua index db3c1f1ecb..11ef1db1a7 100644 --- a/tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeEncryptTest.lua +++ b/tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeEncryptTest.lua @@ -1,10 +1,16 @@ local targetPlatform = cc.Application:getInstance():getTargetPlatform() -local isIOS64bit = cc.Application:getInstance():isIOS64bit() -if cc.PLATFORM_OS_LINUX ~= targetPlatform and isIOS64bit ~= true then +local is64BitIOSDevice = cc.Application:getInstance():is64BitIOSDevice() + +if cc.PLATFORM_OS_LINUX ~= targetPlatform and is64BitIOSDevice ~= true then require("ByteCodeEncryptTest/ByteCodeTest") require("ByteCodeEncryptTest/ByteCodeAndEncryptTest") end +if (cc.PLATFORM_OS_IPHONE == targetPlatform or cc.PLATFORM_OS_IPAD == targetPlatform) and is64BitIOSDevice == true then +require("ByteCodeEncryptTest/ByteCodeAndEncryptTest-arm64") +require("ByteCodeEncryptTest/ByteCodeTest-arm64") +end + local LINE_SPACE = 40 local ItemTagBasic = 1000 @@ -55,9 +61,13 @@ local function byteCodeEncryptMainLayer() item:registerScriptTapHandler(menuCallback) item:setPosition(size.width / 2, size.height - i * LINE_SPACE) menu:addChild(item, ItemTagBasic + i) - if cc.PLATFORM_OS_LINUX == targetPlatform or isIOS64bit == true then + if cc.PLATFORM_OS_LINUX == targetPlatform or is64BitIOSDevice == true then -- isIOS64bit item:setEnabled(false) end + + if (cc.PLATFORM_OS_IPHONE == targetPlatform or cc.PLATFORM_OS_IPAD == targetPlatform) and is64BitIOSDevice == true then + item:setEnabled(true) + end end layer:addChild(menu) diff --git a/tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeTest-arm64.luac b/tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeTest-arm64.luac new file mode 100644 index 0000000000..28674b2d02 Binary files /dev/null and b/tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeTest-arm64.luac differ diff --git a/tests/lua-tests/src/TerrainTest/TerrainTest.lua b/tests/lua-tests/src/TerrainTest/TerrainTest.lua new file mode 100644 index 0000000000..2b9ffd97c1 --- /dev/null +++ b/tests/lua-tests/src/TerrainTest/TerrainTest.lua @@ -0,0 +1,342 @@ +require "cocos.3d.3dConstants" + +---------------------------------------- +----TerrainSimple +---------------------------------------- +local TerrainSimple = class("TerrainSimple", function () + local layer = cc.Layer:create() + Helper.initWithLayer(layer) + return layer +end) + +function TerrainSimple:ctor() + -- body + self:init() +end + +function TerrainSimple:init() + Helper.titleLabel:setString(self:title()) + Helper.subtitleLabel:setString(self:subtitle()) + + local visibleSize = cc.Director:getInstance():getVisibleSize() + + --use custom camera + self._camera = cc.Camera:createPerspective(60, visibleSize.width/visibleSize.height, 0.1, 800) + self._camera:setCameraFlag(cc.CameraFlag.USER1) + self:addChild(self._camera) + + local detailMapR = { detailMapSrc = "TerrainTest/dirt.dds", detailMapSize = 35} + local detailMapG = { detailMapSrc = "TerrainTest/Grass2.dds", detailMapSize = 35} + local detailMapB = { detailMapSrc = "TerrainTest/road.dds", detailMapSize = 35} + local detailMapA = { detailMapSrc = "TerrainTest/GreenSkin.jpg", detailMapSize = 35} + local terrainData = { heightMapSrc = "TerrainTest/heightmap16.jpg", alphaMapSrc = "TerrainTest/alphamap.png" , detailMaps = {detailMapR, detailMapG, detailMapB, detailMapA}, _detailMapAmount = 4 } + + self._terrain = cc.Terrain:create(terrainData,cc.Terrain.CrackFixedType.SKIRT) + self._terrain:setLODDistance(1000.2, 6.4, 9.6) + self._terrain:setMaxDetailMapAmount(4) + self:addChild(self._terrain) + self._terrain:setCameraMask(2) + self._terrain:setDrawWire(false) + + local listener = cc.EventListenerTouchAllAtOnce:create() + listener:registerScriptHandler(function (touches, event) + local delta = cc.Director:getInstance():getDeltaTime() + local touch = touches[1] + local location = touch:getLocation() + local previousLocation = touch:getPreviousLocation() + local newPos = {x=previousLocation.x - location.x, y=previousLocation.y - location.y} + + local matTransform = self:getNodeToWorldTransform() + + local cameraDir = {x = -matTransform[9], y = -matTransform[10], z = -matTransform[11]} + cameraDir = cc.vec3normalize(cameraDir) + cameraDir.y = 0 + + local cameraRightDir = {x = matTransform[1], y = matTransform[2], z = matTransform[3]} + cameraRightDir = cc.vec3normalize(cameraRightDir) + cameraRightDir.y = 0 + + local cameraPos = self._camera:getPosition3D() + cameraPos = { x = cameraPos.x + cameraDir.x * newPos.y * 0.5 * delta, y = cameraPos.y + cameraDir.y * newPos.y * 0.5 * delta, z = cameraPos.z + cameraDir.z * newPos.y * 0.5 * delta } + cameraPos = { x = cameraPos.x + cameraRightDir.x * newPos.x * 0.5 * delta, y = cameraPos.y + cameraRightDir.y * newPos.x * 0.5 * delta, z = cameraPos.z + cameraRightDir.z * newPos.x * 0.5 * delta } + self._camera:setPosition3D(cameraPos) + + end,cc.Handler.EVENT_TOUCHES_MOVED) + + local eventDispatcher = self:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) +end + +function TerrainSimple:title() + return "Terrain with skirt" +end + +function TerrainSimple:subtitle() + return "Drag to walkThru" +end + +---------------------------------------- +----TerrainWalkThru +---------------------------------------- + +local PLAER_STATE = +{ + LEFT = 0, + RIGHT = 1, + IDLE = 2, + FORWARD = 3, + BACKWARD = 4, +} + +local PLAYER_HEIGHT = 0 + +local camera_offset = cc.vec3(0, 45, 60) + +local Player = class("Player", function(file, cam, terrain) + local sprite = cc.Sprite3D:create(file) + if nil ~= sprite then + sprite._headingAngle = 0 + sprite._playerState = PLAER_STATE.IDLE + sprite._cam = cam + sprite._terrain = terrain + end + return sprite +end) + +function Player:ctor() + -- body + self:init() +end + +function Player:init() + self._headingAxis = cc.vec3(0.0, 0.0, 0.0) + self:scheduleUpdateWithPriorityLua(function(dt) + local curPos = self:getPosition3D() + if self._playerState == PLAER_STATE.IDLE then + + elseif self._playerState == PLAER_STATE.FORWARD then + local newFaceDir = cc.vec3( self._targetPos.x - curPos.x, self._targetPos.y - curPos.y, self._targetPos.z - curPos.z) + newFaceDir.y = 0.0 + newFaceDir = cc.vec3normalize(newFaceDir) + local offset = cc.vec3(newFaceDir.x * 25.0 * dt, newFaceDir.y * 25.0 * dt, newFaceDir.z * 25.0 * dt) + curPos = cc.vec3(curPos.x + offset.x, curPos.y + offset.y, curPos.z + offset.z) + self:setPosition3D(curPos) + elseif self._playerState == PLAER_STATE.BACKWARD then + + local transform = self:getNodeToWorldTransform() + local forward_vec = cc.vec3(-transform[9], -transform[10], -transform[11]) + forward_vec = cc.vec3normalize(forward_vec) + self:setPosition3D(cc.vec3(curPos.x - forward_vec.x * 15 * dt, curPos.y - forward_vec.y * 15 * dt, curPos.z - forward_vec.z * 15 *dt)) + elseif self._playerState == PLAER_STATE.LEFT then + player:setRotation3D(cc.vec3(curPos.x, curPos.y + 25 * dt, curPos.z)) + elseif self._playerState == PLAER_STATE.RIGHT then + player:setRotation3D(cc.vec3(curPos.x, curPos.y - 25 * dt, curPos.z)) + end + + local normal = cc.vec3(0.0, 0.0, 0.0) + local player_h, normal = self._terrain:getHeight(self:getPositionX(), self:getPositionZ(), normal) + self:setPositionY(player_h + PLAYER_HEIGHT) + + --need to scriptfile + local q2 = cc.quaternion_createFromAxisAngle(cc.vec3(0, 1, 0), -math.pi) + local headingQ = cc.quaternion_createFromAxisAngle(self._headingAxis, self._headingAngle) + local x = headingQ.w * q2.x + headingQ.x * q2.w + headingQ.y * q2.z - headingQ.z * q2.y + local y = headingQ.w * q2.y - headingQ.x * q2.z + headingQ.y * q2.w + headingQ.z * q2.x + local z = headingQ.w * q2.z + headingQ.x * q2.y - headingQ.y * q2.x + headingQ.z * q2.w + local w = headingQ.w * q2.w - headingQ.x * q2.x - headingQ.y * q2.y - headingQ.z * q2.z + headingQ = cc.quaternion(x, y, z, w) + self:setRotationQuat(headingQ) + + local vec_offset = cc.vec4(camera_offset.x, camera_offset.y, camera_offset.z, 1) + local transform = self:getNodeToWorldTransform() + local dst = cc.vec4(0.0, 0.0, 0.0, 0.0) + vec_offset = mat4_transformVector(transform, vec_offset, dst) + local playerPos = self:getPosition3D() + self._cam:setPosition3D(cc.vec3(playerPos.x + camera_offset.x, playerPos.y + camera_offset.y, playerPos.z + camera_offset.z)) + self:updateState() + end, 0) + + self:registerScriptHandler(function (event) + -- body + if "exit" == event then + self:unscheduleUpdate() + end + end) +end + +function Player:updateState() + if self._playerState == PLAER_STATE.FORWARD then + local player_pos = cc.p(self:getPositionX(),self:getPositionZ()) + local targetPos = cc.p(self._targetPos.x, self._targetPos.z) + local dist = cc.pGetDistance(player_pos, targetPos) + if dist < 1 then + self._playerState = PLAER_STATE.IDLE + end + end +end + +local TerrainWalkThru = class("TerrainWalkThru", function () + local layer = cc.Layer:create() + Helper.initWithLayer(layer) + return layer +end) + +function TerrainWalkThru:ctor() + -- body + self:init() +end + +function TerrainWalkThru:init() + Helper.titleLabel:setString(self:title()) + Helper.subtitleLabel:setString(self:subtitle()) + + local listener = cc.EventListenerTouchAllAtOnce:create() + + listener:registerScriptHandler(function (touches, event) + + end,cc.Handler.EVENT_TOUCHES_BEGAN) + + listener:registerScriptHandler(function (touches, event) + local delta = cc.Director:getInstance():getDeltaTime() + local touch = touches[1] + local location = touch:getLocation() + local previousLocation = touch:getPreviousLocation() + local newPos = cc.p(previousLocation.x - location.x, previousLocation.y - location.y) + + local matTransform = self._camera:getNodeToWorldTransform() + + local cameraDir = {x = -matTransform[9], y = -matTransform[10], z = -matTransform[11]} + cameraDir = cc.vec3normalize(cameraDir) + cameraDir.y = 0 + + local cameraRightDir = {x = matTransform[1], y = matTransform[2], z = matTransform[3]} + cameraRightDir = cc.vec3normalize(cameraRightDir) + cameraRightDir.y = 0 + + local cameraPos = self._camera:getPosition3D() + cameraPos = { x = cameraPos.x + cameraDir.x * newPos.y * 0.5 * delta, y = cameraPos.y + cameraDir.y * newPos.y * 0.5 * delta, z = cameraPos.z + cameraDir.z * newPos.y * 0.5 * delta } + cameraPos = { x = cameraPos.x + cameraRightDir.x * newPos.x * 0.5 * delta, y = cameraPos.y + cameraRightDir.y * newPos.x * 0.5 * delta, z = cameraPos.z + cameraRightDir.z * newPos.x * 0.5 * delta } + self._camera:setPosition3D(cameraPos) + end,cc.Handler.EVENT_TOUCHES_MOVED) + + listener:registerScriptHandler(function (touches, event) + + local touch = touches[1] + local location = touch:getLocationInView() + if self._camera ~= nil then + if self._player ~= nil then + local nearP = cc.vec3(location.x, location.y, 0.0) + local farP = cc.vec3(location.x, location.y, 1.0) + + local size = cc.Director:getInstance():getWinSize() + nearP = self._camera:unproject(size, nearP, nearP) + farP = self._camera:unproject(size, farP, farP) + local dir = cc.vec3(farP.x - nearP.x, farP.y - nearP.y, farP.z - nearP.z) + dir = cc.vec3normalize(dir) + + local rayStep = cc.vec3(15 * dir.x, 15 * dir.y, 15 * dir.z) + local rayPos = nearP + local rayStartPosition = nearP + local lastRayPosition = rayPos + rayPos = cc.vec3(rayPos.x + rayStep.x, rayPos.y + rayStep.y, rayPos.z + rayStep.z) + -- Linear search - Loop until find a point inside and outside the terrain Vector3 + local height = self._terrain:getHeight(rayPos.x, rayPos.z) + + while rayPos.y > height do + lastRayPosition = rayPos + rayPos = cc.vec3(rayPos.x + rayStep.x, rayPos.y + rayStep.y, rayPos.z + rayStep.z) + height = self._terrain:getHeight(rayPos.x,rayPos.z) + end + + local startPosition = lastRayPosition + local endPosition = rayPos + + for i = 1, 32 do + -- Binary search pass + local middlePoint = cc.vec3(0.5 * (startPosition.x + endPosition.x), 0.5 * (startPosition.y + endPosition.y), 0.5 * (startPosition.z + endPosition.z)) + if (middlePoint.y < height) then + endPosition = middlePoint + else + startPosition = middlePoint + end + end + + local collisionPoint = cc.vec3(0.5 * (startPosition.x + endPosition.x), 0.5 * (startPosition.y + endPosition.y), 0.5 * (startPosition.z + endPosition.z)) + local playerPos = self._player:getPosition3D() + dir = cc.vec3(collisionPoint.x - playerPos.x, collisionPoint.y - playerPos.y, collisionPoint.z - playerPos.z) + dir.y = 0 + dir = cc.vec3normalize(dir) + self._player._headingAngle = -1 * math.acos(-dir.z) + + self._player._headingAxis = vec3_cross(dir, cc.vec3(0, 0, -1), self._player._headingAxis) + self._player._targetPos = collisionPoint + -- self._player:forward() + self._player._playerState = PLAER_STATE.FORWARD + end + end + end,cc.Handler.EVENT_TOUCHES_ENDED) + + local eventDispatcher = self:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) + + local visibleSize = cc.Director:getInstance():getVisibleSize() + self._camera = cc.Camera:createPerspective(60, visibleSize.width/visibleSize.height, 0.1, 200) + self._camera:setCameraFlag(cc.CameraFlag.USER1) + self:addChild(self._camera) + + local detailMapR = { detailMapSrc = "TerrainTest/dirt.dds", detailMapSize = 35} + local detailMapG = { detailMapSrc = "TerrainTest/Grass2.dds", detailMapSize = 10} + local detailMapB = { detailMapSrc = "TerrainTest/road.dds", detailMapSize = 35} + local detailMapA = { detailMapSrc = "TerrainTest/GreenSkin.jpg", detailMapSize = 20} + local terrainData = { heightMapSrc = "TerrainTest/heightmap16.jpg", alphaMapSrc = "TerrainTest/alphamap.png" , detailMaps = {detailMapR, detailMapG, detailMapB, detailMapA}, _detailMapAmount = 4, mapHeight = 40.0, mapScale = 2.0 } + + self._terrain = cc.Terrain:create(terrainData,cc.Terrain.CrackFixedType.SKIRT) + self._terrain:setLODDistance(1000.2, 6.4, 9.6) + self._terrain:setMaxDetailMapAmount(4) + self._terrain:setCameraMask(2) + self._terrain:setDrawWire(false) + + self._terrain:setSkirtHeightRatio(3) + self._terrain:setLODDistance(64,128,192) + + self._player = Player:create("Sprite3DTest/girl.c3b", self._camera, self._terrain) + self._player:setCameraMask(2) + self._player:setScale(0.08) + self._player:setPositionY(self._terrain:getHeight(self._player:getPositionX(), self._player:getPositionZ()) + PLAYER_HEIGHT) + + local animation = cc.Animation3D:create("Sprite3DTest/girl.c3b","Take 001") + if nil ~= animation then + local animate = cc.Animate3D:create(animation) + self._player:runAction(cc.RepeatForever:create(animate)) + end + + local playerPos = self._player:getPosition3D() + self._camera:setPosition3D(cc.vec3(playerPos.x + camera_offset.x, playerPos.y + camera_offset.y, playerPos.z + camera_offset.z)) + self._camera:setRotation3D(cc.vec3(-45,0,0)) + + self:addChild(self._player) + self:addChild(self._terrain) +end + +function TerrainWalkThru:title() + return "TerrainWalkThru" +end + +function TerrainWalkThru:subtitle() + return "" +end + +function TerrainTest() + local scene = cc.Scene:create() + + Helper.createFunctionTable = + { + TerrainSimple.create, + TerrainWalkThru.create, + } + + scene:addChild(TerrainSimple.create()) + scene:addChild(CreateBackMenuItem()) + + return scene +end \ No newline at end of file diff --git a/tests/lua-tests/src/mainMenu.lua b/tests/lua-tests/src/mainMenu.lua index b5cdf161f8..3c20ebc779 100644 --- a/tests/lua-tests/src/mainMenu.lua +++ b/tests/lua-tests/src/mainMenu.lua @@ -43,6 +43,7 @@ require "Sprite3DTest/Sprite3DTest" require "SpriteTest/SpriteTest" require "SceneTest/SceneTest" require "SpineTest/SpineTest" +require "TerrainTest/TerrainTest" require "Texture2dTest/Texture2dTest" require "TileMapTest/TileMapTest" require "TouchesTest/TouchesTest" @@ -123,6 +124,7 @@ local _allTests = { { isSupported = false, name = "SchdulerTest" , create_func= SchdulerTestMain }, { isSupported = false, name = "ShaderTest" , create_func= ShaderTestMain }, { isSupported = true, name = "Sprite3DTest" , create_func = Sprite3DTest }, + { isSupported = true, name = "TerrainTest" , create_func = TerrainTest }, { isSupported = true, name = "SpriteTest" , create_func = SpriteTest }, { isSupported = false, name = "TextInputTest" , create_func= TextInputTestMain }, { isSupported = true, name = "Texture2DTest" , create_func = Texture2dTestMain }, diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 41a1468b22..d0208ac730 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 41a1468b229eb1d93e382e54c70457940129cdc0 +Subproject commit d0208ac730d517dd5f9d4edb4c680933f7948fe9 diff --git a/tools/jenkins-scripts/slave-scripts/android-build.sh b/tools/jenkins-scripts/slave-scripts/android-build.sh index 8df85e346c..5c86082518 100755 --- a/tools/jenkins-scripts/slave-scripts/android-build.sh +++ b/tools/jenkins-scripts/slave-scripts/android-build.sh @@ -2,5 +2,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" COCOS2DX_ROOT="$DIR"/../../.. cd ${COCOS2DX_ROOT} -python build/android-build.py -p 10 all - +python build/android-build.py -p 10 cpp-tests lua-tests diff --git a/tools/tolua/cocos2dx_3d.ini b/tools/tolua/cocos2dx_3d.ini index 15aada2fbc..8fc0bbfeb0 100644 --- a/tools/tolua/cocos2dx_3d.ini +++ b/tools/tolua/cocos2dx_3d.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/cocos2d.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard Sprite3DCache TextureCube Skybox +classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard Sprite3DCache TextureCube Skybox Terrain # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -40,7 +40,8 @@ skip = Mesh::[create getAABB getVertexBuffer hasVertexAttrib getSkin getMeshInde Skeleton3D::[create], Animation3D::[getBoneCurveByName getBoneCurves], BillBoard::[draw], - Sprite3DCache::[addSprite3DData getSpriteData] + Sprite3DCache::[addSprite3DData getSpriteData], + Terrain::[lookForIndicesLODSkrit lookForIndicesLOD insertIndicesLOD insertIndicesLODSkirt getIntersectionPoint getAABB getQuadTree create getHeight] rename_functions =