From fdbf84a11867d81b3f406d5b4ba5be80752185ed Mon Sep 17 00:00:00 2001 From: andyque Date: Mon, 26 Jan 2015 13:49:54 +0800 Subject: [PATCH 01/66] add uploading switch scale9 tests --- cocos/ui/UILoadingBar.cpp | 12 ++- cocos/ui/UILoadingBar.h | 1 + .../CocoStudioGUITest/CocosGUIScene.cpp | 2 +- .../UILoadingBarTest/UILoadingBarTest.cpp | 83 +++++++++++++++++++ .../UILoadingBarTest/UILoadingBarTest.h | 16 +++- .../CocoStudioGUITest/UISceneManager.cpp | 3 + .../UITest/CocoStudioGUITest/UISceneManager.h | 1 + 7 files changed, 113 insertions(+), 5 deletions(-) diff --git a/cocos/ui/UILoadingBar.cpp b/cocos/ui/UILoadingBar.cpp index 917a07e3ed..c0a2aab2cd 100644 --- a/cocos/ui/UILoadingBar.cpp +++ b/cocos/ui/UILoadingBar.cpp @@ -216,7 +216,7 @@ void LoadingBar::setScale9Enabled(bool enabled) ignoreContentAdaptWithSize(_prevIgnoreSize); } setCapInsets(_capInsets); - setPercent(_percent); + this->setPercent(_percent); _barRendererAdaptDirty = true; } @@ -255,18 +255,24 @@ void LoadingBar::setPercent(float percent) return; } _percent = percent; + if (_totalLength <= 0) { return; } - float res = _percent / 100.0f; + this->updateProgressBar(); +} + +void LoadingBar::updateProgressBar() +{ if (_scale9Enabled) { setScale9Scale(); } else { + float res = _percent / 100.0f; Sprite* spriteRenderer = _barRenderer->getSprite(); Rect rect = spriteRenderer->getTextureRect(); rect.size.width = _barRendererTextureSize.width * res; @@ -334,7 +340,7 @@ void LoadingBar::barRendererScaleChangedWithSize() _totalLength = _contentSize.width; if (_scale9Enabled) { - setScale9Scale(); + this->setScale9Scale(); _barRenderer->setScale(1.0f); } else diff --git a/cocos/ui/UILoadingBar.h b/cocos/ui/UILoadingBar.h index 058ce793ac..3a961c0f29 100644 --- a/cocos/ui/UILoadingBar.h +++ b/cocos/ui/UILoadingBar.h @@ -148,6 +148,7 @@ protected: virtual void onSizeChanged() override; void setScale9Scale(); + void updateProgressBar(); void barRendererScaleChangedWithSize(); virtual void adaptRenderers() override; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp index 0a63ebbf5f..b5489b4451 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp @@ -139,7 +139,7 @@ g_guisTests[] = UISceneManager* sceneManager = UISceneManager::sharedUISceneManager(); sceneManager->setCurrentUISceneId(kUILoadingBarTest_Left); sceneManager->setMinUISceneId(kUILoadingBarTest_Left); - sceneManager->setMaxUISceneId(kUILoadingBarTest_Right_Scale9); + sceneManager->setMaxUISceneId(kUILoadingBarReloadTexture); Scene* scene = sceneManager->currentUIScene(); Director::getInstance()->replaceScene(scene); } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp index 94e1062365..6da67c0a0e 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp @@ -396,4 +396,87 @@ bool UILoadingBarTest_Scale9_State_Change::init() return true; } return false; +} + + +// UILoadingBarReloadTexture + +UILoadingBarReloadTexture::UILoadingBarReloadTexture() +: _count(0) +{ + +} + +UILoadingBarReloadTexture::~UILoadingBarReloadTexture() +{ + +} + +bool UILoadingBarReloadTexture::init() +{ + if (UIScene::init()) + { + Size widgetSize = _widget->getContentSize(); + + // Add the alert + Text *alert = Text::create("LoadingBar right scale9 render", "fonts/Marker Felt.ttf", 20); + alert->setColor(Color3B(159, 168, 176)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 2.7f)); + _uiLayer->addChild(alert); + + LoadingBar* loadingBar = LoadingBar::create("cocosui/slider_bar_active_9patch.png"); + loadingBar->setTag(0); + loadingBar->ignoreContentAdaptWithSize(false); + loadingBar->setScale9Enabled(true); + loadingBar->setCapInsets(Rect(0, 0, 0, 0)); + loadingBar->setContentSize(Size(300, 13)); + loadingBar->setName("texture0"); + loadingBar->setDirection(LoadingBar::Direction::RIGHT); + + loadingBar->setPosition(Vec2(widgetSize.width / 2.0f, + widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f)); + + _uiLayer->addChild(loadingBar); + + auto buttonScale9 = Button::create(); + buttonScale9->setTitleText("ToggleScale9"); + buttonScale9->addClickEventListener([=](Ref*){ + loadingBar->setScale9Enabled(!loadingBar->isScale9Enabled()); + }); + buttonScale9->setPosition(loadingBar->getPosition() + Vec2(-50,50)); + _uiLayer->addChild(buttonScale9); + + auto buttonChangeTexture = Button::create(); + buttonChangeTexture->setTitleText("ChangeTexture"); + buttonChangeTexture->addClickEventListener([=](Ref*){ + auto name = loadingBar->getName(); + if (name == "texture0") + { + loadingBar->loadTexture("cocosui/slider_bar_active_9patch2.png"); + loadingBar->setName("texture1"); + } + else + { + loadingBar->loadTexture("cocosui/slider_bar_active_9patch.png"); + loadingBar->setName("texture0"); + } + }); + buttonChangeTexture->setPosition(loadingBar->getPosition() + Vec2(50,50)); + _uiLayer->addChild(buttonChangeTexture); + + this->scheduleUpdate(); + return true; + } + return false; +} + +void UILoadingBarReloadTexture::update(float delta) +{ + _count++; + if (_count > 100) + { + _count = 0; + } + LoadingBar* loadingBar = static_cast(_uiLayer->getChildByTag(0)); + loadingBar->setPercent(_count); } \ No newline at end of file diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h index c6c8a4d56a..79428689b4 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h @@ -104,7 +104,21 @@ public: protected: UI_SCENE_CREATE_FUNC(UILoadingBarTest_Scale9_State_Change) - int _count; + int _count; +}; + +class UILoadingBarReloadTexture : public UIScene +{ +public: + UILoadingBarReloadTexture(); + ~UILoadingBarReloadTexture(); + void update(float dt); + bool init(); + +protected: + UI_SCENE_CREATE_FUNC(UILoadingBarReloadTexture); + int _count; + }; #endif /* defined(__TestCpp__UILoadingBarTest__) */ diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp index 5de0885b90..90439e937a 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp @@ -71,6 +71,7 @@ static const char* s_testArray[] = "UILoadingBarTest_Scale9_State_Change", "UILoadingBarTest_Left_Scale9", "UILoadingBarTest_Right_Scale9", + "UILoadingBarReloadTexture", "UITextAtlasTest", "UITextTest", @@ -284,6 +285,8 @@ Scene *UISceneManager::currentUIScene() case kUILoadingBarTest_Right_Scale9: return UILoadingBarTest_Right_Scale9::sceneWithTitle(s_testArray[_currentUISceneId]); + case kUILoadingBarReloadTexture: + return UILoadingBarReloadTexture::sceneWithTitle(s_testArray[_currentUISceneId]); case kUITextAtlasTest: return UITextAtlasTest::sceneWithTitle(s_testArray[_currentUISceneId]); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h index f0613a2680..52df15c65d 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h @@ -66,6 +66,7 @@ enum kUILoadingBarTest_Scale9_State_Change, kUILoadingBarTest_Left_Scale9, kUILoadingBarTest_Right_Scale9, + kUILoadingBarReloadTexture, kUITextAtlasTest, kUITextTest, kUITextTest_LineWrap, From 0e67cfcbff1d8a05ceb5886c1b94b692d0b1bcee Mon Sep 17 00:00:00 2001 From: andyque Date: Mon, 26 Jan 2015 14:39:44 +0800 Subject: [PATCH 02/66] improve loading Bar Test --- cocos/ui/UILoadingBar.cpp | 4 +++- .../UILoadingBarTest/UILoadingBarTest.cpp | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cocos/ui/UILoadingBar.cpp b/cocos/ui/UILoadingBar.cpp index c0a2aab2cd..7910dc6899 100644 --- a/cocos/ui/UILoadingBar.cpp +++ b/cocos/ui/UILoadingBar.cpp @@ -193,6 +193,8 @@ void LoadingBar::loadTexture(const std::string& texture,TextureResType texType) barRendererScaleChangedWithSize(); updateContentSizeWithTextureSize(_barRendererTextureSize); + + this->updateProgressBar(); _barRendererAdaptDirty = true; } @@ -216,7 +218,7 @@ void LoadingBar::setScale9Enabled(bool enabled) ignoreContentAdaptWithSize(_prevIgnoreSize); } setCapInsets(_capInsets); - this->setPercent(_percent); + this->updateProgressBar(); _barRendererAdaptDirty = true; } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp index 6da67c0a0e..62b422ac43 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp @@ -427,18 +427,19 @@ bool UILoadingBarReloadTexture::init() LoadingBar* loadingBar = LoadingBar::create("cocosui/slider_bar_active_9patch.png"); loadingBar->setTag(0); loadingBar->ignoreContentAdaptWithSize(false); - loadingBar->setScale9Enabled(true); +// loadingBar->setScale9Enabled(true); loadingBar->setCapInsets(Rect(0, 0, 0, 0)); loadingBar->setContentSize(Size(300, 13)); loadingBar->setName("texture0"); loadingBar->setDirection(LoadingBar::Direction::RIGHT); - + loadingBar->setPercent(70); loadingBar->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f)); _uiLayer->addChild(loadingBar); - auto buttonScale9 = Button::create(); + auto buttonScale9 = Button::create("cocosui/animationbuttonnormal.png", + "cocosui/animationbuttonpressed.png"); buttonScale9->setTitleText("ToggleScale9"); buttonScale9->addClickEventListener([=](Ref*){ loadingBar->setScale9Enabled(!loadingBar->isScale9Enabled()); @@ -446,7 +447,8 @@ bool UILoadingBarReloadTexture::init() buttonScale9->setPosition(loadingBar->getPosition() + Vec2(-50,50)); _uiLayer->addChild(buttonScale9); - auto buttonChangeTexture = Button::create(); + auto buttonChangeTexture = Button::create("cocosui/animationbuttonnormal.png", + "cocosui/animationbuttonpressed.png"); buttonChangeTexture->setTitleText("ChangeTexture"); buttonChangeTexture->addClickEventListener([=](Ref*){ auto name = loadingBar->getName(); From 12cf9da486dc9f07a0781d1dbd930e3d43c40cd3 Mon Sep 17 00:00:00 2001 From: andyque Date: Mon, 26 Jan 2015 14:46:45 +0800 Subject: [PATCH 03/66] improve loadingbar test --- .../CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp index 62b422ac43..fcf8ed7580 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp @@ -419,9 +419,10 @@ bool UILoadingBarReloadTexture::init() Size widgetSize = _widget->getContentSize(); // Add the alert - Text *alert = Text::create("LoadingBar right scale9 render", "fonts/Marker Felt.ttf", 20); + Text *alert = Text::create("Click button to Toggle Scale9 and switch Texture.", "fonts/Marker Felt.ttf", 20); alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 2.7f)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, + widgetSize.height / 2.0f - alert->getContentSize().height * 2.7f)); _uiLayer->addChild(alert); LoadingBar* loadingBar = LoadingBar::create("cocosui/slider_bar_active_9patch.png"); From 691e1925ca440297fbdd00b168de9cbe5424920b Mon Sep 17 00:00:00 2001 From: andyque Date: Mon, 26 Jan 2015 15:05:41 +0800 Subject: [PATCH 04/66] udpate test resource submodule --- tests/cpp-tests/Resources/ccs-res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cpp-tests/Resources/ccs-res b/tests/cpp-tests/Resources/ccs-res index 615f52a6c5..ce5606d4e5 160000 --- a/tests/cpp-tests/Resources/ccs-res +++ b/tests/cpp-tests/Resources/ccs-res @@ -1 +1 @@ -Subproject commit 615f52a6c5fc1f60c6f01832d110c78a65be3a11 +Subproject commit ce5606d4e520d2671a678b0ba3d5a0b84fdb5ab9 From 95e8072afac17cb3b59208eaf36bd32d69910259 Mon Sep 17 00:00:00 2001 From: andyque Date: Mon, 26 Jan 2015 18:26:59 +0800 Subject: [PATCH 05/66] fixed issue #10183 --- cocos/ui/UITextField.cpp | 16 ++++++++++------ .../UITextFieldTest/UITextFieldTest.cpp | 7 ++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cocos/ui/UITextField.cpp b/cocos/ui/UITextField.cpp index 045a3f24d8..b507178e3b 100644 --- a/cocos/ui/UITextField.cpp +++ b/cocos/ui/UITextField.cpp @@ -599,26 +599,30 @@ void TextField::update(float dt) detachWithIMEEvent(); setDetachWithIME(false); } + if (getAttachWithIME()) { attachWithIMEEvent(); setAttachWithIME(false); } + if (getInsertText()) { + //we update the content size first such that when user call getContentSize() in event callback won't be wrong + _textFieldRendererAdaptDirty = true; + updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); + insertTextEvent(); setInsertText(false); - - _textFieldRendererAdaptDirty = true; - updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); } + if (getDeleteBackward()) { - deleteBackwardEvent(); - setDeleteBackward(false); - _textFieldRendererAdaptDirty = true; updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); + + deleteBackwardEvent(); + setDeleteBackward(false); } } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp index 265af8be64..2619787632 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp @@ -426,7 +426,7 @@ bool UITextFieldTest_PlaceHolderColor::init() Size widgetSize = _widget->getContentSize(); // Add a label in which the textfield events will be displayed - _displayValueLabel = Text::create("Set place hold color","fonts/Marker Felt.ttf",32); + _displayValueLabel = Text::create("You should see 16.50000, 34.0000 in the output window the first time you type","fonts/Marker Felt.ttf",12); _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f)); _uiLayer->addChild(_displayValueLabel); @@ -473,7 +473,12 @@ void UITextFieldTest_PlaceHolderColor::textFieldEvent(Ref *pSender, TextField::E break; case TextField::EventType::INSERT_TEXT: + { _displayValueLabel->setString(String::createWithFormat("insert words")->getCString()); + TextField* textField = dynamic_cast(pSender); + auto& contentSize = textField->getContentSize(); + CCLOG("%f, %f", contentSize.width, contentSize.height); + } break; case TextField::EventType::DELETE_BACKWARD: From bb419719aa6b6c63301837366710ded8a0232b78 Mon Sep 17 00:00:00 2001 From: lvlong Date: Mon, 26 Jan 2015 18:40:00 +0800 Subject: [PATCH 06/66] fix bug: about caching uniform. --- cocos/renderer/CCGLProgram.cpp | 16 +++++++++++----- cocos/renderer/CCGLProgram.h | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cocos/renderer/CCGLProgram.cpp b/cocos/renderer/CCGLProgram.cpp index b80e40d6ae..3d2c3a3aec 100644 --- a/cocos/renderer/CCGLProgram.cpp +++ b/cocos/renderer/CCGLProgram.cpp @@ -159,7 +159,7 @@ GLProgram::~GLProgram() for (auto e : _hashForUniforms) { - free(e.second); + free(e.second.first); } _hashForUniforms.clear(); } @@ -662,17 +662,23 @@ bool GLProgram::updateUniformLocation(GLint location, const GLvoid* data, unsign { GLvoid* value = malloc(bytes); memcpy(value, data, bytes ); - _hashForUniforms.insert(std::make_pair(location, value)); + _hashForUniforms.insert(std::make_pair(location, std::make_pair(value, bytes))); } else { - if (memcmp(element->second, data, bytes) == 0) + if (memcmp(element->second.first, data, bytes) == 0) { updated = false; } else { - memcpy(element->second, data, bytes); + if (element->second.second != bytes){ + free(element->second.first); + GLvoid* value = malloc(bytes); + memcpy(value, data, bytes ); + _hashForUniforms[location] = std::make_pair(value, bytes); + }else + memcpy(element->second.first, data, bytes); } } @@ -933,7 +939,7 @@ void GLProgram::reset() for (auto e: _hashForUniforms) { - free(e.second); + free(e.second.first); } _hashForUniforms.clear(); diff --git a/cocos/renderer/CCGLProgram.h b/cocos/renderer/CCGLProgram.h index 4577311262..36054e1d58 100644 --- a/cocos/renderer/CCGLProgram.h +++ b/cocos/renderer/CCGLProgram.h @@ -357,7 +357,7 @@ protected: std::unordered_map _userUniforms; std::unordered_map _vertexAttribs; - std::unordered_map _hashForUniforms; + std::unordered_map> _hashForUniforms; //cached director pointer for calling Director* _director; }; From cc18a3a95552f934ffe24da3eb3beff2d1e8c672 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Mon, 26 Jan 2015 18:44:30 +0800 Subject: [PATCH 07/66] another use case not finished --- .../Classes/Sprite3DTest/Sprite3DTest.cpp | 33 +++++++++++-------- .../Classes/Sprite3DTest/Sprite3DTest.h | 1 + 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index a6b23ed9c6..3c43eaa864 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -2115,13 +2115,13 @@ UseCaseSprite3D::UseCaseSprite3D() auto s = Director::getInstance()->getWinSize(); _useCaseTitles[0] = "transparent 3d sprite and 2d sprite"; - + _useCaseTitles[1] = "ui - 3d - ui"; auto itemPrev = MenuItemImage::create("Images/b1.png", "Images/b2.png", [&](Ref *sender) { _caseIdx--; if (_caseIdx < 0) - _caseIdx = 0; + _caseIdx = (int)USECASE::MAX_CASE_NUM - 1; this->switchCase(); }); @@ -2129,7 +2129,7 @@ UseCaseSprite3D::UseCaseSprite3D() [&](Ref *sender) { _caseIdx++; if (_caseIdx >= (int)USECASE::MAX_CASE_NUM) - _caseIdx = (int)USECASE::MAX_CASE_NUM - 1; + _caseIdx = 0; this->switchCase(); }); @@ -2213,6 +2213,10 @@ void UseCaseSprite3D::switchCase() _sprite3d->setCameraMask(2); _sprite2d->setCameraMask(2); } + else if (_caseIdx == 1) + { + + } scheduleUpdate(); update(0.f); @@ -2220,14 +2224,17 @@ void UseCaseSprite3D::switchCase() void UseCaseSprite3D::update(float delta) { - static float accAngle = 0.f; - accAngle += delta * CC_DEGREES_TO_RADIANS(60); - - float radius = 30.f; - float x = cosf(accAngle) * radius, z = sinf(accAngle) * radius; - - _sprite3d->setPositionX(x); - _sprite3d->setPositionZ(z); - _sprite2d->setPositionX(x); - _sprite2d->setPositionZ(z); + if (_caseIdx == 0) + { + static float accAngle = 0.f; + accAngle += delta * CC_DEGREES_TO_RADIANS(60); + + float radius = 30.f; + float x = cosf(accAngle) * radius, z = sinf(accAngle) * radius; + + _sprite3d->setPositionX(x); + _sprite3d->setPositionZ(z); + _sprite2d->setPositionX(x); + _sprite2d->setPositionZ(z); + } } diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index 13aaed415d..330303d331 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -471,6 +471,7 @@ protected: enum class USECASE{ _3D_WITH_2D, + _UI_3D_UI, MAX_CASE_NUM, }; cocos2d::Label* _label; From a1a7273436eecf66386b97a1b0ebed835288cd4d Mon Sep 17 00:00:00 2001 From: geron-cn Date: Mon, 26 Jan 2015 21:20:26 +0800 Subject: [PATCH 08/66] fix bug: fix crash when lack of projected file --- .../cocostudio/ActionTimeline/CCFrame.cpp | 3 ++ .../cocostudio/ActionTimeline/CSLoader.cpp | 43 +++++++++++-------- plugin | 2 +- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp index fc2227f5d1..a68d3af35b 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp @@ -481,6 +481,9 @@ InnerActionFrame::InnerActionFrame() void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex) { auto innerActiontimeline = static_cast(_node->getActionByTag(_node->getTag())); + if( nullptr == innerActiontimeline) + return; + if (InnerActionType::SingleFrame == _innerActionType) { innerActiontimeline->gotoFrameAndPause(_singleFrameIndex); diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp index 7fceedb098..5d14a35363 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp @@ -833,20 +833,24 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree) auto projectNodeOptions = (ProjectNodeOptions*)options->data(); std::string filePath = projectNodeOptions->fileName()->c_str(); CCLOG("filePath = %s", filePath.c_str()); + + cocostudio::timeline::ActionTimeline* action = nullptr; if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath)) { - node = createNodeWithFlatBuffersFile(filePath); - reader->setPropsWithFlatBuffers(node, options->data()); - - cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath); - if (action) - { - node->runAction(action); - action->gotoFrameAndPause(0); - } + action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath); } + else + { + node = Node::create(); + } + reader->setPropsWithFlatBuffers(node, options->data()); + if (action) + { + node->runAction(action); + action->gotoFrameAndPause(0); + } } else if (classname == "SimpleAudio") { @@ -1164,17 +1168,22 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod std::string filePath = projectNodeOptions->fileName()->c_str(); CCLOG("filePath = %s", filePath.c_str()); + cocostudio::timeline::ActionTimeline* action = nullptr; if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath)) { - node = createNodeWithFlatBuffersForSimulator(filePath); - reader->setPropsWithFlatBuffers(node, options->data()); + node = createNodeWithFlatBuffersFile(filePath); + action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath); - cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator(filePath); - if (action) - { - node->runAction(action); - action->gotoFrameAndPause(0); - } + } + else + { + node = Node::create(); + } + reader->setPropsWithFlatBuffers(node, options->data()); + if (action) + { + node->runAction(action); + action->gotoFrameAndPause(0); } } else if (classname == "SimpleAudio") diff --git a/plugin b/plugin index dc25546289..3609894790 160000 --- a/plugin +++ b/plugin @@ -1 +1 @@ -Subproject commit dc25546289ab18dd273199124dada948638eb5e1 +Subproject commit 3609894790678a7a3a9e66cefe881f75534f98b0 From 937ee25e7b60b5b79610e910dc2777b7d37d3038 Mon Sep 17 00:00:00 2001 From: geron-cn Date: Mon, 26 Jan 2015 21:25:11 +0800 Subject: [PATCH 09/66] revert plugin --- plugin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin b/plugin index 3609894790..dc25546289 160000 --- a/plugin +++ b/plugin @@ -1 +1 @@ -Subproject commit 3609894790678a7a3a9e66cefe881f75534f98b0 +Subproject commit dc25546289ab18dd273199124dada948638eb5e1 From 15adaf2877052541ac6f14286c7a38cc89fdd201 Mon Sep 17 00:00:00 2001 From: Nite Luo Date: Mon, 26 Jan 2015 16:37:11 -0800 Subject: [PATCH 10/66] save/restore render state --- cocos/renderer/CCRenderer.cpp | 41 ++++++++++++++++++++++++++++++++++- cocos/renderer/CCRenderer.h | 10 ++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index dc718d284f..e4b087dbc0 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -131,6 +131,41 @@ void RenderQueue::clear() _queuePosZ.clear(); } +void RenderQueue::saveRenderState() +{ + _isDepthEnabled = glIsEnabled(GL_DEPTH_TEST); + _isCullEnabled = glIsEnabled(GL_CULL_FACE); + glGetBooleanv(GL_DEPTH_WRITEMASK, &_isDepthWrite); + + CHECK_GL_ERROR_DEBUG(); +} + +void RenderQueue::restoreRenderState() +{ + if (_isCullEnabled) + { + glEnable(GL_CULL_FACE); + } + else + { + glDisable(GL_CULL_FACE); + } + + + if (_isDepthEnabled) + { + glEnable(GL_DEPTH_TEST); + } + else + { + glDisable(GL_DEPTH_TEST); + } + + glDepthMask(_isDepthWrite); + + CHECK_GL_ERROR_DEBUG(); +} + // // // @@ -465,10 +500,12 @@ void Renderer::processRenderCommand(RenderCommand* command) } } -void Renderer::visitRenderQueue(const RenderQueue& queue) +void Renderer::visitRenderQueue(RenderQueue& queue) { ssize_t size = queue.size(); + queue.saveRenderState(); + //Process Opaque Object const std::vector& opaqueQueue = queue.getOpaqueCommands(); if (opaqueQueue.size() > 0) @@ -507,6 +544,8 @@ void Renderer::visitRenderQueue(const RenderQueue& queue) processRenderCommand(queue[index]); } flush(); + + queue.restoreRenderState(); } void Renderer::render() diff --git a/cocos/renderer/CCRenderer.h b/cocos/renderer/CCRenderer.h index 70392c0be4..b0c206b167 100644 --- a/cocos/renderer/CCRenderer.h +++ b/cocos/renderer/CCRenderer.h @@ -57,12 +57,20 @@ public: ssize_t getOpaqueQueueSize() const { return _queue3DOpaque.size(); } const std::vector& getOpaqueCommands() const { return _queue3DOpaque; } + void saveRenderState(); + void restoreRenderState(); + protected: std::vector _queue3DOpaque; std::vector _queue3DTransparent; std::vector _queueNegZ; std::vector _queue0; std::vector _queuePosZ; + + //Render State related + bool _isCullEnabled; + bool _isDepthEnabled; + GLboolean _isDepthWrite; }; struct RenderStackElement @@ -162,7 +170,7 @@ protected: void flushTriangles(); void processRenderCommand(RenderCommand* command); - void visitRenderQueue(const RenderQueue& queue); + void visitRenderQueue(RenderQueue& queue); void fillVerticesAndIndices(const TrianglesCommand* cmd); void fillQuads(const QuadCommand* cmd); From d857164768d6bb481092a93014cbb84a397e7477 Mon Sep 17 00:00:00 2001 From: cpascal Date: Tue, 27 Jan 2015 11:10:04 +0900 Subject: [PATCH 11/66] Added override of ui::EditBox::getDescription() --- cocos/ui/UIEditBox/UIEditBox.cpp | 5 +++++ cocos/ui/UIEditBox/UIEditBox.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/cocos/ui/UIEditBox/UIEditBox.cpp b/cocos/ui/UIEditBox/UIEditBox.cpp index 73a504930d..6d71191916 100644 --- a/cocos/ui/UIEditBox/UIEditBox.cpp +++ b/cocos/ui/UIEditBox/UIEditBox.cpp @@ -385,6 +385,11 @@ void EditBox::setAnchorPoint(const Vec2& anchorPoint) } } +std::string EditBox::getDescription() const +{ + return "EditBox"; +} + void EditBox::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { Widget::visit(renderer, parentTransform, parentFlags); diff --git a/cocos/ui/UIEditBox/UIEditBox.h b/cocos/ui/UIEditBox/UIEditBox.h index 72af4a2627..d35e27d60e 100644 --- a/cocos/ui/UIEditBox/UIEditBox.h +++ b/cocos/ui/UIEditBox/UIEditBox.h @@ -394,6 +394,12 @@ namespace ui { virtual void setVisible(bool visible) override; virtual void setContentSize(const Size& size) override; virtual void setAnchorPoint(const Vec2& anchorPoint) override; + + /** + * Returns the "class name" of widget. + */ + virtual std::string getDescription() const override; + /** * @js NA * @lua NA From 7b81f3a81115afecb2fd22b5f1bbf3f72cd75f05 Mon Sep 17 00:00:00 2001 From: andyque Date: Tue, 27 Jan 2015 10:17:41 +0800 Subject: [PATCH 12/66] remove unused code --- cocos/ui/UIButton.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 7847428e18..45ef0531a4 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -449,15 +449,9 @@ void Button::onPressStateChangedToPressed() _buttonNormalRenderer->setScale(_pressedTextureScaleXInSize + _zoomScale, _pressedTextureScaleYInSize + _zoomScale); _titleRenderer->stopAllActions(); + Action *zoomTitleAction = ScaleTo::create(ZOOM_ACTION_TIME_STEP, 1.0f + _zoomScale, 1.0f + _zoomScale); - if (_unifySize) - { - _titleRenderer->runAction(zoomTitleAction); - } - else - { - _titleRenderer->runAction(zoomTitleAction->clone()); - } + _titleRenderer->runAction(zoomTitleAction); } } else From 390c336a19f222b02347d46df689bc353a4da6bb Mon Sep 17 00:00:00 2001 From: geron-cn Date: Tue, 27 Jan 2015 12:04:14 +0800 Subject: [PATCH 13/66] FIX animationfio lost after actiontimeline clone --- .../cocostudio/ActionTimeline/CCActionTimeline.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp index f112b125a1..cf3fc88605 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp @@ -181,7 +181,11 @@ ActionTimeline* ActionTimeline::clone() const newAction->addTimeline(newTimeline); } } - + + for( auto info : _animationInfos) + { + newAction->addAnimationInfo(info.second); + } return newAction; } From 4792a44a87d73e3f6e22c14f513e87509c7b213c Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 27 Jan 2015 05:58:53 +0000 Subject: [PATCH 14/66] [AUTO]: updating luabinding automatically --- cocos/scripting/lua-bindings/auto/api/EditBox.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cocos/scripting/lua-bindings/auto/api/EditBox.lua b/cocos/scripting/lua-bindings/auto/api/EditBox.lua index ca9abc6723..82e27b5b40 100644 --- a/cocos/scripting/lua-bindings/auto/api/EditBox.lua +++ b/cocos/scripting/lua-bindings/auto/api/EditBox.lua @@ -254,6 +254,12 @@ -- @param #vec2_table anchorPoint -- @return EditBox#EditBox self (return value: ccui.EditBox) +-------------------------------- +-- Returns the "class name" of widget. +-- @function [parent=#EditBox] getDescription +-- @param self +-- @return string#string ret (return value: string) + -------------------------------- -- -- @function [parent=#EditBox] setPosition From a38b210803d0267869a6e57721b866468219dd9f Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 27 Jan 2015 14:29:09 +0800 Subject: [PATCH 15/66] add depth in renderCommand refactor rendering order of renderQueue --- cocos/renderer/CCRenderCommand.cpp | 7 +- cocos/renderer/CCRenderCommand.h | 7 +- cocos/renderer/CCRenderer.cpp | 101 ++++++++++++++++------------- cocos/renderer/CCRenderer.h | 30 +++++++-- 4 files changed, 91 insertions(+), 54 deletions(-) diff --git a/cocos/renderer/CCRenderCommand.cpp b/cocos/renderer/CCRenderCommand.cpp index 0a8f3c7ee6..a0affae504 100644 --- a/cocos/renderer/CCRenderCommand.cpp +++ b/cocos/renderer/CCRenderCommand.cpp @@ -35,6 +35,7 @@ RenderCommand::RenderCommand() , _isTransparent(true) , _skipBatching(false) , _is3D(false) +, _depth(0) { } @@ -44,14 +45,16 @@ RenderCommand::~RenderCommand() void RenderCommand::init(float globalZOrder, const cocos2d::Mat4 &transform, uint32_t flags) { + _globalOrder = globalZOrder; if (flags & Node::FLAGS_RENDER_AS_3D) { - _globalOrder = Camera::getVisitingCamera()->getDepthInView(transform); + _depth = Camera::getVisitingCamera()->getDepthInView(transform); set3D(true); } else { - _globalOrder = globalZOrder; + set3D(false); + _depth = 0; } } diff --git a/cocos/renderer/CCRenderCommand.h b/cocos/renderer/CCRenderCommand.h index a127944bcb..88d98c0ae7 100644 --- a/cocos/renderer/CCRenderCommand.h +++ b/cocos/renderer/CCRenderCommand.h @@ -77,7 +77,9 @@ public: inline bool is3D() const { return _is3D; } inline void set3D(bool value) { _is3D = value; } - + + inline float getDepth() const { return _depth; } + protected: RenderCommand(); virtual ~RenderCommand(); @@ -98,6 +100,9 @@ protected: // is the command been rendered on 3D pass bool _is3D; + + // depth + float _depth; }; NS_CC_END diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index dc718d284f..a9794ccde1 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -53,7 +53,7 @@ static bool compareRenderCommand(RenderCommand* a, RenderCommand* b) static bool compare3DCommand(RenderCommand* a, RenderCommand* b) { - return a->getGlobalOrder() > b->getGlobalOrder(); + return (a->getGlobalOrder() > b->getGlobalOrder()) || (a->getGlobalOrder() == b->getGlobalOrder() && a->getDepth() > b->getDepth()); } // queue @@ -61,74 +61,78 @@ static bool compare3DCommand(RenderCommand* a, RenderCommand* b) void RenderQueue::push_back(RenderCommand* command) { float z = command->getGlobalOrder(); - if(command->is3D()) + if(z < 0) { - if(command->isTransparent()) + _commands[QUEUE_GROUP::GLOBALZ_NEG].push_back(command); + } + else if(z > 0) + { + _commands[QUEUE_GROUP::GLOBALZ_POS].push_back(command); + } + else + { + if(command->is3D()) { - _queue3DTransparent.push_back(command); + if(command->isTransparent()) + { + _commands[QUEUE_GROUP::TRANSPARENT_3D].push_back(command); + } + else + { + _commands[QUEUE_GROUP::OPAQUE_3D].push_back(command); + } } else { - _queue3DOpaque.push_back(command); + _commands[QUEUE_GROUP::GLOBALZ_ZERO].push_back(command); } } - else if(z < 0) - _queueNegZ.push_back(command); - else if(z > 0) - _queuePosZ.push_back(command); - else - _queue0.push_back(command); } ssize_t RenderQueue::size() const { - return _queue3DOpaque.size() + _queue3DTransparent.size() + _queueNegZ.size() + _queue0.size() + _queuePosZ.size(); + ssize_t result(0); + for(int index = 0; index < QUEUE_GROUP::QUEUE_GROUP_SIZE; ++index) + { + result += _commands[index].size(); + } + + return result; } void RenderQueue::sort() { // Don't sort _queue0, it already comes sorted - std::sort(std::begin(_queue3DTransparent), std::end(_queue3DTransparent), compare3DCommand); - std::sort(std::begin(_queueNegZ), std::end(_queueNegZ), compareRenderCommand); - std::sort(std::begin(_queuePosZ), std::end(_queuePosZ), compareRenderCommand); + std::sort(std::begin(_commands[QUEUE_GROUP::TRANSPARENT_3D]), std::end(_commands[QUEUE_GROUP::TRANSPARENT_3D]), compare3DCommand); + std::sort(std::begin(_commands[QUEUE_GROUP::GLOBALZ_NEG]), std::end(_commands[QUEUE_GROUP::GLOBALZ_NEG]), compareRenderCommand); + std::sort(std::begin(_commands[QUEUE_GROUP::GLOBALZ_POS]), std::end(_commands[QUEUE_GROUP::GLOBALZ_POS]), compareRenderCommand); } RenderCommand* RenderQueue::operator[](ssize_t index) const { - if(index < static_cast(_queue3DOpaque.size())) - return _queue3DOpaque[index]; - - index -= _queue3DOpaque.size(); - - if(index < static_cast(_queue3DTransparent.size())) - return _queue3DTransparent[index]; + for(int queIndex = 0; queIndex < QUEUE_GROUP::QUEUE_GROUP_SIZE; ++queIndex) + { + if(index < static_cast(_commands[queIndex].size())) + return _commands[queIndex][index]; + else + { + index -= _commands[queIndex].size(); + } + } - index -= _queue3DTransparent.size(); - - if(index < static_cast(_queueNegZ.size())) - return _queueNegZ[index]; - - index -= _queueNegZ.size(); - - if(index < static_cast(_queue0.size())) - return _queue0[index]; - - index -= _queue0.size(); - - if(index < static_cast(_queuePosZ.size())) - return _queuePosZ[index]; - CCASSERT(false, "invalid index"); return nullptr; + + } void RenderQueue::clear() { - _queue3DOpaque.clear(); - _queue3DTransparent.clear(); - _queueNegZ.clear(); - _queue0.clear(); - _queuePosZ.clear(); + _commands.clear(); + for(int index = GLOBALZ_NEG; index <= GLOBALZ_POS; ++index) + { + _commands.push_back(std::vector()); + } } // @@ -467,8 +471,17 @@ void Renderer::processRenderCommand(RenderCommand* command) void Renderer::visitRenderQueue(const RenderQueue& queue) { + ssize_t visitIndex(0); ssize_t size = queue.size(); + ssize_t negZSize = queue.getSubQueueSize(RenderQueue::QUEUE_GROUP::GLOBALZ_NEG); + //Process NegZ Objects + for (ssize_t index = 0; index < negZSize; ++index) + { + processRenderCommand(queue[index]); + } + flush(); + visitIndex = negZSize; //Process Opaque Object const std::vector& opaqueQueue = queue.getOpaqueCommands(); if (opaqueQueue.size() > 0) @@ -484,7 +497,7 @@ void Renderer::visitRenderQueue(const RenderQueue& queue) glDepthMask(false); } flush(); - + visitIndex += queue.getOpaqueQueueSize(); //Setup Transparent rendering if (opaqueQueue.size() > 0) { @@ -502,7 +515,7 @@ void Renderer::visitRenderQueue(const RenderQueue& queue) } //Process Transparent Object - for (ssize_t index = queue.getOpaqueQueueSize(); index < size; ++index) + for (ssize_t index = visitIndex; index < size; ++index) { processRenderCommand(queue[index]); } diff --git a/cocos/renderer/CCRenderer.h b/cocos/renderer/CCRenderer.h index 70392c0be4..adf700dde8 100644 --- a/cocos/renderer/CCRenderer.h +++ b/cocos/renderer/CCRenderer.h @@ -47,22 +47,38 @@ class MeshCommand; are the ones that have `z < 0` and `z > 0`. */ class RenderQueue { +public: + enum QUEUE_GROUP + { + GLOBALZ_NEG = 0, + OPAQUE_3D = 1, + TRANSPARENT_3D = 2, + GLOBALZ_ZERO = 3, + GLOBALZ_POS = 4, + QUEUE_GROUP_SIZE = 5, + }; public: + RenderQueue() + { + clear(); + } void push_back(RenderCommand* command); ssize_t size() const; void sort(); RenderCommand* operator[](ssize_t index) const; void clear(); - ssize_t getOpaqueQueueSize() const { return _queue3DOpaque.size(); } - const std::vector& getOpaqueCommands() const { return _queue3DOpaque; } + inline ssize_t getSubQueueSize(QUEUE_GROUP group) const { return _commands[group].size();} + inline ssize_t getOpaqueQueueSize() const { return _commands[OPAQUE_3D].size(); } + inline const std::vector& getOpaqueCommands() const { return _commands[OPAQUE_3D]; } protected: - std::vector _queue3DOpaque; - std::vector _queue3DTransparent; - std::vector _queueNegZ; - std::vector _queue0; - std::vector _queuePosZ; + std::vector> _commands; +// std::vector _queue3DOpaque; +// std::vector _queue3DTransparent; +// std::vector _queueNegZ; +// std::vector _queue0; +// std::vector _queuePosZ; }; struct RenderStackElement From ed1b7edce7714d76725e9452db886cba2c49f894 Mon Sep 17 00:00:00 2001 From: pipu Date: Tue, 27 Jan 2015 15:09:48 +0800 Subject: [PATCH 16/66] Modify that parse ignoreSize for TextAtlas, TextBMFont. --- .../cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp | 2 ++ .../WidgetReader/TextBMFontReader/TextBMFontReader.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp index 1f78ac201b..ae06d71567 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp @@ -267,6 +267,8 @@ namespace cocostudio auto widgetReader = WidgetReader::getInstance(); widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); + labelAtlas->ignoreContentAdaptWithSize(true); + } Node* TextAtlasReader::createNodeWithFlatBuffers(const flatbuffers::Table *textAtlasOptions) diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp index 39502292ca..c3cc6d2665 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp @@ -241,6 +241,8 @@ namespace cocostudio auto widgetReader = WidgetReader::getInstance(); widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions()); + + labelBMFont->ignoreContentAdaptWithSize(true); } Node* TextBMFontReader::createNodeWithFlatBuffers(const flatbuffers::Table *textBMFontOptions) From 9744439048c4e2237aa7b80bb01a9bb0ffd17440 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Tue, 27 Jan 2015 15:24:15 +0800 Subject: [PATCH 17/66] use case 2 finished --- .../Classes/Sprite3DTest/Sprite3DTest.cpp | 108 +++++++++++++----- .../Classes/Sprite3DTest/Sprite3DTest.h | 4 + 2 files changed, 83 insertions(+), 29 deletions(-) diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index 3c43eaa864..083acfb4d2 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -2111,6 +2111,7 @@ UseCaseSprite3D::UseCaseSprite3D() : _caseIdx(0) , _sprite3d(nullptr) , _sprite2d(nullptr) +, _layer(nullptr) { auto s = Director::getInstance()->getWinSize(); @@ -2167,25 +2168,15 @@ std::string UseCaseSprite3D::subtitle() const void UseCaseSprite3D::switchCase() { - if (_sprite3d) - { - removeChild(_sprite3d); - _sprite3d = nullptr; - } - if (_sprite2d) - { - removeChild(_sprite2d); - _sprite2d = nullptr; - } + removeChildByTag(101); auto s = Director::getInstance()->getWinSize(); _label->setString(_useCaseTitles[_caseIdx]); - if (_caseIdx == 0) + if (_caseIdx == 0) // use case 1, 3d transparent sprite + 2d sprite { std::string filename = "Sprite3DTest/girl.c3b"; auto sprite = Sprite3D::create(filename); sprite->setScale(0.15f); - addChild(sprite); auto animation = Animation3D::create(filename); if (animation) { @@ -2202,24 +2193,79 @@ void UseCaseSprite3D::switchCase() circleBack->setRotation3D(Vec3(90, 0, 0)); - addChild(circleBack); - auto pos = sprite->getPosition3D(); circleBack->setPosition3D(Vec3(pos.x, pos.y, pos.z - 1)); - _sprite3d = sprite; - _sprite2d = circleBack; - _sprite3d->setOpacity(250); - _sprite3d->setCameraMask(2); - _sprite2d->setCameraMask(2); - } - else if (_caseIdx == 1) - { + sprite->setOpacity(250); + sprite->setCameraMask(2); + circleBack->setCameraMask(2); + sprite->setTag(3); + circleBack->setTag(2); + auto node = Node::create(); + node->addChild(sprite); + node->addChild(circleBack); + node->setTag(101); + addChild(node); + + scheduleUpdate(); + update(0.f); + } + else if (_caseIdx == 1) // use case 2, ui - 3d - ui, last ui should on the top + { + auto layer = LayerColor::create(Color4B(0, 0, 100, 255), s.width / 2.f, s.height / 2.f); + layer->setPosition(s.width * 0.25f, s.height * 0.25f); + addChild(layer); + + std::string filename = "Sprite3DTest/girl.c3b"; + auto sprite = Sprite3D::create(filename); + sprite->setScale(0.5f); + auto animation = Animation3D::create(filename); + if (animation) + { + auto animate = Animate3D::create(animation); + sprite->runAction(RepeatForever::create(animate)); + } + sprite->setPosition(s.width * 0.25f, s.height * 0.125f); + layer->addChild(sprite); + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig,"Message"); + auto item1 = MenuItemLabel::create(label1,CC_CALLBACK_1(UseCaseSprite3D::menuCallback_Message,this) ); + auto label2 = Label::createWithTTF(ttfConfig,"Message"); + auto item2 = MenuItemLabel::create(label2, CC_CALLBACK_1(UseCaseSprite3D::menuCallback_Message,this) ); + + item1->setPosition( Vec2(s.width * 0.5f - item1->getContentSize().width * 0.5f, s.height * 0.5f - item1->getContentSize().height ) ); + item2->setPosition( Vec2(s.width * 0.5f - item1->getContentSize().width * 0.5f, s.height * 0.5f - item1->getContentSize().height * 2.f ) ); + + auto pMenu1 = CCMenu::create(item1, item2, nullptr); + pMenu1->setPosition(Vec2(0,0)); + layer->addChild(pMenu1); + + layer->setTag(101); + } +} + +void UseCaseSprite3D::menuCallback_Message(Ref* sender) +{ + auto layer = getChildByTag(101); + auto message = layer->getChildByTag(102); // message layer + if (message) + layer->removeChild(message); + else + { + // create a new message layer on the top + auto s = layer->getContentSize(); + auto messagelayer = LayerColor::create(Color4B(100, 100, 0, 255)); + messagelayer->setContentSize(Size(s.width * 0.5f, s.height * 0.5f)); + messagelayer->setPosition(Vec2(s.width * 0.25f, s.height * 0.25f)); + auto label = Label::create(); + label->setString("This Message Layer \n Should Be On Top"); + label->setPosition(Vec2(s.width * 0.25f, s.height * 0.25f)); + messagelayer->addChild(label); + messagelayer->setTag(102); + layer->addChild(messagelayer); } - - scheduleUpdate(); - update(0.f); } void UseCaseSprite3D::update(float delta) @@ -2232,9 +2278,13 @@ void UseCaseSprite3D::update(float delta) float radius = 30.f; float x = cosf(accAngle) * radius, z = sinf(accAngle) * radius; - _sprite3d->setPositionX(x); - _sprite3d->setPositionZ(z); - _sprite2d->setPositionX(x); - _sprite2d->setPositionZ(z); + auto node = getChildByTag(101); + auto sprite3d = node->getChildByTag(3); + auto circle = node->getChildByTag(2); + + sprite3d->setPositionX(x); + sprite3d->setPositionZ(z); + circle->setPositionX(x); + circle->setPositionZ(z); } } diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index 330303d331..999644bda5 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -455,6 +455,7 @@ protected: float _accAngle; }; +// 3d + 2d use case class UseCaseSprite3D : public Sprite3DTestDemo { public: @@ -465,6 +466,8 @@ public: virtual void update(float delta) override; + void menuCallback_Message(Ref* sender); + protected: void switchCase(); @@ -480,6 +483,7 @@ protected: cocos2d::Sprite3D* _sprite3d; cocos2d::Sprite3D* _sprite2d; + cocos2d::Layer* _layer; }; class Sprite3DTestScene : public TestScene From 89f107ac08bb8164356db12339c36af32526b626 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Tue, 27 Jan 2015 15:25:40 +0800 Subject: [PATCH 18/66] remove unused variables --- tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp | 3 --- tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h | 4 ---- 2 files changed, 7 deletions(-) diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index 083acfb4d2..1e1faad178 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -2109,9 +2109,6 @@ void QuaternionTest::update(float delta) UseCaseSprite3D::UseCaseSprite3D() : _caseIdx(0) -, _sprite3d(nullptr) -, _sprite2d(nullptr) -, _layer(nullptr) { auto s = Director::getInstance()->getWinSize(); diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index 999644bda5..812e84171c 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -480,10 +480,6 @@ protected: cocos2d::Label* _label; int _caseIdx; // use case index std::string _useCaseTitles[(int)USECASE::MAX_CASE_NUM]; - - cocos2d::Sprite3D* _sprite3d; - cocos2d::Sprite3D* _sprite2d; - cocos2d::Layer* _layer; }; class Sprite3DTestScene : public TestScene From 57970da3989615ebbc39fca562f9b7bd1cb91cc5 Mon Sep 17 00:00:00 2001 From: lvlong Date: Tue, 27 Jan 2015 15:50:05 +0800 Subject: [PATCH 19/66] Do some optimize --- cocos/renderer/CCGLProgram.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cocos/renderer/CCGLProgram.cpp b/cocos/renderer/CCGLProgram.cpp index 3d2c3a3aec..ac5ee3ecfe 100644 --- a/cocos/renderer/CCGLProgram.cpp +++ b/cocos/renderer/CCGLProgram.cpp @@ -672,9 +672,8 @@ bool GLProgram::updateUniformLocation(GLint location, const GLvoid* data, unsign } else { - if (element->second.second != bytes){ - free(element->second.first); - GLvoid* value = malloc(bytes); + if (element->second.second < bytes){ + GLvoid* value = realloc(element->second.first, bytes); memcpy(value, data, bytes ); _hashForUniforms[location] = std::make_pair(value, bytes); }else From f2335fb3bcfdfeadada8fa494bb96826973dd15c Mon Sep 17 00:00:00 2001 From: Wenhai Lin Date: Tue, 27 Jan 2015 16:13:45 +0800 Subject: [PATCH 20/66] Fixed Scale9Sprite can't run move/scale/rotation action in physics scene --- cocos/2d/CCNode.cpp | 49 ++++++++++++++++++++++++++++++-- cocos/2d/CCNode.h | 2 +- cocos/base/CCDirector.cpp | 6 ++++ cocos/physics/CCPhysicsWorld.cpp | 17 +++++++---- cocos/physics/CCPhysicsWorld.h | 1 + 5 files changed, 65 insertions(+), 10 deletions(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 1eb1bb57bd..26acd89da3 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -126,6 +126,7 @@ Node::Node(void) , _physicsScaleStartY(1.0f) , _physicsRotation(0.0f) , _physicsTransformDirty(true) +, _updateTransformFromPhysics(true) #endif , _displayedOpacity(255) , _realOpacity(255) @@ -330,6 +331,11 @@ void Node::setRotation(float rotation) _rotationZ_X = _rotationZ_Y = rotation; _transformUpdated = _transformDirty = _inverseDirty = true; +#if CC_USE_PHYSICS + if (_physicsBody && _physicsBody->getWorld()) { + _physicsBody->getWorld()->_updateBodyTransform = true; + } +#endif updateRotationQuat(); } @@ -466,6 +472,11 @@ void Node::setScale(float scale) _scaleX = _scaleY = _scaleZ = scale; _transformUpdated = _transformDirty = _inverseDirty = true; +#if CC_USE_PHYSICS + if (_physicsBody && _physicsBody->getWorld()) { + _physicsBody->getWorld()->_updateBodyTransform = true; + } +#endif } /// scaleX getter @@ -483,6 +494,11 @@ void Node::setScale(float scaleX,float scaleY) _scaleX = scaleX; _scaleY = scaleY; _transformUpdated = _transformDirty = _inverseDirty = true; +#if CC_USE_PHYSICS + if (_physicsBody && _physicsBody->getWorld()) { + _physicsBody->getWorld()->_updateBodyTransform = true; + } +#endif } /// scaleX setter @@ -493,6 +509,11 @@ void Node::setScaleX(float scaleX) _scaleX = scaleX; _transformUpdated = _transformDirty = _inverseDirty = true; +#if CC_USE_PHYSICS + if (_physicsBody && _physicsBody->getWorld()) { + _physicsBody->getWorld()->_updateBodyTransform = true; + } +#endif } /// scaleY getter @@ -532,6 +553,11 @@ void Node::setScaleY(float scaleY) _scaleY = scaleY; _transformUpdated = _transformDirty = _inverseDirty = true; +#if CC_USE_PHYSICS + if (_physicsBody && _physicsBody->getWorld()) { + _physicsBody->getWorld()->_updateBodyTransform = true; + } +#endif } @@ -563,6 +589,11 @@ void Node::setPosition(float x, float y) _transformUpdated = _transformDirty = _inverseDirty = true; _usingNormalizedPosition = false; +#if CC_USE_PHYSICS + if (_physicsBody && _physicsBody->getWorld()) { + _physicsBody->getWorld()->_updateBodyTransform = true; + } +#endif } void Node::setPosition3D(const Vec3& position) @@ -631,6 +662,11 @@ void Node::setNormalizedPosition(const Vec2& position) _usingNormalizedPosition = true; _normalizedPositionDirty = true; _transformUpdated = _transformDirty = _inverseDirty = true; +#if CC_USE_PHYSICS + if (_physicsBody && _physicsBody->getWorld()) { + _physicsBody->getWorld()->_updateBodyTransform = true; + } +#endif } ssize_t Node::getChildrenCount() const @@ -1270,9 +1306,16 @@ uint32_t Node::processParentFlags(const Mat4& parentTransform, uint32_t parentFl if(flags & FLAGS_DIRTY_MASK) _modelViewTransform = this->transform(parentTransform); - + +#if CC_USE_PHYSICS + if (_updateTransformFromPhysics) { + _transformUpdated = false; + _contentSizeDirty = false; + } +#else _transformUpdated = false; _contentSizeDirty = false; +#endif return flags; } @@ -2021,7 +2064,7 @@ void Node::setPhysicsBody(PhysicsBody* body) } } -void Node::updatePhysicsBodyTransform(Scene* scene, const Mat4& parentTransform, uint32_t parentFlags, float parentScaleX, float parentScaleY) +void Node::updatePhysicsBodyTransform(const Mat4& parentTransform, uint32_t parentFlags, float parentScaleX, float parentScaleY) { _updateTransformFromPhysics = false; auto flags = processParentFlags(parentTransform, parentFlags); @@ -2046,7 +2089,7 @@ void Node::updatePhysicsBodyTransform(Scene* scene, const Mat4& parentTransform, for (auto node : _children) { - node->updatePhysicsBodyTransform(scene, _modelViewTransform, flags, scaleX, scaleY); + node->updatePhysicsBodyTransform(_modelViewTransform, flags, scaleX, scaleY); } } diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 89f8d8da82..1533a4e698 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -1543,7 +1543,7 @@ public: void updateTransformFromPhysics(const Mat4& parentTransform, uint32_t parentFlags); - virtual void updatePhysicsBodyTransform(Scene* scene, const Mat4& parentTransform, uint32_t parentFlags, float parentScaleX, float parentScaleY); + virtual void updatePhysicsBodyTransform(const Mat4& parentTransform, uint32_t parentFlags, float parentScaleX, float parentScaleY); #endif // overrides diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 82fcfd12dc..8f39cfaac1 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -300,6 +300,12 @@ void Director::drawScene() _runningScene->render(_renderer); _eventDispatcher->dispatchEvent(_eventAfterVisit); +#if CC_USE_PHYSICS + if(physicsWorld) + { + physicsWorld->_updateBodyTransform = false; + } +#endif } // draw the notifications node diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index 1989ecd16a..33d3380160 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -334,7 +334,7 @@ void PhysicsWorld::rayCast(PhysicsRayCastCallbackFunc func, const Vec2& point1, { if (!_delayAddBodies.empty() || !_delayRemoveBodies.empty()) { - _scene->updatePhysicsBodyTransform(_scene, _scene->getNodeToParentTransform(), 0, 1.0f, 1.0f); + _scene->updatePhysicsBodyTransform(_scene->getNodeToParentTransform(), 0, 1.0f, 1.0f); updateBodies(); } RayCastCallbackInfo info = { this, func, point1, point2, data }; @@ -358,7 +358,7 @@ void PhysicsWorld::queryRect(PhysicsQueryRectCallbackFunc func, const Rect& rect { if (!_delayAddBodies.empty() || !_delayRemoveBodies.empty()) { - _scene->updatePhysicsBodyTransform(_scene, _scene->getNodeToParentTransform(), 0, 1.0f, 1.0f); + _scene->updatePhysicsBodyTransform(_scene->getNodeToParentTransform(), 0, 1.0f, 1.0f); updateBodies(); } RectQueryCallbackInfo info = {this, func, data}; @@ -381,7 +381,7 @@ void PhysicsWorld::queryPoint(PhysicsQueryPointCallbackFunc func, const Vec2& po { if (!_delayAddBodies.empty() || !_delayRemoveBodies.empty()) { - _scene->updatePhysicsBodyTransform(_scene, _scene->getNodeToParentTransform(), 0, 1.0f, 1.0f); + _scene->updatePhysicsBodyTransform(_scene->getNodeToParentTransform(), 0, 1.0f, 1.0f); updateBodies(); } PointQueryCallbackInfo info = {this, func, data}; @@ -823,9 +823,13 @@ void PhysicsWorld::update(float delta, bool userCall/* = false*/) return; } - _scene->updatePhysicsBodyTransform(_scene, _scene->getNodeToParentTransform(), 0, 1.0f, 1.0f); - - if (!_delayAddBodies.empty() || !_delayRemoveBodies.empty()) + if(_updateBodyTransform || !_delayAddBodies.empty()) + { + _scene->updatePhysicsBodyTransform(_scene->getNodeToParentTransform(), 0, 1.0f, 1.0f); + updateBodies(); + _updateBodyTransform = false; + } + else if (!_delayRemoveBodies.empty()) { updateBodies(); } @@ -880,6 +884,7 @@ PhysicsWorld::PhysicsWorld() , _autoStep(true) , _debugDraw(nullptr) , _debugDrawMask(DEBUGDRAW_NONE) +, _updateBodyTransform(false) { } diff --git a/cocos/physics/CCPhysicsWorld.h b/cocos/physics/CCPhysicsWorld.h index 08224937c2..6f714b55ab 100644 --- a/cocos/physics/CCPhysicsWorld.h +++ b/cocos/physics/CCPhysicsWorld.h @@ -204,6 +204,7 @@ protected: int _substeps; cpSpace* _cpSpace; + bool _updateBodyTransform; Vector _bodies; std::list _joints; Scene* _scene; From fad8f9f1da6a44d23bc41193af8a551864f4df4f Mon Sep 17 00:00:00 2001 From: yangxiao Date: Tue, 27 Jan 2015 16:31:15 +0800 Subject: [PATCH 21/66] format --- cocos/renderer/CCGLProgram.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos/renderer/CCGLProgram.cpp b/cocos/renderer/CCGLProgram.cpp index 01bea45748..5996c9a066 100644 --- a/cocos/renderer/CCGLProgram.cpp +++ b/cocos/renderer/CCGLProgram.cpp @@ -675,11 +675,13 @@ bool GLProgram::updateUniformLocation(GLint location, const GLvoid* data, unsign } else { - if (element->second.second < bytes){ + if (element->second.second < bytes) + { GLvoid* value = realloc(element->second.first, bytes); memcpy(value, data, bytes ); _hashForUniforms[location] = std::make_pair(value, bytes); - }else + } + else memcpy(element->second.first, data, bytes); } } From d9bb6192dc0e1b8b782a36f11bd211685163f69d Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 27 Jan 2015 17:29:12 +0800 Subject: [PATCH 22/66] Fixed may access wrong memory in Scheduler::schedule --- cocos/base/CCScheduler.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos/base/CCScheduler.cpp b/cocos/base/CCScheduler.cpp index 1fb32a1379..8ed57ecab6 100644 --- a/cocos/base/CCScheduler.cpp +++ b/cocos/base/CCScheduler.cpp @@ -311,9 +311,9 @@ void Scheduler::schedule(const ccSchedulerFunc& callback, void *target, float in { for (int i = 0; i < element->timers->num; ++i) { - TimerTargetCallback *timer = static_cast(element->timers->arr[i]); + TimerTargetCallback *timer = dynamic_cast(element->timers->arr[i]); - if (key == timer->getKey()) + if (timer && key == timer->getKey()) { CCLOG("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", timer->getInterval(), interval); timer->setInterval(interval); @@ -1012,9 +1012,9 @@ void Scheduler::schedule(SEL_SCHEDULE selector, Ref *target, float interval, uns { for (int i = 0; i < element->timers->num; ++i) { - TimerTargetSelector *timer = static_cast(element->timers->arr[i]); + TimerTargetSelector *timer = dynamic_cast(element->timers->arr[i]); - if (selector == timer->getSelector()) + if (timer && selector == timer->getSelector()) { CCLOG("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", timer->getInterval(), interval); timer->setInterval(interval); From 71abf22a0d60c6f259bf620740811ce64f6143d1 Mon Sep 17 00:00:00 2001 From: cheyiliu Date: Tue, 27 Jan 2015 18:22:39 +0800 Subject: [PATCH 23/66] Update SocketIOTest.cpp just a fix for spelling --- .../Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp index 87dbb13435..6ca58d5895 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp @@ -81,7 +81,7 @@ SocketIOTestLayer::SocketIOTestLayer(void) itemTestEndpointDisconnect->setPosition(Vec2(VisibleRect::right().x - labelTestEndpointDisconnect->getContentSize().width / 2 - 5, winSize.height - MARGIN - 4 * SPACE)); menuRequest->addChild(itemTestEndpointDisconnect); - // Sahred Status Label + // Shared Status Label _sioClientStatus = Label::createWithTTF("Not connected...", "fonts/arial.ttf", 14, Size(320, 100), TextHAlignment::LEFT); _sioClientStatus->setAnchorPoint(Vec2(0, 0)); _sioClientStatus->setPosition(Vec2(VisibleRect::left().x, VisibleRect::rightBottom().y)); From df10a974fa82d2497a4b038c5e187657a6ab9083 Mon Sep 17 00:00:00 2001 From: geron-cn Date: Tue, 27 Jan 2015 23:19:27 +0800 Subject: [PATCH 24/66] fix projectnode --- cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp index 5d14a35363..5efee44637 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp @@ -839,7 +839,6 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree) { node = createNodeWithFlatBuffersFile(filePath); action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath); - } else { @@ -1171,9 +1170,8 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod cocostudio::timeline::ActionTimeline* action = nullptr; if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath)) { - node = createNodeWithFlatBuffersFile(filePath); - action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath); - + node = createNodeWithFlatBuffersForSimulator(filePath); + action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator(filePath); } else { From 3268dbc9fd53d2934f42c3ffe71502243854db3b Mon Sep 17 00:00:00 2001 From: geron-cn Date: Wed, 28 Jan 2015 02:12:09 +0800 Subject: [PATCH 25/66] add cpp-test for animation list and projected --- .../ActionTimelineTestScene.cpp | 81 +++++++++++++++++- .../ActionTimelineTestScene.h | 26 +++++- .../Resources/ActionTimeline/Animation.csb | Bin 0 -> 1164 bytes .../Resources/ActionTimeline/Animation.csd | 47 ++++++++++ .../ActionTimeline/Default/Button_Disable.png | Bin 0 -> 1111 bytes .../ActionTimeline/Default/Sprite.png | Bin 0 -> 1773 bytes .../ActionTimeline/TestAnimation.csb | Bin 0 -> 896 bytes .../ActionTimeline/TestAnimation.csd | 34 ++++++++ .../ActionTimeline/TestNullProjectNode.csb | Bin 0 -> 660 bytes .../ActionTimeline/TestNullProjectNode.csd | 28 ++++++ .../Resources/hd/ActionTimeline/Animation.csb | Bin 0 -> 1164 bytes .../Resources/hd/ActionTimeline/Animation.csd | 47 ++++++++++ .../ActionTimeline/Default/Button_Disable.png | Bin 0 -> 1111 bytes .../hd/ActionTimeline/Default/Sprite.png | Bin 0 -> 1773 bytes 14 files changed, 261 insertions(+), 2 deletions(-) create mode 100755 tests/cpp-tests/Resources/ActionTimeline/Animation.csb create mode 100755 tests/cpp-tests/Resources/ActionTimeline/Animation.csd create mode 100755 tests/cpp-tests/Resources/ActionTimeline/Default/Button_Disable.png create mode 100755 tests/cpp-tests/Resources/ActionTimeline/Default/Sprite.png create mode 100755 tests/cpp-tests/Resources/ActionTimeline/TestAnimation.csb create mode 100755 tests/cpp-tests/Resources/ActionTimeline/TestAnimation.csd create mode 100755 tests/cpp-tests/Resources/ActionTimeline/TestNullProjectNode.csb create mode 100755 tests/cpp-tests/Resources/ActionTimeline/TestNullProjectNode.csd create mode 100755 tests/cpp-tests/Resources/hd/ActionTimeline/Animation.csb create mode 100755 tests/cpp-tests/Resources/hd/ActionTimeline/Animation.csd create mode 100755 tests/cpp-tests/Resources/hd/ActionTimeline/Default/Button_Disable.png create mode 100755 tests/cpp-tests/Resources/hd/ActionTimeline/Default/Sprite.png diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp index 14921367a6..97d12eef94 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp @@ -34,7 +34,17 @@ Layer *CreateAnimationLayer(int index) case TEST_TIMELINE_PERFORMACE: pLayer = new (std::nothrow) TestTimelinePerformance(); break; + case TEST_TIMELINEACTION_ANIMATIONLIST: + pLayer = new (std::nothrow) TestTimelineAnimationList(); + break; + case TEST_TIMELINEPROJECTNODE: + pLayer = new (std::nothrow) TestTimelineProjectNode(); + break; + case TEST_PROJECTNODEFORSIMALATOR: + pLayer = new (std::nothrow) TestProjectNodeForSimulator; + break; default: + CCLOG("NONE OF THIS TEST LAYER"); break; } @@ -185,7 +195,8 @@ void ActionTimelineTestLayer::nextCallback(Ref *pSender) void ActionTimelineTestLayer::backCallback(Ref *pSender) { Scene *s = new (std::nothrow) ActionTimelineTestScene(); - s->addChild( BackAnimationTest() ); + auto a = BackAnimationTest(); + s->addChild( a); Director::getInstance()->replaceScene(s); s->release(); } @@ -324,3 +335,71 @@ std::string TestTimelinePerformance::title() const return "Test ActionTimeline performance"; } +// TestTimelineAnimationList +void TestTimelineAnimationList::onEnter() +{ + ActionTimelineTestLayer::onEnter(); + Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb"); + ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb"); + action->addAnimationInfo({"stand", 0, 40}); + action->addAnimationInfo({"walk", 41, 81}); + node->runAction(action); + action->play("walk", true); + + node->setScale(0.2f); + node->setPosition(150,100); + addChild(node); +} + +std::string TestTimelineAnimationList::title() const +{ + return "Test ActionTimeline AnimationList"; +} + + +//TestTimelineProjectNode +//InnerActionFrame make InnerAction Play until action's duration or next InnerActionFrame +void TestTimelineProjectNode::onEnter() +{ + ActionTimelineTestLayer::onEnter(); + Node* node = CSLoader::createNode("ActionTimeline/TestAnimation.csb"); + ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/TestAnimation.csb"); + + node->runAction(action); + action->gotoFrameAndPlay(0, true); + + node->setPosition(-300, -300); + addChild(node); +} + +std::string TestTimelineProjectNode::title() const +{ + return "Test ActionTimeline ProjectNode"; +} + +//TestProjectNodeForSimulator +//InnerActionFrame make InnerAction Play until action's duration or next InnerActionFrame +void TestProjectNodeForSimulator::onEnter() +{ + ActionTimelineTestLayer::onEnter(); + Node* node = CSLoader::getInstance()->createNodeWithFlatBuffersForSimulator("ActionTimeline/TestAnimation.csd"); + ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator("ActionTimeline/TestAnimation.csd"); + + node->runAction(action); + action->gotoFrameAndPlay(0, true); + + node->setPosition(-300, -300); + addChild(node); + + // test for when ProjectNode file lost + Node* lackProjectNodefileNode = CSLoader::getInstance()->createNodeWithFlatBuffersForSimulator("ActionTimeline/TestNullProjectNode.csd"); + ActionTimeline* lackProjectNodefileAction = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator("ActionTimeline/TestNullProjectNode.csd"); + lackProjectNodefileNode->runAction(lackProjectNodefileAction); + lackProjectNodefileAction->gotoFrameAndPlay(0); + addChild(lackProjectNodefileNode); +} + +std::string TestProjectNodeForSimulator::title() const +{ + return "Test ProjectNode for Simalator"; +} diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.h b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.h index 1e681aa4c4..141e60e296 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.h +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.h @@ -25,7 +25,10 @@ enum { TEST_CHANGE_PLAY_SECTION, // TEST_TIMELINE_FRAME_EVENT, TEST_TIMELINE_PERFORMACE, - + TEST_TIMELINEACTION_ANIMATIONLIST, + TEST_TIMELINEPROJECTNODE, + TEST_PROJECTNODEFORSIMALATOR, + TEST_ANIMATION_LAYER_COUNT }; @@ -85,4 +88,25 @@ public: virtual std::string title() const override; }; +class TestTimelineAnimationList : public ActionTimelineTestLayer +{ +public: + virtual void onEnter(); + virtual std::string title() const override; +}; + +class TestTimelineProjectNode : public ActionTimelineTestLayer +{ +public: + virtual void onEnter(); + virtual std::string title() const override; +}; + +class TestProjectNodeForSimulator : public ActionTimelineTestLayer +{ +public: + virtual void onEnter(); + virtual std::string title() const override; +}; + #endif // __ANIMATION_SCENE_H__ diff --git a/tests/cpp-tests/Resources/ActionTimeline/Animation.csb b/tests/cpp-tests/Resources/ActionTimeline/Animation.csb new file mode 100755 index 0000000000000000000000000000000000000000..f64ece32db3cc0c7dc1dc57fea5d499f1c04739e GIT binary patch literal 1164 zcmZWoO-oxr6g`bG1{)=Ww~*o@ixgax*C-+`gapkZn@TZ1KthcY8hxTMf*bP_`~j|X z>q-!Jx@b23hyIArbu~R_?wjUGE}WVBX71Oyb6)@;k42=BMUGm41+L%<6k{xLAEfMT zhWbjl9G1f}HIonA`n>PFjz-@1iie7kCbpx!mMmqLlM>5y!oI|_fXEPyzjgVDH3%;wOK8@%Ty<% z28Rh&(Xuj#%v^-J0O4A|{>ExntF@wvUEeT%EA^{+IxvNzYQe{;={ z@_mbXZh~@T=Vx2~x>wzbCw+=Yb1*eW$@rg0M&EjCagn|gb(`IGbkz9SI_D=+M3GRw zJKAe6aJL-%pbX;kKW~}^lU^dWW_Oxs{AhMmuwvE;R$?X1M#Fw57s?x=sBuX3nA-=ovE_{vpvRS9MI&D=h&{C)rBcXxQO`SD@xS@pcH P#`^93tk+hL|9}1g)sBBT literal 0 HcmV?d00001 diff --git a/tests/cpp-tests/Resources/ActionTimeline/Animation.csd b/tests/cpp-tests/Resources/ActionTimeline/Animation.csd new file mode 100755 index 0000000000..f849e56513 --- /dev/null +++ b/tests/cpp-tests/Resources/ActionTimeline/Animation.csd @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/cpp-tests/Resources/ActionTimeline/Default/Button_Disable.png b/tests/cpp-tests/Resources/ActionTimeline/Default/Button_Disable.png new file mode 100755 index 0000000000000000000000000000000000000000..62ee840c40d3f8defc9d735d97d463afb5413f2e GIT binary patch literal 1111 zcmbVL&ui0A91jfV7_J8|q7FS&wP740^=iUnbqCU0wK^TXtI&3f3T zFsJ?r9-RXb)PuLFY@nB+7ab@YC=)z*5Cp;DMe(I;H-)i-A<6r`@B4l}-yiS$y)`;~ zwyX0*Cx&5NnIS2MRuX-uJKE8Io9MWJmg7(^z%gqA))WU|3C$`3JYy)6AO{p}`sx}O zz_7NGo-e>c_PnTC2C4Wqq-WR&jbQ_Wo~@{50P!N2)Xg~Y?db}E>sp++6wT6EI|WMm zP~8Dz_2Il)FROw^44%OUJP{EX04lg=R7_X&;zWa2M6$1@2)tne%W+~Ss6uuWPgxGY zqhutk(hP(1JjrlTo@e@SmS$LrMlT;`I5EnLY(L(72;|MtCd8bSZu&yII8lPo7AdM$ ztC6(`X*rV=BM5@e!Lngw5q76dsCZ%1?P)Pcz*QaHhPq|qKBH2!sxVHVNOw{&>}+n9Z z(b1(S70FVo1~6epiWBIB)O1Zu@^p$#%4vpUX+Fj&C>Y9bkH6Zbr9wUEi@VK_HoM~kOf)kN8jc^zmvd;a<}*?v?`?kF z2nOcpBlDlkpcgwe)EDSJhQ$}~jbArjzCC1b>EBmAU!1-Bpc;Uw*anq`WxQ z3tw-JSMDu8TzLQH_H+1gwf<~ryU49xYdak1j@euP2)_@Fw0{V_SWNu9GkA3I-CA|) g@l0T5JhUEK#e&O$*}3)mC;d^+$ivd3&D+EJ z>P7Y=lSm}5h;UI1u~O`hyDRZtQM)LFSf=A*IUb9y#WNHbLgK5?H3$%)RU{%Yh(eW_ z+KwzHk(|_;I5{qtMsk&?mZGrhP>fnVfhLg_hZ^+?Wio;TYmh{Zjt36aHG+Uf#RFHc zq%^5sh^RH;Sr`(V6&0t*}IVCWKHv5`v!xV_gf?+5Kpwl2al}6lfFvR4tU@kob7{5Tm8m3yy zjS)%4Z4oCPsK#+UmrBjZ$e?5}C@7Xlg*Y6Jor6vfCNzQ#nL1oy4AvRuPB4fNgA&u| zaSf^i?2L*vXd2D~2~XdIpw&yIZ;5q=@k9|RqZ$=@Dny}CwOV^zW7-Bh26^Ykd$kR5 znROi9#Z?c514k-HBYvMUnaaAlZ=D2gIQgeudthz^es@j&7WMWs=31u#uW z7lBcE_=_4`R7O3{l`H7KfrK6CDt(Msd`jM)iO&76t;O3Z+J8 z7c8_F=uNyL1kpGgox-t`}S?~6Nk6sgXoBv!HD6wc`mVvn7J7dB7U6l+FHr|F8LqeXMtTRU);aPzKBm%-=?s5Cb$drN;!jqYoC@bIF1_v|C8 zJ>3^FDA(lK+yo>u)YjDfuzuQT&cILWF4YeNe(If@>zFqb>A?_t;pg)fhVI=tl|ikH zeBt?WQupR(yYsq?KCGOyG?xN_LstFllCyqWUFmy0Q&7~}x+MQ~b7|**X=>KwSN;9@ zzZX~~*UI-Z$Qvq;JHJ-@8m3oVd8j~9pPHJQHb?%-x`u{tB_;=A+VG_7Nhbugt6aCY zIwdD315?QDpRYfcK3M5Jla+&EjxmRePx$v%`?oH4nY~p~DUh963i_UE>N-^07Es#d zWd737Ye=2-Tybla={|VyaispbG1b>>UE+BvbL?&7zfWzE?U-t^!>V3F78djI&Usr9!Arr+)}wr(k1WezTIXg<_xAk zoLYC|v)qr}o$tDtyOa6`2R)DX1O=3ItdKn!9_D^^tkd7`%F@6RFzv$3^LPHTZ1`RT z9xRBjaxE(>GgQkeFMEuPjL0sivH6qy`Vzc!a9NQhtWG!t$vg^MoV}mYjpcc6#StE^ z8yUH~x<6@C(fj*ft`GGH9Gd6m=BB#1CvyHD#cpO(D)_q5&(f2kdeY~ZDZ7_ifjk{m zHU~SE1}@O=tH~VhwQP>6bSi9V?z}OF>k3@1Jk1EbAx4YtAC>EAirTU6>9Ym4WLIktaf?l)hNX{41S WkD^+(+0 zm;4g6RGxo_Llf7X(p(Gf-S{{n3nt`GKAmQ|Dl% ztT&7QEr9pT1NC<6tl4SBZ9lv`5+6R@6RheP6xXd)?q{ zI49O}yZrF}_v9uurLmk*4jDNk-Jg$sI2m&X-_}9i6->a$8YV!gss3w9*T>6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/cpp-tests/Resources/ActionTimeline/TestNullProjectNode.csb b/tests/cpp-tests/Resources/ActionTimeline/TestNullProjectNode.csb new file mode 100755 index 0000000000000000000000000000000000000000..f0b88003572a5c613235078ad0b77a3a21644bd4 GIT binary patch literal 660 zcmZvZy-EW?6os#GjX_sXNMW(X7F$@zu#pHBLIQ4)N&}1-?Yn83 zSU24Zxe3?z%ja5IgnUo=vXn`2X3AN$8MpwNeGKNSyb z0?iEOY_^#Y&Qg}szqD~opU-93yz8%3?+5$%hCn-|4O#hQH>k<{wZoF + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/cpp-tests/Resources/hd/ActionTimeline/Animation.csb b/tests/cpp-tests/Resources/hd/ActionTimeline/Animation.csb new file mode 100755 index 0000000000000000000000000000000000000000..f64ece32db3cc0c7dc1dc57fea5d499f1c04739e GIT binary patch literal 1164 zcmZWoO-oxr6g`bG1{)=Ww~*o@ixgax*C-+`gapkZn@TZ1KthcY8hxTMf*bP_`~j|X z>q-!Jx@b23hyIArbu~R_?wjUGE}WVBX71Oyb6)@;k42=BMUGm41+L%<6k{xLAEfMT zhWbjl9G1f}HIonA`n>PFjz-@1iie7kCbpx!mMmqLlM>5y!oI|_fXEPyzjgVDH3%;wOK8@%Ty<% z28Rh&(Xuj#%v^-J0O4A|{>ExntF@wvUEeT%EA^{+IxvNzYQe{;={ z@_mbXZh~@T=Vx2~x>wzbCw+=Yb1*eW$@rg0M&EjCagn|gb(`IGbkz9SI_D=+M3GRw zJKAe6aJL-%pbX;kKW~}^lU^dWW_Oxs{AhMmuwvE;R$?X1M#Fw57s?x=sBuX3nA-=ovE_{vpvRS9MI&D=h&{C)rBcXxQO`SD@xS@pcH P#`^93tk+hL|9}1g)sBBT literal 0 HcmV?d00001 diff --git a/tests/cpp-tests/Resources/hd/ActionTimeline/Animation.csd b/tests/cpp-tests/Resources/hd/ActionTimeline/Animation.csd new file mode 100755 index 0000000000..f849e56513 --- /dev/null +++ b/tests/cpp-tests/Resources/hd/ActionTimeline/Animation.csd @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/cpp-tests/Resources/hd/ActionTimeline/Default/Button_Disable.png b/tests/cpp-tests/Resources/hd/ActionTimeline/Default/Button_Disable.png new file mode 100755 index 0000000000000000000000000000000000000000..62ee840c40d3f8defc9d735d97d463afb5413f2e GIT binary patch literal 1111 zcmbVL&ui0A91jfV7_J8|q7FS&wP740^=iUnbqCU0wK^TXtI&3f3T zFsJ?r9-RXb)PuLFY@nB+7ab@YC=)z*5Cp;DMe(I;H-)i-A<6r`@B4l}-yiS$y)`;~ zwyX0*Cx&5NnIS2MRuX-uJKE8Io9MWJmg7(^z%gqA))WU|3C$`3JYy)6AO{p}`sx}O zz_7NGo-e>c_PnTC2C4Wqq-WR&jbQ_Wo~@{50P!N2)Xg~Y?db}E>sp++6wT6EI|WMm zP~8Dz_2Il)FROw^44%OUJP{EX04lg=R7_X&;zWa2M6$1@2)tne%W+~Ss6uuWPgxGY zqhutk(hP(1JjrlTo@e@SmS$LrMlT;`I5EnLY(L(72;|MtCd8bSZu&yII8lPo7AdM$ ztC6(`X*rV=BM5@e!Lngw5q76dsCZ%1?P)Pcz*QaHhPq|qKBH2!sxVHVNOw{&>}+n9Z z(b1(S70FVo1~6epiWBIB)O1Zu@^p$#%4vpUX+Fj&C>Y9bkH6Zbr9wUEi@VK_HoM~kOf)kN8jc^zmvd;a<}*?v?`?kF z2nOcpBlDlkpcgwe)EDSJhQ$}~jbArjzCC1b>EBmAU!1-Bpc;Uw*anq`WxQ z3tw-JSMDu8TzLQH_H+1gwf<~ryU49xYdak1j@euP2)_@Fw0{V_SWNu9GkA3I-CA|) g@l0T5JhUEK#e&O$*}3)mC;d^+$ivd3&D+EJ z>P7Y=lSm}5h;UI1u~O`hyDRZtQM)LFSf=A*IUb9y#WNHbLgK5?H3$%)RU{%Yh(eW_ z+KwzHk(|_;I5{qtMsk&?mZGrhP>fnVfhLg_hZ^+?Wio;TYmh{Zjt36aHG+Uf#RFHc zq%^5sh^RH;Sr`(V6&0t*}IVCWKHv5`v!xV_gf?+5Kpwl2al}6lfFvR4tU@kob7{5Tm8m3yy zjS)%4Z4oCPsK#+UmrBjZ$e?5}C@7Xlg*Y6Jor6vfCNzQ#nL1oy4AvRuPB4fNgA&u| zaSf^i?2L*vXd2D~2~XdIpw&yIZ;5q=@k9|RqZ$=@Dny}CwOV^zW7-Bh26^Ykd$kR5 znROi9#Z?c514k-HBYvMUnaaAlZ=D2gIQgeudthz^es@j&7WMWs=31u#uW z7lBcE_=_4`R7O3{l`H7KfrK6CDt(Msd`jM)iO&76t;O3Z+J8 z7c8_F=uNyL1kpGgox-t`}S?~6Nk6sgXoBv!HD6wc`mVvn7J7dB7U6l+FHr|F8LqeXMtTRU);aPzKBm%-=?s5Cb$drN;!jqYoC@bIF1_v|C8 zJ>3^FDA(lK+yo>u)YjDfuzuQT&cILWF4YeNe(If@>zFqb>A?_t;pg)fhVI=tl|ikH zeBt?WQupR(yYsq?KCGOyG?xN_LstFllCyqWUFmy0Q&7~}x+MQ~b7|**X=>KwSN;9@ zzZX~~*UI-Z$Qvq;JHJ-@8m3oVd8j~9pPHJQHb?%-x`u{tB_;=A+VG_7Nhbugt6aCY zIwdD315?QDpRYfcK3M5Jla+&EjxmRePx$v%`?oH4nY~p~DUh963i_UE>N-^07Es#d zWd737Ye=2-Tybla={|VyaispbG1b>>UE+BvbL?&7zfWzE?U-t^!>V3F78djI&Usr9!Arr+)}wr(k1WezTIXg<_xAk zoLYC|v)qr}o$tDtyOa6`2R)DX1O=3ItdKn!9_D^^tkd7`%F@6RFzv$3^LPHTZ1`RT z9xRBjaxE(>GgQkeFMEuPjL0sivH6qy`Vzc!a9NQhtWG!t$vg^MoV}mYjpcc6#StE^ z8yUH~x<6@C(fj*ft`GGH9Gd6m=BB#1CvyHD#cpO(D)_q5&(f2kdeY~ZDZ7_ifjk{m zHU~SE1}@O=tH~VhwQP>6bSi9V?z}OF>k3@1Jk1EbAx4YtAC>EAirTU6>9Ym4WLIktaf?l)hNX{41S WkD^+(+ Date: Tue, 27 Jan 2015 11:12:51 -0800 Subject: [PATCH 26/66] Add Queue_count for render queues --- cocos/renderer/CCRenderer.cpp | 2 +- cocos/renderer/CCRenderer.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index a9794ccde1..9ff56859fe 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -129,7 +129,7 @@ RenderCommand* RenderQueue::operator[](ssize_t index) const void RenderQueue::clear() { _commands.clear(); - for(int index = GLOBALZ_NEG; index <= GLOBALZ_POS; ++index) + for(int index = 0; index < QUEUE_COUNT; ++index) { _commands.push_back(std::vector()); } diff --git a/cocos/renderer/CCRenderer.h b/cocos/renderer/CCRenderer.h index adf700dde8..bf9b6477d8 100644 --- a/cocos/renderer/CCRenderer.h +++ b/cocos/renderer/CCRenderer.h @@ -56,6 +56,7 @@ public: GLOBALZ_ZERO = 3, GLOBALZ_POS = 4, QUEUE_GROUP_SIZE = 5, + QUEUE_COUNT, }; public: From 3cd74ee8cea759c837fb972f1fc0333d0f999692 Mon Sep 17 00:00:00 2001 From: Nite Luo Date: Tue, 27 Jan 2015 13:49:49 -0800 Subject: [PATCH 27/66] Fix BillboardTest --- .../Classes/BillBoardTest/BillBoardTest.cpp | 59 +++++++++++++++++-- .../Classes/BillBoardTest/BillBoardTest.h | 8 +++ 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp b/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp index d33b7a6fc8..490be99e66 100644 --- a/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp +++ b/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp @@ -47,7 +47,7 @@ static std::function createFunctions[] = #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) -static Layer* nextSpriteTestAction() +static Layer* nextTest() { sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; @@ -56,7 +56,7 @@ static Layer* nextSpriteTestAction() return layer; } -static Layer* backSpriteTestAction() +static Layer* backTest() { sceneIdx--; int total = MAX_LAYER; @@ -67,7 +67,7 @@ static Layer* backSpriteTestAction() return layer; } -static Layer* restartSpriteTestAction() +static Layer* restartTest() { auto layer = (createFunctions[sceneIdx])(); return layer; @@ -137,6 +137,31 @@ std::string BillBoardRotationTest::subtitle() const return "All the sprites should still facing camera"; } +void BillBoardRotationTest::restartCallback(Ref* sender) +{ + auto s = new (std::nothrow) BillBoardTestScene(); + s->addChild(restartTest()); + + Director::getInstance()->replaceScene(s); + s->release(); +} + +void BillBoardRotationTest::nextCallback(Ref* sender) +{ + auto s = new (std::nothrow) BillBoardTestScene(); + s->addChild(nextTest()); + Director::getInstance()->replaceScene(s); + s->release(); +} + +void BillBoardRotationTest::backCallback(Ref* sender) +{ + auto s = new (std::nothrow) BillBoardTestScene(); + s->addChild(backTest()); + Director::getInstance()->replaceScene(s); + s->release(); +} + //------------------------------------------------------------------ // // Billboard Rendering Test @@ -338,9 +363,35 @@ void BillBoardTest::rotateCameraCallback(Ref* sender,float value) _camera->setRotation3D(rotation3D); } + +void BillBoardTest::restartCallback(Ref* sender) +{ + auto s = new (std::nothrow) BillBoardTestScene(); + s->addChild(restartTest()); + + Director::getInstance()->replaceScene(s); + s->release(); +} + +void BillBoardTest::nextCallback(Ref* sender) +{ + auto s = new (std::nothrow) BillBoardTestScene(); + s->addChild(nextTest()); + Director::getInstance()->replaceScene(s); + s->release(); +} + +void BillBoardTest::backCallback(Ref* sender) +{ + auto s = new (std::nothrow) BillBoardTestScene(); + s->addChild(backTest()); + Director::getInstance()->replaceScene(s); + s->release(); +} + void BillBoardTestScene::runThisTest() { - auto layer = nextSpriteTestAction(); + auto layer = nextTest(); addChild(layer); Director::getInstance()->replaceScene(this); } diff --git a/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.h b/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.h index 3bbf65ae28..a897703a54 100644 --- a/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.h +++ b/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.h @@ -43,6 +43,10 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; + virtual void restartCallback(Ref* sender) override; + virtual void nextCallback(Ref* sender) override; + virtual void backCallback(Ref* sender) override; + protected: }; @@ -63,6 +67,10 @@ public: void menuCallback_orientedPoint(Ref* sender); void menuCallback_orientedPlane(Ref* sender); + virtual void restartCallback(Ref* sender) override; + virtual void nextCallback(Ref* sender) override; + virtual void backCallback(Ref* sender) override; + protected: Camera* _camera; Layer* _layerBillBorad; From b89e255099cebe8d844c40b9641c75e96f71ab10 Mon Sep 17 00:00:00 2001 From: Nite Luo Date: Tue, 27 Jan 2015 14:41:16 -0800 Subject: [PATCH 28/66] Finish organize the render queue --- cocos/renderer/CCRenderer.cpp | 130 +++++++++++++++++++++------------- cocos/renderer/CCRenderer.h | 3 +- 2 files changed, 83 insertions(+), 50 deletions(-) diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index b4ee6be402..edcfb96837 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -506,69 +506,103 @@ void Renderer::processRenderCommand(RenderCommand* command) void Renderer::visitRenderQueue(RenderQueue& queue) { - ssize_t visitIndex(0); - ssize_t size = queue.size(); - ssize_t negZSize = queue.getSubQueueSize(RenderQueue::QUEUE_GROUP::GLOBALZ_NEG); - queue.saveRenderState(); - //Process NegZ Objects - if(_isDepthTestFor2D) + // + //Process Global-Z < 0 Objects + // + const std::vector& zNegQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::GLOBALZ_NEG); + if (zNegQueue.size() > 0) { - glEnable(GL_DEPTH_TEST); - glDepthMask(true); - } - else - { - glDisable(GL_DEPTH_TEST); - glDepthMask(false); - } - for (ssize_t index = 0; index < negZSize; ++index) - { - processRenderCommand(queue[index]); - } - flush(); - visitIndex = negZSize; - - //Process Opaque Object - const std::vector& opaqueQueue = queue.getOpaqueCommands(); - if (opaqueQueue.size() > 0) - { - glDepthMask(true); - glEnable(GL_DEPTH_TEST); - - for (auto it = opaqueQueue.cbegin(); it != opaqueQueue.cend(); ++it) { + if(_isDepthTestFor2D) + { + glEnable(GL_DEPTH_TEST); + glDepthMask(true); + } + else + { + glDisable(GL_DEPTH_TEST); + glDepthMask(false); + } + for (auto it = zNegQueue.cbegin(); it != zNegQueue.cend(); ++it) + { processRenderCommand(*it); } + flush(); - glDisable(GL_DEPTH_TEST); - glDepthMask(false); + //Clear depth to achieve layered rendering + glClear(GL_DEPTH_BUFFER_BIT); } - flush(); - visitIndex += queue.getOpaqueQueueSize(); - //Setup Transparent rendering + // + //Process Opaque Object + // + const std::vector& opaqueQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::OPAQUE_3D); if (opaqueQueue.size() > 0) { - glEnable(GL_DEPTH_TEST); - } - else - { - glDisable(GL_DEPTH_TEST); - } - - if(_isDepthTestFor2D) - { - glEnable(GL_DEPTH_TEST); glDepthMask(true); + glEnable(GL_DEPTH_TEST); + + for (auto it = opaqueQueue.cbegin(); it != opaqueQueue.cend(); ++it) + { + processRenderCommand(*it); + } + flush(); } - //Process Transparent Object - for (ssize_t index = visitIndex; index < size; ++index) + // + //Process 3D Transparent object + // + std::vector transQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::TRANSPARENT_3D); + if (transQueue.size() > 0) { - processRenderCommand(queue[index]); + glEnable(GL_DEPTH_TEST); + glDepthMask(false); + + for (auto it = transQueue.cbegin(); it != transQueue.cend(); ++it) + { + processRenderCommand(*it); + } + flush(); + } + + // + //Process Global-Z = 0 Queue + // + std::vector zZeroQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::GLOBALZ_ZERO); + if (zZeroQueue.size() > 0) + { + if(_isDepthTestFor2D) + { + glEnable(GL_DEPTH_TEST); + glDepthMask(true); + } + else + { + glDisable(GL_DEPTH_TEST); + glDepthMask(false); + } + for (auto it = zZeroQueue.cbegin(); it != zZeroQueue.cend(); ++it) + { + processRenderCommand(*it); + } + flush(); + + glClear(GL_DEPTH_BUFFER_BIT); + } + + // + //Process Global-Z > 0 Queue + // + std::vector zPosQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::GLOBALZ_POS); + if (zPosQueue.size() > 0) + { + for (auto it = zPosQueue.cbegin(); it != zPosQueue.cend(); ++it) + { + processRenderCommand(*it); + } + flush(); } - flush(); queue.restoreRenderState(); } diff --git a/cocos/renderer/CCRenderer.h b/cocos/renderer/CCRenderer.h index e5fda0d2b7..a2177d7594 100644 --- a/cocos/renderer/CCRenderer.h +++ b/cocos/renderer/CCRenderer.h @@ -69,9 +69,8 @@ public: void sort(); RenderCommand* operator[](ssize_t index) const; void clear(); + inline std::vector& getSubQueue(QUEUE_GROUP group) { return _commands[group]; } inline ssize_t getSubQueueSize(QUEUE_GROUP group) const { return _commands[group].size();} - inline ssize_t getOpaqueQueueSize() const { return _commands[OPAQUE_3D].size(); } - inline const std::vector& getOpaqueCommands() const { return _commands[OPAQUE_3D]; } void saveRenderState(); void restoreRenderState(); From 8f539a01075a9047280e6b6aea51862244719cf1 Mon Sep 17 00:00:00 2001 From: Nite Luo Date: Tue, 27 Jan 2015 15:41:58 -0800 Subject: [PATCH 29/66] Make PositionZ independent from global Z --- cocos/2d/CCCamera.cpp | 7 ------- cocos/2d/CCCamera.h | 4 ---- cocos/2d/CCNode.cpp | 4 ---- cocos/renderer/CCRenderer.cpp | 9 +++++---- tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp | 1 - 5 files changed, 5 insertions(+), 20 deletions(-) diff --git a/cocos/2d/CCCamera.cpp b/cocos/2d/CCCamera.cpp index 354bdcdb73..1fa4807f2e 100644 --- a/cocos/2d/CCCamera.cpp +++ b/cocos/2d/CCCamera.cpp @@ -91,13 +91,6 @@ Camera::~Camera() } -void Camera::setPosition3D(const Vec3& position) -{ - Node::setPosition3D(position); - - _transformUpdated = _transformDirty = _inverseDirty = true; -} - const Mat4& Camera::getProjectionMatrix() const { return _projection; diff --git a/cocos/2d/CCCamera.h b/cocos/2d/CCCamera.h index 37fbfeac6a..5e15eb23f8 100644 --- a/cocos/2d/CCCamera.h +++ b/cocos/2d/CCCamera.h @@ -102,10 +102,6 @@ public: /**get & set Camera flag*/ CameraFlag getCameraFlag() const { return (CameraFlag)_cameraFlag; } void setCameraFlag(CameraFlag flag) { _cameraFlag = (unsigned short)flag; } - /** - * Sets the position (X, Y, and Z) in its parent's coordinate system - */ - virtual void setPosition3D(const Vec3& position) override; /** * Make Camera looks at target diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index c933eef593..ebac7333ab 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -609,10 +609,6 @@ void Node::setPositionZ(float positionZ) _transformUpdated = _transformDirty = _inverseDirty = true; _positionZ = positionZ; - - // FIXME: BUG - // Global Z Order should based on the modelViewTransform - setGlobalZOrder(positionZ); } /// position getter diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index edcfb96837..b876ff1ebd 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -53,7 +53,7 @@ static bool compareRenderCommand(RenderCommand* a, RenderCommand* b) static bool compare3DCommand(RenderCommand* a, RenderCommand* b) { - return (a->getGlobalOrder() > b->getGlobalOrder()) || (a->getGlobalOrder() == b->getGlobalOrder() && a->getDepth() > b->getDepth()); + return a->getDepth() > b->getDepth(); } // queue @@ -529,9 +529,6 @@ void Renderer::visitRenderQueue(RenderQueue& queue) processRenderCommand(*it); } flush(); - - //Clear depth to achieve layered rendering - glClear(GL_DEPTH_BUFFER_BIT); } // @@ -540,7 +537,9 @@ void Renderer::visitRenderQueue(RenderQueue& queue) const std::vector& opaqueQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::OPAQUE_3D); if (opaqueQueue.size() > 0) { + //Clear depth to achieve layered rendering glDepthMask(true); + glClear(GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); for (auto it = opaqueQueue.cbegin(); it != opaqueQueue.cend(); ++it) @@ -588,7 +587,9 @@ void Renderer::visitRenderQueue(RenderQueue& queue) } flush(); + glDepthMask(true); glClear(GL_DEPTH_BUFFER_BIT); + glDepthMask(false); } // diff --git a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp index 42d29d5969..0408ea92dd 100644 --- a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp +++ b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp @@ -130,7 +130,6 @@ CameraRotationTest::CameraRotationTest() auto sp3d = Sprite3D::create(); sp3d->setPosition(s.width/2, s.height/2); - sp3d->setRotation3D(Vec3(90,90,0)); addChild(sp3d); auto lship = Label::create(); From c364323bbc24730d43ad239a8af7040ffd8ee902 Mon Sep 17 00:00:00 2001 From: Nite Luo Date: Tue, 27 Jan 2015 16:26:31 -0800 Subject: [PATCH 30/66] Not using static value to save previous render state since other commands like custom command could change them --- cocos/renderer/CCMeshCommand.cpp | 50 +++++++++++++++----------------- cocos/renderer/CCMeshCommand.h | 4 +++ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/cocos/renderer/CCMeshCommand.cpp b/cocos/renderer/CCMeshCommand.cpp index 630e6c1294..66d9625690 100644 --- a/cocos/renderer/CCMeshCommand.cpp +++ b/cocos/renderer/CCMeshCommand.cpp @@ -42,12 +42,6 @@ NS_CC_BEGIN -//render state -static bool s_cullFaceEnabled = false; -static GLenum s_cullFace = 0; -static bool s_depthTestEnabled = false; -static bool s_depthWriteEnabled = false; - static const char *s_dirLightUniformColorName = "u_DirLightSourceColor"; static std::vector s_dirLightUniformColorValues; static const char *s_dirLightUniformDirName = "u_DirLightSourceDirection"; @@ -185,46 +179,48 @@ MeshCommand::~MeshCommand() void MeshCommand::applyRenderState() { - if (_cullFaceEnabled && !s_cullFaceEnabled) + _renderStateCullFace = glIsEnabled(GL_CULL_FACE); + _renderStateDepthTest = glIsEnabled(GL_DEPTH_TEST); + glGetBooleanv(GL_DEPTH_WRITEMASK, &_renderStateDepthWrite); + + if (_cullFaceEnabled && !_renderStateCullFace) { glEnable(GL_CULL_FACE); - s_cullFaceEnabled = true; } - if (s_cullFace != _cullFace) - { - glCullFace(_cullFace); - s_cullFace = _cullFace; - } - if (_depthTestEnabled && !s_depthTestEnabled) + + glCullFace(_cullFace); + + if (_depthTestEnabled && !_renderStateDepthTest) { glEnable(GL_DEPTH_TEST); - s_depthTestEnabled = true; } - if (_depthWriteEnabled && !s_depthWriteEnabled) + if (_depthWriteEnabled && !_renderStateDepthWrite) { glDepthMask(GL_TRUE); - s_depthWriteEnabled = true; } } void MeshCommand::restoreRenderState() { - if (s_cullFaceEnabled) + if (_renderStateCullFace) + { + glEnable(GL_CULL_FACE); + } + else { glDisable(GL_CULL_FACE); - s_cullFaceEnabled = false; } - if (s_depthTestEnabled) + + if (_renderStateDepthTest) + { + glEnable(GL_DEPTH_TEST); + } + else { glDisable(GL_DEPTH_TEST); - s_depthTestEnabled = false; } - if (s_depthWriteEnabled) - { - glDepthMask(GL_FALSE); - s_depthWriteEnabled = false; - } - s_cullFace = 0; + + glDepthMask(_renderStateDepthTest); } void MeshCommand::genMaterialID(GLuint texID, void* glProgramState, GLuint vertexBuffer, GLuint indexBuffer, const BlendFunc& blend) diff --git a/cocos/renderer/CCMeshCommand.h b/cocos/renderer/CCMeshCommand.h index 3dfc6937ed..867da76d2a 100644 --- a/cocos/renderer/CCMeshCommand.h +++ b/cocos/renderer/CCMeshCommand.h @@ -127,6 +127,10 @@ protected: GLenum _cullFace; bool _depthTestEnabled; bool _depthWriteEnabled; + + bool _renderStateCullFace; + bool _renderStateDepthTest; + GLboolean _renderStateDepthWrite; // ModelView transform Mat4 _mv; From be6ca1b6d2b141093b5be40e75158df56a4ea555 Mon Sep 17 00:00:00 2001 From: Nite Luo Date: Tue, 27 Jan 2015 17:05:51 -0800 Subject: [PATCH 31/66] add force depth write --- cocos/2d/CCNode.h | 2 +- cocos/3d/CCSprite3D.cpp | 10 ++++++++++ cocos/3d/CCSprite3D.h | 17 +++++++++++++++++ cocos/renderer/CCMeshCommand.cpp | 7 ++++++- cocos/renderer/CCMeshCommand.h | 1 + 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 89f8d8da82..703c81ad32 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -1122,7 +1122,7 @@ public: * * @return An Action pointer */ - Action* runAction(Action* action); + virtual Action* runAction(Action* action); /** * Stops and removes all actions from the running action list . diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index 1c28f4c13c..fdf69f6aef 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -741,6 +741,10 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) } //support tint and fade meshCommand.setDisplayColor(Vec4(color.r, color.g, color.b, color.a)); + if (_forceDepthWrite) + { + meshCommand.setDepthWriteEnabled(true); + } meshCommand.setTransparent(isTransparent); renderer->addCommand(&meshCommand); } @@ -801,6 +805,12 @@ const AABB& Sprite3D::getAABB() const return _aabb; } +Action* Sprite3D::runAction(Action *action) +{ + setForceDepthWrite(true); + return Node::runAction(action); +} + Rect Sprite3D::getBoundingBox() const { AABB aabb = getAABB(); diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index cec60085c7..b819c4471d 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -126,6 +126,22 @@ public: */ const AABB& getAABB() const; + /** + * Executes an action, and returns the action that is executed. For Sprite3D special logic are needed to take care of Fading. + * + * This node becomes the action's target. Refer to Action::getTarget() + * @warning Actions don't retain their target. + * + * @return An Action pointer + */ + virtual Action* runAction(Action* action) override; + + /** + * Force to write to depth buffer, this is useful if you want to achieve effects like fading. + */ + void setForceDepthWrite(bool value) { _forceDepthWrite = value; } + bool isForceDepthWrite() const { return _forceDepthWrite;}; + /** * Returns 2d bounding-box * Note: the bouding-box is just get from the AABB which as Z=0, so that is not very accurate. @@ -200,6 +216,7 @@ protected: bool _aabbDirty; unsigned int _lightMask; bool _shaderUsingLight; // is current shader using light ? + bool _forceDepthWrite; // Always write to depth buffer struct AsyncLoadParam { diff --git a/cocos/renderer/CCMeshCommand.cpp b/cocos/renderer/CCMeshCommand.cpp index 66d9625690..48685f2c64 100644 --- a/cocos/renderer/CCMeshCommand.cpp +++ b/cocos/renderer/CCMeshCommand.cpp @@ -153,6 +153,7 @@ void MeshCommand::setDepthTestEnabled(bool enable) void MeshCommand::setDepthWriteEnabled(bool enable) { + _forceDepthWrite = enable; _depthWriteEnabled = enable; } @@ -166,7 +167,11 @@ void MeshCommand::setTransparent(bool value) _isTransparent = value; //Skip batching for transparent mesh _skipBatching = value; - setDepthWriteEnabled(!_isTransparent); + + if (!_forceDepthWrite) + { + _depthWriteEnabled = true; + } } MeshCommand::~MeshCommand() diff --git a/cocos/renderer/CCMeshCommand.h b/cocos/renderer/CCMeshCommand.h index 867da76d2a..128c294913 100644 --- a/cocos/renderer/CCMeshCommand.h +++ b/cocos/renderer/CCMeshCommand.h @@ -127,6 +127,7 @@ protected: GLenum _cullFace; bool _depthTestEnabled; bool _depthWriteEnabled; + bool _forceDepthWrite; bool _renderStateCullFace; bool _renderStateDepthTest; From 5c32b31d6e9303446c40eb67a7a6a1b7104b6e57 Mon Sep 17 00:00:00 2001 From: Nite Luo Date: Tue, 27 Jan 2015 17:24:01 -0800 Subject: [PATCH 32/66] Fix test case #10237 --- tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index 1e1faad178..b633f9252d 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -2212,6 +2212,7 @@ void UseCaseSprite3D::switchCase() { auto layer = LayerColor::create(Color4B(0, 0, 100, 255), s.width / 2.f, s.height / 2.f); layer->setPosition(s.width * 0.25f, s.height * 0.25f); + layer->setGlobalZOrder(-1); addChild(layer); std::string filename = "Sprite3DTest/girl.c3b"; From 6208e9cba53300338d9ac9c44c8441113325e557 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 28 Jan 2015 09:40:20 +0800 Subject: [PATCH 33/66] Add more test cases about 3D --- .../manual/cocos2d/lua_cocos2dx_manual.cpp | 261 +++++++- .../lua-bindings/script/cocos2d/Cocos2d.lua | 64 +- .../Classes/Camera3DTest/Camera3DTest.cpp | 1 + .../src/Camera3DTest/Camera3DTest.lua | 621 +++++++++++++++++- tools/tolua/cocos2dx_3d.ini | 2 +- 5 files changed, 918 insertions(+), 31 deletions(-) diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp index ff636d65da..e7bf8b68af 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp @@ -6718,7 +6718,7 @@ static int lua_cocos2dx_GLProgramState_setVertexAttribPointer(lua_State* tolua_S unsigned int arg2; bool arg3; int arg4; - int arg5; + long arg5; ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.GLProgramState:setVertexAttribPointer"); @@ -6730,11 +6730,11 @@ static int lua_cocos2dx_GLProgramState_setVertexAttribPointer(lua_State* tolua_S ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "cc.GLProgramState:setVertexAttribPointer"); - ok &= luaval_to_int32(tolua_S, 7, (int *)&arg5, "cc.GLProgramState:setVertexAttribPointer"); + ok &= luaval_to_long(tolua_S, 7, (long *)&arg5, "cc.GLProgramState:setVertexAttribPointer"); if(!ok) return 0; - cobj->setVertexAttribPointer(arg0, arg1, arg2, arg3, arg4, (void*)&arg5); + cobj->setVertexAttribPointer(arg0, arg1, arg2, arg3, arg4, (void*)arg5); lua_settop(tolua_S, 1); return 1; } @@ -7527,7 +7527,7 @@ static int tolua_cocos2d_Mat4_transformVector(lua_State* tolua_S) !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S, 5, 0, &tolua_err) || - !tolua_isnumber(tolua_S, 6, 0, &tolua_err)) + !tolua_istable(tolua_S, 6, 0, &tolua_err) ) goto tolua_lerror; else #endif @@ -7566,10 +7566,11 @@ static int tolua_cocos2d_Mat4_decompose(lua_State* tolua_S) { #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; + if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || - !tolua_istable(tolua_S, 2, 0, &tolua_err) || - !tolua_istable(tolua_S, 3, 0, &tolua_err) || - !tolua_istable(tolua_S, 4, 0, &tolua_err)) + (!lua_isnil(tolua_S, 2) && !tolua_istable(tolua_S, 2, 0, &tolua_err)) || + (!lua_isnil(tolua_S, 3) && !tolua_istable(tolua_S, 3, 0, &tolua_err)) || + (!lua_isnil(tolua_S, 4) && !tolua_istable(tolua_S, 4, 0, &tolua_err)) ) goto tolua_lerror; else #endif @@ -7579,27 +7580,210 @@ static int tolua_cocos2d_Mat4_decompose(lua_State* tolua_S) cocos2d::Quaternion rotation; cocos2d::Vec3 translation; bool ok = true; + ok &= luaval_to_mat4(tolua_S, 1, &mat); if (!ok) return 0; - ok &= luaval_to_vec3(tolua_S, 2, &scale); - if (!ok) - return 0; + if (lua_isnil(tolua_S, 2) && !lua_isnil(tolua_S, 3) && !lua_isnil(tolua_S, 4)) + { + ok &= luaval_to_quaternion(tolua_S, 3, &rotation); + if (!ok) + return 0; + - ok &= luaval_to_quaternion(tolua_S, 3, &rotation); - if (!ok) - return 0; + ok &= luaval_to_vec3(tolua_S, 4, &translation); + if (!ok) + return 0; + + + mat.decompose(nullptr, &rotation, &translation); + + lua_newtable(tolua_S); + + lua_pushstring(tolua_S, "scale"); + lua_pushnil(tolua_S); + lua_rawset(tolua_S, -3); + + lua_pushstring(tolua_S, "rotation"); + quaternion_to_luaval(tolua_S, rotation); + lua_rawset(tolua_S, -3); + + lua_pushstring(tolua_S, "translation"); + vec3_to_luaval(tolua_S, translation); + lua_rawset(tolua_S, -3); + + return 1; + } - ok &= luaval_to_vec3(tolua_S, 2, &translation); - if (!ok) - return 0; + if (lua_isnil(tolua_S, 2) && lua_isnil(tolua_S, 3) && !lua_isnil(tolua_S, 4)) + { + ok &= luaval_to_vec3(tolua_S, 4, &translation); + if (!ok) + return 0; + + + mat.decompose(nullptr, nullptr, &translation); + + lua_newtable(tolua_S); + + lua_pushstring(tolua_S, "scale"); + lua_pushnil(tolua_S); + lua_rawset(tolua_S, -3); + + lua_pushstring(tolua_S, "rotation"); + lua_pushnil(tolua_S); + lua_rawset(tolua_S, -3); + + lua_pushstring(tolua_S, "translation"); + vec3_to_luaval(tolua_S, translation); + lua_rawset(tolua_S, -3); + + return 1; + } - mat.decompose(&scale, &rotation, &translation); - vec3_to_luaval(tolua_S, scale); - quaternion_to_luaval(tolua_S, rotation); - vec3_to_luaval(tolua_S, translation); - return 3; + if (!lua_isnil(tolua_S, 2) && lua_isnil(tolua_S, 3) && !lua_isnil(tolua_S, 4)) + { + ok &= luaval_to_vec3(tolua_S, 2, &scale); + if (!ok) + return 0; + + ok &= luaval_to_vec3(tolua_S, 4, &translation); + if (!ok) + return 0; + + mat.decompose(&scale, nullptr, &translation); + + lua_newtable(tolua_S); + + lua_pushstring(tolua_S, "scale"); + vec3_to_luaval(tolua_S, scale); + lua_rawset(tolua_S, -3); + + lua_pushstring(tolua_S, "rotation"); + lua_pushnil(tolua_S); + lua_rawset(tolua_S, -3); + + lua_pushstring(tolua_S, "translation"); + vec3_to_luaval(tolua_S, translation); + lua_rawset(tolua_S, -3); + + return 1; + } + + if (!lua_isnil(tolua_S, 2) && lua_isnil(tolua_S, 3) && lua_isnil(tolua_S, 4)) + { + ok &= luaval_to_vec3(tolua_S, 2, &scale); + if (!ok) + return 0; + + + mat.decompose(&scale, nullptr, nullptr); + + lua_newtable(tolua_S); + + lua_pushstring(tolua_S, "scale"); + vec3_to_luaval(tolua_S, scale); + lua_rawset(tolua_S, -3); + + lua_pushstring(tolua_S, "rotation"); + lua_pushnil(tolua_S); + lua_rawset(tolua_S, -3); + + lua_pushstring(tolua_S, "translation"); + lua_pushnil(tolua_S); + lua_rawset(tolua_S, -3); + + return 1; + } + + if (!lua_isnil(tolua_S, 2) && !lua_isnil(tolua_S, 3) && lua_isnil(tolua_S, 4)) + { + ok &= luaval_to_vec3(tolua_S, 2, &scale); + if (!ok) + return 0; + + ok &= luaval_to_quaternion(tolua_S, 3, &rotation); + if (!ok) + return 0; + + mat.decompose(&scale, &rotation, nullptr); + + lua_newtable(tolua_S); + + lua_pushstring(tolua_S, "scale"); + vec3_to_luaval(tolua_S, scale); + lua_rawset(tolua_S, -3); + + lua_pushstring(tolua_S, "rotation"); + quaternion_to_luaval(tolua_S, rotation); + lua_rawset(tolua_S, -3); + + lua_pushstring(tolua_S, "translation"); + lua_pushnil(tolua_S); + lua_rawset(tolua_S, -3); + + return 1; + + } + + if (lua_isnil(tolua_S, 2) && !lua_isnil(tolua_S, 3) && lua_isnil(tolua_S, 4)) + { + ok &= luaval_to_quaternion(tolua_S, 3, &rotation); + if (!ok) + return 0; + + mat.decompose(nullptr, &rotation, nullptr); + + lua_newtable(tolua_S); + + lua_pushstring(tolua_S, "scale"); + lua_pushnil(tolua_S); + lua_rawset(tolua_S, -3); + + lua_pushstring(tolua_S, "rotation"); + quaternion_to_luaval(tolua_S, rotation); + lua_rawset(tolua_S, -3); + + lua_pushstring(tolua_S, "translation"); + lua_pushnil(tolua_S); + lua_rawset(tolua_S, -3); + } + + if (!lua_isnil(tolua_S, 2) && !lua_isnil(tolua_S, 3) && !lua_isnil(tolua_S, 4)) + { + ok &= luaval_to_vec3(tolua_S, 2, &scale); + if (!ok) + return 0; + + ok &= luaval_to_quaternion(tolua_S, 3, &rotation); + if (!ok) + return 0; + + ok &= luaval_to_vec3(tolua_S, 4, &translation); + if (!ok) + return 0; + + mat.decompose(&scale, &rotation, &translation); + + lua_newtable(tolua_S); + + lua_pushstring(tolua_S, "scale"); + vec3_to_luaval(tolua_S, scale); + lua_rawset(tolua_S, -3); + + lua_pushstring(tolua_S, "rotation"); + quaternion_to_luaval(tolua_S, rotation); + lua_rawset(tolua_S, -3); + + lua_pushstring(tolua_S, "translation"); + lua_pushnil(tolua_S); + lua_rawset(tolua_S, -3); + + return 1; + } + + return 0; } return 0; #if COCOS2D_DEBUG >= 1 @@ -7617,7 +7801,7 @@ static int tolua_cocos2d_Vec3_cross(lua_State* tolua_S) tolua_Error tolua_err; #endif - if (1 == argc) + if (2 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || @@ -7687,6 +7871,38 @@ tolua_lerror: #endif } +static int tolua_cocos2d_Mat4_multiply(lua_State* tolua_S) +{ +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || + !tolua_istable(tolua_S, 2, 0, &tolua_err) ) + goto tolua_lerror; + else +#endif + { + cocos2d::Mat4 mat1; + bool ok = luaval_to_mat4(tolua_S, 1, &mat1); + if(!ok) + return 0; + + cocos2d::Mat4 mat2; + ok = luaval_to_mat4(tolua_S, 2, &mat2); + if(!ok) + return 0; + + cocos2d::Mat4 ret = mat1 * mat2; + mat4_to_luaval(tolua_S, ret); + return 1; + } + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'mat4_multiply'.",&tolua_err); + return 0; +#endif +} + int register_all_cocos2dx_math_manual(lua_State* tolua_S) { if (nullptr == tolua_S) @@ -7698,6 +7914,7 @@ int register_all_cocos2dx_math_manual(lua_State* tolua_S) tolua_function(tolua_S, "mat4_getInversed", tolua_cocos2d_Mat4_getInversed); tolua_function(tolua_S, "mat4_transformVector", tolua_cocos2d_Mat4_transformVector); tolua_function(tolua_S, "mat4_decompose", tolua_cocos2d_Mat4_decompose); + tolua_function(tolua_S, "mat4_multiply", tolua_cocos2d_Mat4_multiply); tolua_function(tolua_S, "vec3_cross", tolua_cocos2d_Vec3_cross); tolua_endmodule(tolua_S); return 0; diff --git a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua index 4eccc543e7..40663e766d 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua @@ -175,7 +175,7 @@ function cc.pIsSegmentIntersect(pt1,pt2,pt3,pt4) ret,s,t =cc.pIsLineIntersect(pt1, pt2, pt3, pt4,s,t) if ret and s >= 0.0 and s <= 1.0 and t >= 0.0 and t <= 0.0 then - return true; + return true end return false @@ -450,7 +450,6 @@ cc.mat4 = cc.mat4 or {} function cc.mat4.new(...) local params = {...} local size = #params - local obj = {} if 1 == size then @@ -463,10 +462,8 @@ function cc.mat4.new(...) end end elseif 16 == size then - if params[i] ~= nil then - mat4[i] = params[i] - else - mat4[i] = 0 + for i= 1, 16 do + obj[i] = params[i] end end @@ -482,3 +479,58 @@ end function cc.mat4.transformVector(self, vector, dst) return mat4_transformVector(self, vector, dst) end + +function cc.mat4.createIdentity() + return cc.mat4.new(1.0 ,0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0) +end + +function cc.mat4.createTranslation(translation, dst) + assert(type(translation) == "table" and type(dst) == "table", "The type of input parameters should be table") + dst = cc.mat4.createIdentity() + dst[13] = translation.x + dst[14] = translation.y + dst[15] = translation.z + return dst +end + +function cc.mat4.createRotation(q, dst) + assert(type(q) == "table" and type(dst) == "table", "The type of input parameters should be table") + local x2 = q.x + q.x + local y2 = q.y + q.y + local z2 = q.z + q.z + + local xx2 = q.x * x2 + local yy2 = q.y * y2 + local zz2 = q.z * z2 + local xy2 = q.x * y2 + local xz2 = q.x * z2 + local yz2 = q.y * z2 + local wx2 = q.w * x2 + local wy2 = q.w * y2 + local wz2 = q.w * z2 + + dst[1] = 1.0 - yy2 - zz2 + dst[2] = xy2 + wz2 + dst[3] = xz2 - wy2 + dst[4] = 0.0 + + dst[5] = xy2 - wz2 + dst[6] = 1.0 - xx2 - zz2 + dst[7] = yz2 + wx2 + dst[8] = 0.0 + + dst[9] = xz2 + wy2 + dst[10] = yz2 - wx2 + dst[11] = 1.0 - xx2 - yy2 + dst[12] = 0.0 + + dst[13] = 0.0 + dst[14] = 0.0 + dst[15] = 0.0 + dst[16] = 1.0 + + return dst +end diff --git a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp index 54360e83aa..003d14462c 100644 --- a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp +++ b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp @@ -1194,6 +1194,7 @@ void CameraArcBallDemo::onTouchsMoved( const std::vector &touchs, Event Vec3 axes; float angle; calculateArcBall(axes, angle, prelocation.x, prelocation.y, location.x, location.y); //calculate rotation quaternion parameters + CCLOG("axes is %f, %f,%f,angle is %f",axes.x, axes.y, axes.z, angle); Quaternion quat(axes, angle); //get rotation quaternion _rotationQuat = quat * _rotationQuat; diff --git a/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua b/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua index 98a60968e0..f5f5b8d49b 100644 --- a/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua +++ b/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua @@ -23,7 +23,9 @@ local CameraType = local scheduler = cc.Director:getInstance():getScheduler() local Camera3DTestDemo = class("Camera3DTestDemo", function () - return cc.Layer:create() + local layer = cc.Layer:create() + Helper.initWithLayer(layer) + return layer end) function Camera3DTestDemo:ctor() @@ -451,10 +453,625 @@ function Camera3DTestDemo:init() end) end +local CameraRotationTest = class("CameraRotationTest", function () + local layer = cc.Layer:create() + Helper.initWithLayer(layer) + return layer +end) + +function CameraRotationTest:ctor() + -- body + self:init() +end + +function CameraRotationTest:init() + -- body + Helper.titleLabel:setString(self:title()) + Helper.subtitleLabel:setString(self:subtitle()) + self:registerScriptHandler(function (event) + if event == "enter" then + self:onEnter() + elseif event == "exit" then + self:onExit() + end + end) +end + +function CameraRotationTest:onEnter() + local s = cc.Director:getInstance():getWinSize() + + camControlNode = cc.Node:create() + camControlNode:setNormalizedPosition(cc.p(0.5, 0.5)) + self:addChild(camControlNode) + + camNode = cc.Node:create() + camNode:setPositionZ(cc.Camera:getDefaultCamera():getPosition3D().z) + camControlNode:addChild(camNode) + + local sp3d = cc.Sprite3D:create() + sp3d:setPosition(s.width/2, s.height/2) + self:addChild(sp3d) + + local lship = cc.Label:create() + lship:setString("Ship") + lship:setPosition(0, 20) + sp3d:addChild(lship) + + --Billboards + --Yellow is at the back + bill1 = cc.BillBoard:create("Images/Icon.png") + bill1:setPosition3D(cc.vec3(s.width/2 + 50, s.height/2 + 10, -10)) + bill1:setColor(cc.c3b(255, 255, 0)) + bill1:setScale(0.6) + self:addChild(bill1) + + l1 = cc.Label:create() + l1:setPosition(cc.p(0,-10)) + l1:setString("Billboard1") + l1:setColor(cc.c3b(255, 255, 255)) + l1:setScale(3) + bill1:addChild(l1) + + local p1 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") + p1:setPosition(30,80) + bill1:addChild(p1) + + bill2 = cc.BillBoard:create("Images/Icon.png") + bill2:setPosition3D(cc.vec3(s.width/2 - 50, s.height/2 - 10, 10)) + bill2:setScale(0.6) + self:addChild(bill2) + + l2 = cc.Label:create() + l2:setString("Billboard2") + l2:setPosition(cc.p(0,-10)) + l2:setColor(cc.c3b(255, 255, 255)) + l2:setScale(3) + bill2:addChild(l2) + + local p2 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") + p2:setPosition(30,80) + bill2:addChild(p2) + + --3D models + local model = cc.Sprite3D:create("Sprite3DTest/boss1.obj") + model:setScale(4) + model:setTexture("Sprite3DTest/boss.png") + model:setPosition3D(cc.vec3(s.width/2, s.height/2, 0)) + self:addChild(model) + + --Listener + lis = cc.EventListenerTouchOneByOne:create() + lis:registerScriptHandler(function (touch, event) + return true + end,cc.Handler.EVENT_TOUCH_BEGAN ) + + lis:registerScriptHandler(function (touch, event) + local dx = touch:getDelta().x + local rot = camControlNode:getRotation3D() + rot.y = rot.y + dx + camControlNode:setRotation3D(rot) + + local worldPos = cc.vec3(0.0, 0.0, 0.0) + local decompose = mat4_decompose(camNode:getNodeToWorldTransform(), nil ,nil, worldPos) + worldPos = decompose.translation + cc.Camera:getDefaultCamera():setPosition3D(worldPos) + cc.Camera:getDefaultCamera():lookAt(camControlNode:getPosition3D()) + end, cc.Handler.EVENT_TOUCH_MOVED) + + local eventDispatcher = self:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(lis, self) +end + +function CameraRotationTest:onExit() + +end + +function CameraRotationTest:title() + return "Camera Rotation Test" +end + +function CameraRotationTest:subtitle() + return "Slide to rotate" +end + +local FogTestDemo = class("FogTestDemo", function () + local layer = cc.Layer:create() + Helper.initWithLayer(layer) + return layer +end) + +function FogTestDemo:ctor() + -- body + self:init() +end + +function FogTestDemo:init() + -- body + self._layer3D = nil + self._cameraType = CameraType.FreeCamera + self._camera = nil + self._shader = nil + self._state = nil + + Helper.titleLabel:setString(self:title()) + Helper.subtitleLabel:setString(self:subtitle()) + + self:registerScriptHandler(function (event) + if event == "enter" then + self:onEnter() + elseif event == "exit" then + self:onExit() + end + end) +end + +function FogTestDemo:setEventListener() + local listener = cc.EventListenerTouchAllAtOnce:create() + + listener:registerScriptHandler(function(touches, event) + if #touches == 1 then + local touch = touches[1] + local prelocation = touch:getPreviousLocationInView() + local location = touch:getLocationInView() + local newPos = cc.p(prelocation.x - location.x, prelocation.y - location.y) + if self._cameraType == CameraType.FreeCamera then + + local transformMat = self._camera:getNodeToWorldTransform() + local cameraDir = { x = -transformMat[9], y = -transformMat[10], z = -transformMat[11] } + cameraDir = cc.vec3normalize(cameraDir) + cameraDir.y = 0 + + transformMat = self._camera:getNodeToWorldTransform() + local cameraRightDir = { x = transformMat[1], y = transformMat[2], z = transformMat[3]} + cameraRightDir = cc.vec3normalize(cameraRightDir) + cameraRightDir.y = 0 + + local cameraPos = self._camera:getPosition3D() + cameraPos = {x = cameraPos.x - cameraDir.x * newPos.y * 0.1, y = cameraPos.y - cameraDir.y * newPos.y * 0.1, z = cameraPos.z - cameraDir.z * newPos.y * 0.1} + cameraPos = {x = cameraPos.x + cameraRightDir.x * newPos.x * 0.1, y = cameraPos.y + cameraRightDir.y * newPos.x * 0.1, z = cameraPos.z + cameraRightDir.z * newPos.x * 0.1} + self._camera:setPosition3D(cameraPos) + + end + end + end, cc.Handler.EVENT_TOUCHES_MOVED) + + local eventDispatcher = self:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) +end + +function FogTestDemo:createMenu() + -- body + local ttfConfig = {} + ttfConfig.fontFilePath = "fonts/arial.ttf" + ttfConfig.fontSize = 20 + + local label1 = cc.Label:createWithTTF(ttfConfig,"Linear ") + local menuItem1 = cc.MenuItemLabel:create(label1) + menuItem1:registerScriptTapHandler(function (tag, sender ) + self._state:setUniformVec4("u_fogColor", cc.vec4(0.5,0.5,0.5,1.0)) + self._state:setUniformFloat("u_fogStart",10) + self._state:setUniformFloat("u_fogEnd",60) + self._state:setUniformInt("u_fogEquation" ,0) + + self._sprite3D1:setGLProgramState(self._state) + self._sprite3D2:setGLProgramState(self._state) + end) + + local label2 = cc.Label:createWithTTF(ttfConfig,"Exp") + local menuItem2 = cc.MenuItemLabel:create(label2) + menuItem2:registerScriptTapHandler(function (tag, sender ) + self._state:setUniformVec4("u_fogColor", cc.vec4(0.5,0.5,0.5,1.0)) + self._state:setUniformFloat("u_fogDensity",0.03) + self._state:setUniformInt("u_fogEquation" ,1) + + self._sprite3D1:setGLProgramState(self._state) + self._sprite3D2:setGLProgramState(self._state) + end) + local label3 = cc.Label:createWithTTF(ttfConfig,"Exp2") + local menuItem3 = cc.MenuItemLabel:create(label3) + menuItem3:registerScriptTapHandler(function (tag, sender ) + self._state:setUniformVec4("u_fogColor", cc.vec4(0.5,0.5,0.5,1.0)) + self._state:setUniformFloat("u_fogDensity",0.03) + self._state:setUniformInt("u_fogEquation" ,2) + + self._sprite3D1:setGLProgramState(self._state) + self._sprite3D2:setGLProgramState(self._state) + end) + local menu = cc.Menu:create(menuItem1, menuItem2, menuItem3) + + menu:setPosition(cc.p(0.0, 0.0)) + + menuItem1:setPosition(VisibleRect:left().x + 60, VisibleRect:top().y - 50) + menuItem2:setPosition(VisibleRect:left().x + 60, VisibleRect:top().y - 100) + menuItem3:setPosition(VisibleRect:left().x + 60, VisibleRect:top().y - 150) + self:addChild(menu, 0) +end + +function FogTestDemo:createLayer3D() + -- body + local s = cc.Director:getInstance():getWinSize() + + local layer3D = cc.Layer:create() + self:addChild(layer3D,0) + self._layer3D = layer3D + + self._shader = cc.GLProgram:createWithFilenames("Sprite3DTest/fog.vert","Sprite3DTest/fog.frag") + self._state = cc.GLProgramState:create(self._shader) + + self._sprite3D1 = cc.Sprite3D:create("Sprite3DTest/teapot.c3b") + self._sprite3D2 = cc.Sprite3D:create("Sprite3DTest/teapot.c3b") + + self._sprite3D1:setGLProgramState(self._state) + self._sprite3D2:setGLProgramState(self._state) + + --pass mesh's attribute to shader + local attributeNames = + { + "a_position", + "a_color", + "a_texCoord", + "a_texCoord1", + "a_texCoord2", + "a_texCoord3", + "a_normal", + "a_blendWeight", + "a_blendIndex", + } + + local offset = 0 + local attributeCount = self._sprite3D1:getMesh():getMeshVertexAttribCount() + for i = 1, attributeCount do + local meshattribute = self._sprite3D1:getMesh():getMeshVertexAttribute(i - 1) + self._state:setVertexAttribPointer(attributeNames[meshattribute.vertexAttrib + 1], + meshattribute.size, + meshattribute.type, + false, + self._sprite3D1:getMesh():getVertexSizeInBytes(), + offset) + offset = offset + meshattribute.attribSizeBytes + end + + local offset1 = 0 + local attributeCount1 = self._sprite3D2:getMesh():getMeshVertexAttribCount() + for i = 1, attributeCount1 do + local meshattribute = self._sprite3D2:getMesh():getMeshVertexAttribute(i - 1) + self._state:setVertexAttribPointer(attributeNames[meshattribute.vertexAttrib + 1], + meshattribute.size, + meshattribute.type, + false, + self._sprite3D2:getMesh():getVertexSizeInBytes(), + offset1) + offset1 = offset1 + meshattribute.attribSizeBytes + end + + self._state:setUniformVec4("u_fogColor", cc.vec4(0.5,0.5,0.5,1.0)) + self._state:setUniformFloat("u_fogStart",10) + self._state:setUniformFloat("u_fogEnd",60) + self._state:setUniformInt("u_fogEquation" ,0) + + self._layer3D:addChild(self._sprite3D1) + self._sprite3D1:setPosition3D( cc.vec3( 0, 0,0 ) ) + self._sprite3D1:setScale(2.0) + self._sprite3D1:setRotation3D(cc.vec3(-90,180,0)) + + self._layer3D:addChild(self._sprite3D2) + self._sprite3D2:setPosition3D( cc.vec3( 0, 0,-20 ) ) + self._sprite3D2:setScale(2.0) + self._sprite3D2:setRotation3D(cc.vec3(-90,180,0)) + + if self._camera == nil then + self._camera = cc.Camera:createPerspective(60, s.width/s.height, 1, 1000) + self._camera:setCameraFlag(cc.CameraFlag.USER1) + self._camera:setPosition3D(cc.vec3(0, 30, 40)) + self._camera:lookAt(cc.vec3(0,0,0), cc.vec3(0, 1, 0)) + + self._layer3D:addChild(self._camera) + end + + self._layer3D:setCameraMask(2) + + local targetPlatform = cc.Application:getInstance():getTargetPlatform() + if targetPlatform == cc.PLATFORM_OS_ANDROID or targetPlatform == cc.PLATFORM_OS_WINRT or targetPlatform == cc.PLATFORM_OS_WP8 then + self._backToForegroundListener = cc.EventListenerCustom:create("event_renderer_recreated", function (eventCustom) + -- body + cc.Director:getInstance():setClearColor(cc.c4f(0.5,0.5,0.5,1)) + local glProgram = self._state:getGLProgram() + glProgram:reset() + glProgram:initWithFilenames("Sprite3DTest/fog.vert","Sprite3DTest/fog.frag") + glProgram:link() + glProgram:updateUniforms() + + self._state:setUniformVec4("u_fogColor", cc.vec4(0.5,0.5,0.5,1.0)) + self._state:setUniformFloat("u_fogStart",10) + self._state:setUniformFloat("u_fogEnd",60) + self._state:setUniformInt("u_fogEquation" ,0) + end) + cc.Director:getInstance():getEventDispatcher():addEventListenerWithFixedPriority(self._backToForegroundListener, -1) + end +end + +function FogTestDemo:onEnter() + cc.Director:getInstance():setClearColor(cc.c4f(0.5,0.5,0.5,1)) + self:setEventListener() + self:createMenu() + self:createLayer3D() +end + +function FogTestDemo:onExit() + cc.Director:getInstance():setClearColor(cc.c4f(0,0,0,1)) + if nil ~= self._camera then + self._camera = nil + end + local targetPlatform = cc.Application:getInstance():getTargetPlatform() + if targetPlatform == cc.PLATFORM_OS_ANDROID or targetPlatform == cc.PLATFORM_OS_WINRT or targetPlatform == cc.PLATFORM_OS_WP8 then + cc.Director:getInstance():getEventDispatcher():removeEventListener(self._backToForegroundListener) + end +end + +function FogTestDemo:title() + return "Fog Test Demo" +end + +function FogTestDemo:subtitle() + return "" +end + +local OperateCamType = +{ + MoveCamera = 0, + RotateCamera = 1, +} + +local CameraArcBallDemo = class("CameraArcBallDemo", function () + local layer = cc.Layer:create() + Helper.initWithLayer(layer) + return layer +end) + +function CameraArcBallDemo:ctor() + -- body + self:init() +end + +function CameraArcBallDemo:init() + self._layer3D = nil + self._cameraType = CameraType.FreeCamera + self._camera = nil + self._drawGrid = nil + self._sprite3D1 = nil + self._sprite3D2 = nil + self._radius = 1.0 + self._distanceZ = 50.0 + self._operate = OperateCamType.RotateCamera + self._center = cc.vec3(0, 0, 0) + self._target = 0 + + Helper.titleLabel:setString(self:title()) + Helper.subtitleLabel:setString(self:subtitle()) + + self:registerScriptHandler(function (event) + if event == "enter" then + self:onEnter() + elseif event == "exit" then + self:onExit() + end + end) +end + +function CameraArcBallDemo:projectToSphere(r, x, y) + local d, t, z + d = math.sqrt(x*x + y*y) + --inside sphere + if d < r * 0.70710678118654752440 then + z = math.sqrt(r*r - d*d) + else--on hyperbola + t = r / 1.41421356237309504880 + z = t*t / d + end + return z +end + +function CameraArcBallDemo:calculateArcBall(axis, angle, p1x, p1y, p2x, p2y) + local rotation_matrix = cc.mat4.createRotation(self._rotationQuat, cc.mat4.createIdentity()) + --rotation y + local uv = mat4_transformVector(rotation_matrix , 0.0, 1.0, 0.0, 0.0, cc.vec3(0.0, 0.0, 0.0)) + --rotation x + local sv = mat4_transformVector(rotation_matrix, 1.0, 0.0, 0.0, 0.0, cc.vec3(0.0, 0.0, 0.0)) + --rotation z + local lv = mat4_transformVector(rotation_matrix, 0.0, 0.0, -1.0, 0.0, cc.vec3(0.0, 0.0, 0.0)) + --start point screen transform to 3d + local projectZ1 = self:projectToSphere(self._radius, p1x, p1y) + local p1 = cc.vec3(sv.x * p1x + uv.x * p1y - lv.x * projectZ1, sv.y * p1x + uv.y * p1y - lv.y * projectZ1 , sv.z * p1x + uv.z * p1y - lv.z * projectZ1) + --end point screen transform to 3d + local projectZ2 = self:projectToSphere(self._radius, p2x, p2y) + local p2 = cc.vec3(sv.x * p2x + uv.x * p2y - lv.x * projectZ2, sv.y * p2x + uv.y * p2y - lv.y * projectZ2 , sv.z * p2x + uv.z * p2y - lv.z * projectZ2) + --calculate rotation axis + axis = vec3_cross(p2, p1, axis) + axis = cc.vec3normalize(axis) + + local t = math.sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y) + (p2.z - p1.z) * (p2.z - p1.z)) / (2.0 * self._radius) + --clamp -1 to 1 + if t > 1.0 then + t = 1.0 + end + + if t < -1.0 then + t = -1.0 + end + --rotation angle + angle = math.asin(t) + + return axis, angle +end +function CameraArcBallDemo:setEventListener() + local listener = cc.EventListenerTouchAllAtOnce:create() + + listener:registerScriptHandler(function(touchs, event) + if #touchs ~= 0 then + if self._operate == OperateCamType.RotateCamera then + local visibleSize = cc.Director:getInstance():getVisibleSize() + local prelocation = touchs[1]:getPreviousLocationInView() + local location = touchs[1]:getLocationInView() + location.x = 2.0 * (location.x) / (visibleSize.width) - 1.0 + location.y = 2.0 * (visibleSize.height - location.y) / (visibleSize.height) - 1.0 + prelocation.x = 2.0 * (prelocation.x) / (visibleSize.width) - 1.0 + prelocation.y = 2.0 * (visibleSize.height - prelocation.y) / (visibleSize.height) - 1.0 + + local axes = cc.vec3(0,0,0) + local angle = 0.0 + --calculate rotation quaternion parameters + axes , angle = self:calculateArcBall(axes, angle, prelocation.x, prelocation.y, location.x, location.y) + + --get rotation quaternion + local halfAngle = angle * 0.5 + local sinHalfAngle = math.sin(math.deg(halfAngle)) + + local normal = axes + normal = cc.vec3normalize(normal) + local quat = cc.quaternion(normal.x * sinHalfAngle, normal.y * sinHalfAngle, normal.z * sinHalfAngle, math.cos(math.deg(halfAngle))) + local x = quat.w * self._rotationQuat.x + quat.x * self._rotationQuat.w + quat.y * self._rotationQuat.z - quat.z * self._rotationQuat.y + local y = quat.w * self._rotationQuat.y - quat.x * self._rotationQuat.z + quat.y * self._rotationQuat.w + quat.z * self._rotationQuat.x + local z = quat.w * self._rotationQuat.z + quat.x * self._rotationQuat.y - quat.y * self._rotationQuat.x + quat.z * self._rotationQuat.w + local w = quat.w * self._rotationQuat.w - quat.x * self._rotationQuat.x - quat.y * self._rotationQuat.y - quat.z * self._rotationQuat.z + self._rotationQuat = cc.quaternion(x, y, z, w) + + self:updateCameraTransform() + + elseif self._operate == OperateCamType.MoveCamera then + local previousLocation = touchs[1]:getPreviousLocation() + local location = touchs[1]:getLocation() + local newPos = cc.p(previousLocation.x - location.x, previousLocation.y - location.y) + self._distanceZ = self._distanceZ - newPos.y * 0.1 + + self:updateCameraTransform() + end + end + end, cc.Handler.EVENT_TOUCHES_MOVED) + + local eventDispatcher = self:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) +end + +function CameraArcBallDemo:createLayer3D() + local s = cc.Director:getInstance():getWinSize() + + cc.MenuItemFont:setFontName("fonts/arial.ttf") + cc.MenuItemFont:setFontSize(20) + + local menuItem1 = cc.MenuItemFont:create("Switch Operation") + menuItem1:setColor(cc.c3b(0,200,20)) + menuItem1:registerScriptTapHandler(function (tag, sender ) + if self._operate == OperateCamType.MoveCamera then + self._operate = OperateCamType.RotateCamera + elseif self._operate == OperateCamType.RotateCamera then + self._operate = OperateCamType.MoveCamera + end + end) + local menuItem2 = cc.MenuItemFont:create("Switch Target") + menuItem2:setColor(cc.c3b(0,200,20)) + menuItem2:registerScriptTapHandler(function (tag, sender ) + if self._target == 0 then + self._target = 1 + self._center = self._sprite3D2:getPosition3D() + self:updateCameraTransform() + elseif self._target == 1 then + self._target = 0 + self._center = self._sprite3D1:getPosition3D() + self:updateCameraTransform() + end + end) + local menu = cc.Menu:create(menuItem1,menuItem2) + menu:setPosition(cc.p(0.0, 0.0)) + menuItem1:setPosition(VisibleRect:left().x + 80, VisibleRect:top().y -70) + menuItem2:setPosition(VisibleRect:left().x + 80, VisibleRect:top().y -100) + self:addChild(menu, 1) + + local layer3D = cc.Layer:create() + self:addChild(layer3D,0) + self._layer3D = layer3D + + if self._camera == nil then + self._camera = cc.Camera:createPerspective(60, s.width/s.height, 1, 1000) + self._camera:setCameraFlag(cc.CameraFlag.USER1) + self._camera:setPosition3D(cc.vec3(0, 10, 50)) + self._camera:lookAt(cc.vec3(0, 0, 0), cc.vec3(0, 1, 0)) + self._layer3D:addChild(self._camera) + end + + self._sprite3D1 = cc.Sprite3D:create("Sprite3DTest/orc.c3b") + self._sprite3D1:setScale(0.5) + self._sprite3D1:setRotation3D(cc.vec3(0,180,0)) + self._sprite3D1:setPosition3D(cc.vec3(0,0,0)) + self._layer3D:addChild(self._sprite3D1) + + self._sprite3D2 = cc.Sprite3D:create("Sprite3DTest/boss.c3b") + self._sprite3D2:setScale(0.6) + self._sprite3D2:setRotation3D(cc.vec3(-90,0,0)) + self._sprite3D2:setPosition3D(cc.vec3(20,0,0)) + self._layer3D:addChild(self._sprite3D2) + + self._drawGrid = cc.DrawNode3D:create() + --draw x + for j = -20, 20 do + self._drawGrid:drawLine(cc.vec3(-100, 0, 5*j), cc.vec3(100, 0, 5*j),cc.c4f(1, 0, 0, 1)) + end + + --draw z + for j = -20, 20 do + self._drawGrid:drawLine(cc.vec3(5*j, 0, -100), cc.vec3(5*j, 0, 100),cc.c4f(0,0,1,1)) + end + + --draw y + self._drawGrid:drawLine(cc.vec3(0, 0, 0), cc.vec3(0,50,0), cc.c4f(0,1,0,1)) + + self._layer3D:addChild(self._drawGrid) + + self._layer3D:setCameraMask(2) + self:updateCameraTransform() +end + +function CameraArcBallDemo:updateCameraTransform() + -- body + local trans = cc.mat4.createTranslation(cc.vec3(0.0, 10.0, self._distanceZ), cc.mat4.createIdentity()) + local rot = cc.mat4.createRotation(self._rotationQuat, cc.mat4.createIdentity()) + local center = cc.mat4.createTranslation(self._center, cc.mat4.createIdentity()) + local result = mat4_multiply(mat4_multiply(trans, rot), center) + + self._camera:setNodeToParentTransform(result) +end + +function CameraArcBallDemo:onEnter() + self._rotationQuat = cc.quaternion(0.0, 0.0, 0.0, 1.0) + self:setEventListener() + self:createLayer3D() +end + +function CameraArcBallDemo:onExit() + if self._camera ~= nil then + self._camera = nil + end +end + +function CameraArcBallDemo:title() + return "Camera ArcBall Moving" +end + +function CameraArcBallDemo:subtitle() + return "" +end + function Camera3DTestMain() cclog("Camera3DTestMain") local scene = cc.Scene:create() - scene:addChild(Camera3DTestDemo.new()) + + Helper.createFunctionTable = + { + Camera3DTestDemo.create, + CameraRotationTest.create, + FogTestDemo.create, + CameraArcBallDemo.create, + } + scene:addChild(Helper.createFunctionTable[1]()) scene:addChild(CreateBackMenuItem()) diff --git a/tools/tolua/cocos2dx_3d.ini b/tools/tolua/cocos2dx_3d.ini index 13f9095598..d554da2066 100644 --- a/tools/tolua/cocos2dx_3d.ini +++ b/tools/tolua/cocos2dx_3d.ini @@ -35,7 +35,7 @@ classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = Mesh::[create getAABB getVertexBuffer hasVertexAttrib getMeshVertexAttribCount getMeshVertexAttribute getVertexSizeInBytes getSkin getMeshIndexData getGLProgramState getPrimitiveType getIndexCount getIndexFormat getIndexBuffer], +skip = Mesh::[create getAABB getVertexBuffer hasVertexAttrib getSkin getMeshIndexData getGLProgramState getPrimitiveType getIndexCount getIndexFormat getIndexBuffer], Sprite3D::[getSkin getAABB getMeshArrayByName], Skeleton3D::[create], Animation3D::[getBoneCurveByName], From 823ec8812fc19b175cdb2454779feb1809a429f5 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 28 Jan 2015 10:00:16 +0800 Subject: [PATCH 34/66] [ci skip]update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 5dd738cbc0..f9b5a03a37 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ cocos2d-x-3.4 xxx [FIX] UI::Slider: when scale9 is enabled, the progress bar's rendering height is wrong [FIX] UI:Scale9Sprite: some position information will be lost when toggling `Scale9` state [FIX] UI::TextField: will get wrong event message if clicking `TextField` twice + [FIX] UI::TextField: result of `getContentSize` is wrong if it is invoked in insert or delete event callback [FIX] UI::WebView: base URL can not work cocos2d-x-3.4rc1 Jan.15 2015 From 4685ab1ef6a0fa0e431e983d7aa6fa70de8da38b Mon Sep 17 00:00:00 2001 From: Wenhai Lin Date: Wed, 28 Jan 2015 10:20:30 +0800 Subject: [PATCH 35/66] Add a test case about Scale9Sprite run action in physics scene --- .../Classes/PhysicsTest/PhysicsTest.cpp | 35 +++++++++++++++++++ .../Classes/PhysicsTest/PhysicsTest.h | 11 ++++++ 2 files changed, 46 insertions(+) diff --git a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp index 93bcecb722..b75e4ded76 100644 --- a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp +++ b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp @@ -1,6 +1,7 @@ #include "PhysicsTest.h" #include #include "../testResource.h" +#include "ui/CocosGUI.h" USING_NS_CC; namespace @@ -23,6 +24,7 @@ namespace CL(Bug5482), CL(PhysicsFixedUpdate), CL(PhysicsTransformTest), + CL(PhysicsIssue9959) #else CL(PhysicsDemoDisabled), #endif @@ -1865,4 +1867,37 @@ std::string PhysicsTransformTest::title() const return "Physics transform test"; } +void PhysicsIssue9959::onEnter() +{ + PhysicsDemo::onEnter(); + + auto origin = Director::getInstance()->getVisibleOrigin(); + auto visibleSize = Director::getInstance()->getVisibleSize(); + + auto scale9Sprite1 = ui::Scale9Sprite::create("Images/ball.png"); + scale9Sprite1->setPosition(origin + visibleSize/2); + addChild(scale9Sprite1); + scale9Sprite1->runAction(RepeatForever::create(Sequence::create(MoveBy::create(2.0f, Vec2(100.0f,0.0f)), MoveBy::create(2.0f, Vec2(-100.0f, 0.0f)), NULL))); + + auto scale9Sprite2 = ui::Scale9Sprite::create("Images/ball.png"); + scale9Sprite2->setPosition(origin + visibleSize/2 + Vec2(0.0f, 50.0f)); + addChild(scale9Sprite2); + scale9Sprite2->runAction(RepeatForever::create(Sequence::create(ScaleTo::create(2.0f, 1.5f), ScaleTo::create(2.0f, 1.0f), NULL))); + + auto scale9Sprite3 = ui::Scale9Sprite::create("Images/ball.png"); + scale9Sprite3->setPosition(origin + visibleSize/2 + Vec2(0.0f, -50.0f)); + addChild(scale9Sprite3); + scale9Sprite3->runAction(RepeatForever::create(RotateBy::create(2.0f, 360.0f))); +} + +std::string PhysicsIssue9959::title() const +{ + return "Reorder issue #9959"; +} + +std::string PhysicsIssue9959::subtitle() const +{ + return "Test Scale9Sprite run scale/move/rotation action in physics scene"; +} + #endif // ifndef CC_USE_PHYSICS diff --git a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h index 3eba820180..1fc6aaa40e 100644 --- a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h +++ b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h @@ -278,5 +278,16 @@ public: bool onTouchBegan(Touch* touch, Event* event); }; + +class PhysicsIssue9959 : public PhysicsDemo +{ +public: + CREATE_FUNC(PhysicsIssue9959); + + void onEnter() override; + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + #endif #endif From 5f5c00b7d2093a00cd74cdc72be07182d1425373 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 28 Jan 2015 10:32:22 +0800 Subject: [PATCH 36/66] remove duplicated QUEUE_GROUP::QUEUE_COUNT and QUEUE_GROUP::QUEUE_GROUP_SIZE --- cocos/renderer/CCRenderer.cpp | 4 ++-- cocos/renderer/CCRenderer.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index b876ff1ebd..72983cb7d5 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -92,7 +92,7 @@ void RenderQueue::push_back(RenderCommand* command) ssize_t RenderQueue::size() const { ssize_t result(0); - for(int index = 0; index < QUEUE_GROUP::QUEUE_GROUP_SIZE; ++index) + for(int index = 0; index < QUEUE_GROUP::QUEUE_COUNT; ++index) { result += _commands[index].size(); } @@ -110,7 +110,7 @@ void RenderQueue::sort() RenderCommand* RenderQueue::operator[](ssize_t index) const { - for(int queIndex = 0; queIndex < QUEUE_GROUP::QUEUE_GROUP_SIZE; ++queIndex) + for(int queIndex = 0; queIndex < QUEUE_GROUP::QUEUE_COUNT; ++queIndex) { if(index < static_cast(_commands[queIndex].size())) return _commands[queIndex][index]; diff --git a/cocos/renderer/CCRenderer.h b/cocos/renderer/CCRenderer.h index a2177d7594..de8f3fbe1d 100644 --- a/cocos/renderer/CCRenderer.h +++ b/cocos/renderer/CCRenderer.h @@ -55,8 +55,7 @@ public: TRANSPARENT_3D = 2, GLOBALZ_ZERO = 3, GLOBALZ_POS = 4, - QUEUE_GROUP_SIZE = 5, - QUEUE_COUNT, + QUEUE_COUNT = 5, }; public: From 7b9d9ff9f92b74a634fef6563258de1c78ea5748 Mon Sep 17 00:00:00 2001 From: geron-cn Date: Wed, 28 Jan 2015 10:33:50 +0800 Subject: [PATCH 37/66] fix complie error on win --- .../ActionTimelineTestScene.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp index 97d12eef94..760f575d99 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp @@ -341,8 +341,10 @@ void TestTimelineAnimationList::onEnter() ActionTimelineTestLayer::onEnter(); Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb"); ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb"); - action->addAnimationInfo({"stand", 0, 40}); - action->addAnimationInfo({"walk", 41, 81}); + cocostudio::timeline::AnimationInfo standinfo("stand", 0, 40); + cocostudio::timeline::AnimationInfo walkinfo("walk", 41, 81) + action->addAnimationInfo(standinfo); + action->addAnimationInfo(walkinfo); node->runAction(action); action->play("walk", true); From 82a95bf2fc5ba34e9b9f876316f0e925e5fc381a Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 28 Jan 2015 10:57:30 +0800 Subject: [PATCH 38/66] Modify some script files --- cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua | 8 ++++++++ tests/lua-tests/src/Camera3DTest/Camera3DTest.lua | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua index 40663e766d..316c3ed0a7 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua @@ -480,6 +480,14 @@ function cc.mat4.transformVector(self, vector, dst) return mat4_transformVector(self, vector, dst) end +function cc.mat4.multiply(self, mat) + return mat4_multiply(self, mat) +end + +function cc.mat4.decompose(self, scale, rotation, translation) + return mat4_decompose(self, scale ,rotation, translation) +end + function cc.mat4.createIdentity() return cc.mat4.new(1.0 ,0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, diff --git a/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua b/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua index f5f5b8d49b..4e08494881 100644 --- a/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua +++ b/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua @@ -552,7 +552,7 @@ function CameraRotationTest:onEnter() camControlNode:setRotation3D(rot) local worldPos = cc.vec3(0.0, 0.0, 0.0) - local decompose = mat4_decompose(camNode:getNodeToWorldTransform(), nil ,nil, worldPos) + local decompose = cc.mat4.new(camNode:getNodeToWorldTransform()):decompose(nil, nil, worldPos) worldPos = decompose.translation cc.Camera:getDefaultCamera():setPosition3D(worldPos) cc.Camera:getDefaultCamera():lookAt(camControlNode:getPosition3D()) @@ -1035,7 +1035,7 @@ function CameraArcBallDemo:updateCameraTransform() local trans = cc.mat4.createTranslation(cc.vec3(0.0, 10.0, self._distanceZ), cc.mat4.createIdentity()) local rot = cc.mat4.createRotation(self._rotationQuat, cc.mat4.createIdentity()) local center = cc.mat4.createTranslation(self._center, cc.mat4.createIdentity()) - local result = mat4_multiply(mat4_multiply(trans, rot), center) + local result = cc.mat4.new(center:multiply(rot)):multiply(trans) self._camera:setNodeToParentTransform(result) end From c8a783e4ac6a9388f8f34925baf72520c197160a Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 28 Jan 2015 10:59:29 +0800 Subject: [PATCH 39/66] use const auto& --- cocos/renderer/CCRenderer.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index 72983cb7d5..9754bea3d5 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -511,7 +511,7 @@ void Renderer::visitRenderQueue(RenderQueue& queue) // //Process Global-Z < 0 Objects // - const std::vector& zNegQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::GLOBALZ_NEG); + const auto& zNegQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::GLOBALZ_NEG); if (zNegQueue.size() > 0) { if(_isDepthTestFor2D) @@ -534,7 +534,7 @@ void Renderer::visitRenderQueue(RenderQueue& queue) // //Process Opaque Object // - const std::vector& opaqueQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::OPAQUE_3D); + const auto& opaqueQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::OPAQUE_3D); if (opaqueQueue.size() > 0) { //Clear depth to achieve layered rendering @@ -552,7 +552,7 @@ void Renderer::visitRenderQueue(RenderQueue& queue) // //Process 3D Transparent object // - std::vector transQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::TRANSPARENT_3D); + const auto& transQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::TRANSPARENT_3D); if (transQueue.size() > 0) { glEnable(GL_DEPTH_TEST); @@ -568,7 +568,7 @@ void Renderer::visitRenderQueue(RenderQueue& queue) // //Process Global-Z = 0 Queue // - std::vector zZeroQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::GLOBALZ_ZERO); + const auto& zZeroQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::GLOBALZ_ZERO); if (zZeroQueue.size() > 0) { if(_isDepthTestFor2D) @@ -595,7 +595,7 @@ void Renderer::visitRenderQueue(RenderQueue& queue) // //Process Global-Z > 0 Queue // - std::vector zPosQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::GLOBALZ_POS); + const auto& zPosQueue = queue.getSubQueue(RenderQueue::QUEUE_GROUP::GLOBALZ_POS); if (zPosQueue.size() > 0) { for (auto it = zPosQueue.cbegin(); it != zPosQueue.cend(); ++it) From 7628ec53bc842e60384e99be405faa2753a5d3e7 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 28 Jan 2015 11:06:00 +0800 Subject: [PATCH 40/66] Remove useless comment --- tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp | 1 - tests/lua-tests/src/Camera3DTest/Camera3DTest.lua | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp index 003d14462c..54360e83aa 100644 --- a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp +++ b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp @@ -1194,7 +1194,6 @@ void CameraArcBallDemo::onTouchsMoved( const std::vector &touchs, Event Vec3 axes; float angle; calculateArcBall(axes, angle, prelocation.x, prelocation.y, location.x, location.y); //calculate rotation quaternion parameters - CCLOG("axes is %f, %f,%f,angle is %f",axes.x, axes.y, axes.z, angle); Quaternion quat(axes, angle); //get rotation quaternion _rotationQuat = quat * _rotationQuat; diff --git a/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua b/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua index 4e08494881..fbf4b3b29e 100644 --- a/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua +++ b/tests/lua-tests/src/Camera3DTest/Camera3DTest.lua @@ -444,6 +444,9 @@ function Camera3DTestDemo:onExit() end function Camera3DTestDemo:init() + Helper.titleLabel:setString(self:title()) + Helper.subtitleLabel:setString(self:subtitle()) + self:registerScriptHandler(function (event) if event == "enter" then self:onEnter() From cd4280636730930530eddd39232ffc7d615b9422 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 28 Jan 2015 11:12:12 +0800 Subject: [PATCH 41/66] Fix the error of tolua_cocos2d_Mat4_decompose --- .../lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp index e7bf8b68af..6a08b48200 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp @@ -7777,7 +7777,7 @@ static int tolua_cocos2d_Mat4_decompose(lua_State* tolua_S) lua_rawset(tolua_S, -3); lua_pushstring(tolua_S, "translation"); - lua_pushnil(tolua_S); + vec3_to_luaval(tolua_S, translation); lua_rawset(tolua_S, -3); return 1; From 7baf84c232e05d572e45b59ebc00de0f6db621f6 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Wed, 28 Jan 2015 11:31:52 +0800 Subject: [PATCH 42/66] Add test case for issue#10232 --- .../Classes/SchedulerTest/SchedulerTest.cpp | 29 ++++++++++++++++++- .../Classes/SchedulerTest/SchedulerTest.h | 12 ++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp index f75808e8fe..9fa67e6372 100644 --- a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp +++ b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp @@ -29,7 +29,8 @@ static std::function createFunctions[] = { CL(SchedulerDelayAndRepeat), CL(SchedulerIssue2268), CL(ScheduleCallbackTest), - CL(ScheduleUpdatePriority) + CL(ScheduleUpdatePriority), + CL(SchedulerIssue10232) }; #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) @@ -1212,3 +1213,29 @@ void SchedulerTestScene::runThisTest() Director::getInstance()->replaceScene(this); } + +void SchedulerIssue10232::onEnter() +{ + SchedulerTestLayer::onEnter(); + + this->scheduleOnce(SEL_SCHEDULE(&SchedulerIssue2268::update), 0.25f); + + this->scheduleOnce([](float dt){ + log("SchedulerIssue10232:Schedules a lambda function"); + }, 0.25f,"SchedulerIssue10232"); +} + +void SchedulerIssue10232::update(float dt) +{ + log("SchedulerIssue10232:Schedules a selector"); +} + +std::string SchedulerIssue10232::title() const +{ + return "Issue #10232"; +} + +std::string SchedulerIssue10232::subtitle() const +{ + return "Should not crash"; +} diff --git a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h index 09e6534bf2..c6107d9c8e 100644 --- a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h +++ b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h @@ -330,4 +330,16 @@ public: virtual void runThisTest(); }; +class SchedulerIssue10232 : public SchedulerTestLayer +{ +public: + CREATE_FUNC(SchedulerIssue10232); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + + void onEnter(); + void update(float dt); +}; + #endif From 78463a4a66098e2e50ad2f042cbd4617f6258047 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 28 Jan 2015 05:46:25 +0000 Subject: [PATCH 43/66] [AUTO]: updating luabinding automatically --- .../scripting/lua-bindings/auto/api/Mesh.lua | 19 +++ .../auto/lua_cocos2dx_3d_auto.cpp | 147 ++++++++++++++++++ .../auto/lua_cocos2dx_3d_auto.hpp | 3 + 3 files changed, 169 insertions(+) diff --git a/cocos/scripting/lua-bindings/auto/api/Mesh.lua b/cocos/scripting/lua-bindings/auto/api/Mesh.lua index 5ac728c0c5..2fef75fef8 100644 --- a/cocos/scripting/lua-bindings/auto/api/Mesh.lua +++ b/cocos/scripting/lua-bindings/auto/api/Mesh.lua @@ -4,6 +4,12 @@ -- @extend Ref -- @parent_module cc +-------------------------------- +-- get mesh vertex attribute count +-- @function [parent=#Mesh] getMeshVertexAttribCount +-- @param self +-- @return long#long ret (return value: long) + -------------------------------- -- @overload self, cc.Texture2D -- @overload self, string @@ -31,12 +37,25 @@ -- @param #cc.BlendFunc blendFunc -- @return Mesh#Mesh self (return value: cc.Mesh) +-------------------------------- +-- get per vertex size in bytes +-- @function [parent=#Mesh] getVertexSizeInBytes +-- @param self +-- @return int#int ret (return value: int) + -------------------------------- -- -- @function [parent=#Mesh] getBlendFunc -- @param self -- @return BlendFunc#BlendFunc ret (return value: cc.BlendFunc) +-------------------------------- +-- get MeshVertexAttribute by index +-- @function [parent=#Mesh] getMeshVertexAttribute +-- @param self +-- @param #int idx +-- @return MeshVertexAttrib#MeshVertexAttrib ret (return value: cc.MeshVertexAttrib) + -------------------------------- -- -- @function [parent=#Mesh] isVisible diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp index 6fb906344e..1defe61d8e 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp @@ -1279,6 +1279,53 @@ int lua_register_cocos2dx_3d_Sprite3D(lua_State* tolua_S) return 1; } +int lua_cocos2dx_3d_Mesh_getMeshVertexAttribCount(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Mesh* 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.Mesh",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Mesh*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Mesh_getMeshVertexAttribCount'", 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_3d_Mesh_getMeshVertexAttribCount'", nullptr); + return 0; + } + ssize_t ret = cobj->getMeshVertexAttribCount(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Mesh:getMeshVertexAttribCount",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Mesh_getMeshVertexAttribCount'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_3d_Mesh_setTexture(lua_State* tolua_S) { int argc = 0; @@ -1478,6 +1525,53 @@ int lua_cocos2dx_3d_Mesh_setBlendFunc(lua_State* tolua_S) return 0; } +int lua_cocos2dx_3d_Mesh_getVertexSizeInBytes(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Mesh* 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.Mesh",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Mesh*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Mesh_getVertexSizeInBytes'", 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_3d_Mesh_getVertexSizeInBytes'", nullptr); + return 0; + } + int ret = cobj->getVertexSizeInBytes(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Mesh:getVertexSizeInBytes",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Mesh_getVertexSizeInBytes'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_3d_Mesh_getBlendFunc(lua_State* tolua_S) { int argc = 0; @@ -1525,6 +1619,56 @@ int lua_cocos2dx_3d_Mesh_getBlendFunc(lua_State* tolua_S) return 0; } +int lua_cocos2dx_3d_Mesh_getMeshVertexAttribute(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Mesh* 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.Mesh",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Mesh*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Mesh_getMeshVertexAttribute'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + int arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Mesh:getMeshVertexAttribute"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Mesh_getMeshVertexAttribute'", nullptr); + return 0; + } + const cocos2d::MeshVertexAttrib& ret = cobj->getMeshVertexAttribute(arg0); + mesh_vertex_attrib_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Mesh:getMeshVertexAttribute",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Mesh_getMeshVertexAttribute'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_3d_Mesh_isVisible(lua_State* tolua_S) { int argc = 0; @@ -1634,11 +1778,14 @@ int lua_register_cocos2dx_3d_Mesh(lua_State* tolua_S) tolua_cclass(tolua_S,"Mesh","cc.Mesh","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"Mesh"); + tolua_function(tolua_S,"getMeshVertexAttribCount",lua_cocos2dx_3d_Mesh_getMeshVertexAttribCount); tolua_function(tolua_S,"setTexture",lua_cocos2dx_3d_Mesh_setTexture); tolua_function(tolua_S,"getTexture",lua_cocos2dx_3d_Mesh_getTexture); tolua_function(tolua_S,"getName",lua_cocos2dx_3d_Mesh_getName); tolua_function(tolua_S,"setBlendFunc",lua_cocos2dx_3d_Mesh_setBlendFunc); + tolua_function(tolua_S,"getVertexSizeInBytes",lua_cocos2dx_3d_Mesh_getVertexSizeInBytes); tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_3d_Mesh_getBlendFunc); + tolua_function(tolua_S,"getMeshVertexAttribute",lua_cocos2dx_3d_Mesh_getMeshVertexAttribute); tolua_function(tolua_S,"isVisible",lua_cocos2dx_3d_Mesh_isVisible); tolua_function(tolua_S,"setVisible",lua_cocos2dx_3d_Mesh_setVisible); tolua_endmodule(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp index 47b0caebab..b1d944925a 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp @@ -63,6 +63,9 @@ int register_all_cocos2dx_3d(lua_State* tolua_S); + + + From 93665c5c6da1fead25f7a25e434dbd8e72818c8e Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 28 Jan 2015 13:49:19 +0800 Subject: [PATCH 44/66] =?UTF-8?q?Fix=20the=20error=20that=20HttpClient=20d?= =?UTF-8?q?idn=E2=80=99t=20setResponseCode=20when=20connecting=20failed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cocos/network/HttpClient-android.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/network/HttpClient-android.cpp b/cocos/network/HttpClient-android.cpp index a8d1932027..ea81d79279 100644 --- a/cocos/network/HttpClient-android.cpp +++ b/cocos/network/HttpClient-android.cpp @@ -687,6 +687,7 @@ static void processResponse(HttpResponse* response, std::string& responseMessage { response->setSucceed(false); response->setErrorBuffer("connect failed"); + response->setResponseCode(responseCode); return; } From b41873bb7eb5108df41d9bb9567cbf266613529e Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 28 Jan 2015 15:20:22 +0800 Subject: [PATCH 45/66] [ci skip]update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index f9b5a03a37..e728782803 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ cocos2d-x-3.4 xxx [FIX] Lua-binding:studio-support: AnimationInfo is not binded [FIX] New audio: not close file descriptor leads to that may causes game freeze if playing two many times(may be more than 1000) on Android [FIX] Node: anchor point has not effect to rotation, it always rotate along (0, 0) + [FIX] Physics integration: Scale9Sprite can't run `Move` action and `Scale` action if used physical scene [FIX] SpriteFrameCache: `addSpriteFramesWithFil`e may crash if plist file doesn't exist [FIX] Sprite3D: material files (.mtl) are not loaded for any object when creating from an .obj file [FIX] UI::ImageView: rendered content size is wrong if `ignoreSize` is true and `Scale9` is not enabled From ba5b23d2a51862cf0d6d03bb42eacdbe98e818eb Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 28 Jan 2015 07:21:15 +0000 Subject: [PATCH 46/66] [AUTO]: updating luabinding automatically --- .../lua-bindings/auto/api/Camera.lua | 7 -- .../lua-bindings/auto/api/Sprite3D.lua | 23 +++++ .../auto/lua_cocos2dx_3d_auto.cpp | 99 +++++++++++++++++++ .../auto/lua_cocos2dx_3d_auto.hpp | 2 + 4 files changed, 124 insertions(+), 7 deletions(-) diff --git a/cocos/scripting/lua-bindings/auto/api/Camera.lua b/cocos/scripting/lua-bindings/auto/api/Camera.lua index 81c16d13f3..2a2e9bcb67 100644 --- a/cocos/scripting/lua-bindings/auto/api/Camera.lua +++ b/cocos/scripting/lua-bindings/auto/api/Camera.lua @@ -115,11 +115,4 @@ -- @param self -- @return Camera#Camera ret (return value: cc.Camera) --------------------------------- --- Sets the position (X, Y, and Z) in its parent's coordinate system --- @function [parent=#Camera] setPosition3D --- @param self --- @param #vec3_table position --- @return Camera#Camera self (return value: cc.Camera) - return nil diff --git a/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua b/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua index 71f21ff438..d7060da219 100644 --- a/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua +++ b/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua @@ -4,6 +4,12 @@ -- @extend Node,BlendProtocol -- @parent_module cc +-------------------------------- +-- +-- @function [parent=#Sprite3D] isForceDepthWrite +-- @param self +-- @return bool#bool ret (return value: bool) + -------------------------------- -- -- @function [parent=#Sprite3D] setCullFaceEnabled @@ -90,6 +96,13 @@ -- @param #int index -- @return Mesh#Mesh ret (return value: cc.Mesh) +-------------------------------- +-- Force to write to depth buffer, this is useful if you want to achieve effects like fading. +-- @function [parent=#Sprite3D] setForceDepthWrite +-- @param self +-- @param #bool value +-- @return Sprite3D#Sprite3D self (return value: cc.Sprite3D) + -------------------------------- -- get Mesh by Name, it returns the first one if there are more than one mesh with the same name -- @function [parent=#Sprite3D] getMeshByName @@ -139,6 +152,16 @@ -- @param #cc.GLProgramState glProgramState -- @return Sprite3D#Sprite3D self (return value: cc.Sprite3D) +-------------------------------- +-- Executes an action, and returns the action that is executed. For Sprite3D special logic are needed to take care of Fading.
+-- This node becomes the action's target. Refer to Action::getTarget()
+-- warning Actions don't retain their target.
+-- return An Action pointer +-- @function [parent=#Sprite3D] runAction +-- @param self +-- @param #cc.Action action +-- @return Action#Action ret (return value: cc.Action) + -------------------------------- -- just rember bind attributes -- @function [parent=#Sprite3D] setGLProgram diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp index 1defe61d8e..9968e1800a 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp @@ -372,6 +372,53 @@ int lua_register_cocos2dx_3d_Skeleton3D(lua_State* tolua_S) return 1; } +int lua_cocos2dx_3d_Sprite3D_isForceDepthWrite(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Sprite3D* 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.Sprite3D",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_isForceDepthWrite'", 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_3d_Sprite3D_isForceDepthWrite'", nullptr); + return 0; + } + bool ret = cobj->isForceDepthWrite(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:isForceDepthWrite",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_isForceDepthWrite'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_3d_Sprite3D_setCullFaceEnabled(lua_State* tolua_S) { int argc = 0; @@ -1009,6 +1056,56 @@ int lua_cocos2dx_3d_Sprite3D_getMeshByIndex(lua_State* tolua_S) return 0; } +int lua_cocos2dx_3d_Sprite3D_setForceDepthWrite(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Sprite3D* 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.Sprite3D",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setForceDepthWrite'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Sprite3D:setForceDepthWrite"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_setForceDepthWrite'", nullptr); + return 0; + } + cobj->setForceDepthWrite(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:setForceDepthWrite",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setForceDepthWrite'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_3d_Sprite3D_getMeshByName(lua_State* tolua_S) { int argc = 0; @@ -1255,6 +1352,7 @@ int lua_register_cocos2dx_3d_Sprite3D(lua_State* tolua_S) tolua_cclass(tolua_S,"Sprite3D","cc.Sprite3D","cc.Node",nullptr); tolua_beginmodule(tolua_S,"Sprite3D"); + tolua_function(tolua_S,"isForceDepthWrite",lua_cocos2dx_3d_Sprite3D_isForceDepthWrite); tolua_function(tolua_S,"setCullFaceEnabled",lua_cocos2dx_3d_Sprite3D_setCullFaceEnabled); tolua_function(tolua_S,"setTexture",lua_cocos2dx_3d_Sprite3D_setTexture); tolua_function(tolua_S,"getLightMask",lua_cocos2dx_3d_Sprite3D_getLightMask); @@ -1268,6 +1366,7 @@ int lua_register_cocos2dx_3d_Sprite3D(lua_State* tolua_S) tolua_function(tolua_S,"removeAttachNode",lua_cocos2dx_3d_Sprite3D_removeAttachNode); tolua_function(tolua_S,"getSkeleton",lua_cocos2dx_3d_Sprite3D_getSkeleton); tolua_function(tolua_S,"getMeshByIndex",lua_cocos2dx_3d_Sprite3D_getMeshByIndex); + tolua_function(tolua_S,"setForceDepthWrite",lua_cocos2dx_3d_Sprite3D_setForceDepthWrite); tolua_function(tolua_S,"getMeshByName",lua_cocos2dx_3d_Sprite3D_getMeshByName); tolua_function(tolua_S,"getAttachNode",lua_cocos2dx_3d_Sprite3D_getAttachNode); tolua_function(tolua_S,"create", lua_cocos2dx_3d_Sprite3D_create); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp index b1d944925a..fb02fc2e6b 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp @@ -67,6 +67,8 @@ int register_all_cocos2dx_3d(lua_State* tolua_S); + + From fc1dbf49fb0e09e2897cb39e7b9857f96b5b24f0 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Wed, 28 Jan 2015 15:21:57 +0800 Subject: [PATCH 47/66] fix billboard --- cocos/3d/CCBillBoard.cpp | 23 ++++++++++++++++------- cocos/3d/CCBillBoard.h | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/cocos/3d/CCBillBoard.cpp b/cocos/3d/CCBillBoard.cpp index 67f2a6816a..6ae4e793ae 100644 --- a/cocos/3d/CCBillBoard.cpp +++ b/cocos/3d/CCBillBoard.cpp @@ -102,6 +102,9 @@ void BillBoard::visit(Renderer *renderer, const Mat4& parentTransform, uint32_t { return; } + bool visibleByCamera = isVisitableByVisitingCamera(); + if (!visibleByCamera && _children.empty()) + return; uint32_t flags = processParentFlags(parentTransform, parentFlags); @@ -119,7 +122,7 @@ void BillBoard::visit(Renderer *renderer, const Mat4& parentTransform, uint32_t director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform); - bool visibleByCamera = isVisitableByVisitingCamera(); + int i = 0; @@ -158,7 +161,7 @@ bool BillBoard::calculateBillbaordTransform() const Mat4& camWorldMat = camera->getNodeToWorldTransform(); //TODO: use math lib to calculate math lib Make it easier to read and maintain - if (memcmp(_camWorldMat.m, camWorldMat.m, sizeof(float) * 16) != 0 || _transformDirty || _modeDirty) + if (memcmp(_camWorldMat.m, camWorldMat.m, sizeof(float) * 16) != 0 || memcmp(_mvTransform.m, _modelViewTransform.m, sizeof(float) * 16) != 0 || _modeDirty || true) { //Rotate based on anchor point Vec3 anchorPoint(_anchorPointInPoints.x , _anchorPointInPoints.y , 0.0f); @@ -190,12 +193,18 @@ bool BillBoard::calculateBillbaordTransform() Quaternion rotationQuaternion; this->getNodeToWorldTransform().getRotation(&rotationQuaternion); - // fetch the rotation angle of z - float rotationZ = atan2(2*(rotationQuaternion.w*rotationQuaternion.z + rotationQuaternion.x*rotationQuaternion.y), - (1 - 2* (rotationQuaternion.y*rotationQuaternion.y + rotationQuaternion.z *rotationQuaternion.z))); + Mat4 rotationMatrix; rotationMatrix.setIdentity(); - rotationMatrix.rotateZ(rotationZ); + ///FIXME: maybe should keep rotation along z axis +// if (rotationQuaternion.z > 0) +// { +// //rotate z only, keep it +// // fetch the rotation angle of z +// float rotationZ = atan2(2*(rotationQuaternion.w*rotationQuaternion.z + rotationQuaternion.x*rotationQuaternion.y), +// (1 - 2* (rotationQuaternion.y*rotationQuaternion.y + rotationQuaternion.z *rotationQuaternion.z))); +// rotationMatrix.rotateZ(rotationZ); +// } Vec3 upAxis = Vec3(rotationMatrix.m[4],rotationMatrix.m[5],rotationMatrix.m[6]); Vec3 x, y; @@ -217,7 +226,7 @@ bool BillBoard::calculateBillbaordTransform() billboardTransform.m[12] = localToWorld.m[12]; billboardTransform.m[13] = localToWorld.m[13]; billboardTransform.m[14] = localToWorld.m[14]; billboardTransform.translate(-anchorPoint); - _modelViewTransform = billboardTransform; + _mvTransform = _modelViewTransform = billboardTransform; _camWorldMat = camWorldMat; diff --git a/cocos/3d/CCBillBoard.h b/cocos/3d/CCBillBoard.h index b2f5ac8937..13862a97ee 100644 --- a/cocos/3d/CCBillBoard.h +++ b/cocos/3d/CCBillBoard.h @@ -105,6 +105,7 @@ protected: bool calculateBillbaordTransform(); Mat4 _camWorldMat; + Mat4 _mvTransform; Mode _mode; bool _modeDirty; From 29c4c744ac31066558806e46307521921e8cfa93 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 28 Jan 2015 15:34:28 +0800 Subject: [PATCH 48/66] fix compile error on cpp-tests release mode --- .../CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp index 2619787632..ac030cc8d0 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp @@ -475,9 +475,7 @@ void UITextFieldTest_PlaceHolderColor::textFieldEvent(Ref *pSender, TextField::E case TextField::EventType::INSERT_TEXT: { _displayValueLabel->setString(String::createWithFormat("insert words")->getCString()); - TextField* textField = dynamic_cast(pSender); - auto& contentSize = textField->getContentSize(); - CCLOG("%f, %f", contentSize.width, contentSize.height); + CCLOG("%f, %f", dynamic_cast(pSender)->getContentSize().width, dynamic_cast(pSender)->getContentSize().height); } break; From 35c436f1f3d14d47127eb35a4bc4154286673529 Mon Sep 17 00:00:00 2001 From: andyque Date: Wed, 28 Jan 2015 16:35:16 +0800 Subject: [PATCH 49/66] fix compile error --- .../CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp index 760f575d99..3b2ed64f3a 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp @@ -341,8 +341,8 @@ void TestTimelineAnimationList::onEnter() ActionTimelineTestLayer::onEnter(); Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb"); ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb"); - cocostudio::timeline::AnimationInfo standinfo("stand", 0, 40); - cocostudio::timeline::AnimationInfo walkinfo("walk", 41, 81) + cocostudio::timeline::AnimationInfo standinfo{"stand", 0, 40}; + cocostudio::timeline::AnimationInfo walkinfo{"walk", 41, 81}; action->addAnimationInfo(standinfo); action->addAnimationInfo(walkinfo); node->runAction(action); From ac3d79a516022721fe3f2b5859405add537feba4 Mon Sep 17 00:00:00 2001 From: andyque Date: Wed, 28 Jan 2015 16:59:27 +0800 Subject: [PATCH 50/66] add constructor to AnimationInfo --- .../cocostudio/ActionTimeline/CCActionTimeline.h | 7 +++++++ .../ActionTimelineTestScene.cpp | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.h b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.h index c41f98c173..7ec93d211c 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.h @@ -33,6 +33,13 @@ NS_TIMELINE_BEGIN struct AnimationInfo { + AnimationInfo():startIndex(0),endIndex(0){} + AnimationInfo(const std::string& otherName, int otherStartIndex, int otherEndIndex) + :name(otherName), + startIndex(otherStartIndex), + endIndex(otherEndIndex) + { + } std::string name; int startIndex; int endIndex; diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp index 3b2ed64f3a..518b92165c 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp @@ -341,8 +341,8 @@ void TestTimelineAnimationList::onEnter() ActionTimelineTestLayer::onEnter(); Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb"); ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb"); - cocostudio::timeline::AnimationInfo standinfo{"stand", 0, 40}; - cocostudio::timeline::AnimationInfo walkinfo{"walk", 41, 81}; + cocostudio::timeline::AnimationInfo standinfo("stand", 0, 40); + cocostudio::timeline::AnimationInfo walkinfo("walk", 41, 81); action->addAnimationInfo(standinfo); action->addAnimationInfo(walkinfo); node->runAction(action); From 80c2e0c153018c65e50d4098830465d092e4b36b Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 28 Jan 2015 21:47:52 +0800 Subject: [PATCH 51/66] Add AsyncLoadSprite3D test case and update the related lua binding --- .../manual/3d/lua_cocos2dx_3d_manual.cpp | 84 ++++++++++++++ .../script/cocos2d/Cocos2dConstants.lua | 9 ++ .../src/Sprite3DTest/Sprite3DTest.lua | 108 ++++++++++++++++++ tools/tolua/cocos2dx.ini | 4 +- tools/tolua/cocos2dx_3d.ini | 7 +- 5 files changed, 207 insertions(+), 5 deletions(-) diff --git a/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp b/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp index c948c249f4..ee0717712a 100644 --- a/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp @@ -116,6 +116,89 @@ tolua_lerror: return 0; } +int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S)-1; + + do + { + if (argc == 3) + { + std::string modelPath; + ok &= luaval_to_std_string(tolua_S, 2,&modelPath, "cc.Sprite3D:createAsync"); + if (!ok) + break; + std::string texturePath; + ok &= luaval_to_std_string(tolua_S, 3,&texturePath, "cc.Sprite3D:createAsync"); + if (!ok) + break; + +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,4,"LUA_FUNCTION",0,&tolua_err)) { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = toluafix_ref_function(tolua_S,4,0); + + cocos2d::Sprite3D::createAsync(modelPath, texturePath, [=](cocos2d::Sprite3D* sprite, void* callbackparam){ + int id = (sprite) ? (int)sprite->_ID : -1; + int* luaID = (sprite) ? &sprite->_luaID : nullptr; + toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)sprite,"cc.Sprite3D"); + LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 1); + }, nullptr); + + lua_settop(tolua_S, 1); + return 1; + } + } while (0); + ok = true; + do + { + if (argc == 2) + { + std::string modelPath; + ok &= luaval_to_std_string(tolua_S, 2,&modelPath, "cc.Sprite3D:createAsync"); + if (!ok) + break; + +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err)) { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 3, 0); + + cocos2d::Sprite3D::createAsync(modelPath, [=](cocos2d::Sprite3D* sprite, void* callbackparam){ + int id = (sprite) ? (int)sprite->_ID : -1; + int* luaID = (sprite) ? &sprite->_luaID : nullptr; + toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)sprite,"cc.Sprite3D"); + LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 1); + }, nullptr); + + lua_settop(tolua_S, 1); + return 1; + } + } while (0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite3D:createAsync",argc, 3); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_createAsync'.",&tolua_err); +#endif + return 0; +} + static void extendSprite3D(lua_State* L) { lua_pushstring(L, "cc.Sprite3D"); @@ -124,6 +207,7 @@ static void extendSprite3D(lua_State* L) { tolua_function(L, "setBlendFunc", lua_cocos2dx_3d_Sprite3D_setBlendFunc01); tolua_function(L, "getAABB", lua_cocos2dx_3d_Sprite3D_getAABB); + tolua_function(L, "createAsync", lua_cocos2dx_3d_Sprite3D_createAsync); } lua_pop(L, 1); } diff --git a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua index defb4a51b8..b54ba5c100 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua @@ -610,3 +610,12 @@ cc.LightFlag = LIGHT14 = math.pow(2,14), LIGHT15 = math.pow(2,15), } + +cc.AsyncTaskPool.TaskType = +{ + TASK_IO = 0, + TASK_NETWORK = 1, + TASK_OTHER = 2, + TASK_MAX_TYPE = 3, +} + diff --git a/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua b/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua index bb95144f61..6807e64103 100644 --- a/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua +++ b/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua @@ -919,6 +919,113 @@ function Sprite3DMirrorTest.create() return layer end + +---------------------------------------- +----AsyncLoadSprite3DTest +---------------------------------------- +local AsyncLoadSprite3DTest = class("AsyncLoadSprite3DTest", function () + local layer = cc.Layer:create() + Helper.initWithLayer(layer) + return layer +end) + +function AsyncLoadSprite3DTest:ctor() + -- body + self:init() +end + +function AsyncLoadSprite3DTest:init() + Helper.titleLabel:setString(self:title()) + Helper.subtitleLabel:setString(self:subtitle()) + + self:registerScriptHandler(function (event) + if event == "enter" then + self:onEnter() + elseif event == "exit" then + self:onExit() + end + end) +end + +function AsyncLoadSprite3DTest:title() + return "Testing Sprite3D:createAsync" +end + +function AsyncLoadSprite3DTest:subtitle() + return "" +end + +function AsyncLoadSprite3DTest:onEnter() + + local ttfConfig = {} + ttfConfig.fontFilePath = "fonts/arial.ttf" + ttfConfig.fontSize = 15 + + local paths = {"Sprite3DTest/boss.obj", "Sprite3DTest/girl.c3b", "Sprite3DTest/orc.c3b", "Sprite3DTest/ReskinGirl.c3b", "Sprite3DTest/axe.c3b"} + + local label1 = cc.Label:createWithTTF(ttfConfig,"AsyncLoad Sprite3D") + local item1 = cc.MenuItemLabel:create(label1) + + function menuCallback_asyncLoadSprite(tag, sender) + --Note that you must stop the tasks before leaving the scene. + cc.AsyncTaskPool:getInstance():stopTasks(cc.AsyncTaskPool.TaskType.TASK_IO) + + local node = self:getChildByTag(101) + --remove all loaded sprite + node:removeAllChildren() + + --remove cache data + cc.Sprite3DCache:getInstance():removeAllSprite3DData() + + local function callback(sprite, index) + local node = self:getChildByTag(101) + local s = cc.Director:getInstance():getWinSize() + local width = s.width / (#paths) + local point = cc.p(width * (0.5 + index), s.height / 2.0) + sprite:setPosition(point) + node:addChild(sprite) + end + + cc.Sprite3D:createAsync(paths[1], function(sprite) + callback(sprite, 0) + end) + + cc.Sprite3D:createAsync(paths[2], function(sprite) + callback(sprite, 1) + end) + + cc.Sprite3D:createAsync(paths[3], function(sprite) + callback(sprite, 2) + end) + + cc.Sprite3D:createAsync(paths[4], function(sprite) + callback(sprite, 3) + end) + + cc.Sprite3D:createAsync(paths[5], function(sprite) + callback(sprite, 4) + end) + end + item1:registerScriptTapHandler(menuCallback_asyncLoadSprite) + + local s = cc.Director:getInstance():getWinSize() + item1:setPosition( s.width * 0.5, s.height * 0.8) + + local menu = cc.Menu:create(item1) + menu:setPosition(cc.p(0,0)) + self:addChild(menu, 10) + + local node = cc.Node:create() + node:setTag(101) + self:addChild(node) + + menuCallback_asyncLoadSprite() +end + +function AsyncLoadSprite3DTest:onExit() + +end + function Sprite3DTest() local scene = cc.Scene:create() @@ -932,6 +1039,7 @@ function Sprite3DTest() Sprite3DReskinTest.create, Sprite3DWithOBBPerfromanceTest.create, Sprite3DMirrorTest.create, + AsyncLoadSprite3DTest.create } scene:addChild(Sprite3DBasicTest.create()) diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index c0019ef351..06a3865007 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -22,11 +22,11 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/2d/CCProtectedNode.h +headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/2d/CCProtectedNode.h %(cocosdir)s/cocos/base/CCAsyncTaskPool.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Device ClippingRectangleNode .*Light$ +classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Device ClippingRectangleNode .*Light$ AsyncTaskPool # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also diff --git a/tools/tolua/cocos2dx_3d.ini b/tools/tolua/cocos2dx_3d.ini index d554da2066..6cdd569c0f 100644 --- a/tools/tolua/cocos2dx_3d.ini +++ b/tools/tolua/cocos2dx_3d.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/cocos2d.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard +classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard Sprite3DCache # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -36,10 +36,11 @@ classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard # functions from all classes. skip = Mesh::[create getAABB getVertexBuffer hasVertexAttrib getSkin getMeshIndexData getGLProgramState getPrimitiveType getIndexCount getIndexFormat getIndexBuffer], - Sprite3D::[getSkin getAABB getMeshArrayByName], + Sprite3D::[getSkin getAABB getMeshArrayByName createAsync], Skeleton3D::[create], Animation3D::[getBoneCurveByName], - BillBoard::[draw] + BillBoard::[draw], + Sprite3DCache::[addSprite3DData getSpriteData] rename_functions = From c0ff8d1177a8ef858356825a125fde4f107b9e2c Mon Sep 17 00:00:00 2001 From: Nite Luo Date: Wed, 28 Jan 2015 15:28:14 -0800 Subject: [PATCH 52/66] Don't clear depth between queues --- cocos/3d/CCBillBoard.cpp | 12 +----------- cocos/renderer/CCRenderer.cpp | 5 ----- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/cocos/3d/CCBillBoard.cpp b/cocos/3d/CCBillBoard.cpp index 6ae4e793ae..8a26a8c93f 100644 --- a/cocos/3d/CCBillBoard.cpp +++ b/cocos/3d/CCBillBoard.cpp @@ -193,19 +193,9 @@ bool BillBoard::calculateBillbaordTransform() Quaternion rotationQuaternion; this->getNodeToWorldTransform().getRotation(&rotationQuaternion); - Mat4 rotationMatrix; rotationMatrix.setIdentity(); - ///FIXME: maybe should keep rotation along z axis -// if (rotationQuaternion.z > 0) -// { -// //rotate z only, keep it -// // fetch the rotation angle of z -// float rotationZ = atan2(2*(rotationQuaternion.w*rotationQuaternion.z + rotationQuaternion.x*rotationQuaternion.y), -// (1 - 2* (rotationQuaternion.y*rotationQuaternion.y + rotationQuaternion.z *rotationQuaternion.z))); -// rotationMatrix.rotateZ(rotationZ); -// } - + Vec3 upAxis = Vec3(rotationMatrix.m[4],rotationMatrix.m[5],rotationMatrix.m[6]); Vec3 x, y; camWorldMat.transformVector(upAxis, &y); diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index 9754bea3d5..f6e39d9cae 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -539,7 +539,6 @@ void Renderer::visitRenderQueue(RenderQueue& queue) { //Clear depth to achieve layered rendering glDepthMask(true); - glClear(GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); for (auto it = opaqueQueue.cbegin(); it != opaqueQueue.cend(); ++it) @@ -586,10 +585,6 @@ void Renderer::visitRenderQueue(RenderQueue& queue) processRenderCommand(*it); } flush(); - - glDepthMask(true); - glClear(GL_DEPTH_BUFFER_BIT); - glDepthMask(false); } // From 0ec8510f0050950fe3511d485402b02992387a75 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Thu, 29 Jan 2015 09:19:57 +0800 Subject: [PATCH 53/66] Fix linux compile error --- cocos/scripting/lua-bindings/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/scripting/lua-bindings/CMakeLists.txt b/cocos/scripting/lua-bindings/CMakeLists.txt index 971f06b140..0e17e70d84 100644 --- a/cocos/scripting/lua-bindings/CMakeLists.txt +++ b/cocos/scripting/lua-bindings/CMakeLists.txt @@ -14,6 +14,7 @@ include_directories( ${cocos_root}/cocos/ui ${cocos_root}/cocos/2d ${cocos_root}/cocos/3d + ${cocos_root}/cocos/base ${cocos_root}/cocos/editor-support/spine ${cocos_root}/cocos/editor-support/cocostudio ${cocos_root}/cocos/editor-support/cocostudio/ActionTimeline From 9a2b4e5e5617ce89f5cd4433bd94bfcb625f18a9 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 29 Jan 2015 10:15:24 +0800 Subject: [PATCH 54/66] [ci skip]update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index e728782803..eb28be91f6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ cocos2d-x-3.4 xxx [FIX] C++: may crash if VAO is not supported [FIX] EditBox: content is not clipped correctly on windows [FIX] GLProgram: will cause crash on some devices that don't support more than 8 atrributes + [FIX] HttpClient: not set response code when connecting failed on Android [FIX] Label: alpha channel of text color of system font has not effect [FIX] Label: use int for dimensions that will lose the precision [FIX] Label: labels will become white block after resume from background on some Android devices, such as xiaomi3 From fcf0a2272f21d5a7a45c83b05ce02cc2323f18ea Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Thu, 29 Jan 2015 02:27:42 +0000 Subject: [PATCH 55/66] [AUTO]: updating luabinding automatically --- .../lua-bindings/auto/api/AsyncTaskPool.lua | 26 ++ .../lua-bindings/auto/api/Sprite3D.lua | 11 - .../lua-bindings/auto/api/Sprite3DCache.lua | 31 +++ .../auto/api/lua_cocos2dx_3d_auto_api.lua | 5 + .../auto/api/lua_cocos2dx_auto_api.lua | 5 + .../auto/lua_cocos2dx_3d_auto.cpp | 263 +++++++++++++----- .../auto/lua_cocos2dx_3d_auto.hpp | 4 + .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 142 ++++++++++ .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 4 + 9 files changed, 406 insertions(+), 85 deletions(-) create mode 100644 cocos/scripting/lua-bindings/auto/api/AsyncTaskPool.lua create mode 100644 cocos/scripting/lua-bindings/auto/api/Sprite3DCache.lua diff --git a/cocos/scripting/lua-bindings/auto/api/AsyncTaskPool.lua b/cocos/scripting/lua-bindings/auto/api/AsyncTaskPool.lua new file mode 100644 index 0000000000..7f083e814f --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/AsyncTaskPool.lua @@ -0,0 +1,26 @@ + +-------------------------------- +-- @module AsyncTaskPool +-- @parent_module cc + +-------------------------------- +-- stop tasks
+-- param type task type you want to stop +-- @function [parent=#AsyncTaskPool] stopTasks +-- @param self +-- @param #int type +-- @return AsyncTaskPool#AsyncTaskPool self (return value: cc.AsyncTaskPool) + +-------------------------------- +-- destroy instance +-- @function [parent=#AsyncTaskPool] destoryInstance +-- @param self +-- @return AsyncTaskPool#AsyncTaskPool self (return value: cc.AsyncTaskPool) + +-------------------------------- +-- get instance +-- @function [parent=#AsyncTaskPool] getInstance +-- @param self +-- @return AsyncTaskPool#AsyncTaskPool ret (return value: cc.AsyncTaskPool) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua b/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua index d7060da219..d0fa5ee964 100644 --- a/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua +++ b/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua @@ -127,17 +127,6 @@ -- @param #string texturePath -- @return Sprite3D#Sprite3D ret (return value: cc.Sprite3D) --------------------------------- --- @overload self, string, string, function, void --- @overload self, string, function, void --- @function [parent=#Sprite3D] createAsync --- @param self --- @param #string modelPath --- @param #string texturePath --- @param #function callback --- @param #void callbackparam --- @return Sprite3D#Sprite3D self (return value: cc.Sprite3D) - -------------------------------- -- Returns 2d bounding-box
-- Note: the bouding-box is just get from the AABB which as Z=0, so that is not very accurate. diff --git a/cocos/scripting/lua-bindings/auto/api/Sprite3DCache.lua b/cocos/scripting/lua-bindings/auto/api/Sprite3DCache.lua new file mode 100644 index 0000000000..677a5bd770 --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/Sprite3DCache.lua @@ -0,0 +1,31 @@ + +-------------------------------- +-- @module Sprite3DCache +-- @parent_module cc + +-------------------------------- +-- +-- @function [parent=#Sprite3DCache] removeSprite3DData +-- @param self +-- @param #string key +-- @return Sprite3DCache#Sprite3DCache self (return value: cc.Sprite3DCache) + +-------------------------------- +-- +-- @function [parent=#Sprite3DCache] removeAllSprite3DData +-- @param self +-- @return Sprite3DCache#Sprite3DCache self (return value: cc.Sprite3DCache) + +-------------------------------- +-- +-- @function [parent=#Sprite3DCache] destroyInstance +-- @param self +-- @return Sprite3DCache#Sprite3DCache self (return value: cc.Sprite3DCache) + +-------------------------------- +-- get & destroy +-- @function [parent=#Sprite3DCache] getInstance +-- @param self +-- @return Sprite3DCache#Sprite3DCache ret (return value: cc.Sprite3DCache) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua index df2829323b..355592bcc8 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua @@ -11,6 +11,11 @@ -- @field [parent=#cc] Sprite3D#Sprite3D Sprite3D preloaded module +-------------------------------------------------------- +-- the cc Sprite3DCache +-- @field [parent=#cc] Sprite3DCache#Sprite3DCache Sprite3DCache preloaded module + + -------------------------------------------------------- -- the cc Mesh -- @field [parent=#cc] Mesh#Mesh Mesh preloaded module diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua index 7ae6c196fa..6b4966fb2f 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua @@ -1246,4 +1246,9 @@ -- @field [parent=#cc] Component#Component Component preloaded module +-------------------------------------------------------- +-- the cc AsyncTaskPool +-- @field [parent=#cc] AsyncTaskPool#AsyncTaskPool AsyncTaskPool preloaded module + + return nil diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp index 9968e1800a..4523f0a4ae 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp @@ -1267,79 +1267,6 @@ int lua_cocos2dx_3d_Sprite3D_create(lua_State* tolua_S) #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S)-1; - - do - { - if (argc == 4) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite3D:createAsync"); - if (!ok) { break; } - std::string arg1; - ok &= luaval_to_std_string(tolua_S, 3,&arg1, "cc.Sprite3D:createAsync"); - if (!ok) { break; } - std::function arg2; - do { - // Lambda binding for lua is not supported. - assert(false); - } while(0) - ; - if (!ok) { break; } - void* arg3; - #pragma warning NO CONVERSION TO NATIVE FOR void* - ok = false; - if (!ok) { break; } - cocos2d::Sprite3D::createAsync(arg0, arg1, arg2, arg3); - lua_settop(tolua_S, 1); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 3) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite3D:createAsync"); - if (!ok) { break; } - std::function arg1; - do { - // Lambda binding for lua is not supported. - assert(false); - } while(0) - ; - if (!ok) { break; } - void* arg2; - #pragma warning NO CONVERSION TO NATIVE FOR void* - ok = false; - if (!ok) { break; } - cocos2d::Sprite3D::createAsync(arg0, arg1, arg2); - lua_settop(tolua_S, 1); - return 1; - } - } while (0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite3D:createAsync",argc, 3); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_createAsync'.",&tolua_err); -#endif - return 0; -} static int lua_cocos2dx_3d_Sprite3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Sprite3D)"); @@ -1370,7 +1297,6 @@ int lua_register_cocos2dx_3d_Sprite3D(lua_State* tolua_S) tolua_function(tolua_S,"getMeshByName",lua_cocos2dx_3d_Sprite3D_getMeshByName); tolua_function(tolua_S,"getAttachNode",lua_cocos2dx_3d_Sprite3D_getAttachNode); tolua_function(tolua_S,"create", lua_cocos2dx_3d_Sprite3D_create); - tolua_function(tolua_S,"createAsync", lua_cocos2dx_3d_Sprite3D_createAsync); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Sprite3D).name(); g_luaType[typeName] = "cc.Sprite3D"; @@ -1378,6 +1304,194 @@ int lua_register_cocos2dx_3d_Sprite3D(lua_State* tolua_S) return 1; } +int lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Sprite3DCache* 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.Sprite3DCache",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Sprite3DCache*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite3DCache:removeSprite3DData"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData'", nullptr); + return 0; + } + cobj->removeSprite3DData(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3DCache:removeSprite3DData",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Sprite3DCache* 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.Sprite3DCache",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Sprite3DCache*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData'", 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_3d_Sprite3DCache_removeAllSprite3DData'", nullptr); + return 0; + } + cobj->removeAllSprite3DData(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3DCache:removeAllSprite3DData",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Sprite3DCache_destroyInstance(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.Sprite3DCache",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_destroyInstance'", nullptr); + return 0; + } + cocos2d::Sprite3DCache::destroyInstance(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite3DCache:destroyInstance",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_destroyInstance'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_3d_Sprite3DCache_getInstance(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.Sprite3DCache",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_getInstance'", nullptr); + return 0; + } + cocos2d::Sprite3DCache* ret = cocos2d::Sprite3DCache::getInstance(); + object_to_luaval(tolua_S, "cc.Sprite3DCache",(cocos2d::Sprite3DCache*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite3DCache:getInstance",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_getInstance'.",&tolua_err); +#endif + return 0; +} +static int lua_cocos2dx_3d_Sprite3DCache_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (Sprite3DCache)"); + return 0; +} + +int lua_register_cocos2dx_3d_Sprite3DCache(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.Sprite3DCache"); + tolua_cclass(tolua_S,"Sprite3DCache","cc.Sprite3DCache","",nullptr); + + tolua_beginmodule(tolua_S,"Sprite3DCache"); + tolua_function(tolua_S,"removeSprite3DData",lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData); + tolua_function(tolua_S,"removeAllSprite3DData",lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData); + tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_3d_Sprite3DCache_destroyInstance); + tolua_function(tolua_S,"getInstance", lua_cocos2dx_3d_Sprite3DCache_getInstance); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::Sprite3DCache).name(); + g_luaType[typeName] = "cc.Sprite3DCache"; + g_typeCast["Sprite3DCache"] = "cc.Sprite3DCache"; + return 1; +} + int lua_cocos2dx_3d_Mesh_getMeshVertexAttribCount(lua_State* tolua_S) { int argc = 0; @@ -2881,6 +2995,7 @@ TOLUA_API int register_all_cocos2dx_3d(lua_State* tolua_S) lua_register_cocos2dx_3d_Animate3D(tolua_S); lua_register_cocos2dx_3d_Sprite3D(tolua_S); lua_register_cocos2dx_3d_AttachNode(tolua_S); + lua_register_cocos2dx_3d_Sprite3DCache(tolua_S); lua_register_cocos2dx_3d_BillBoard(tolua_S); lua_register_cocos2dx_3d_Animation3D(tolua_S); lua_register_cocos2dx_3d_Skeleton3D(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp index fb02fc2e6b..3963c71800 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp @@ -67,6 +67,10 @@ int register_all_cocos2dx_3d(lua_State* tolua_S); + + + + diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 69cd52ea2a..5349d35a96 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -1,6 +1,7 @@ #include "lua_cocos2dx_auto.hpp" #include "cocos2d.h" #include "CCProtectedNode.h" +#include "CCAsyncTaskPool.h" #include "tolua_fix.h" #include "LuaBasicConversions.h" @@ -72824,6 +72825,146 @@ int lua_register_cocos2dx_Component(lua_State* tolua_S) g_typeCast["Component"] = "cc.Component"; return 1; } + +int lua_cocos2dx_AsyncTaskPool_stopTasks(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::AsyncTaskPool* 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.AsyncTaskPool",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::AsyncTaskPool*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AsyncTaskPool_stopTasks'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::AsyncTaskPool::TaskType arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AsyncTaskPool:stopTasks"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AsyncTaskPool_stopTasks'", nullptr); + return 0; + } + cobj->stopTasks(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.AsyncTaskPool:stopTasks",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AsyncTaskPool_stopTasks'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_AsyncTaskPool_destoryInstance(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.AsyncTaskPool",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AsyncTaskPool_destoryInstance'", nullptr); + return 0; + } + cocos2d::AsyncTaskPool::destoryInstance(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AsyncTaskPool:destoryInstance",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AsyncTaskPool_destoryInstance'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_AsyncTaskPool_getInstance(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.AsyncTaskPool",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AsyncTaskPool_getInstance'", nullptr); + return 0; + } + cocos2d::AsyncTaskPool* ret = cocos2d::AsyncTaskPool::getInstance(); + object_to_luaval(tolua_S, "cc.AsyncTaskPool",(cocos2d::AsyncTaskPool*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AsyncTaskPool:getInstance",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AsyncTaskPool_getInstance'.",&tolua_err); +#endif + return 0; +} +static int lua_cocos2dx_AsyncTaskPool_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (AsyncTaskPool)"); + return 0; +} + +int lua_register_cocos2dx_AsyncTaskPool(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.AsyncTaskPool"); + tolua_cclass(tolua_S,"AsyncTaskPool","cc.AsyncTaskPool","",nullptr); + + tolua_beginmodule(tolua_S,"AsyncTaskPool"); + tolua_function(tolua_S,"stopTasks",lua_cocos2dx_AsyncTaskPool_stopTasks); + tolua_function(tolua_S,"destoryInstance", lua_cocos2dx_AsyncTaskPool_destoryInstance); + tolua_function(tolua_S,"getInstance", lua_cocos2dx_AsyncTaskPool_getInstance); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::AsyncTaskPool).name(); + g_luaType[typeName] = "cc.AsyncTaskPool"; + g_typeCast["AsyncTaskPool"] = "cc.AsyncTaskPool"; + return 1; +} TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) { tolua_open(tolua_S); @@ -72925,6 +73066,7 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_Application(tolua_S); lua_register_cocos2dx_DelayTime(tolua_S); lua_register_cocos2dx_LabelAtlas(tolua_S); + lua_register_cocos2dx_AsyncTaskPool(tolua_S); lua_register_cocos2dx_ParticleSnow(tolua_S); lua_register_cocos2dx_EaseElasticIn(tolua_S); lua_register_cocos2dx_EaseCircleActionInOut(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 60ff8cc44b..f8080968eb 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -1637,6 +1637,10 @@ int register_all_cocos2dx(lua_State* tolua_S); + + + + From ebf6f2728f7f38c76e5fc3c80190adcb30de1a0a Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Thu, 29 Jan 2015 02:57:47 +0000 Subject: [PATCH 56/66] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index c262b095c0..a05606ec79 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -4909,6 +4909,7 @@ "cocos/scripting/lua-bindings/auto/api/ArmatureDisplayData.lua", "cocos/scripting/lua-bindings/auto/api/AssetsManager.lua", "cocos/scripting/lua-bindings/auto/api/AssetsManagerEx.lua", + "cocos/scripting/lua-bindings/auto/api/AsyncTaskPool.lua", "cocos/scripting/lua-bindings/auto/api/AtlasNode.lua", "cocos/scripting/lua-bindings/auto/api/AttachNode.lua", "cocos/scripting/lua-bindings/auto/api/AudioEngine.lua", @@ -5189,6 +5190,7 @@ "cocos/scripting/lua-bindings/auto/api/SpotLight.lua", "cocos/scripting/lua-bindings/auto/api/Sprite.lua", "cocos/scripting/lua-bindings/auto/api/Sprite3D.lua", + "cocos/scripting/lua-bindings/auto/api/Sprite3DCache.lua", "cocos/scripting/lua-bindings/auto/api/SpriteBatchNode.lua", "cocos/scripting/lua-bindings/auto/api/SpriteDisplayData.lua", "cocos/scripting/lua-bindings/auto/api/SpriteFrame.lua", From 05db3bfd72664940f7677ddc72277b280e90a8ee Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Thu, 29 Jan 2015 11:55:49 +0800 Subject: [PATCH 57/66] Fixed system font can't display the proper text when the text contains '&' on win32. --- cocos/platform/win32/CCDevice-win32.cpp | 45 ++++++++++++++++++- .../cpp-tests/Classes/LabelTest/LabelTest.cpp | 6 +-- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/cocos/platform/win32/CCDevice-win32.cpp b/cocos/platform/win32/CCDevice-win32.cpp index 40272ec0de..a56a7320ac 100644 --- a/cocos/platform/win32/CCDevice-win32.cpp +++ b/cocos/platform/win32/CCDevice-win32.cpp @@ -246,6 +246,7 @@ public: { int nRet = 0; wchar_t * pwszBuffer = 0; + wchar_t* fixedText = nullptr; do { CC_BREAK_IF(! pszText); @@ -276,7 +277,37 @@ public: memset(pwszBuffer, 0, sizeof(wchar_t)*nBufLen); nLen = MultiByteToWideChar(CP_UTF8, 0, pszText, nLen, pwszBuffer, nBufLen); - SIZE newSize = sizeWithText(pwszBuffer, nLen, dwFmt, tSize.cx); + if (strchr(pszText, '&')) + { + fixedText = new wchar_t[nLen * 2 + 1]; + int fixedIndex = 0; + for (int index = 0; index < nLen; ++index) + { + if (pwszBuffer[index] == '&') + { + fixedText[fixedIndex] = '&'; + fixedText[fixedIndex + 1] = '&'; + fixedIndex += 2; + } + else + { + fixedText[fixedIndex] = pwszBuffer[index]; + fixedIndex += 1; + } + } + fixedText[fixedIndex] = '\0'; + nLen = fixedIndex; + } + + SIZE newSize; + if (fixedText) + { + newSize = sizeWithText(fixedText, nLen, dwFmt, tSize.cx); + } + else + { + newSize = sizeWithText(pwszBuffer, nLen, dwFmt, tSize.cx); + } RECT rcText = {0}; // if content width is 0, use text size as content size @@ -343,13 +374,23 @@ public: SetTextColor(_DC, RGB(255, 255, 255)); // white color // draw text - nRet = DrawTextW(_DC, pwszBuffer, nLen, &rcText, dwFmt); + if (fixedText) + { + nRet = DrawTextW(_DC, fixedText, nLen, &rcText, dwFmt); + } + else + { + nRet = DrawTextW(_DC, pwszBuffer, nLen, &rcText, dwFmt); + } + //DrawTextA(_DC, pszText, nLen, &rcText, dwFmt); SelectObject(_DC, hOldBmp); SelectObject(_DC, hOldFont); } while (0); CC_SAFE_DELETE_ARRAY(pwszBuffer); + delete[] fixedText; + return nRet; } diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp index 290f5f0875..5fd0dd878e 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp @@ -1537,11 +1537,7 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke() strokeShaodwTextDef._fontFillColor = tintColorBlue; // shadow + stroke label -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - auto fontStrokeAndShadow = LabelTTF::createWithFontDefinition("Stroke && Shadow Blue Text", strokeShaodwTextDef); -#else - auto fontStrokeAndShadow = LabelTTF::createWithFontDefinition("Stroke &Shadow Blue Text", strokeShaodwTextDef); -#endif + auto fontStrokeAndShadow = LabelTTF::createWithFontDefinition("Stroke & Shadow Blue Text", strokeShaodwTextDef); // add label to the scene this->addChild(fontStrokeAndShadow); From be8075b29ca1066a2466a483a7216f5834b6a3fd Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 28 Jan 2015 20:32:32 -0800 Subject: [PATCH 58/66] increase build heap memory option to /Zm384 --- cocos/2d/libcocos2d_wp8.vcxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos/2d/libcocos2d_wp8.vcxproj b/cocos/2d/libcocos2d_wp8.vcxproj index d3ba865a77..c9b10d10d2 100644 --- a/cocos/2d/libcocos2d_wp8.vcxproj +++ b/cocos/2d/libcocos2d_wp8.vcxproj @@ -93,7 +93,7 @@ true $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) $(EngineRoot)external\jpeg\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\tiff\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\png\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) - /Zm256 /bigobj %(AdditionalOptions) + /Zm384 /bigobj %(AdditionalOptions) pch.h @@ -114,7 +114,7 @@ true $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) $(EngineRoot)external\jpeg\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\tiff\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\png\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) - /Zm256 /bigobj %(AdditionalOptions) + /Zm384 /bigobj %(AdditionalOptions) pch.h @@ -135,7 +135,7 @@ true $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) $(EngineRoot)external\jpeg\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\tiff\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\png\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) - /Zm256 /bigobj %(AdditionalOptions) + /Zm384 /bigobj %(AdditionalOptions) pch.h @@ -156,7 +156,7 @@ true $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) $(EngineRoot)external\jpeg\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\tiff\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\png\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) - /Zm256 /bigobj %(AdditionalOptions) + /Zm384 /bigobj %(AdditionalOptions) pch.h From 652baed1eeced166c69cbfb3c5680eb855c4d933 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 28 Jan 2015 20:37:39 -0800 Subject: [PATCH 59/66] increase build heap memory option to /Zm384 --- .../libcocos2d_8_1.Windows.vcxproj | 12 ++++++------ .../libcocos2d_8_1.WindowsPhone.vcxproj | 8 ++++---- 2 files changed, 10 insertions(+), 10 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 934482d522..0054ce136d 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 @@ -144,7 +144,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1;$(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;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) @@ -162,7 +162,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1;$(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;NDEBUG;%(PreprocessorDefinitions) @@ -180,7 +180,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1;$(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;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) @@ -198,7 +198,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1;$(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;NDEBUG;%(PreprocessorDefinitions) @@ -216,7 +216,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1;$(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;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) @@ -234,7 +234,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1;$(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;NDEBUG;%(PreprocessorDefinitions) 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 5bc2b1b499..97c1d2e342 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 @@ -106,7 +106,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1;$(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_NO_GL_POINTSIZE;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) @@ -124,7 +124,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1;$(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_NO_GL_POINTSIZE;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) @@ -142,7 +142,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1;$(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_NO_GL_POINTSIZE;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) @@ -160,7 +160,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1;$(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_NO_GL_POINTSIZE;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) From f30174bf67d051caef91db4a939818966af55e79 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 29 Jan 2015 13:57:27 +0800 Subject: [PATCH 60/66] [ci skip]update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index eb28be91f6..df221d2202 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ cocos2d-x-3.4 xxx [FIX] Label: use int for dimensions that will lose the precision [FIX] Label: labels will become white block after resume from background on some Android devices, such as xiaomi3 [FIX] Label: improved parsing performance of bitmap font + [FIX] Label: can not display `&` if using system font on windows [FIX] Lua-binding:studio-support: AnimationInfo is not binded [FIX] New audio: not close file descriptor leads to that may causes game freeze if playing two many times(may be more than 1000) on Android [FIX] Node: anchor point has not effect to rotation, it always rotate along (0, 0) From f914297703098d6525f9d9bdac7dce3768711988 Mon Sep 17 00:00:00 2001 From: Nite Luo Date: Wed, 28 Jan 2015 23:55:26 -0800 Subject: [PATCH 61/66] Fix force depth write logic --- cocos/renderer/CCMeshCommand.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cocos/renderer/CCMeshCommand.cpp b/cocos/renderer/CCMeshCommand.cpp index 48685f2c64..6b5d12915d 100644 --- a/cocos/renderer/CCMeshCommand.cpp +++ b/cocos/renderer/CCMeshCommand.cpp @@ -83,6 +83,10 @@ MeshCommand::MeshCommand() , _cullFace(GL_BACK) , _depthTestEnabled(false) , _depthWriteEnabled(false) +, _forceDepthWrite(false) +, _renderStateCullFace(false) +, _renderStateDepthTest(false) +, _renderStateDepthWrite(GL_FALSE) , _lightMask(-1) { _type = RenderCommand::Type::MESH_COMMAND; @@ -168,7 +172,11 @@ void MeshCommand::setTransparent(bool value) //Skip batching for transparent mesh _skipBatching = value; - if (!_forceDepthWrite) + if (_isTransparent && !_forceDepthWrite) + { + _depthWriteEnabled = false; + } + else { _depthWriteEnabled = true; } From 995b7225dded0f89addd9c76e5e55708fac71007 Mon Sep 17 00:00:00 2001 From: Nite Luo Date: Thu, 29 Jan 2015 00:21:33 -0800 Subject: [PATCH 62/66] Add test-case for force depth bug --- .../Classes/Sprite3DTest/Sprite3DTest.cpp | 39 ++++++++++++++++++- .../Classes/Sprite3DTest/Sprite3DTest.h | 9 +++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index b633f9252d..c420d9469c 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -70,7 +70,8 @@ static std::function createFunctions[] = CL(Sprite3DMirrorTest), CL(QuaternionTest), CL(Sprite3DEmptyTest), - CL(UseCaseSprite3D) + CL(UseCaseSprite3D), + CL(Sprite3DForceDepthTest) }; #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) @@ -156,6 +157,42 @@ void Sprite3DTestDemo::backCallback(Ref* sender) s->release(); } +//------------------------------------------------------------------ +// +// Sprite3DForceDepthTest +// +//------------------------------------------------------------------ +Sprite3DForceDepthTest::Sprite3DForceDepthTest() +{ + auto orc = Sprite3D::create("Sprite3DTest/orc.c3b"); + orc->setScale(5); + orc->setNormalizedPosition(Vec2(.5,.3)); + orc->setPositionZ(40); + orc->setRotation3D(Vec3(0,180,0)); + orc->setGlobalZOrder(-1); + + addChild(orc); + + auto ship = Sprite3D::create("Sprite3DTest/boss1.obj"); + ship->setScale(5); + ship->setTexture("Sprite3DTest/boss.png"); + ship->setNormalizedPosition(Vec2(.5,.5)); + ship->setRotation3D(Vec3(90,0,0)); + ship->setForceDepthWrite(true); + + addChild(ship); +} + +std::string Sprite3DForceDepthTest::title() const +{ + return "Force Depth Write Test"; +} + +std::string Sprite3DForceDepthTest::subtitle() const +{ + return "Ship should always appear behind orc"; +} + //------------------------------------------------------------------ // // Sprite3DEmptyTest diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index 812e84171c..c59cd4895d 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -54,6 +54,15 @@ public: virtual void onEnter() override; }; +class Sprite3DForceDepthTest : public Sprite3DTestDemo +{ +public: + CREATE_FUNC(Sprite3DForceDepthTest); + Sprite3DForceDepthTest(); + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + class Sprite3DEmptyTest : public Sprite3DTestDemo { public: From 5532cb30b68c5cc73b271f25d4ce89a472653450 Mon Sep 17 00:00:00 2001 From: Nite Luo Date: Thu, 29 Jan 2015 00:24:32 -0800 Subject: [PATCH 63/66] Tweak the name --- tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index c420d9469c..79fc9241ac 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -185,7 +185,7 @@ Sprite3DForceDepthTest::Sprite3DForceDepthTest() std::string Sprite3DForceDepthTest::title() const { - return "Force Depth Write Test"; + return "Force Depth Write Error Test"; } std::string Sprite3DForceDepthTest::subtitle() const From 3eeeaf051f4a92ff13fa612bf4045e79f11706c2 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Thu, 29 Jan 2015 17:54:22 +0800 Subject: [PATCH 64/66] fix load mtl --- cocos/3d/CCObjLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/3d/CCObjLoader.cpp b/cocos/3d/CCObjLoader.cpp index 01da07a27c..eb77f2a7d5 100644 --- a/cocos/3d/CCObjLoader.cpp +++ b/cocos/3d/CCObjLoader.cpp @@ -289,7 +289,7 @@ std::string LoadMtl ( std::map& material_map filepath = std::string(filename); } - std::ifstream ifs(filepath.c_str()); + std::istringstream ifs(FileUtils::getInstance()->getStringFromFile(filepath)); if (!ifs) { err << "Cannot open file [" << filepath << "]" << std::endl; From cd00de572d60704ca031070c47444a4e73939cf8 Mon Sep 17 00:00:00 2001 From: huangshiwu Date: Thu, 29 Jan 2015 18:06:20 +0800 Subject: [PATCH 65/66] add glBindBuffer for drawnode and clippingnode to avoid crash --- cocos/2d/CCClippingNode.cpp | 3 ++- cocos/2d/CCDrawNode.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index 4cb2180915..de31dba134 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -218,7 +218,8 @@ void ClippingNode::drawFullScreenQuadClearStencil() glProgram->use(); glProgram->setUniformsForBuiltins(); glProgram->setUniformLocationWith4fv(colorLocation, (GLfloat*) &color.r, 1); - + + glBindBuffer(GL_ARRAY_BUFFER, 0); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index 91cd48152e..e72f5c9e21 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -274,6 +274,8 @@ bool DrawNode::init() glGenBuffers(1, &_vboGLPoint); glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint); glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLPoint, _bufferGLPoint, GL_STREAM_DRAW); + + glBindBuffer(GL_ARRAY_BUFFER, 0); } CHECK_GL_ERROR_DEBUG(); From 6873713c31f64818f7ec8b11abe93fa64726dc85 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Thu, 29 Jan 2015 19:38:55 +0800 Subject: [PATCH 66/66] Fixed compile error on win32 --- cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj index 2ece90e2c5..d916eba7d1 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj @@ -277,7 +277,7 @@ Disabled - $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos\2d;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\ui;$(EngineRoot)external;$(EngineRoot)external\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -309,7 +309,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ MinSpace true - $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)cocos\ui;$(EngineRoot)external;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)cocos\ui;$(EngineRoot)external;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true