Skip to content

Commit

Permalink
Fixed|Model Renderer: Use model's atlas when drawing; fixed shutdown …
Browse files Browse the repository at this point in the history
…crash

Also removed the default textures, since they would have to be allocated
separately for each model, in the model's alloc group. Now that
the shader can be changed, there is no reason to have optional
textures: if a texture is missing, a warning will be logged.
  • Loading branch information
skyjake committed Oct 26, 2015
1 parent 7553e08 commit 92e05b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions doomsday/apps/client/src/render/model.cpp
Expand Up @@ -44,6 +44,9 @@ Model::AnimSequence::AnimSequence(String const &name, Record const &def)

Model::~Model()
{
// The commit group will be deleted now.
unsetAtlas();

qDeleteAll(timelines.values());
}

Expand Down
14 changes: 8 additions & 6 deletions doomsday/apps/client/src/render/modelrenderer.cpp
Expand Up @@ -89,7 +89,7 @@ DENG2_PIMPL(ModelRenderer)

MultiAtlas atlasPool { *this };

struct DefaultTextures
/*struct DefaultTextures
{
Id diffuse { Id::None };
Id normals { Id::None };
Expand Down Expand Up @@ -118,7 +118,7 @@ DENG2_PIMPL(ModelRenderer)
specular = atlas.alloc(img);
}
};
QHash<Atlas const *, DefaultTextures> defaultTextures;
QHash<Atlas const *, DefaultTextures> defaultTextures;*/

filesys::AssetObserver observer { "model\\..*" };
ModelBank bank { [] () -> ModelDrawable * { return new render::Model; } };
Expand Down Expand Up @@ -152,7 +152,7 @@ DENG2_PIMPL(ModelRenderer)
bank.unloadAll(Bank::ImmediatelyInCurrentThread);

atlasPool.clear();
defaultTextures.clear();
//defaultTextures.clear();
unloadProgram(*programs[SHADER_DEFAULT]);
}

Expand All @@ -166,7 +166,7 @@ DENG2_PIMPL(ModelRenderer)
atlas->setMarginSize(0);

// The default textures are present on each atlas.
defaultTextures[atlas].alloc(*atlas);
//defaultTextures[atlas].alloc(*atlas);

return atlas;
}
Expand Down Expand Up @@ -256,13 +256,13 @@ DENG2_PIMPL(ModelRenderer)

model.setAtlas(*model.textures);

DENG2_ASSERT(defaultTextures.contains(model.textures->atlas()));
/*DENG2_ASSERT(defaultTextures.contains(model.textures->atlas()));
DefaultTextures &defaults = defaultTextures[model.textures->atlas()];
model.setDefaultTexture(ModelDrawable::Diffuse, defaults.diffuse);
model.setDefaultTexture(ModelDrawable::Normals, defaults.normals);
model.setDefaultTexture(ModelDrawable::Emissive, defaults.emission);
model.setDefaultTexture(ModelDrawable::Specular, defaults.specular);
model.setDefaultTexture(ModelDrawable::Specular, defaults.specular);*/
}

static gl::Blend textToBlendFunc(String const &text)
Expand Down Expand Up @@ -615,6 +615,8 @@ DENG2_PIMPL(ModelRenderer)
template <typename Params> // generic to accommodate psprites and vispsprites
void draw(Params const &p)
{
uTex = static_cast<AtlasTexture const *>(p.model->textures->atlas());

p.model->draw(&p.animator->appearance(), p.animator);
}
};
Expand Down

0 comments on commit 92e05b2

Please sign in to comment.