Skip to content

Commit

Permalink
Sprite|Resources: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Nov 20, 2013
1 parent 68e133d commit bdebb03
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
3 changes: 1 addition & 2 deletions doomsday/client/include/resource/sprite.h
Expand Up @@ -2,8 +2,6 @@
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2006 Jamie Jones <jamie_jones_au@yahoo.com.au>
* @authors Copyright © 1993-1996 by id Software, Inc.
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand All @@ -23,6 +21,7 @@
#ifndef DENG_RESOURCE_SPRITE_H
#define DENG_RESOURCE_SPRITE_H

#include "dd_types.h" // angle_t
#include <de/Error>
#include <de/String>
#include <QList>
Expand Down
21 changes: 16 additions & 5 deletions doomsday/client/src/resource/sprite.cpp
Expand Up @@ -2,6 +2,8 @@
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2006 Jamie Jones <jamie_jones_au@yahoo.com.au>
* @authors Copyright © 1993-1996 by id Software, Inc.
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand All @@ -25,12 +27,12 @@
# include "MaterialSnapshot"
# include "TextureManifest"

# include "gl/gl_tex.h"
# include "gl/gl_texmanager.h"
# include "gl/gl_tex.h" // pointlight_analysis_t

# include "Lumobj"
# include "render/billboard.h"
# include "render/billboard.h" // Rend_SpriteMaterialSpec
#endif
#include <de/Log>

using namespace de;

Expand Down Expand Up @@ -97,12 +99,14 @@ void Sprite::newViewAngle(Material *material, uint rotation, bool mirrorX)

Sprite::ViewAngle const &Sprite::viewAngle(int rotation) const
{
LOG_AS("Sprite::viewAngle");

if(rotation >= 0 && rotation < max_angles)
{
return d->viewAngles[rotation];
}
/// @throw MissingViewAngle Specified an invalid rotation.
throw MissingViewAngleError("Sprite::viewAngle", "Invalid rotation" + String::number(rotation));
throw MissingViewAngleError("Sprite::viewAngle", "Invalid rotation " + String::number(rotation));
}

Sprite::ViewAngle const &Sprite::closestViewAngle(angle_t mobjAngle, angle_t angleToEye,
Expand All @@ -122,6 +126,8 @@ Sprite::ViewAngle const &Sprite::closestViewAngle(angle_t mobjAngle, angle_t ang
#ifdef __CLIENT__
Lumobj *Sprite::generateLumobj() const
{
LOG_AS("Sprite::generateLumobj");

// Always use rotation zero.
/// @todo We could do better here...
if(!hasViewAngle(0)) return 0;
Expand All @@ -133,7 +139,12 @@ Lumobj *Sprite::generateLumobj() const
Texture &tex = ms.texture(MTU_PRIMARY).generalCase();

pointlight_analysis_t const *pl = reinterpret_cast<pointlight_analysis_t const *>(ms.texture(MTU_PRIMARY).generalCase().analysisDataPointer(Texture::BrightPointAnalysis));
if(!pl) throw Error("Sprite::generateLumobj", QString("Texture \"%1\" has no BrightPointAnalysis").arg(ms.texture(MTU_PRIMARY).generalCase().manifest().composeUri()));
if(!pl)
{
LOG_WARNING("Texture \"%s\" has no BrightPointAnalysis")
<< ms.texture(MTU_PRIMARY).generalCase().manifest().composeUri();
return 0;
}

// Apply the auto-calculated color.
return &(new Lumobj(Vector3d(), pl->brightMul, pl->color.rgb))
Expand Down

0 comments on commit bdebb03

Please sign in to comment.