Added a clear() method to VBORef and removed unsafe memset() clear.

This commit is contained in:
Bart Trzynadlowski 2012-02-25 06:36:04 +00:00
parent 3b41239cfb
commit 69610ef8dd
2 changed files with 20 additions and 2 deletions

View file

@ -631,8 +631,7 @@ struct VBORef *CRender3D::BeginModel(ModelCache *Cache)
Cache->curVertIdx[i] = 0; Cache->curVertIdx[i] = 0;
// Clear the VBO reference to 0 and clear texture references // Clear the VBO reference to 0 and clear texture references
memset(Model, 0, sizeof(VBORef) - sizeof(CTextureRefs)); Model->Clear();
Model->texRefs.Clear();
// Record starting index of first opaque polygon in VBO (alpha poly index will be re-set in EndModel()) // Record starting index of first opaque polygon in VBO (alpha poly index will be re-set in EndModel())
Model->index[POLY_STATE_NORMAL] = Cache->vboCurOffset/(VBO_VERTEX_SIZE*sizeof(GLfloat)); Model->index[POLY_STATE_NORMAL] = Cache->vboCurOffset/(VBO_VERTEX_SIZE*sizeof(GLfloat));

View file

@ -78,6 +78,25 @@ struct VBORef
UINT16 texOffset; // texture offset data for this model UINT16 texOffset; // texture offset data for this model
CTextureRefs texRefs; // unique texture references contained in this model CTextureRefs texRefs; // unique texture references contained in this model
/*
* Clear():
*
* Clears the VBORef by setting all fields to 0 and clearing the texture
* references.
*/
inline void Clear(void)
{
texRefs.Clear();
lutIdx = 0;
texOffset = 0;
nextTexOffset = NULL;
for (int i = 0; i < 2; i++)
{
index[i] = 0;
numVerts[i] = 0;
}
}
}; };
// Display list items: model instances and viewport settings // Display list items: model instances and viewport settings