Skip to content

Commit

Permalink
ResourceSystem: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Dec 9, 2013
1 parent 0ac7425 commit b3afeeb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
11 changes: 9 additions & 2 deletions doomsday/client/include/resource/resourcesystem.h
Expand Up @@ -37,7 +37,7 @@
#include "Sprite"
#include "Texture"
#include "TextureScheme"
#include "resource/rawtexture.h" /// @todo not yet owned
#include "resource/rawtexture.h"
#include "resource/wad.h"
#include "resource/zip.h"
#include "uri.hh"
Expand Down Expand Up @@ -159,13 +159,20 @@ class ResourceSystem : public de::System
*/
bool hasSprite(spritenum_t spriteId, int frame);

/**
* Lookup a sprite by unique identifier & frame number.
*
* @see hasSprite(), spritePtr()
*/
Sprite &sprite(spritenum_t spriteId, int frame);

/**
* Returns a pointer to the identified Sprite.
*
* @see hasSprite()
*/
inline Sprite *spritePtr(spritenum_t spriteId, int frame) {
return hasSprite(spriteId, frame)? spriteSet(spriteId).at(frame) : 0;
return hasSprite(spriteId, frame)? &sprite(spriteId, frame) : 0;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/api_render.cpp
Expand Up @@ -118,7 +118,7 @@ DENG_EXTERN_C boolean R_GetSpriteInfo(int spriteId, int frame, spriteinfo_t *inf
}

SpriteViewAngle const &sprViewAngle =
App_ResourceSystem().spritePtr(spriteId, frame)->viewAngle(0);
App_ResourceSystem().sprite(spriteId, frame).viewAngle(0);
info->material = sprViewAngle.material;
info->flip = sprViewAngle.mirrorX;

Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/r_main.cpp
Expand Up @@ -71,7 +71,7 @@ static void setupPSpriteParams(rendpspriteparams_t *params, vispsprite_t *spr)
float const offScaleY = weaponOffsetScaleY / 1000.0f;

SpriteViewAngle const &sprViewAngle =
ClientApp::resourceSystem().spritePtr(spriteIdx, frameIdx)->viewAngle(0);
ClientApp::resourceSystem().sprite(spriteIdx, frameIdx).viewAngle(0);

Material *material = sprViewAngle.material;
bool flip = sprViewAngle.mirrorX;
Expand Down
14 changes: 9 additions & 5 deletions doomsday/client/src/resource/resourcesystem.cpp
Expand Up @@ -349,7 +349,6 @@ DENG2_PIMPL(ResourceSystem)
resClasses.append(new ResourceClass("RC_MUSIC", "Music"));
resClasses.append(new ResourceClass("RC_FONT", "Fonts"));

LOG_MSG("Initializing Texture collection...");
/// @note Order here defines the ambigious-URI search order.
createTextureScheme("Sprites");
createTextureScheme("Textures");
Expand All @@ -364,15 +363,13 @@ DENG2_PIMPL(ResourceSystem)
createTextureScheme("Lightmaps");
createTextureScheme("Flaremaps");

LOG_MSG("Initializing Material collection...");
/// @note Order here defines the ambigious-URI search order.
createMaterialScheme("Sprites");
createMaterialScheme("Textures");
createMaterialScheme("Flats");
createMaterialScheme("System");

#ifdef __CLIENT__
LOG_MSG("Initializing Font collection...");
/// @note Order here defines the ambigious-URI search order.
createFontScheme("System");
createFontScheme("Game");
Expand Down Expand Up @@ -1968,6 +1965,11 @@ bool ResourceSystem::hasSprite(spritenum_t spriteId, int frame)
return false;
}

Sprite &ResourceSystem::sprite(spritenum_t spriteId, int frame)
{
return *spriteSet(spriteId).at(frame);
}

ResourceSystem::SpriteSet const &ResourceSystem::spriteSet(spritenum_t spriteId)
{
if(Instance::SpriteGroup *group = d->spriteGroup(spriteId))
Expand Down Expand Up @@ -2771,7 +2773,8 @@ void ResourceSystem::releaseAllSystemGLTextures()
{
if(novideo) return;

LOG_VERBOSE("Releasing System textures...");
LOG_AS("ResourceSystem");
LOG_VERBOSE("Releasing system textures...");

// The rendering lists contain persistent references to texture names.
// Which, obviously, can't persist any longer...
Expand All @@ -2791,7 +2794,8 @@ void ResourceSystem::releaseAllRuntimeGLTextures()
{
if(novideo) return;

LOG_VERBOSE("Releasing Runtime textures...");
LOG_AS("ResourceSystem");
LOG_VERBOSE("Releasing runtime textures...");

// The rendering lists contain persistent references to texture names.
// Which, obviously, can't persist any longer...
Expand Down

0 comments on commit b3afeeb

Please sign in to comment.