diff --git a/CHANGELOG b/CHANGELOG index 5f05b96968..46fcf0a17c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +cocos2d-x-3.3 ?? + [FIX] Label: label shifting when outline feature enabled + [FIX] Sprite3D: did not create attached sprite from cache + cocos2d-x-3.3-rc0 Oct.21 2014 [NEW] 3d: added light support: direction light, point light, spot light and ambient light [NEW] Added ClippingRectangleNode diff --git a/cocos/2d/CCFontAtlas.cpp b/cocos/2d/CCFontAtlas.cpp index be92cbc4b6..fd8c50c0b7 100644 --- a/cocos/2d/CCFontAtlas.cpp +++ b/cocos/2d/CCFontAtlas.cpp @@ -67,7 +67,7 @@ FontAtlas::FontAtlas(Font &theFont) auto outlineSize = fontTTf->getOutlineSize(); if(outlineSize > 0) { - _commonLineHeight += 2 * outlineSize * CC_CONTENT_SCALE_FACTOR(); + _commonLineHeight += 2 * outlineSize; _currentPageDataSize *= 2; } diff --git a/cocos/2d/CCFontFreeType.cpp b/cocos/2d/CCFontFreeType.cpp index 6a4f639c82..1ee2c1aebc 100644 --- a/cocos/2d/CCFontFreeType.cpp +++ b/cocos/2d/CCFontFreeType.cpp @@ -95,12 +95,12 @@ FT_Library FontFreeType::getFTLibrary() FontFreeType::FontFreeType(bool distanceFieldEnabled /* = false */,int outline /* = 0 */) : _fontRef(nullptr) ,_distanceFieldEnabled(distanceFieldEnabled) -,_outlineSize(outline) +,_outlineSize(0.0f) ,_stroker(nullptr) { - if (_outlineSize > 0) + if (outline > 0) { - _outlineSize *= CC_CONTENT_SCALE_FACTOR(); + _outlineSize = outline * CC_CONTENT_SCALE_FACTOR(); FT_Stroker_New(FontFreeType::getFTLibrary(), &_stroker); FT_Stroker_Set(_stroker, (int)(_outlineSize * 64), @@ -328,8 +328,6 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid } } - outRect.origin.x = bbox.xMin >> 6; - outRect.origin.y = - (bbox.yMax >> 6); xAdvance += 2 * _outlineSize; outRect.size.width = blendWidth; outRect.size.height = blendHeight; diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index d47de90238..a498d9b03e 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -92,6 +92,14 @@ bool Sprite3D::loadFromCache(const std::string& path) } } + for(const auto& it : spritedata->nodedatas->skeleton) + { + if(it) + { + createAttachSprite3DNode(it,*(spritedata->materialdatas)); + } + } + for (ssize_t i = 0; i < _meshes.size(); i++) { _meshes.at(i)->setGLProgramState(spritedata->glProgramStates.at(i)); } diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index 29df67b674..3b08d9bf9e 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -69,6 +69,9 @@ public: /**get mesh*/ Mesh* getMesh() const { return _meshes.at(0); } + /** get mesh count */ + ssize_t getMeshCount() const { return _meshes.size(); } + /**get skin*/ CC_DEPRECATED_ATTRIBUTE MeshSkin* getSkin() const; diff --git a/cocos/renderer/CCGLProgram.cpp b/cocos/renderer/CCGLProgram.cpp index dc39cda79f..6aa05848ca 100644 --- a/cocos/renderer/CCGLProgram.cpp +++ b/cocos/renderer/CCGLProgram.cpp @@ -45,13 +45,6 @@ THE SOFTWARE. NS_CC_BEGIN -typedef struct _hashUniformEntry -{ - GLvoid* value; // value - unsigned int location; // Key - UT_hash_handle hh; // hash entry -} tHashUniformEntry; - const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR = "ShaderPositionTextureColor"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP = "ShaderPositionTextureColor_noMVP"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST = "ShaderPositionTextureColorAlphaTest"; @@ -136,7 +129,6 @@ GLProgram::GLProgram() : _program(0) , _vertShader(0) , _fragShader(0) -, _hashForUniforms(nullptr) , _flags() { memset(_builtInUniforms, 0, sizeof(_builtInUniforms)); @@ -163,15 +155,11 @@ GLProgram::~GLProgram() GL::deleteProgram(_program); } - tHashUniformEntry *current_element, *tmp; - - // Purge uniform hash - HASH_ITER(hh, _hashForUniforms, current_element, tmp) + for (auto e : _hashForUniforms) { - HASH_DEL(_hashForUniforms, current_element); - free(current_element->value); - free(current_element); + free(e.second); } + _hashForUniforms.clear(); } bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) @@ -222,7 +210,8 @@ bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* { glAttachShader(_program, _fragShader); } - _hashForUniforms = nullptr; + + _hashForUniforms.clear(); CHECK_GL_ERROR_DEBUG(); @@ -260,7 +249,7 @@ bool GLProgram::initWithPrecompiledProgramByteArray(const GLchar* vShaderByteArr haveProgram = CCPrecompiledShaders::getInstance()->loadProgram(_program, vShaderByteArray, fShaderByteArray); CHECK_GL_ERROR_DEBUG(); - _hashForUniforms = nullptr; + _hashForUniforms.clear(); CHECK_GL_ERROR_DEBUG(); @@ -633,31 +622,23 @@ bool GLProgram::updateUniformLocation(GLint location, const GLvoid* data, unsign } bool updated = true; - tHashUniformEntry *element = nullptr; - HASH_FIND_INT(_hashForUniforms, &location, element); - - if (! element) + + auto element = _hashForUniforms.find(location); + if (element == _hashForUniforms.end()) { - element = (tHashUniformEntry*)malloc( sizeof(*element) ); - - // key - element->location = location; - - // value - element->value = malloc( bytes ); - memcpy(element->value, data, bytes ); - - HASH_ADD_INT(_hashForUniforms, location, element); + GLvoid* value = malloc(bytes); + memcpy(value, data, bytes ); + _hashForUniforms.insert(std::make_pair(location, value)); } else { - if (memcmp(element->value, data, bytes) == 0) + if (memcmp(element->second, data, bytes) == 0) { updated = false; } else { - memcpy(element->value, data, bytes); + memcpy(element->second, data, bytes); } } @@ -923,17 +904,12 @@ void GLProgram::reset() //GL::deleteProgram(_program); _program = 0; - - tHashUniformEntry *current_element, *tmp; - - // Purge uniform hash - HASH_ITER(hh, _hashForUniforms, current_element, tmp) + for (auto e: _hashForUniforms) { - HASH_DEL(_hashForUniforms, current_element); - free(current_element->value); - free(current_element); + free(e.second); } - _hashForUniforms = nullptr; + + _hashForUniforms.clear(); } NS_CC_END diff --git a/cocos/renderer/CCGLProgram.h b/cocos/renderer/CCGLProgram.h index fcb7670829..5f422722ad 100644 --- a/cocos/renderer/CCGLProgram.h +++ b/cocos/renderer/CCGLProgram.h @@ -45,7 +45,6 @@ NS_CC_BEGIN * @{ */ -struct _hashUniformEntry; class GLProgram; typedef void (*GLInfoFunction)(GLuint program, GLenum pname, GLint* params); @@ -340,7 +339,6 @@ protected: GLuint _vertShader; GLuint _fragShader; GLint _builtInUniforms[UNIFORM_MAX]; - struct _hashUniformEntry* _hashForUniforms; bool _hasShaderCompiler; #if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || defined(WP8_SHADER_COMPILER) @@ -360,6 +358,7 @@ protected: std::unordered_map _userUniforms; std::unordered_map _vertexAttribs; + std::unordered_map _hashForUniforms; }; NS_CC_END