diff options
Diffstat (limited to 'source/gameengine/Rasterizer/RAS_MaterialBucket.cpp')
-rw-r--r-- | source/gameengine/Rasterizer/RAS_MaterialBucket.cpp | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index ad26ed52ed7..a18adfd8986 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -77,9 +77,9 @@ RAS_MeshSlot::~RAS_MeshSlot() m_joinedSlots.front()->Split(true); #endif - for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { + for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { (*it)->m_users--; - if((*it)->m_users == 0) + if ((*it)->m_users == 0) delete *it; } @@ -117,7 +117,7 @@ RAS_MeshSlot::RAS_MeshSlot(const RAS_MeshSlot& slot) : SG_QList() m_endvertex = slot.m_endvertex; m_endindex = slot.m_endindex; - for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { + for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { // don't copy display arrays for now because it breaks python // access to vertices, but we'll need a solution if we want to // join display arrays for reducing draw calls. @@ -149,7 +149,7 @@ void RAS_MeshSlot::begin(RAS_MeshSlot::iterator& it) it.array = (m_displayArrays.size() > 0)? m_displayArrays[m_startarray]: NULL; - if(it.array == NULL || it.array->m_index.size() == 0 || it.array->m_vertex.size() == 0) { + if (it.array == NULL || it.array->m_index.size() == 0 || it.array->m_vertex.size() == 0) { it.array = NULL; it.vertex = NULL; it.index = NULL; @@ -177,7 +177,7 @@ void RAS_MeshSlot::next(RAS_MeshSlot::iterator& it) int startvertex, endvertex; int startindex, endindex; - if(it.arraynum == (size_t)m_endarray) { + if (it.arraynum == (size_t)m_endarray) { it.array = NULL; it.vertex = NULL; it.index = NULL; @@ -217,13 +217,13 @@ void RAS_MeshSlot::SetDisplayArray(int numverts) RAS_DisplayArrayList::iterator it; RAS_DisplayArray *darray = NULL; - for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { + for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { darray = *it; - if(darray->m_type == numverts) { - if(darray->m_index.size()+numverts >= RAS_DisplayArray::BUCKET_MAX_INDEX) + if (darray->m_type == numverts) { + if (darray->m_index.size()+numverts >= RAS_DisplayArray::BUCKET_MAX_INDEX) darray = NULL; - else if(darray->m_vertex.size()+numverts >= RAS_DisplayArray::BUCKET_MAX_VERTEX) + else if (darray->m_vertex.size()+numverts >= RAS_DisplayArray::BUCKET_MAX_VERTEX) darray = NULL; else break; @@ -232,21 +232,21 @@ void RAS_MeshSlot::SetDisplayArray(int numverts) darray = NULL; } - if(!darray) { + if (!darray) { darray = new RAS_DisplayArray(); darray->m_users = 1; - if(numverts == 2) darray->m_type = RAS_DisplayArray::LINE; - else if(numverts == 3) darray->m_type = RAS_DisplayArray::TRIANGLE; + if (numverts == 2) darray->m_type = RAS_DisplayArray::LINE; + else if (numverts == 3) darray->m_type = RAS_DisplayArray::TRIANGLE; else darray->m_type = RAS_DisplayArray::QUAD; m_displayArrays.push_back(darray); - if(numverts == 2) + if (numverts == 2) darray->m_type = RAS_DisplayArray::LINE; - else if(numverts == 3) + else if (numverts == 3) darray->m_type = RAS_DisplayArray::TRIANGLE; - else if(numverts == 4) + else if (numverts == 4) darray->m_type = RAS_DisplayArray::QUAD; m_endarray = m_displayArrays.size()-1; @@ -271,7 +271,7 @@ int RAS_MeshSlot::AddVertex(const RAS_TexVert& tv) darray->m_vertex.push_back(tv); offset = darray->m_vertex.size()-1; - if(darray == m_displayArrays[m_endarray]) + if (darray == m_displayArrays[m_endarray]) m_endvertex++; return offset; @@ -284,7 +284,7 @@ void RAS_MeshSlot::AddPolygonVertex(int offset) darray = m_currentArray; darray->m_index.push_back(offset); - if(darray == m_displayArrays[m_endarray]) + if (darray == m_displayArrays[m_endarray]) m_endindex++; } @@ -294,9 +294,9 @@ void RAS_MeshSlot::SetDeformer(RAS_Deformer* deformer) RAS_DisplayArrayList::iterator it; if (deformer->ShareVertexArray()) { // this deformer uses the base vertex array, first release the current ones - for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { + for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { (*it)->m_users--; - if((*it)->m_users == 0) + if ((*it)->m_users == 0) delete *it; } m_displayArrays.clear(); @@ -304,7 +304,7 @@ void RAS_MeshSlot::SetDeformer(RAS_Deformer* deformer) RAS_MeshMaterial *mmat = m_mesh->GetMeshMaterial(m_bucket->GetPolyMaterial()); if (mmat && mmat->m_baseslot) { m_displayArrays = mmat->m_baseslot->m_displayArrays; - for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { + for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { (*it)->m_users++; } } @@ -313,7 +313,7 @@ void RAS_MeshSlot::SetDeformer(RAS_Deformer* deformer) // no sharing // we create local copy of RAS_DisplayArray when we have a deformer: // this way we can avoid conflict between the vertex cache of duplicates - for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { + for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { if (deformer->UseVertexArray()) { // the deformer makes use of vertex array, make sure we have our local copy if ((*it)->m_users > 1) { @@ -327,7 +327,7 @@ void RAS_MeshSlot::SetDeformer(RAS_Deformer* deformer) } else { // the deformer is not using vertex array (Modifier), release them (*it)->m_users--; - if((*it)->m_users == 0) + if ((*it)->m_users == 0) delete *it; } } @@ -347,15 +347,15 @@ void RAS_MeshSlot::SetDeformer(RAS_Deformer* deformer) bool RAS_MeshSlot::Equals(RAS_MeshSlot *target) { - if(!m_OpenGLMatrix || !target->m_OpenGLMatrix) + if (!m_OpenGLMatrix || !target->m_OpenGLMatrix) return false; - if(m_pDeformer || target->m_pDeformer) + if (m_pDeformer || target->m_pDeformer) return false; - if(m_bVisible != target->m_bVisible) + if (m_bVisible != target->m_bVisible) return false; - if(m_bObjectColor != target->m_bObjectColor) + if (m_bObjectColor != target->m_bObjectColor) return false; - if(m_bObjectColor && !(m_RGBAcolor == target->m_RGBAcolor)) + if (m_bObjectColor && !(m_RGBAcolor == target->m_RGBAcolor)) return false; return true; @@ -368,16 +368,16 @@ bool RAS_MeshSlot::Join(RAS_MeshSlot *target, MT_Scalar distance) size_t i; // verify if we can join - if(m_joinSlot || m_joinedSlots.size() || target->m_joinSlot) + if (m_joinSlot || m_joinedSlots.size() || target->m_joinSlot) return false; - if(!Equals(target)) + if (!Equals(target)) return false; MT_Vector3 co(&m_OpenGLMatrix[12]); MT_Vector3 targetco(&target->m_OpenGLMatrix[12]); - if((co - targetco).length() > distance) + if ((co - targetco).length() > distance) return false; MT_Matrix4x4 mat(m_OpenGLMatrix); @@ -395,14 +395,14 @@ bool RAS_MeshSlot::Join(RAS_MeshSlot *target, MT_Scalar distance) MT_Matrix4x4 ntransform = m_joinInvTransform.transposed(); ntransform[0][3]= ntransform[1][3]= ntransform[2][3]= 0.0f; - for(begin(mit); !end(mit); next(mit)) - for(i=mit.startvertex; i<mit.endvertex; i++) + for (begin(mit); !end(mit); next(mit)) + for (i=mit.startvertex; i<mit.endvertex; i++) mit.vertex[i].Transform(transform, ntransform); /* We know we'll need a list at least this big, reserve in advance */ target->m_displayArrays.reserve(target->m_displayArrays.size() + m_displayArrays.size()); - for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { + for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { target->m_displayArrays.push_back(*it); target->m_endarray++; target->m_endvertex = target->m_displayArrays.back()->m_vertex.size(); @@ -432,24 +432,24 @@ bool RAS_MeshSlot::Split(bool force) iterator mit; size_t i, found0 = 0, found1 = 0; - if(target && (force || !Equals(target))) { + if (target && (force || !Equals(target))) { m_joinSlot = NULL; - for(jit=target->m_joinedSlots.begin(); jit!=target->m_joinedSlots.end(); jit++) { - if(*jit == this) { + for (jit=target->m_joinedSlots.begin(); jit!=target->m_joinedSlots.end(); jit++) { + if (*jit == this) { target->m_joinedSlots.erase(jit); found0 = 1; break; } } - if(!found0) + if (!found0) abort(); - for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { + for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { found1 = 0; - for(jt=target->m_displayArrays.begin(); jt!=target->m_displayArrays.end(); jt++) { - if(*jt == *it) { + for (jt=target->m_displayArrays.begin(); jt!=target->m_displayArrays.end(); jt++) { + if (*jt == *it) { target->m_displayArrays.erase(jt); target->m_endarray--; found1 = 1; @@ -457,11 +457,11 @@ bool RAS_MeshSlot::Split(bool force) } } - if(!found1) + if (!found1) abort(); } - if(target->m_displayArrays.size()) { + if (target->m_displayArrays.size()) { target->m_endvertex = target->m_displayArrays.back()->m_vertex.size(); target->m_endindex = target->m_displayArrays.back()->m_index.size(); } @@ -473,8 +473,8 @@ bool RAS_MeshSlot::Split(bool force) MT_Matrix4x4 ntransform = m_joinInvTransform.inverse().transposed(); ntransform[0][3]= ntransform[1][3]= ntransform[2][3]= 0.0f; - for(begin(mit); !end(mit); next(mit)) - for(i=mit.startvertex; i<mit.endvertex; i++) + for (begin(mit); !end(mit); next(mit)) + for (i=mit.startvertex; i<mit.endvertex; i++) mit.vertex[i].Transform(m_joinInvTransform, ntransform); if (target->m_DisplayList) { @@ -492,13 +492,13 @@ bool RAS_MeshSlot::Split(bool force) #ifdef USE_SPLIT bool RAS_MeshSlot::IsCulled() { - if(m_joinSlot) + if (m_joinSlot) return true; - if(!m_bCulled) + if (!m_bCulled) return false; list<RAS_MeshSlot*>::iterator it; - for(it=m_joinedSlots.begin(); it!=m_joinedSlots.end(); it++) - if(!(*it)->m_bCulled) + for (it=m_joinedSlots.begin(); it!=m_joinedSlots.end(); it++) + if (!(*it)->m_bCulled) return false; return true; } @@ -563,8 +563,8 @@ void RAS_MaterialBucket::RemoveMesh(RAS_MeshSlot* ms) { list<RAS_MeshSlot>::iterator it; - for(it=m_meshSlots.begin(); it!=m_meshSlots.end(); it++) { - if(&*it == ms) { + for (it=m_meshSlots.begin(); it!=m_meshSlots.end(); it++) { + if (&*it == ms) { m_meshSlots.erase(it); return; } @@ -586,10 +586,10 @@ bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_I { bool uselights; - if(rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && !m_material->CastsShadows()) + if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && !m_material->CastsShadows()) return false; - if(!rasty->SetMaterial(*m_material)) + if (!rasty->SetMaterial(*m_material)) return false; uselights= m_material->UsesLighting(rasty); @@ -609,7 +609,7 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa // KX_ReInstanceShapeFromMesh(ms.m_mesh); // Recompute the physics mesh. (Can't call KX_* from RAS_) } - if(IsZSort() && rasty->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID) + if (IsZSort() && rasty->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID) ms.m_mesh->SortPolygons(ms, cameratrans*MT_Transform(ms.m_OpenGLMatrix)); rendertools->PushMatrix(); @@ -618,8 +618,8 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa rendertools->applyTransform(rasty,ms.m_OpenGLMatrix,m_material->GetDrawingMode()); } - if(rasty->QueryLists()) - if(ms.m_DisplayList) + if (rasty->QueryLists()) + if (ms.m_DisplayList) ms.m_DisplayList->SetModified(ms.m_mesh->MeshModified()); // verify if we can use display list, not for deformed object, and @@ -627,13 +627,13 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa // then it won't have texture coordinates for actual drawing. also // for zsort we can't make a display list, since the polygon order // changes all the time. - if(ms.m_pDeformer && ms.m_pDeformer->IsDynamic()) + if (ms.m_pDeformer && ms.m_pDeformer->IsDynamic()) ms.m_bDisplayList = false; - else if(!ms.m_DisplayList && rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW) + else if (!ms.m_DisplayList && rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW) ms.m_bDisplayList = false; else if (IsZSort()) ms.m_bDisplayList = false; - else if(m_material->UsesObjectColor() && ms.m_bObjectColor) + else if (m_material->UsesObjectColor() && ms.m_bObjectColor) ms.m_bDisplayList = false; else ms.m_bDisplayList = true; @@ -642,14 +642,14 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT) rasty->IndexPrimitives_3DText(ms, m_material, rendertools); // for multitexturing - else if((m_material->GetFlag() & (RAS_MULTITEX|RAS_BLENDERGLSL))) + else if ((m_material->GetFlag() & (RAS_MULTITEX|RAS_BLENDERGLSL))) rasty->IndexPrimitivesMulti(ms); // use normal IndexPrimitives else rasty->IndexPrimitives(ms); - if(rasty->QueryLists()) - if(ms.m_DisplayList) + if (rasty->QueryLists()) + if (ms.m_DisplayList) ms.m_mesh->SetMeshModified(false); rendertools->PopMatrix(); @@ -666,8 +666,8 @@ void RAS_MaterialBucket::Optimize(MT_Scalar distance) list<RAS_MeshSlot>::iterator jt; // greed joining on all following buckets - for(it=m_meshSlots.begin(); it!=m_meshSlots.end(); it++) - for(jt=it, jt++; jt!=m_meshSlots.end(); jt++) + for (it=m_meshSlots.begin(); it!=m_meshSlots.end(); it++) + for (jt=it, jt++; jt!=m_meshSlots.end(); jt++) jt->Join(&*it, distance); #endif } |