Skip to content

Commit

Permalink
Refactor: Updated texture collection initialization
Browse files Browse the repository at this point in the history
Made use of CompositeTexture and reimplemented all texture collection
initialization using components of the 2.0 architecture and Qt.
  • Loading branch information
danij-deng committed Nov 27, 2012
1 parent 94bc9a6 commit 8c28298
Show file tree
Hide file tree
Showing 6 changed files with 218 additions and 342 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/include/de_resource.h
Expand Up @@ -30,7 +30,7 @@
#include "resource/materials.h"
#include "resource/materialvariant.h"
#include "resource/models.h"
#include "resource/patchcompositetexture.h"
#include "resource/compositetexture.h"
#include "resource/rawtexture.h"
#include "resource/textures.h"
#include "resource/wad.h"
Expand Down
15 changes: 12 additions & 3 deletions doomsday/engine/include/resource/r_data.h
Expand Up @@ -58,15 +58,24 @@ typedef struct patchtex_s
} patchtex_t;

#pragma pack(1)
typedef struct doompatch_header_s
{
typedef struct doompatch_header_s {
int16_t width; /// Bounding box size.
int16_t height;
int16_t leftOffset; /// Pixels to the left of origin.
int16_t topOffset; /// Pixels below the origin.
} doompatch_header_t;

// Posts are runs of non masked source pixels.
typedef struct post_s {
byte topOffset; // @c 0xff is the last post in a column.
byte length;
// Length palette indices follow.
} post_t;
#pragma pack()

// column_t is a list of 0 or more post_t, (uint8_t)-1 terminated
typedef post_t column_t;

#ifdef __cplusplus
#include <de/IReadable>
#include <de/Reader>
Expand Down Expand Up @@ -127,7 +136,7 @@ extern "C" {
#endif

void R_InitSystemTextures(void);
void R_InitPatchCompositeTextures(void);
void R_InitCompositeTextures(void);
void R_InitFlatTextures(void);
void R_InitSpriteTextures(void);

Expand Down
6 changes: 3 additions & 3 deletions doomsday/engine/src/dd_main.cpp
Expand Up @@ -1061,7 +1061,7 @@ static int DD_ActivateGameWorker(void* parameters)
DENG_ASSERT(p);

// Texture resources are located now, prior to initializing the game.
R_InitPatchCompositeTextures();
R_InitCompositeTextures();
R_InitFlatTextures();
R_InitSpriteTextures();

Expand Down Expand Up @@ -1904,7 +1904,7 @@ boolean DD_Init(void)
initPathMappings();
App_FileSystem()->resetAllSchemes();

R_InitPatchCompositeTextures();
R_InitCompositeTextures();
R_InitFlatTextures();
R_InitSpriteTextures();

Expand Down Expand Up @@ -2134,7 +2134,7 @@ void DD_UpdateEngineState(void)
// Re-build the filesystem subspace schemes as there may be new resources to be found.
App_FileSystem()->resetAllSchemes();

R_InitPatchCompositeTextures();
R_InitCompositeTextures();
R_InitFlatTextures();
R_InitSpriteTextures();

Expand Down
15 changes: 8 additions & 7 deletions doomsday/engine/src/def_main.cpp
Expand Up @@ -949,9 +949,9 @@ void Def_GenerateGroupsFromAnims(void)
}
}

static int generateMaterialDefForPatchCompositeTexture(textureid_t texId, void* parameters)
static int generateMaterialDefForCompositeTexture(textureid_t texId, void* /*parameters*/)
{
DENG_UNUSED(parameters);
LOG_AS("generateMaterialDefForCompositeTexture");

Uri* texUri = Textures_ComposeUri(texId);
ded_material_layer_stage_t* st;
Expand All @@ -969,17 +969,18 @@ static int generateMaterialDefForPatchCompositeTexture(textureid_t texId, void*
tex = Textures_ToTexture(texId);
if(tex)
{
patchcompositetex_t* pcTex = (patchcompositetex_t*)Texture_UserDataPointer(tex);
assert(pcTex);
de::CompositeTexture* pcTex = reinterpret_cast<de::CompositeTexture *>(Texture_UserDataPointer(tex));
DENG_ASSERT(pcTex);
mat->width = Texture_Width(tex);
mat->height = Texture_Height(tex);
mat->flags = ((pcTex->flags & TXDF_NODRAW)? MATF_NO_DRAW : 0);
mat->flags = (pcTex->flags().testFlag(de::CompositeTexture::NoDraw)? MATF_NO_DRAW : 0);
}
#if _DEBUG
else
{
AutoStr* path = Uri_ToString(texUri);
Con_Message("Warning:generateMaterialDefForPatchCompositeTexture: Texture \"%s\" has not yet been defined, resultant Material will inherit dimensions.\n", Str_Text(path));
LOG_WARNING("Texture \"%s\" yet defined, resultant Material will inherit dimensions.")
<< Str_Text(path);
}
#endif

Expand Down Expand Up @@ -1067,7 +1068,7 @@ static int generateMaterialDefForSpriteTexture(textureid_t texId, void* paramete

void Def_GenerateAutoMaterials(void)
{
Textures_IterateDeclared(TS_TEXTURES, generateMaterialDefForPatchCompositeTexture);
Textures_IterateDeclared(TS_TEXTURES, generateMaterialDefForCompositeTexture);
Textures_IterateDeclared(TS_FLATS, generateMaterialDefForFlatTexture);
Textures_IterateDeclared(TS_SPRITES, generateMaterialDefForSpriteTexture);
}
Expand Down
16 changes: 8 additions & 8 deletions doomsday/engine/src/resource/patchname.cpp
Expand Up @@ -28,8 +28,8 @@

namespace de {

PatchName::PatchName(String _name, lumpnum_t _lumpNum)
: name_(_name), lumpNum_(_lumpNum)
PatchName::PatchName(String percentEncodedName, lumpnum_t _lumpNum)
: name(percentEncodedName), lumpNum_(_lumpNum)
{}

lumpnum_t PatchName::lumpNum()
Expand All @@ -42,7 +42,7 @@ lumpnum_t PatchName::lumpNum()
// Perform the search.
try
{
lumpNum_ = App_FileSystem()->lumpNumForName(name_);
lumpNum_ = App_FileSystem()->lumpNumForName(name);
}
catch(FS1::NotFoundError const &er)
{
Expand All @@ -62,18 +62,18 @@ void PatchName::operator << (Reader &from)

// WAD format allows characters not normally permitted in native paths.
// To achieve uniformity we apply a percent encoding to the "raw" names.
name_ = QString(QByteArray(asciiName).toPercentEncoding());
name = QString(QByteArray(asciiName).toPercentEncoding());

// The cached found lump number is no longer valid.
lumpNum_ = -2;
}

String PatchName::name() const {
return name_;
String PatchName::percentEncodedName() const {
return name;
}

String const &PatchName::nameRef() const {
return name_;
String const &PatchName::percentEncodedNameRef() const {
return name;
}

} // namespace de

0 comments on commit 8c28298

Please sign in to comment.