Skip to content

Commit

Permalink
UPBGE: Use int instead of short in vertex array index.
Browse files Browse the repository at this point in the history
It fixes some issues about half converted meshes cause of an huge number of vertexes.
  • Loading branch information
panzergame committed Jan 3, 2016
1 parent c4a9a21 commit c896644
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion source/gameengine/Rasterizer/RAS_MaterialBucket.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class RAS_DisplayArray
{
public:
vector<RAS_TexVert> m_vertex;
vector<unsigned short> m_index;
vector<unsigned int> m_index;

enum {BUCKET_MAX_INDEX = 65535};
enum {BUCKET_MAX_VERTEX = 65535};
Expand Down
4 changes: 2 additions & 2 deletions source/gameengine/Rasterizer/RAS_MeshObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct RAS_MeshObject::polygonSlot

/* pnorm is the normal from the plane equation that the distance from is
* used to sort again. */
void get(const RAS_TexVert *vertexarray, const unsigned short *indexarray,
void get(const RAS_TexVert *vertexarray, const unsigned int *indexarray,
int offset, int nvert, const MT_Vector3& pnorm)
{
MT_Vector3 center(0.0f, 0.0f, 0.0f);
Expand All @@ -72,7 +72,7 @@ struct RAS_MeshObject::polygonSlot
m_z = MT_dot(pnorm, center);
}

void set(unsigned short *indexarray, int offset, int nvert)
void set(unsigned int *indexarray, int offset, int nvert)
{
int i;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void RAS_StorageVA::IndexPrimitives(RAS_MeshSlot *ms)
bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME;
RAS_DisplayArray *array = ms->GetDisplayArray();
RAS_TexVert *vertexarray = array->m_vertex.data();
unsigned short *indexarray = array->m_index.data();
unsigned int *indexarray = array->m_index.data();

// colors
if (!wireframe) {
Expand All @@ -120,7 +120,7 @@ void RAS_StorageVA::IndexPrimitives(RAS_MeshSlot *ms)
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);

// here the actual drawing takes places
glDrawElements(GL_TRIANGLES, array->m_index.size(), GL_UNSIGNED_SHORT, indexarray);
glDrawElements(GL_TRIANGLES, array->m_index.size(), GL_UNSIGNED_INT, indexarray);
}

void RAS_StorageVA::TexCoordPtr(const RAS_TexVert *tv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void VBO::UpdateData()
void VBO::UpdateIndices()
{
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_ibo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_data->m_index.size() * sizeof(GLushort),
glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_data->m_index.size() * sizeof(GLuint),
m_data->m_index.data(), GL_STATIC_DRAW);
}

Expand Down Expand Up @@ -182,7 +182,7 @@ void VBO::Unbind(int attrib_num)

void VBO::Draw()
{
glDrawElements(m_mode, m_indices, GL_UNSIGNED_SHORT, 0);
glDrawElements(m_mode, m_indices, GL_UNSIGNED_INT, 0);
}

RAS_StorageVBO::RAS_StorageVBO(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer) :
Expand Down

0 comments on commit c896644

Please sign in to comment.