Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Commit

Permalink
AnimationState: unsigned to signed
Browse files Browse the repository at this point in the history
  • Loading branch information
1vanK committed Sep 2, 2022
1 parent 212c4d8 commit 90dfc4e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 36 deletions.
20 changes: 10 additions & 10 deletions Source/Urho3D/AngelScript/Generated_Members.h
Original file line number Diff line number Diff line change
Expand Up @@ -7638,8 +7638,8 @@ template <class T> void RegisterMembers_AnimationState(asIScriptEngine* engine,
engine->RegisterObjectMethod(className, "AnimationBlendMode GetBlendMode() const", AS_METHODPR(T, GetBlendMode, () const, AnimationBlendMode), AS_CALL_THISCALL);
engine->RegisterObjectMethod(className, "AnimationBlendMode get_blendMode() const", AS_METHODPR(T, GetBlendMode, () const, AnimationBlendMode), AS_CALL_THISCALL);

// float AnimationState::GetBoneWeight(unsigned index) const
engine->RegisterObjectMethod(className, "float GetBoneWeight(uint) const", AS_METHODPR(T, GetBoneWeight, (unsigned) const, float), AS_CALL_THISCALL);
// float AnimationState::GetBoneWeight(i32 index) const
engine->RegisterObjectMethod(className, "float GetBoneWeight(int) const", AS_METHODPR(T, GetBoneWeight, (i32) const, float), AS_CALL_THISCALL);

// float AnimationState::GetBoneWeight(const String& name) const
engine->RegisterObjectMethod(className, "float GetBoneWeight(const String&in) const", AS_METHODPR(T, GetBoneWeight, (const String&) const, float), AS_CALL_THISCALL);
Expand Down Expand Up @@ -7672,14 +7672,14 @@ template <class T> void RegisterMembers_AnimationState(asIScriptEngine* engine,
engine->RegisterObjectMethod(className, "float GetTime() const", AS_METHODPR(T, GetTime, () const, float), AS_CALL_THISCALL);
engine->RegisterObjectMethod(className, "float get_time() const", AS_METHODPR(T, GetTime, () const, float), AS_CALL_THISCALL);

// unsigned AnimationState::GetTrackIndex(Node* node) const
engine->RegisterObjectMethod(className, "uint GetTrackIndex(Node@+) const", AS_METHODPR(T, GetTrackIndex, (Node*) const, unsigned), AS_CALL_THISCALL);
// i32 AnimationState::GetTrackIndex(Node* node) const
engine->RegisterObjectMethod(className, "int GetTrackIndex(Node@+) const", AS_METHODPR(T, GetTrackIndex, (Node*) const, i32), AS_CALL_THISCALL);

// unsigned AnimationState::GetTrackIndex(const String& name) const
engine->RegisterObjectMethod(className, "uint GetTrackIndex(const String&in) const", AS_METHODPR(T, GetTrackIndex, (const String&) const, unsigned), AS_CALL_THISCALL);
// i32 AnimationState::GetTrackIndex(const String& name) const
engine->RegisterObjectMethod(className, "int GetTrackIndex(const String&in) const", AS_METHODPR(T, GetTrackIndex, (const String&) const, i32), AS_CALL_THISCALL);

// unsigned AnimationState::GetTrackIndex(StringHash nameHash) const
engine->RegisterObjectMethod(className, "uint GetTrackIndex(StringHash) const", AS_METHODPR(T, GetTrackIndex, (StringHash) const, unsigned), AS_CALL_THISCALL);
// i32 AnimationState::GetTrackIndex(StringHash nameHash) const
engine->RegisterObjectMethod(className, "int GetTrackIndex(StringHash) const", AS_METHODPR(T, GetTrackIndex, (StringHash) const, i32), AS_CALL_THISCALL);

// float AnimationState::GetWeight() const
engine->RegisterObjectMethod(className, "float GetWeight() const", AS_METHODPR(T, GetWeight, () const, float), AS_CALL_THISCALL);
Expand All @@ -7697,8 +7697,8 @@ template <class T> void RegisterMembers_AnimationState(asIScriptEngine* engine,
engine->RegisterObjectMethod(className, "void SetBlendMode(AnimationBlendMode)", AS_METHODPR(T, SetBlendMode, (AnimationBlendMode), void), AS_CALL_THISCALL);
engine->RegisterObjectMethod(className, "void set_blendMode(AnimationBlendMode)", AS_METHODPR(T, SetBlendMode, (AnimationBlendMode), void), AS_CALL_THISCALL);

// void AnimationState::SetBoneWeight(unsigned index, float weight, bool recursive = false)
engine->RegisterObjectMethod(className, "void SetBoneWeight(uint, float, bool = false)", AS_METHODPR(T, SetBoneWeight, (unsigned, float, bool), void), AS_CALL_THISCALL);
// void AnimationState::SetBoneWeight(i32 index, float weight, bool recursive = false)
engine->RegisterObjectMethod(className, "void SetBoneWeight(int, float, bool = false)", AS_METHODPR(T, SetBoneWeight, (i32, float, bool), void), AS_CALL_THISCALL);

// void AnimationState::SetBoneWeight(const String& name, float weight, bool recursive = false)
engine->RegisterObjectMethod(className, "void SetBoneWeight(const String&in, float, bool = false)", AS_METHODPR(T, SetBoneWeight, (const String&, float, bool), void), AS_CALL_THISCALL);
Expand Down
37 changes: 20 additions & 17 deletions Source/Urho3D/Graphics/AnimationState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ void AnimationState::SetTime(float time)
}
}

void AnimationState::SetBoneWeight(unsigned index, float weight, bool recursive)
void AnimationState::SetBoneWeight(i32 index, float weight, bool recursive)
{
if (index >= stateTracks_.Size())
assert(index >= 0 || index == NINDEX);

if (index >= stateTracks_.Size() || index == NINDEX)
return;

weight = Clamp(weight, 0.0f, 1.0f);
Expand All @@ -203,10 +205,10 @@ void AnimationState::SetBoneWeight(unsigned index, float weight, bool recursive)
if (boneNode)
{
const Vector<SharedPtr<Node>>& children = boneNode->GetChildren();
for (unsigned i = 0; i < children.Size(); ++i)
for (i32 i = 0; i < children.Size(); ++i)
{
unsigned childTrackIndex = GetTrackIndex(children[i]);
if (childTrackIndex != M_MAX_UNSIGNED)
i32 childTrackIndex = GetTrackIndex(children[i]);
if (childTrackIndex != NINDEX)
SetBoneWeight(childTrackIndex, weight, true);
}
}
Expand Down Expand Up @@ -367,9 +369,10 @@ Bone* AnimationState::GetStartBone() const
return model_ ? startBone_ : nullptr;
}

float AnimationState::GetBoneWeight(unsigned index) const
float AnimationState::GetBoneWeight(i32 index) const
{
return index < stateTracks_.Size() ? stateTracks_[index].weight_ : 0.0f;
assert(index >= 0 || index == NINDEX);
return (index != NINDEX && index < stateTracks_.Size()) ? stateTracks_[index].weight_ : 0.0f;
}

float AnimationState::GetBoneWeight(const String& name) const
Expand All @@ -382,39 +385,39 @@ float AnimationState::GetBoneWeight(StringHash nameHash) const
return GetBoneWeight(GetTrackIndex(nameHash));
}

unsigned AnimationState::GetTrackIndex(const String& name) const
i32 AnimationState::GetTrackIndex(const String& name) const
{
for (unsigned i = 0; i < stateTracks_.Size(); ++i)
for (i32 i = 0; i < stateTracks_.Size(); ++i)
{
Node* node = stateTracks_[i].node_;
if (node && node->GetName() == name)
return i;
}

return M_MAX_UNSIGNED;
return NINDEX;
}

unsigned AnimationState::GetTrackIndex(Node* node) const
i32 AnimationState::GetTrackIndex(Node* node) const
{
for (unsigned i = 0; i < stateTracks_.Size(); ++i)
for (i32 i = 0; i < stateTracks_.Size(); ++i)
{
if (stateTracks_[i].node_ == node)
return i;
}

return M_MAX_UNSIGNED;
return NINDEX;
}

unsigned AnimationState::GetTrackIndex(StringHash nameHash) const
i32 AnimationState::GetTrackIndex(StringHash nameHash) const
{
for (unsigned i = 0; i < stateTracks_.Size(); ++i)
for (i32 i = 0; i < stateTracks_.Size(); ++i)
{
Node* node = stateTracks_[i].node_;
if (node && node->GetNameHash() == nameHash)
return i;
}

return M_MAX_UNSIGNED;
return NINDEX;
}

float AnimationState::GetLength() const
Expand Down Expand Up @@ -467,7 +470,7 @@ void AnimationState::ApplyTrack(AnimationStateTrack& stateTrack, float weight, b
track->GetKeyFrameIndex(time_, frame);

// Check if next frame to interpolate to is valid, or if wrapping is needed (looping animation only)
unsigned nextFrame = frame + 1;
i32 nextFrame = frame + 1;
bool interpolate = true;
if (nextFrame >= track->keyFrames_.Size())
{
Expand Down
18 changes: 9 additions & 9 deletions Source/Urho3D/Graphics/AnimationState.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class URHO3D_API AnimationState : public RefCounted
/// @property
void SetTime(float time);
/// Set per-bone blending weight by track index. Default is 1.0 (full), is multiplied with the state's blending weight when applying the animation. Optionally recurses to child bones.
void SetBoneWeight(unsigned index, float weight, bool recursive = false);
void SetBoneWeight(i32 index, float weight, bool recursive = false);
/// Set per-bone blending weight by name.
void SetBoneWeight(const String& name, float weight, bool recursive = false);
/// Set per-bone blending weight by name hash.
Expand All @@ -88,7 +88,7 @@ class URHO3D_API AnimationState : public RefCounted
void AddTime(float delta);
/// Set blending layer.
/// @property
void SetLayer(unsigned char layer);
void SetLayer(unsigned char layer); // TODO: i8?

/// Return animation.
/// @property
Expand All @@ -104,18 +104,18 @@ class URHO3D_API AnimationState : public RefCounted
/// @property
Bone* GetStartBone() const;
/// Return per-bone blending weight by track index.
float GetBoneWeight(unsigned index) const;
float GetBoneWeight(i32 index) const;
/// Return per-bone blending weight by name.
/// @property{get_boneWeights}
float GetBoneWeight(const String& name) const;
/// Return per-bone blending weight by name.
float GetBoneWeight(StringHash nameHash) const;
/// Return track index with matching bone node, or M_MAX_UNSIGNED if not found.
unsigned GetTrackIndex(Node* node) const;
/// Return track index by bone name, or M_MAX_UNSIGNED if not found.
unsigned GetTrackIndex(const String& name) const;
/// Return track index by bone name hash, or M_MAX_UNSIGNED if not found.
unsigned GetTrackIndex(StringHash nameHash) const;
/// Return track index with matching bone node, or NINDEX if not found.
i32 GetTrackIndex(Node* node) const;
/// Return track index by bone name, or NINDEX if not found.
i32 GetTrackIndex(const String& name) const;
/// Return track index by bone name hash, or NINDEX if not found.
i32 GetTrackIndex(StringHash nameHash) const;

/// Return whether weight is nonzero.
/// @property
Expand Down

0 comments on commit 90dfc4e

Please sign in to comment.