Skip to content

Commit

Permalink
Fixed (Engine): IWAD flats replaced in PWADs inherit decorations defi…
Browse files Browse the repository at this point in the history
…ned for use with the IWAD originals only.
  • Loading branch information
danij-deng committed Nov 19, 2009
1 parent c268c1f commit e69dcab
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
15 changes: 13 additions & 2 deletions doomsday/engine/portable/src/p_materialmanager.c
Expand Up @@ -491,14 +491,15 @@ Con_Message("P_MaterialCreate: Warning, attempted to create material in "

if(oldMat)
{ // We are updating an existing material.
materialbind_t* mb = &materialBinds[oldMat - 1];
materialbind_t* mb = &materialBinds[oldMat - 1];
uint i;

mat = mb->mat;

// Update the (possibly new) meta data.
mat->flags = flags;
if(tex)
mat->layers[0].tex = tex;
mat->flags = flags;
if(width > 0)
mat->width = width;
if(height > 0)
Expand All @@ -513,6 +514,16 @@ Con_Message("P_MaterialCreate: Warning, attempted to create material in "
mat->envClass = MEC_UNKNOWN;
mat->mnamespace = mnamespace;

// Is this a custom material?
mat->flags &= ~MATF_CUSTOM;
for(i = 0; i < mat->numLayers; ++i)
{
if(!GLTexture_IsFromIWAD(GL_GetGLTexture(mat->layers[i].tex)))
{
mat->flags |= MATF_CUSTOM;
break;
}
}
return mat; // Yep, return it.
}

Expand Down
32 changes: 18 additions & 14 deletions doomsday/engine/portable/src/r_data.c
Expand Up @@ -1665,10 +1665,8 @@ doomtexturedef_t* R_GetDoomTextureDef(int num)
*/
static int R_NewFlat(lumpnum_t lump)
{
int i;
flat_t** newlist, *ptr;
material_t* mat;
const gltexture_t* tex;
int i;
flat_t** newlist, *ptr;

for(i = 0; i < numFlats; ++i)
{
Expand Down Expand Up @@ -1700,26 +1698,20 @@ static int R_NewFlat(lumpnum_t lump)
ptr->width = 64; /// \fixme not all flats are 64 texels in width!
ptr->height = 64; /// \fixme not all flats are 64 texels in height!

tex = GL_CreateGLTexture(W_LumpName(lump), numFlats - 1, GLT_FLAT);

// Create a material for this flat.
// \note that width = 64, height = 64 regardless of the flat dimensions.
mat = P_MaterialCreate(W_LumpName(lump), 64, 64, 0, tex->id, MN_FLATS, NULL);

return numFlats - 1;
}

void R_InitFlats(void)
{
int i;
float starttime = Sys_GetSeconds();
ddstack_t* stack = Stack_New();
int i;
float starttime = Sys_GetSeconds();
ddstack_t* stack = Stack_New();

numFlats = 0;

for(i = 0; i < numLumps; ++i)
{
const char* name = W_LumpName(i);
const char* name = W_LumpName(i);

if(name[0] == 'F')
{
Expand Down Expand Up @@ -1749,6 +1741,18 @@ void R_InitFlats(void)
Stack_Pop(stack);
Stack_Delete(stack);

for(i = 0; i < numFlats; ++i)
{
const flat_t* flat = flats[i];
const gltexture_t* tex;

tex = GL_CreateGLTexture(W_LumpName(flat->lump), i, GLT_FLAT);

// Create a material for this flat.
// \note that width = 64, height = 64 regardless of the flat dimensions.
P_MaterialCreate(W_LumpName(flat->lump), 64, 64, 0, tex->id, MN_FLATS, NULL);
}

VERBOSE(Con_Message("R_InitFlats: Done in %.2f seconds.\n",
Sys_GetSeconds() - starttime));
}
Expand Down

0 comments on commit e69dcab

Please sign in to comment.