BGE: restore a feature that was lost in 2.48: sharing of display lists between duplicated objects.

This commit is contained in:
Benoit Bolsee
2009-04-18 09:14:51 +00:00
parent df8cf26404
commit 53fd3847bc
4 changed files with 11 additions and 9 deletions

View File

@@ -60,7 +60,7 @@ RAS_MeshSlot::RAS_MeshSlot()
RAS_MeshSlot::~RAS_MeshSlot() RAS_MeshSlot::~RAS_MeshSlot()
{ {
vector<RAS_DisplayArray*>::iterator it; RAS_DisplayArrayList::iterator it;
#ifdef USE_SPLIT #ifdef USE_SPLIT
Split(true); Split(true);
@@ -83,7 +83,7 @@ RAS_MeshSlot::~RAS_MeshSlot()
RAS_MeshSlot::RAS_MeshSlot(const RAS_MeshSlot& slot) RAS_MeshSlot::RAS_MeshSlot(const RAS_MeshSlot& slot)
{ {
vector<RAS_DisplayArray*>::iterator it; RAS_DisplayArrayList::iterator it;
m_clientObj = NULL; m_clientObj = NULL;
m_pDeformer = NULL; m_pDeformer = NULL;
@@ -205,7 +205,7 @@ RAS_DisplayArray *RAS_MeshSlot::CurrentDisplayArray()
void RAS_MeshSlot::SetDisplayArray(int numverts) void RAS_MeshSlot::SetDisplayArray(int numverts)
{ {
vector<RAS_DisplayArray*>::iterator it; RAS_DisplayArrayList::iterator it;
RAS_DisplayArray *darray = NULL; RAS_DisplayArray *darray = NULL;
for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
@@ -297,7 +297,7 @@ bool RAS_MeshSlot::Equals(RAS_MeshSlot *target)
bool RAS_MeshSlot::Join(RAS_MeshSlot *target, MT_Scalar distance) bool RAS_MeshSlot::Join(RAS_MeshSlot *target, MT_Scalar distance)
{ {
vector<RAS_DisplayArray*>::iterator it; RAS_DisplayArrayList::iterator it;
iterator mit; iterator mit;
size_t i; size_t i;
@@ -362,7 +362,7 @@ bool RAS_MeshSlot::Split(bool force)
{ {
list<RAS_MeshSlot*>::iterator jit; list<RAS_MeshSlot*>::iterator jit;
RAS_MeshSlot *target = m_joinSlot; RAS_MeshSlot *target = m_joinSlot;
vector<RAS_DisplayArray*>::iterator it, jt; RAS_DisplayArrayList::iterator it, jt;
iterator mit; iterator mit;
size_t i, found0 = 0, found1 = 0; size_t i, found0 = 0, found1 = 0;

View File

@@ -86,9 +86,11 @@ public:
}; };
/* Entry of a RAS_MeshObject into RAS_MaterialBucket */ /* Entry of a RAS_MeshObject into RAS_MaterialBucket */
typedef std::vector<RAS_DisplayArray*> RAS_DisplayArrayList;
class RAS_MeshSlot class RAS_MeshSlot
{ {
friend class RAS_ListRasterizer;
private: private:
// indices into display arrays // indices into display arrays
int m_startarray; int m_startarray;
@@ -97,7 +99,7 @@ private:
int m_endindex; int m_endindex;
int m_startvertex; int m_startvertex;
int m_endvertex; int m_endvertex;
vector<RAS_DisplayArray*> m_displayArrays; RAS_DisplayArrayList m_displayArrays;
// for construction only // for construction only
RAS_DisplayArray* m_currentArray; RAS_DisplayArray* m_currentArray;

View File

@@ -136,10 +136,10 @@ RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(RAS_MeshSlot& ms)
*/ */
RAS_ListSlot* localSlot = (RAS_ListSlot*)ms.m_DisplayList; RAS_ListSlot* localSlot = (RAS_ListSlot*)ms.m_DisplayList;
if(!localSlot) { if(!localSlot) {
RAS_Lists::iterator it = mLists.find(&ms); RAS_Lists::iterator it = mLists.find(ms.m_displayArrays);
if(it == mLists.end()) { if(it == mLists.end()) {
localSlot = new RAS_ListSlot(this); localSlot = new RAS_ListSlot(this);
mLists.insert(std::pair<RAS_MeshSlot*, RAS_ListSlot*>(&ms, localSlot)); mLists.insert(std::pair<RAS_DisplayArrayList, RAS_ListSlot*>(ms.m_displayArrays, localSlot));
} else { } else {
localSlot = static_cast<RAS_ListSlot*>(it->second->AddRef()); localSlot = static_cast<RAS_ListSlot*>(it->second->AddRef());
} }

View File

@@ -35,7 +35,7 @@ enum RAS_ListSlotFlags {
LIST_REGEN =64 LIST_REGEN =64
}; };
typedef std::map<class RAS_MeshSlot*, RAS_ListSlot*> RAS_Lists; typedef std::map<RAS_DisplayArrayList, RAS_ListSlot*> RAS_Lists;
class RAS_ListRasterizer : public RAS_VAOpenGLRasterizer class RAS_ListRasterizer : public RAS_VAOpenGLRasterizer
{ {