diff --git a/cocos/3d/CCAnimate3D.cpp b/cocos/3d/CCAnimate3D.cpp index c359194843..0aff12f2d1 100644 --- a/cocos/3d/CCAnimate3D.cpp +++ b/cocos/3d/CCAnimate3D.cpp @@ -96,17 +96,19 @@ void Animate3D::startWithTarget(Node *target) _boneCurves.clear(); auto skin = sprite->getSkeleton(); + bool hasCurve = false; for (unsigned int i = 0; i < skin->getBoneCount(); i++) { auto bone = skin->getBoneByIndex(i); auto curve = _animation->getBoneCurveByName(bone->getName()); if (curve) { _boneCurves[bone] = curve; + hasCurve = true; } - else - { - CCLOG("warning: bone %s not find in animation", bone->getName().c_str()); - } + } + if (!hasCurve) + { + CCLOG("warning: no animation finde for the skeleton"); } } diff --git a/cocos/3d/CCBundle3D.cpp b/cocos/3d/CCBundle3D.cpp index 8c8bbab2f8..b1a8020eec 100644 --- a/cocos/3d/CCBundle3D.cpp +++ b/cocos/3d/CCBundle3D.cpp @@ -1202,6 +1202,10 @@ bool Bundle3D::loadAnimationDataJson(Animation3DData* animationdata) { const rapidjson::Value& bone_keyframes = bone[KEYFRAMES]; rapidjson::SizeType keyframe_size = bone_keyframes.Size(); + animationdata->_rotationKeys[bone_name].reserve(keyframe_size); + animationdata->_scaleKeys[bone_name].reserve(keyframe_size); + animationdata->_translationKeys[bone_name].reserve(keyframe_size); + for (rapidjson::SizeType j = 0; j < keyframe_size; j++) { const rapidjson::Value& bone_keyframe = bone_keyframes[j]; @@ -1627,6 +1631,10 @@ bool Bundle3D::loadAnimationDataBinary(Animation3DData* animationdata) CCLOGINFO("Failed to read AnimationData: keyframeNum '%s'.", _path.c_str()); return false; } + + animationdata->_rotationKeys[boneName].reserve(keyframeNum); + animationdata->_scaleKeys[boneName].reserve(keyframeNum); + animationdata->_translationKeys[boneName].reserve(keyframeNum); for (unsigned int j = 0; j < keyframeNum; ++j) { diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 30518792db..fc5f588ee8 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -1166,9 +1166,15 @@ void Director::getFPSImageData(unsigned char** datapointer, ssize_t* length) void Director::createStatsLabel() { Texture2D *texture = nullptr; - + std::string fpsString = "00.0"; + std::string drawBatchString = "000"; + std::string drawVerticesString = "00000"; if (_FPSLabel) { + fpsString = _FPSLabel->getString(); + drawBatchString = _drawnBatchesLabel->getString(); + drawVerticesString = _drawnVerticesLabel->getString(); + CC_SAFE_RELEASE_NULL(_FPSLabel); CC_SAFE_RELEASE_NULL(_drawnBatchesLabel); CC_SAFE_RELEASE_NULL(_drawnVerticesLabel); @@ -1205,19 +1211,19 @@ void Director::createStatsLabel() _FPSLabel = LabelAtlas::create(); _FPSLabel->retain(); _FPSLabel->setIgnoreContentScaleFactor(true); - _FPSLabel->initWithString("00.0", texture, 12, 32 , '.'); + _FPSLabel->initWithString(fpsString, texture, 12, 32 , '.'); _FPSLabel->setScale(scaleFactor); _drawnBatchesLabel = LabelAtlas::create(); _drawnBatchesLabel->retain(); _drawnBatchesLabel->setIgnoreContentScaleFactor(true); - _drawnBatchesLabel->initWithString("000", texture, 12, 32, '.'); + _drawnBatchesLabel->initWithString(drawBatchString, texture, 12, 32, '.'); _drawnBatchesLabel->setScale(scaleFactor); _drawnVerticesLabel = LabelAtlas::create(); _drawnVerticesLabel->retain(); _drawnVerticesLabel->setIgnoreContentScaleFactor(true); - _drawnVerticesLabel->initWithString("00000", texture, 12, 32, '.'); + _drawnVerticesLabel->initWithString(drawVerticesString, texture, 12, 32, '.'); _drawnVerticesLabel->setScale(scaleFactor); diff --git a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp index d381e4c2a5..6754895447 100644 --- a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp +++ b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp @@ -363,34 +363,12 @@ void Camera3DTestDemo::addNewSpriteWithCoords(Vec3 p,std::string fileName,bool p if (animation) { auto animate = Animate3D::create(animation); - bool inverse = (std::rand() % 3 == 0); - - int rand2 = std::rand(); - float speed = 1.0f; - if(rand2 % 3 == 1) - { - speed = animate->getSpeed() + CCRANDOM_0_1(); - } - else if(rand2 % 3 == 2) - { - speed = animate->getSpeed() - 0.5 * CCRANDOM_0_1(); - } - animate->setSpeed(inverse ? -speed : speed); sprite->runAction(RepeatForever::create(animate)); - //auto sp = Sprite3D::create("Sprite3DTest/axe.c3b"); - // sprite->getAttachNode("Bip001 R Hand")->addChild(sp); } } if(bindCamera) { _sprite3D=sprite; - // auto sp = Sprite3D::create("Sprite3DTest/axe.c3b"); - // sp->setScale(3); - //sprite->getAttachNode("Bip001 R Hand")->addChild(sp); - //ParticleSystem3D* particleSystem3D = ParticleSystem3D::create("CameraTest/particle3Dtest1.particle"); - //particleSystem3D->start(); - //sprite->getAttachNode("Bip001 R Hand")->addChild(particleSystem3D); - } sprite->setScale(scale); diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index d817e0e348..1ec8d15e5d 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -1056,7 +1056,7 @@ void Sprite3DReskinTest::menuCallback_switchHair(Ref* sender) } void Sprite3DReskinTest::menuCallback_switchGlasses(Ref* sender) { - auto subMesh = _sprite->getMeshByName("Girl_Yanjing_01"); + auto subMesh = _sprite->getMeshByName("Girl_Glasses01"); if(subMesh) { if(subMesh->isVisible()) @@ -1159,14 +1159,14 @@ std::string Sprite3DReskinTest::subtitle() const void Sprite3DReskinTest::addNewSpriteWithCoords(Vec2 p) { - _girlPants[0]= "Girl_Xiashen_01"; - _girlPants[1]= "Girl_Xiashen_02"; - _girlUpperBody[0] = "Girl_Shangshen_01"; - _girlUpperBody[1] = "Girl_Shangshen_02"; - _girlShoes[0] = "Girl_Xie_01"; - _girlShoes[1] = "Girl_Xie_02"; - _girlHair[0]= "Girl_Toufa_01"; - _girlHair[1]= "Girl_Toufa_02"; + _girlPants[0]= "Girl_LowerBody01"; + _girlPants[1]= "Girl_LowerBody02"; + _girlUpperBody[0] = "Girl_UpperBody01"; + _girlUpperBody[1] = "Girl_UpperBody02"; + _girlShoes[0] = "Girl_Shoes01"; + _girlShoes[1] = "Girl_Shoes02"; + _girlHair[0]= "Girl_Hair01"; + _girlHair[1]= "Girl_Hair02"; _usePantsId = 0; _useUpBodyId = 0; _useShoesId =0; diff --git a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Lian.png b/tests/cpp-tests/Resources/Sprite3DTest/Girl_Face.png similarity index 100% rename from tests/cpp-tests/Resources/Sprite3DTest/Girl_Lian.png rename to tests/cpp-tests/Resources/Sprite3DTest/Girl_Face.png diff --git a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Yanjing_01.png b/tests/cpp-tests/Resources/Sprite3DTest/Girl_Glasses01.png similarity index 100% rename from tests/cpp-tests/Resources/Sprite3DTest/Girl_Yanjing_01.png rename to tests/cpp-tests/Resources/Sprite3DTest/Girl_Glasses01.png diff --git a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Toufa_01.png b/tests/cpp-tests/Resources/Sprite3DTest/Girl_Hair01.png similarity index 100% rename from tests/cpp-tests/Resources/Sprite3DTest/Girl_Toufa_01.png rename to tests/cpp-tests/Resources/Sprite3DTest/Girl_Hair01.png diff --git a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Toufa_02.png b/tests/cpp-tests/Resources/Sprite3DTest/Girl_Hair02.png similarity index 100% rename from tests/cpp-tests/Resources/Sprite3DTest/Girl_Toufa_02.png rename to tests/cpp-tests/Resources/Sprite3DTest/Girl_Hair02.png diff --git a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Shou_01.png b/tests/cpp-tests/Resources/Sprite3DTest/Girl_Hand.png similarity index 100% rename from tests/cpp-tests/Resources/Sprite3DTest/Girl_Shou_01.png rename to tests/cpp-tests/Resources/Sprite3DTest/Girl_Hand.png diff --git a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Xiashen_01.png b/tests/cpp-tests/Resources/Sprite3DTest/Girl_LowerBody01.png similarity index 100% rename from tests/cpp-tests/Resources/Sprite3DTest/Girl_Xiashen_01.png rename to tests/cpp-tests/Resources/Sprite3DTest/Girl_LowerBody01.png diff --git a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Xiashen_02.png b/tests/cpp-tests/Resources/Sprite3DTest/Girl_LowerBody02.png similarity index 100% rename from tests/cpp-tests/Resources/Sprite3DTest/Girl_Xiashen_02.png rename to tests/cpp-tests/Resources/Sprite3DTest/Girl_LowerBody02.png diff --git a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Maozi_01.png b/tests/cpp-tests/Resources/Sprite3DTest/Girl_Maozi_01.png deleted file mode 100644 index d7d47ac29f..0000000000 Binary files a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Maozi_01.png and /dev/null differ diff --git a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Shangshen_03.png b/tests/cpp-tests/Resources/Sprite3DTest/Girl_Shangshen_03.png deleted file mode 100644 index 0e8821b78d..0000000000 Binary files a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Shangshen_03.png and /dev/null differ diff --git a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Xie_01.png b/tests/cpp-tests/Resources/Sprite3DTest/Girl_Shoes01.png similarity index 100% rename from tests/cpp-tests/Resources/Sprite3DTest/Girl_Xie_01.png rename to tests/cpp-tests/Resources/Sprite3DTest/Girl_Shoes01.png diff --git a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Xie_02.png b/tests/cpp-tests/Resources/Sprite3DTest/Girl_Shoes02.png similarity index 100% rename from tests/cpp-tests/Resources/Sprite3DTest/Girl_Xie_02.png rename to tests/cpp-tests/Resources/Sprite3DTest/Girl_Shoes02.png diff --git a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Shangshen_01.png b/tests/cpp-tests/Resources/Sprite3DTest/Girl_UpperBody01.png similarity index 100% rename from tests/cpp-tests/Resources/Sprite3DTest/Girl_Shangshen_01.png rename to tests/cpp-tests/Resources/Sprite3DTest/Girl_UpperBody01.png diff --git a/tests/cpp-tests/Resources/Sprite3DTest/Girl_Shangshen_02.png b/tests/cpp-tests/Resources/Sprite3DTest/Girl_UpperBody02.png similarity index 100% rename from tests/cpp-tests/Resources/Sprite3DTest/Girl_Shangshen_02.png rename to tests/cpp-tests/Resources/Sprite3DTest/Girl_UpperBody02.png diff --git a/tests/cpp-tests/Resources/Sprite3DTest/ReskinGirl.c3b b/tests/cpp-tests/Resources/Sprite3DTest/ReskinGirl.c3b index 001818417f..06e51a31a0 100644 Binary files a/tests/cpp-tests/Resources/Sprite3DTest/ReskinGirl.c3b and b/tests/cpp-tests/Resources/Sprite3DTest/ReskinGirl.c3b differ