From ed2dac1ba44a9e0ea3146c6adcf120bec9eff5cd Mon Sep 17 00:00:00 2001 From: zloopnew Date: Thu, 27 Oct 2016 15:20:41 +0800 Subject: [PATCH] Mesh* Sprite3D::getMesh() should return nullptr when _meshes.empty() is true (#16711) --- cocos/3d/CCSprite3D.cpp | 9 +++++++++ cocos/3d/CCSprite3D.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index e83258c631..3957e5f7b5 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -920,6 +920,15 @@ std::vector Sprite3D::getMeshArrayByName(const std::string& name) const return meshes; } +Mesh* Sprite3D::getMesh() const +{ + if(_meshes.empty()) + { + return nullptr; + } + return _meshes.at(0); +} + MeshSkin* Sprite3D::getSkin() const { for (const auto& it : _meshes) { diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index 16443c6bd9..35eab65a80 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -98,7 +98,7 @@ public: std::vector getMeshArrayByName(const std::string& name) const; /**get mesh*/ - Mesh* getMesh() const { return _meshes.at(0); } + Mesh* getMesh() const; /** get mesh count */ ssize_t getMeshCount() const { return _meshes.size(); }