diff --git a/AUTHORS b/AUTHORS index ba8e4686d9..a5b107d9d3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -896,6 +896,7 @@ Developers: kezhuw AutoReleasePool manager improvement + Fixed a bug that condition variable sleep on unrelated mutex in HttpClient zhouxiaoxiaoxujian Added TextField::getStringLength() diff --git a/CHANGELOG b/CHANGELOG index bfe066429f..93ed0c39b6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,11 +1,14 @@ cocos2d-x-3.3?? ?? [NEW] ActionManager: added removeAllActionsByTag() [NEW] Node: added stopAllActionsByTag() + [NEW] Renderer: added TriangleCommand [NEW] UI: added `WebView` on iOS and Android [FIX] EditBox: moved to ui:EditBox + [FIX] HttpClient: condition variable sleep on unrelated mutex [FIX] Node: create unneeded temple `Vec2` object in `setPosition(int, int)`, `setPositionX()` and `setPositionY()` [FIX] Node: skew effect is wrong + [FIX] Node: setNormalizedPosition can not take effect if parent position is not changed [FIX] TextureAtlas: may crash if only drawing part of it cocos2d-x-3.3alpha0 Aug.28 2014 diff --git a/build/cocos2d-win32.vc2012.sln b/build/cocos2d-win32.vc2012.sln index f23109c90c..45dcf34217 100644 --- a/build/cocos2d-win32.vc2012.sln +++ b/build/cocos2d-win32.vc2012.sln @@ -1,6 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-tests", "..\tests\cpp-tests\proj.win32\cpp-tests.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua-tests", "..\tests\lua-tests\project\proj.win32\lua-tests.win32.vcxproj", "{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}" @@ -13,40 +15,76 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos\2d\l EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libluacocos2d", "..\cocos\scripting\lua-bindings\proj.win32\libluacocos2d.vcxproj", "{9F2D6CE6-C893-4400-B50C-6DB70CC2562F}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbox2d", "..\external\Box2D\proj.win32\libbox2d.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{92D54E36-7916-48EF-A951-224DD3B25442}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos\editor-support\spine\proj.win32\libSpine.vcxproj", "{B7C2A162-DEC9-4418-972E-240AB3CBFCAE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM Debug|Win32 = Debug|Win32 + Release|ARM = Release|ARM Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|ARM.ActiveCfg = Debug|Win32 {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.ActiveCfg = Debug|Win32 {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.Build.0 = Debug|Win32 + {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|ARM.ActiveCfg = Release|Win32 {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.ActiveCfg = Release|Win32 {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.Build.0 = Release|Win32 + {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|ARM.ActiveCfg = Debug|Win32 {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.ActiveCfg = Debug|Win32 {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.Build.0 = Debug|Win32 + {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|ARM.ActiveCfg = Release|Win32 {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.ActiveCfg = Release|Win32 {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.Build.0 = Release|Win32 + {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|ARM.ActiveCfg = Debug|Win32 {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.ActiveCfg = Debug|Win32 {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.Build.0 = Debug|Win32 + {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|ARM.ActiveCfg = Release|Win32 {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.ActiveCfg = Release|Win32 {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.Build.0 = Release|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|ARM.ActiveCfg = Debug|Win32 {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.ActiveCfg = Debug|Win32 {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.Build.0 = Debug|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|ARM.ActiveCfg = Release|Win32 {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.ActiveCfg = Release|Win32 {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.Build.0 = Release|Win32 + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|ARM.ActiveCfg = Debug|Win32 {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.ActiveCfg = Debug|Win32 {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32 + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|ARM.ActiveCfg = Release|Win32 {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32 {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32 + {9F2D6CE6-C893-4400-B50C-6DB70CC2562F}.Debug|ARM.ActiveCfg = Debug|Win32 {9F2D6CE6-C893-4400-B50C-6DB70CC2562F}.Debug|Win32.ActiveCfg = Debug|Win32 {9F2D6CE6-C893-4400-B50C-6DB70CC2562F}.Debug|Win32.Build.0 = Debug|Win32 + {9F2D6CE6-C893-4400-B50C-6DB70CC2562F}.Release|ARM.ActiveCfg = Release|Win32 {9F2D6CE6-C893-4400-B50C-6DB70CC2562F}.Release|Win32.ActiveCfg = Release|Win32 {9F2D6CE6-C893-4400-B50C-6DB70CC2562F}.Release|Win32.Build.0 = Release|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Debug|ARM.ActiveCfg = Debug|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Release|ARM.ActiveCfg = Release|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|ARM.ActiveCfg = Debug|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.ActiveCfg = Debug|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.Build.0 = Debug|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|ARM.ActiveCfg = Release|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.ActiveCfg = Release|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {929480E7-23C0-4DF6-8456-096D71547116} = {92D54E36-7916-48EF-A951-224DD3B25442} + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE} = {92D54E36-7916-48EF-A951-224DD3B25442} + EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} EndGlobalSection diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index ee4fb60fd9..8fd3a8b5bf 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1827,6 +1827,10 @@ 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 */; }; + B230ED7319B417AE00364AA8 /* CCTrianglesCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = B230ED7019B417AE00364AA8 /* CCTrianglesCommand.h */; }; + B230ED7419B417AE00364AA8 /* CCTrianglesCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = B230ED7019B417AE00364AA8 /* CCTrianglesCommand.h */; }; B24AA985195A675C007B4522 /* CCFastTMXLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B24AA981195A675C007B4522 /* CCFastTMXLayer.cpp */; }; B24AA986195A675C007B4522 /* CCFastTMXLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B24AA981195A675C007B4522 /* CCFastTMXLayer.cpp */; }; B24AA987195A675C007B4522 /* CCFastTMXLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = B24AA982195A675C007B4522 /* CCFastTMXLayer.h */; }; @@ -2869,6 +2873,8 @@ B21770481977ED4C009EE11B /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; B217704A1977ED55009EE11B /* libcurl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.dylib; path = usr/lib/libcurl.dylib; sourceTree = SDKROOT; }; B217704C1977ED8B009EE11B /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; + B230ED6F19B417AE00364AA8 /* CCTrianglesCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTrianglesCommand.cpp; sourceTree = ""; }; + B230ED7019B417AE00364AA8 /* CCTrianglesCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTrianglesCommand.h; sourceTree = ""; }; B24AA981195A675C007B4522 /* CCFastTMXLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCFastTMXLayer.cpp; sourceTree = ""; }; B24AA982195A675C007B4522 /* CCFastTMXLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFastTMXLayer.h; sourceTree = ""; }; B24AA983195A675C007B4522 /* CCFastTMXTiledMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCFastTMXTiledMap.cpp; sourceTree = ""; }; @@ -4619,6 +4625,8 @@ 50ABBD731925AB4100A911A9 /* CCGroupCommand.h */, B29594B21926D5EC003EEF37 /* CCMeshCommand.cpp */, B29594B31926D5EC003EEF37 /* CCMeshCommand.h */, + B230ED6F19B417AE00364AA8 /* CCTrianglesCommand.cpp */, + B230ED7019B417AE00364AA8 /* CCTrianglesCommand.h */, 50ABBD741925AB4100A911A9 /* CCQuadCommand.cpp */, 50ABBD751925AB4100A911A9 /* CCQuadCommand.h */, 50ABBD761925AB4100A911A9 /* CCRenderCommand.cpp */, @@ -5017,6 +5025,7 @@ 15AE1BE519AAE01E00C27E9E /* CCTableView.h in Headers */, 15AE1BD319AAE01E00C27E9E /* CCControlPotentiometer.h in Headers */, 15AE1B6E19AADA9900C27E9E /* UIHelper.h in Headers */, + B230ED7319B417AE00364AA8 /* CCTrianglesCommand.h in Headers */, 15AE187F19AAD33D00C27E9E /* CCBKeyframe.h in Headers */, 1A570073180BC5A10088DEC7 /* CCActionGrid.h in Headers */, 15AE1BCC19AAE01E00C27E9E /* CCControlButton.h in Headers */, @@ -5599,6 +5608,7 @@ 15AE192519AAD35100C27E9E /* CocoLoader.h in Headers */, 15AE1BBB19AADFF000C27E9E /* HttpRequest.h in Headers */, B60C5BD719AC68B10056FBDE /* CCBillBoard.h in Headers */, + B230ED7419B417AE00364AA8 /* CCTrianglesCommand.h in Headers */, 15AE1A0019AAD3A700C27E9E /* AtlasAttachmentLoader.h in Headers */, 15AE1ACB19AAD40300C27E9E /* b2MouseJoint.h in Headers */, 50ABBD3F1925AB0000A911A9 /* CCGeometry.h in Headers */, @@ -6282,6 +6292,7 @@ 15AE1A7819AAD40300C27E9E /* b2PolygonAndCircleContact.cpp in Sources */, 15AE1A3419AAD3D500C27E9E /* b2EdgeShape.cpp in Sources */, 15AE1BA319AADFDF00C27E9E /* UILayoutManager.cpp in Sources */, + B230ED7119B417AE00364AA8 /* CCTrianglesCommand.cpp in Sources */, 1A5702F2180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */, 15AE1A5B19AAD40300C27E9E /* b2Timer.cpp in Sources */, 15AE1B1219AAD43700C27E9E /* cpGearJoint.c in Sources */, @@ -6477,6 +6488,7 @@ 1A01C6A518F58F7500EFE3A6 /* CCNotificationCenter.cpp in Sources */, 292DB14E19B4574100A80320 /* UIEditBoxImplMac.mm in Sources */, 15AE1BFB19AAE01E00C27E9E /* CCControlUtils.cpp in Sources */, + B230ED7219B417AE00364AA8 /* CCTrianglesCommand.cpp in Sources */, 15AE1B9019AADA9A00C27E9E /* UIWidget.cpp in Sources */, ED9C6A9518599AD8000A5232 /* CCNodeGrid.cpp in Sources */, 1A01C68F18F57BE800EFE3A6 /* CCDictionary.cpp in Sources */, diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index cbd4b97f31..d13cd07bc6 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -126,6 +126,7 @@ Node::Node(void) , _cascadeColorEnabled(false) , _cascadeOpacityEnabled(false) , _usingNormalizedPosition(false) +, _normalizedPositionDirty(false) , _name("") , _hashOfName(0) , _cameraMask(1) @@ -613,6 +614,7 @@ void Node::setNormalizedPosition(const Vec2& position) _normalizedPosition = position; _usingNormalizedPosition = true; + _normalizedPositionDirty = true; _transformUpdated = _transformDirty = _inverseDirty = true; } @@ -1210,17 +1212,21 @@ void Node::visit() uint32_t Node::processParentFlags(const Mat4& parentTransform, uint32_t parentFlags) { + if(_usingNormalizedPosition) { + CCASSERT(_parent, "setNormalizedPosition() doesn't work with orphan nodes"); + if ((parentFlags & FLAGS_CONTENT_SIZE_DIRTY) || _normalizedPositionDirty) { + auto s = _parent->getContentSize(); + _position.x = _normalizedPosition.x * s.width; + _position.y = _normalizedPosition.y * s.height; + _transformUpdated = _transformDirty = _inverseDirty = true; + _normalizedPositionDirty = false; + } + } + uint32_t flags = parentFlags; flags |= (_transformUpdated ? FLAGS_TRANSFORM_DIRTY : 0); flags |= (_contentSizeDirty ? FLAGS_CONTENT_SIZE_DIRTY : 0); - - if(_usingNormalizedPosition && (flags & FLAGS_CONTENT_SIZE_DIRTY)) { - CCASSERT(_parent, "setNormalizedPosition() doesn't work with orphan nodes"); - auto s = _parent->getContentSize(); - _position.x = _normalizedPosition.x * s.width; - _position.y = _normalizedPosition.y * s.height; - _transformUpdated = _transformDirty = _inverseDirty = true; - } + if(flags & FLAGS_DIRTY_MASK) _modelViewTransform = this->transform(parentTransform); diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 8f24f2d09d..96ab1118ee 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -1555,6 +1555,7 @@ protected: float _positionZ; ///< OpenGL real Z position Vec2 _normalizedPosition; bool _usingNormalizedPosition; + bool _normalizedPositionDirty; float _skewX; ///< skew angle on x-axis float _skewY; ///< skew angle on y-axis diff --git a/cocos/2d/cocos2d_headers.props b/cocos/2d/cocos2d_headers.props index afdcd49a10..aaaefd1c7d 100644 --- a/cocos/2d/cocos2d_headers.props +++ b/cocos/2d/cocos2d_headers.props @@ -10,6 +10,9 @@ $(EngineRoot)cocos;$(EngineRoot)cocos\platform\win32;$(EngineRoot)cocos\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES _VARIADIC_MAX=10;%(PreprocessorDefinitions) + + false + diff --git a/cocos/2d/cocos2dx.props b/cocos/2d/cocos2dx.props index 543f4ab5cc..a0a234ee9f 100644 --- a/cocos/2d/cocos2dx.props +++ b/cocos/2d/cocos2dx.props @@ -7,11 +7,14 @@ - opengl32.lib;glew32.lib;libzlib.lib;libpng.lib;libjpeg.lib;libtiff.lib;libwebp.lib;libiconv.lib;glfw3.lib;freetype250.lib;winmm.lib;ws2_32.lib;libchipmunk.lib;libbox2d.lib;libspine.lib;%(AdditionalDependencies) + opengl32.lib;glew32.lib;libzlib.lib;libpng.lib;libjpeg.lib;libtiff.lib;libwebp.lib;libiconv.lib;glfw3.lib;freetype250.lib;winmm.lib;ws2_32.lib;libchipmunk.lib;libbox2d.lib;libSpine.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) false + + false + \ No newline at end of file diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index c98b955655..1e29c37755 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -24,7 +24,7 @@ v110 v110_xp v120 - v110_xp + v120_xp DynamicLibrary @@ -33,7 +33,7 @@ v110 v110_xp v120 - v110_xp + v120_xp @@ -77,7 +77,7 @@ Disabled - $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\win32;$(EngineRoot)external\jpeg\include\win32;$(EngineRoot)external\tiff\include\win32;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\win32;$(EngineRoot)external\win32-specific\icon\include;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\Box2d;$(EngineRoot)external\curl\include\win32;$(EngineRoot)external\websockets\include\win32;$(EngineRoot)external;$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot)external\box2d;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\win32;$(EngineRoot)external\jpeg\include\win32;$(EngineRoot)external\tiff\include\win32;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\win32;$(EngineRoot)external\win32-specific\icon\include;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\curl\include\win32;$(EngineRoot)external\websockets\include\win32;$(EngineRoot)external;$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) WIN32;_USRDLL;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) false EnableFastChecks @@ -104,9 +104,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\zlib\prebuilt\*.*" "$(Ou xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\icon\prebuilt\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\chipmunk\prebuilt\debug-lib\*.*" "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\box2d\prebuilt\debug-lib\*.*" "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\spine\prebuilt\debug-lib\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\chipmunk\prebuilt\debug-lib\*.*" "$(OutDir)" $(OutDir)$(ProjectName).dll @@ -158,8 +156,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\zlib\prebuilt\*.*" "$(Ou xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\icon\prebuilt\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\chipmunk\prebuilt\release-lib\*.*" "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\box2d\prebuilt\release-lib\*.*" "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\spine\prebuilt\release-lib\*.*" "$(OutDir)" + sqlite3.lib;libcurl_imp.lib;websockets.lib;%(AdditionalDependencies) @@ -402,6 +399,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\spine\prebuilt\release-l + @@ -777,6 +775,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\spine\prebuilt\release-l + @@ -887,6 +886,14 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\spine\prebuilt\release-l + + + {929480e7-23c0-4df6-8456-096d71547116} + + + {b7c2a162-dec9-4418-972e-240ab3cbfcae} + + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index 3f1d82aa8e..29f36901e9 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -589,6 +589,9 @@ renderer + + renderer + renderer @@ -1588,6 +1591,9 @@ renderer + + renderer + renderer diff --git a/cocos/3d/CCBundle3D.cpp b/cocos/3d/CCBundle3D.cpp index c28351046b..6a2a74efd2 100644 --- a/cocos/3d/CCBundle3D.cpp +++ b/cocos/3d/CCBundle3D.cpp @@ -760,7 +760,17 @@ bool Bundle3D::loadNodes(NodeDatas& nodedatas) if (_version == "0.1" || _version == "1.2" || _version == "0.2") { SkinData skinData; - loadSkinData("", &skinData); + if (!loadSkinData("", &skinData)) + { + auto node= new (std::nothrow) NodeData(); + auto modelnode = new (std::nothrow) ModelData(); + modelnode->matrialId = ""; + modelnode->subMeshId = ""; + node->modelNodeDatas.push_back(modelnode); + nodedatas.nodes.push_back(node); + return true; + } + auto nodeDatas = new (std::nothrow) NodeData*[skinData.skinBoneNames.size() + skinData.nodeBoneNames.size()]; int index = 0; size_t i; diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index 8d289035ab..ed9a3baf89 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -231,6 +231,7 @@ Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,c auto sprite = new (std::nothrow) Sprite3D(); if (sprite) { + sprite->setName(nodedata->id); auto mesh = Mesh::create(nodedata->id, getMeshIndexData(modeldata->subMeshId)); if (modeldata->matrialId == "" && matrialdatas.materials.size()) { @@ -399,6 +400,7 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m node= Node::create(); if(node) { + node->setName(nodedata->id); node->setAdditionalTransform(&nodedata->transform); if(root) { diff --git a/cocos/Android.mk b/cocos/Android.mk index 94c14a9824..87573c5ce1 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -159,6 +159,7 @@ renderer/CCVertexIndexBuffer.cpp \ renderer/CCVertexIndexData.cpp \ renderer/CCPrimitive.cpp \ renderer/CCPrimitiveCommand.cpp \ +renderer/CCTrianglesCommand.cpp \ deprecated/CCArray.cpp \ deprecated/CCSet.cpp \ deprecated/CCString.cpp \ diff --git a/cocos/base/ObjectFactory.cpp b/cocos/base/ObjectFactory.cpp index 1a14b14ce7..4d9c11145b 100644 --- a/cocos/base/ObjectFactory.cpp +++ b/cocos/base/ObjectFactory.cpp @@ -22,6 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ +#include #include "base/ObjectFactory.h" @@ -30,12 +31,22 @@ NS_CC_BEGIN ObjectFactory::TInfo::TInfo(void) :_class("") ,_fun(nullptr) +,_func(nullptr) { } ObjectFactory::TInfo::TInfo(const std::string& type, Instance ins) :_class(type) ,_fun(ins) +,_func(nullptr) +{ + ObjectFactory::getInstance()->registerType(*this); +} + +ObjectFactory::TInfo::TInfo(const std::string& type, InstanceFunc ins) + :_class(type) + ,_fun(nullptr) + ,_func(ins) { ObjectFactory::getInstance()->registerType(*this); } @@ -44,18 +55,21 @@ ObjectFactory::TInfo::TInfo(const TInfo &t) { _class = t._class; _fun = t._fun; + _func = t._func; } ObjectFactory::TInfo::~TInfo(void) { _class = ""; _fun = nullptr; + _func = nullptr; } ObjectFactory::TInfo& ObjectFactory::TInfo::operator= (const TInfo &t) { _class = t._class; _fun = t._fun; + _func = t._func; return *this; } @@ -88,13 +102,18 @@ void ObjectFactory::destroyInstance() Ref* ObjectFactory::createObject(const std::string &name) { - Ref *o = nullptr; - do - { - const TInfo t = _typeMap[name]; - CC_BREAK_IF(t._fun == nullptr); - o = t._fun(); - } while (0); + Ref *o = nullptr; + do + { + const TInfo t = _typeMap[name]; + if (t._fun != nullptr) + { + o = t._fun(); + }else if (t._func != nullptr) + { + o = t._func(); + } + } while (0); return o; } diff --git a/cocos/base/ObjectFactory.h b/cocos/base/ObjectFactory.h index 658fc65352..c9342f2c9d 100644 --- a/cocos/base/ObjectFactory.h +++ b/cocos/base/ObjectFactory.h @@ -27,6 +27,7 @@ THE SOFTWARE. #include #include +#include #include "base/CCRef.h" #include "base/CCPlatformMacros.h" @@ -36,15 +37,18 @@ class CC_DLL ObjectFactory { public: typedef cocos2d::Ref* (*Instance)(void); + typedef std::function InstanceFunc; struct CC_DLL TInfo { TInfo(void); - TInfo(const std::string& type, Instance ins = NULL); + TInfo(const std::string& type, Instance ins = nullptr); + TInfo(const std::string& type, InstanceFunc ins = nullptr); TInfo(const TInfo &t); ~TInfo(void); TInfo& operator= (const TInfo &t); std::string _class; Instance _fun; + InstanceFunc _func; }; typedef std::unordered_map FactoryMap; diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index 0bd428f97d..4f06a692d7 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -158,6 +158,7 @@ THE SOFTWARE. #include "renderer/CCVertexIndexData.h" #include "renderer/CCPrimitive.h" #include "renderer/CCPrimitiveCommand.h" +#include "renderer/CCTrianglesCommand.h" // physics #include "physics/CCPhysicsBody.h" diff --git a/cocos/editor-support/cocostudio/CCActionNode.cpp b/cocos/editor-support/cocostudio/CCActionNode.cpp index d1dfa4f438..aa30b2b2fe 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.cpp +++ b/cocos/editor-support/cocostudio/CCActionNode.cpp @@ -313,18 +313,14 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root) } void ActionNode::initActionNodeFromRoot(Ref* root) -{ - Node* rootNode = dynamic_cast(root); - if (rootNode != nullptr) +{ + Widget* rootWidget = dynamic_cast(root); + if (rootWidget != nullptr) { - Widget* rootWidget = dynamic_cast(root); - if (rootWidget != nullptr) + Widget* widget = Helper::seekActionWidgetByActionTag(rootWidget, getActionTag()); + if (widget != nullptr) { - Widget* widget = Helper::seekActionWidgetByActionTag(rootWidget, getActionTag()); - if (widget != nullptr) - { - setObject(widget); - } + setObject(widget); } } } @@ -367,14 +363,6 @@ Node* ActionNode::getActionNode() { return cNode; } - else - { - Widget* rootWidget = dynamic_cast(_object); - if (rootWidget != nullptr) - { - return rootWidget; - } - } return nullptr; } diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 0369186f4f..e1e1cf9af3 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -176,6 +176,27 @@ void GUIReader::registerTypeAndCallBack(const std::string& classType, } } +void GUIReader::registerTypeAndCallBack(const std::string& classType, + ObjectFactory::InstanceFunc ins, + Ref *object, + SEL_ParseEvent callBack) +{ + ObjectFactory* factoryCreate = ObjectFactory::getInstance(); + + ObjectFactory::TInfo t(classType, ins); + factoryCreate->registerType(t); + + if (object) + { + _mapObject.insert(ParseObjectMap::value_type(classType, object)); + } + + if (callBack) + { + _mapParseSelector.insert(ParseCallBackMap::value_type(classType, callBack)); + } +} + Widget* GUIReader::widgetFromJsonFile(const char *fileName) { @@ -1511,11 +1532,11 @@ void WidgetPropertiesReader0300::setPropsForAllCustomWidgetFromJsonDictionary(co { GUIReader* guiReader = GUIReader::getInstance(); - std::map object_map = GUIReader::getInstance()->getParseObjectMap(); - Ref* object = object_map[classType]; + std::map *object_map = guiReader->getParseObjectMap(); + Ref* object = (*object_map)[classType]; - std::map selector_map = guiReader->getParseCallBackMap(); - SEL_ParseEvent selector = selector_map[classType]; + std::map *selector_map = guiReader->getParseCallBackMap(); + SEL_ParseEvent selector = (*selector_map)[classType]; if (object && selector) { diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.h b/cocos/editor-support/cocostudio/CCSGUIReader.h index 89f27a6a1b..12239ead66 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.h +++ b/cocos/editor-support/cocostudio/CCSGUIReader.h @@ -72,6 +72,11 @@ public: cocos2d::ObjectFactory::Instance ins, Ref* object, SEL_ParseEvent callBack); + + void registerTypeAndCallBack(const std::string& classType, + cocos2d::ObjectFactory::InstanceFunc ins, + Ref* object, + SEL_ParseEvent callBack); protected: GUIReader(); ~GUIReader(); @@ -85,8 +90,8 @@ protected: ParseObjectMap _mapObject; public: - ParseCallBackMap getParseCallBackMap() { return _mapParseSelector; }; - ParseObjectMap getParseObjectMap() { return _mapObject; }; + ParseCallBackMap* getParseCallBackMap() { return &_mapParseSelector; }; + ParseObjectMap* getParseObjectMap() { return &_mapObject; }; }; diff --git a/cocos/editor-support/spine/proj.win32/libSpine.vcxproj b/cocos/editor-support/spine/proj.win32/libSpine.vcxproj new file mode 100644 index 0000000000..2f033657b8 --- /dev/null +++ b/cocos/editor-support/spine/proj.win32/libSpine.vcxproj @@ -0,0 +1,152 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE} + libSpine + + + + StaticLibrary + true + v100 + v110 + v110_xp + v120 + v120_xp + Unicode + + + StaticLibrary + false + v100 + v110 + v110_xp + v120 + v120_xp + true + Unicode + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + + + + Level3 + Disabled + + + $(EngineRoot);$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + 4267;4251;4244;%(DisableSpecificWarnings) + false + + + true + + + + + Level3 + MinSpace + true + true + + + WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(EngineRoot);$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + None + false + + + true + true + true + + + + + + \ No newline at end of file diff --git a/cocos/editor-support/spine/proj.win32/libSpine.vcxproj.filters b/cocos/editor-support/spine/proj.win32/libSpine.vcxproj.filters new file mode 100644 index 0000000000..a6f105d4bc --- /dev/null +++ b/cocos/editor-support/spine/proj.win32/libSpine.vcxproj.filters @@ -0,0 +1,170 @@ + + + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/cocos/network/HttpClient.cpp b/cocos/network/HttpClient.cpp index c2a0440b99..4640258c2a 100644 --- a/cocos/network/HttpClient.cpp +++ b/cocos/network/HttpClient.cpp @@ -47,16 +47,13 @@ namespace network { static std::mutex s_requestQueueMutex; static std::mutex s_responseQueueMutex; -static std::mutex s_SleepMutex; -static std::condition_variable s_SleepCondition; +static std::condition_variable_any s_SleepCondition; #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) typedef int int32_t; #endif -static bool s_need_quit = false; - static Vector* s_requestQueue = nullptr; static Vector* s_responseQueue = nullptr; @@ -102,43 +99,31 @@ static int processDeleteTask(HttpRequest *request, write_callback callback, void // int processDownloadTask(HttpRequest *task, write_callback callback, void *stream, int32_t *errorCode); static void processResponse(HttpResponse* response, char* errorBuffer); +static HttpRequest *s_requestSentinel = new HttpRequest; + // Worker thread void HttpClient::networkThread() { - HttpRequest *request = nullptr; - auto scheduler = Director::getInstance()->getScheduler(); while (true) { - if (s_need_quit) - { - break; - } - + HttpRequest *request; + // step 1: send http request if the requestQueue isn't empty - request = nullptr; - - s_requestQueueMutex.lock(); - - //Get request task from queue - - if (!s_requestQueue->empty()) { + std::lock_guard lock(s_requestQueueMutex); + while (s_requestQueue->empty()) { + s_SleepCondition.wait(s_requestQueueMutex); + } request = s_requestQueue->at(0); s_requestQueue->erase(0); } - - s_requestQueueMutex.unlock(); - - if (nullptr == request) - { - // Wait for http request tasks from main thread - std::unique_lock lk(s_SleepMutex); - s_SleepCondition.wait(lk); - continue; + + if (request == s_requestSentinel) { + break; } - + // step 2: libcurl sync access // Create a HttpResponse object, the default setting is http access failed @@ -462,12 +447,14 @@ HttpClient::HttpClient() HttpClient::~HttpClient() { - s_need_quit = true; - if (s_requestQueue != nullptr) { + { + std::lock_guard lock(s_requestQueueMutex); + s_requestQueue->pushBack(s_requestSentinel); + } s_SleepCondition.notify_one(); } - + s_pHttpClient = nullptr; } @@ -480,9 +467,7 @@ bool HttpClient::lazyInitThreadSemphore() s_requestQueue = new (std::nothrow) Vector(); s_responseQueue = new (std::nothrow) Vector(); - - s_need_quit = false; - + auto t = std::thread(CC_CALLBACK_0(HttpClient::networkThread, this)); t.detach(); } diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java index ea102e7f73..ebbc5bdc75 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java @@ -91,7 +91,6 @@ public class Cocos2dxHelper { Cocos2dxHelper.nativeSetContext((Context)activity, Cocos2dxHelper.sAssetManager); Cocos2dxBitmap.setContext(activity); - Cocos2dxETCLoader.setContext(activity); sActivity = activity; sInited = true; diff --git a/cocos/platform/win32/CCFileUtilsWin32.cpp b/cocos/platform/win32/CCFileUtilsWin32.cpp index c43339c8a7..1e174ef13e 100644 --- a/cocos/platform/win32/CCFileUtilsWin32.cpp +++ b/cocos/platform/win32/CCFileUtilsWin32.cpp @@ -147,7 +147,7 @@ static Data getData(const std::string& filename, bool forString) WCHAR wszBuf[CC_MAX_PATH] = {0}; MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf)/sizeof(wszBuf[0])); - HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, 0, NULL, OPEN_EXISTING, NULL, nullptr); + HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, nullptr); CC_BREAK_IF(fileHandle == INVALID_HANDLE_VALUE); size = ::GetFileSize(fileHandle, nullptr); @@ -222,7 +222,7 @@ unsigned char* FileUtilsWin32::getFileData(const std::string& filename, const ch WCHAR wszBuf[CC_MAX_PATH] = {0}; MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf)/sizeof(wszBuf[0])); - HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, 0, NULL, OPEN_EXISTING, NULL, nullptr); + HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, nullptr); CC_BREAK_IF(fileHandle == INVALID_HANDLE_VALUE); *size = ::GetFileSize(fileHandle, nullptr); diff --git a/cocos/renderer/CCQuadCommand.cpp b/cocos/renderer/CCQuadCommand.cpp index ac52bb0f1a..5b910e7e89 100644 --- a/cocos/renderer/CCQuadCommand.cpp +++ b/cocos/renderer/CCQuadCommand.cpp @@ -28,16 +28,12 @@ #include "renderer/ccGLStateCache.h" #include "renderer/CCGLProgram.h" #include "xxhash.h" +#include "renderer/CCRenderer.h" NS_CC_BEGIN - QuadCommand::QuadCommand() -:_materialID(0) -,_textureID(0) -,_glProgramState(nullptr) -,_blendType(BlendFunc::DISABLE) -,_quads(nullptr) +:_quads(nullptr) ,_quadsCount(0) { _type = RenderCommand::Type::QUAD_COMMAND; @@ -52,6 +48,29 @@ void QuadCommand::init(float globalOrder, GLuint textureID, GLProgramState* glPr _quadsCount = quadCount; _quads = quad; + + //generate triangles + { + static std::vector QUADINDICESMAX; + if(QUADINDICESMAX.size() == 0) + { + QUADINDICESMAX.resize(Renderer::INDEX_VBO_SIZE); + for(ssize_t i = 0; i < Renderer::INDEX_VBO_SIZE / 6; ++i) + { + QUADINDICESMAX[ 6 * i + 0] = 4 * i + 0; + QUADINDICESMAX[ 6 * i + 1] = 4 * i + 1; + QUADINDICESMAX[ 6 * i + 2] = 4 * i + 2; + QUADINDICESMAX[ 6 * i + 3] = 4 * i + 3; + QUADINDICESMAX[ 6 * i + 4] = 4 * i + 2; + QUADINDICESMAX[ 6 * i + 5] = 4 * i + 1; + } + } + + _triangles.vertCount = quadCount * 4; + _triangles.indexCount = quadCount * 6; + _triangles.indices = &QUADINDICESMAX[0]; + _triangles.verts = &quad->tl; + } _mv = mv; @@ -69,31 +88,4 @@ QuadCommand::~QuadCommand() { } -void QuadCommand::generateMaterialID() -{ - - if(_glProgramState->getUniformCount() > 0) - { - _materialID = QuadCommand::MATERIAL_ID_DO_NOT_BATCH; - } - else - { - int glProgram = (int)_glProgramState->getGLProgram()->getProgram(); - int intArray[4] = { glProgram, (int)_textureID, (int)_blendType.src, (int)_blendType.dst}; - - _materialID = XXH32((const void*)intArray, sizeof(intArray), 0); - } -} - -void QuadCommand::useMaterial() const -{ - //Set texture - GL::bindTexture2D(_textureID); - - //set blend mode - GL::blendFunc(_blendType.src, _blendType.dst); - - _glProgramState->apply(_mv); -} - NS_CC_END diff --git a/cocos/renderer/CCQuadCommand.h b/cocos/renderer/CCQuadCommand.h index 25e003b4a5..bacd8528b3 100644 --- a/cocos/renderer/CCQuadCommand.h +++ b/cocos/renderer/CCQuadCommand.h @@ -27,14 +27,14 @@ #include "renderer/CCRenderCommand.h" #include "renderer/CCGLProgramState.h" +#include "renderer/CCTrianglesCommand.h" NS_CC_BEGIN /** Command used to render one or more Quads */ -class CC_DLL QuadCommand : public RenderCommand +class CC_DLL QuadCommand : public TrianglesCommand { public: - static const int MATERIAL_ID_DO_NOT_BATCH = 0; QuadCommand(); ~QuadCommand(); @@ -44,26 +44,12 @@ public: void init(float globalOrder, GLuint texutreID, GLProgramState* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount, const Mat4& mv); - void useMaterial() const; - - inline uint32_t getMaterialID() const { return _materialID; } - inline GLuint getTextureID() const { return _textureID; } - inline V3F_C4B_T2F_Quad* getQuads() const { return _quads; } + inline const V3F_C4B_T2F_Quad* getQuads() const { return _quads; } inline ssize_t getQuadCount() const { return _quadsCount; } - inline GLProgramState* getGLProgramState() const { return _glProgramState; } - inline BlendFunc getBlendType() const { return _blendType; } - inline const Mat4& getModelView() const { return _mv; } protected: - void generateMaterialID(); - - uint32_t _materialID; - GLuint _textureID; - GLProgramState* _glProgramState; - BlendFunc _blendType; V3F_C4B_T2F_Quad* _quads; ssize_t _quadsCount; - Mat4 _mv; }; NS_CC_END diff --git a/cocos/renderer/CCRenderCommand.h b/cocos/renderer/CCRenderCommand.h index 77332e01b0..882cc3518e 100644 --- a/cocos/renderer/CCRenderCommand.h +++ b/cocos/renderer/CCRenderCommand.h @@ -50,6 +50,7 @@ public: GROUP_COMMAND, MESH_COMMAND, PRIMITIVE_COMMAND, + TRIANGLES_COMMAND }; /** Get Render Command Id */ diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index 13404bd5fd..9dd1d48260 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -26,6 +26,7 @@ #include +#include "renderer/CCTrianglesCommand.h" #include "renderer/CCQuadCommand.h" #include "renderer/CCBatchCommand.h" #include "renderer/CCCustomCommand.h" @@ -138,7 +139,8 @@ static const int DEFAULT_RENDER_QUEUE = 0; Renderer::Renderer() :_lastMaterialID(0) ,_lastBatchedMeshCommand(nullptr) -,_numQuads(0) +,_filledVertex(0) +,_filledIndex(0) ,_glViewAssigned(false) ,_isRendering(false) #if CC_ENABLE_CACHE_TEXTURE_DATA @@ -151,7 +153,7 @@ Renderer::Renderer() RenderQueue defaultRenderQueue; _renderGroups.push_back(defaultRenderQueue); - _batchedQuadCommands.reserve(BATCH_QUADCOMMAND_RESEVER_SIZE); + _batchedCommands.reserve(BATCH_QUADCOMMAND_RESEVER_SIZE); } Renderer::~Renderer() @@ -181,27 +183,12 @@ void Renderer::initGLView() Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_cacheTextureListener, -1); #endif - - setupIndices(); setupBuffer(); _glViewAssigned = true; } -void Renderer::setupIndices() -{ - for( int i=0; i < VBO_SIZE; i++) - { - _indices[i*6+0] = (GLushort) (i*4+0); - _indices[i*6+1] = (GLushort) (i*4+1); - _indices[i*6+2] = (GLushort) (i*4+2); - _indices[i*6+3] = (GLushort) (i*4+3); - _indices[i*6+4] = (GLushort) (i*4+2); - _indices[i*6+5] = (GLushort) (i*4+1); - } -} - void Renderer::setupBuffer() { if(Configuration::getInstance()->supportsShareableVAO()) @@ -222,7 +209,7 @@ void Renderer::setupVBOAndVAO() glGenBuffers(2, &_buffersVBO[0]); glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); - glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * VBO_SIZE, _quads, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(_verts[0]) * VBO_SIZE, _verts, GL_DYNAMIC_DRAW); // vertices glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); @@ -237,7 +224,7 @@ void Renderer::setupVBOAndVAO() glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B_T2F), (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * VBO_SIZE * 6, _indices, GL_STATIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * INDEX_VBO_SIZE, _indices, GL_STATIC_DRAW); // Must unbind the VAO before changing the element buffer. GL::bindVAO(0); @@ -260,11 +247,11 @@ void Renderer::mapBuffers() GL::bindVAO(0); glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); - glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * VBO_SIZE, _quads, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(_verts[0]) * VBO_SIZE, _verts, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * VBO_SIZE * 6, _indices, GL_STATIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * INDEX_VBO_SIZE, _indices, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); CHECK_GL_ERROR_DEBUG(); @@ -316,25 +303,22 @@ void Renderer::visitRenderQueue(const RenderQueue& queue) { auto command = queue[index]; auto commandType = command->getType(); - if(RenderCommand::Type::QUAD_COMMAND == commandType) + if(RenderCommand::Type::QUAD_COMMAND == commandType || RenderCommand::Type::TRIANGLES_COMMAND == commandType) { flush3D(); - auto cmd = static_cast(command); + auto cmd = static_cast(command); //Batch quads - if(_numQuads + cmd->getQuadCount() > VBO_SIZE) + if( _filledVertex + cmd->getVertexCount() > VBO_SIZE || _filledIndex + cmd->getIndexCount() > INDEX_VBO_SIZE) { - CCASSERT(cmd->getQuadCount()>= 0 && cmd->getQuadCount() < VBO_SIZE, "VBO is not big enough for quad data, please break the quad data down or use customized render command"); - + CCASSERT(cmd->getVertexCount()>= 0 && cmd->getVertexCount() < VBO_SIZE, "VBO for vertex is not big enough, please break the data down or use customized render command"); + CCASSERT(cmd->getIndexCount()>= 0 && cmd->getIndexCount() < INDEX_VBO_SIZE, "VBO for index is not big enough, please break the data down or use customized render command"); //Draw batched quads if VBO is full drawBatchedQuads(); } - _batchedQuadCommands.push_back(cmd); + _batchedCommands.push_back(cmd); - memcpy(_quads + _numQuads, cmd->getQuads(), sizeof(V3F_C4B_T2F_Quad) * cmd->getQuadCount()); - convertToWorldCoordinates(_quads + _numQuads, cmd->getQuadCount(), cmd->getModelView()); - - _numQuads += cmd->getQuadCount(); + fillVerticesAndIndices(cmd); } else if(RenderCommand::Type::GROUP_COMMAND == commandType) @@ -389,18 +373,19 @@ void Renderer::visitTransparentRenderQueue(const TransparentRenderQueue& queue) // do not batch for transparent objects ssize_t size = queue.size(); + _batchedCommands.clear(); + _filledVertex = 0; + _filledIndex = 0; + for (ssize_t index = 0; index < size; ++index) { auto command = queue[index]; auto commandType = command->getType(); - if(RenderCommand::Type::QUAD_COMMAND == commandType) + if(RenderCommand::Type::QUAD_COMMAND == commandType || RenderCommand::Type::TRIANGLES_COMMAND == commandType) { - auto cmd = static_cast(command); - - _batchedQuadCommands.push_back(cmd); - _numQuads = (int)cmd->getQuadCount(); - memcpy(_quads, cmd->getQuads(), sizeof(V3F_C4B_T2F_Quad) * cmd->getQuadCount()); - convertToWorldCoordinates(_quads, cmd->getQuadCount(), cmd->getModelView()); + auto cmd = static_cast(command); + _batchedCommands.push_back(cmd); + fillVerticesAndIndices(cmd); drawBatchedQuads(); } else if(RenderCommand::Type::GROUP_COMMAND == commandType) @@ -482,52 +467,55 @@ void Renderer::clean() } // Clear batch quad commands - _batchedQuadCommands.clear(); - _numQuads = 0; - + _batchedCommands.clear(); + _filledVertex = 0; + _filledIndex = 0; _lastMaterialID = 0; _lastBatchedMeshCommand = nullptr; _transparentRenderGroups.clear(); } -void Renderer::convertToWorldCoordinates(V3F_C4B_T2F_Quad* quads, ssize_t quantity, const Mat4& modelView) +void Renderer::fillVerticesAndIndices(const TrianglesCommand* cmd) { -// kmMat4 matrixP, mvp; -// kmGLGetMatrix(KM_GL_PROJECTION, &matrixP); -// kmMat4Multiply(&mvp, &matrixP, &modelView); - for(ssize_t i=0; igetVertices(), sizeof(V3F_C4B_T2F) * cmd->getVertexCount()); + const Mat4& modelView = cmd->getModelView(); + + for(ssize_t i=0; i< cmd->getVertexCount(); ++i) { - V3F_C4B_T2F_Quad *q = &quads[i]; - Vec3 *vec1 = (Vec3*)&q->bl.vertices; + V3F_C4B_T2F *q = &_verts[i + _filledVertex]; + Vec3 *vec1 = (Vec3*)&q->vertices; modelView.transformPoint(vec1); - - Vec3 *vec2 = (Vec3*)&q->br.vertices; - modelView.transformPoint(vec2); - - Vec3 *vec3 = (Vec3*)&q->tr.vertices; - modelView.transformPoint(vec3); - - Vec3 *vec4 = (Vec3*)&q->tl.vertices; - modelView.transformPoint(vec4); } + + const unsigned short* indices = cmd->getIndices(); + //fill index + for(ssize_t i=0; i< cmd->getIndexCount(); ++i) + { + _indices[_filledIndex + i] = _filledVertex + indices[i]; + } + + _filledVertex += cmd->getVertexCount(); + _filledIndex += cmd->getIndexCount(); } void Renderer::drawBatchedQuads() { //TODO: we can improve the draw performance by insert material switching command before hand. - int quadsToDraw = 0; - int startQuad = 0; + int indexToDraw = 0; + int startIndex = 0; //Upload buffer to VBO - if(_numQuads <= 0 || _batchedQuadCommands.empty()) + if(_filledVertex <= 0 || _filledIndex <= 0 || _batchedCommands.empty()) { return; } if (Configuration::getInstance()->supportsShareableVAO()) { + //Bind VAO + GL::bindVAO(_quadVAO); //Set VBO data glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); @@ -538,22 +526,22 @@ void Renderer::drawBatchedQuads() // glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * (n-start), &quads_[start], GL_DYNAMIC_DRAW); // option 3: orphaning + glMapBuffer - glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * (_numQuads), nullptr, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(_verts[0]) * _filledVertex, nullptr, GL_DYNAMIC_DRAW); void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); - memcpy(buf, _quads, sizeof(_quads[0])* (_numQuads)); + memcpy(buf, _verts, sizeof(_verts[0])* _filledVertex); glUnmapBuffer(GL_ARRAY_BUFFER); glBindBuffer(GL_ARRAY_BUFFER, 0); - - //Bind VAO - GL::bindVAO(_quadVAO); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _filledIndex, _indices, GL_STATIC_DRAW); } else { -#define kQuadSize sizeof(_quads[0].bl) +#define kQuadSize sizeof(_verts[0]) glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); - glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _numQuads , _quads, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(_verts[0]) * _filledVertex , _verts, GL_DYNAMIC_DRAW); GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); @@ -567,23 +555,24 @@ void Renderer::drawBatchedQuads() glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _filledIndex, _indices, GL_STATIC_DRAW); } //Start drawing verties in batch - for(const auto& cmd : _batchedQuadCommands) + for(const auto& cmd : _batchedCommands) { auto newMaterialID = cmd->getMaterialID(); - if(_lastMaterialID != newMaterialID || newMaterialID == QuadCommand::MATERIAL_ID_DO_NOT_BATCH) + if(_lastMaterialID != newMaterialID || newMaterialID == TrianglesCommand::MATERIAL_ID_DO_NOT_BATCH) { //Draw quads - if(quadsToDraw > 0) + if(indexToDraw > 0) { - glDrawElements(GL_TRIANGLES, (GLsizei) quadsToDraw*6, GL_UNSIGNED_SHORT, (GLvoid*) (startQuad*6*sizeof(_indices[0])) ); + glDrawElements(GL_TRIANGLES, (GLsizei) indexToDraw, GL_UNSIGNED_SHORT, (GLvoid*) (startIndex*sizeof(_indices[0])) ); _drawnBatches++; - _drawnVertices += quadsToDraw*6; + _drawnVertices += indexToDraw; - startQuad += quadsToDraw; - quadsToDraw = 0; + startIndex += indexToDraw; + indexToDraw = 0; } //Use new material @@ -591,15 +580,15 @@ void Renderer::drawBatchedQuads() _lastMaterialID = newMaterialID; } - quadsToDraw += cmd->getQuadCount(); + indexToDraw += cmd->getIndexCount(); } //Draw any remaining quad - if(quadsToDraw > 0) + if(indexToDraw > 0) { - glDrawElements(GL_TRIANGLES, (GLsizei) quadsToDraw*6, GL_UNSIGNED_SHORT, (GLvoid*) (startQuad*6*sizeof(_indices[0])) ); + glDrawElements(GL_TRIANGLES, (GLsizei) indexToDraw, GL_UNSIGNED_SHORT, (GLvoid*) (startIndex*sizeof(_indices[0])) ); _drawnBatches++; - _drawnVertices += quadsToDraw*6; + _drawnVertices += indexToDraw; } if (Configuration::getInstance()->supportsShareableVAO()) @@ -613,8 +602,9 @@ void Renderer::drawBatchedQuads() glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } - _batchedQuadCommands.clear(); - _numQuads = 0; + _batchedCommands.clear(); + _filledVertex = 0; + _filledIndex = 0; } void Renderer::flush() diff --git a/cocos/renderer/CCRenderer.h b/cocos/renderer/CCRenderer.h index 1ba5abcd7e..5d99b7fb94 100644 --- a/cocos/renderer/CCRenderer.h +++ b/cocos/renderer/CCRenderer.h @@ -38,6 +38,7 @@ NS_CC_BEGIN class EventListenerCustom; class QuadCommand; +class TrianglesCommand; class MeshCommand; /** Class that knows how to sort `RenderCommand` objects. @@ -91,7 +92,9 @@ Whenever possible prefer to use `QuadCommand` objects since the renderer will au class CC_DLL Renderer { public: - static const int VBO_SIZE = 65536 / 6; + static const int VBO_SIZE = 8192; + static const int INDEX_VBO_SIZE = 8192 * 6 / 4; + static const int BATCH_QUADCOMMAND_RESEVER_SIZE = 64; Renderer(); @@ -142,7 +145,6 @@ public: protected: - void setupIndices(); //Setup VBO or VAO based on OpenGL extensions void setupBuffer(); void setupVBOAndVAO(); @@ -162,7 +164,7 @@ protected: void visitTransparentRenderQueue(const TransparentRenderQueue& queue); - void convertToWorldCoordinates(V3F_C4B_T2F_Quad* quads, ssize_t quantity, const Mat4& modelView); + void fillVerticesAndIndices(const TrianglesCommand* cmd); std::stack _commandGroupStack; @@ -172,14 +174,15 @@ protected: uint32_t _lastMaterialID; MeshCommand* _lastBatchedMeshCommand; - std::vector _batchedQuadCommands; + std::vector _batchedCommands; - V3F_C4B_T2F_Quad _quads[VBO_SIZE]; - GLushort _indices[6 * VBO_SIZE]; + V3F_C4B_T2F _verts[VBO_SIZE]; + GLushort _indices[INDEX_VBO_SIZE]; GLuint _quadVAO; GLuint _buffersVBO[2]; //0: vertex 1: indices - int _numQuads; + int _filledVertex; + int _filledIndex; bool _glViewAssigned; diff --git a/cocos/renderer/CCTrianglesCommand.cpp b/cocos/renderer/CCTrianglesCommand.cpp new file mode 100644 index 0000000000..8f46ef9c6a --- /dev/null +++ b/cocos/renderer/CCTrianglesCommand.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + 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 "renderer/CCTrianglesCommand.h" +#include "renderer/ccGLStateCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCGLProgramState.h" +#include "xxhash.h" +#include "renderer/CCRenderer.h" + +NS_CC_BEGIN + +TrianglesCommand::TrianglesCommand() +:_materialID(0) +,_textureID(0) +,_glProgramState(nullptr) +,_blendType(BlendFunc::DISABLE) +{ + _type = RenderCommand::Type::TRIANGLES_COMMAND; +} + +void TrianglesCommand::init(float globalOrder, GLuint textureID, GLProgramState* glProgramState, BlendFunc blendType, const Triangles& triangles,const Mat4& mv) +{ + CCASSERT(glProgramState, "Invalid GLProgramState"); + CCASSERT(glProgramState->getVertexAttribsFlags() == 0, "No custom attributes are supported in QuadCommand"); + + _globalOrder = globalOrder; + + _triangles = triangles; + if(_triangles.indexCount % 3 != 0) + { + ssize_t count = _triangles.indexCount; + _triangles.indexCount = count / 3 * 3; + CCLOGERROR("Resize indexCount from %zd to %zd, size must be multiple times of 3", count, _triangles.indexCount); + } + _mv = mv; + + if( _textureID != textureID || _blendType.src != blendType.src || _blendType.dst != blendType.dst || _glProgramState != glProgramState) { + + _textureID = textureID; + _blendType = blendType; + _glProgramState = glProgramState; + + generateMaterialID(); + } +} + +TrianglesCommand::~TrianglesCommand() +{ +} + +void TrianglesCommand::generateMaterialID() +{ + + if(_glProgramState->getUniformCount() > 0) + { + _materialID = TrianglesCommand::MATERIAL_ID_DO_NOT_BATCH; + } + else + { + int glProgram = (int)_glProgramState->getGLProgram()->getProgram(); + int intArray[4] = { glProgram, (int)_textureID, (int)_blendType.src, (int)_blendType.dst}; + + _materialID = XXH32((const void*)intArray, sizeof(intArray), 0); + } +} + +void TrianglesCommand::useMaterial() const +{ + //Set texture + GL::bindTexture2D(_textureID); + + //set blend mode + GL::blendFunc(_blendType.src, _blendType.dst); + + _glProgramState->apply(_mv); +} + +NS_CC_END diff --git a/cocos/renderer/CCTrianglesCommand.h b/cocos/renderer/CCTrianglesCommand.h new file mode 100644 index 0000000000..71cd1cca25 --- /dev/null +++ b/cocos/renderer/CCTrianglesCommand.h @@ -0,0 +1,79 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + 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_TRIANGLES_COMMAND__ +#define __CC_TRIANGLES_COMMAND__ + +#include "renderer/CCRenderCommand.h" +#include "renderer/CCGLProgramState.h" + +NS_CC_BEGIN +class CC_DLL TrianglesCommand : public RenderCommand +{ +public: + static const int MATERIAL_ID_DO_NOT_BATCH = 0; + +public: + struct Triangles + { + V3F_C4B_T2F* verts; + unsigned short* indices; + ssize_t vertCount; + ssize_t indexCount; + }; + + TrianglesCommand(); + ~TrianglesCommand(); + + /** Initializes the command with a globalZOrder, a texture ID, a `GLProgram`, a blending function, a pointer to triangles, + * quantity of quads, and the Model View transform to be used for the quads */ + void init(float globalOrder, GLuint textureID, GLProgramState* glProgramState, BlendFunc blendType, const Triangles& triangles,const Mat4& mv); + + void useMaterial() const; + + inline uint32_t getMaterialID() const { return _materialID; } + inline GLuint getTextureID() const { return _textureID; } + inline const Triangles& getTriangles() const { return _triangles; } + inline ssize_t getVertexCount() const { return _triangles.vertCount; } + inline ssize_t getIndexCount() const { return _triangles.indexCount; } + inline const V3F_C4B_T2F* getVertices() const { return _triangles.verts; } + inline const unsigned short* getIndices() const { return _triangles.indices; } + inline GLProgramState* getGLProgramState() const { return _glProgramState; } + inline BlendFunc getBlendType() const { return _blendType; } + inline const Mat4& getModelView() const { return _mv; } + +protected: + void generateMaterialID(); + + uint32_t _materialID; + GLuint _textureID; + GLProgramState* _glProgramState; + BlendFunc _blendType; + Triangles _triangles; + Mat4 _mv; +}; + +NS_CC_END + +#endif // defined(__CC_TRIANGLES_COMMAND__) diff --git a/cocos/scripting/lua-bindings/manual/cocostudio/CustomGUIReader.cpp b/cocos/scripting/lua-bindings/manual/cocostudio/CustomGUIReader.cpp new file mode 100644 index 0000000000..fa0bcb1832 --- /dev/null +++ b/cocos/scripting/lua-bindings/manual/cocostudio/CustomGUIReader.cpp @@ -0,0 +1,87 @@ +#include "CustomGUIReader.h" +#include "CCLuaEngine.h" +#include "base/ObjectFactory.h" +#include "json/document.h" +#include "json/writer.h" +#include "json/stringbuffer.h" + +USING_NS_CC; + +namespace cocostudio +{ + + CustomGUIReader* CustomGUIReader::create(std::string &className, int createFunc, int setPropsFunc) + { + auto reader = new CustomGUIReader(); + reader->init(className, createFunc, setPropsFunc); + return reader; + } + + Ref* CustomGUIReader::createInstance() + { + Ref* result = nullptr; + LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); + stack->executeFunction(_createFunc, 0, 1, [&result](lua_State* L,int numReturn){ + result = static_cast(tolua_tousertype(L, -1, nullptr)); + lua_pop(L, 1); + }); + return result; + } + + CustomGUIReader::CustomGUIReader() + :_className() + ,_createFunc(0) + ,_setPropsFunc(0) + { + + } + + CustomGUIReader::~CustomGUIReader() + { + if (_createFunc) + { + LuaEngine::getInstance()->removeScriptHandler(_createFunc); + _createFunc = 0; + } + if (_setPropsFunc) + { + LuaEngine::getInstance()->removeScriptHandler(_setPropsFunc); + _setPropsFunc = 0; + } + } + + void CustomGUIReader::init(std::string &className, int createFunc, int setPropsFunc) + { + _className = className; + _createFunc = createFunc; + _setPropsFunc = setPropsFunc; + + ObjectFactory* factoryCreate = ObjectFactory::getInstance(); + ObjectFactory::TInfo t; + t._class = className; + t._func = CC_CALLBACK_0(CustomGUIReader::createInstance, this); + factoryCreate->registerType(t); + + auto guiReader = GUIReader::getInstance(); + auto objMap = guiReader->getParseObjectMap(); + (*objMap)[className] = this; + auto callbackMap = guiReader->getParseCallBackMap(); + (*callbackMap)[className] = parseselector(CustomGUIReader::setCustomProps); + } + + void CustomGUIReader::setCustomProps(const std::string &classType, cocos2d::Ref *widget, const rapidjson::Value &customOptions) + { + if (_setPropsFunc != 0) + { + rapidjson::StringBuffer buffer; + rapidjson::Writer writer(buffer); + customOptions.Accept(writer); + + auto stack = LuaEngine::getInstance()->getLuaStack(); + stack->pushString(classType.c_str(), classType.size()); + stack->pushObject(widget, "cc.Ref"); + stack->pushString(buffer.GetString(), buffer.Size()); + stack->executeFunctionByHandler(_setPropsFunc, 3); + } + } +} diff --git a/cocos/scripting/lua-bindings/manual/cocostudio/CustomGUIReader.h b/cocos/scripting/lua-bindings/manual/cocostudio/CustomGUIReader.h new file mode 100644 index 0000000000..b82ddd65aa --- /dev/null +++ b/cocos/scripting/lua-bindings/manual/cocostudio/CustomGUIReader.h @@ -0,0 +1,34 @@ +#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_CUSTOM_GUI_READER_H +#define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_CUSTOM_GUI_READER_H + +#include "cocostudio/WidgetReader/WidgetReader.h" + +USING_NS_CC; + +namespace cocostudio +{ + class CustomGUIReader : public Ref + { + public: + + CustomGUIReader(); + virtual ~CustomGUIReader(); + + static CustomGUIReader* create(std::string &className, int createFunc, int setPropsFunc); + + void init(std::string &className, int createFunc, int setPropsFunc); + + Ref* createInstance(); + + void setCustomProps(const std::string &classType, cocos2d::Ref *widget, const rapidjson::Value &customOptions); + + private: + std::string _className; + int _createFunc; + int _setPropsFunc; + }; +} + + + +#endif diff --git a/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp index a8bca1e5dc..eabfb21ac0 100644 --- a/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp @@ -30,6 +30,7 @@ #include "CCLuaValue.h" #include "CocoStudio.h" #include "CCLuaEngine.h" +#include "CustomGUIReader.h" using namespace cocostudio; @@ -554,6 +555,53 @@ static void extendActionTimeline(lua_State* L) lua_pop(L, 1); } +int lua_cocos2dx_CustomGUIReader_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"ccs.CustomGUIReader",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S)-1; + + do + { + if (argc == 3) + { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccs.CustomGUIReader:create"); + if (!ok) { break; } +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,3,"LUA_FUNCTION",0,&tolua_err)) { + goto tolua_lerror; + } +#endif + LUA_FUNCTION arg1 = toluafix_ref_function(tolua_S,3,0); +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,4,"LUA_FUNCTION",0,&tolua_err)) { + goto tolua_lerror; + } +#endif + LUA_FUNCTION arg2 = toluafix_ref_function(tolua_S,4,0); + + cocostudio::CustomGUIReader* ret = cocostudio::CustomGUIReader::create(arg0, arg1, arg2); + object_to_luaval(tolua_S, "ccs.CustomGUIReader",(cocostudio::CustomGUIReader*)ret); + return 1; + } + } while (0); + CCLOG("%s has wrong number of arguments: %d, was expecting %d", "ccs.CustomGUIReader:create",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CustomGUIReader_create'.",&tolua_err); +#endif + return 0; +} int register_all_cocos2dx_coco_studio_manual(lua_State* L) { @@ -569,6 +617,26 @@ int register_all_cocos2dx_coco_studio_manual(lua_State* L) return 0; } +int lua_register_cocos2dx_coco_studio_CustomGUIReader(lua_State* tolua_S) +{ + tolua_module(tolua_S,"ccs",0); + tolua_beginmodule(tolua_S,"ccs"); + + + tolua_usertype(tolua_S,"ccs.CustomGUIReader"); + tolua_cclass(tolua_S,"CustomGUIReader","ccs.CustomGUIReader","cc.Ref",nullptr); + + tolua_beginmodule(tolua_S,"CustomGUIReader"); + tolua_function(tolua_S,"create",lua_cocos2dx_CustomGUIReader_create); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocostudio::CustomGUIReader).name(); + g_luaType[typeName] = "ccs.CustomGUIReader"; + g_typeCast["CustomGUIReader"] = "ccs.CustomGUIReader"; + + tolua_endmodule(tolua_S); + return 1; +} + int register_cocostudio_module(lua_State* L) { lua_getglobal(L, "_G"); @@ -576,6 +644,7 @@ int register_cocostudio_module(lua_State* L) { register_all_cocos2dx_studio(L); register_all_cocos2dx_coco_studio_manual(L); + lua_register_cocos2dx_coco_studio_CustomGUIReader(L); } lua_pop(L, 1); diff --git a/cocos/scripting/lua-bindings/proj.android/Android.mk b/cocos/scripting/lua-bindings/proj.android/Android.mk index c61e2b6ae3..cee7f1fd53 100644 --- a/cocos/scripting/lua-bindings/proj.android/Android.mk +++ b/cocos/scripting/lua-bindings/proj.android/Android.mk @@ -66,6 +66,7 @@ LOCAL_SRC_FILES += ../manual/cocosbuilder/lua_cocos2dx_cocosbuilder_manual.cpp \ #cocostudio LOCAL_SRC_FILES += ../manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp \ + ../manual/cocostudio/CustomGUIReader.cpp \ ../auto/lua_cocos2dx_studio_auto.cpp #spine 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 36cecee16a..260b98b268 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 @@ -236,6 +236,10 @@ 15EFA64E198B3342000C57D3 /* lua.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ABCA1E718CD8F470087CE3A /* lua.h */; }; 15EFA64F198B3342000C57D3 /* luaconf.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ABCA1E818CD8F470087CE3A /* luaconf.h */; }; 15EFA650198B3342000C57D3 /* lualib.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ABCA1E918CD8F470087CE3A /* lualib.h */; }; + 566F015F19B5EB0F00FCA620 /* CustomGUIReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 566F015D19B5EB0F00FCA620 /* CustomGUIReader.cpp */; }; + 566F016019B5EB0F00FCA620 /* CustomGUIReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 566F015D19B5EB0F00FCA620 /* CustomGUIReader.cpp */; }; + 566F016119B5EB0F00FCA620 /* CustomGUIReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 566F015E19B5EB0F00FCA620 /* CustomGUIReader.h */; }; + 566F016219B5EB0F00FCA620 /* CustomGUIReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 566F015E19B5EB0F00FCA620 /* CustomGUIReader.h */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -364,6 +368,8 @@ 1ABCA1FF18CD8F6E0087CE3A /* tolua++.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "tolua++.h"; path = "../../../../external/lua/tolua/tolua++.h"; sourceTree = ""; }; 2905FACE18CF12E600240AA3 /* lua_cocos2dx_ui_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_ui_auto.cpp; sourceTree = ""; }; 2905FACF18CF12E600240AA3 /* lua_cocos2dx_ui_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_ui_auto.hpp; sourceTree = ""; }; + 566F015D19B5EB0F00FCA620 /* CustomGUIReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomGUIReader.cpp; sourceTree = ""; }; + 566F015E19B5EB0F00FCA620 /* CustomGUIReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomGUIReader.h; sourceTree = ""; }; C0D9BAFA1974D30000EC35BB /* liblua.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblua.a; path = ../../../../external/lua/lua/prebuilt/ios/liblua.a; sourceTree = ""; }; /* End PBXFileReference section */ @@ -507,6 +513,8 @@ 15EFA400198B2AB2000C57D3 /* cocostudio */ = { isa = PBXGroup; children = ( + 566F015D19B5EB0F00FCA620 /* CustomGUIReader.cpp */, + 566F015E19B5EB0F00FCA620 /* CustomGUIReader.h */, 15EFA401198B2AB2000C57D3 /* lua_cocos2dx_coco_studio_manual.cpp */, 15EFA402198B2AB2000C57D3 /* lua_cocos2dx_coco_studio_manual.hpp */, ); @@ -738,6 +746,7 @@ 15C1C2EE19874CBE00A46ACC /* tolua_fix.h in Headers */, 155C7E2019A71CCC00F08B25 /* LuaSkeletonAnimation.h in Headers */, 15415AB719A71A53004F1E71 /* io.h in Headers */, + 566F016119B5EB0F00FCA620 /* CustomGUIReader.h in Headers */, 15C1C2DC19874B4400A46ACC /* xxtea.h in Headers */, 15415AD319A71A53004F1E71 /* timeout.h in Headers */, 15C1C2D5198749BC00A46ACC /* LuaOpengl.h in Headers */, @@ -798,6 +807,7 @@ 15EFA642198B32BB000C57D3 /* tolua_fix.h in Headers */, 155C7E2119A71CCE00F08B25 /* LuaSkeletonAnimation.h in Headers */, 15415AB819A71A53004F1E71 /* io.h in Headers */, + 566F016219B5EB0F00FCA620 /* CustomGUIReader.h in Headers */, 15EFA62B198B3220000C57D3 /* LuaOpengl.h in Headers */, 15415AD419A71A53004F1E71 /* timeout.h in Headers */, 15EFA62C198B3220000C57D3 /* lua_cocos2dx_deprecated.h in Headers */, @@ -928,6 +938,7 @@ 155C7E1E19A71CC700F08B25 /* LuaSkeletonAnimation.cpp in Sources */, 15415AB519A71A53004F1E71 /* io.c in Sources */, 15C1C2CE1987498B00A46ACC /* LuaOpengl.cpp in Sources */, + 566F015F19B5EB0F00FCA620 /* CustomGUIReader.cpp in Sources */, 15415AC119A71A53004F1E71 /* options.c in Sources */, 155C7E0A19A71C8B00F08B25 /* lua_cocos2dx_network_manual.cpp in Sources */, 15415AD119A71A53004F1E71 /* timeout.c in Sources */, @@ -995,6 +1006,7 @@ 155C7E1F19A71CC800F08B25 /* LuaSkeletonAnimation.cpp in Sources */, 15415ACA19A71A53004F1E71 /* serial.c in Sources */, 155C7DEA19A71BDA00F08B25 /* lua_cocos2dx_3d_auto.cpp in Sources */, + 566F016019B5EB0F00FCA620 /* CustomGUIReader.cpp in Sources */, 155C7DF119A71C2300F08B25 /* lua_cocos2dx_studio_auto.cpp in Sources */, 155C7E0B19A71C8D00F08B25 /* lua_cocos2dx_network_manual.cpp in Sources */, 15415AAE19A71A53004F1E71 /* except.c in Sources */, diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj index e84501f6f1..774b9914ec 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -56,6 +56,7 @@ + @@ -117,6 +118,7 @@ + @@ -208,7 +210,7 @@ v110 v110_xp v120 - v110_xp + v120_xp StaticLibrary @@ -217,7 +219,7 @@ v110 v110_xp v120 - v110_xp + v120_xp diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters index 11d3df728e..1f8c61573d 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters @@ -243,6 +243,9 @@ luasocket + + manual\cocostudio + @@ -422,6 +425,9 @@ luasocket + + manual\cocostudio + diff --git a/cocos/ui/UIEditBox/UIEditBox.cpp b/cocos/ui/UIEditBox/UIEditBox.cpp index 27e4ccc95b..6ef69b9e74 100644 --- a/cocos/ui/UIEditBox/UIEditBox.cpp +++ b/cocos/ui/UIEditBox/UIEditBox.cpp @@ -268,7 +268,7 @@ void EditBox::setPlaceholderFontSize(int fontSize) _placeholderFontSize = fontSize; if (_editBoxImpl != nullptr && _placeholderFontName.length() > 0) { - _editBoxImpl->setPlaceholderFont(_placeholderFontName.c_str(), _fontSize); + _editBoxImpl->setPlaceholderFont(_placeholderFontName.c_str(), fontSize); } } diff --git a/cocos/ui/UIEditBox/UIEditBoxImplIOS.mm b/cocos/ui/UIEditBox/UIEditBoxImplIOS.mm index d78dd0c765..a2456ed125 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImplIOS.mm +++ b/cocos/ui/UIEditBox/UIEditBoxImplIOS.mm @@ -395,8 +395,6 @@ void EditBoxImplIOS::setFont(const char* pFontName, int fontSize) _label->setSystemFontName(pFontName); _label->setSystemFontSize(fontSize); - _labelPlaceHolder->setSystemFontName(pFontName); - _labelPlaceHolder->setSystemFontSize(fontSize); } void EditBoxImplIOS::setFontColor(const Color3B& color) @@ -407,7 +405,8 @@ void EditBoxImplIOS::setFontColor(const Color3B& color) void EditBoxImplIOS::setPlaceholderFont(const char* pFontName, int fontSize) { - // TODO: need to be implemented. + _labelPlaceHolder->setSystemFontName(pFontName); + _labelPlaceHolder->setSystemFontSize(fontSize); } void EditBoxImplIOS::setPlaceholderFontColor(const Color3B& color) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index bd96b210b5..0a6d47fec7 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -642,6 +642,8 @@ "cocos/editor-support/spine/SlotData.h", "cocos/editor-support/spine/extension.cpp", "cocos/editor-support/spine/extension.h", + "cocos/editor-support/spine/proj.win32/libSpine.vcxproj", + "cocos/editor-support/spine/proj.win32/libSpine.vcxproj.filters", "cocos/editor-support/spine/proj.wp8/libSpine.vcxproj", "cocos/editor-support/spine/proj.wp8/libSpine.vcxproj.filters", "cocos/editor-support/spine/proj.wp8/libSpine.vcxproj.user", @@ -948,6 +950,8 @@ "cocos/renderer/CCTextureAtlas.h", "cocos/renderer/CCTextureCache.cpp", "cocos/renderer/CCTextureCache.h", + "cocos/renderer/CCTrianglesCommand.cpp", + "cocos/renderer/CCTrianglesCommand.h", "cocos/renderer/CCVertexIndexBuffer.cpp", "cocos/renderer/CCVertexIndexBuffer.h", "cocos/renderer/CCVertexIndexData.cpp", @@ -4032,6 +4036,8 @@ "cocos/scripting/lua-bindings/manual/cocosbuilder/lua_cocos2dx_cocosbuilder_manual.h", "cocos/scripting/lua-bindings/manual/cocosdenshion/lua_cocos2dx_cocosdenshion_manual.cpp", "cocos/scripting/lua-bindings/manual/cocosdenshion/lua_cocos2dx_cocosdenshion_manual.h", + "cocos/scripting/lua-bindings/manual/cocostudio/CustomGUIReader.cpp", + "cocos/scripting/lua-bindings/manual/cocostudio/CustomGUIReader.h", "cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp", "cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.hpp", "cocos/scripting/lua-bindings/manual/controller/lua_cocos2dx_controller_manual.cpp", diff --git a/tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj b/tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj index 4bc89fa9de..22c42ff781 100644 --- a/tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj +++ b/tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -24,7 +24,7 @@ v110 v110_xp v120 - v110_xp + v120_xp Application @@ -33,7 +33,7 @@ v110 v110_xp v120 - v110_xp + v120_xp diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index dc4bad49dd..2790a989f5 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -73,6 +73,7 @@ static std::function createFunctions[] = CL(NodeGlobalZValueTest), CL(NodeNormalizedPositionTest1), CL(NodeNormalizedPositionTest2), + CL(NodeNormalizedPositionBugTest), CL(NodeNameTest), }; @@ -1227,11 +1228,49 @@ void NodeNormalizedPositionTest2::update(float dt) Size s = Size(_copyContentSize.width*norm, _copyContentSize.height*norm); setContentSize(s); - CCLOG("s: %f,%f", s.width, s.height); } +//------------------------------------------------------------------ +// +// NodeNormalizedPositionBugTest +// +//------------------------------------------------------------------ +NodeNormalizedPositionBugTest::NodeNormalizedPositionBugTest() +: _accum(0) +{ + Vec2 position; + + position = Vec2(0.5,0.5); + + + sprite = Sprite::create("Images/grossini.png"); + sprite->setNormalizedPosition(position); + addChild(sprite); + + scheduleUpdate(); +} + +std::string NodeNormalizedPositionBugTest::title() const +{ + return "NodeNormalizedPositionBugTest"; +} + +std::string NodeNormalizedPositionBugTest::subtitle() const +{ + return "When changing sprite normalizedPosition, the sprite doesn't move!"; +} + +void NodeNormalizedPositionBugTest::update(float dt) +{ + _accum += dt; + + // for 5 seconds + float norm = clampf(sinf(_accum), 0, 1.0); + sprite->setNormalizedPosition(Vec2(norm,norm)); +} + std::string NodeNameTest::title() const { return "getName()/setName()/getChildByName()/enumerateChildren()"; diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.h b/tests/cpp-tests/Classes/NodeTest/NodeTest.h index 068bdb7cfd..a7ab77894b 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.h +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.h @@ -295,6 +295,21 @@ protected: float _accum; }; +class NodeNormalizedPositionBugTest : public TestCocosNodeDemo +{ +public: + CREATE_FUNC(NodeNormalizedPositionBugTest); + virtual std::string title() const override; + virtual std::string subtitle() const override; + +protected: + NodeNormalizedPositionBugTest(); + + void update(float dt); + float _accum; + Sprite *sprite; +}; + class NodeNameTest : public TestCocosNodeDemo { public: diff --git a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj index 40361baa79..d4111e02d1 100644 --- a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj +++ b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -24,7 +24,7 @@ v110 v110_xp v120 - v110_xp + v120_xp Application @@ -33,7 +33,7 @@ v110 v110_xp v120 - v110_xp + v120_xp diff --git a/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj b/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj index 7d24ad16dc..a9dbfd77e9 100644 --- a/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj +++ b/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -22,7 +22,7 @@ v110 v110_xp v120 - v110_xp + v120_xp Application @@ -31,7 +31,7 @@ v110 v110_xp v120 - v110_xp + v120_xp diff --git a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj index f4592847dd..547770c554 100644 --- a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj +++ b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -23,7 +23,7 @@ v110 v110_xp v120 - v110_xp + v120_xp Application @@ -33,7 +33,7 @@ v110 v110_xp v120 - v110_xp + v120_xp diff --git a/tools/tolua/cocos2dx_studio.ini b/tools/tolua/cocos2dx_studio.ini index 32baa60dae..a25e3b67b9 100644 --- a/tools/tolua/cocos2dx_studio.ini +++ b/tools/tolua/cocos2dx_studio.ini @@ -48,7 +48,7 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .* ActionManagerEx::[initWithDictionary initWithBinary], DisplayManager::[initDisplayList (s|g)etCurrentDecorativeDisplay getDecorativeDisplayByIndex], Tween::[(s|g)etMovementBoneData], - GUIReader::[storeFileDesignSize getFileDesignSize getParseCallBackMap getParseObjectMap], + GUIReader::[registerTypeAndCallBack storeFileDesignSize getFileDesignSize getParseCallBackMap getParseObjectMap], ActionNode::[initWithDictionary], ActionObject::[initWithDictionary initWithBinary], BaseData::[copy subtract],