BGE: Remove RAS_IRasterizer::IndexPrimitivesMulti()

The work that was being done in IndexPrimitiveMulti() is now done by
IndexPrimitive() and we always assume multitexture support.
This commit is contained in:
Mitchell Stokes 2015-12-06 14:35:14 -08:00
parent a4a5d85755
commit 9d03307033
13 changed files with 43 additions and 179 deletions

@ -267,7 +267,6 @@ public:
* IndexPrimitives: Renders primitives from mesh slot.
*/
virtual void IndexPrimitives(class RAS_MeshSlot &ms) = 0;
virtual void IndexPrimitivesMulti(class RAS_MeshSlot &ms) = 0;
/**
* IndexPrimitives_3DText will render text into the polygons.

@ -649,15 +649,13 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa
else
ms.m_bDisplayList = true;
// for text drawing using faces
if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT)
if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT) {
// for text drawing using faces
rasty->IndexPrimitives_3DText(ms, m_material);
// for multitexturing
else if ((m_material->GetFlag() & (RAS_MULTITEX|RAS_BLENDERGLSL)))
rasty->IndexPrimitivesMulti(ms);
// use normal IndexPrimitives
else
}
else {
rasty->IndexPrimitives(ms);
}
rasty->PopMatrix();
}

@ -44,7 +44,6 @@ public:
virtual void Exit()=0;
virtual void IndexPrimitives(RAS_MeshSlot& ms)=0;
virtual void IndexPrimitivesMulti(RAS_MeshSlot& ms)=0;
virtual void SetDrawingMode(int drawingmode)=0;

@ -243,6 +243,7 @@ void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
if (ms.m_bDisplayList) {
localSlot = FindOrAdd(ms);
localSlot->DrawList();
if (localSlot->End()) {
// save slot here too, needed for replicas and object using same mesh
// => they have the same vertexarray but different mesh slot
@ -250,7 +251,7 @@ void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
return;
}
}
RAS_OpenGLRasterizer::IndexPrimitives(ms);
if (ms.m_bDisplayList) {
@ -259,31 +260,6 @@ void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
}
}
void RAS_ListRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
{
RAS_ListSlot* localSlot =0;
if (ms.m_bDisplayList) {
localSlot = FindOrAdd(ms);
localSlot->DrawList();
if (localSlot->End()) {
// save slot here too, needed for replicas and object using same mesh
// => they have the same vertexarray but different mesh slot
ms.m_DisplayList = localSlot;
return;
}
}
RAS_OpenGLRasterizer::IndexPrimitivesMulti(ms);
if (ms.m_bDisplayList) {
localSlot->EndList();
ms.m_DisplayList = localSlot;
}
}
bool RAS_ListRasterizer::Init(void)
{
return RAS_OpenGLRasterizer::Init();

@ -60,7 +60,6 @@ public:
virtual ~RAS_ListRasterizer();
virtual void IndexPrimitives(class RAS_MeshSlot& ms);
virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms);
virtual bool Init();
virtual void Exit();

@ -740,14 +740,6 @@ void RAS_OpenGLRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
m_storage->IndexPrimitives(ms);
}
void RAS_OpenGLRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
{
if (ms.m_pDerivedMesh)
m_failsafe_storage->IndexPrimitivesMulti(ms);
else
m_storage->IndexPrimitivesMulti(ms);
}
void RAS_OpenGLRasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat)
{
glMatrixMode(GL_PROJECTION);

@ -186,7 +186,6 @@ public:
virtual void SwapBuffers();
virtual void IndexPrimitives(class RAS_MeshSlot &ms);
virtual void IndexPrimitivesMulti(class RAS_MeshSlot &ms);
virtual void IndexPrimitives_3DText(class RAS_MeshSlot &ms, class RAS_IPolyMaterial *polymat);
virtual void SetProjectionMatrix(MT_CmMatrix4x4 &mat);

@ -59,16 +59,6 @@ void RAS_StorageIM::Exit()
{
}
void RAS_StorageIM::IndexPrimitives(RAS_MeshSlot& ms)
{
IndexPrimitivesInternal(ms, false);
}
void RAS_StorageIM::IndexPrimitivesMulti(class RAS_MeshSlot& ms)
{
IndexPrimitivesInternal(ms, true);
}
void RAS_StorageIM::TexCoord(const RAS_TexVert &tv)
{
int unit;
@ -206,15 +196,17 @@ static DMDrawOption CheckTexDM(MTexPoly *mtexpoly, const bool has_mcol, int matn
return DM_DRAW_OPTION_SKIP;
}
void RAS_StorageIM::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
{
void RAS_StorageIM::IndexPrimitives(RAS_MeshSlot& ms)
{
bool obcolor = ms.m_bObjectColor;
bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME;
MT_Vector4& rgba = ms.m_RGBAcolor;
RAS_MeshSlot::iterator it;
if (ms.m_pDerivedMesh) {
// mesh data is in derived mesh,
// mesh data is in derived mesh,
current_bucket = ms.m_bucket;
current_polymat = current_bucket->GetPolyMaterial();
current_ms = &ms;
@ -229,7 +221,7 @@ void RAS_StorageIM::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
this->SetCullFace(false);
if (current_polymat->GetFlag() & RAS_BLENDERGLSL) {
// GetMaterialIndex return the original mface material index,
// GetMaterialIndex return the original mface material index,
// increment by 1 to match what derived mesh is doing
current_blmat_nr = current_polymat->GetMaterialIndex()+1;
// For GLSL we need to retrieve the GPU material attribute
@ -255,7 +247,7 @@ void RAS_StorageIM::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
for (ms.begin(it); !ms.end(it); ms.next(it)) {
RAS_TexVert *vertex;
size_t i, j, numvert;
numvert = it.array->m_type;
if (it.array->m_type == RAS_DisplayArray::LINE) {
@ -294,10 +286,7 @@ void RAS_StorageIM::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
glNormal3fv(vertex->getNormal());
if (multi)
TexCoord(*vertex);
else
glTexCoord2fv(vertex->getUV(0));
TexCoord(*vertex);
}
glVertex3fv(vertex->getXYZ());

@ -41,7 +41,6 @@ public:
virtual void Exit();
virtual void IndexPrimitives(RAS_MeshSlot& ms);
virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms);
virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;};
@ -56,8 +55,6 @@ protected:
void TexCoord(const RAS_TexVert &tv);
void SetCullFace(bool enable);
void IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi);
#ifdef WITH_CXX_GUARDEDALLOC
public:

@ -56,68 +56,7 @@ void RAS_StorageVA::Exit()
{
}
void RAS_StorageVA::IndexPrimitives(RAS_MeshSlot& ms)
{
static const GLsizei stride = sizeof(RAS_TexVert);
bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME;
RAS_MeshSlot::iterator it;
GLenum drawmode;
if (!wireframe)
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
// use glDrawElements to draw each vertexarray
for (ms.begin(it); !ms.end(it); ms.next(it)) {
if (it.totindex == 0)
continue;
// drawing mode
if (it.array->m_type == RAS_DisplayArray::TRIANGLE)
drawmode = GL_TRIANGLES;
else if (it.array->m_type == RAS_DisplayArray::QUAD)
drawmode = GL_QUADS;
else
drawmode = GL_LINES;
// colors
if (drawmode != GL_LINES && !wireframe) {
if (ms.m_bObjectColor) {
const MT_Vector4& rgba = ms.m_RGBAcolor;
glDisableClientState(GL_COLOR_ARRAY);
glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
}
else {
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
glEnableClientState(GL_COLOR_ARRAY);
}
}
else
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
glVertexPointer(3, GL_FLOAT, stride, it.vertex->getXYZ());
glNormalPointer(GL_FLOAT, stride, it.vertex->getNormal());
if (!wireframe) {
glTexCoordPointer(2, GL_FLOAT, stride, it.vertex->getUV(0));
if (glIsEnabled(GL_COLOR_ARRAY))
glColorPointer(4, GL_UNSIGNED_BYTE, stride, it.vertex->getRGBA());
}
// here the actual drawing takes places
glDrawElements(drawmode, it.totindex, GL_UNSIGNED_SHORT, it.index);
}
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
if (!wireframe) {
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
}
}
void RAS_StorageVA::IndexPrimitivesMulti(class RAS_MeshSlot& ms)
void RAS_StorageVA::IndexPrimitives(class RAS_MeshSlot& ms)
{
static const GLsizei stride = sizeof(RAS_TexVert);
bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME, use_color_array = true;

@ -44,7 +44,6 @@ public:
virtual void Exit();
virtual void IndexPrimitives(RAS_MeshSlot& ms);
virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms);
virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;};

@ -80,7 +80,7 @@ void VBO::UpdateIndices()
&data->m_index[0], GL_STATIC_DRAW);
}
void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer, bool multi)
void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer)
{
int unit;
@ -100,41 +100,32 @@ void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num,
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, this->stride, this->color_offset);
if (multi)
for (unit = 0; unit < texco_num; ++unit)
{
for (unit = 0; unit < texco_num; ++unit)
{
glClientActiveTexture(GL_TEXTURE0_ARB + unit);
switch (texco[unit]) {
case RAS_IRasterizer::RAS_TEXCO_ORCO:
case RAS_IRasterizer::RAS_TEXCO_GLOB:
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(3, GL_FLOAT, this->stride, this->vertex_offset);
break;
case RAS_IRasterizer::RAS_TEXCO_UV:
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, this->stride, (void*)((intptr_t)this->uv_offset+(sizeof(GLfloat)*2*unit)));
break;
case RAS_IRasterizer::RAS_TEXCO_NORM:
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(3, GL_FLOAT, this->stride, this->normal_offset);
break;
case RAS_IRasterizer::RAS_TEXTANGENT:
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(4, GL_FLOAT, this->stride, this->tangent_offset);
break;
default:
break;
}
glClientActiveTexture(GL_TEXTURE0_ARB + unit);
switch (texco[unit]) {
case RAS_IRasterizer::RAS_TEXCO_ORCO:
case RAS_IRasterizer::RAS_TEXCO_GLOB:
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(3, GL_FLOAT, this->stride, this->vertex_offset);
break;
case RAS_IRasterizer::RAS_TEXCO_UV:
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, this->stride, (void*)((intptr_t)this->uv_offset+(sizeof(GLfloat)*2*unit)));
break;
case RAS_IRasterizer::RAS_TEXCO_NORM:
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(3, GL_FLOAT, this->stride, this->normal_offset);
break;
case RAS_IRasterizer::RAS_TEXTANGENT:
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(4, GL_FLOAT, this->stride, this->tangent_offset);
break;
default:
break;
}
glClientActiveTextureARB(GL_TEXTURE0_ARB);
}
else //TexFace
{
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, this->stride, this->uv_offset);
}
glClientActiveTextureARB(GL_TEXTURE0_ARB);
if (GLEW_ARB_vertex_program)
{
@ -163,7 +154,7 @@ void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num,
}
}
}
glDrawElements(this->mode, this->indices, GL_UNSIGNED_SHORT, 0);
glDisableClientState(GL_VERTEX_ARRAY);
@ -206,16 +197,6 @@ void RAS_StorageVBO::Exit()
}
void RAS_StorageVBO::IndexPrimitives(RAS_MeshSlot& ms)
{
IndexPrimitivesInternal(ms, false);
}
void RAS_StorageVBO::IndexPrimitivesMulti(RAS_MeshSlot& ms)
{
IndexPrimitivesInternal(ms, true);
}
void RAS_StorageVBO::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
{
RAS_MeshSlot::iterator it;
VBO *vbo;
@ -233,6 +214,6 @@ void RAS_StorageVBO::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
vbo->UpdateData();
}
vbo->Draw(*m_texco_num, m_texco, *m_attrib_num, m_attrib, m_attrib_layer, multi);
vbo->Draw(*m_texco_num, m_texco, *m_attrib_num, m_attrib, m_attrib_layer);
}
}

@ -42,7 +42,7 @@ public:
VBO(RAS_DisplayArray *data, unsigned int indices);
~VBO();
void Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer, bool multi);
void Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer);
void UpdateData();
void UpdateIndices();
@ -73,7 +73,6 @@ public:
virtual void Exit();
virtual void IndexPrimitives(RAS_MeshSlot& ms);
virtual void IndexPrimitivesMulti(RAS_MeshSlot& ms);
virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;};
@ -89,8 +88,6 @@ protected:
std::map<RAS_DisplayArray*, class VBO*> m_vbo_lookup;
virtual void IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi);
#ifdef WITH_CXX_GUARDEDALLOC
public:
void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_StorageVA"); }