Skip to content

Commit

Permalink
Server: Remove various material/texture logics needed only by the client
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Feb 19, 2013
1 parent 6a8d89c commit c26890d
Show file tree
Hide file tree
Showing 17 changed files with 148 additions and 246 deletions.
4 changes: 4 additions & 0 deletions doomsday/client/include/map/r_world.h
Expand Up @@ -132,6 +132,7 @@ coord_t R_OpenRange(Sector const* frontSec, Sector const* backSec, coord_t* retB
/// height coordinates rather than the "sharp" coordinates.
coord_t R_VisOpenRange(Sector const* frontSec, Sector const* backSec, coord_t* retBottom, coord_t* retTop);

#ifdef __CLIENT__
/**
* @param lineFlags @ref ldefFlags.
* @param frontSec Sector in front of the wall.
Expand All @@ -154,6 +155,7 @@ boolean R_MiddleMaterialCoversOpening(int lineFlags, Sector* frontSec, Sector* b
* hedges instead).
*/
boolean R_MiddleMaterialCoversLineOpening(LineDef* line, int side, boolean ignoreOpacity);
#endif // __CLIENT__

Plane* R_NewPlaneForSector(Sector* sec);
void R_DestroyPlaneOfSector(uint id, Sector* sec);
Expand Down Expand Up @@ -189,6 +191,7 @@ float R_GlowStrength(const Plane* pln);

lineowner_t* R_GetVtxLineOwner(const Vertex* vtx, const LineDef* line);

#ifdef __CLIENT__
/**
* A neighbour is a line that shares a vertex with 'line', and faces the
* specified sector.
Expand All @@ -214,6 +217,7 @@ LineDef* R_FindLineAlignNeighbor(const Sector* sec, const LineDef* line,
*/
LineDef* R_FindLineBackNeighbor(const Sector* sector, const LineDef* line,
const lineowner_t* own, boolean antiClockwise, binangle_t* diff);
#endif // __CLIENT__

/**
* @defgroup skyCapFlags Sky Cap Flags
Expand Down
5 changes: 4 additions & 1 deletion doomsday/client/include/render/rend_main.h
Expand Up @@ -104,7 +104,10 @@ void R_DrawLightRange(void);
#ifdef __cplusplus
} // extern "C"

#ifdef __CLIENT__
de::MaterialVariantSpec const &Rend_MapSurfaceMaterialSpec();
#endif

#endif /* LIBDENG_REND_MAIN_H */
#endif // __cplusplus

#endif // LIBDENG_REND_MAIN_H
2 changes: 2 additions & 0 deletions doomsday/client/include/resource/materials.h
Expand Up @@ -337,6 +337,7 @@ class Materials
/// Empty the Material cache queue, cancelling all outstanding tasks.
void purgeCacheQueue();

#ifdef __CLIENT__
/**
* Prepare a material variant specification in accordance to the specified
* usage context. If incomplete context information is supplied, suitable
Expand All @@ -363,6 +364,7 @@ class Materials
int flags, byte border, int tClass, int tMap, int wrapS, int wrapT,
int minFilter, int magFilter, int anisoFilter,
bool mipmapped, bool gammaCorrection, bool noStretch, bool toAlpha);
#endif

private:
struct Instance;
Expand Down
16 changes: 15 additions & 1 deletion doomsday/client/include/resource/texture.h
Expand Up @@ -150,11 +150,13 @@ class Texture
/// Returns @c true if the variant is flagged as "masked".
inline bool isMasked() const { return flags().testFlag(Masked); }

#ifdef __CLIENT__
/// Returns @c true if the variant is flagged as "uploaded".
inline bool isUploaded() const { return flags().testFlag(Uploaded); }

/// Returns @c true if the variant is "prepared".
inline bool isPrepared() const { return isUploaded() && glName() != 0; }
#endif

/**
* Returns the flags for the variant.
Expand All @@ -169,9 +171,21 @@ class Texture
*/
void setFlags(Flags flagsToChange, bool set = true);

#ifdef __CLIENT__
/**
* Returns the GL-name of the uploaded texture content for the variant;
* otherwise @c 0 (not uploaded).
*/
uint glName() const;

void setGLName(uint glName);
/**
* Change the GL-name of the uploaded texture content associated with
* the variant.
*
* @param newGLName New GL-name. Can be @c 0.
*/
void setGLName(uint newGLName);
#endif

friend class Texture;
friend struct Texture::Instance;
Expand Down
19 changes: 12 additions & 7 deletions doomsday/client/src/dd_main.cpp
Expand Up @@ -575,15 +575,20 @@ void DD_ClearRuntimeTextureSchemes()
textures.scheme("Lightmaps").clear();
textures.scheme("Flaremaps").clear();

#ifdef __CLIENT__
GL_PruneTextureVariantSpecifications();
#endif
}

void DD_ClearSystemTextureSchemes()
{
Textures &textures = App_Textures();

textures.scheme("System").clear();

#ifdef __CLIENT__
GL_PruneTextureVariantSpecifications();
#endif
}

Materials &App_Materials()
Expand Down Expand Up @@ -2377,6 +2382,7 @@ ddvalue_t ddValues[DD_LAST_VALUE - DD_FIRST_VALUE - 1] = {
/**
* Get a 32-bit signed integer value.
*/
#undef DD_GetInteger
int DD_GetInteger(int ddvalue)
{
switch(ddvalue)
Expand All @@ -2393,26 +2399,24 @@ int DD_GetInteger(int ddvalue)

case DD_CURRENT_CLIENT_FINALE_ID:
return Cl_CurrentFinale();
#endif

case DD_DYNLIGHT_TEXTURE:
return (int) GL_PrepareLSTexture(LST_DYNAMIC);
#endif

case DD_NUMLUMPS:
return F_LumpCount();

case DD_MAP_MUSIC: {
GameMap* map = theMap;
if(map)
if(GameMap *map = theMap)
{
ded_mapinfo_t* mapInfo = Def_GetMapInfo(GameMap_Uri(map));
if(mapInfo)
if(ded_mapinfo_t *mapInfo = Def_GetMapInfo(GameMap_Uri(map)))
{
return Def_GetMusicNum(mapInfo->music);
}
}
return -1;
}
return -1; }

default: break;
}

Expand All @@ -2426,6 +2430,7 @@ int DD_GetInteger(int ddvalue)
/**
* Set a 32-bit signed integer value.
*/
#undef DD_SetInteger
void DD_SetInteger(int ddvalue, int parm)
{
if(ddvalue <= DD_FIRST_VALUE || ddvalue >= DD_LAST_VALUE)
Expand Down
32 changes: 17 additions & 15 deletions doomsday/client/src/map/linedef.cpp
Expand Up @@ -32,6 +32,7 @@
#include <de/mathutil.h>
#include <de/binangle.h>

#ifdef __CLIENT__
static void calcNormal(const LineDef* l, byte side, pvec2f_t normal)
{
V2f_Set(normal, (l->L_vorigin(side^1)[VY] - l->L_vorigin(side) [VY]) / l->length,
Expand Down Expand Up @@ -74,16 +75,17 @@ static boolean backClosedForBlendNeighbor(LineDef* lineDef, int side, boolean ig
return R_MiddleMaterialCoversLineOpening(lineDef, side, ignoreOpacity);
}

static LineDef* findBlendNeighbor(LineDef* l, byte side, byte right,
binangle_t* diff)
static LineDef *findBlendNeighbor(LineDef *l, byte side, byte right,
binangle_t *diff)
{
const lineowner_t* farVertOwner = l->L_vo(right^side);
lineowner_t const *farVertOwner = l->L_vo(right^side);
if(backClosedForBlendNeighbor(l, side, true/*ignore opacity*/))
{
return R_FindSolidLineNeighbor(l->L_sector(side), l, farVertOwner, right, diff);
}
return R_FindLineNeighbor(l->L_sector(side), l, farVertOwner, right, diff);
}
#endif // __CLIENT__

#undef LineDef_PointDistance
DENG_EXTERN_C coord_t LineDef_PointDistance(LineDef* line, coord_t const point[2], coord_t* offset)
Expand Down Expand Up @@ -255,25 +257,19 @@ void LineDef_UpdateAABox(LineDef* line)
line->aaBox.maxY = MAX_OF(line->L_v2origin[VY], line->L_v1origin[VY]);
}

/**
* @todo Now that we store surface tangent space normals use those rather than angles.
*/
void LineDef_LightLevelDelta(LineDef* l, int side, float* deltaL, float* deltaR)
void LineDef_LightLevelDelta(LineDef *l, int side, float* deltaL, float* deltaR)
{
binangle_t diff;
LineDef* other;
vec2f_t normal;
float delta;

#ifdef __CLIENT__
// Disabled?
if(!(rendLightWallAngle > 0))
{
*deltaL = *deltaR = 0;
return;
}

vec2f_t normal;
calcNormal(l, side, normal);
delta = lightLevelDelta(normal);
float delta = lightLevelDelta(normal);

// If smoothing is disabled use this delta for left and right edges.
// Must forcibly disable smoothing for polyobj linedefs as they have
Expand All @@ -288,8 +284,8 @@ void LineDef_LightLevelDelta(LineDef* l, int side, float* deltaL, float* deltaR)
// lightlevel delta and then blend with this to produce the value for
// the left edge. Blend iff the angle between the two linedefs is less
// than 45 degrees.
diff = 0;
other = findBlendNeighbor(l, side, 0, &diff);
binangle_t diff = 0;
LineDef *other = findBlendNeighbor(l, side, 0, &diff);
if(other && INRANGE_OF(diff, BANG_180, BANG_45))
{
vec2f_t otherNormal;
Expand Down Expand Up @@ -324,6 +320,12 @@ void LineDef_LightLevelDelta(LineDef* l, int side, float* deltaL, float* deltaR)
{
*deltaR = delta;
}
#else // !__CLIENT__
DENG2_UNUSED2(l, side);

if(deltaL) *deltaL = 0;
if(deltaR) *deltaR = 0;
#endif
}

int LineDef_SetProperty(LineDef* lin, const setargs_t* args)
Expand Down
10 changes: 9 additions & 1 deletion doomsday/client/src/map/r_world.cpp
Expand Up @@ -789,6 +789,7 @@ coord_t R_VisOpenRange(Sector const *frontSec, Sector const *backSec, coord_t *r
return top - bottom;
}

#ifdef __CLIENT__
boolean R_MiddleMaterialCoversOpening(int lineFlags, Sector *frontSec, Sector *backSec,
SideDef *frontDef, SideDef *backDef, boolean ignoreOpacity)
{
Expand Down Expand Up @@ -978,6 +979,7 @@ LineDef *R_FindLineAlignNeighbor(Sector const *sec, LineDef const *line,
// Not suitable, try the next.
return R_FindLineAlignNeighbor(sec, line, cown, antiClockwise, alignment);
}
#endif // __CLIENT__

static inline void initSurfaceMaterialOffset(Surface *suf)
{
Expand Down Expand Up @@ -1255,6 +1257,8 @@ boolean R_SectorContainsSkySurfaces(Sector const *sec)
return sectorContainsSkySurfaces;
}

#ifdef __CLIENT__

/**
* Given a sidedef section, look at the neighbouring surfaces and pick the
* best choice of material used on those surfaces to be applied to "this"
Expand Down Expand Up @@ -1377,9 +1381,11 @@ static void addMissingMaterial(SideDef *s, SideDefSection section)
<< path;
}
}
#endif // __CLIENT__

static void R_UpdateLinedefsOfSector(Sector *sec)
{
#ifdef __CLIENT__
if(!sec) return;

for(uint i = 0; i < sec->lineDefCount; ++i)
Expand All @@ -1400,7 +1406,6 @@ static void R_UpdateLinedefsOfSector(Sector *sec)
* extend the floor/ceiling to fill the space (unless it is skymasked),
* or if there is a midtexture use that instead.
*/

if(backSec)
{
// Bottom section.
Expand All @@ -1421,6 +1426,9 @@ static void R_UpdateLinedefsOfSector(Sector *sec)
addMissingMaterial(front, SS_MIDDLE);
}
}
#else // !__CLIENT__
DENG2_UNUSED(sec);
#endif
}

boolean R_UpdatePlane(Plane *pln, boolean forceUpdate)
Expand Down
43 changes: 25 additions & 18 deletions doomsday/client/src/render/r_things.cpp
Expand Up @@ -438,41 +438,49 @@ DENG_EXTERN_C boolean R_GetSpriteInfo(int sprite, int frame, spriteinfo_t *info)
{
// We have no information to return.
LOG_WARNING("Invalid sprite frame %i.") << frame;
memset(info, 0, sizeof(*info));
std::memset(info, 0, sizeof(*info));
return false;
}
spriteframe_t *sprFrame = &sprDef->spriteFrames[frame];

if(novideo)
{
// We can't prepare the material.
memset(info, 0, sizeof(*info));
std::memset(info, 0, sizeof(*info));
info->numFrames = sprDef->numFrames;
info->flip = sprFrame->flip[0];
return true;
}

Material *mat = sprFrame->mats[0];
info->material = sprFrame->mats[0];
info->numFrames = sprDef->numFrames;
info->flip = sprFrame->flip[0];

#ifdef __CLIENT__
/// @todo fixme: We should not be using the PSprite spec here. -ds
MaterialVariantSpec const &spec =
App_Materials().variantSpecForContext(MC_PSPRITE, 0, 1, 0, 0,
GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, 0, 1, -1,
false, true, true, false);
MaterialSnapshot const &ms = mat->prepare(spec);
GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, 0, 1, -1,
false, true, true, false);
MaterialSnapshot const &ms = info->material->prepare(spec);

Texture &tex = ms.texture(MTU_PRIMARY).generalCase();
variantspecification_t const *texSpec = TS_GENERAL(ms.texture(MTU_PRIMARY).spec());
DENG_ASSERT(texSpec);
variantspecification_t const &texSpec = TS_GENERAL(ms.texture(MTU_PRIMARY).spec());

info->geometry.origin.x = -tex.origin().x() + -texSpec.border;
info->geometry.origin.y = -tex.origin().y() + texSpec.border;
info->geometry.size.width = ms.dimensions().width() + texSpec.border * 2;
info->geometry.size.height = ms.dimensions().height() + texSpec.border * 2;

info->numFrames = sprDef->numFrames;
info->material = mat;
info->flip = sprFrame->flip[0];
info->geometry.origin.x = -tex.origin().x() + -texSpec->border;
info->geometry.origin.y = -tex.origin().y() + texSpec->border;
info->geometry.size.width = ms.dimensions().width() + texSpec->border*2;
info->geometry.size.height = ms.dimensions().height() + texSpec->border*2;
ms.texture(MTU_PRIMARY).coords(&info->texCoord[0], &info->texCoord[1]);
#else
Texture &tex = *info->material->layers()[0]->stages()[0]->texture;

info->geometry.origin.x = -tex.origin().x();
info->geometry.origin.y = -tex.origin().y();
info->geometry.size.width = info->material->dimensions().width();
info->geometry.size.height = info->material->dimensions().height();
#endif

return true;
}
Expand Down Expand Up @@ -1373,8 +1381,6 @@ void R_ProjectSprite(mobj_t *mo)
}
}

#endif // __CLIENT__

typedef struct {
BspLeaf *bspLeaf;
} addspriteparams_t;
Expand Down Expand Up @@ -1485,6 +1491,8 @@ void R_SortVisSprites()
}
}

#endif // __CLIENT__

coord_t R_GetBobOffset(mobj_t* mo)
{
if(mo->ddFlags & DDMF_BOB)
Expand All @@ -1493,4 +1501,3 @@ coord_t R_GetBobOffset(mobj_t* mo)
}
return 0;
}

0 comments on commit c26890d

Please sign in to comment.