Skip to content

Commit

Permalink
Changes missing from the previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jan 10, 2013
1 parent d0dae26 commit 62fc413
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 33 deletions.
8 changes: 4 additions & 4 deletions doomsday/engine/include/def_main.h
Expand Up @@ -102,10 +102,10 @@ ded_sky_t* Def_GetSky(const char* id);
ded_material_t* Def_GetMaterial(const char* uri);
ded_compositefont_t* Def_GetCompositeFont(const char* uri);
ded_light_t* Def_GetLightDef(int spr, int frame);
ded_decor_t* Def_GetDecoration(material_t *mat, boolean hasExternal, boolean isCustom);
ded_reflection_t* Def_GetReflection(material_t *mat, boolean hasExternal, boolean isCustom);
ded_detailtexture_t* Def_GetDetailTex(material_t *mat, boolean hasExternal, boolean isCustom);
ded_ptcgen_t* Def_GetGenerator(material_t *mat, boolean hasExternal, boolean isCustom);
ded_decor_t* Def_GetDecoration(Uri const *uri, boolean hasExternal, boolean isCustom);
ded_reflection_t* Def_GetReflection(Uri const *uri, boolean hasExternal, boolean isCustom);
ded_detailtexture_t* Def_GetDetailTex(Uri const *uri, boolean hasExternal, boolean isCustom);
ded_ptcgen_t* Def_GetGenerator(Uri const *uri, boolean hasExternal, boolean isCustom);
ded_ptcgen_t* Def_GetDamageGenerator(int mobjType);

int Def_EvalFlags(char* string);
Expand Down
3 changes: 1 addition & 2 deletions doomsday/engine/include/resource/materials.h
Expand Up @@ -292,8 +292,7 @@ class Materials
*/
material_t *newFromDef(ded_material_t &def);

MaterialManifest &newManifest(MaterialScheme &scheme, Path const &path,
material_t *material = 0);
MaterialManifest &newManifest(MaterialScheme &scheme, Path const &path);

/**
* Prepare a material variant specification in accordance to the specified
Expand Down
32 changes: 13 additions & 19 deletions doomsday/engine/src/def_main.cpp
Expand Up @@ -468,16 +468,15 @@ ded_compositefont_t* Def_GetCompositeFont(char const* uriCString)
return def;
}

ded_decor_t *Def_GetDecoration(material_t *mat, boolean hasExternal, boolean isCustom)
ded_decor_t *Def_GetDecoration(uri_s const *uri, boolean hasExternal, boolean isCustom)
{
DENG_ASSERT(mat);
DENG_ASSERT(uri);

de::Uri uri = Material_Manifest(mat).composeUri();
ded_decor_t *def;
int i;
for(i = defs.count.decorations.num - 1, def = defs.decorations + i; i >= 0; i--, def--)
{
if(def->material && Uri_Equality(def->material, reinterpret_cast<uri_s *>(&uri)))
if(def->material && Uri_Equality(def->material, uri))
{
// Is this suitable?
if(Def_IsAllowedDecoration(def, hasExternal, isCustom))
Expand All @@ -487,16 +486,15 @@ ded_decor_t *Def_GetDecoration(material_t *mat, boolean hasExternal, boolean isC
return 0; // None found.
}

ded_reflection_t *Def_GetReflection(material_t *mat, boolean hasExternal, boolean isCustom)
ded_reflection_t *Def_GetReflection(uri_s const *uri, boolean hasExternal, boolean isCustom)
{
DENG_ASSERT(mat);
DENG_ASSERT(uri);

de::Uri uri = Material_Manifest(mat).composeUri();
ded_reflection_t *def;
int i;
for(i = defs.count.reflections.num - 1, def = defs.reflections + i; i >= 0; i--, def--)
{
if(def->material && Uri_Equality(def->material, reinterpret_cast<uri_s *>(&uri)))
if(def->material && Uri_Equality(def->material, uri))
{
// Is this suitable?
if(Def_IsAllowedReflection(def, hasExternal, isCustom))
Expand All @@ -506,23 +504,22 @@ ded_reflection_t *Def_GetReflection(material_t *mat, boolean hasExternal, boolea
return 0; // None found.
}

ded_detailtexture_t *Def_GetDetailTex(material_t *mat, boolean hasExternal, boolean isCustom)
ded_detailtexture_t *Def_GetDetailTex(uri_s const *uri, boolean hasExternal, boolean isCustom)
{
DENG_ASSERT(mat);
DENG_ASSERT(uri);

de::Uri uri = Material_Manifest(mat).composeUri();
ded_detailtexture_t *def;
int i;
for(i = defs.count.details.num - 1, def = defs.details + i; i >= 0; i--, def--)
{
if(def->material1 && Uri_Equality(def->material1, reinterpret_cast<uri_s *>(&uri)))
if(def->material1 && Uri_Equality(def->material1, uri))
{
// Is this suitable?
if(Def_IsAllowedDetailTex(def, hasExternal, isCustom))
return def;
}

if(def->material2 && Uri_Equality(def->material2, reinterpret_cast<uri_s *>(&uri)))
if(def->material2 && Uri_Equality(def->material2, uri))
{
// Is this suitable?
if(Def_IsAllowedDetailTex(def, hasExternal, isCustom))
Expand All @@ -532,22 +529,19 @@ ded_detailtexture_t *Def_GetDetailTex(material_t *mat, boolean hasExternal, bool
return 0; // None found.
}

ded_ptcgen_t* Def_GetGenerator(material_t *mat, boolean hasExternal, boolean isCustom)
ded_ptcgen_t* Def_GetGenerator(uri_s const *uri, boolean hasExternal, boolean isCustom)
{
DENG_ASSERT(mat);
DENG_ASSERT(uri);
DENG_UNUSED(hasExternal); DENG_UNUSED(isCustom);

de::Uri uri = Material_Manifest(mat).composeUri();
ded_ptcgen_t *def = defs.ptcGens;
for(int i = 0; i < defs.count.ptcGens.num; ++i, def++)
{
if(!def->material) continue;

// Is this suitable?
if(Uri_Equality(def->material, reinterpret_cast<uri_s *>(&uri)))
{
if(Uri_Equality(def->material, uri))
return def;
}

#ifdef LIBDENG_OLD_MATERIAL_ANIM_METHOD
if(def->flags & PGF_GROUP)
Expand Down
19 changes: 11 additions & 8 deletions doomsday/engine/src/resource/materialmanifest.cpp
Expand Up @@ -128,21 +128,24 @@ void MaterialManifest::setMaterial(material_t *newMaterial)

void MaterialManifest::linkDefinitions()
{
Uri _uri = composeUri();
uri_s *uri = reinterpret_cast<uri_s *>(&_uri);

// Surface decorations (lights and models).
d->defs.decors[0] = Def_GetDecoration(d->material, 0, d->isCustom);
d->defs.decors[1] = Def_GetDecoration(d->material, 1, d->isCustom);
d->defs.decors[0] = Def_GetDecoration(uri, 0, d->isCustom);
d->defs.decors[1] = Def_GetDecoration(uri, 1, d->isCustom);

// Reflection (aka shiny surface).
d->defs.reflections[0] = Def_GetReflection(d->material, 0, d->isCustom);
d->defs.reflections[1] = Def_GetReflection(d->material, 1, d->isCustom);
d->defs.reflections[0] = Def_GetReflection(uri, 0, d->isCustom);
d->defs.reflections[1] = Def_GetReflection(uri, 1, d->isCustom);

// Generator (particles).
d->defs.ptcgens[0] = Def_GetGenerator(d->material, 0, d->isCustom);
d->defs.ptcgens[1] = Def_GetGenerator(d->material, 1, d->isCustom);
d->defs.ptcgens[0] = Def_GetGenerator(uri, 0, d->isCustom);
d->defs.ptcgens[1] = Def_GetGenerator(uri, 1, d->isCustom);

// Detail texture.
d->defs.detailtextures[0] = Def_GetDetailTex(d->material, 0, d->isCustom);
d->defs.detailtextures[1] = Def_GetDetailTex(d->material, 1, d->isCustom);
d->defs.detailtextures[0] = Def_GetDetailTex(uri, 0, d->isCustom);
d->defs.detailtextures[1] = Def_GetDetailTex(uri, 1, d->isCustom);
}

void MaterialManifest::clearDefinitionLinks()
Expand Down

0 comments on commit 62fc413

Please sign in to comment.