From bdebb038a2c7873ac60b1bff4a12f10e41e194c4 Mon Sep 17 00:00:00 2001 From: danij Date: Wed, 20 Nov 2013 21:43:13 +0000 Subject: [PATCH] Sprite|Resources: Cleanup --- doomsday/client/include/resource/sprite.h | 3 +-- doomsday/client/src/resource/sprite.cpp | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/doomsday/client/include/resource/sprite.h b/doomsday/client/include/resource/sprite.h index 363faaaee4..8a91d2109a 100644 --- a/doomsday/client/include/resource/sprite.h +++ b/doomsday/client/include/resource/sprite.h @@ -2,8 +2,6 @@ * * @authors Copyright © 2003-2013 Jaakko Keränen * @authors Copyright © 2006-2013 Daniel Swanson - * @authors Copyright © 2006 Jamie Jones - * @authors Copyright © 1993-1996 by id Software, Inc. * * @par License * GPL: http://www.gnu.org/licenses/gpl.html @@ -23,6 +21,7 @@ #ifndef DENG_RESOURCE_SPRITE_H #define DENG_RESOURCE_SPRITE_H +#include "dd_types.h" // angle_t #include #include #include diff --git a/doomsday/client/src/resource/sprite.cpp b/doomsday/client/src/resource/sprite.cpp index 2823f7f210..455725cc87 100644 --- a/doomsday/client/src/resource/sprite.cpp +++ b/doomsday/client/src/resource/sprite.cpp @@ -2,6 +2,8 @@ * * @authors Copyright © 2003-2013 Jaakko Keränen * @authors Copyright © 2006-2013 Daniel Swanson + * @authors Copyright © 2006 Jamie Jones + * @authors Copyright © 1993-1996 by id Software, Inc. * * @par License * GPL: http://www.gnu.org/licenses/gpl.html @@ -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 using namespace de; @@ -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, @@ -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; @@ -133,7 +139,12 @@ Lumobj *Sprite::generateLumobj() const Texture &tex = ms.texture(MTU_PRIMARY).generalCase(); pointlight_analysis_t const *pl = reinterpret_cast(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))