Skip to content

Commit

Permalink
Refactor|Model Renderer: Revised definition syntax for state triggers
Browse files Browse the repository at this point in the history
It is more intuitive if the state is the parent record. Multiple
possible sequences can be defined per state (maybe with different
probabilities). One sequence may also be used in several states.
  • Loading branch information
skyjake committed Aug 3, 2014
1 parent 4e47346 commit ac82fdc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
5 changes: 2 additions & 3 deletions doomsday/client/net.dengine.client.pack/testmodel.pack/Info
Expand Up @@ -7,9 +7,8 @@ asset model.thing.possessed {
path = "boblampclean.md5mesh"

group animation {
sequence "#0" {
state = POSS_STND
timeline <0, 5, 10>
state POSS_STND {
sequence "#0" { timeline <0, 5, 10> }
}
}
}
20 changes: 15 additions & 5 deletions doomsday/client/src/render/modelrenderer.cpp
Expand Up @@ -75,15 +75,25 @@ DENG2_PIMPL(ModelRenderer)
// Prepare the animations for the model.
QScopedPointer<StateAnims> anims(new StateAnims);

Record const &animDef = asset.accessedRecord().subrecord(DEF_ANIMATION);
Record::Subrecords subs = animDef.subrecords();
// TODO: Add a utility method for getting subrecords of particular type (ScriptedInfo).

Record::Subrecords subs = asset.accessedRecord().subrecord(DEF_ANIMATION).subrecords();

DENG2_FOR_EACH_CONST(Record::Subrecords, i, subs)
{
// Is this an animation sequence?
Record const &def = *i.value();
if(def.gets("__type__", "") == "sequence" && def.has("state"))
if(def.gets("__type__", "") == "state")
{
(*anims)[def.gets("state")] << AnimSequence(i.key(), def);
Record::Subrecords seqs = def.accessedRecord().subrecords();

DENG2_FOR_EACH_CONST(Record::Subrecords, s, seqs)
{
Record const &seqDef = *s.value();
if(seqDef.gets("__type__", "") == "sequence")
{
(*anims)[i.key()] << AnimSequence(s.key(), seqDef);
}
}
}
}

Expand Down

0 comments on commit ac82fdc

Please sign in to comment.