From fb1a7f1e8b11cd26510edaa59c8e481f689a7b04 Mon Sep 17 00:00:00 2001 From: tangziwen Date: Fri, 22 May 2015 09:07:57 +0800 Subject: [PATCH 01/35] fix Terrain::getIntersectionPoint --- cocos/3d/CCTerrain.cpp | 51 ++++++++++++++++++++++++++++++++++++++++-- cocos/3d/CCTerrain.h | 2 ++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp index d8c9b13a4f..6126b625d1 100644 --- a/cocos/3d/CCTerrain.cpp +++ b/cocos/3d/CCTerrain.cpp @@ -327,6 +327,10 @@ float Terrain::getHeight(float x, float z, Vec3 * normal) if(image_x>=_imageWidth-1 || image_y >=_imageHeight-1 || image_x<0 || image_y<0) { return 0; + if (normal) + { + normal->setZero(); + } }else { float a = getImageHeight(i,j)*getScaleY(); @@ -513,12 +517,14 @@ cocos2d::Vec3 Terrain::getIntersectionPoint(const Ray & ray) Vec3 lastRayPosition =rayPos; rayPos += rayStep; // Linear search - Loop until find a point inside and outside the terrain Vector3 - float height = getHeight(rayPos.x,rayPos.z); - + Vec3 normal; + float height = getHeight(rayPos.x, rayPos.z, &normal); while (rayPos.y > height) { lastRayPosition = rayPos; rayPos += rayStep; + if (normal.isZero()) + return Vec3(0, 0, 0); height = getHeight(rayPos.x,rayPos.z); } @@ -538,6 +544,47 @@ cocos2d::Vec3 Terrain::getIntersectionPoint(const Ray & ray) return collisionPoint; } +bool Terrain::getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) +{ + Vec3 dir = ray._direction; + dir.normalize(); + Vec3 rayStep = _terrainData._chunkSize.width*0.25*dir; + Vec3 rayPos = ray._origin; + Vec3 rayStartPosition = ray._origin; + Vec3 lastRayPosition = rayPos; + rayPos += rayStep; + // Linear search - Loop until find a point inside and outside the terrain Vector3 + Vec3 normal; + float height = getHeight(rayPos.x, rayPos.z, &normal); + while (rayPos.y > height) + { + lastRayPosition = rayPos; + rayPos += rayStep; + if (normal.isZero()) + { + intersectionPoint = Vec3(0, 0, 0); + return false; + } + height = getHeight(rayPos.x, rayPos.z); + } + + Vec3 startPosition = lastRayPosition; + Vec3 endPosition = rayPos; + + for (int i = 0; i < 32; i++) + { + // Binary search pass + Vec3 middlePoint = (startPosition + endPosition) * 0.5f; + if (middlePoint.y < height) + endPosition = middlePoint; + else + startPosition = middlePoint; + } + Vec3 collisionPoint = (startPosition + endPosition) * 0.5f; + intersectionPoint = collisionPoint; + return true; +} + void Terrain::setMaxDetailMapAmount(int max_value) { _maxDetailMapValue = max_value; diff --git a/cocos/3d/CCTerrain.h b/cocos/3d/CCTerrain.h index c348ecb22b..4a78781b19 100644 --- a/cocos/3d/CCTerrain.h +++ b/cocos/3d/CCTerrain.h @@ -343,6 +343,8 @@ public: */ Vec3 getIntersectionPoint(const Ray & ray); + bool getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint); + /** * set the MaxDetailAmount. */ From 28b9b86b0b69f4bf539cec1dc9097ac445547c3b Mon Sep 17 00:00:00 2001 From: yangxiao Date: Wed, 27 May 2015 18:07:31 +0800 Subject: [PATCH 02/35] get set gravity --- cocos/physics3d/CCPhysics3DWorld.cpp | 10 ++++++++++ cocos/physics3d/CCPhysics3DWorld.h | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/cocos/physics3d/CCPhysics3DWorld.cpp b/cocos/physics3d/CCPhysics3DWorld.cpp index f3cd4f35d9..5ca5c5ea7b 100644 --- a/cocos/physics3d/CCPhysics3DWorld.cpp +++ b/cocos/physics3d/CCPhysics3DWorld.cpp @@ -67,6 +67,16 @@ Physics3DWorld* Physics3DWorld::create(Physics3DWorldDes* info) return world; } +void Physics3DWorld::setGravity(const Vec3& gravity) +{ + _btPhyiscsWorld->setGravity(convertVec3TobtVector3(gravity)); +} + +Vec3 Physics3DWorld::getGravity() const +{ + return convertbtVector3ToVec3(_btPhyiscsWorld->getGravity()); +} + bool Physics3DWorld::init(Physics3DWorldDes* info) { ///collision configuration contains default setup for memory, collision setup diff --git a/cocos/physics3d/CCPhysics3DWorld.h b/cocos/physics3d/CCPhysics3DWorld.h index b238de3ebf..23c7b601ff 100644 --- a/cocos/physics3d/CCPhysics3DWorld.h +++ b/cocos/physics3d/CCPhysics3DWorld.h @@ -90,6 +90,12 @@ public: */ static Physics3DWorld* create(Physics3DWorldDes* info); + /** set gravity for the physics world */ + void setGravity(const Vec3& gravity); + + /** get current gravity */ + Vec3 getGravity() const; + /** Add a Physics3DObject. */ void addPhysics3DObject(Physics3DObject* physicsObj); From a5976a43f7838c2fd6aa75990762eaccf652f050 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Wed, 27 May 2015 18:19:44 +0800 Subject: [PATCH 03/35] code style --- cocos/3d/CCTerrain.cpp | 14 +++++++------- cocos/3d/CCTerrain.h | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp index 6126b625d1..da4b44ec48 100644 --- a/cocos/3d/CCTerrain.cpp +++ b/cocos/3d/CCTerrain.cpp @@ -297,7 +297,7 @@ void Terrain::setChunksLOD(Vec3 cameraPos) } } -float Terrain::getHeight(float x, float z, Vec3 * normal) +float Terrain::getHeight(float x, float z, Vec3 * normal) const { Vec2 pos(x,z); @@ -326,11 +326,11 @@ float Terrain::getHeight(float x, float z, Vec3 * normal) if(image_x>=_imageWidth-1 || image_y >=_imageHeight-1 || image_x<0 || image_y<0) { - return 0; if (normal) { normal->setZero(); } + return 0; }else { float a = getImageHeight(i,j)*getScaleY(); @@ -350,12 +350,12 @@ float Terrain::getHeight(float x, float z, Vec3 * normal) } } -float Terrain::getHeight(Vec2 pos, Vec3*Normal) +float Terrain::getHeight(Vec2 pos, Vec3*Normal) const { return getHeight(pos.x,pos.y,Normal); } -float Terrain::getImageHeight(int pixel_x,int pixel_y) +float Terrain::getImageHeight(int pixel_x,int pixel_y) const { int byte_stride =1; switch (_heightMapImage->getRenderFormat()) @@ -493,7 +493,7 @@ Terrain::~Terrain() #endif } -cocos2d::Vec3 Terrain::getNormal(int pixel_x, int pixel_y) +cocos2d::Vec3 Terrain::getNormal(int pixel_x, int pixel_y) const { float a = getImageHeight(pixel_x,pixel_y)*getScaleY(); float b = getImageHeight(pixel_x,pixel_y+1)*getScaleY(); @@ -507,7 +507,7 @@ cocos2d::Vec3 Terrain::getNormal(int pixel_x, int pixel_y) return normal; } -cocos2d::Vec3 Terrain::getIntersectionPoint(const Ray & ray) +cocos2d::Vec3 Terrain::getIntersectionPoint(const Ray & ray) const { Vec3 dir = ray._direction; dir.normalize(); @@ -544,7 +544,7 @@ cocos2d::Vec3 Terrain::getIntersectionPoint(const Ray & ray) return collisionPoint; } -bool Terrain::getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) +bool Terrain::getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) const { Vec3 dir = ray._direction; dir.normalize(); diff --git a/cocos/3d/CCTerrain.h b/cocos/3d/CCTerrain.h index 4a78781b19..34245faa9f 100644 --- a/cocos/3d/CCTerrain.h +++ b/cocos/3d/CCTerrain.h @@ -299,22 +299,22 @@ public: * @param normal the specified position's normal vector in terrain . if this argument is NULL or nullptr,Normal calculation shall be skip. * @return the height value of the specified position of the terrain, if the (X,Z) position is out of the terrain bounds,it shall return 0; **/ - float getHeight(float x, float z, Vec3 * normal= nullptr); + float getHeight(float x, float z, Vec3 * normal= nullptr) const; /**get specified position's height mapping to the terrain,use bi-linear interpolation method * @param pos the position (X,Z) * @param normal the specified position's normal vector in terrain . if this argument is NULL or nullptr,Normal calculation shall be skip. * @return the height value of the specified position of the terrain, if the (X,Z) position is out of the terrain bounds,it shall return 0; **/ - float getHeight(Vec2 pos, Vec3*Normal = nullptr); + float getHeight(Vec2 pos, Vec3*Normal = nullptr) const; /**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. **/ - Vec3 getNormal(int pixelX, int pixelY); + Vec3 getNormal(int pixelX, int pixelY) const; /**get height from the raw height filed*/ - float getImageHeight(int pixelX, int pixelY); + float getImageHeight(int pixelX, int pixelY) const; /**show the wireline instead of the surface,Debug Use only. * @Note only support desktop platform **/ @@ -341,9 +341,9 @@ public: * Ray-Terrain intersection. * @return the intersection point */ - Vec3 getIntersectionPoint(const Ray & ray); + Vec3 getIntersectionPoint(const Ray & ray) const; - bool getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint); + bool getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) const; /** * set the MaxDetailAmount. From 2e27bfd6c7cfd1b576a8c34e526e1abd115d00db Mon Sep 17 00:00:00 2001 From: yangxiao Date: Thu, 28 May 2015 12:40:16 +0800 Subject: [PATCH 04/35] add comment --- cocos/3d/CCTerrain.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cocos/3d/CCTerrain.h b/cocos/3d/CCTerrain.h index 34245faa9f..a5a7e3be8d 100644 --- a/cocos/3d/CCTerrain.h +++ b/cocos/3d/CCTerrain.h @@ -343,6 +343,12 @@ public: */ Vec3 getIntersectionPoint(const Ray & ray) const; + /** + * Ray-Terrain intersection. + * @param ray to hit the terrain + * @param intersectionPoint hit point if hitted + * @return true if hit, false otherwise + */ bool getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) const; /** From b430353cd856093d199b81eb1802f00dc701feb4 Mon Sep 17 00:00:00 2001 From: Michael Sotnikov Date: Fri, 29 May 2015 10:17:40 +0300 Subject: [PATCH 05/35] Fixed: #12097 VideoPlayer on Android ignores search paths --- cocos/ui/UIVideoPlayer-android.cpp | 3 ++- cocos/ui/UIVideoPlayer-ios.mm | 10 ++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cocos/ui/UIVideoPlayer-android.cpp b/cocos/ui/UIVideoPlayer-android.cpp index ca588b44b3..66a4a7233e 100644 --- a/cocos/ui/UIVideoPlayer-android.cpp +++ b/cocos/ui/UIVideoPlayer-android.cpp @@ -32,6 +32,7 @@ #include "jni/JniHelper.h" #include "base/CCDirector.h" #include "base/CCEventListenerKeyboard.h" +#include "platform/CCFileUtils.h" //----------------------------------------------------------------------------------------------------------- #define CLASS_NAME "org/cocos2dx/lib/Cocos2dxVideoHelper" @@ -193,7 +194,7 @@ VideoPlayer::~VideoPlayer() void VideoPlayer::setFileName(const std::string& fileName) { - _videoURL = fileName; + _videoURL = FileUtils::getInstance()->fullPathForFilename(fileName); _videoSource = VideoPlayer::Source::FILENAME; setVideoURLJNI(_videoPlayerIndex, (int)Source::FILENAME,_videoURL); } diff --git a/cocos/ui/UIVideoPlayer-ios.mm b/cocos/ui/UIVideoPlayer-ios.mm index 7acba78890..2081422cf4 100644 --- a/cocos/ui/UIVideoPlayer-ios.mm +++ b/cocos/ui/UIVideoPlayer-ios.mm @@ -55,7 +55,6 @@ using namespace cocos2d::experimental::ui; -(void) videoFinished:(NSNotification*) notification; -(void) playStateChange; -+(NSString*) fullPathFromRelativePath:(NSString*) relPath; @end @@ -138,8 +137,7 @@ using namespace cocos2d::experimental::ui; self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming; [self.moviePlayer setContentURL:[NSURL URLWithString:@(videoUrl.c_str())]]; } else { - NSString *path = [UIVideoViewWrapperIos fullPathFromRelativePath:@(videoUrl.c_str())]; - self.moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]] autorelease]; + self.moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:@(videoUrl.c_str())]] autorelease]; self.moviePlayer.movieSourceType = MPMovieSourceTypeFile; } self.moviePlayer.allowsAirPlay = false; @@ -260,10 +258,6 @@ using namespace cocos2d::experimental::ui; } } -+(NSString*) fullPathFromRelativePath:(NSString*) relPath -{ - return [NSString stringWithCString: cocos2d::FileUtils::getInstance()->fullPathForFilename(std::string([relPath UTF8String])).c_str() encoding: [NSString defaultCStringEncoding]]; -} @end //------------------------------------------------------------------------------------------------------------ @@ -293,7 +287,7 @@ VideoPlayer::~VideoPlayer() void VideoPlayer::setFileName(const std::string& fileName) { - _videoURL = fileName; + _videoURL = FileUtils::getInstance()->fullPathForFilename(fileName); _videoSource = VideoPlayer::Source::FILENAME; [((UIVideoViewWrapperIos*)_videoView) setURL:(int)_videoSource :_videoURL]; } From b294dffaa1962133febb5248faefa5e66c423f98 Mon Sep 17 00:00:00 2001 From: "anniruddh.koppal" Date: Wed, 3 Jun 2015 19:50:57 -0700 Subject: [PATCH 06/35] Added ogg support to audio engine. Fixed issues #150 and #151 --- .../libcocos2d_8_1.Windows.vcxproj | 8 +- .../libcocos2d_8_1.WindowsPhone.vcxproj | 8 +- .../winrt_8.1_props/cocos2d_winrt_8.1.props | 4 +- .../cocos2d_winrt_8.1_app.props | 10 + cocos/audio/winrt/AudioCachePlayer.cpp | 41 ++-- cocos/audio/winrt/AudioCachePlayer.h | 1 + cocos/audio/winrt/AudioEngine-winrt.cpp | 3 +- cocos/audio/winrt/AudioSourceReader.cpp | 195 ++++++++++++++---- cocos/audio/winrt/AudioSourceReader.h | 18 ++ 9 files changed, 221 insertions(+), 67 deletions(-) diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj index aa50019dda..b416a13c74 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj @@ -159,7 +159,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\winrt_8.1-specific\OggDecoder\include;$(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) @@ -179,7 +179,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\winrt_8.1-specific\OggDecoder\include;$(EngineRoot)external\winrt_8.1-specific\OggDecoder\include;$(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) @@ -199,7 +199,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\winrt_8.1-specific\OggDecoder\include;$(EngineRoot)external\winrt_8.1-specific\OggDecoder\include;$(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) @@ -219,7 +219,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\winrt_8.1-specific\OggDecoder\include;$(EngineRoot)external\winrt_8.1-specific\OggDecoder\include;$(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj index d6f4970a79..4c5c0b69d3 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj @@ -113,7 +113,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\wp_8.1-specific\OggDecoder\include;$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) @@ -133,7 +133,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\wp_8.1-specific\OggDecoder\include;$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) @@ -153,7 +153,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\wp_8.1-specific\OggDecoder\include;$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) @@ -173,7 +173,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\wp_8.1-specific\OggDecoder\include;$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) 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 3e56e02d37..a8e48dc02c 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 @@ -18,8 +18,8 @@ 4056;4244;4251;4756;4453;28204;4099; - libGLESv2.lib;libEGL.lib;ws2_32.lib;libwebsockets.lib;libcurl.lib;chipmunk.lib;zlib.lib;freetype.lib;sqlite3.lib;d2d1.lib;d3d11.lib;dxgi.lib;windowscodecs.lib;dwrite.lib;dxguid.lib;xaudio2.lib;mfcore.lib;mfplat.lib;mfreadwrite.lib;mfuuid.lib;%(AdditionalDependencies) - $(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\angle\prebuilt\$(Platform);$(EngineRoot)external\curl\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\websockets\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\chipmunk\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\zlib\prebuilt\$(Platform);$(EngineRoot)external\sqlite3\libraries\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\freetype2\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\poly2tri;$(EngineRoot)external\poly2tri\common;$(EngineRoot)external\poly2tri\sweep;%(AdditionalLibraryDirectories); + libogg.lib;libvorbis.lib;libvorbisfile.lib;libGLESv2.lib;libEGL.lib;ws2_32.lib;libwebsockets.lib;libcurl.lib;chipmunk.lib;zlib.lib;freetype.lib;sqlite3.lib;d2d1.lib;d3d11.lib;dxgi.lib;windowscodecs.lib;dwrite.lib;dxguid.lib;xaudio2.lib;mfcore.lib;mfplat.lib;mfreadwrite.lib;mfuuid.lib;%(AdditionalDependencies) + $(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\OggDecoder\prebuilt\$(Platform);$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\angle\prebuilt\$(Platform);$(EngineRoot)external\curl\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\websockets\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\chipmunk\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\zlib\prebuilt\$(Platform);$(EngineRoot)external\sqlite3\libraries\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\freetype2\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\poly2tri;$(EngineRoot)external\poly2tri\common;$(EngineRoot)external\poly2tri\sweep;%(AdditionalLibraryDirectories); /IGNORE:4264 %(AdditionalOptions) diff --git a/cocos/2d/winrt_8.1_props/cocos2d_winrt_8.1_app.props b/cocos/2d/winrt_8.1_props/cocos2d_winrt_8.1_app.props index 56a1e35697..88ce0623ee 100644 --- a/cocos/2d/winrt_8.1_props/cocos2d_winrt_8.1_app.props +++ b/cocos/2d/winrt_8.1_props/cocos2d_winrt_8.1_app.props @@ -6,6 +6,7 @@ $(EngineRoot)external\curl\prebuilt\$(COCOS2D_PLATFORM)\$(Platform)\ $(EngineRoot)external\websockets\prebuilt\$(COCOS2D_PLATFORM)\$(Platform)\ $(EngineRoot)external\sqlite3\libraries\$(COCOS2D_PLATFORM)\$(Platform)\ + $(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\OggDecoder\prebuilt\$(Platform)\ @@ -29,5 +30,14 @@ true + + true + + + true + + + true + \ No newline at end of file diff --git a/cocos/audio/winrt/AudioCachePlayer.cpp b/cocos/audio/winrt/AudioCachePlayer.cpp index 19dab3147c..0be13433dd 100644 --- a/cocos/audio/winrt/AudioCachePlayer.cpp +++ b/cocos/audio/winrt/AudioCachePlayer.cpp @@ -37,6 +37,7 @@ inline void ThrowIfFailed(HRESULT hr) // AudioCache AudioCache::AudioCache() : _isReady(false) + , _retry(false) , _fileFullPath("") , _srcReader(nullptr) , _fileFormat(FileFormat::UNKNOWN) @@ -57,6 +58,10 @@ AudioCache::~AudioCache() void AudioCache::readDataTask() { + if (_isReady) { + return; + } + std::wstring path(_fileFullPath.begin(), _fileFullPath.end()); if (nullptr != _srcReader) { @@ -68,31 +73,34 @@ void AudioCache::readDataTask() { case FileFormat::WAV: _srcReader = new (std::nothrow) WAVReader(); - if (_srcReader && _srcReader->initialize(_fileFullPath)) { - _audInfo._totalAudioBytes = _srcReader->getTotalAudioBytes(); - _audInfo._wfx = _srcReader->getWaveFormatInfo(); - _isReady = true; - invokeCallbacks(); - } break; case FileFormat::OGG: + _srcReader = new (std::nothrow) OGGReader(); break; case FileFormat::MP3: _srcReader = new (std::nothrow) MP3Reader(); - if (_srcReader && _srcReader->initialize(_fileFullPath)) { - _audInfo._totalAudioBytes = _srcReader->getTotalAudioBytes(); - _audInfo._wfx = _srcReader->getWaveFormatInfo(); - _isReady = true; - invokeCallbacks(); - } + break; case FileFormat::UNKNOWN: default: break; } + + if (_srcReader && _srcReader->initialize(_fileFullPath)) { + _audInfo._totalAudioBytes = _srcReader->getTotalAudioBytes(); + _audInfo._wfx = _srcReader->getWaveFormatInfo(); + _isReady = true; + _retry = false; + invokeCallbacks(); + } + + if (!_isReady) { + _retry = true; + log("Failed to read input file: %s.\n", _fileFullPath.c_str()); + } } void AudioCache::addCallback(const std::function &callback) @@ -105,6 +113,10 @@ void AudioCache::addCallback(const std::function &callback) _callbacks.push_back(callback); } _cbMutex.unlock(); + + if (_retry) { + readDataTask(); + } } void AudioCache::invokeCallbacks() @@ -290,6 +302,9 @@ void AudioPlayer::setVolume(float volume) if (FAILED(_xaMasterVoice->SetVolume(volume))) { error(); } + else { + _volume = volume; + } } } @@ -371,7 +386,7 @@ bool AudioPlayer::_play(bool resume) if (_state == AudioPlayerState::PAUSED && !resume || nullptr == _xaSourceVoice) break; - if (FAILED(_xaSourceVoice->Start())) { + if (FAILED(_xaMasterVoice->SetVolume(_volume)) || FAILED(_xaSourceVoice->Start())) { error(); } else { diff --git a/cocos/audio/winrt/AudioCachePlayer.h b/cocos/audio/winrt/AudioCachePlayer.h index f6911f47c6..2439c4d582 100644 --- a/cocos/audio/winrt/AudioCachePlayer.h +++ b/cocos/audio/winrt/AudioCachePlayer.h @@ -65,6 +65,7 @@ private: AudioCache& operator=(const AudioCache&); private: + bool _retry; bool _isReady; AudioInfo _audInfo; std::mutex _cbMutex; diff --git a/cocos/audio/winrt/AudioEngine-winrt.cpp b/cocos/audio/winrt/AudioEngine-winrt.cpp index bb6f1d5ece..22a322171e 100644 --- a/cocos/audio/winrt/AudioEngine-winrt.cpp +++ b/cocos/audio/winrt/AudioEngine-winrt.cpp @@ -160,7 +160,7 @@ int AudioEngineImpl::play2d(const std::string &filePath, bool loop, float volume } else if (ext.compare(".ogg") == 0){ audioCache->_fileFormat = FileFormat::OGG; - //eraseCache = false; //TODO add support for OGG + eraseCache = false; } else if (ext.compare(".mp3") == 0){ audioCache->_fileFormat = FileFormat::MP3; @@ -168,7 +168,6 @@ int AudioEngineImpl::play2d(const std::string &filePath, bool loop, float volume } else{ log("unsupported media type:%s\n", ext.c_str()); - eraseCache = false; } if (eraseCache){ diff --git a/cocos/audio/winrt/AudioSourceReader.cpp b/cocos/audio/winrt/AudioSourceReader.cpp index dcca1804f1..4c64b09578 100644 --- a/cocos/audio/winrt/AudioSourceReader.cpp +++ b/cocos/audio/winrt/AudioSourceReader.cpp @@ -53,6 +53,24 @@ void AudioSourceReader::flushChunks() _rwMutex.unlock(); } +void AudioSourceReader::seekTo(const float ratio) +{ + if (_isStreaming) { + auto newPos = ratio * _audioSize; + + if (!newPos && !_isDirty && _chnkQ.size()) // already in 0.0 position + return; + + _bytesRead = newPos; + flushChunks(); + auto alignment = _wfx.nChannels * _wfx.nBlockAlign; + _bytesRead = _bytesRead >= _audioSize ? (_audioSize - alignment) : _bytesRead - (_bytesRead % alignment); + + for (int i = 0; i < QUEUEBUFFER_NUM; i++) { + produceChunk(); + } + } +} // WAVFileReader WAVReader::WAVReader() : @@ -78,10 +96,8 @@ bool WAVReader::initialize(const std::string& filePath) flushChunks(); - _rwMutex.lock(); _streamer = ref new MediaStreamer; _streamer->Initialize(std::wstring(_filePath.begin(), _filePath.end()).c_str(), true); - _rwMutex.unlock(); _wfx = _streamer->GetOutputWaveFormatEx(); UINT32 dataSize = _streamer->GetMaxStreamLengthInBytes(); @@ -162,31 +178,7 @@ void WAVReader::produceChunk() void WAVReader::seekTo(const float ratio) { - if (_isStreaming) { - auto newPos = ratio * _audioSize; - - if (!newPos && !_isDirty && _chnkQ.size()) // already in 0.0 position - return; - - _bytesRead = newPos; - flushChunks(); - - switch (_wfx.wFormatTag) - { - case WAVE_FORMAT_PCM: - case WAVE_FORMAT_ADPCM: { - auto alignment = _wfx.nChannels * _wfx.nBlockAlign; - _bytesRead = _bytesRead >= _audioSize ? (_audioSize - alignment) : _bytesRead - (_bytesRead % alignment); - } break; - - default: - break; - } - - for (int i = 0; i < QUEUEBUFFER_NUM; i++) { - produceChunk(); - } - } + AudioSourceReader::seekTo(ratio); } @@ -299,21 +291,7 @@ void MP3Reader::produceChunk() void MP3Reader::seekTo(const float ratio) { - if (_isStreaming) { - auto newPos = ratio * _audioSize; - - if (!newPos && !_isDirty && _chnkQ.size()) // already in 0.0 position - return; - - _bytesRead = newPos; - flushChunks(); - auto alignment = _wfx.nChannels * _wfx.nBlockAlign; - _bytesRead = _bytesRead >= _audioSize ? (_audioSize - alignment) : _bytesRead - (_bytesRead % alignment); - - for (int i = 0; i < QUEUEBUFFER_NUM; i++) { - produceChunk(); - } - } + AudioSourceReader::seekTo(ratio); } HRESULT MP3Reader::configureSourceReader(IMFSourceReader* pReader, IMFMediaType** ppDecomprsdAudioType) @@ -520,4 +498,137 @@ Wrappers::FileHandle MP3Reader::openFile(const std::string& path, bool append) return Microsoft::WRL::Wrappers::FileHandle(CreateFile2(std::wstring(path.begin(), path.end()).c_str(), access, FILE_SHARE_READ, creation, &extParams)); } + +// OGGReader +OGGReader::OGGReader() +{ +} + +OGGReader::~OGGReader() +{ + if (_vorbisFd) { + ov_clear(_vorbisFd.get()); + } +} + +bool OGGReader::initialize(const std::string& filePath) +{ + bool ret = false; + _filePath = filePath; + + do { + _vorbisFd = std::make_unique(); + if (ov_fopen(FileUtils::getInstance()->getSuitableFOpen(_filePath).c_str(), _vorbisFd.get())){ + break; + } + + auto vi = ov_info(_vorbisFd.get(), -1); + + if (!vi) { + break; + } + + auto totalFrames = ov_pcm_total(_vorbisFd.get(), -1); + auto bytesPerFrame = vi->channels * 2; + _audioSize = totalFrames * bytesPerFrame; + + _wfx.wFormatTag = WAVE_FORMAT_PCM; + _wfx.nChannels = vi->channels; + _wfx.nSamplesPerSec = vi->rate; + _wfx.nAvgBytesPerSec = vi->rate * bytesPerFrame; + _wfx.nBlockAlign = bytesPerFrame; + _wfx.wBitsPerSample = (bytesPerFrame / vi->channels) * 8; + _wfx.cbSize = 0; + + if (_audioSize <= PCMDATA_CACHEMAXSIZE) { + produceChunk(); + } + else { + _isStreaming = true; + for (int i = 0; i < QUEUEBUFFER_NUM; i++) { + produceChunk(); + } + } + + ret = true; + } while (false); + + return ret; +} + +bool OGGReader::consumeChunk(AudioDataChunk& chunk) +{ + bool ret = false; + _isDirty = true; + + _rwMutex.lock(); + if (_chnkQ.size() > 0) { + chunk = _chnkQ.front(); + if (_isStreaming) { + _chnkQ.pop(); + } + ret = true; + } + _rwMutex.unlock(); + + return ret; +} + +void OGGReader::produceChunk() +{ + _rwMutex.lock(); + int chunkSize = _audioSize; + + do { + if (!_isStreaming && _chnkQ.size() || _chnkQ.size() >= QUEUEBUFFER_NUM) { + break; + } + + if (_isStreaming) { + chunkSize = std::min(CHUNK_SIZE_MAX, _audioSize - _bytesRead); + } + + if (!chunkSize && !_chnkQ.size()) { + auto alignment = _wfx.nChannels * _wfx.nBlockAlign; + _bytesRead -= alignment; + chunkSize = alignment; + } + + if (!chunkSize) { + break; + } + + int retSize = 0; + AudioDataChunk chunk = { 0 }; + chunk._data = std::make_shared(chunkSize); + + auto newPos = (1.0f * _bytesRead / _audioSize) * ov_time_total(_vorbisFd.get(), -1); + if (ov_time_seek(_vorbisFd.get(), newPos)){ + break; + } + + do + { + long br = 0; + int current_section = 0; + if ((br = ov_read(_vorbisFd.get(), (char*)chunk._data->data() + retSize, chunkSize - retSize, 0, 2, 1, ¤t_section)) == 0) { + break; + } + retSize += br; + } while (retSize < chunkSize); + + _bytesRead += retSize; + chunk._dataSize = retSize; + chunk._seqNo = ((float)_bytesRead / _audioSize) * ((float)_audioSize / CHUNK_SIZE_MAX); + chunk._endOfStream = (_bytesRead >= _audioSize); + _chnkQ.push(chunk); + } while (false); + _rwMutex.unlock(); +} + +void OGGReader::seekTo(const float ratio) +{ + AudioSourceReader::seekTo(ratio); +} + #endif diff --git a/cocos/audio/winrt/AudioSourceReader.h b/cocos/audio/winrt/AudioSourceReader.h index e6d5f37a05..d835d22cf8 100644 --- a/cocos/audio/winrt/AudioSourceReader.h +++ b/cocos/audio/winrt/AudioSourceReader.h @@ -30,6 +30,8 @@ #include #include #include "MediaStreamer.h" +#include "ogg/ogg.h" +#include "vorbis/vorbisfile.h" NS_CC_BEGIN namespace experimental{ @@ -132,6 +134,22 @@ class MP3Reader : public AudioSourceReader std::string _mappedWavFile; }; +class OGGReader : public AudioSourceReader +{ +public: + OGGReader(); + virtual ~OGGReader(); + + virtual bool initialize(const std::string& filePath) override; + virtual FileFormat getFileFormat() override { return FileFormat::WAV; } + virtual bool consumeChunk(AudioDataChunk& chunk) override; + virtual void produceChunk() override; + virtual void seekTo(const float ratio) override; + +private: + std::unique_ptr _vorbisFd; +}; + } NS_CC_END #endif // __AUDIO_SOURCE_READER_H_ From 84fad34daffc17fed1e1e0f9a6024008ec78f40c Mon Sep 17 00:00:00 2001 From: "anniruddh.koppal" Date: Wed, 3 Jun 2015 19:50:57 -0700 Subject: [PATCH 07/35] Added ogg support to audio engine. Fixed issues #150 and #151 --- .../libcocos2d_8_1.Windows.vcxproj | 8 +- .../libcocos2d_8_1.WindowsPhone.vcxproj | 8 +- .../winrt_8.1_props/cocos2d_winrt_8.1.props | 4 +- .../cocos2d_winrt_8.1_app.props | 10 + cocos/audio/winrt/AudioCachePlayer.cpp | 41 ++-- cocos/audio/winrt/AudioCachePlayer.h | 1 + cocos/audio/winrt/AudioEngine-winrt.cpp | 3 +- cocos/audio/winrt/AudioSourceReader.cpp | 195 ++++++++++++++---- cocos/audio/winrt/AudioSourceReader.h | 18 ++ 9 files changed, 221 insertions(+), 67 deletions(-) diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj index 44d407fdb5..804753da1f 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj @@ -159,7 +159,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\winrt_8.1-specific\OggDecoder\include;$(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) @@ -180,7 +180,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\winrt_8.1-specific\OggDecoder\include;$(EngineRoot)external\winrt_8.1-specific\OggDecoder\include;$(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) @@ -200,7 +200,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\winrt_8.1-specific\OggDecoder\include;$(EngineRoot)external\winrt_8.1-specific\OggDecoder\include;$(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) @@ -221,7 +221,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\winrt_8.1-specific\OggDecoder\include;$(EngineRoot)external\winrt_8.1-specific\OggDecoder\include;$(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj index 36626d492a..205e35193e 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj @@ -113,7 +113,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\wp_8.1-specific\OggDecoder\include;$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) @@ -134,7 +134,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\wp_8.1-specific\OggDecoder\include;$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) @@ -154,7 +154,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\wp_8.1-specific\OggDecoder\include;$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) @@ -175,7 +175,7 @@ true /Zm384 /bigobj %(AdditionalOptions) pch.h - $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\wp_8.1-specific\OggDecoder\include;$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) false %(DisableSpecificWarnings) 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 3e56e02d37..a8e48dc02c 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 @@ -18,8 +18,8 @@ 4056;4244;4251;4756;4453;28204;4099; - libGLESv2.lib;libEGL.lib;ws2_32.lib;libwebsockets.lib;libcurl.lib;chipmunk.lib;zlib.lib;freetype.lib;sqlite3.lib;d2d1.lib;d3d11.lib;dxgi.lib;windowscodecs.lib;dwrite.lib;dxguid.lib;xaudio2.lib;mfcore.lib;mfplat.lib;mfreadwrite.lib;mfuuid.lib;%(AdditionalDependencies) - $(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\angle\prebuilt\$(Platform);$(EngineRoot)external\curl\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\websockets\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\chipmunk\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\zlib\prebuilt\$(Platform);$(EngineRoot)external\sqlite3\libraries\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\freetype2\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\poly2tri;$(EngineRoot)external\poly2tri\common;$(EngineRoot)external\poly2tri\sweep;%(AdditionalLibraryDirectories); + libogg.lib;libvorbis.lib;libvorbisfile.lib;libGLESv2.lib;libEGL.lib;ws2_32.lib;libwebsockets.lib;libcurl.lib;chipmunk.lib;zlib.lib;freetype.lib;sqlite3.lib;d2d1.lib;d3d11.lib;dxgi.lib;windowscodecs.lib;dwrite.lib;dxguid.lib;xaudio2.lib;mfcore.lib;mfplat.lib;mfreadwrite.lib;mfuuid.lib;%(AdditionalDependencies) + $(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\OggDecoder\prebuilt\$(Platform);$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\angle\prebuilt\$(Platform);$(EngineRoot)external\curl\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\websockets\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\chipmunk\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\zlib\prebuilt\$(Platform);$(EngineRoot)external\sqlite3\libraries\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\freetype2\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\poly2tri;$(EngineRoot)external\poly2tri\common;$(EngineRoot)external\poly2tri\sweep;%(AdditionalLibraryDirectories); /IGNORE:4264 %(AdditionalOptions) diff --git a/cocos/2d/winrt_8.1_props/cocos2d_winrt_8.1_app.props b/cocos/2d/winrt_8.1_props/cocos2d_winrt_8.1_app.props index 56a1e35697..88ce0623ee 100644 --- a/cocos/2d/winrt_8.1_props/cocos2d_winrt_8.1_app.props +++ b/cocos/2d/winrt_8.1_props/cocos2d_winrt_8.1_app.props @@ -6,6 +6,7 @@ $(EngineRoot)external\curl\prebuilt\$(COCOS2D_PLATFORM)\$(Platform)\ $(EngineRoot)external\websockets\prebuilt\$(COCOS2D_PLATFORM)\$(Platform)\ $(EngineRoot)external\sqlite3\libraries\$(COCOS2D_PLATFORM)\$(Platform)\ + $(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\OggDecoder\prebuilt\$(Platform)\ @@ -29,5 +30,14 @@ true + + true + + + true + + + true + \ No newline at end of file diff --git a/cocos/audio/winrt/AudioCachePlayer.cpp b/cocos/audio/winrt/AudioCachePlayer.cpp index 19dab3147c..0be13433dd 100644 --- a/cocos/audio/winrt/AudioCachePlayer.cpp +++ b/cocos/audio/winrt/AudioCachePlayer.cpp @@ -37,6 +37,7 @@ inline void ThrowIfFailed(HRESULT hr) // AudioCache AudioCache::AudioCache() : _isReady(false) + , _retry(false) , _fileFullPath("") , _srcReader(nullptr) , _fileFormat(FileFormat::UNKNOWN) @@ -57,6 +58,10 @@ AudioCache::~AudioCache() void AudioCache::readDataTask() { + if (_isReady) { + return; + } + std::wstring path(_fileFullPath.begin(), _fileFullPath.end()); if (nullptr != _srcReader) { @@ -68,31 +73,34 @@ void AudioCache::readDataTask() { case FileFormat::WAV: _srcReader = new (std::nothrow) WAVReader(); - if (_srcReader && _srcReader->initialize(_fileFullPath)) { - _audInfo._totalAudioBytes = _srcReader->getTotalAudioBytes(); - _audInfo._wfx = _srcReader->getWaveFormatInfo(); - _isReady = true; - invokeCallbacks(); - } break; case FileFormat::OGG: + _srcReader = new (std::nothrow) OGGReader(); break; case FileFormat::MP3: _srcReader = new (std::nothrow) MP3Reader(); - if (_srcReader && _srcReader->initialize(_fileFullPath)) { - _audInfo._totalAudioBytes = _srcReader->getTotalAudioBytes(); - _audInfo._wfx = _srcReader->getWaveFormatInfo(); - _isReady = true; - invokeCallbacks(); - } + break; case FileFormat::UNKNOWN: default: break; } + + if (_srcReader && _srcReader->initialize(_fileFullPath)) { + _audInfo._totalAudioBytes = _srcReader->getTotalAudioBytes(); + _audInfo._wfx = _srcReader->getWaveFormatInfo(); + _isReady = true; + _retry = false; + invokeCallbacks(); + } + + if (!_isReady) { + _retry = true; + log("Failed to read input file: %s.\n", _fileFullPath.c_str()); + } } void AudioCache::addCallback(const std::function &callback) @@ -105,6 +113,10 @@ void AudioCache::addCallback(const std::function &callback) _callbacks.push_back(callback); } _cbMutex.unlock(); + + if (_retry) { + readDataTask(); + } } void AudioCache::invokeCallbacks() @@ -290,6 +302,9 @@ void AudioPlayer::setVolume(float volume) if (FAILED(_xaMasterVoice->SetVolume(volume))) { error(); } + else { + _volume = volume; + } } } @@ -371,7 +386,7 @@ bool AudioPlayer::_play(bool resume) if (_state == AudioPlayerState::PAUSED && !resume || nullptr == _xaSourceVoice) break; - if (FAILED(_xaSourceVoice->Start())) { + if (FAILED(_xaMasterVoice->SetVolume(_volume)) || FAILED(_xaSourceVoice->Start())) { error(); } else { diff --git a/cocos/audio/winrt/AudioCachePlayer.h b/cocos/audio/winrt/AudioCachePlayer.h index f6911f47c6..2439c4d582 100644 --- a/cocos/audio/winrt/AudioCachePlayer.h +++ b/cocos/audio/winrt/AudioCachePlayer.h @@ -65,6 +65,7 @@ private: AudioCache& operator=(const AudioCache&); private: + bool _retry; bool _isReady; AudioInfo _audInfo; std::mutex _cbMutex; diff --git a/cocos/audio/winrt/AudioEngine-winrt.cpp b/cocos/audio/winrt/AudioEngine-winrt.cpp index bb6f1d5ece..22a322171e 100644 --- a/cocos/audio/winrt/AudioEngine-winrt.cpp +++ b/cocos/audio/winrt/AudioEngine-winrt.cpp @@ -160,7 +160,7 @@ int AudioEngineImpl::play2d(const std::string &filePath, bool loop, float volume } else if (ext.compare(".ogg") == 0){ audioCache->_fileFormat = FileFormat::OGG; - //eraseCache = false; //TODO add support for OGG + eraseCache = false; } else if (ext.compare(".mp3") == 0){ audioCache->_fileFormat = FileFormat::MP3; @@ -168,7 +168,6 @@ int AudioEngineImpl::play2d(const std::string &filePath, bool loop, float volume } else{ log("unsupported media type:%s\n", ext.c_str()); - eraseCache = false; } if (eraseCache){ diff --git a/cocos/audio/winrt/AudioSourceReader.cpp b/cocos/audio/winrt/AudioSourceReader.cpp index dcca1804f1..4c64b09578 100644 --- a/cocos/audio/winrt/AudioSourceReader.cpp +++ b/cocos/audio/winrt/AudioSourceReader.cpp @@ -53,6 +53,24 @@ void AudioSourceReader::flushChunks() _rwMutex.unlock(); } +void AudioSourceReader::seekTo(const float ratio) +{ + if (_isStreaming) { + auto newPos = ratio * _audioSize; + + if (!newPos && !_isDirty && _chnkQ.size()) // already in 0.0 position + return; + + _bytesRead = newPos; + flushChunks(); + auto alignment = _wfx.nChannels * _wfx.nBlockAlign; + _bytesRead = _bytesRead >= _audioSize ? (_audioSize - alignment) : _bytesRead - (_bytesRead % alignment); + + for (int i = 0; i < QUEUEBUFFER_NUM; i++) { + produceChunk(); + } + } +} // WAVFileReader WAVReader::WAVReader() : @@ -78,10 +96,8 @@ bool WAVReader::initialize(const std::string& filePath) flushChunks(); - _rwMutex.lock(); _streamer = ref new MediaStreamer; _streamer->Initialize(std::wstring(_filePath.begin(), _filePath.end()).c_str(), true); - _rwMutex.unlock(); _wfx = _streamer->GetOutputWaveFormatEx(); UINT32 dataSize = _streamer->GetMaxStreamLengthInBytes(); @@ -162,31 +178,7 @@ void WAVReader::produceChunk() void WAVReader::seekTo(const float ratio) { - if (_isStreaming) { - auto newPos = ratio * _audioSize; - - if (!newPos && !_isDirty && _chnkQ.size()) // already in 0.0 position - return; - - _bytesRead = newPos; - flushChunks(); - - switch (_wfx.wFormatTag) - { - case WAVE_FORMAT_PCM: - case WAVE_FORMAT_ADPCM: { - auto alignment = _wfx.nChannels * _wfx.nBlockAlign; - _bytesRead = _bytesRead >= _audioSize ? (_audioSize - alignment) : _bytesRead - (_bytesRead % alignment); - } break; - - default: - break; - } - - for (int i = 0; i < QUEUEBUFFER_NUM; i++) { - produceChunk(); - } - } + AudioSourceReader::seekTo(ratio); } @@ -299,21 +291,7 @@ void MP3Reader::produceChunk() void MP3Reader::seekTo(const float ratio) { - if (_isStreaming) { - auto newPos = ratio * _audioSize; - - if (!newPos && !_isDirty && _chnkQ.size()) // already in 0.0 position - return; - - _bytesRead = newPos; - flushChunks(); - auto alignment = _wfx.nChannels * _wfx.nBlockAlign; - _bytesRead = _bytesRead >= _audioSize ? (_audioSize - alignment) : _bytesRead - (_bytesRead % alignment); - - for (int i = 0; i < QUEUEBUFFER_NUM; i++) { - produceChunk(); - } - } + AudioSourceReader::seekTo(ratio); } HRESULT MP3Reader::configureSourceReader(IMFSourceReader* pReader, IMFMediaType** ppDecomprsdAudioType) @@ -520,4 +498,137 @@ Wrappers::FileHandle MP3Reader::openFile(const std::string& path, bool append) return Microsoft::WRL::Wrappers::FileHandle(CreateFile2(std::wstring(path.begin(), path.end()).c_str(), access, FILE_SHARE_READ, creation, &extParams)); } + +// OGGReader +OGGReader::OGGReader() +{ +} + +OGGReader::~OGGReader() +{ + if (_vorbisFd) { + ov_clear(_vorbisFd.get()); + } +} + +bool OGGReader::initialize(const std::string& filePath) +{ + bool ret = false; + _filePath = filePath; + + do { + _vorbisFd = std::make_unique(); + if (ov_fopen(FileUtils::getInstance()->getSuitableFOpen(_filePath).c_str(), _vorbisFd.get())){ + break; + } + + auto vi = ov_info(_vorbisFd.get(), -1); + + if (!vi) { + break; + } + + auto totalFrames = ov_pcm_total(_vorbisFd.get(), -1); + auto bytesPerFrame = vi->channels * 2; + _audioSize = totalFrames * bytesPerFrame; + + _wfx.wFormatTag = WAVE_FORMAT_PCM; + _wfx.nChannels = vi->channels; + _wfx.nSamplesPerSec = vi->rate; + _wfx.nAvgBytesPerSec = vi->rate * bytesPerFrame; + _wfx.nBlockAlign = bytesPerFrame; + _wfx.wBitsPerSample = (bytesPerFrame / vi->channels) * 8; + _wfx.cbSize = 0; + + if (_audioSize <= PCMDATA_CACHEMAXSIZE) { + produceChunk(); + } + else { + _isStreaming = true; + for (int i = 0; i < QUEUEBUFFER_NUM; i++) { + produceChunk(); + } + } + + ret = true; + } while (false); + + return ret; +} + +bool OGGReader::consumeChunk(AudioDataChunk& chunk) +{ + bool ret = false; + _isDirty = true; + + _rwMutex.lock(); + if (_chnkQ.size() > 0) { + chunk = _chnkQ.front(); + if (_isStreaming) { + _chnkQ.pop(); + } + ret = true; + } + _rwMutex.unlock(); + + return ret; +} + +void OGGReader::produceChunk() +{ + _rwMutex.lock(); + int chunkSize = _audioSize; + + do { + if (!_isStreaming && _chnkQ.size() || _chnkQ.size() >= QUEUEBUFFER_NUM) { + break; + } + + if (_isStreaming) { + chunkSize = std::min(CHUNK_SIZE_MAX, _audioSize - _bytesRead); + } + + if (!chunkSize && !_chnkQ.size()) { + auto alignment = _wfx.nChannels * _wfx.nBlockAlign; + _bytesRead -= alignment; + chunkSize = alignment; + } + + if (!chunkSize) { + break; + } + + int retSize = 0; + AudioDataChunk chunk = { 0 }; + chunk._data = std::make_shared(chunkSize); + + auto newPos = (1.0f * _bytesRead / _audioSize) * ov_time_total(_vorbisFd.get(), -1); + if (ov_time_seek(_vorbisFd.get(), newPos)){ + break; + } + + do + { + long br = 0; + int current_section = 0; + if ((br = ov_read(_vorbisFd.get(), (char*)chunk._data->data() + retSize, chunkSize - retSize, 0, 2, 1, ¤t_section)) == 0) { + break; + } + retSize += br; + } while (retSize < chunkSize); + + _bytesRead += retSize; + chunk._dataSize = retSize; + chunk._seqNo = ((float)_bytesRead / _audioSize) * ((float)_audioSize / CHUNK_SIZE_MAX); + chunk._endOfStream = (_bytesRead >= _audioSize); + _chnkQ.push(chunk); + } while (false); + _rwMutex.unlock(); +} + +void OGGReader::seekTo(const float ratio) +{ + AudioSourceReader::seekTo(ratio); +} + #endif diff --git a/cocos/audio/winrt/AudioSourceReader.h b/cocos/audio/winrt/AudioSourceReader.h index e6d5f37a05..d835d22cf8 100644 --- a/cocos/audio/winrt/AudioSourceReader.h +++ b/cocos/audio/winrt/AudioSourceReader.h @@ -30,6 +30,8 @@ #include #include #include "MediaStreamer.h" +#include "ogg/ogg.h" +#include "vorbis/vorbisfile.h" NS_CC_BEGIN namespace experimental{ @@ -132,6 +134,22 @@ class MP3Reader : public AudioSourceReader std::string _mappedWavFile; }; +class OGGReader : public AudioSourceReader +{ +public: + OGGReader(); + virtual ~OGGReader(); + + virtual bool initialize(const std::string& filePath) override; + virtual FileFormat getFileFormat() override { return FileFormat::WAV; } + virtual bool consumeChunk(AudioDataChunk& chunk) override; + virtual void produceChunk() override; + virtual void seekTo(const float ratio) override; + +private: + std::unique_ptr _vorbisFd; +}; + } NS_CC_END #endif // __AUDIO_SOURCE_READER_H_ From bd718bb85ff1fbb5bba0cdf244b8828ad5de7f45 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Thu, 4 Jun 2015 14:57:37 +0800 Subject: [PATCH 08/35] Node:Fixed the anchor point can only be Vec2::ANCHOR_MIDDLE after setting physics body. --- cocos/2d/CCNode.cpp | 28 +++++++++------------------- cocos/2d/CCNode.h | 3 +++ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 6fac752ec8..311e37da89 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -710,14 +710,6 @@ const Vec2& Node::getAnchorPoint() const void Node::setAnchorPoint(const Vec2& point) { -#if CC_USE_PHYSICS - if (_physicsBody != nullptr && !point.equals(Vec2::ANCHOR_MIDDLE)) - { - CCLOG("Node warning: This node has a physics body, the anchor must be in the middle, you cann't change this to other value."); - return; - } -#endif - if (! point.equals(_anchorPoint)) { _anchorPoint = point; @@ -2077,14 +2069,6 @@ void Node::setPhysicsBody(PhysicsBody* body) body->_node = this; body->retain(); - - // physics rotation based on body position, but node rotation based on node anthor point - // it cann't support both of them, so I clear the anthor point to default. - if (!getAnchorPoint().equals(Vec2::ANCHOR_MIDDLE)) - { - CCLOG("Node warning: setPhysicsBody sets anchor point to Vec2::ANCHOR_MIDDLE."); - setAnchorPoint(Vec2::ANCHOR_MIDDLE); - } _physicsBody = body; _physicsScaleStartX = _scaleX; @@ -2123,10 +2107,16 @@ void Node::updatePhysicsBodyTransform(const Mat4& parentTransform, uint32_t pare if (_physicsBody && ((flags & FLAGS_DIRTY_MASK) || _physicsTransformDirty)) { _physicsTransformDirty = false; - Vec3 vec3(_position.x, _position.y, 0); + + Vec3 vec3(_contentSize.width * 0.5f, _contentSize.height * 0.5f, 0); Vec3 ret; - parentTransform.transformPoint(vec3, &ret); + _modelViewTransform.transformPoint(vec3, &ret); _physicsBody->setPosition(Vec2(ret.x, ret.y)); + + parentTransform.getInversed().transformPoint(&ret); + _offsetX = ret.x - _position.x; + _offsetY = ret.y - _position.y; + _physicsBody->setScale(scaleX / _physicsScaleStartX, scaleY / _physicsScaleStartY); _physicsBody->setRotation(_physicsRotation - _physicsRotationOffset); } @@ -2148,7 +2138,7 @@ void Node::updateTransformFromPhysics(const Mat4& parentTransform, uint32_t pare Vec3 vec3(newPosition.x, newPosition.y, 0); Vec3 ret; parentTransform.getInversed().transformPoint(vec3, &ret); - setPosition(ret.x, ret.y); + setPosition(ret.x - _offsetX, ret.y - _offsetY); } _physicsRotation = _physicsBody->getRotation(); setRotation(_physicsRotation - _parent->_physicsRotation + _physicsRotationOffset); diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 5333bbb33f..59d8cd2c94 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -1844,6 +1844,9 @@ protected: PhysicsWorld* _physicsWorld; /** The PhysicsWorld associated with the node.*/ int _physicsBodyAssociatedWith; /** The count of PhysicsBody associated with the node and children.*/ float _physicsRotationOffset; /** Record the rotation value when invoke Node::setPhysicsBody.*/ + + float _offsetX; + float _offsetY; #endif // opacity controls From 3f3ace05a732cb777b8d5380f5166244fb8dd729 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Thu, 4 Jun 2015 14:42:11 -0700 Subject: [PATCH 09/35] added ogg support for Windows 10 UWP --- cocos/2d/libcocos2d_win10/libcocos2d.vcxproj | 12 +- cocos/2d/win10_props/cocos2d_win10.props | 4 +- cocos/2d/win10_props/cocos2d_win10_app.props | 10 + .../App/Cocos2dEngine/OpenGLESPage.xaml.cpp | 184 ++++++++++-------- .../App/Cocos2dEngine/OpenGLESPage.xaml.h | 17 +- .../proj.win10/cpp-empty-test.vcxproj | 12 +- .../proj.win10/cpp-empty-test.vcxproj.filters | 3 + 7 files changed, 145 insertions(+), 97 deletions(-) diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj index a6df06194a..e9e645e053 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj @@ -1506,7 +1506,7 @@ _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false 4458;4459;%(DisableSpecificWarnings) - $(EngineRoot)external\win10-specific\zlib\include;$(EngineRoot)external\freetype2\include\win10\freetype2;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\win10-specific\zlib\include;$(EngineRoot)external\freetype2\include\win10\freetype2;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;$(EngineRoot)external\win10-specific\OggDecoder\include;%(AdditionalIncludeDirectories) /Zm384 /bigobj %(AdditionalOptions) ProgramDatabase @@ -1524,7 +1524,7 @@ _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;%(PreprocessorDefinitions) false 4458;4459;%(DisableSpecificWarnings) - $(EngineRoot)external\win10-specific\zlib\include;$(EngineRoot)external\freetype2\include\win10\freetype2;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\win10-specific\zlib\include;$(EngineRoot)external\freetype2\include\win10\freetype2;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;$(EngineRoot)external\win10-specific\OggDecoder\include;%(AdditionalIncludeDirectories) /Zm384 /bigobj %(AdditionalOptions) false @@ -1543,7 +1543,7 @@ _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false 4458;4459;%(DisableSpecificWarnings) - $(EngineRoot)external\win10-specific\zlib\include;$(EngineRoot)external\freetype2\include\win10\freetype2;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\win10-specific\zlib\include;$(EngineRoot)external\freetype2\include\win10\freetype2;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;$(EngineRoot)external\win10-specific\OggDecoder\include;%(AdditionalIncludeDirectories) /Zm384 /bigobj %(AdditionalOptions) ProgramDatabase @@ -1561,7 +1561,7 @@ _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;%(PreprocessorDefinitions) false 4458;4459;%(DisableSpecificWarnings) - $(EngineRoot)external\win10-specific\zlib\include;$(EngineRoot)external\freetype2\include\win10\freetype2;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\win10-specific\zlib\include;$(EngineRoot)external\freetype2\include\win10\freetype2;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;$(EngineRoot)external\win10-specific\OggDecoder\include;%(AdditionalIncludeDirectories) /Zm384 /bigobj %(AdditionalOptions) false ProgramDatabase @@ -1581,7 +1581,7 @@ _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false 4458;4459;%(DisableSpecificWarnings) - $(EngineRoot)external\win10-specific\zlib\include;$(EngineRoot)external\freetype2\include\win10\freetype2;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\win10-specific\zlib\include;$(EngineRoot)external\freetype2\include\win10\freetype2;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;$(EngineRoot)external\win10-specific\OggDecoder\include;%(AdditionalIncludeDirectories) /Zm384 /bigobj %(AdditionalOptions) EditAndContinue @@ -1599,7 +1599,7 @@ _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;%(PreprocessorDefinitions) false 4458;4459;%(DisableSpecificWarnings) - $(EngineRoot)external\win10-specific\zlib\include;$(EngineRoot)external\freetype2\include\win10\freetype2;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) + $(EngineRoot)external\win10-specific\zlib\include;$(EngineRoot)external\freetype2\include\win10\freetype2;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;$(EngineRoot)external\win10-specific\OggDecoder\include;%(AdditionalIncludeDirectories) /Zm384 /bigobj %(AdditionalOptions) false diff --git a/cocos/2d/win10_props/cocos2d_win10.props b/cocos/2d/win10_props/cocos2d_win10.props index b5bfaeca85..3972b399f7 100644 --- a/cocos/2d/win10_props/cocos2d_win10.props +++ b/cocos/2d/win10_props/cocos2d_win10.props @@ -18,8 +18,8 @@ 4056;4244;4251;4756;4453;28204;4099; - libGLESv2.lib;libEGL.lib;ws2_32.lib;libwebsockets.lib;chipmunk.lib;zlib.lib;freetype.lib;sqlite3.lib;d2d1.lib;d3d11.lib;dxgi.lib;windowscodecs.lib;dwrite.lib;dxguid.lib;xaudio2.lib;mfcore.lib;mfplat.lib;mfreadwrite.lib;mfuuid.lib;%(AdditionalDependencies) - $(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\angle\prebuilt\$(Platform);$(EngineRoot)external\websockets\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\chipmunk\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\zlib\prebuilt\$(Platform);$(EngineRoot)external\sqlite3\libraries\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\freetype2\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\poly2tri;$(EngineRoot)external\poly2tri\common;$(EngineRoot)external\poly2tri\sweep;%(AdditionalLibraryDirectories); + libogg.lib;libvorbis.lib;libvorbisfile.lib;libGLESv2.lib;libEGL.lib;ws2_32.lib;libwebsockets.lib;chipmunk.lib;zlib.lib;freetype.lib;sqlite3.lib;d2d1.lib;d3d11.lib;dxgi.lib;windowscodecs.lib;dwrite.lib;dxguid.lib;xaudio2.lib;mfcore.lib;mfplat.lib;mfreadwrite.lib;mfuuid.lib;%(AdditionalDependencies) + $(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\OggDecoder\prebuilt\$(Platform);$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\angle\prebuilt\$(Platform);$(EngineRoot)external\websockets\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\chipmunk\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\zlib\prebuilt\$(Platform);$(EngineRoot)external\sqlite3\libraries\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\freetype2\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\poly2tri;$(EngineRoot)external\poly2tri\common;$(EngineRoot)external\poly2tri\sweep;%(AdditionalLibraryDirectories); /IGNORE:4264 %(AdditionalOptions) diff --git a/cocos/2d/win10_props/cocos2d_win10_app.props b/cocos/2d/win10_props/cocos2d_win10_app.props index 9d5ace9ee9..68820b5032 100644 --- a/cocos/2d/win10_props/cocos2d_win10_app.props +++ b/cocos/2d/win10_props/cocos2d_win10_app.props @@ -6,6 +6,7 @@ $(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\zlib\prebuilt\$(Platform)\ $(EngineRoot)external\websockets\prebuilt\$(COCOS2D_PLATFORM)\$(Platform)\ $(EngineRoot)external\sqlite3\libraries\$(COCOS2D_PLATFORM)\$(Platform)\ + $(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\OggDecoder\prebuilt\$(Platform)\ @@ -23,5 +24,14 @@ true + + true + + + true + + + true + \ No newline at end of file diff --git a/templates/cpp-template-default/proj.win10/App/Cocos2dEngine/OpenGLESPage.xaml.cpp b/templates/cpp-template-default/proj.win10/App/Cocos2dEngine/OpenGLESPage.xaml.cpp index fc4a36bc71..ce0bc7407e 100644 --- a/templates/cpp-template-default/proj.win10/App/Cocos2dEngine/OpenGLESPage.xaml.cpp +++ b/templates/cpp-template-default/proj.win10/App/Cocos2dEngine/OpenGLESPage.xaml.cpp @@ -51,10 +51,11 @@ OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) : mRenderSurface(EGL_NO_SURFACE), mCustomRenderSurfaceSize(0,0), mUseCustomRenderSurfaceSize(false), - m_coreInput(nullptr), - m_dpi(0.0f), - m_deviceLost(false), - m_orientation(DisplayOrientations::Landscape) + mCoreInput(nullptr), + mDpi(0.0f), + mDeviceLost(false), + mVisible(false), + mOrientation(DisplayOrientations::Landscape) { InitializeComponent(); @@ -77,7 +78,7 @@ OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) : currentDisplayInformation->OrientationChanged += ref new TypedEventHandler(this, &OpenGLESPage::OnOrientationChanged); - m_orientation = currentDisplayInformation->CurrentOrientation; + mOrientation = currentDisplayInformation->CurrentOrientation; this->Loaded += ref new Windows::UI::Xaml::RoutedEventHandler(this, &OpenGLESPage::OnPageLoaded); @@ -111,23 +112,23 @@ OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) : auto workItemHandler = ref new WorkItemHandler([this](IAsyncAction ^) { // The CoreIndependentInputSource will raise pointer events for the specified device types on whichever thread it's created on. - m_coreInput = swapChainPanel->CreateCoreIndependentInputSource( + mCoreInput = swapChainPanel->CreateCoreIndependentInputSource( Windows::UI::Core::CoreInputDeviceTypes::Mouse | Windows::UI::Core::CoreInputDeviceTypes::Touch | Windows::UI::Core::CoreInputDeviceTypes::Pen ); // Register for pointer events, which will be raised on the background thread. - m_coreInput->PointerPressed += ref new TypedEventHandler(this, &OpenGLESPage::OnPointerPressed); - m_coreInput->PointerMoved += ref new TypedEventHandler(this, &OpenGLESPage::OnPointerMoved); - m_coreInput->PointerReleased += ref new TypedEventHandler(this, &OpenGLESPage::OnPointerReleased); + mCoreInput->PointerPressed += ref new TypedEventHandler(this, &OpenGLESPage::OnPointerPressed); + mCoreInput->PointerMoved += ref new TypedEventHandler(this, &OpenGLESPage::OnPointerMoved); + mCoreInput->PointerReleased += ref new TypedEventHandler(this, &OpenGLESPage::OnPointerReleased); // Begin processing input messages as they're delivered. - m_coreInput->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit); + mCoreInput->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit); }); // Run task on a dedicated high priority background thread. - m_inputLoopWorker = ThreadPool::RunAsync(workItemHandler, WorkItemPriority::High, WorkItemOptions::TimeSliced); + mInputLoopWorker = ThreadPool::RunAsync(workItemHandler, WorkItemPriority::High, WorkItemOptions::TimeSliced); } OpenGLESPage::~OpenGLESPage() @@ -141,29 +142,30 @@ void OpenGLESPage::OnPageLoaded(Platform::Object^ sender, Windows::UI::Xaml::Rou // The SwapChainPanel has been created and arranged in the page layout, so EGL can be initialized. CreateRenderSurface(); StartRenderLoop(); + mVisible = true; } void OpenGLESPage::OnPointerPressed(Object^ sender, PointerEventArgs^ e) { - if (m_renderer) + if (mRenderer) { - m_renderer->QueuePointerEvent(PointerEventType::PointerPressed, e); + mRenderer->QueuePointerEvent(PointerEventType::PointerPressed, e); } } void OpenGLESPage::OnPointerMoved(Object^ sender, PointerEventArgs^ e) { - if (m_renderer) + if (mRenderer) { - m_renderer->QueuePointerEvent(PointerEventType::PointerMoved, e); + mRenderer->QueuePointerEvent(PointerEventType::PointerMoved, e); } } void OpenGLESPage::OnPointerReleased(Object^ sender, PointerEventArgs^ e) { - if (m_renderer) + if (mRenderer) { - m_renderer->QueuePointerEvent(PointerEventType::PointerReleased, e); + mRenderer->QueuePointerEvent(PointerEventType::PointerReleased, e); } } @@ -172,9 +174,9 @@ void OpenGLESPage::OnKeyPressed(CoreWindow^ sender, KeyEventArgs^ e) if (!e->KeyStatus.WasKeyDown) { //log("OpenGLESPage::OnKeyPressed %d", e->VirtualKey); - if (m_renderer) + if (mRenderer) { - m_renderer->QueueKeyboardEvent(WinRTKeyboardEventType::KeyPressed, e); + mRenderer->QueueKeyboardEvent(WinRTKeyboardEventType::KeyPressed, e); } } } @@ -192,9 +194,9 @@ void OpenGLESPage::OnCharacterReceived(CoreWindow^ sender, CharacterReceivedEven void OpenGLESPage::OnKeyReleased(CoreWindow^ sender, KeyEventArgs^ e) { //log("OpenGLESPage::OnKeyReleased %d", e->VirtualKey); - if (m_renderer) + if (mRenderer) { - m_renderer->QueueKeyboardEvent(WinRTKeyboardEventType::KeyReleased, e); + mRenderer->QueueKeyboardEvent(WinRTKeyboardEventType::KeyReleased, e); } } @@ -202,18 +204,20 @@ void OpenGLESPage::OnKeyReleased(CoreWindow^ sender, KeyEventArgs^ e) void OpenGLESPage::OnOrientationChanged(DisplayInformation^ sender, Object^ args) { critical_section::scoped_lock lock(mSwapChainPanelSizeCriticalSection); - m_orientation = sender->CurrentOrientation; + mOrientation = sender->CurrentOrientation; } void OpenGLESPage::OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args) { if (args->Visible && mRenderSurface != EGL_NO_SURFACE) { - StartRenderLoop(); + std::unique_lock locker(mSleepMutex); + mVisible = true; + mSleepCondition.notify_one(); } else { - StopRenderLoop(); + mVisible = false; } } @@ -230,15 +234,14 @@ void OpenGLESPage::OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Wi */ void OpenGLESPage::OnBackButtonPressed(Object^ sender, BackPressedEventArgs^ args) { - if (m_renderer) + if (mRenderer) { - m_renderer->QueueBackButtonEvent(); + mRenderer->QueueBackButtonEvent(); args->Handled = true; } } #endif - void OpenGLESPage::OnSwapChainPanelSizeChanged(Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e) { // Size change events occur outside of the render thread. A lock is required when updating @@ -291,19 +294,13 @@ void OpenGLESPage::DestroyRenderSurface() void OpenGLESPage::RecoverFromLostDevice() { - // Stop the render loop, reset OpenGLES, recreate the render surface - // and start the render loop again to recover from a lost device. - - StopRenderLoop(); - - { - critical_section::scoped_lock lock(mRenderSurfaceCriticalSection); - DestroyRenderSurface(); - mOpenGLES->Reset(); - CreateRenderSurface(); - } - - StartRenderLoop(); + critical_section::scoped_lock lock(mRenderSurfaceCriticalSection); + DestroyRenderSurface(); + mOpenGLES->Reset(); + CreateRenderSurface(); + std::unique_lock locker(mSleepMutex); + mDeviceLost = false; + mSleepCondition.notify_one(); } void OpenGLESPage::TerminateApp() @@ -316,7 +313,6 @@ void OpenGLESPage::TerminateApp() mOpenGLES->DestroySurface(mRenderSurface); mOpenGLES->Cleanup(); } - } Windows::UI::Xaml::Application::Current->Exit(); } @@ -330,45 +326,60 @@ void OpenGLESPage::StartRenderLoop() } DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); - m_dpi = currentDisplayInformation->LogicalDpi; + mDpi = currentDisplayInformation->LogicalDpi; auto dispatcher = Windows::UI::Xaml::Window::Current->CoreWindow->Dispatcher; // Create a task for rendering that will be run on a background thread. auto workItemHandler = ref new Windows::System::Threading::WorkItemHandler([this, dispatcher](Windows::Foundation::IAsyncAction ^ action) { - critical_section::scoped_lock lock(mRenderSurfaceCriticalSection); - mOpenGLES->MakeCurrent(mRenderSurface); GLsizei panelWidth = 0; GLsizei panelHeight = 0; GetSwapChainPanelSize(&panelWidth, &panelHeight); - if (m_renderer.get() == nullptr) + if (mRenderer.get() == nullptr) { - m_renderer = std::make_shared(panelWidth, panelHeight, m_dpi, m_orientation, dispatcher, swapChainPanel); + mRenderer = std::make_shared(panelWidth, panelHeight, mDpi, mOrientation, dispatcher, swapChainPanel); } - if (m_deviceLost) - { - m_deviceLost = false; - m_renderer->DeviceLost(); - } - else - { - m_renderer->Resume(); - } + mRenderer->Resume(); - - while (action->Status == Windows::Foundation::AsyncStatus::Started && !m_deviceLost) + while (action->Status == Windows::Foundation::AsyncStatus::Started) { - GetSwapChainPanelSize(&panelWidth, &panelHeight); - m_renderer.get()->Draw(panelWidth, panelHeight, m_dpi, m_orientation); - - // run on main UI thread - if (m_renderer->AppShouldExit()) + if (!mVisible) { + mRenderer->Pause(); + } + + // wait until app is visible again or thread is cancelled + while (!mVisible) + { + std::unique_lock lock(mSleepMutex); + mSleepCondition.wait(lock); + + if (action->Status != Windows::Foundation::AsyncStatus::Started) + { + return; // thread was cancelled. Exit thread + } + + if (mVisible) + { + mRenderer->Resume(); + } + else // spurious wake up + { + continue; + } + } + + GetSwapChainPanelSize(&panelWidth, &panelHeight); + mRenderer.get()->Draw(panelWidth, panelHeight, mDpi, mOrientation); + + if (mRenderer->AppShouldExit()) + { + // run on main UI thread swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]() { TerminateApp(); @@ -376,17 +387,19 @@ void OpenGLESPage::StartRenderLoop() return; } - else if (mOpenGLES->SwapBuffers(mRenderSurface) != GL_TRUE) + + EGLBoolean result = GL_FALSE; { - // The call to eglSwapBuffers might not be successful (i.e. due to Device Lost) + critical_section::scoped_lock lock(mRenderSurfaceCriticalSection); + result = mOpenGLES->SwapBuffers(mRenderSurface); + } + + if (result != GL_TRUE) + { + // The call to eglSwapBuffers was not be successful (i.e. due to Device Lost) // If the call fails, then we must reinitialize EGL and the GL resources. - - m_deviceLost = true; - - if (m_renderer) - { - m_renderer->Pause(); - } + mRenderer->Pause(); + mDeviceLost = true; // XAML objects like the SwapChainPanel must only be manipulated on the UI thread. swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([=]() @@ -394,13 +407,28 @@ void OpenGLESPage::StartRenderLoop() RecoverFromLostDevice(); }, CallbackContext::Any)); - return; - } - } + // wait until OpenGL is reset or thread is cancelled + while (mDeviceLost) + { + std::unique_lock lock(mSleepMutex); + mSleepCondition.wait(lock); - if (m_renderer) - { - m_renderer->Pause(); + if (action->Status != Windows::Foundation::AsyncStatus::Started) + { + return; // thread was cancelled. Exit thread + } + + if (!mDeviceLost) + { + // restart cocos2d-x + mRenderer->DeviceLost(); + } + else // spurious wake up + { + continue; + } + } + } } }); @@ -413,6 +441,8 @@ void OpenGLESPage::StopRenderLoop() if (mRenderLoopWorker) { mRenderLoopWorker->Cancel(); + std::unique_lock locker(mSleepMutex); + mSleepCondition.notify_one(); mRenderLoopWorker = nullptr; } } \ No newline at end of file diff --git a/templates/cpp-template-default/proj.win10/App/Cocos2dEngine/OpenGLESPage.xaml.h b/templates/cpp-template-default/proj.win10/App/Cocos2dEngine/OpenGLESPage.xaml.h index 26e3ff1fe0..c0dbe0699a 100644 --- a/templates/cpp-template-default/proj.win10/App/Cocos2dEngine/OpenGLESPage.xaml.h +++ b/templates/cpp-template-default/proj.win10/App/Cocos2dEngine/OpenGLESPage.xaml.h @@ -21,6 +21,8 @@ #include "OpenGLES.h" #include "OpenGLESPage.g.h" #include +#include +#include #include "Cocos2dRenderer.h" @@ -51,7 +53,7 @@ namespace cocos2d void StopRenderLoop(); OpenGLES* mOpenGLES; - std::shared_ptr m_renderer; + std::shared_ptr mRenderer; Windows::Foundation::Size mSwapChainPanelSize; Concurrency::critical_section mSwapChainPanelSizeCriticalSection; @@ -64,8 +66,8 @@ namespace cocos2d Windows::Foundation::IAsyncAction^ mRenderLoopWorker; // Track user input on a background worker thread. - Windows::Foundation::IAsyncAction^ m_inputLoopWorker; - Windows::UI::Core::CoreIndependentInputSource^ m_coreInput; + Windows::Foundation::IAsyncAction^ mInputLoopWorker; + Windows::UI::Core::CoreIndependentInputSource^ mCoreInput; // Independent input handling functions. void OnPointerPressed(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e); @@ -77,9 +79,12 @@ namespace cocos2d void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); - float m_dpi; - bool m_deviceLost; - Windows::Graphics::Display::DisplayOrientations m_orientation; + float mDpi; + bool mDeviceLost; + bool mVisible; + Windows::Graphics::Display::DisplayOrientations mOrientation; + std::mutex mSleepMutex; + std::condition_variable mSleepCondition; }; } diff --git a/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj b/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj index f042b8597e..9ae1357cad 100644 --- a/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj +++ b/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj @@ -154,7 +154,7 @@ ProgramDatabase - echo "Copying Windows 8.1 Universal App CPP template files" + echo "Copying Windows 10.0 Universal App CPP template files" xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq @@ -176,7 +176,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat ProgramDatabase - echo "Copying Windows 8.1 Universal App CPP template files" + echo "Copying Windows 10.0 Universal App CPP template files" xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq @@ -198,7 +198,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat ProgramDatabase - echo "Copying Windows 8.1 Universal App CPP template files" + echo "Copying Windows 10.0 Universal App CPP template files" xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq @@ -220,7 +220,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat OldStyle - echo "Copying Windows 8.1 Universal App CPP template files" + echo "Copying Windows 10.0 Universal App CPP template files" xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq @@ -242,7 +242,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat EditAndContinue - echo "Copying Windows 8.1 Universal App CPP template files" + echo "Copying Windows 10.0 Universal App CPP template files" xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq @@ -263,7 +263,7 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat ..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) - echo "Copying Windows 8.1 Universal App CPP template files" + echo "Copying Windows 10.0 Universal App CPP template files" xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq diff --git a/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj.filters b/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj.filters index 61bd275564..2f5ffc0135 100644 --- a/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj.filters +++ b/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj.filters @@ -68,6 +68,9 @@ + + + From 761944f5074c8d9b55b5dac63f1531983265c12e Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 5 Jun 2015 13:54:09 +0800 Subject: [PATCH 10/35] remove addChildToPhysicsWorld for 3d object --- cocos/2d/CCScene.cpp | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index 252c3952a8..c82bcb17e8 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -215,13 +215,17 @@ void Scene::setPhysics3DDebugCamera(Camera* camera) void Scene::addChild(Node* child, int zOrder, int tag) { Node::addChild(child, zOrder, tag); +#if CC_USE_PHYSICS addChildToPhysicsWorld(child); +#endif } void Scene::addChild(Node* child, int zOrder, const std::string &name) { Node::addChild(child, zOrder, name); +#if CC_USE_PHYSICS addChildToPhysicsWorld(child); +#endif } Scene* Scene::createWithPhysics() @@ -254,8 +258,6 @@ bool Scene::initWithPhysics() #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION Physics3DWorldDes info; - //TODO: FIX ME - //info.isDebugDrawEnabled = true; CC_BREAK_IF(! (_physics3DWorld = Physics3DWorld::create(&info))); _physics3DWorld->retain(); #endif @@ -290,29 +292,6 @@ void Scene::addChildToPhysicsWorld(Node* child) addToPhysicsWorldFunc(child); } #endif - -#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION - if (_physics3DWorld) - { - std::function addToPhysicsWorldFunc = nullptr; - addToPhysicsWorldFunc = [this, &addToPhysicsWorldFunc](Node* node) -> void - { - static std::string comName = Physics3DComponent::getPhysics3DComponentName(); - auto com = static_cast(node->getComponent(comName)); - if (com) - { - com->addToPhysicsWorld(_physics3DWorld); - } - - auto& children = node->getChildren(); - for( const auto &n : children) { - addToPhysicsWorldFunc(n); - } - }; - - addToPhysicsWorldFunc(child); - } -#endif } #endif From 8e558db3d689863dee984a9a95599cbef63fd449 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 5 Jun 2015 16:25:09 +0800 Subject: [PATCH 11/35] call setTransparent --- cocos/3d/CCMesh.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index 30688d27bd..b801cb25d9 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -350,6 +350,7 @@ void Mesh::draw(Renderer* renderer, float globalZOrder, const Mat4& transform, u _meshCommand.setSkipBatching(isTransparent); + _meshCommand.setTransparent(isTransparent); // set default uniforms for Mesh // 'u_color' and others From bc1ea87adf7997e430fcd33c7d91460ee238aaf7 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Fri, 5 Jun 2015 06:21:03 -0700 Subject: [PATCH 12/35] updated app guid and disables auto version increment for App Cert tests --- .../HelloCpp.Windows/HelloCpp.Windows.vcxproj | 2 +- .../HelloCpp.Windows/Package.appxmanifest | 2 +- .../HelloCpp.WindowsPhone/HelloCpp.WindowsPhone.vcxproj | 2 +- .../HelloCpp.WindowsPhone/Package.appxmanifest | 4 ++-- .../cpp-tests.Windows/Package.appxmanifest | 2 +- .../cpp-tests.Windows/cpp-tests.Windows.vcxproj | 2 ++ .../cpp-tests.WindowsPhone/Package.appxmanifest | 4 ++-- .../cpp-tests.WindowsPhone/cpp-tests.WindowsPhone.vcxproj | 2 +- 8 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.Windows/HelloCpp.Windows.vcxproj b/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.Windows/HelloCpp.Windows.vcxproj index e1643f82b8..f8f7e4a5d9 100644 --- a/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.Windows/HelloCpp.Windows.vcxproj +++ b/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.Windows/HelloCpp.Windows.vcxproj @@ -112,7 +112,7 @@ HelloCpp.Windows_TemporaryKey.pfx - True + False x86 F75DA75441DF3361D325C567D0B34DA34BD31EED diff --git a/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.Windows/Package.appxmanifest b/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.Windows/Package.appxmanifest index 1f5d2e56b1..c97d50ca00 100644 --- a/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.Windows/Package.appxmanifest +++ b/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.Windows/Package.appxmanifest @@ -1,6 +1,6 @@  - + HelloCpp.Windows msopentech diff --git a/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.WindowsPhone/HelloCpp.WindowsPhone.vcxproj b/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.WindowsPhone/HelloCpp.WindowsPhone.vcxproj index fca4c95b89..f535611726 100644 --- a/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.WindowsPhone/HelloCpp.WindowsPhone.vcxproj +++ b/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.WindowsPhone/HelloCpp.WindowsPhone.vcxproj @@ -79,7 +79,7 @@ - True + False arm diff --git a/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.WindowsPhone/Package.appxmanifest b/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.WindowsPhone/Package.appxmanifest index 831614a464..cd88b875de 100644 --- a/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.WindowsPhone/Package.appxmanifest +++ b/tests/cpp-empty-test/proj.win8.1-universal/HelloCpp.WindowsPhone/Package.appxmanifest @@ -1,7 +1,7 @@  - - + + HelloCpp.WindowsPhone msopentech diff --git a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Windows/Package.appxmanifest b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Windows/Package.appxmanifest index 4b7d099a5d..b7e74dc176 100644 --- a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Windows/Package.appxmanifest +++ b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Windows/Package.appxmanifest @@ -1,6 +1,6 @@  - + cpp-tests.Windows msopentech diff --git a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Windows/cpp-tests.Windows.vcxproj b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Windows/cpp-tests.Windows.vcxproj index b04a8a8c59..5b84eb0413 100644 --- a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Windows/cpp-tests.Windows.vcxproj +++ b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Windows/cpp-tests.Windows.vcxproj @@ -90,6 +90,8 @@ cpp-tests.Windows_TemporaryKey.pfx 35C2132BDB64C0DFA54722663D9148FF118E341B + False + x86 false diff --git a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.WindowsPhone/Package.appxmanifest b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.WindowsPhone/Package.appxmanifest index e819a6cfa1..004db327a5 100644 --- a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.WindowsPhone/Package.appxmanifest +++ b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.WindowsPhone/Package.appxmanifest @@ -1,7 +1,7 @@  - - + + cpp-tests.WindowsPhone dalestam diff --git a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.WindowsPhone/cpp-tests.WindowsPhone.vcxproj b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.WindowsPhone/cpp-tests.WindowsPhone.vcxproj index a16b9fee92..4589917fe3 100644 --- a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.WindowsPhone/cpp-tests.WindowsPhone.vcxproj +++ b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.WindowsPhone/cpp-tests.WindowsPhone.vcxproj @@ -116,7 +116,7 @@ - True + False arm From 798e10ba9f1e50b207eefbc7b397e63d1aefdae9 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Fri, 5 Jun 2015 06:29:02 -0700 Subject: [PATCH 13/35] updated package GUID --- .../proj.win8.1-universal/App.Windows/Package.appxmanifest | 2 +- .../App.WindowsPhone/Package.appxmanifest | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/cpp-template-default/proj.win8.1-universal/App.Windows/Package.appxmanifest b/templates/cpp-template-default/proj.win8.1-universal/App.Windows/Package.appxmanifest index 91951e9a31..bcc43eb4da 100644 --- a/templates/cpp-template-default/proj.win8.1-universal/App.Windows/Package.appxmanifest +++ b/templates/cpp-template-default/proj.win8.1-universal/App.Windows/Package.appxmanifest @@ -1,6 +1,6 @@  - + HelloCpp.Windows msopentech diff --git a/templates/cpp-template-default/proj.win8.1-universal/App.WindowsPhone/Package.appxmanifest b/templates/cpp-template-default/proj.win8.1-universal/App.WindowsPhone/Package.appxmanifest index a2181cf8a0..98ec106e2b 100644 --- a/templates/cpp-template-default/proj.win8.1-universal/App.WindowsPhone/Package.appxmanifest +++ b/templates/cpp-template-default/proj.win8.1-universal/App.WindowsPhone/Package.appxmanifest @@ -1,7 +1,7 @@  - - + + HelloCpp.WindowsPhone msopentech From 74a60d18c5144be0da60d8b23afe5ebfbe853645 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Fri, 5 Jun 2015 06:29:33 -0700 Subject: [PATCH 14/35] removed old files. Added missing Cocos2dRenderer.h --- .../proj.win8.1-universal/App.Shared/HelloCpp.Shared.vcxitems | 2 +- .../App.Shared/HelloCpp.Shared.vcxitems.filters | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/HelloCpp.Shared.vcxitems b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/HelloCpp.Shared.vcxitems index 466b128576..846c15e029 100644 --- a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/HelloCpp.Shared.vcxitems +++ b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/HelloCpp.Shared.vcxitems @@ -27,7 +27,6 @@ $(MSBuildThisFileDirectory)OpenGLESPage.xaml - $(MSBuildThisFileDirectory)App.xaml @@ -35,6 +34,7 @@ Create + $(MSBuildThisFileDirectory)OpenGLESPage.xaml diff --git a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/HelloCpp.Shared.vcxitems.filters b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/HelloCpp.Shared.vcxitems.filters index 56ad91d96f..41c0107488 100644 --- a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/HelloCpp.Shared.vcxitems.filters +++ b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/HelloCpp.Shared.vcxitems.filters @@ -27,14 +27,12 @@ Classes - - Classes - Classes + From f1a067ee752033d20653966a738508beaaa41741 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Fri, 5 Jun 2015 09:21:52 -0700 Subject: [PATCH 15/35] removed e option from xcopy of cpp template files --- .../proj.win10/cpp-empty-test.vcxproj | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj b/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj index 9ae1357cad..4d98fb102f 100644 --- a/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj +++ b/tests/cpp-empty-test/proj.win10/cpp-empty-test.vcxproj @@ -155,15 +155,15 @@ echo "Copying Windows 10.0 Universal App CPP template files" -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /eiycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /iycq @@ -177,15 +177,15 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat echo "Copying Windows 10.0 Universal App CPP template files" -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /eiycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /iycq @@ -199,15 +199,15 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat echo "Copying Windows 10.0 Universal App CPP template files" -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /eiycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /iycq @@ -221,15 +221,15 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat echo "Copying Windows 10.0 Universal App CPP template files" -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /eiycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /iycq @@ -243,15 +243,15 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat echo "Copying Windows 10.0 Universal App CPP template files" -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /eiycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /iycq @@ -264,15 +264,15 @@ xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templat echo "Copying Windows 10.0 Universal App CPP template files" -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /eiycq -xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /eiycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\Cocos2dEngine\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.h" "$(EngineRoot)templates\cpp-template-default\proj.win10\App\*" /iycq From 3be686cee7f868a6b73acaed641be9889aa51a42 Mon Sep 17 00:00:00 2001 From: Oscar Utbult Date: Sun, 7 Jun 2015 13:29:32 +0200 Subject: [PATCH 16/35] Fix clone URL in README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d0fcd5fcda..0203e87b18 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ cocos2d-x is: Git user attention ----------------------- -1. clone the repo from GitHub. +1. Clone the repo from GitHub. - $ git clone git@github.com:cocos2d/cocos2d-x.git + $ git clone https://github.com/cocos2d/cocos2d-x.git 2. After cloning the repo, please execute `download-deps.py` to download and install dependencies. From c5c2f04ff0046820cbd2d329a52c09dd89a7a23c Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 5 Jun 2015 14:53:30 -0700 Subject: [PATCH 17/35] samplers are treated as uniforms --- cocos/3d/CCMesh.cpp | 3 ++ cocos/3d/CCSprite3D.cpp | 4 +- cocos/renderer/CCGLProgramState.cpp | 2 +- cocos/renderer/CCMaterial.cpp | 33 ++++++++++------ cocos/renderer/CCMaterial.h | 2 +- cocos/renderer/CCPass.cpp | 2 +- cocos/renderer/CCRenderState.cpp | 28 ++++++------- cocos/renderer/CCRenderState.h | 11 ++---- .../Resources/Materials/3d_effects.material | 39 ++++++++----------- .../Shaders3D/3d_color_normal_tex.frag | 5 ++- .../Resources/Shaders3D/3d_color_tex.frag | 3 +- .../Resources/Shaders3D/OutLine.vert | 2 +- 12 files changed, 67 insertions(+), 67 deletions(-) diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index 30688d27bd..939cd2d15f 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -283,6 +283,9 @@ void Mesh::setTexture(Texture2D* tex) auto technique = _material->_currentTechnique; for(auto& pass: technique->_passes) { + // FIXME: Ideally it should use glProgramState->setUniformTexture() + // and set CC_Texture0 that way. But trying to it, will trigger + // another bug pass->setTexture(tex); } } diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index f231591cd4..e0afe20449 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -606,8 +606,8 @@ void Sprite3D::setTexture(const std::string& texFile) void Sprite3D::setTexture(Texture2D* texture) { - for (auto& state : _meshes) { - state->setTexture(texture); + for (auto mesh: _meshes) { + mesh->setTexture(texture); } } AttachNode* Sprite3D::getAttachNode(const std::string& boneName) diff --git a/cocos/renderer/CCGLProgramState.cpp b/cocos/renderer/CCGLProgramState.cpp index 470704caca..616e5b2d92 100644 --- a/cocos/renderer/CCGLProgramState.cpp +++ b/cocos/renderer/CCGLProgramState.cpp @@ -359,7 +359,7 @@ GLProgramState* GLProgramState::getOrCreateWithShaders(const std::string& vertex GLProgramState::GLProgramState() : _uniformAttributeValueDirty(true) -, _textureUnitIndex(1) +, _textureUnitIndex(4) // first 4 textures unites are reserved for CC_Texture0-3 , _vertexAttribsFlags(0) , _glprogram(nullptr) , _nodeBinding(nullptr) diff --git a/cocos/renderer/CCMaterial.cpp b/cocos/renderer/CCMaterial.cpp index 57b0dbe6e6..06a618b957 100644 --- a/cocos/renderer/CCMaterial.cpp +++ b/cocos/renderer/CCMaterial.cpp @@ -198,9 +198,7 @@ bool Material::parsePass(Technique* technique, Properties* passProperties) while (space) { const char* name = space->getNamespace(); - if (strcmp(name, "sampler") == 0) - parseSampler(pass, space); - else if (strcmp(name, "shader") == 0) + if (strcmp(name, "shader") == 0) parseShader(pass, space); else if (strcmp(name, "renderState") == 0) parseRenderState(pass, space); @@ -216,10 +214,12 @@ bool Material::parsePass(Technique* technique, Properties* passProperties) } // cocos2d-x doesn't support Samplers yet. But will be added soon -bool Material::parseSampler(Pass* pass, Properties* textureProperties) +bool Material::parseSampler(GLProgramState* glProgramState, Properties* samplerProperties) { + CCASSERT(samplerProperties->getId(), "Sampler must have an id. The id is the uniform name"); + // required - auto filename = textureProperties->getString("path"); + auto filename = samplerProperties->getString("path"); auto texture = Director::getInstance()->getTextureCache()->addImage(filename); if (!texture) { @@ -234,14 +234,14 @@ bool Material::parseSampler(Pass* pass, Properties* textureProperties) // mipmap bool usemipmap = false; - const char* mipmap = getOptionalString(textureProperties, "mipmap", "false"); + const char* mipmap = getOptionalString(samplerProperties, "mipmap", "false"); if (mipmap && strcasecmp(mipmap, "true")==0) { texture->generateMipmap(); usemipmap = true; } // valid options: REPEAT, CLAMP - const char* wrapS = getOptionalString(textureProperties, "wrapS", "CLAMP_TO_EDGE"); + const char* wrapS = getOptionalString(samplerProperties, "wrapS", "CLAMP_TO_EDGE"); if (strcasecmp(wrapS, "REPEAT")==0) texParams.wrapS = GL_REPEAT; else if(strcasecmp(wrapS, "CLAMP_TO_EDGE")==0) @@ -251,7 +251,7 @@ bool Material::parseSampler(Pass* pass, Properties* textureProperties) // valid options: REPEAT, CLAMP - const char* wrapT = getOptionalString(textureProperties, "wrapT", "CLAMP_TO_EDGE"); + const char* wrapT = getOptionalString(samplerProperties, "wrapT", "CLAMP_TO_EDGE"); if (strcasecmp(wrapT, "REPEAT")==0) texParams.wrapT = GL_REPEAT; else if(strcasecmp(wrapT, "CLAMP_TO_EDGE")==0) @@ -261,7 +261,7 @@ bool Material::parseSampler(Pass* pass, Properties* textureProperties) // valid options: NEAREST, LINEAR, NEAREST_MIPMAP_NEAREST, LINEAR_MIPMAP_NEAREST, NEAREST_MIPMAP_LINEAR, LINEAR_MIPMAP_LINEAR - const char* minFilter = getOptionalString(textureProperties, "minFilter", usemipmap ? "LINEAR_MIPMAP_NEAREST" : "LINEAR"); + const char* minFilter = getOptionalString(samplerProperties, "minFilter", usemipmap ? "LINEAR_MIPMAP_NEAREST" : "LINEAR"); if (strcasecmp(minFilter, "NEAREST")==0) texParams.minFilter = GL_NEAREST; else if(strcasecmp(minFilter, "LINEAR")==0) @@ -278,7 +278,7 @@ bool Material::parseSampler(Pass* pass, Properties* textureProperties) CCLOG("Invalid minFilter: %s", minFilter); // valid options: NEAREST, LINEAR - const char* magFilter = getOptionalString(textureProperties, "magFilter", "LINEAR"); + const char* magFilter = getOptionalString(samplerProperties, "magFilter", "LINEAR"); if (strcasecmp(magFilter, "NEAREST")==0) texParams.magFilter = GL_NEAREST; else if(strcasecmp(magFilter, "LINEAR")==0) @@ -289,7 +289,7 @@ bool Material::parseSampler(Pass* pass, Properties* textureProperties) texture->setTexParameters(texParams); } - pass->_textures.pushBack(texture); + glProgramState->setUniformTexture(samplerProperties->getId(), texture); return true; } @@ -321,7 +321,16 @@ bool Material::parseShader(Pass* pass, Properties* shaderProperties) property = shaderProperties->getNextProperty(); } -// glProgramState->updateUniformsAndAttributes(); + auto space = shaderProperties->getNextNamespace(); + while (space) + { + const char* name = space->getNamespace(); + if (strcmp(name, "sampler") == 0) + { + parseSampler(glProgramState, space); + } + space = shaderProperties->getNextNamespace(); + } } return true; diff --git a/cocos/renderer/CCMaterial.h b/cocos/renderer/CCMaterial.h index ddae8425dc..dde8591895 100644 --- a/cocos/renderer/CCMaterial.h +++ b/cocos/renderer/CCMaterial.h @@ -133,8 +133,8 @@ protected: bool parseProperties(Properties* properties); bool parseTechnique(Properties* properties); bool parsePass(Technique* technique, Properties* properties); - bool parseSampler(Pass* pass, Properties* properties); bool parseShader(Pass* pass, Properties* properties); + bool parseSampler(GLProgramState* glProgramState, Properties* properties); bool parseUniform(GLProgramState* programState, Properties* properties, const char* uniformName); bool parseRenderState(RenderState* renderState, Properties* properties); diff --git a/cocos/renderer/CCPass.cpp b/cocos/renderer/CCPass.cpp index 29dd7eff4c..2ac59e3092 100644 --- a/cocos/renderer/CCPass.cpp +++ b/cocos/renderer/CCPass.cpp @@ -129,7 +129,7 @@ uint32_t Pass::getHash() const { if (_hashDirty || _state->isDirty()) { uint32_t glProgram = (uint32_t)_glProgramState->getGLProgram()->getProgram(); - uint32_t textureid = (uint32_t)_textures.at(0)->getName(); + uint32_t textureid = _texture ? _texture->getName() : -1; uint32_t stateblockid = _state->getHash(); _hash = glProgram ^ textureid ^ stateblockid; diff --git a/cocos/renderer/CCRenderState.cpp b/cocos/renderer/CCRenderState.cpp index d67482e4a4..d0fb9e45f1 100644 --- a/cocos/renderer/CCRenderState.cpp +++ b/cocos/renderer/CCRenderState.cpp @@ -58,7 +58,7 @@ enum RenderState::RenderState() -: _textures() +: _texture(nullptr) , _hash(0) , _hashDirty(true) , _parent(nullptr) @@ -102,32 +102,27 @@ std::string RenderState::getName() const } -const Vector& RenderState::getTextures() const -{ - return _textures; -} - void RenderState::setTexture(Texture2D* texture) { - if (_textures.size() > 0) - _textures.replace(0, texture); - else - _textures.pushBack(texture); + if (_texture != texture) + { + CC_SAFE_RELEASE(_texture); + _texture = texture; + CC_SAFE_RETAIN(_texture); + } } Texture2D* RenderState::getTexture() const { - if (_textures.size() > 0) - return _textures.at(0); - return nullptr; + return _texture; } void RenderState::bind(Pass* pass) { CC_ASSERT(pass); - if (_textures.size() > 0) - GL::bindTexture2D(_textures.at(0)->getName()); + if (_texture) + GL::bindTexture2D(_texture->getName()); // Get the combined modified state bits for our RenderState hierarchy. long stateOverrideBits = _state ? _state->_bits : 0; @@ -193,7 +188,8 @@ void RenderState::cloneInto(RenderState* renderState) const } renderState->_name = _name; - renderState->_textures = _textures; + renderState->_texture = _texture; + CC_SAFE_RETAIN(renderState->_texture); // weak ref. don't retain renderState->_parent = _parent; } diff --git a/cocos/renderer/CCRenderState.h b/cocos/renderer/CCRenderState.h index 088db5621c..3f3a68eb11 100644 --- a/cocos/renderer/CCRenderState.h +++ b/cocos/renderer/CCRenderState.h @@ -31,7 +31,6 @@ #include #include -#include "renderer/CCTexture2D.h" #include "platform/CCPlatformMacros.h" #include "base/CCRef.h" #include "base/ccTypes.h" @@ -65,14 +64,12 @@ public: std::string getName() const; - const Vector& getTextures() const; - - /** Replaces the texture that is at the front of _textures array. - Added to be backwards compatible. + /** Texture that will use in the CC_Texture0 uniform. + Added to be backwards compatible. Use Samplers from .material instead. */ void setTexture(Texture2D* texture); - /** Returns the texture that is at the front of the _textures array. + /** Returns the texture that is going to be used for CC_Texture0. Added to be backwards compatible. */ Texture2D* getTexture() const; @@ -413,7 +410,7 @@ protected: // name, for filtering std::string _name; - Vector _textures; + Texture2D* _texture; }; NS_CC_END diff --git a/tests/cpp-tests/Resources/Materials/3d_effects.material b/tests/cpp-tests/Resources/Materials/3d_effects.material index aab208a426..39e3ad0d50 100644 --- a/tests/cpp-tests/Resources/Materials/3d_effects.material +++ b/tests/cpp-tests/Resources/Materials/3d_effects.material @@ -22,19 +22,20 @@ material spaceship // renderState: // resposinble for depth buffer, cullface, stencil, blending, etc. // shader: - // responsible for the vertex and frag shaders, and its uniforms - // sampler: - // responsible for setting the texture and its parameters + // responsible for the vertex and frag shaders, and its uniforms, including the samplers pass 0 { shader { vertexShader = Shaders3D/3d_position_tex.vert fragmentShader = Shaders3D/3d_color_tex.frag - } - sampler 0 - { - path = Sprite3DTest/boss.png + // sampler: + // responsible for setting the texture and its parameters + // the Id of the sampler is the uniform name + sampler u_sampler0 + { + path = Sprite3DTest/boss.png + } } } } @@ -61,10 +62,6 @@ material spaceship OutLineColor = 1,1,0 OutlineWidth = 0.04 } - sampler 0 - { - path = Sprite3DTest/boss.png - } } // 2nd pass: @@ -85,10 +82,6 @@ material spaceship OutLineColor = 0,0,1 OutlineWidth = 0.02 } - sampler 0 - { - path = Sprite3DTest/boss.png - } } // 3rd pass // Renders the model "normally" @@ -99,10 +92,10 @@ material spaceship { vertexShader = Shaders3D/3d_position_tex.vert fragmentShader = Shaders3D/3d_color_tex.frag - } - sampler 0 - { - path = Sprite3DTest/boss.png + sampler u_sampler0 + { + path = Sprite3DTest/boss.png + } } } } @@ -118,10 +111,10 @@ material spaceship defines = MAX_POINT_LIGHT_NUM 1;MAX_SPOT_LIGHT_NUM 1;MAX_DIRECTIONAL_LIGHT_NUM 1 vertexShader = Shaders3D/3d_position_normal_tex.vert fragmentShader = Shaders3D/3d_color_normal_tex.frag - } - sampler 0 - { - path = Sprite3DTest/boss.png + sampler u_sampler0 + { + path = Sprite3DTest/boss.png + } } } } diff --git a/tests/cpp-tests/Resources/Shaders3D/3d_color_normal_tex.frag b/tests/cpp-tests/Resources/Shaders3D/3d_color_normal_tex.frag index 3ffac456e1..e9ec20ed96 100644 --- a/tests/cpp-tests/Resources/Shaders3D/3d_color_normal_tex.frag +++ b/tests/cpp-tests/Resources/Shaders3D/3d_color_normal_tex.frag @@ -43,6 +43,7 @@ varying vec3 v_normal; #endif uniform vec4 u_color; +uniform sampler2D u_sampler0; vec3 computeLighting(vec3 normalVector, vec3 lightDirection, vec3 lightColor, float attenuation) { @@ -101,9 +102,9 @@ void main(void) #endif #if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0)) - gl_FragColor = texture2D(CC_Texture0, TextureCoordOut) * u_color * combinedColor; + gl_FragColor = texture2D(u_sampler0, TextureCoordOut) * u_color * combinedColor; #else - gl_FragColor = texture2D(CC_Texture0, TextureCoordOut) * u_color; + gl_FragColor = texture2D(u_sampler0, TextureCoordOut) * u_color; #endif } diff --git a/tests/cpp-tests/Resources/Shaders3D/3d_color_tex.frag b/tests/cpp-tests/Resources/Shaders3D/3d_color_tex.frag index 0d87c7e229..9808ded895 100644 --- a/tests/cpp-tests/Resources/Shaders3D/3d_color_tex.frag +++ b/tests/cpp-tests/Resources/Shaders3D/3d_color_tex.frag @@ -4,9 +4,10 @@ varying mediump vec2 TextureCoordOut; varying vec2 TextureCoordOut; #endif uniform vec4 u_color; +uniform sampler2D u_sampler0; void main(void) { - gl_FragColor = texture2D(CC_Texture0, TextureCoordOut) * u_color; + gl_FragColor = texture2D(u_sampler0, TextureCoordOut) * u_color; } diff --git a/tests/cpp-tests/Resources/Shaders3D/OutLine.vert b/tests/cpp-tests/Resources/Shaders3D/OutLine.vert index f4cd386b34..deafa4d387 100644 --- a/tests/cpp-tests/Resources/Shaders3D/OutLine.vert +++ b/tests/cpp-tests/Resources/Shaders3D/OutLine.vert @@ -8,6 +8,6 @@ void main(void) vec4 normalproj = CC_MVPMatrix * vec4(a_normal, 0); normalproj = normalize(normalproj); pos.xy += normalproj.xy * (OutlineWidth * (pos.z * 0.5 + 0.5)); - + gl_Position = pos; } From f97a3474b2c469115bc17a09b2f58c4e5edc2c95 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 5 Jun 2015 23:13:03 +0000 Subject: [PATCH 18/35] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_auto_api.js | 10 ---- .../js-bindings/auto/jsb_cocos2dx_auto.cpp | 19 -------- .../js-bindings/auto/jsb_cocos2dx_auto.hpp | 1 - .../lua-bindings/auto/api/RenderState.lua | 12 ++--- .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 48 ------------------- .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 1 - 6 files changed, 3 insertions(+), 88 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index 21a8f84eaf..dd2b364215 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -19915,16 +19915,6 @@ getStateBlock : function ( return cc.RenderState::StateBlock; }, -/** - * @method getTextures - * @return {Array} - */ -getTextures : function ( -) -{ - return new Array(); -}, - /** * @method initialize */ diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index aa5b597b38..f277da83c9 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -61442,24 +61442,6 @@ bool js_cocos2dx_RenderState_getStateBlock(JSContext *cx, uint32_t argc, jsval * JS_ReportError(cx, "js_cocos2dx_RenderState_getStateBlock : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_RenderState_getTextures(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::RenderState* cobj = (cocos2d::RenderState *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderState_getTextures : Invalid Native Object"); - if (argc == 0) { - const cocos2d::Vector& ret = cobj->getTextures(); - jsval jsret = JSVAL_NULL; - jsret = ccvector_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_RenderState_getTextures : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_RenderState_initialize(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -61515,7 +61497,6 @@ void js_register_cocos2dx_RenderState(JSContext *cx, JS::HandleObject global) { JS_FN("bind", js_cocos2dx_RenderState_bind, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getName", js_cocos2dx_RenderState_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStateBlock", js_cocos2dx_RenderState_getStateBlock, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getTextures", js_cocos2dx_RenderState_getTextures, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index 260cb822c0..78a1d9e6c8 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -3567,7 +3567,6 @@ bool js_cocos2dx_RenderState_getTexture(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_RenderState_bind(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_RenderState_getName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_RenderState_getStateBlock(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_RenderState_getTextures(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_RenderState_initialize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_RenderState_finalize(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/RenderState.lua b/cocos/scripting/lua-bindings/auto/api/RenderState.lua index b10d6e2c7e..c9f29ca8d0 100644 --- a/cocos/scripting/lua-bindings/auto/api/RenderState.lua +++ b/cocos/scripting/lua-bindings/auto/api/RenderState.lua @@ -5,8 +5,8 @@ -- @parent_module cc -------------------------------- --- Replaces the texture that is at the front of _textures array.
--- Added to be backwards compatible. +-- Texture that will use in the CC_Texture0 uniform.
+-- Added to be backwards compatible. Use Samplers from .material instead. -- @function [parent=#RenderState] setTexture -- @param self -- @param #cc.Texture2D texture @@ -20,7 +20,7 @@ -- @return RenderState#RenderState ret (return value: cc.RenderState) -------------------------------- --- Returns the texture that is at the front of the _textures array.
+-- Returns the texture that is going to be used for CC_Texture0.
-- Added to be backwards compatible. -- @function [parent=#RenderState] getTexture -- @param self @@ -46,12 +46,6 @@ -- @param self -- @return RenderState::StateBlock#RenderState::StateBlock ret (return value: cc.RenderState::StateBlock) --------------------------------- --- --- @function [parent=#RenderState] getTextures --- @param self --- @return array_table#array_table ret (return value: array_table) - -------------------------------- -- Static initializer that is called during game startup. -- @function [parent=#RenderState] initialize diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 8064da4c86..5470e176e7 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -81971,53 +81971,6 @@ int lua_cocos2dx_RenderState_getStateBlock(lua_State* tolua_S) return 0; } -int lua_cocos2dx_RenderState_getTextures(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::RenderState* 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.RenderState",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::RenderState*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderState_getTextures'", 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_RenderState_getTextures'", nullptr); - return 0; - } - const cocos2d::Vector& ret = cobj->getTextures(); - ccvector_to_luaval(tolua_S, ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.RenderState:getTextures",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderState_getTextures'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_RenderState_initialize(lua_State* tolua_S) { int argc = 0; @@ -82070,7 +82023,6 @@ int lua_register_cocos2dx_RenderState(lua_State* tolua_S) tolua_function(tolua_S,"bind",lua_cocos2dx_RenderState_bind); tolua_function(tolua_S,"getName",lua_cocos2dx_RenderState_getName); tolua_function(tolua_S,"getStateBlock",lua_cocos2dx_RenderState_getStateBlock); - tolua_function(tolua_S,"getTextures",lua_cocos2dx_RenderState_getTextures); tolua_function(tolua_S,"initialize", lua_cocos2dx_RenderState_initialize); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::RenderState).name(); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 59981d3917..ec6c32737b 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -2051,7 +2051,6 @@ int register_all_cocos2dx(lua_State* tolua_S); - #endif // __cocos2dx_h__ From 4e5f746b4be4a651a0860ae14b89745a3228c23b Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Sun, 7 Jun 2015 20:20:57 -0700 Subject: [PATCH 19/35] updated version to v3-deps-62 --- external/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/config.json b/external/config.json index 4f0f2e4cf1..5f976034bb 100644 --- a/external/config.json +++ b/external/config.json @@ -1,5 +1,5 @@ { - "version":"v3-deps-61", + "version":"v3-deps-62", "zip_file_size":"138162176", "repo_name":"cocos2d-x-3rd-party-libs-bin", "repo_parent":"https://github.com/cocos2d/", From 5b8c51c22fa7025c20c5f92259b8dea42d68606a Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 8 Jun 2015 03:35:39 +0000 Subject: [PATCH 20/35] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_3d_auto_api.js | 14 +- .../api/jsb_cocos2dx_physics3d_auto_api.js | 32 +++- .../js-bindings/auto/jsb_cocos2dx_3d_auto.cpp | 51 +++++-- .../auto/jsb_cocos2dx_physics3d_auto.cpp | 86 ++++++++--- .../auto/jsb_cocos2dx_physics3d_auto.hpp | 6 +- .../lua-bindings/auto/api/Physics3DWorld.lua | 23 ++- .../auto/lua_cocos2dx_physics3d_auto.cpp | 137 +++++++++++++++--- .../auto/lua_cocos2dx_physics3d_auto.hpp | 2 + 8 files changed, 275 insertions(+), 76 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js index b7b36f805e..01716a3a20 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js @@ -1405,14 +1405,16 @@ getTerrainSize : function ( /** * @method getIntersectionPoint - * @param {cc.Ray} arg0 - * @return {vec3_object} - */ -getIntersectionPoint : function ( -ray +* @param {cc.Ray|cc.Ray} ray +* @param {vec3_object} vec3 +* @return {bool|vec3_object} +*/ +getIntersectionPoint : function( +ray, +vec3 ) { - return cc.Vec3; + return false; }, /** diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_physics3d_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_physics3d_auto_api.js index b347ba72e3..86a3561a4f 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_physics3d_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_physics3d_auto_api.js @@ -888,6 +888,16 @@ PhysicsSprite3D : function ( */ cc.Physics3DWorld = { +/** + * @method setGravity + * @param {vec3_object} arg0 + */ +setGravity : function ( +vec3 +) +{ +}, + /** * @method stepSimulate * @param {float} arg0 @@ -929,11 +939,9 @@ physics3dworlddes }, /** - * @method removePhysics3DConstraint - * @param {cc.Physics3DConstraint} arg0 + * @method removeAllPhysics3DObjects */ -removePhysics3DConstraint : function ( -physics3dconstraint +removeAllPhysics3DObjects : function ( ) { }, @@ -973,9 +981,21 @@ hitresult }, /** - * @method removeAllPhysics3DObjects + * @method getGravity + * @return {vec3_object} */ -removeAllPhysics3DObjects : function ( +getGravity : function ( +) +{ + return cc.Vec3; +}, + +/** + * @method removePhysics3DConstraint + * @param {cc.Physics3DConstraint} arg0 + */ +removePhysics3DConstraint : function ( +physics3dconstraint ) { }, diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp index 81928ad133..2179d1bffe 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp @@ -4022,22 +4022,43 @@ bool js_cocos2dx_3d_Terrain_getIntersectionPoint(JSContext *cx, uint32_t argc, j { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getIntersectionPoint : Invalid Native Object"); - if (argc == 1) { - cocos2d::Ray arg0; - ok &= jsval_to_ray(cx, args.get(0), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_getIntersectionPoint : Error processing arguments"); - cocos2d::Vec3 ret = cobj->getIntersectionPoint(arg0); - jsval jsret = JSVAL_NULL; - jsret = vector3_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - JS_ReportError(cx, "js_cocos2dx_3d_Terrain_getIntersectionPoint : wrong number of arguments: %d, was expecting %d", argc, 1); + JS::RootedObject obj(cx); + cocos2d::Terrain* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getIntersectionPoint : Invalid Native Object"); + do { + if (argc == 2) { + cocos2d::Ray arg0; + ok &= jsval_to_ray(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->getIntersectionPoint(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Ray arg0; + ok &= jsval_to_ray(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 ret = cobj->getIntersectionPoint(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_getIntersectionPoint : wrong number of arguments"); return false; } bool js_cocos2dx_3d_Terrain_getNormal(JSContext *cx, uint32_t argc, jsval *vp) diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp index 34104d96da..06526eff62 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp @@ -2280,6 +2280,26 @@ void js_register_cocos2dx_physics3d_PhysicsSprite3D(JSContext *cx, JS::HandleObj JSClass *jsb_cocos2d_Physics3DWorld_class; JSObject *jsb_cocos2d_Physics3DWorld_prototype; +bool js_cocos2dx_physics3d_Physics3DWorld_setGravity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Physics3DWorld* cobj = (cocos2d::Physics3DWorld *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_setGravity : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec3 arg0; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_setGravity : Error processing arguments"); + cobj->setGravity(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_setGravity : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_physics3d_Physics3DWorld_stepSimulate(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -2357,32 +2377,20 @@ bool js_cocos2dx_physics3d_Physics3DWorld_init(JSContext *cx, uint32_t argc, jsv JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_init : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Physics3DWorld* cobj = (cocos2d::Physics3DWorld *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : Invalid Native Object"); - if (argc == 1) { - cocos2d::Physics3DConstraint* arg0; - do { - if (args.get(0).isNull()) { arg0 = nullptr; break; } - if (!args.get(0).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : Error processing arguments"); - cobj->removePhysics3DConstraint(arg0); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllPhysics3DObjects(); args.rval().setUndefined(); return true; } - JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_physics3d_Physics3DWorld_isDebugDrawEnabled(JSContext *cx, uint32_t argc, jsval *vp) @@ -2446,20 +2454,50 @@ bool js_cocos2dx_physics3d_Physics3DWorld_rayCast(JSContext *cx, uint32_t argc, JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_rayCast : wrong number of arguments: %d, was expecting %d", argc, 3); return false; } -bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_physics3d_Physics3DWorld_getGravity(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Physics3DWorld* cobj = (cocos2d::Physics3DWorld *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_getGravity : Invalid Native Object"); if (argc == 0) { - cobj->removeAllPhysics3DObjects(); + cocos2d::Vec3 ret = cobj->getGravity(); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_getGravity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Physics3DWorld* cobj = (cocos2d::Physics3DWorld *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : Invalid Native Object"); + if (argc == 1) { + cocos2d::Physics3DConstraint* arg0; + do { + if (args.get(0).isNull()) { arg0 = nullptr; break; } + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : Error processing arguments"); + cobj->removePhysics3DConstraint(arg0); args.rval().setUndefined(); return true; } - JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DObject(JSContext *cx, uint32_t argc, jsval *vp) @@ -2766,15 +2804,17 @@ void js_register_cocos2dx_physics3d_Physics3DWorld(JSContext *cx, JS::HandleObje }; static JSFunctionSpec funcs[] = { + JS_FN("setGravity", js_cocos2dx_physics3d_Physics3DWorld_setGravity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stepSimulate", js_cocos2dx_physics3d_Physics3DWorld_stepSimulate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("needCollisionChecking", js_cocos2dx_physics3d_Physics3DWorld_needCollisionChecking, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("collisionChecking", js_cocos2dx_physics3d_Physics3DWorld_collisionChecking, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_physics3d_Physics3DWorld_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removePhysics3DConstraint", js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllPhysics3DObjects", js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isDebugDrawEnabled", js_cocos2dx_physics3d_Physics3DWorld_isDebugDrawEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllPhysics3DConstraints", js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DConstraints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("rayCast", js_cocos2dx_physics3d_Physics3DWorld_rayCast, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removeAllPhysics3DObjects", js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGravity", js_cocos2dx_physics3d_Physics3DWorld_getGravity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removePhysics3DConstraint", js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addPhysics3DObject", js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DObject, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDebugDrawEnable", js_cocos2dx_physics3d_Physics3DWorld_setDebugDrawEnable, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removePhysics3DObject", js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DObject, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.hpp index 3fac1aca43..ba6ab0adc9 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.hpp @@ -134,15 +134,17 @@ bool js_cocos2dx_physics3d_Physics3DWorld_constructor(JSContext *cx, uint32_t ar void js_cocos2dx_physics3d_Physics3DWorld_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_physics3d_Physics3DWorld(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx_physics3d(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_physics3d_Physics3DWorld_setGravity(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_stepSimulate(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_needCollisionChecking(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_collisionChecking(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_init(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_isDebugDrawEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DConstraints(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_rayCast(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_physics3d_Physics3DWorld_getGravity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DObject(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_setDebugDrawEnable(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DObject(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/Physics3DWorld.lua b/cocos/scripting/lua-bindings/auto/api/Physics3DWorld.lua index 67257504df..7aff8dadb5 100644 --- a/cocos/scripting/lua-bindings/auto/api/Physics3DWorld.lua +++ b/cocos/scripting/lua-bindings/auto/api/Physics3DWorld.lua @@ -4,6 +4,13 @@ -- @extend Ref -- @parent_module cc +-------------------------------- +-- set gravity for the physics world +-- @function [parent=#Physics3DWorld] setGravity +-- @param self +-- @param #vec3_table gravity +-- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld) + -------------------------------- -- Simulate one frame. -- @function [parent=#Physics3DWorld] stepSimulate @@ -24,10 +31,9 @@ -- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld) -------------------------------- --- Remove a Physics3DConstraint. --- @function [parent=#Physics3DWorld] removePhysics3DConstraint +-- Remove all Physics3DObjects. +-- @function [parent=#Physics3DWorld] removeAllPhysics3DObjects -- @param self --- @param #cc.Physics3DConstraint constraint -- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld) -------------------------------- @@ -43,9 +49,16 @@ -- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld) -------------------------------- --- Remove all Physics3DObjects. --- @function [parent=#Physics3DWorld] removeAllPhysics3DObjects +-- get current gravity +-- @function [parent=#Physics3DWorld] getGravity -- @param self +-- @return vec3_table#vec3_table ret (return value: vec3_table) + +-------------------------------- +-- Remove a Physics3DConstraint. +-- @function [parent=#Physics3DWorld] removePhysics3DConstraint +-- @param self +-- @param #cc.Physics3DConstraint constraint -- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld) -------------------------------- diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.cpp index 115ba9609f..b46047fb8a 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.cpp @@ -3978,6 +3978,56 @@ int lua_register_cocos2dx_physics3d_PhysicsSprite3D(lua_State* tolua_S) return 1; } +int lua_cocos2dx_physics3d_Physics3DWorld_setGravity(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Physics3DWorld* 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.Physics3DWorld",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Physics3DWorld*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_setGravity'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Vec3 arg0; + + ok &= luaval_to_vec3(tolua_S, 2, &arg0, "cc.Physics3DWorld:setGravity"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_setGravity'", nullptr); + return 0; + } + cobj->setGravity(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:setGravity",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_setGravity'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_physics3d_Physics3DWorld_stepSimulate(lua_State* tolua_S) { int argc = 0; @@ -4122,7 +4172,7 @@ int lua_cocos2dx_physics3d_Physics3DWorld_collisionChecking(lua_State* tolua_S) return 0; } -int lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(lua_State* tolua_S) +int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(lua_State* tolua_S) { int argc = 0; cocos2d::Physics3DWorld* cobj = nullptr; @@ -4142,32 +4192,29 @@ int lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(lua_State* t #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 0) { - cocos2d::Physics3DConstraint* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.Physics3DConstraint",&arg0, "cc.Physics3DWorld:removePhysics3DConstraint"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'", nullptr); return 0; } - cobj->removePhysics3DConstraint(arg0); + cobj->removeAllPhysics3DObjects(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:removePhysics3DConstraint",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:removeAllPhysics3DObjects",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'.",&tolua_err); #endif return 0; @@ -4266,7 +4313,7 @@ int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DConstraints(lua_Stat return 0; } -int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(lua_State* tolua_S) +int lua_cocos2dx_physics3d_Physics3DWorld_getGravity(lua_State* tolua_S) { int argc = 0; cocos2d::Physics3DWorld* cobj = nullptr; @@ -4286,7 +4333,7 @@ int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(lua_State* t #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_getGravity'", nullptr); return 0; } #endif @@ -4296,19 +4343,69 @@ int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(lua_State* t { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_getGravity'", nullptr); return 0; } - cobj->removeAllPhysics3DObjects(); - lua_settop(tolua_S, 1); + cocos2d::Vec3 ret = cobj->getGravity(); + vec3_to_luaval(tolua_S, ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:removeAllPhysics3DObjects",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:getGravity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_getGravity'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Physics3DWorld* 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.Physics3DWorld",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Physics3DWorld*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Physics3DConstraint* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.Physics3DConstraint",&arg0, "cc.Physics3DWorld:removePhysics3DConstraint"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'", nullptr); + return 0; + } + cobj->removePhysics3DConstraint(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:removePhysics3DConstraint",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'.",&tolua_err); #endif return 0; @@ -4630,13 +4727,15 @@ int lua_register_cocos2dx_physics3d_Physics3DWorld(lua_State* tolua_S) tolua_beginmodule(tolua_S,"Physics3DWorld"); tolua_function(tolua_S,"new",lua_cocos2dx_physics3d_Physics3DWorld_constructor); + tolua_function(tolua_S,"setGravity",lua_cocos2dx_physics3d_Physics3DWorld_setGravity); tolua_function(tolua_S,"stepSimulate",lua_cocos2dx_physics3d_Physics3DWorld_stepSimulate); tolua_function(tolua_S,"needCollisionChecking",lua_cocos2dx_physics3d_Physics3DWorld_needCollisionChecking); tolua_function(tolua_S,"collisionChecking",lua_cocos2dx_physics3d_Physics3DWorld_collisionChecking); - tolua_function(tolua_S,"removePhysics3DConstraint",lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint); + tolua_function(tolua_S,"removeAllPhysics3DObjects",lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects); tolua_function(tolua_S,"isDebugDrawEnabled",lua_cocos2dx_physics3d_Physics3DWorld_isDebugDrawEnabled); tolua_function(tolua_S,"removeAllPhysics3DConstraints",lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DConstraints); - tolua_function(tolua_S,"removeAllPhysics3DObjects",lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects); + tolua_function(tolua_S,"getGravity",lua_cocos2dx_physics3d_Physics3DWorld_getGravity); + tolua_function(tolua_S,"removePhysics3DConstraint",lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint); tolua_function(tolua_S,"addPhysics3DObject",lua_cocos2dx_physics3d_Physics3DWorld_addPhysics3DObject); tolua_function(tolua_S,"setDebugDrawEnable",lua_cocos2dx_physics3d_Physics3DWorld_setDebugDrawEnable); tolua_function(tolua_S,"removePhysics3DObject",lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DObject); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.hpp index 0685ba505a..e2345e5253 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.hpp @@ -253,6 +253,8 @@ int register_all_cocos2dx_physics3d(lua_State* tolua_S); + + From 87dab42255e67137a3b9892c72a1fa2d12c53453 Mon Sep 17 00:00:00 2001 From: tangziwen Date: Fri, 22 May 2015 09:07:57 +0800 Subject: [PATCH 21/35] fix Terrain::getIntersectionPoint --- cocos/3d/CCTerrain.cpp | 51 ++++++++++++++++++++++++++++++++++++++++-- cocos/3d/CCTerrain.h | 2 ++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp index a309052a98..d3ddf1079d 100644 --- a/cocos/3d/CCTerrain.cpp +++ b/cocos/3d/CCTerrain.cpp @@ -308,6 +308,10 @@ float Terrain::getHeight(float x, float z, Vec3 * normal) if(image_x>=_imageWidth-1 || image_y >=_imageHeight-1 || image_x<0 || image_y<0) { return 0; + if (normal) + { + normal->setZero(); + } }else { float a = getImageHeight(i,j)*getScaleY(); @@ -496,12 +500,14 @@ cocos2d::Vec3 Terrain::getIntersectionPoint(const Ray & ray) Vec3 lastRayPosition =rayPos; rayPos += rayStep; // Linear search - Loop until find a point inside and outside the terrain Vector3 - float height = getHeight(rayPos.x,rayPos.z); - + Vec3 normal; + float height = getHeight(rayPos.x, rayPos.z, &normal); while (rayPos.y > height) { lastRayPosition = rayPos; rayPos += rayStep; + if (normal.isZero()) + return Vec3(0, 0, 0); height = getHeight(rayPos.x,rayPos.z); } @@ -521,6 +527,47 @@ cocos2d::Vec3 Terrain::getIntersectionPoint(const Ray & ray) return collisionPoint; } +bool Terrain::getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) +{ + Vec3 dir = ray._direction; + dir.normalize(); + Vec3 rayStep = _terrainData._chunkSize.width*0.25*dir; + Vec3 rayPos = ray._origin; + Vec3 rayStartPosition = ray._origin; + Vec3 lastRayPosition = rayPos; + rayPos += rayStep; + // Linear search - Loop until find a point inside and outside the terrain Vector3 + Vec3 normal; + float height = getHeight(rayPos.x, rayPos.z, &normal); + while (rayPos.y > height) + { + lastRayPosition = rayPos; + rayPos += rayStep; + if (normal.isZero()) + { + intersectionPoint = Vec3(0, 0, 0); + return false; + } + height = getHeight(rayPos.x, rayPos.z); + } + + Vec3 startPosition = lastRayPosition; + Vec3 endPosition = rayPos; + + for (int i = 0; i < 32; i++) + { + // Binary search pass + Vec3 middlePoint = (startPosition + endPosition) * 0.5f; + if (middlePoint.y < height) + endPosition = middlePoint; + else + startPosition = middlePoint; + } + Vec3 collisionPoint = (startPosition + endPosition) * 0.5f; + intersectionPoint = collisionPoint; + return true; +} + void Terrain::setMaxDetailMapAmount(int max_value) { _maxDetailMapValue = max_value; diff --git a/cocos/3d/CCTerrain.h b/cocos/3d/CCTerrain.h index d06e1005d1..5a7fdd0d05 100644 --- a/cocos/3d/CCTerrain.h +++ b/cocos/3d/CCTerrain.h @@ -346,6 +346,8 @@ public: */ Vec3 getIntersectionPoint(const Ray & ray); + bool getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint); + /** * set the MaxDetailAmount. */ From 076c3a8d9056929e4ae8c1aba3f264b831803520 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Wed, 27 May 2015 18:07:31 +0800 Subject: [PATCH 22/35] get set gravity --- cocos/physics3d/CCPhysics3DWorld.cpp | 10 ++++++++++ cocos/physics3d/CCPhysics3DWorld.h | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/cocos/physics3d/CCPhysics3DWorld.cpp b/cocos/physics3d/CCPhysics3DWorld.cpp index f3cd4f35d9..5ca5c5ea7b 100644 --- a/cocos/physics3d/CCPhysics3DWorld.cpp +++ b/cocos/physics3d/CCPhysics3DWorld.cpp @@ -67,6 +67,16 @@ Physics3DWorld* Physics3DWorld::create(Physics3DWorldDes* info) return world; } +void Physics3DWorld::setGravity(const Vec3& gravity) +{ + _btPhyiscsWorld->setGravity(convertVec3TobtVector3(gravity)); +} + +Vec3 Physics3DWorld::getGravity() const +{ + return convertbtVector3ToVec3(_btPhyiscsWorld->getGravity()); +} + bool Physics3DWorld::init(Physics3DWorldDes* info) { ///collision configuration contains default setup for memory, collision setup diff --git a/cocos/physics3d/CCPhysics3DWorld.h b/cocos/physics3d/CCPhysics3DWorld.h index b238de3ebf..23c7b601ff 100644 --- a/cocos/physics3d/CCPhysics3DWorld.h +++ b/cocos/physics3d/CCPhysics3DWorld.h @@ -90,6 +90,12 @@ public: */ static Physics3DWorld* create(Physics3DWorldDes* info); + /** set gravity for the physics world */ + void setGravity(const Vec3& gravity); + + /** get current gravity */ + Vec3 getGravity() const; + /** Add a Physics3DObject. */ void addPhysics3DObject(Physics3DObject* physicsObj); From f9cc7fec0ebe54fdb7c68f0407e01d0cb74d8655 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Wed, 27 May 2015 18:19:44 +0800 Subject: [PATCH 23/35] code style --- cocos/3d/CCTerrain.cpp | 14 +++++++------- cocos/3d/CCTerrain.h | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp index d3ddf1079d..c44e8424d8 100644 --- a/cocos/3d/CCTerrain.cpp +++ b/cocos/3d/CCTerrain.cpp @@ -278,7 +278,7 @@ void Terrain::setChunksLOD(Vec3 cameraPos) } } -float Terrain::getHeight(float x, float z, Vec3 * normal) +float Terrain::getHeight(float x, float z, Vec3 * normal) const { Vec2 pos(x,z); @@ -307,11 +307,11 @@ float Terrain::getHeight(float x, float z, Vec3 * normal) if(image_x>=_imageWidth-1 || image_y >=_imageHeight-1 || image_x<0 || image_y<0) { - return 0; if (normal) { normal->setZero(); } + return 0; }else { float a = getImageHeight(i,j)*getScaleY(); @@ -331,12 +331,12 @@ float Terrain::getHeight(float x, float z, Vec3 * normal) } } -float Terrain::getHeight(Vec2 pos, Vec3*Normal) +float Terrain::getHeight(Vec2 pos, Vec3*Normal) const { return getHeight(pos.x,pos.y,Normal); } -float Terrain::getImageHeight(int pixel_x,int pixel_y) +float Terrain::getImageHeight(int pixel_x,int pixel_y) const { int byte_stride =1; switch (_heightMapImage->getRenderFormat()) @@ -476,7 +476,7 @@ Terrain::~Terrain() #endif } -cocos2d::Vec3 Terrain::getNormal(int pixel_x, int pixel_y) +cocos2d::Vec3 Terrain::getNormal(int pixel_x, int pixel_y) const { float a = getImageHeight(pixel_x,pixel_y)*getScaleY(); float b = getImageHeight(pixel_x,pixel_y+1)*getScaleY(); @@ -490,7 +490,7 @@ cocos2d::Vec3 Terrain::getNormal(int pixel_x, int pixel_y) return normal; } -cocos2d::Vec3 Terrain::getIntersectionPoint(const Ray & ray) +cocos2d::Vec3 Terrain::getIntersectionPoint(const Ray & ray) const { Vec3 dir = ray._direction; dir.normalize(); @@ -527,7 +527,7 @@ cocos2d::Vec3 Terrain::getIntersectionPoint(const Ray & ray) return collisionPoint; } -bool Terrain::getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) +bool Terrain::getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) const { Vec3 dir = ray._direction; dir.normalize(); diff --git a/cocos/3d/CCTerrain.h b/cocos/3d/CCTerrain.h index 5a7fdd0d05..c7ad20d7ac 100644 --- a/cocos/3d/CCTerrain.h +++ b/cocos/3d/CCTerrain.h @@ -302,22 +302,22 @@ public: * @param normal the specified position's normal vector in terrain . if this argument is NULL or nullptr,Normal calculation shall be skip. * @return the height value of the specified position of the terrain, if the (X,Z) position is out of the terrain bounds,it shall return 0; **/ - float getHeight(float x, float z, Vec3 * normal= nullptr); + float getHeight(float x, float z, Vec3 * normal= nullptr) const; /**get specified position's height mapping to the terrain,use bi-linear interpolation method * @param pos the position (X,Z) * @param normal the specified position's normal vector in terrain . if this argument is NULL or nullptr,Normal calculation shall be skip. * @return the height value of the specified position of the terrain, if the (X,Z) position is out of the terrain bounds,it shall return 0; **/ - float getHeight(Vec2 pos, Vec3*Normal = nullptr); + float getHeight(Vec2 pos, Vec3*Normal = nullptr) const; /**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. **/ - Vec3 getNormal(int pixelX, int pixelY); + Vec3 getNormal(int pixelX, int pixelY) const; /**get height from the raw height filed*/ - float getImageHeight(int pixelX, int pixelY); + float getImageHeight(int pixelX, int pixelY) const; /**show the wireline instead of the surface,Debug Use only. * @Note only support desktop platform **/ @@ -344,9 +344,9 @@ public: * Ray-Terrain intersection. * @return the intersection point */ - Vec3 getIntersectionPoint(const Ray & ray); + Vec3 getIntersectionPoint(const Ray & ray) const; - bool getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint); + bool getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) const; /** * set the MaxDetailAmount. From 3fa17c28dfd263130fbbb96db919bd11cb93b6e0 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Thu, 28 May 2015 12:40:16 +0800 Subject: [PATCH 24/35] add comment --- cocos/3d/CCTerrain.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cocos/3d/CCTerrain.h b/cocos/3d/CCTerrain.h index c7ad20d7ac..5f678b3795 100644 --- a/cocos/3d/CCTerrain.h +++ b/cocos/3d/CCTerrain.h @@ -346,6 +346,12 @@ public: */ Vec3 getIntersectionPoint(const Ray & ray) const; + /** + * Ray-Terrain intersection. + * @param ray to hit the terrain + * @param intersectionPoint hit point if hitted + * @return true if hit, false otherwise + */ bool getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) const; /** From 4fc0366e4d5eb4dd41f2c5fa99247e2e5ef87de3 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 8 Jun 2015 06:21:14 +0000 Subject: [PATCH 25/35] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_3d_auto_api.js | 14 +- .../api/jsb_cocos2dx_physics3d_auto_api.js | 32 +++- .../js-bindings/auto/jsb_cocos2dx_3d_auto.cpp | 51 +++++-- .../auto/jsb_cocos2dx_physics3d_auto.cpp | 86 ++++++++--- .../auto/jsb_cocos2dx_physics3d_auto.hpp | 6 +- .../lua-bindings/auto/api/Physics3DWorld.lua | 23 ++- .../auto/lua_cocos2dx_physics3d_auto.cpp | 137 +++++++++++++++--- .../auto/lua_cocos2dx_physics3d_auto.hpp | 2 + 8 files changed, 275 insertions(+), 76 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js index b7b36f805e..01716a3a20 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js @@ -1405,14 +1405,16 @@ getTerrainSize : function ( /** * @method getIntersectionPoint - * @param {cc.Ray} arg0 - * @return {vec3_object} - */ -getIntersectionPoint : function ( -ray +* @param {cc.Ray|cc.Ray} ray +* @param {vec3_object} vec3 +* @return {bool|vec3_object} +*/ +getIntersectionPoint : function( +ray, +vec3 ) { - return cc.Vec3; + return false; }, /** diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_physics3d_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_physics3d_auto_api.js index b347ba72e3..86a3561a4f 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_physics3d_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_physics3d_auto_api.js @@ -888,6 +888,16 @@ PhysicsSprite3D : function ( */ cc.Physics3DWorld = { +/** + * @method setGravity + * @param {vec3_object} arg0 + */ +setGravity : function ( +vec3 +) +{ +}, + /** * @method stepSimulate * @param {float} arg0 @@ -929,11 +939,9 @@ physics3dworlddes }, /** - * @method removePhysics3DConstraint - * @param {cc.Physics3DConstraint} arg0 + * @method removeAllPhysics3DObjects */ -removePhysics3DConstraint : function ( -physics3dconstraint +removeAllPhysics3DObjects : function ( ) { }, @@ -973,9 +981,21 @@ hitresult }, /** - * @method removeAllPhysics3DObjects + * @method getGravity + * @return {vec3_object} */ -removeAllPhysics3DObjects : function ( +getGravity : function ( +) +{ + return cc.Vec3; +}, + +/** + * @method removePhysics3DConstraint + * @param {cc.Physics3DConstraint} arg0 + */ +removePhysics3DConstraint : function ( +physics3dconstraint ) { }, diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp index 81928ad133..2179d1bffe 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp @@ -4022,22 +4022,43 @@ bool js_cocos2dx_3d_Terrain_getIntersectionPoint(JSContext *cx, uint32_t argc, j { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getIntersectionPoint : Invalid Native Object"); - if (argc == 1) { - cocos2d::Ray arg0; - ok &= jsval_to_ray(cx, args.get(0), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_getIntersectionPoint : Error processing arguments"); - cocos2d::Vec3 ret = cobj->getIntersectionPoint(arg0); - jsval jsret = JSVAL_NULL; - jsret = vector3_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - JS_ReportError(cx, "js_cocos2dx_3d_Terrain_getIntersectionPoint : wrong number of arguments: %d, was expecting %d", argc, 1); + JS::RootedObject obj(cx); + cocos2d::Terrain* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getIntersectionPoint : Invalid Native Object"); + do { + if (argc == 2) { + cocos2d::Ray arg0; + ok &= jsval_to_ray(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->getIntersectionPoint(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Ray arg0; + ok &= jsval_to_ray(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 ret = cobj->getIntersectionPoint(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_getIntersectionPoint : wrong number of arguments"); return false; } bool js_cocos2dx_3d_Terrain_getNormal(JSContext *cx, uint32_t argc, jsval *vp) diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp index 34104d96da..06526eff62 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp @@ -2280,6 +2280,26 @@ void js_register_cocos2dx_physics3d_PhysicsSprite3D(JSContext *cx, JS::HandleObj JSClass *jsb_cocos2d_Physics3DWorld_class; JSObject *jsb_cocos2d_Physics3DWorld_prototype; +bool js_cocos2dx_physics3d_Physics3DWorld_setGravity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Physics3DWorld* cobj = (cocos2d::Physics3DWorld *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_setGravity : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec3 arg0; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_setGravity : Error processing arguments"); + cobj->setGravity(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_setGravity : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_physics3d_Physics3DWorld_stepSimulate(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -2357,32 +2377,20 @@ bool js_cocos2dx_physics3d_Physics3DWorld_init(JSContext *cx, uint32_t argc, jsv JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_init : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Physics3DWorld* cobj = (cocos2d::Physics3DWorld *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : Invalid Native Object"); - if (argc == 1) { - cocos2d::Physics3DConstraint* arg0; - do { - if (args.get(0).isNull()) { arg0 = nullptr; break; } - if (!args.get(0).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : Error processing arguments"); - cobj->removePhysics3DConstraint(arg0); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllPhysics3DObjects(); args.rval().setUndefined(); return true; } - JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_physics3d_Physics3DWorld_isDebugDrawEnabled(JSContext *cx, uint32_t argc, jsval *vp) @@ -2446,20 +2454,50 @@ bool js_cocos2dx_physics3d_Physics3DWorld_rayCast(JSContext *cx, uint32_t argc, JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_rayCast : wrong number of arguments: %d, was expecting %d", argc, 3); return false; } -bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_physics3d_Physics3DWorld_getGravity(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Physics3DWorld* cobj = (cocos2d::Physics3DWorld *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_getGravity : Invalid Native Object"); if (argc == 0) { - cobj->removeAllPhysics3DObjects(); + cocos2d::Vec3 ret = cobj->getGravity(); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_getGravity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Physics3DWorld* cobj = (cocos2d::Physics3DWorld *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : Invalid Native Object"); + if (argc == 1) { + cocos2d::Physics3DConstraint* arg0; + do { + if (args.get(0).isNull()) { arg0 = nullptr; break; } + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : Error processing arguments"); + cobj->removePhysics3DConstraint(arg0); args.rval().setUndefined(); return true; } - JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DObject(JSContext *cx, uint32_t argc, jsval *vp) @@ -2766,15 +2804,17 @@ void js_register_cocos2dx_physics3d_Physics3DWorld(JSContext *cx, JS::HandleObje }; static JSFunctionSpec funcs[] = { + JS_FN("setGravity", js_cocos2dx_physics3d_Physics3DWorld_setGravity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stepSimulate", js_cocos2dx_physics3d_Physics3DWorld_stepSimulate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("needCollisionChecking", js_cocos2dx_physics3d_Physics3DWorld_needCollisionChecking, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("collisionChecking", js_cocos2dx_physics3d_Physics3DWorld_collisionChecking, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_physics3d_Physics3DWorld_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removePhysics3DConstraint", js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllPhysics3DObjects", js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isDebugDrawEnabled", js_cocos2dx_physics3d_Physics3DWorld_isDebugDrawEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllPhysics3DConstraints", js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DConstraints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("rayCast", js_cocos2dx_physics3d_Physics3DWorld_rayCast, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removeAllPhysics3DObjects", js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGravity", js_cocos2dx_physics3d_Physics3DWorld_getGravity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removePhysics3DConstraint", js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addPhysics3DObject", js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DObject, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDebugDrawEnable", js_cocos2dx_physics3d_Physics3DWorld_setDebugDrawEnable, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removePhysics3DObject", js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DObject, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.hpp index 3fac1aca43..ba6ab0adc9 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.hpp @@ -134,15 +134,17 @@ bool js_cocos2dx_physics3d_Physics3DWorld_constructor(JSContext *cx, uint32_t ar void js_cocos2dx_physics3d_Physics3DWorld_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_physics3d_Physics3DWorld(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx_physics3d(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_physics3d_Physics3DWorld_setGravity(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_stepSimulate(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_needCollisionChecking(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_collisionChecking(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_init(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_isDebugDrawEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DConstraints(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_rayCast(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_physics3d_Physics3DWorld_getGravity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DObject(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_setDebugDrawEnable(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DObject(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/Physics3DWorld.lua b/cocos/scripting/lua-bindings/auto/api/Physics3DWorld.lua index 67257504df..7aff8dadb5 100644 --- a/cocos/scripting/lua-bindings/auto/api/Physics3DWorld.lua +++ b/cocos/scripting/lua-bindings/auto/api/Physics3DWorld.lua @@ -4,6 +4,13 @@ -- @extend Ref -- @parent_module cc +-------------------------------- +-- set gravity for the physics world +-- @function [parent=#Physics3DWorld] setGravity +-- @param self +-- @param #vec3_table gravity +-- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld) + -------------------------------- -- Simulate one frame. -- @function [parent=#Physics3DWorld] stepSimulate @@ -24,10 +31,9 @@ -- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld) -------------------------------- --- Remove a Physics3DConstraint. --- @function [parent=#Physics3DWorld] removePhysics3DConstraint +-- Remove all Physics3DObjects. +-- @function [parent=#Physics3DWorld] removeAllPhysics3DObjects -- @param self --- @param #cc.Physics3DConstraint constraint -- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld) -------------------------------- @@ -43,9 +49,16 @@ -- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld) -------------------------------- --- Remove all Physics3DObjects. --- @function [parent=#Physics3DWorld] removeAllPhysics3DObjects +-- get current gravity +-- @function [parent=#Physics3DWorld] getGravity -- @param self +-- @return vec3_table#vec3_table ret (return value: vec3_table) + +-------------------------------- +-- Remove a Physics3DConstraint. +-- @function [parent=#Physics3DWorld] removePhysics3DConstraint +-- @param self +-- @param #cc.Physics3DConstraint constraint -- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld) -------------------------------- diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.cpp index 115ba9609f..b46047fb8a 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.cpp @@ -3978,6 +3978,56 @@ int lua_register_cocos2dx_physics3d_PhysicsSprite3D(lua_State* tolua_S) return 1; } +int lua_cocos2dx_physics3d_Physics3DWorld_setGravity(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Physics3DWorld* 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.Physics3DWorld",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Physics3DWorld*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_setGravity'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Vec3 arg0; + + ok &= luaval_to_vec3(tolua_S, 2, &arg0, "cc.Physics3DWorld:setGravity"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_setGravity'", nullptr); + return 0; + } + cobj->setGravity(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:setGravity",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_setGravity'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_physics3d_Physics3DWorld_stepSimulate(lua_State* tolua_S) { int argc = 0; @@ -4122,7 +4172,7 @@ int lua_cocos2dx_physics3d_Physics3DWorld_collisionChecking(lua_State* tolua_S) return 0; } -int lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(lua_State* tolua_S) +int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(lua_State* tolua_S) { int argc = 0; cocos2d::Physics3DWorld* cobj = nullptr; @@ -4142,32 +4192,29 @@ int lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(lua_State* t #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 0) { - cocos2d::Physics3DConstraint* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.Physics3DConstraint",&arg0, "cc.Physics3DWorld:removePhysics3DConstraint"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'", nullptr); return 0; } - cobj->removePhysics3DConstraint(arg0); + cobj->removeAllPhysics3DObjects(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:removePhysics3DConstraint",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:removeAllPhysics3DObjects",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'.",&tolua_err); #endif return 0; @@ -4266,7 +4313,7 @@ int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DConstraints(lua_Stat return 0; } -int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(lua_State* tolua_S) +int lua_cocos2dx_physics3d_Physics3DWorld_getGravity(lua_State* tolua_S) { int argc = 0; cocos2d::Physics3DWorld* cobj = nullptr; @@ -4286,7 +4333,7 @@ int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(lua_State* t #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_getGravity'", nullptr); return 0; } #endif @@ -4296,19 +4343,69 @@ int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(lua_State* t { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_getGravity'", nullptr); return 0; } - cobj->removeAllPhysics3DObjects(); - lua_settop(tolua_S, 1); + cocos2d::Vec3 ret = cobj->getGravity(); + vec3_to_luaval(tolua_S, ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:removeAllPhysics3DObjects",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:getGravity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_getGravity'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Physics3DWorld* 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.Physics3DWorld",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Physics3DWorld*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Physics3DConstraint* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.Physics3DConstraint",&arg0, "cc.Physics3DWorld:removePhysics3DConstraint"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'", nullptr); + return 0; + } + cobj->removePhysics3DConstraint(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:removePhysics3DConstraint",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'.",&tolua_err); #endif return 0; @@ -4630,13 +4727,15 @@ int lua_register_cocos2dx_physics3d_Physics3DWorld(lua_State* tolua_S) tolua_beginmodule(tolua_S,"Physics3DWorld"); tolua_function(tolua_S,"new",lua_cocos2dx_physics3d_Physics3DWorld_constructor); + tolua_function(tolua_S,"setGravity",lua_cocos2dx_physics3d_Physics3DWorld_setGravity); tolua_function(tolua_S,"stepSimulate",lua_cocos2dx_physics3d_Physics3DWorld_stepSimulate); tolua_function(tolua_S,"needCollisionChecking",lua_cocos2dx_physics3d_Physics3DWorld_needCollisionChecking); tolua_function(tolua_S,"collisionChecking",lua_cocos2dx_physics3d_Physics3DWorld_collisionChecking); - tolua_function(tolua_S,"removePhysics3DConstraint",lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint); + tolua_function(tolua_S,"removeAllPhysics3DObjects",lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects); tolua_function(tolua_S,"isDebugDrawEnabled",lua_cocos2dx_physics3d_Physics3DWorld_isDebugDrawEnabled); tolua_function(tolua_S,"removeAllPhysics3DConstraints",lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DConstraints); - tolua_function(tolua_S,"removeAllPhysics3DObjects",lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects); + tolua_function(tolua_S,"getGravity",lua_cocos2dx_physics3d_Physics3DWorld_getGravity); + tolua_function(tolua_S,"removePhysics3DConstraint",lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint); tolua_function(tolua_S,"addPhysics3DObject",lua_cocos2dx_physics3d_Physics3DWorld_addPhysics3DObject); tolua_function(tolua_S,"setDebugDrawEnable",lua_cocos2dx_physics3d_Physics3DWorld_setDebugDrawEnable); tolua_function(tolua_S,"removePhysics3DObject",lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DObject); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.hpp index 0685ba505a..e2345e5253 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.hpp @@ -253,6 +253,8 @@ int register_all_cocos2dx_physics3d(lua_State* tolua_S); + + From f4d6d057871f054063ea6e0bdf918147294840f2 Mon Sep 17 00:00:00 2001 From: andyque Date: Thu, 4 Jun 2015 18:24:47 +0800 Subject: [PATCH 26/35] update changelog --- CHANGELOG | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 31e291c659..6d0ad12a78 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,7 +24,7 @@ cocos2d-x-3.7 ?? [FIX] audio: Fixed program may freeze if `AudioEngine::stop` or `AudioEngine::stopAll()` is invoked frequently on Android [FIX] audio: Fixed audio can't resume if it is interrupted by an incoming phone call. [FIX] audio: Fixed SimpleAudioEngine::playEffect() lagged on Android 5.0.x - [FIX] ui: TextField scale factor is wrong with multiline text. + [FIX] ui: Text scale factor is wrong with multiline text. [FIX] 3d: skybox can't move to other position except origin point in world space [FIX] 3d: terrain can't move to other position except origin point in world space [FIX] 3rd: fix PIE link error on iOS caused by libpng and libtiff @@ -35,6 +35,7 @@ cocos2d-x-3.7 ?? [FIX] Label: position is wrong if label content is changed after invoking `getLetter(letterIndex)` [FIX] Label: shadow effect cause OpenGL error on iOS [FIX] Label: outline effect doesn't match characters well + [FIX] Label: Fixed system font label line height calculation is wrong on Android. [FIX] ProgressTimer: `setSprite()` doesn't take effect [FIX] Sprite3D: setGLProgram() does not work [FIX] Sprite3D: transition breaks when there is a Sprite3D in the scene From 9721621ecca0ffbb9885240593d6f3794af530e6 Mon Sep 17 00:00:00 2001 From: andyque Date: Mon, 8 Jun 2015 17:30:59 +0800 Subject: [PATCH 27/35] update changelog and authors --- AUTHORS | 3 +++ CHANGELOG | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index a64e2a8252..8927688026 100644 --- a/AUTHORS +++ b/AUTHORS @@ -69,6 +69,9 @@ Developers: silverscania Pass correct parameter to glPixelStorei when creating a texture + stari4ek + Fix VideoPlayer on Android ignore search paths + FlagellumDei Center the window correctly on windows diff --git a/CHANGELOG b/CHANGELOG index 6d0ad12a78..d2177903e8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,7 +20,8 @@ cocos2d-x-3.7 ?? [NEW] win10: Added Windows 10.0 Universal App(UWP) support. [FIX] network: Fix memory leak of HttpClient on iOS and Mac platform. - [FIX] android++: Improve UserDefault's robustness, now the converting behavior is the same as iOS platform. + [FIX] android: Improve UserDefault's robustness, now the converting behavior is the same as iOS platform. + [FIX] android: Fix VideoPlayer on Android ignore search paths. [FIX] audio: Fixed program may freeze if `AudioEngine::stop` or `AudioEngine::stopAll()` is invoked frequently on Android [FIX] audio: Fixed audio can't resume if it is interrupted by an incoming phone call. [FIX] audio: Fixed SimpleAudioEngine::playEffect() lagged on Android 5.0.x From dae8f788c175e096216e7c7311396839e057ddc4 Mon Sep 17 00:00:00 2001 From: Michael Sotnikov Date: Mon, 8 Jun 2015 12:56:43 +0300 Subject: [PATCH 28/35] improve rendering of inner shapes when outline is used --- cocos/renderer/ccShader_Label_outline.frag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/renderer/ccShader_Label_outline.frag b/cocos/renderer/ccShader_Label_outline.frag index 4395e90910..3b01c0a365 100644 --- a/cocos/renderer/ccShader_Label_outline.frag +++ b/cocos/renderer/ccShader_Label_outline.frag @@ -17,7 +17,7 @@ void main() vec4 sample = texture2D(CC_Texture0, v_texCoord); float fontAlpha = sample.a; float outlineAlpha = sample.r; - if (outlineAlpha > 0.0){ + if ((fontAlpha + outlineAlpha) > 0.0){ vec4 color = u_textColor * fontAlpha + u_effectColor * (1.0 - fontAlpha); gl_FragColor = v_fragmentColor * vec4( color.rgb,max(fontAlpha,outlineAlpha)*color.a); } From f3afd51ff52649f4559c84417dc2f509c4ed10bd Mon Sep 17 00:00:00 2001 From: Zachary Lester Date: Mon, 8 Jun 2015 23:28:30 -0700 Subject: [PATCH 29/35] Fix typo in AUTHORS.txt Altered sentence explaining how authors were ordered so as to fix its grammar and more clearly convey its meaning. --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 8927688026..0e3bb44364 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,6 +1,6 @@ cocos2d-x authors & contributors -(ordered by the join in time) +(ordered by join time) Core Developers: Ricardo Quesada From f6083f34900202dd3863f28b8ea9f46e7f8b64b1 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Tue, 9 Jun 2015 14:38:48 +0800 Subject: [PATCH 30/35] Fix issue 10258 & 10408 --- cocos/editor-support/cocostudio/CCActionNode.cpp | 2 ++ cocos/editor-support/cocostudio/CocoLoader.cpp | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCActionNode.cpp b/cocos/editor-support/cocostudio/CCActionNode.cpp index aa30b2b2fe..f963a242f2 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.cpp +++ b/cocos/editor-support/cocostudio/CCActionNode.cpp @@ -60,6 +60,7 @@ ActionNode::~ActionNode() else { CC_SAFE_RELEASE_NULL(_action); + CC_SAFE_RELEASE_NULL(_actionSpawn); } for (auto object : _frameArray) @@ -464,6 +465,7 @@ Spawn * ActionNode::refreshActionProperty() else { CC_SAFE_RELEASE_NULL(_action); + CC_SAFE_RELEASE_NULL(_actionSpawn); } _actionSpawn = Spawn::create(cSpawnArray); diff --git a/cocos/editor-support/cocostudio/CocoLoader.cpp b/cocos/editor-support/cocostudio/CocoLoader.cpp index 41bafa1392..173fc52d5c 100644 --- a/cocos/editor-support/cocostudio/CocoLoader.cpp +++ b/cocos/editor-support/cocostudio/CocoLoader.cpp @@ -177,15 +177,19 @@ bool CocoLoader::ReadCocoBinBuff(char* pBinBuff) pTempBuff += sizeof(stCocoFileHeader); char* pStartAddr = m_pMemoryBuff = pTempBuff; - if( m_pFileHeader->m_nCompressSize > 0 ) + char* pDestBuff = new char[m_pFileHeader->m_nDataSize]; + if (m_pFileHeader->m_nCompressSize > 0) { - char* pDestBuff = new char[m_pFileHeader->m_nDataSize]; uLongf dwSrcSize = m_pFileHeader->m_nCompressSize; uLongf dwDestSize = m_pFileHeader->m_nDataSize; uncompress((Bytef*)pDestBuff,&dwDestSize,(Bytef*)m_pMemoryBuff,dwSrcSize); - pStartAddr = m_pMemoryBuff = pDestBuff; } - + else + { + memcpy(pDestBuff, m_pMemoryBuff, m_pFileHeader->m_nDataSize); + } + pStartAddr = m_pMemoryBuff = pDestBuff; + m_pObjectDescArray = (stExpCocoObjectDesc*)pStartAddr; char* pCocoMemAddr = pStartAddr + m_pFileHeader->m_CocoNodeMemAddr; From 20a6151f4cee03e453a20aca91286a7fd57b4450 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Tue, 9 Jun 2015 17:40:42 +0800 Subject: [PATCH 31/35] Fix indent --- cocos/editor-support/cocostudio/CocoLoader.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos/editor-support/cocostudio/CocoLoader.cpp b/cocos/editor-support/cocostudio/CocoLoader.cpp index 173fc52d5c..5cef34224c 100644 --- a/cocos/editor-support/cocostudio/CocoLoader.cpp +++ b/cocos/editor-support/cocostudio/CocoLoader.cpp @@ -177,19 +177,19 @@ bool CocoLoader::ReadCocoBinBuff(char* pBinBuff) pTempBuff += sizeof(stCocoFileHeader); char* pStartAddr = m_pMemoryBuff = pTempBuff; - char* pDestBuff = new char[m_pFileHeader->m_nDataSize]; - if (m_pFileHeader->m_nCompressSize > 0) + char* pDestBuff = new char[m_pFileHeader->m_nDataSize]; + if (m_pFileHeader->m_nCompressSize > 0) { uLongf dwSrcSize = m_pFileHeader->m_nCompressSize; uLongf dwDestSize = m_pFileHeader->m_nDataSize; uncompress((Bytef*)pDestBuff,&dwDestSize,(Bytef*)m_pMemoryBuff,dwSrcSize); } - else - { - memcpy(pDestBuff, m_pMemoryBuff, m_pFileHeader->m_nDataSize); - } - pStartAddr = m_pMemoryBuff = pDestBuff; - + else + { + memcpy(pDestBuff, m_pMemoryBuff, m_pFileHeader->m_nDataSize); + } + pStartAddr = m_pMemoryBuff = pDestBuff; + m_pObjectDescArray = (stExpCocoObjectDesc*)pStartAddr; char* pCocoMemAddr = pStartAddr + m_pFileHeader->m_CocoNodeMemAddr; From fc34881ab9dd30f9800c3451bd844554ec24c697 Mon Sep 17 00:00:00 2001 From: tangziwen Date: Fri, 22 May 2015 09:07:57 +0800 Subject: [PATCH 32/35] fix Terrain::getIntersectionPoint --- cocos/3d/CCTerrain.cpp | 4 ++++ cocos/3d/CCTerrain.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp index c44e8424d8..3f03df5855 100644 --- a/cocos/3d/CCTerrain.cpp +++ b/cocos/3d/CCTerrain.cpp @@ -312,6 +312,10 @@ float Terrain::getHeight(float x, float z, Vec3 * normal) const normal->setZero(); } return 0; + if (normal) + { + normal->setZero(); + } }else { float a = getImageHeight(i,j)*getScaleY(); diff --git a/cocos/3d/CCTerrain.h b/cocos/3d/CCTerrain.h index 5f678b3795..0c2879f3ee 100644 --- a/cocos/3d/CCTerrain.h +++ b/cocos/3d/CCTerrain.h @@ -354,6 +354,8 @@ public: */ bool getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) const; + bool getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint); + /** * set the MaxDetailAmount. */ From 7f26ccb9ba9400cfc7774701e9dc3a136a5695eb Mon Sep 17 00:00:00 2001 From: yangxiao Date: Wed, 27 May 2015 18:19:44 +0800 Subject: [PATCH 33/35] code style --- cocos/3d/CCTerrain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp index 3f03df5855..05acb0c4c8 100644 --- a/cocos/3d/CCTerrain.cpp +++ b/cocos/3d/CCTerrain.cpp @@ -547,7 +547,7 @@ bool Terrain::getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) co { lastRayPosition = rayPos; rayPos += rayStep; - if (normal.isZero()) + if (normal.isZero { intersectionPoint = Vec3(0, 0, 0); return false; From 3f4d1c4ed35a70057c27d9c4e98d8be98c6b0d35 Mon Sep 17 00:00:00 2001 From: "anniruddh.koppal" Date: Tue, 9 Jun 2015 14:04:11 -0700 Subject: [PATCH 34/35] Fixed merge conflict issue --- cocos/3d/CCTerrain.cpp | 6 +----- cocos/3d/CCTerrain.h | 2 -- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp index 05acb0c4c8..c44e8424d8 100644 --- a/cocos/3d/CCTerrain.cpp +++ b/cocos/3d/CCTerrain.cpp @@ -312,10 +312,6 @@ float Terrain::getHeight(float x, float z, Vec3 * normal) const normal->setZero(); } return 0; - if (normal) - { - normal->setZero(); - } }else { float a = getImageHeight(i,j)*getScaleY(); @@ -547,7 +543,7 @@ bool Terrain::getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) co { lastRayPosition = rayPos; rayPos += rayStep; - if (normal.isZero + if (normal.isZero()) { intersectionPoint = Vec3(0, 0, 0); return false; diff --git a/cocos/3d/CCTerrain.h b/cocos/3d/CCTerrain.h index 0c2879f3ee..5f678b3795 100644 --- a/cocos/3d/CCTerrain.h +++ b/cocos/3d/CCTerrain.h @@ -354,8 +354,6 @@ public: */ bool getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) const; - bool getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint); - /** * set the MaxDetailAmount. */ From 76a3db6f29f28db6bf4dcf4bf9a3433d5eeaf900 Mon Sep 17 00:00:00 2001 From: Oscar Utbult Date: Tue, 9 Jun 2015 23:54:03 +0200 Subject: [PATCH 35/35] Capitalize default option in download-deps.py --- download-deps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/download-deps.py b/download-deps.py index 260298aa1e..d2ea7c9a8d 100755 --- a/download-deps.py +++ b/download-deps.py @@ -199,10 +199,10 @@ class CocosZipInstaller(object): print("==> Extraction done!") def ask_to_delete_downloaded_zip_file(self): - ret = self.get_input_value("==> Do you want to keep '%s'? So you don't have to download it later. (yes/no): " % self._filename) + ret = self.get_input_value("==> Would you like to save '%s'? So you don't have to download it later. [Yes/no]: " % self._filename) ret = ret.strip() if ret != 'yes' and ret != 'y' and ret != 'no' and ret != 'n': - print("==> Cache the dependency libraries by default") + print("==> Saving the dependency libraries by default") return False else: return True if ret == 'no' or ret == 'n' else False