Skip to content

Commit

Permalink
Fixed|libdoomsday|client: Benign compiler warnings, ambiguous de::Vec…
Browse files Browse the repository at this point in the history
…tor<> conversion
  • Loading branch information
danij-deng committed Jun 11, 2015
1 parent c225aae commit 889dd04
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 42 deletions.
64 changes: 35 additions & 29 deletions doomsday/apps/client/src/render/billboard.cpp
Expand Up @@ -250,46 +250,52 @@ static void applyUniformColor(dint count, dgl_color_t *colors, dfloat const *rgb
/**
* Calculate vertex lighting.
*/
static void Spr_VertexColors(dint count, dgl_color_t *out, dgl_vertex_t *normalIt,
duint lightListIdx, duint maxLights, dfloat const *ambient)
static void Spr_VertexColors(dint count, dgl_color_t *out, dgl_vertex_t *normals,
duint lightListIdx, dint maxLights, dfloat const *_ambient)
{
DENG2_ASSERT(out && normalIt);
DENG2_ASSERT(out && normals && _ambient);

dbyte const opacity = 255 * _ambient[3];
Vector3f const ambient(_ambient);
Vector3f const saturated(1, 1, 1);

for(dint i = 0; i < count; ++i, out++, normalIt++)
Vector3ub colorClamped;
for(dint i = 0; i < count; ++i)
{
Vector3f const normal(normalIt->xyz);

// Accumulate contributions from all affecting lights.
Vector3f accum[2]; // Begin with total darkness [color, extra].
dint numProcessed = 0;
rendSys().forAllVectorLights(lightListIdx, [&maxLights, &normal
, &accum, &numProcessed] (VectorLightData const &vlight)
if(maxLights > 0)
{
numProcessed += 1;

dfloat strength = vlight.direction.dot(normal)
+ vlight.offset; // Shift toward the light a little.
// Accumulate contributions from all affecting lights.
Vector3f const normal(normals[i].xyz);
Vector3f accum[2]; // Begin with total darkness [color, extra].
dint numProcessed = 0;
rendSys().forAllVectorLights(lightListIdx, [&maxLights, &normal
, &accum, &numProcessed](VectorLightData const &vlight)
{
numProcessed += 1;

// Ability to both light and shade.
if(strength > 0) strength *= vlight.lightSide;
else strength *= vlight.darkSide;
dfloat strength = vlight.direction.dot(normal) + vlight.offset; // Shift toward the light a little.
// Ability to both light and shade.
if(strength > 0) strength *= vlight.lightSide;
else strength *= vlight.darkSide;

accum[vlight.affectedByAmbient? 0 : 1]
+= vlight.color * de::clamp(-1.f, strength, 1.f);
accum[vlight.affectedByAmbient ? 0 : 1]
+= vlight.color * de::clamp(-1.f, strength, 1.f);

// Time to stop?
return (maxLights && numProcessed == maxLights);
});
// Time to stop?
return (maxLights && numProcessed == maxLights);
});

// Check for ambient and convert to ubyte.
Vector3f color = (accum[0].max(ambient) + accum[1]).min(saturated);
colorClamped = ((accum[0].max(ambient) + accum[1]).min(saturated) * 255).toVector3ub();
}
else if(i == 0)
{
colorClamped = (ambient.min(saturated) * 255).toVector3ub();
}

out->rgba[0] = dbyte( 255 * color.x );
out->rgba[1] = dbyte( 255 * color.y );
out->rgba[2] = dbyte( 255 * color.z );
out->rgba[3] = dbyte( 255 * ambient[3] );
out[i].rgba[0] = colorClamped.x;
out[i].rgba[1] = colorClamped.y;
out[i].rgba[2] = colorClamped.z;
out[i].rgba[3] = opacity;
}
}

Expand Down
5 changes: 0 additions & 5 deletions doomsday/apps/client/src/render/r_main.cpp
Expand Up @@ -53,11 +53,6 @@ dfloat weaponFOVShift = 45;
dfloat weaponOffsetScale = 0.3183f; // 1/Pi
dbyte weaponScaleMode = SCALEMODE_SMART_STRETCH;

static inline RenderSystem &rendSys()
{
return ClientApp::renderSystem();
}

static inline ResourceSystem &resSys()
{
return ClientApp::resourceSystem();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/render/rend_fakeradio.cpp
Expand Up @@ -1307,7 +1307,7 @@ void Rend_RadioSubspaceEdges(ConvexSubspace const &subspace)
// Any need to continue?
if(shadowDark < .0001f) return;

Vector3f const eyeToSurface = Rend_EyeOrigin().xz() - subspace.poly().center();
Vector3f const eyeToSurface = Vector3d(Rend_EyeOrigin().xz(), 0) - subspace.poly().center();

// We need to check all the shadow lines linked to this subspace for
// the purpose of fakeradio shadowing.
Expand Down
6 changes: 2 additions & 4 deletions doomsday/apps/client/src/render/rend_main.cpp
Expand Up @@ -1103,7 +1103,7 @@ static void makeFlatShadowGeometry(Geometry &verts, Vector3d const &topLeft, Vec
std::memcpy(verts.pos, posCoords, sizeof(Vector3f) * numVertices);
}

static void makeWallShadowGeometry(Geometry &verts, Vector3d const &topLeft, Vector3d const &bottomRight,
static void makeWallShadowGeometry(Geometry &verts, Vector3d const &/*topLeft*/, Vector3d const &/*bottomRight*/,
duint numVertices, Vector3f const *posCoords, WallEdge const &leftEdge, WallEdge const &rightEdge,
ProjectedTextureData const &tp)
{
Expand Down Expand Up @@ -1166,7 +1166,7 @@ static void makeFlatLightGeometry(Geometry &verts, Vector3d const &topLeft, Vect
std::memcpy(verts.pos, posCoords, sizeof(Vector3f) * numVertices);
}

static void makeWallLightGeometry(Geometry &verts, Vector3d const &topLeft, Vector3d const &bottomRight,
static void makeWallLightGeometry(Geometry &verts, Vector3d const &/*topLeft*/, Vector3d const &/*bottomRight*/,
duint numVertices, Vector3f const *posCoords, WallEdge const &leftEdge, WallEdge const &rightEdge,
ProjectedTextureData const &tp)
{
Expand Down Expand Up @@ -1250,8 +1250,6 @@ static bool renderWorldPoly(Vector3f const *rvertices, duint numVertices,
{
DENG2_ASSERT(rvertices);

SectorCluster &cluster = curSubspace->cluster();

// Ensure we've up to date info about the material.
matAnimator.prepare();

Expand Down
5 changes: 2 additions & 3 deletions doomsday/apps/libdoomsday/src/defs/dedparser.cpp
Expand Up @@ -2920,10 +2920,10 @@ DENG2_PIMPL(DEDParser)
{
xgclassparm_t const& iParm = xgClassLinks[l->lineClass].iparm[i];

if(!iParm.name || !iParm.name[0]) continue;
if(!iParm.name[0]) continue;
if(!ISLABEL(iParm.name)) continue;

if(iParm.flagPrefix && iParm.flagPrefix[0])
if(iParm.flagPrefix[0])
{
READFLAGS(l->iparm[i], iParm.flagPrefix)
}
Expand All @@ -2933,7 +2933,6 @@ DENG2_PIMPL(DEDParser)
}
break;
}

// Not a known label?
if(i == 20) RV_END

Expand Down
3 changes: 3 additions & 0 deletions doomsday/sdk/libcore/include/de/core/vector.h
Expand Up @@ -312,6 +312,9 @@ class Vector3 : public Vector2<Type>
operator Vector3<ddouble> () const {
return Vector3<ddouble>(Vector2<Type>::x, Vector2<Type>::y, z);
}
Vector3<dbyte> toVector3ub() const {
return Vector3<dbyte>(dbyte(Vector2<Type>::x), dbyte(Vector2<Type>::y), dbyte(z));
}
Vector3<dfloat> toVector3f() const {
return Vector3<dfloat>(dfloat(Vector2<Type>::x), dfloat(Vector2<Type>::y), dfloat(z));
}
Expand Down

0 comments on commit 889dd04

Please sign in to comment.