From e8007b9e63f214f3b6f119702d9c6a218e073896 Mon Sep 17 00:00:00 2001 From: tangziwen Date: Mon, 13 Oct 2014 17:49:00 +0800 Subject: [PATCH 1/2] fix mesh AABB incorrect calculation through using static variable --- cocos/3d/CCMeshVertexIndexData.cpp | 4 ++-- cocos/3d/CCMeshVertexIndexData.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/3d/CCMeshVertexIndexData.cpp b/cocos/3d/CCMeshVertexIndexData.cpp index 3bb77ddefb..9e62a35e07 100644 --- a/cocos/3d/CCMeshVertexIndexData.cpp +++ b/cocos/3d/CCMeshVertexIndexData.cpp @@ -121,9 +121,9 @@ MeshVertexData* MeshVertexData::create(const MeshData& meshdata) return vertexdata; } -const AABB& MeshVertexData::calculateAABB(const std::vector& vertex, int stride, const std::vector& index) +const AABB MeshVertexData::calculateAABB(const std::vector& vertex, int stride, const std::vector& index) { - static AABB aabb; + AABB aabb; stride /= 4; for(const auto& it : index) { diff --git a/cocos/3d/CCMeshVertexIndexData.h b/cocos/3d/CCMeshVertexIndexData.h index 1c540b72c8..9b67757632 100644 --- a/cocos/3d/CCMeshVertexIndexData.h +++ b/cocos/3d/CCMeshVertexIndexData.h @@ -116,7 +116,7 @@ CC_CONSTRUCTOR_ACCESS: MeshVertexData(); virtual ~MeshVertexData(); - static const AABB& calculateAABB(const std::vector& vertex, int stride, const std::vector& index); + static const AABB calculateAABB(const std::vector& vertex, int stride, const std::vector& index); protected: VertexData* _vertexData; //mesh vertex data VertexBuffer* _vertexBuffer; // vertex buffer From 7566880d46dcef478cb2c2686d99e9ccaf63a783 Mon Sep 17 00:00:00 2001 From: tangziwen Date: Tue, 14 Oct 2014 09:14:46 +0800 Subject: [PATCH 2/2] fix mesh's AABB calculation incorrect by using static variable --- cocos/3d/CCMeshVertexIndexData.cpp | 2 +- cocos/3d/CCMeshVertexIndexData.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/3d/CCMeshVertexIndexData.cpp b/cocos/3d/CCMeshVertexIndexData.cpp index 9e62a35e07..513805ccb2 100644 --- a/cocos/3d/CCMeshVertexIndexData.cpp +++ b/cocos/3d/CCMeshVertexIndexData.cpp @@ -121,7 +121,7 @@ MeshVertexData* MeshVertexData::create(const MeshData& meshdata) return vertexdata; } -const AABB MeshVertexData::calculateAABB(const std::vector& vertex, int stride, const std::vector& index) +AABB MeshVertexData::calculateAABB(const std::vector& vertex, int stride, const std::vector& index) { AABB aabb; stride /= 4; diff --git a/cocos/3d/CCMeshVertexIndexData.h b/cocos/3d/CCMeshVertexIndexData.h index 9b67757632..1fb4af9c68 100644 --- a/cocos/3d/CCMeshVertexIndexData.h +++ b/cocos/3d/CCMeshVertexIndexData.h @@ -116,7 +116,7 @@ CC_CONSTRUCTOR_ACCESS: MeshVertexData(); virtual ~MeshVertexData(); - static const AABB calculateAABB(const std::vector& vertex, int stride, const std::vector& index); + static AABB calculateAABB(const std::vector& vertex, int stride, const std::vector& index); protected: VertexData* _vertexData; //mesh vertex data VertexBuffer* _vertexBuffer; // vertex buffer