Skip to content

Commit

Permalink
Added Animation::GetTrack(unsigned)
Browse files Browse the repository at this point in the history
  • Loading branch information
stardustgarden committed Mar 22, 2017
1 parent c896983 commit 0059972
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
17 changes: 17 additions & 0 deletions Source/Urho3D/Graphics/Animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,25 @@ SharedPtr<Animation> Animation::Clone(const String& cloneName) const
ret->SetMemoryUse(GetMemoryUse());

return ret;
}

AnimationTrack* Animation::GetTrack(unsigned index)
{
index = (index < 0) || (index > tracks_.Size() - 1) ? 0 : index;

int j = 0;
for(HashMap<StringHash, AnimationTrack>::Iterator i = tracks_.Begin(); i != tracks_.End(); ++i)
{
if (j == index)
return &i->second_;

++j;
}

return (AnimationTrack*)0;
}


AnimationTrack* Animation::GetTrack(const String& name)
{
HashMap<StringHash, AnimationTrack>::Iterator i = tracks_.Find(StringHash(name));
Expand Down
5 changes: 4 additions & 1 deletion Source/Urho3D/Graphics/Animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ class URHO3D_API Animation : public Resource
const HashMap<StringHash, AnimationTrack>& GetTracks() const { return tracks_; }

/// Return number of animation tracks.
unsigned GetNumTracks() const { return tracks_.Size(); }
unsigned GetNumTracks() const { return tracks_.Size(); }

/// Return animation track by index.
AnimationTrack *GetTrack(unsigned index);

/// Return animation track by name.
AnimationTrack* GetTrack(const String& name);
Expand Down
3 changes: 2 additions & 1 deletion Source/Urho3D/LuaScript/pkgs/Graphics/Animation.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class Animation : public Resource
float GetLength() const;
unsigned GetNumTracks() const;
AnimationTrack* GetTrack(const String name);
AnimationTrack* GetTrack(StringHash nameHash);
AnimationTrack* GetTrack(StringHash nameHash);
AnimationTrack* GetTrack(unsigned index);
unsigned GetNumTriggers() const;
AnimationTriggerPoint* GetTrigger(unsigned index);

Expand Down

0 comments on commit 0059972

Please sign in to comment.