Skip to content

Commit

Permalink
World|Line|Sector: Relocated missing material fixing to Line::Side
Browse files Browse the repository at this point in the history
When a missing material fix is applied, automatically mark reverb
data for the adjoining sector cluster dirty.

Also applied the fluent interface pattern to Surface as typically
one configures several properties at once.
  • Loading branch information
danij-deng committed Sep 17, 2013
1 parent f70697c commit a1c3438
Show file tree
Hide file tree
Showing 10 changed files with 306 additions and 274 deletions.
10 changes: 10 additions & 0 deletions doomsday/client/include/world/line.h
Expand Up @@ -534,6 +534,16 @@ class Line : public de::MapElement
*/
void setShadowVisCount(int newCount);

#ifdef __CLIENT__

/**
* Do as in the original DOOM if the texture has not been defined -
* extend the floor/ceiling to fill the space (unless it is skymasked).
*/
void fixMissingMaterials();

#endif // __CLIENT__

protected:
int property(DmuArgs &args) const;
int setProperty(DmuArgs const &args);
Expand Down
10 changes: 0 additions & 10 deletions doomsday/client/include/world/sector.h
Expand Up @@ -453,11 +453,6 @@ class Sector : public de::MapElement
*/
void setLightColor(de::Vector3f const &newLightColor);

/// @copydoc setLightColor()
inline void setLightColor(float red, float green, float blue) {
setLightColor(de::Vector3f(red, green, blue));
}

/**
* Change the strength of the specified @a component of the ambient light
* color in the sector. The LightColorChange audience is notified whenever
Expand Down Expand Up @@ -559,11 +554,6 @@ class Sector : public de::MapElement
*/
LightGridData &lightGridData();

/**
* Perform missing material fixes again for all line sides in the sector.
*/
void fixMissingMaterialsForSides();

#endif // __CLIENT__

protected:
Expand Down
38 changes: 24 additions & 14 deletions doomsday/client/include/world/surface.h
Expand Up @@ -131,7 +131,7 @@ class Surface : public de::MapElement
*
* @param newNormal New normal vector (will be normalized if needed).
*/
void setNormal(de::Vector3f const &newNormal);
Surface &setNormal(de::Vector3f const &newNormal);

/**
* Returns a copy of the current @ref surfaceFlags of the surface.
Expand All @@ -144,7 +144,7 @@ class Surface : public de::MapElement
* @param flagsToChange Flags to change the value of.
* @param operation Logical operation to perform on the flags.
*/
void setFlags(int flagsToChange, de::FlagOp operation = de::SetFlags);
Surface &setFlags(int flagsToChange, de::FlagOp operation = de::SetFlags);

/**
* Returns @c true iff the surface is flagged @a flagsToTest.
Expand Down Expand Up @@ -200,7 +200,7 @@ class Surface : public de::MapElement
* @param newMaterial New material to apply. Use @c 0 to clear.
* @param isMissingFix @c true= this is a fix for a "missing" material.
*/
bool setMaterial(Material *newMaterial, bool isMissingFix = false);
Surface &setMaterial(Material *newMaterial, bool isMissingFix = false);

/**
* Returns the material origin offset of the surface.
Expand All @@ -212,7 +212,7 @@ class Surface : public de::MapElement
*
* @param newOrigin New origin offset in map coordinate space units.
*/
void setMaterialOrigin(de::Vector2f const &newOrigin);
Surface &setMaterialOrigin(de::Vector2f const &newOrigin);

/**
* Change the specified @a component of the material origin for the surface.
Expand All @@ -224,7 +224,7 @@ class Surface : public de::MapElement
*
* @see setMaterialorigin(), setMaterialOriginX(), setMaterialOriginY()
*/
void setMaterialOriginComponent(int component, float newPosition);
Surface &setMaterialOriginComponent(int component, float newPosition);

/**
* Change the position of the X axis component of the material origin for the
Expand All @@ -235,7 +235,9 @@ class Surface : public de::MapElement
*
* @see setMaterialOriginComponent(), setMaterialOriginY()
*/
inline void setMaterialOriginX(float newPosition) { setMaterialOriginComponent(0, newPosition); }
inline Surface &setMaterialOriginX(float newPosition) {
return setMaterialOriginComponent(0, newPosition);
}

/**
* Change the position of the Y axis component of the material origin for the
Expand All @@ -246,7 +248,9 @@ class Surface : public de::MapElement
*
* @see setMaterialOriginComponent(), setMaterialOriginX()
*/
inline void setMaterialOriginY(float newPosition) { setMaterialOriginComponent(1, newPosition); }
inline Surface &setMaterialOriginY(float newPosition) {
return setMaterialOriginComponent(1, newPosition);
}

/**
* Compose a URI for the surface's material. If no material is bound then a
Expand All @@ -272,7 +276,7 @@ class Surface : public de::MapElement
*
* @see opacity()
*/
void setOpacity(float newOpacity);
Surface &setOpacity(float newOpacity);

/**
* Returns the tint color of the surface. The TintColorChange audience is notified
Expand Down Expand Up @@ -324,7 +328,7 @@ class Surface : public de::MapElement
*
* @see tintColor(), setTintColorComponent(), setTintRed(), setTintGreen(), setTintBlue()
*/
void setTintColor(de::Vector3f const &newTintColor);
Surface &setTintColor(de::Vector3f const &newTintColor);

/**
* Change the strength of the specified @a component of the tint color for the
Expand All @@ -335,7 +339,7 @@ class Surface : public de::MapElement
*
* @see setTintColor(), setTintRed(), setTintGreen(), setTintBlue()
*/
void setTintColorComponent(int component, float newStrength);
Surface &setTintColorComponent(int component, float newStrength);

/**
* Change the strength of the red component of the tint color for the surface.
Expand All @@ -345,7 +349,9 @@ class Surface : public de::MapElement
*
* @see setTintColorComponent(), setTintGreen(), setTintBlue()
*/
inline void setTintRed(float newStrength) { setTintColorComponent(0, newStrength); }
inline Surface &setTintRed(float newStrength) {
return setTintColorComponent(0, newStrength);
}

/**
* Change the strength of the green component of the tint color for the surface.
Expand All @@ -355,7 +361,9 @@ class Surface : public de::MapElement
*
* @see setTintColorComponent(), setTintRed(), setTintBlue()
*/
inline void setTintGreen(float newStrength) { setTintColorComponent(1, newStrength); }
inline Surface &setTintGreen(float newStrength) {
return setTintColorComponent(1, newStrength);
}

/**
* Change the strength of the blue component of the tint color for the surface.
Expand All @@ -365,7 +373,9 @@ class Surface : public de::MapElement
*
* @see setTintColorComponent(), setTintRed(), setTintGreen()
*/
inline void setTintBlue(float newStrength) { setTintColorComponent(2, newStrength); }
inline Surface &setTintBlue(float newStrength) {
return setTintColorComponent(2, newStrength);
}

/**
* Returns the blendmode for the surface.
Expand All @@ -377,7 +387,7 @@ class Surface : public de::MapElement
*
* @param newBlendMode New blendmode.
*/
void setBlendMode(blendmode_t newBlendMode);
Surface &setBlendMode(blendmode_t newBlendMode);

#ifdef __CLIENT__

Expand Down
7 changes: 2 additions & 5 deletions doomsday/client/src/dd_main.cpp
Expand Up @@ -3001,12 +3001,9 @@ DENG_EXTERN_C void R_SetupMap(int mode, int flags)
// Update all sectors.
/// @todo Refactor away.
foreach(Sector *sector, map.sectors())
foreach(LineSide *side, sector->sides())
{
sector->fixMissingMaterialsForSides();
foreach(SectorCluster *cluster, sector->clusters())
{
cluster->markReverbDirty();
}
side->fixMissingMaterials();
}
#endif

Expand Down
34 changes: 19 additions & 15 deletions doomsday/client/src/world/api_mapedit.cpp
Expand Up @@ -313,18 +313,21 @@ void MPE_LineAddSide(int lineIdx, int sideId, short flags, ddstring_t const *top
side.addSections();

// Assign the resolved material if found.
side.top().setMaterial(findMaterialInDict(topMaterialUri));
side.top().setMaterialOrigin(Vector2f(topOffsetX, topOffsetY));
side.top().setTintColor(Vector3f(topRed, topGreen, topBlue));

side.middle().setMaterial(findMaterialInDict(middleMaterialUri));
side.middle().setMaterialOrigin(Vector2f(middleOffsetX, middleOffsetY));
side.middle().setTintColor(Vector3f(middleRed, middleGreen, middleBlue));
side.middle().setOpacity(middleOpacity);

side.bottom().setMaterial(findMaterialInDict(bottomMaterialUri));
side.bottom().setMaterialOrigin(Vector2f(bottomOffsetX, bottomOffsetY));
side.bottom().setTintColor(Vector3f(bottomRed, bottomGreen, bottomBlue));
side.top()
.setMaterial(findMaterialInDict(topMaterialUri))
.setMaterialOrigin(Vector2f(topOffsetX, topOffsetY))
.setTintColor(Vector3f(topRed, topGreen, topBlue));

side.middle()
.setMaterial(findMaterialInDict(middleMaterialUri))
.setMaterialOrigin(Vector2f(middleOffsetX, middleOffsetY))
.setTintColor(Vector3f(middleRed, middleGreen, middleBlue))
.setOpacity(middleOpacity);

side.bottom()
.setMaterial(findMaterialInDict(bottomMaterialUri))
.setMaterialOrigin(Vector2f(bottomOffsetX, bottomOffsetY))
.setTintColor(Vector3f(bottomRed, bottomGreen, bottomBlue));
}

#undef MPE_PlaneCreate
Expand All @@ -341,9 +344,10 @@ int MPE_PlaneCreate(int sectorIdx, coord_t height, ddstring_t const *materialUri

plane->setIndexInArchive(archiveIndex);

plane->surface().setMaterial(findMaterialInDict(materialUri));
plane->surface().setTintColor(Vector3f(tintRed, tintGreen, tintBlue));
plane->surface().setMaterialOrigin(Vector2f(matOffsetX, matOffsetY));
plane->surface()
.setMaterial(findMaterialInDict(materialUri))
.setTintColor(Vector3f(tintRed, tintGreen, tintBlue))
.setMaterialOrigin(Vector2f(matOffsetX, matOffsetY));

if(!plane->isSectorFloor() && !plane->isSectorCeiling())
{
Expand Down

0 comments on commit a1c3438

Please sign in to comment.