diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index e21a7e4cc3..b086987c05 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -818,10 +818,6 @@ 15EFA212198A2BB5000C57D3 /* CCProtectedNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15EFA20F198A2BB5000C57D3 /* CCProtectedNode.cpp */; }; 15EFA213198A2BB5000C57D3 /* CCProtectedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */; }; 15EFA214198A2BB5000C57D3 /* CCProtectedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */; }; - 15FB206E1AE7BE7400C31518 /* CCSpritePolygonCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20681AE7BE7400C31518 /* CCSpritePolygonCache.cpp */; }; - 15FB206F1AE7BE7400C31518 /* CCSpritePolygonCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20681AE7BE7400C31518 /* CCSpritePolygonCache.cpp */; }; - 15FB20701AE7BE7400C31518 /* CCSpritePolygonCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20691AE7BE7400C31518 /* CCSpritePolygonCache.h */; }; - 15FB20711AE7BE7400C31518 /* CCSpritePolygonCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20691AE7BE7400C31518 /* CCSpritePolygonCache.h */; }; 15FB20741AE7BF8600C31518 /* CCAutoPolygon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20721AE7BF8600C31518 /* CCAutoPolygon.cpp */; }; 15FB20751AE7BF8600C31518 /* CCAutoPolygon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20721AE7BF8600C31518 /* CCAutoPolygon.cpp */; }; 15FB20761AE7BF8600C31518 /* CCAutoPolygon.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20731AE7BF8600C31518 /* CCAutoPolygon.h */; }; @@ -3563,8 +3559,6 @@ 15B3707719EE414C00ABE682 /* Manifest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Manifest.h; sourceTree = ""; }; 15EFA20F198A2BB5000C57D3 /* CCProtectedNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCProtectedNode.cpp; sourceTree = ""; }; 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProtectedNode.h; sourceTree = ""; }; - 15FB20681AE7BE7400C31518 /* CCSpritePolygonCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpritePolygonCache.cpp; sourceTree = ""; }; - 15FB20691AE7BE7400C31518 /* CCSpritePolygonCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpritePolygonCache.h; sourceTree = ""; }; 15FB20721AE7BF8600C31518 /* CCAutoPolygon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAutoPolygon.cpp; sourceTree = ""; }; 15FB20731AE7BF8600C31518 /* CCAutoPolygon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAutoPolygon.h; sourceTree = ""; }; 15FB207A1AE7C57D00C31518 /* shapes.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = shapes.cc; sourceTree = ""; }; @@ -5865,8 +5859,6 @@ children = ( 15FB20721AE7BF8600C31518 /* CCAutoPolygon.cpp */, 15FB20731AE7BF8600C31518 /* CCAutoPolygon.h */, - 15FB20681AE7BE7400C31518 /* CCSpritePolygonCache.cpp */, - 15FB20691AE7BE7400C31518 /* CCSpritePolygonCache.h */, 1A57028E180BCCAB0088DEC7 /* CCAnimation.cpp */, 1A57028F180BCCAB0088DEC7 /* CCAnimation.h */, 1A570290180BCCAB0088DEC7 /* CCAnimationCache.cpp */, @@ -8882,7 +8874,6 @@ 15AE1A3319AAD3D500C27E9E /* b2CircleShape.h in Headers */, 1A5701E0180BCB8C0088DEC7 /* CCLayer.h in Headers */, 1A5701E4180BCB8C0088DEC7 /* CCScene.h in Headers */, - 15FB20701AE7BE7400C31518 /* CCSpritePolygonCache.h in Headers */, B6CAB2C11AF9AA1A00B9B856 /* btEmptyShape.h in Headers */, B665E3D81AA80A6600DDB1C5 /* CCPUScriptParser.h in Headers */, 382384091A25900F002C4610 /* FlatBuffersSerialize.h in Headers */, @@ -9647,7 +9638,6 @@ B665E2451AA80A6500DDB1C5 /* CCPUCollisionAvoidanceAffector.h in Headers */, B6CAB3381AF9AA1A00B9B856 /* btQuantization.h in Headers */, 50ABBEC41925AB6F00A911A9 /* CCVector.h in Headers */, - 15FB20711AE7BE7400C31518 /* CCSpritePolygonCache.h in Headers */, 50ABBE501925AB6F00A911A9 /* CCEventCustom.h in Headers */, 15AE1AD719AAD40300C27E9E /* b2WheelJoint.h in Headers */, B665E3311AA80A6500DDB1C5 /* CCPUOnCountObserverTranslator.h in Headers */, @@ -10915,7 +10905,6 @@ B6CAB52B1AF9AA1A00B9B856 /* btSerializer.cpp in Sources */, 50ABC0191926664800A911A9 /* CCSAXParser.cpp in Sources */, 15AE189219AAD33D00C27E9E /* CCLayerGradientLoader.cpp in Sources */, - 15FB206E1AE7BE7400C31518 /* CCSpritePolygonCache.cpp in Sources */, B6CAB4471AF9AA1A00B9B856 /* btThreadSupportInterface.cpp in Sources */, 15AE1B6A19AADA9900C27E9E /* UIDeprecated.cpp in Sources */, 15AE183C19AAD2F700C27E9E /* CCSkeleton3D.cpp in Sources */, @@ -11990,7 +11979,6 @@ B665E29F1AA80A6500DDB1C5 /* CCPUEventHandler.cpp in Sources */, 15AE195519AAD35100C27E9E /* CCDisplayManager.cpp in Sources */, B665E43B1AA80A6600DDB1C5 /* CCPUVortexAffectorTranslator.cpp in Sources */, - 15FB206F1AE7BE7400C31518 /* CCSpritePolygonCache.cpp in Sources */, 15AE1BA719AADFDF00C27E9E /* UIRelativeBox.cpp in Sources */, 15AE1ACE19AAD40300C27E9E /* b2PulleyJoint.cpp in Sources */, B665E2DF1AA80A6500DDB1C5 /* CCPULineAffector.cpp in Sources */, diff --git a/cocos/2d/CCAutoPolygon.cpp b/cocos/2d/CCAutoPolygon.cpp index d1ca54da50..3bc35db2e5 100644 --- a/cocos/2d/CCAutoPolygon.cpp +++ b/cocos/2d/CCAutoPolygon.cpp @@ -144,7 +144,6 @@ AutoPolygon::~AutoPolygon() std::vector AutoPolygon::trace(const Rect& rect, const float& threshold) { -// Rect realRect = getRealRect(rect); Vec2 first = findFirstNoneTransparentPixel(rect, threshold); return marchSquare(rect, first, threshold); } @@ -173,23 +172,10 @@ Vec2 AutoPolygon::findFirstNoneTransparentPixel(const Rect& rect, const float& t unsigned char AutoPolygon::getAlphaByIndex(const unsigned int& i) { -// CCASSERT(i < _width*_height, "coordinate is out of range."); -// unsigned int x = i % (int)_rect.size.width; -// unsigned int y = i / (int)_rect.size.width; -// CCLOG("i=%d, x=%d,y=%d",i,x,y); -// x += _rect.origin.x; -// y += _height - _rect.origin.y - _rect.size.height; -// y = _height - _rect.origin.y -_rect.size.height + y; -// return getAlphaByPos(x, y); return *(_data+i*4+3); } unsigned char AutoPolygon::getAlphaByPos(const Vec2& i) { -// CCASSERT(x <= _width-1 && y <= _height-1, "coordinate is out of range."); -// if (x<_rect.origin.x || x>_rect.origin.x+_rect.size.width -// || y<_rect.origin.y || y>_rect.origin.y+_rect.size.height) { -// return 0; -// } return *(_data+((int)i.y*_width+(int)i.x)*4+3); } @@ -378,8 +364,6 @@ std::vector AutoPolygon::marchSquare(const Rect& rect, const Vec2 { //TODO: we triangulation cannot work collineer points, so we need to modify same point a little //TODO: maybe we can detect if we go into a hole and coming back the hole, we should extract those points and remove them -// _points.back().x -= 0.00001; -// _points.back().y -= 0.00001; _points.push_back(Vec2((float)(curx- rect.origin.x) / _scaleFactor, (float)(rect.size.height - cury + rect.origin.y) / _scaleFactor)); } else{ @@ -395,14 +379,6 @@ std::vector AutoPolygon::marchSquare(const Rect& rect, const Vec2 return _points; } -//void AutoPolygon::printPoints() -//{ -// for(auto p : _points) -// { -// CCLOG("%.1f %.1f", p.x, _height-p.y); -// } -//} - float AutoPolygon::perpendicularDistance(const cocos2d::Vec2& i, const cocos2d::Vec2& start, const cocos2d::Vec2& end) { float res; @@ -480,7 +456,6 @@ std::vector AutoPolygon::reduce(const std::vector& points, const Rec float ep = clampf(epsilon, 0.0, maxEp/_scaleFactor/2); std::vector result = rdp(points, ep); -// auto resSize = result.size(); auto last = result.back(); if(last.y > result.front().y && last.getDistance(result.front()) < ep*0.5) { @@ -501,7 +476,6 @@ std::vector AutoPolygon::expand(const std::vector& points, const coc } ClipperLib::Path subj; ClipperLib::PolyTree solution; -// ClipperLib::Paths simple; ClipperLib::PolyTree out; for(std::vector::const_iterator it = points.begin(); it AutoPolygon::expand(const std::vector& points, const coc p = p->GetNext(); } -// //turn the result into simply polygon (AKA, fix overlap) -// ClipperLib::SimplifyPolygon(p->Contour, simple); + //turn the result into simply polygon (AKA, fix overlap) //clamp into the specified rect ClipperLib::Clipper cl= ClipperLib::Clipper(); cl.StrictlySimple(true); cl.AddPath(p->Contour, ClipperLib::ptSubject, true); - //create the clipping rect + //create the clipping rect ClipperLib::Path clamp; clamp.push_back(ClipperLib::IntPoint(0, 0)); clamp.push_back(ClipperLib::IntPoint(rect.size.width/_scaleFactor, 0)); @@ -636,7 +609,6 @@ void AutoPolygon::calculateUV(const Rect& rect, V3F_C4B_T2F* verts, const ssize_ 0,1 1,1 */ -// Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(_filename); CCASSERT(_width && _height, "please specify width and height for this AutoPolygon instance"); float texWidth = _width; float texHeight = _height; @@ -686,8 +658,7 @@ PolygonInfo AutoPolygon::generateTriangles(const Rect& rect, const float& epsilo } PolygonInfo AutoPolygon::generatePolygon(const std::string& filename, const Rect& rect, const float epsilon, const float threshold) { - auto AP = new AutoPolygon(filename); - auto ret = AP->generateTriangles(rect, epsilon, threshold); - delete AP; + auto ap = AutoPolygon(filename); + auto ret = ap.generateTriangles(rect, epsilon, threshold); return ret; } diff --git a/cocos/2d/CCSpritePolygonCache.cpp b/cocos/2d/CCSpritePolygonCache.cpp deleted file mode 100644 index a40a5b6749..0000000000 --- a/cocos/2d/CCSpritePolygonCache.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2011 Zynga Inc. - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCSpritePolygonCache.h" -#include "platform/CCFileUtils.h" -#include "base/CCDirector.h" -#include "renderer/CCTextureCache.h" -#include "poly2tri/poly2tri.h" -USING_NS_CC; - -SpritePolygonCache* SpritePolygonCache::s_spritePolygonCache = nullptr; - -SpritePolygonCache::SpritePolygonCache() -{ - -} - -SpritePolygonCache::~SpritePolygonCache() -{ - removeAllSpritePolygonCache(); -} - -SpritePolygonCache* SpritePolygonCache::getInstance() -{ - if (nullptr == s_spritePolygonCache) - { - s_spritePolygonCache = new (std::nothrow) SpritePolygonCache(); - s_spritePolygonCache->init(); - } - return s_spritePolygonCache; -} - -void SpritePolygonCache::destroyInstance() -{ - CC_SAFE_DELETE(s_spritePolygonCache); -} - -void SpritePolygonCache::init() -{ - _spritePolygonCacheMap.reserve(20); -} - -PolygonInfo* SpritePolygonCache::addSpritePolygonCache(const std::string& filePath, const cocos2d::Rect& rect, const cocos2d::TrianglesCommand::Triangles& triangles) -{ - auto fullpath = FileUtils::getInstance()->fullPathForFilename(filePath);; - - auto it = _spritePolygonCacheMap.find(fullpath); - if (_spritePolygonCacheMap.end() != it) - { - VecSpritePolygonInfo vecInfo = it->second; - - auto infoIt = vecInfo.begin(); - for (; infoIt != vecInfo.end(); infoIt++) - { -// if ((*infoIt)->rect.equals(rect)) -// { -// CC_SAFE_DELETE_ARRAY((*infoIt)->triangles.verts); -// CC_SAFE_DELETE_ARRAY((*infoIt)->triangles.indices); -// (*infoIt)->triangles.verts = new V3F_C4B_T2F[triangles.vertCount]; -// (*infoIt)->triangles.indices = new unsigned short[triangles.indexCount]; -// (*infoIt)->triangles.vertCount = triangles.vertCount; -// (*infoIt)->triangles.indexCount = triangles.indexCount; -// memcpy((*infoIt)->triangles.verts, triangles.verts, triangles.vertCount*sizeof(V3F_C4B_T2F)); -// memcpy((*infoIt)->triangles.indices, triangles.indices, triangles.indexCount*sizeof(unsigned short)); -// return *infoIt; -// } - } - } - - VecSpritePolygonInfo vecInfo; - vecInfo.clear(); - if (it != _spritePolygonCacheMap.end()) - { - vecInfo = it->second; - } - PolygonInfo* info = new (std::nothrow) PolygonInfo(); - if (nullptr != info) - { -// info->rect = rect; -// info->triangles.verts = new V3F_C4B_T2F[triangles.vertCount]; -// info->triangles.indices = new unsigned short[triangles.indexCount]; -// info->triangles.vertCount = triangles.vertCount; -// info->triangles.indexCount = triangles.indexCount; -// memcpy(info->triangles.verts, triangles.verts, triangles.vertCount*sizeof(V3F_C4B_T2F)); -// memcpy(info->triangles.indices, triangles.indices, triangles.indexCount*sizeof(unsigned short)); -// -// vecInfo.push_back(info); -// _spritePolygonCacheMap[filePath] = vecInfo; - } - return info; -} - -PolygonInfo* SpritePolygonCache::getSpritePolygonCache(const std::string& filePath, const cocos2d::Rect& rect, float optimization) -{ - PolygonInfo* spritePolygonInfo = nullptr; - bool isFound = false; - - auto fullpath = FileUtils::getInstance()->fullPathForFilename(filePath); - if(fullpath.size() == 0) - { - return nullptr; - } - - auto it = _spritePolygonCacheMap.find(fullpath); - if (_spritePolygonCacheMap.end() != it) - { - auto infoIter = it->second.begin(); - for (; infoIter != it->second.end(); infoIter++) - { -// if ((*infoIter)->rect.equals(rect)) -// { -// spritePolygonInfo = *infoIter; -// isFound = true; -// } - } - } - -// if(!isFound) -// { -// //we need 5 steps to get cocos2d::TrianglesCommand::Triangles for cache. -// //1.trace 2.optimize 3.expand 4.triangulate 5.calculateuv -// if(-1 == optimization) optimization = 1.169; -// AutoPolygon autopolygon(fullpath); -// autopolygon.generateTriangles(rect, optimization); -// spritePolygonInfo = addSpritePolygonCache(fullpath, rect, autopolygon.getTriangles()); -// } - return spritePolygonInfo; -} - -void SpritePolygonCache::removeSpritePolygonCache(const std::string& filePath, const cocos2d::Rect* rect) -{ - std::string fullpath = FileUtils::getInstance()->fullPathForFilename(filePath); - if (fullpath.size() == 0) - return; - - auto it = _spritePolygonCacheMap.find(fullpath); - if (_spritePolygonCacheMap.end() == it) - return; - - if (nullptr == rect) - return; - - auto infoIter = it->second.begin(); - for (; infoIter != it->second.end(); infoIter++) - { -// if((*infoIter)->rect.equals(*rect)) -// { -// CC_SAFE_RELEASE(*infoIter); -// it->second.erase(infoIter); -// break; -// } - } - - return; -} - -void SpritePolygonCache::removeAllSpritePolygonCache() -{ - for (std::unordered_map::iterator it = _spritePolygonCacheMap.begin(); it != _spritePolygonCacheMap.end(); ++it) - { -// for (auto infoIter = it->second.begin(); infoIter != it->second.end(); infoIter++) -// { -//// CC_SAFE_RELEASE(*infoIter); -// } -// it->second.clear(); - } - _spritePolygonCacheMap.clear(); -} - -void SpritePolygonCache::removeUnusedSpritePolygonCache() -{ - for (std::unordered_map::iterator it = _spritePolygonCacheMap.begin(); it != _spritePolygonCacheMap.end(); ++it) - { - for (auto infoIter = it->second.begin(); infoIter != it->second.end(); infoIter++) - { -// if(1==(*infoIter)->getReferenceCount()) -// { -// CC_SAFE_RELEASE(*infoIter); -// it->second.erase(infoIter); -// } - } - } -} - -bool SpritePolygonCache::isSpritePolygonCacheExist(const std::string& filePath, const cocos2d::Rect& rect) -{ - std::string fullpath = FileUtils::getInstance()->fullPathForFilename(filePath); - if (fullpath.size() == 0) - return false; - - auto it = _spritePolygonCacheMap.find(fullpath); - if (_spritePolygonCacheMap.end() == it) - return false; - - auto infoIter = it->second.begin(); - for (; infoIter != it->second.end(); infoIter++) - { -// if ((*infoIter)->rect.equals(rect)) - return true; - } - - return false; -} - - -void SpritePolygonCache::printInfo(PolygonInfo &info){ - CCLOG("========================"); - CCLOG("%zd, %zd", info.triangles.vertCount, info.triangles.indexCount); - - auto vertEnd = &info.triangles.verts[info.triangles.vertCount]; - for(auto v = info.triangles.verts; v < vertEnd; v++) - { - CCLOG("%f, %f", v->vertices.x, v->vertices.y); - } - auto indEnd = &info.triangles.indices[info.triangles.indexCount]; - for(auto i = info.triangles.indices; i < indEnd; i+=3) - { - CCLOG("%d, %d, %d,", *i,*(i+1), *(i+2)); - } - - auto uvEnd = &info.triangles.verts[info.triangles.vertCount]; - for(auto v = info.triangles.verts; v < uvEnd; v++) - { - CCLOG("%f, %f", v->texCoords.u, v->texCoords.v); - } -} - -USING_NS_CC; diff --git a/cocos/2d/CCSpritePolygonCache.h b/cocos/2d/CCSpritePolygonCache.h deleted file mode 100644 index de73e6be9c..0000000000 --- a/cocos/2d/CCSpritePolygonCache.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2011 Zynga Inc. - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef COCOS_2D_CCSpritePolygonCACHE_H__ -#define COCOS_2D_CCSpritePolygonCACHE_H__ - -#include "renderer/CCTrianglesCommand.h" -#include "2d/CCAutoPolygon.h" - -NS_CC_BEGIN - - - -typedef std::vector VecSpritePolygonInfo; -typedef std::unordered_map MapSpritePolygonInfo; - -class CC_DLL SpritePolygonCache: public cocos2d::Ref -{ -public: - virtual ~SpritePolygonCache(); - static SpritePolygonCache* getInstance(); - static void destroyInstance(); - PolygonInfo* addSpritePolygonCache(const std::string& filePath, const cocos2d::Rect& rect, const cocos2d::TrianglesCommand::Triangles& triangles); - PolygonInfo* getSpritePolygonCache(const std::string& filePath, const cocos2d::Rect& rect, float optimization); - - void removeSpritePolygonCache(const std::string& filePath, const cocos2d::Rect* rect = nullptr); - void removeAllSpritePolygonCache(); - void removeUnusedSpritePolygonCache(); - bool isSpritePolygonCacheExist(const std::string& filePath, const cocos2d::Rect& rect); - - static void printInfo(PolygonInfo &info); -protected: - SpritePolygonCache(); - void init(); -private: - static SpritePolygonCache* s_spritePolygonCache; - MapSpritePolygonInfo _spritePolygonCacheMap; - -}; - -NS_CC_END - -#endif // #ifndef COCOS_2D_CCSpritePolygonCACHE_H__ diff --git a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp index a5a22d7d9c..a3b5ac4703 100644 --- a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp +++ b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp @@ -1,11 +1,3 @@ -// -// SpritePolygonTest.cpp -// cocos2d_tests -// -// Created by WuHao on 15/4/23. -// -// - #include "SpritePolygonTest.h" #include "../testResource.h" #include "ui/CocosGUI.h" @@ -146,8 +138,6 @@ SpritePolygonPerformance::SpritePolygonPerformance() scheduleUpdate(); continuousHighDtTime = 0.0; waitingTime = 0.0; - -// _pinfo = PolygonInfo(AutoPolygon::generatePolygon(s_pathGrossini)); } void SpritePolygonPerformance::updateLabel() { @@ -283,7 +273,6 @@ void SpritePolygonTestSlider::makeSprites(const std::string* list, const int cou { auto vsize =Director::getInstance()->getVisibleSize(); float offset = (vsize.width-100)/(count-1); -// float y = vsize.height/2; for(int i = 0; i < count; i++) { auto sp = makeSprite(list[i], Vec2(50+offset*i, y)); @@ -361,7 +350,6 @@ SpritePolygonTest4::SpritePolygonTest4() int count = 3; std::string list[] = { s_pathGrossini, -// "TileMaps/fixed-ortho-test2.png", "Images/grossinis_sister1.png", "Images/grossinis_sister2.png" }; diff --git a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.h b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.h index 6ec149c6fa..b0fca7f598 100644 --- a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.h +++ b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.h @@ -1,11 +1,11 @@ #ifndef __cocos2d_tests__SpritePolygonTest__ + #include "../testBasic.h" #include "../BaseTest.h" #include "ui/CocosGUI.h" + DEFINE_TEST_SUITE(SpritePolygonTest); - - class SpritePolygonTestCase : public TestCase { protected: