forked from bartvdbraak/blender
BGE: bug #21684 fixed: multiple material with static modifier now supported with display list.
This commit is contained in:
parent
d337448090
commit
f1cfb5f13c
@ -25,7 +25,8 @@ RAS_ListSlot::RAS_ListSlot(RAS_ListRasterizer* rasty)
|
|||||||
: KX_ListSlot(),
|
: KX_ListSlot(),
|
||||||
m_list(0),
|
m_list(0),
|
||||||
m_flag(LIST_MODIFY|LIST_CREATE),
|
m_flag(LIST_MODIFY|LIST_CREATE),
|
||||||
m_rasty(rasty)
|
m_rasty(rasty),
|
||||||
|
m_matnr(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,11 +122,23 @@ void RAS_ListRasterizer::RemoveListSlot(RAS_ListSlot* list)
|
|||||||
if (list->m_flag & LIST_DERIVEDMESH) {
|
if (list->m_flag & LIST_DERIVEDMESH) {
|
||||||
RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.begin();
|
RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.begin();
|
||||||
while(it != mDerivedMeshLists.end()) {
|
while(it != mDerivedMeshLists.end()) {
|
||||||
if (it->second == list) {
|
RAS_ListSlots *slots = it->second;
|
||||||
mDerivedMeshLists.erase(it);
|
if (slots->size() > list->m_matnr && slots->at(list->m_matnr) == list) {
|
||||||
|
(*slots)[list->m_matnr] = NULL;
|
||||||
|
// check if all slots are NULL and if yes, delete the entry
|
||||||
|
int i;
|
||||||
|
for (i=slots->size(); i-- > 0; ) {
|
||||||
|
if (slots->at(i) != NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
it++;
|
if (i < 0) {
|
||||||
|
slots->clear();
|
||||||
|
delete slots;
|
||||||
|
mDerivedMeshLists.erase(it);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
RAS_ArrayLists::iterator it = mArrayLists.begin();
|
RAS_ArrayLists::iterator it = mArrayLists.begin();
|
||||||
@ -152,13 +165,28 @@ RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(RAS_MeshSlot& ms)
|
|||||||
if (ms.m_pDerivedMesh) {
|
if (ms.m_pDerivedMesh) {
|
||||||
// that means that we draw based on derived mesh, a display list is possible
|
// that means that we draw based on derived mesh, a display list is possible
|
||||||
// Note that we come here only for static derived mesh
|
// Note that we come here only for static derived mesh
|
||||||
|
int matnr = ms.m_bucket->GetPolyMaterial()->GetMaterialIndex();
|
||||||
|
RAS_ListSlots *listVector;
|
||||||
RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.find(ms.m_pDerivedMesh);
|
RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.find(ms.m_pDerivedMesh);
|
||||||
if(it == mDerivedMeshLists.end()) {
|
if(it == mDerivedMeshLists.end()) {
|
||||||
|
listVector = new RAS_ListSlots(matnr+4, NULL);
|
||||||
localSlot = new RAS_ListSlot(this);
|
localSlot = new RAS_ListSlot(this);
|
||||||
localSlot->m_flag |= LIST_DERIVEDMESH;
|
localSlot->m_flag |= LIST_DERIVEDMESH;
|
||||||
mDerivedMeshLists.insert(std::pair<DerivedMesh*, RAS_ListSlot*>(ms.m_pDerivedMesh, localSlot));
|
localSlot->m_matnr = matnr;
|
||||||
|
(*listVector)[matnr] = localSlot;
|
||||||
|
mDerivedMeshLists.insert(std::pair<DerivedMesh*, RAS_ListSlots*>(ms.m_pDerivedMesh, listVector));
|
||||||
} else {
|
} else {
|
||||||
localSlot = static_cast<RAS_ListSlot*>(it->second->AddRef());
|
listVector = it->second;
|
||||||
|
if (listVector->size() <= matnr)
|
||||||
|
listVector->resize(matnr+4, NULL);
|
||||||
|
if ((localSlot = listVector->at(matnr)) == NULL) {
|
||||||
|
localSlot = new RAS_ListSlot(this);
|
||||||
|
localSlot->m_flag |= LIST_DERIVEDMESH;
|
||||||
|
localSlot->m_matnr = matnr;
|
||||||
|
(*listVector)[matnr] = localSlot;
|
||||||
|
} else {
|
||||||
|
localSlot->AddRef();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
RAS_ArrayLists::iterator it = mArrayLists.find(ms.m_displayArrays);
|
RAS_ArrayLists::iterator it = mArrayLists.find(ms.m_displayArrays);
|
||||||
@ -179,8 +207,16 @@ void RAS_ListRasterizer::ReleaseAlloc()
|
|||||||
for(RAS_ArrayLists::iterator it = mArrayLists.begin();it != mArrayLists.end();++it)
|
for(RAS_ArrayLists::iterator it = mArrayLists.begin();it != mArrayLists.end();++it)
|
||||||
delete it->second;
|
delete it->second;
|
||||||
mArrayLists.clear();
|
mArrayLists.clear();
|
||||||
for (RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.begin();it != mDerivedMeshLists.end();++it)
|
for (RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.begin();it != mDerivedMeshLists.end();++it) {
|
||||||
delete it->second;
|
RAS_ListSlots* slots = it->second;
|
||||||
|
for (int i=slots->size(); i-- > 0; ) {
|
||||||
|
RAS_ListSlot* slot = slots->at(i);
|
||||||
|
if (slot)
|
||||||
|
delete slot;
|
||||||
|
}
|
||||||
|
slots->clear();
|
||||||
|
delete slots;
|
||||||
|
}
|
||||||
mDerivedMeshLists.clear();
|
mDerivedMeshLists.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ class RAS_ListSlot : public KX_ListSlot
|
|||||||
friend class RAS_ListRasterizer;
|
friend class RAS_ListRasterizer;
|
||||||
unsigned int m_list;
|
unsigned int m_list;
|
||||||
unsigned int m_flag;
|
unsigned int m_flag;
|
||||||
|
unsigned int m_matnr;
|
||||||
RAS_ListRasterizer* m_rasty;
|
RAS_ListRasterizer* m_rasty;
|
||||||
public:
|
public:
|
||||||
RAS_ListSlot(RAS_ListRasterizer* rasty);
|
RAS_ListSlot(RAS_ListRasterizer* rasty);
|
||||||
@ -40,7 +41,8 @@ enum RAS_ListSlotFlags {
|
|||||||
struct DerivedMesh;
|
struct DerivedMesh;
|
||||||
|
|
||||||
typedef std::map<RAS_DisplayArrayList, RAS_ListSlot*> RAS_ArrayLists;
|
typedef std::map<RAS_DisplayArrayList, RAS_ListSlot*> RAS_ArrayLists;
|
||||||
typedef std::map<DerivedMesh*, RAS_ListSlot*> RAS_DerivedMeshLists;
|
typedef std::vector<RAS_ListSlot*> RAS_ListSlots; // indexed by material slot number
|
||||||
|
typedef std::map<DerivedMesh*, RAS_ListSlots*> RAS_DerivedMeshLists;
|
||||||
|
|
||||||
class RAS_ListRasterizer : public RAS_VAOpenGLRasterizer
|
class RAS_ListRasterizer : public RAS_VAOpenGLRasterizer
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user