Merge pull request #8085 from super626/v3

Shared GLProgramState by default and Fix BillBoard Anchor Point
This commit is contained in:
minggo 2014-09-18 10:52:35 +08:00
commit 5e5129d0d1
3 changed files with 14 additions and 3 deletions

View File

@ -36,7 +36,7 @@ BillBoard::BillBoard()
, _mode(Mode::VIEW_POINT_ORIENTED)
, _modeDirty(false)
{
Node::setAnchorPoint(Vec2(0.5f,0.5f));
}
BillBoard::~BillBoard()

View File

@ -90,7 +90,9 @@ bool Sprite3D::loadFromCache(const std::string& path)
}
}
genGLProgramState();
for (ssize_t i = 0; i < _meshes.size(); i++) {
_meshes.at(i)->setGLProgramState(spritedata->glProgramStates.at(i));
}
return true;
}
@ -113,6 +115,10 @@ bool Sprite3D::loadFromObj(const std::string& path)
data->materialdatas = materialdatas;
data->nodedatas = nodeDatas;
data->meshVertexDatas = _meshVertexDatas;
for (const auto mesh : _meshes) {
data->glProgramStates.pushBack(mesh->getGLProgramState());
}
Sprite3DCache::getInstance()->addSprite3DData(path, data);
return true;
}
@ -143,6 +149,9 @@ bool Sprite3D::loadFromC3x(const std::string& path)
data->materialdatas = materialdatas;
data->nodedatas = nodeDatas;
data->meshVertexDatas = _meshVertexDatas;
for (const auto mesh : _meshes) {
data->glProgramStates.pushBack(mesh->getGLProgramState());
}
Sprite3DCache::getInstance()->addSprite3DData(path, data);
return true;
}

View File

@ -32,6 +32,7 @@
#include "base/CCProtocols.h"
#include "2d/CCNode.h"
#include "renderer/CCMeshCommand.h"
#include "renderer/CCGLProgramState.h"
#include "3d/CCSkeleton3D.h" // need to include for lua-binding
#include "3d/CCAABB.h"
#include "3d/CCBundle3DData.h"
@ -41,7 +42,6 @@
NS_CC_BEGIN
class GLProgramState;
class Mesh;
class Texture2D;
class MeshSkin;
@ -171,6 +171,7 @@ public:
struct Sprite3DData
{
Vector<MeshVertexData*> meshVertexDatas;
Vector<GLProgramState*> glProgramStates;
NodeDatas* nodedatas;
MaterialDatas* materialdatas;
~Sprite3DData()
@ -180,6 +181,7 @@ public:
if (materialdatas)
delete materialdatas;
meshVertexDatas.clear();
glProgramStates.clear();
}
};