Skip to content

Commit

Permalink
Merge branch 'master' of ssh://github.com/skyjake/Doomsday-Engine
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Dec 5, 2012
2 parents 0984aa9 + 374a5e3 commit ac5da31
Show file tree
Hide file tree
Showing 19 changed files with 230 additions and 296 deletions.
41 changes: 18 additions & 23 deletions doomsday/engine/include/resource/texture.h
Expand Up @@ -59,6 +59,8 @@ typedef enum {

namespace de {

class TextureManifest;

/**
* Presents an abstract interface to all supported texture types so that
* they may be managed transparently.
Expand All @@ -77,23 +79,21 @@ class Texture

public:
/**
* @param bindId Unique identifier of the primary binding in the owning
* collection. Can be @c NOTEXTUREID in which case there is no binding
* for the resultant texture.
* @param manifest Manifest derived to yield the texture.
* @param userData User data to associate with the resultant texture.
*/
Texture(textureid_t bindId, Flags flags = 0, void *userData = 0);
Texture(TextureManifest &manifest, Flags flags = 0, void *userData = 0);

/**
* @param bindId Unique identifier of the primary binding in the owning
* collection. Can be @c NOTEXTUREID in which case there is no binding
* for the resultant texture.
* @param size Logical size of the texture. Components can be zero in which
* case their value will be inherited from the actual pixel size of the
* image at load time.
* @param manifest Manifest derived to yield the Texture.
* @param dimensions Logical dimensions of the texture in map space
* coordinates. If width=0 and height=0, their value
* will be inferred from the actual pixel dimensions
* of the image resource at load time.
* @param userData User data to associate with the resultant texture.
*/
Texture(textureid_t bindId, Size2Raw const &dimensions, Flags flags = 0, void *userData = 0);
Texture(TextureManifest &manifest, Size2Raw const &dimensions,
Flags flags = 0, void *userData = 0);

~Texture();

Expand All @@ -103,9 +103,10 @@ class Texture
/// Change the "custom" status of this texture instance.
void flagCustom(bool yes);

textureid_t primaryBind() const { return primaryBindId; }

void setPrimaryBind(textureid_t bindId);
/**
* Returns the TextureManifest derived to yield the texture.
*/
TextureManifest &manifest() const;

/**
* Retrieve the value of the associated user data pointer.
Expand Down Expand Up @@ -197,15 +198,15 @@ class Texture
Flags flags;

/// Unique identifier of the primary binding in the owning collection.
textureid_t primaryBindId;
TextureManifest &manifest_;

/// List of variants (e.g., color translations).
Variants variants;

/// User data associated with this texture.
void *userData;

/// Dimensions in logical pixels.
/// "Logical" dimensions in map coordinate space units.
Size2Raw dimensions_;

/// Table of analyses object ptrs, used for various purposes depending
Expand All @@ -225,13 +226,6 @@ extern "C" {
struct texture_s; // The texture instance (opaque).
typedef struct texture_s Texture;

Texture* Texture_NewWithSize(textureid_t bindId, const Size2Raw* size, void* userData);
Texture* Texture_New(textureid_t bindId, void* userData);
void Texture_Delete(Texture* tex);

textureid_t Texture_PrimaryBind(const Texture* tex);
void Texture_SetPrimaryBind(Texture* tex, textureid_t bindId);

void* Texture_UserDataPointer(const Texture* tex);
void Texture_SetUserDataPointer(Texture* tex, void* userData);

Expand All @@ -245,6 +239,7 @@ void Texture_SetAnalysisDataPointer(Texture* tex, texture_analysisid_t analysis,
boolean Texture_IsCustom(const Texture* tex);
void Texture_FlagCustom(Texture* tex, boolean yes);

textureid_t Texture_PrimaryBind(const Texture* tex);
int Texture_Width(const Texture* tex);
int Texture_Height(const Texture* tex);
const Size2Raw* Texture_Dimensions(const Texture* tex);
Expand Down
3 changes: 3 additions & 0 deletions doomsday/engine/include/resource/texturemanifest.h
Expand Up @@ -65,6 +65,9 @@ class TextureManifest : public PathTree::Node
*/
TextureScheme &scheme() const;

/// Convenience method for returning the name of the owning scheme.
String const &schemeName() const;

/**
* Compose a URI of the form "scheme:path" for the TextureManifest.
*
Expand Down
45 changes: 19 additions & 26 deletions doomsday/engine/include/resource/textures.h
Expand Up @@ -148,24 +148,12 @@ class Textures
return size();
}

/// @return Unique identifier of the primary name for @a texture else @c NOTEXTUREID.
textureid_t id(Texture &texture) const;

/// @return Unique identifier of the primary name for @a manifest else @c NOTEXTUREID.
textureid_t idForManifest(Manifest const &manifest) const;

/// @return Texture associated with unique identifier @a textureId else @c 0.
Texture *toTexture(textureid_t textureId) const;

/// @return Scheme-unique identfier associated with the identified @a textureId.
int uniqueId(textureid_t textureId) const;

/// @return Declared, percent-encoded path to this data resource,
/// else a "null" Uri (no scheme or path).
Uri const &resourceUri(textureid_t textureId) const;

/// @return URI to this texture, percent-encoded.
Uri composeUri(textureid_t textureId) const;
/**
* Removes the manifest from any indexes.
*
* @param manifest Manifest to remove from the index.
*/
void deindex(Manifest &manifest);

/**
* Find a single declared texture.
Expand Down Expand Up @@ -194,13 +182,6 @@ class Textures
*/
Manifest *declare(Uri const &uri, int uniqueId, Uri const *resourceUri);

/**
* Removes the manifest from any indexes.
*
* @param manifest Manifest to remove from the index.
*/
void deindex(Manifest &manifest);

/**
* Iterate over defined Textures in the collection making a callback for
* each visited. Iteration ends when all textures have been visited or a
Expand Down Expand Up @@ -249,10 +230,22 @@ class Textures
return iterateDeclared("", callback, parameters);
}


private:
struct Instance;
Instance *d;

public:
/*
* Here follows legacy interface methods awaiting removal -ds
*/

/// @return Unique identifier of the primary name for @a manifest else @c NOTEXTUREID.
/// @deprecated Texture ids are now obsolete. Reference/point-to the manifest instead.
textureid_t idForManifest(Manifest const &manifest) const;

/// @return Texture associated with unique identifier @a textureId else @c 0.
/// @deprecated Texture ids are now obsolete. Reference/point-to the manifest instead.
Texture *toTexture(textureid_t textureId) const;
};

} // namespace de
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/include/resource/texturescheme.h
Expand Up @@ -59,7 +59,7 @@ class TextureScheme
~TextureScheme();

/// @return Symbolic name of this scheme (e.g., "ModelSkins").
String const& name() const;
String const &name() const;

/// @return Total number of manifests in the scheme.
int size() const;
Expand Down
7 changes: 5 additions & 2 deletions doomsday/engine/src/def_main.cpp
Expand Up @@ -945,8 +945,11 @@ void Def_GenerateGroupsFromAnims(void)
gmbr = &grp->members[idx];
gmbr->tics = frame->tics;
gmbr->randomTics = frame->randomTics;
de::Uri textureUri = textures.composeUri(frame->texture);
gmbr->material = reinterpret_cast<uri_s *>(new de::Uri(Str_Text(DD_MaterialSchemeNameForTextureScheme(textureUri.scheme())), textureUri.path()));
if(de::Texture *tex = textures.toTexture(frame->texture))
{
de::Uri textureUri = tex->manifest().composeUri();
gmbr->material = reinterpret_cast<uri_s *>(new de::Uri(Str_Text(DD_MaterialSchemeNameForTextureScheme(textureUri.scheme())), textureUri.path()));
}
}
}
}
Expand Down

0 comments on commit ac5da31

Please sign in to comment.