Skip to content

Commit

Permalink
Refactor|Materials: Create material system subspace schemes outside t…
Browse files Browse the repository at this point in the history
…his class

New subspaces can now be created dynamically, so there is no need
to do so from within de::Materials.

Also removed 'Diffuse' from Rend_MapSurfaceDiffuseMaterialSpec()
(erroneous clarification).
  • Loading branch information
danij-deng committed Jan 6, 2013
1 parent 20d1f3b commit 56bf76d
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/include/render/rend_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ uint Rend_NumFanVerticesForBspLeaf(BspLeaf *bspLeaf);
void R_DrawLightRange(void);

#ifdef __cplusplus
de::MaterialVariantSpec const &Rend_MapSurfaceDiffuseMaterialSpec();
de::MaterialVariantSpec const &Rend_MapSurfaceMaterialSpec();

} // extern "C"
#endif
Expand Down
6 changes: 3 additions & 3 deletions doomsday/engine/src/map/r_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ boolean R_MiddleMaterialCoversOpening(int lineFlags, Sector *frontSec, Sector *b

// Ensure we have up to date info about the material.
MaterialSnapshot const &ms =
App_Materials()->prepare(*material, Rend_MapSurfaceDiffuseMaterialSpec(), true);
App_Materials()->prepare(*material, Rend_MapSurfaceMaterialSpec(), true);

if(ignoreOpacity || (ms.isOpaque() && !frontDef->SW_middleblendmode && frontDef->SW_middlergba[3] >= 1))
{
Expand Down Expand Up @@ -1464,7 +1464,7 @@ boolean R_IsGlowingPlane(Plane const *pln)
if(mat)
{
MaterialSnapshot const &ms =
App_Materials()->prepare(*mat, Rend_MapSurfaceDiffuseMaterialSpec(), true);
App_Materials()->prepare(*mat, Rend_MapSurfaceMaterialSpec(), true);

if(!Material_IsDrawable(mat) || ms.glowStrength() > 0) return true;
}
Expand All @@ -1485,7 +1485,7 @@ float R_GlowStrength(Plane const *pln)
{
/// @todo We should not need to prepare to determine this.
MaterialSnapshot const &ms =
App_Materials()->prepare(*mat, Rend_MapSurfaceDiffuseMaterialSpec(), true);
App_Materials()->prepare(*mat, Rend_MapSurfaceMaterialSpec(), true);

return ms.glowStrength();
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/src/render/lumobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ static boolean createGlowLightForSurface(Surface *suf, void * /*parameters*/)

// Are we glowing at this moment in time?
MaterialSnapshot const &ms =
App_Materials()->prepare(*suf->material, Rend_MapSurfaceDiffuseMaterialSpec(), true);
App_Materials()->prepare(*suf->material, Rend_MapSurfaceMaterialSpec(), true);
if(!(ms.glowStrength() > .001f)) return true; // Continue iteration.

averagecolor_analysis_t const *avgColorAmplified = (averagecolor_analysis_t const *) ms.texture(MTU_PRIMARY).generalCase().analysisDataPointer(TA_COLOR_AMPLIFIED);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/src/render/r_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ void Rend_CacheForMap()

if(precacheMapMaterials)
{
MaterialVariantSpec const &spec = Rend_MapSurfaceDiffuseMaterialSpec();
MaterialVariantSpec const &spec = Rend_MapSurfaceMaterialSpec();

for(uint i = 0; i < NUM_SIDEDEFS; ++i)
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/src/render/rend_decor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ static void updateSurfaceDecorations2(Surface *suf, float offsetS, float offsetT
delta[VY] * delta[VZ] != 0))
{
// Ensure we've prepared a variant of this material.
App_Materials()->prepare(*suf->material, Rend_MapSurfaceDiffuseMaterialSpec(),
App_Materials()->prepare(*suf->material, Rend_MapSurfaceMaterialSpec(),
true /*smooth*/, true /*do-create*/);

ded_decor_t const *def = App_Materials()->decorationDef(*suf->material);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/src/render/rend_fakeradio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ static void processEdgeShadow(BspLeaf const *bspLeaf, LineDef const *lineDef,
if((suf->inFlags & SUIF_NO_RADIO) || !suf->material || Surface_IsSkyMasked(suf)) return;

MaterialSnapshot const &ms =
App_Materials()->prepare(*pln->PS_material, Rend_MapSurfaceDiffuseMaterialSpec(), true);
App_Materials()->prepare(*pln->PS_material, Rend_MapSurfaceMaterialSpec(), true);
if(ms.glowStrength() > 0) return;

// Determine the openness of the lineDef. If this edge is edgeOpen,
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/src/render/rend_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1506,7 +1506,7 @@ static void renderPlane(BspLeaf* bspLeaf, planetype_t type, coord_t height,
material_t *mat = suf->material? suf->material : App_Materials()->find(de::Uri(Path("System:missing"))).material();

MaterialSnapshot const &ms =
App_Materials()->prepare(*mat, Rend_MapSurfaceDiffuseMaterialSpec(), true);
App_Materials()->prepare(*mat, Rend_MapSurfaceMaterialSpec(), true);
params.glowing = ms.glowStrength();
}

Expand Down Expand Up @@ -4027,7 +4027,7 @@ static void Rend_RenderBoundingBoxes()

#endif // __CLIENT__

MaterialVariantSpec const &Rend_MapSurfaceDiffuseMaterialSpec()
MaterialVariantSpec const &Rend_MapSurfaceMaterialSpec()
{
return App_Materials()->variantSpecForContext(MC_MAPSURFACE, 0, 0, 0, 0, GL_REPEAT, GL_REPEAT,
-1, -1, -1, true, true, false, false);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/src/resource/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ boolean Material_HasGlow(material_t *mat)

/// @todo We should not need to prepare to determine this.
MaterialSnapshot const &ms =
App_Materials()->prepare(*mat, Rend_MapSurfaceDiffuseMaterialSpec(), true);
App_Materials()->prepare(*mat, Rend_MapSurfaceMaterialSpec(), true);

return (ms.glowStrength() > .0001f);
}
Expand Down
14 changes: 7 additions & 7 deletions doomsday/engine/src/resource/materials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,6 @@ Materials::Materials()
{
LOG_VERBOSE("Initializing Materials collection...");
d = new Instance();

createScheme("System");
createScheme("Flats");
createScheme("Textures");
createScheme("Sprites");
}

Materials::~Materials()
Expand Down Expand Up @@ -729,7 +724,7 @@ ded_decor_t const *Materials::decorationDef(material_t &mat)
{
if(!Material_Prepared(&mat))
{
prepare(mat, Rend_MapSurfaceDiffuseMaterialSpec(), false);
prepare(mat, Rend_MapSurfaceMaterialSpec(), false);
}
return d->materialBindForId(Material_PrimaryBind(&mat))->decorationDef();
}
Expand All @@ -739,7 +734,7 @@ ded_ptcgen_t const *Materials::ptcGenDef(material_t &mat)
if(isDedicated) return 0;
if(!Material_Prepared(&mat))
{
prepare(mat, Rend_MapSurfaceDiffuseMaterialSpec(), false);
prepare(mat, Rend_MapSurfaceMaterialSpec(), false);
}
return d->materialBindForId(Material_PrimaryBind(&mat))->ptcGenDef();
}
Expand Down Expand Up @@ -1291,6 +1286,11 @@ void Materials_Init()
{
DENG_ASSERT(!materials);
materials = new de::Materials();

materials->createScheme("System");
materials->createScheme("Flats");
materials->createScheme("Textures");
materials->createScheme("Sprites");
}

void Materials_Shutdown()
Expand Down

0 comments on commit 56bf76d

Please sign in to comment.