Skip to content

Commit

Permalink
MaterialSnapshot: Interpolate MaterialVariant layer states at update …
Browse files Browse the repository at this point in the history
…time

Moved the interpolation of MaterialVariant layer state values from
it's ticker to MaterialSnapshot::update() as interpolation of these
values need not be performed each tic.

Also began to restructuring the logic in preparation for the next
phase of refactorings.
  • Loading branch information
danij-deng committed Jan 11, 2013
1 parent d191041 commit 84a79be
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 174 deletions.
6 changes: 4 additions & 2 deletions doomsday/engine/include/resource/materialsnapshot.h
Expand Up @@ -33,7 +33,7 @@ enum {

#include <QSize>
#include <de/Error>
#include "de/vector1.h"
#include <de/Vector>
#include "render/rendpoly.h"

namespace de {
Expand Down Expand Up @@ -82,7 +82,7 @@ class MaterialSnapshot
/**
* Returns the minimum ambient light color for the material snapshot.
*/
vec3f_t const &reflectionMinColor() const;
Vector3f const &reflectionMinColor() const;

/**
* Returns @c true if a texture with @a index is set for the material snapshot.
Expand All @@ -97,13 +97,15 @@ class MaterialSnapshot
*/
TextureVariant &texture(int index) const;

#ifdef __CLIENT__
/**
* Lookup a material snapshot texture unit by index.
*
* @param index Index of the texture unit to lookup.
* @return The associated texture unit.
*/
rtexmapunit_t const &unit(int index) const;
#endif

/**
* Prepare all textures and update property values.
Expand Down
8 changes: 0 additions & 8 deletions doomsday/engine/include/resource/materialvariant.h
Expand Up @@ -132,14 +132,6 @@ class MaterialVariant

/// Intermark from the current stage to the next [0..1].
float inter;

/// Interpolated origin of the texture in material-space.
/// @todo Does not belong at this level.
float texOrigin[2];

/// Interpolated glow strength factor.
/// @todo Does not belong at this level.
float glowStrength;
};

public:
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/src/render/rend_main.cpp
Expand Up @@ -1010,12 +1010,12 @@ static boolean renderWorldPoly(rvertex_t *rvertices, uint numVertices,
if(shinyRTU && !drawAsVisSprite)
{
// Strength of the shine.
vec3f_t const &minColor = msA->reflectionMinColor();
Vector3f const &minColor = msA->reflectionMinColor();
for(uint i = 0; i < numVertices; ++i)
{
shinyColors[i].rgba[CR] = MAX_OF(rcolors[i].rgba[CR], minColor[CR]);
shinyColors[i].rgba[CG] = MAX_OF(rcolors[i].rgba[CG], minColor[CG]);
shinyColors[i].rgba[CB] = MAX_OF(rcolors[i].rgba[CB], minColor[CB]);
shinyColors[i].rgba[CR] = MAX_OF(rcolors[i].rgba[CR], minColor.x);
shinyColors[i].rgba[CG] = MAX_OF(rcolors[i].rgba[CG], minColor.y);
shinyColors[i].rgba[CB] = MAX_OF(rcolors[i].rgba[CB], minColor.z);
shinyColors[i].rgba[CA] = shinyRTU->opacity;
}
}
Expand Down
5 changes: 1 addition & 4 deletions doomsday/engine/src/resource/materials.cpp
Expand Up @@ -507,7 +507,6 @@ MaterialManifest &Materials::newManifest(MaterialScheme &scheme, Path const &pat
// Allocate more memory.
d->manifestIdMapSize += MATERIALS_MANIFESTMAP_BLOCK_ALLOC;
d->manifestIdMap = (MaterialManifest **) M_Realloc(d->manifestIdMap, sizeof *d->manifestIdMap * d->manifestIdMapSize);
if(!d->manifestIdMap) Libdeng_BadAlloc();
}
d->manifestIdMap[d->manifestCount - 1] = manifest; /* 1-based index */
}
Expand Down Expand Up @@ -829,9 +828,7 @@ static void printVariantInfo(MaterialVariant &variant, int variantIdx)
for(int i = 0; i < layerCount; ++i)
{
MaterialVariant::LayerState const &l = variant.layer(i);

Con_Printf(" #%i: Stage:%i Tics:%i Offset: %.2f x %.2f Glow:%.2f\n",
i, l.stage, int(l.tics), l.texOrigin[0], l.texOrigin[1], l.glowStrength);
Con_Printf(" #%i: Stage:%i Tics:%i\n", i, l.stage, int(l.tics));
}
}

Expand Down

0 comments on commit 84a79be

Please sign in to comment.