Skip to content

Commit

Permalink
Model Renderer: Meshes are identified using "@(number)" or "name"
Browse files Browse the repository at this point in the history
Similar to materials.
  • Loading branch information
skyjake committed Aug 9, 2015
1 parent d6ce5dc commit 6587505
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion doomsday/apps/client/src/render/modelrenderer.cpp
Expand Up @@ -296,7 +296,10 @@ DENG2_PIMPL(ModelRenderer)
pass.meshes.resize(model.meshCount());
for(Value const *value : def.geta(DEF_MESHES).elements())
{
pass.meshes.setBit(value->asInt(), true);
int meshId = identifierFromText(value->asText(), [&model] (String const &text) {
return model.meshId(text);
});
pass.meshes.setBit(meshId, true);
}
if(def.has(DEF_BLENDFUNC))
{
Expand Down
9 changes: 9 additions & 0 deletions doomsday/sdk/libgui/include/de/graphics/modeldrawable.h
Expand Up @@ -281,6 +281,15 @@ class LIBGUI_PUBLIC ModelDrawable : public AssetGroup

int meshCount() const;

/**
* Returns the number of the mesh with the given name.
*
* @param name Mesh name.
*
* @return Mesh id, or -1 if no mesh with that name exists.
*/
int meshId(String const &name) const;

/**
* Locates a material specified in the model by its name.
*
Expand Down
13 changes: 13 additions & 0 deletions doomsday/sdk/libgui/src/graphics/modeldrawable.cpp
Expand Up @@ -1224,6 +1224,19 @@ int ModelDrawable::meshCount() const
return d->scene->mNumMeshes;
}

int ModelDrawable::meshId(String const &name) const
{
if(!d->scene) return -1;
for(int i = 0; i < d->scene->mNumMeshes; ++i)
{
if(name == d->scene->mMeshes[i]->mName.C_Str())
{
return i;
}
}
return -1;
}

bool ModelDrawable::nodeExists(String const &name) const
{
return d->nodeNameToPtr.contains(name);
Expand Down

0 comments on commit 6587505

Please sign in to comment.