Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-05-21 12:55:12 +0400
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-05-21 12:55:12 +0400
commite78ef29a593857d87b0c35c211d082c8caa80f7b (patch)
treef116204149c3e29cd57b7b2d2bfd629d61dbe479 /source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
parent2a622e35d4f96a805ab0de22f34d6ae3661a0a53 (diff)
Depth sorting for alpha mesh objects.
- Mesh Objects are sorted by depth (based on object centre.) Using object centre means the user has control over the sort. - Polygons are not sorted. - Polygons are not split. - O(nlog(n))
Diffstat (limited to 'source/gameengine/Rasterizer/RAS_MaterialBucket.cpp')
-rw-r--r--source/gameengine/Rasterizer/RAS_MaterialBucket.cpp167
1 files changed, 95 insertions, 72 deletions
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
index 5f1766be0e4..faaeafb0d05 100644
--- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
+++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
@@ -154,28 +154,28 @@ void RAS_MaterialBucket::EndFrame()
{
}
+unsigned int RAS_MaterialBucket::NumMeshSlots()
+{
+ return m_meshSlots.size();
+}
+RAS_MaterialBucket::T_MeshSlotList::iterator RAS_MaterialBucket::msBegin()
+{
+ return m_meshSlots.begin();
+}
-void RAS_MaterialBucket::Render(const MT_Transform& cameratrans,
- RAS_IRasterizer* rasty,
- RAS_IRenderTools* rendertools)
+RAS_MaterialBucket::T_MeshSlotList::iterator RAS_MaterialBucket::msEnd()
{
+ return m_meshSlots.end();
+}
- if (m_meshSlots.begin()== m_meshSlots.end())
- return;
-
+int RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty,
+ RAS_IRenderTools *rendertools)
+{
rendertools->SetViewMat(cameratrans);
rasty->SetMaterial(*m_material);
- if (m_meshSlots.size() >0)
- {
-
- rendertools->SetClientObject((*m_meshSlots.begin()).m_clientObj);
- }
-
- //printf("RAS_MatBucket::Render: %d m_meshSlots\n", m_meshSlots.size());
-
bool dolights = m_material->GetDrawingMode()&16;
if ((rasty->GetDrawingMode() <= RAS_IRasterizer::KX_SOLID) || !dolights)
@@ -187,68 +187,91 @@ void RAS_MaterialBucket::Render(const MT_Transform& cameratrans,
bool bUseLights = rendertools->ProcessLighting(m_material->GetLightLayer());
}
- int drawmode = (rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID ?
+ return (rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID ?
1: (m_material->UsesTriangles() ? 0 : 2));
+}
+
+void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty,
+ RAS_IRenderTools* rendertools, const KX_MeshSlot &ms, int drawmode)
+{
+ if (!ms.m_bVisible)
+ return;
+
+ rendertools->SetClientObject(ms.m_clientObj);
+
+ /* __NLA Do the deformation */
+ if (ms.m_pDeformer)
+ ms.m_pDeformer->Apply(m_material);
+ /* End __NLA */
+
+ rendertools->PushMatrix();
+ rendertools->applyTransform(rasty,ms.m_OpenGLMatrix,m_material->GetDrawingMode());
+
+ // Use the text-specific IndexPrimitives for text faces
+ if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT)
+ {
+ rasty->IndexPrimitives_3DText(
+ ms.m_mesh->GetVertexCache(m_material),
+ ms.m_mesh->GetIndexCache(m_material),
+ drawmode,
+ m_material,
+ rendertools, // needed for textprinting on polys
+ ms.m_bObjectColor,
+ ms.m_RGBAcolor);
+
+ }
+ // Use the (slower) IndexPrimitives_Ex which can recalc face normals & such
+ // for deformed objects - eventually should be extended to recalc ALL normals
+ else if (ms.m_pDeformer){
+ rasty->IndexPrimitives_Ex(
+ ms.m_mesh->GetVertexCache(m_material),
+ ms.m_mesh->GetIndexCache(m_material),
+ drawmode,
+ m_material,
+ rendertools, // needed for textprinting on polys
+ ms.m_bObjectColor,
+ ms.m_RGBAcolor
+ );
+ }
+ // Use the normal IndexPrimitives
+ else
+ {
+ rasty->IndexPrimitives(
+ ms.m_mesh->GetVertexCache(m_material),
+ ms.m_mesh->GetIndexCache(m_material),
+ drawmode,
+ m_material,
+ rendertools, // needed for textprinting on polys
+ ms.m_bObjectColor,
+ ms.m_RGBAcolor
+ );
+ }
+
+ rendertools->PopMatrix();
+}
+
+void RAS_MaterialBucket::Render(const MT_Transform& cameratrans,
+ RAS_IRasterizer* rasty,
+ RAS_IRenderTools* rendertools)
+{
+ if (m_meshSlots.begin()== m_meshSlots.end())
+ return;
+
+ rendertools->SetViewMat(cameratrans);
+
+ rasty->SetMaterial(*m_material);
+
+ if (m_meshSlots.size() >0)
+ {
+ rendertools->SetClientObject((*m_meshSlots.begin()).m_clientObj);
+ }
+
+ int drawmode = ActivateMaterial(cameratrans, rasty, rendertools);
for (T_MeshSlotList::const_iterator it = m_meshSlots.begin();
- ! (it == m_meshSlots.end());it++)
+ ! (it == m_meshSlots.end()); ++it)
{
- //printf("RAS_MatBucket::Render: (%p) %s MeshSlot %s\n", this, it->m_mesh->m_class?"Skin":"Mesh", (const char *)(*it).m_mesh->GetName());
- if ((*it).m_bVisible)
- {
- rendertools->SetClientObject((*it).m_clientObj);
-
- /* __NLA Do the deformation */
- if ((*it).m_pDeformer)
- (*it).m_pDeformer->Apply(m_material);
- /* End __NLA */
-
- rendertools->PushMatrix();
- rendertools->applyTransform(rasty,(*it).m_OpenGLMatrix,m_material->GetDrawingMode());
-
- // Use the text-specific IndexPrimitives for text faces
- if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT)
- {
- rasty->IndexPrimitives_3DText(
- (*it).m_mesh->GetVertexCache(m_material),
- (*it).m_mesh->GetIndexCache(m_material),
- drawmode,
- m_material,
- rendertools, // needed for textprinting on polys
- (*it).m_bObjectColor,
- (*it).m_RGBAcolor);
-
- }
- // Use the (slower) IndexPrimitives_Ex which can recalc face normals & such
- // for deformed objects - eventually should be extended to recalc ALL normals
- else if ((*it).m_pDeformer){
- rasty->IndexPrimitives_Ex(
- (*it).m_mesh->GetVertexCache(m_material),
- (*it).m_mesh->GetIndexCache(m_material),
- drawmode,
- m_material,
- rendertools, // needed for textprinting on polys
- (*it).m_bObjectColor,
- (*it).m_RGBAcolor
- );
- }
- // Use the normal IndexPrimitives
- else
- {
- rasty->IndexPrimitives(
- (*it).m_mesh->GetVertexCache(m_material),
- (*it).m_mesh->GetIndexCache(m_material),
- drawmode,
- m_material,
- rendertools, // needed for textprinting on polys
- (*it).m_bObjectColor,
- (*it).m_RGBAcolor
- );
- }
-
- rendertools->PopMatrix();
- }
- //printf("gets here\n");
+ RenderMeshSlot(cameratrans, rasty, rendertools, *it, drawmode);
}
}