From e650ef2b4d22edac8f3236f705696a47ce3f02a6 Mon Sep 17 00:00:00 2001 From: songchengjiang Date: Tue, 3 Mar 2015 11:52:55 +0800 Subject: [PATCH] check sprite == nullptr remove unneeded namespace --- extensions/Particle3D/CCParticle3DRender.cpp | 5 +++++ .../ParticleRenders/CCPUParticle3DRender.cpp | 7 ++++++- .../ParticleRenders/CCPUParticle3DRender.h | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/extensions/Particle3D/CCParticle3DRender.cpp b/extensions/Particle3D/CCParticle3DRender.cpp index 5fb970a877..f61c4f4233 100755 --- a/extensions/Particle3D/CCParticle3DRender.cpp +++ b/extensions/Particle3D/CCParticle3DRender.cpp @@ -240,6 +240,11 @@ void Particle3DModelRender::render(Renderer* renderer, const Mat4 &transform, Pa if (_spriteList.empty()){ for (unsigned int i = 0; i < particleSystem->getParticleQuota(); ++i){ Sprite3D *sprite = Sprite3D::create(_modelFile); + if (sprite == nullptr) + { + CCLOG("failed to load file %s", _modelFile.c_str()); + continue; + } sprite->setTexture(_texFile); sprite->retain(); _spriteList.push_back(sprite); diff --git a/extensions/Particle3D/ParticleUniverse/ParticleRenders/CCPUParticle3DRender.cpp b/extensions/Particle3D/ParticleUniverse/ParticleRenders/CCPUParticle3DRender.cpp index 53c52fb9a8..ef6d955cb6 100644 --- a/extensions/Particle3D/ParticleUniverse/ParticleRenders/CCPUParticle3DRender.cpp +++ b/extensions/Particle3D/ParticleUniverse/ParticleRenders/CCPUParticle3DRender.cpp @@ -377,7 +377,7 @@ void PUParticle3DQuadRender::determineUVCoords( PUParticle3D *particle ) particle->rt_uv = particle->lb_uv + Vec2(_textureCoordsColStep, _textureCoordsRowStep); } -void PUParticle3DQuadRender::fillVertex( unsigned short index, const cocos2d::Vec3 &pos, const cocos2d::Vec4 &color, const cocos2d::Vec2 &uv ) +void PUParticle3DQuadRender::fillVertex( unsigned short index, const Vec3 &pos, const Vec4 &color, const Vec2 &uv ) { _vertices[index].position = pos; _vertices[index].color = color; @@ -439,6 +439,11 @@ void PUParticle3DModelRender::render( Renderer* renderer, const Mat4 &transform, if (_spriteList.empty()){ for (unsigned int i = 0; i < particleSystem->getParticleQuota(); ++i){ Sprite3D *sprite = Sprite3D::create(_modelFile); + if (sprite == nullptr) + { + CCLOG("failed to load file %s", _modelFile.c_str()); + continue; + } sprite->setTexture(_texFile); sprite->retain(); _spriteList.push_back(sprite); diff --git a/extensions/Particle3D/ParticleUniverse/ParticleRenders/CCPUParticle3DRender.h b/extensions/Particle3D/ParticleUniverse/ParticleRenders/CCPUParticle3DRender.h index ab8d7e354c..a0819f22c1 100644 --- a/extensions/Particle3D/ParticleUniverse/ParticleRenders/CCPUParticle3DRender.h +++ b/extensions/Particle3D/ParticleUniverse/ParticleRenders/CCPUParticle3DRender.h @@ -161,7 +161,7 @@ protected: void getOriginOffset(int &offsetX, int &offsetY); void determineUVCoords(PUParticle3D *particle); - void fillVertex(unsigned short index, const cocos2d::Vec3 &pos, const cocos2d::Vec4 &color, const cocos2d::Vec2 &uv); + void fillVertex(unsigned short index, const Vec3 &pos, const Vec4 &color, const Vec2 &uv); void fillTriangle(unsigned short index, unsigned short v0, unsigned short v1, unsigned short v2); protected: