Implemented Animation Clip asset and animation controller #410
|
@ -154,6 +154,56 @@ namespace SHADE
|
|||
node.Free();
|
||||
}
|
||||
|
||||
void SHAnimationController::AddTransition(Handle<Node> source, const Transition& transition)
|
||||
{
|
||||
if (!source)
|
||||
{
|
||||
SHLOG_ERROR("[SHAnimationController] Attempted to add transition from an invalid node.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!transition.Target)
|
||||
{
|
||||
SHLOG_ERROR("[SHAnimationController] Attempted to add transition to an invalid node.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (transition.Condition != Transition::ConditionType::None && !parameters.contains(transition.ParamName))
|
||||
{
|
||||
SHLOG_ERROR("[SHAnimationController] Attempted to add a conditional transition for an invalid parameter.");
|
||||
return;
|
||||
}
|
||||
|
||||
source->Transitions.emplace_back(transition);
|
||||
}
|
||||
void SHAnimationController::AddParameter(const std::string& name, AnimParam::Type type)
|
||||
{
|
||||
if (name.empty())
|
||||
{
|
||||
SHLOG_ERROR("[SHAnimationController] Attempted to add a parameter with no name.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (parameters.contains(name))
|
||||
{
|
||||
SHLOG_ERROR("[SHAnimationController] Attempted to add a parameter with the same name.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Insert
|
||||
parameters.emplace(name, type);
|
||||
}
|
||||
void SHAnimationController::RemoveParameter(const std::string& name)
|
||||
{
|
||||
if (!parameters.contains(name))
|
||||
{
|
||||
SHLOG_ERROR("[SHAnimationController] Attempted to reemove a parameter that does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
parameters.erase(name);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Helper Functions */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -167,8 +167,24 @@ namespace SHADE
|
|||
/// </summary>
|
||||
/// <param name="node">Node to destroy.</param>
|
||||
void DestroyNode(Handle<Node> node);
|
||||
/// <summary>
|
||||
/// Links two nodes together with a Transition. This performs some additional
|
||||
/// checking to ensure parameters are valid.
|
||||
/// </summary>
|
||||
/// <param name="source">Source node to transition from.</param>
|
||||
/// <param name="transition">Describes the transition to add.</param>
|
||||
void AddTransition(Handle<Node> source, const Transition& transition);
|
||||
/// <summary>
|
||||
/// Registers a parameter to the animation controller.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the parameter.</param>
|
||||
/// <param name="type">Type of the parameter.</param>
|
||||
void AddParameter(const std::string& name, AnimParam::Type type);
|
||||
/// <summary>
|
||||
/// Removes a parameter from the animation controller.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the parameter.</param>
|
||||
void RemoveParameter(const std::string& name);
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Getters */
|
||||
|
|
Loading…
Reference in New Issue