Skip to content

Commit

Permalink
Surface|World: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Aug 17, 2013
1 parent f49bb78 commit 45f189f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 40 deletions.
10 changes: 5 additions & 5 deletions doomsday/client/include/world/surface.h
Expand Up @@ -117,25 +117,25 @@ class Surface : public de::MapElement
de::Vector3f const &tintColor = de::Vector3f(1, 1, 1));

/**
* Returns the tangent space matrix for the surface.
* Returns the normalized tangent space matrix for the surface.
* (col0: tangent, col1: bitangent, col2: normal)
*/
de::Matrix3f const &tangentMatrix() const;

/**
* Returns a copy of the normalized tangent vector for the surface.
*/
de::Vector3f tangent() const;
inline de::Vector3f tangent() const { return tangentMatrix().column(0); }

/**
* Returns a copy of the normalized bitangent vector for the surface.
*/
de::Vector3f bitangent() const;
inline de::Vector3f bitangent() const { return tangentMatrix().column(1); }

/**
* Returns a copy of the normalized normal vector for the surface.
*/
de::Vector3f normal() const;
inline de::Vector3f normal() const { return tangentMatrix().column(2); }

/**
* Change the tangent space normal vector for the surface. If changed,
Expand Down Expand Up @@ -388,7 +388,7 @@ class Surface : public de::MapElement
*
* @param newBlendMode New blendmode.
*/
bool setBlendMode(blendmode_t newBlendMode);
void setBlendMode(blendmode_t newBlendMode);

#ifdef __CLIENT__

Expand Down
49 changes: 14 additions & 35 deletions doomsday/client/src/world/surface.cpp
Expand Up @@ -23,8 +23,6 @@
#include <de/Log>

#include "de_defs.h" // Def_GetGenerator
#include "dd_main.h"

#include "Materials"

#include "world/map.h"
Expand Down Expand Up @@ -157,8 +155,7 @@ DENG2_PIMPL(Surface)
}
}

void notifyTintColorChanged(Vector3f const &oldTintColor,
int changedComponents)
void notifyTintColorChanged(Vector3f const &oldTintColor, int changedComponents)
{
DENG2_FOR_PUBLIC_AUDIENCE(TintColorChange, i)
{
Expand Down Expand Up @@ -193,8 +190,7 @@ DENG2_PIMPL(Surface)
};

Surface::Surface(MapElement &owner, float opacity, Vector3f const &tintColor)
: MapElement(DMU_SURFACE, &owner),
d(new Instance(this))
: MapElement(DMU_SURFACE, &owner), d(new Instance(this))
{
#ifdef __CLIENT__
_decorationData.needsUpdate = true;
Expand All @@ -216,21 +212,6 @@ Matrix3f const &Surface::tangentMatrix() const
return d->tangentMatrix;
}

Vector3f Surface::tangent() const
{
return tangentMatrix().column(0);
}

Vector3f Surface::bitangent() const
{
return tangentMatrix().column(1);
}

Vector3f Surface::normal() const
{
return tangentMatrix().column(2);
}

void Surface::setNormal(Vector3f const &newNormal)
{
Vector3f oldNormal = normal();
Expand All @@ -249,6 +230,16 @@ void Surface::setNormal(Vector3f const &newNormal)
}
}

int Surface::flags() const
{
return d->flags;
}

void Surface::setFlags(int flagsToChange, FlagOp operation)
{
applyFlagOperation(d->flags, flagsToChange, operation);
}

bool Surface::hasMaterial() const
{
return d->material != 0;
Expand All @@ -269,16 +260,6 @@ Material &Surface::material() const
throw MissingMaterialError("Surface::material", "No material is bound");
}

int Surface::flags() const
{
return d->flags;
}

void Surface::setFlags(int flagsToChange, FlagOp operation)
{
applyFlagOperation(d->flags, flagsToChange, operation);
}

bool Surface::setMaterial(Material *newMaterial, bool isMissingFix)
{
if(d->material != newMaterial)
Expand Down Expand Up @@ -403,7 +384,6 @@ Vector2f const &Surface::visMaterialOriginDelta() const
void Surface::lerpVisMaterialOrigin()
{
// $smoothmaterialorigin

d->visMaterialOriginDelta = d->oldMaterialOrigin[0] * (1 - frameTimePos)
+ d->materialOrigin * frameTimePos - d->materialOrigin;

Expand Down Expand Up @@ -453,7 +433,7 @@ float Surface::opacity() const

void Surface::setOpacity(float newOpacity)
{
DENG_ASSERT(d->isSideMiddle() || d->isSectorExtraPlane());
DENG_ASSERT(d->isSideMiddle() || d->isSectorExtraPlane()); // sanity check

newOpacity = de::clamp(0.f, newOpacity, 1.f);
if(!de::fequal(d->opacity, newOpacity))
Expand Down Expand Up @@ -505,13 +485,12 @@ blendmode_t Surface::blendMode() const
return d->blendMode;
}

bool Surface::setBlendMode(blendmode_t newBlendMode)
void Surface::setBlendMode(blendmode_t newBlendMode)
{
if(d->blendMode != newBlendMode)
{
d->blendMode = newBlendMode;
}
return true;
}

#ifdef __CLIENT__
Expand Down

0 comments on commit 45f189f

Please sign in to comment.