U3D
Open-source, cross-platform 2D and 3D game engine built in C++
Loading...
Searching...
No Matches
Urho3D::IKSolver Class Reference

Marks the root or "beginning" of an IK chain or multiple IK chains. The solving algorithm can be set along with other solver related parameters. The IK problem is solved starting from the node this component is attached to and ending at all nodes that have an IKEffector component attached. More...

#include </var/dev/u3d/stable/Source/Urho3D/IK/IKSolver.h>

Inheritance diagram for Urho3D::IKSolver:
[legend]
Collaboration diagram for Urho3D::IKSolver:
[legend]

Public Types

enum  Algorithm { ONE_BONE = 0 , TWO_BONE , FABRIK }
 
enum  Feature {
  JOINT_ROTATIONS = 0x01 , TARGET_ROTATIONS = 0x02 , UPDATE_ORIGINAL_POSE = 0x04 , UPDATE_ACTIVE_POSE = 0x08 ,
  USE_ORIGINAL_POSE = 0x10 , CONSTRAINTS = 0x20 , AUTO_SOLVE = 0x40
}
 

Public Member Functions

 IKSolver (Context *context)
 Construct an IK root component.
 
 ~IKSolver () override
 Default destructor.
 
Algorithm GetAlgorithm () const
 
void SetAlgorithm (Algorithm algorithm)
 Selects the solver algorithm. Default is FABRIK. Note that this may not be the most efficient algorithm available. The specialized solvers will be a lot faster. More...
 
bool GetFeature (Feature feature) const
 
void SetFeature (Feature feature, bool enable)
 
unsigned GetMaximumIterations () const
 
void SetMaximumIterations (unsigned iterations)
 Sets the maximum number of iterations the solver is allowed to perform before applying the result. More...
 
float GetTolerance () const
 
void SetTolerance (float tolerance)
 Sets the distance at which the effector is "close enough" to the target node, at which point the algorithm will stop iterating. More...
 
void RebuildChainTrees ()
 Updates the solver's internal data structures, which is required whenever the tree is modified in any way (e.g. adding or removing nodes, adding or removing effectors, etc.). More...
 
void RecalculateSegmentLengths ()
 Unusual, but if you have a tree with translational motions such that the distances between nodes changes (perhaps a slider?), you can call this to recalculate the segment lengths after assigning new positions to the nodes. More...
 
void CalculateJointRotations ()
 Skinned models require joint rotations to be calculated so skinning works correctly. This is automatically enabled by default with the feature flag JOINT_ROTATIONS.
 
void Solve ()
 Invokes the solver. The solution is applied back to the scene graph automatically. More...
 
void ApplyOriginalPoseToScene ()
 
void ApplySceneToOriginalPose ()
 
void ApplyActivePoseToScene ()
 
void ApplySceneToActivePose ()
 
void ApplyOriginalPoseToActivePose ()
 
void DrawDebugGeometry (bool depthTest)
 
void DrawDebugGeometry (DebugRenderer *debug, bool depthTest) override
 Visualize the component as debug geometry. More...
 
bool GetJOINT_ROTATIONS () const
 
bool GetTARGET_ROTATIONS () const
 
bool GetUPDATE_ORIGINAL_POSE () const
 
bool GetUPDATE_ACTIVE_POSE () const
 
bool GetUSE_ORIGINAL_POSE () const
 
bool GetCONSTRAINTS () const
 
bool GetAUTO_SOLVE () const
 
void SetJOINT_ROTATIONS (bool enable)
 
void SetTARGET_ROTATIONS (bool enable)
 
void SetUPDATE_ORIGINAL_POSE (bool enable)
 
void SetUPDATE_ACTIVE_POSE (bool enable)
 
void SetUSE_ORIGINAL_POSE (bool enable)
 
void SetCONSTRAINTS (bool enable)
 
void SetAUTO_SOLVE (bool enable)
 
- Public Member Functions inherited from Urho3D::Component
 Component (Context *context)
 Construct.
 
 ~Component () override
 Destruct.
 
virtual void OnSetEnabled ()
 Handle enabled/disabled state change. More...
 
bool Save (Serializer &dest) const override
 Save as binary data. Return true if successful. More...
 
bool SaveXML (XMLElement &dest) const override
 Save as XML data. Return true if successful. More...
 
bool SaveJSON (JSONValue &dest) const override
 Save as JSON data. Return true if successful. More...
 
void MarkNetworkUpdate () override
 Mark for attribute check on the next network update. More...
 
virtual void GetDependencyNodes (PODVector< Node * > &dest)
 Return the depended on nodes to order network updates. More...
 
virtual void DrawDebugGeometry (DebugRenderer *debug, bool depthTest)
 Visualize the component as debug geometry. More...
 
void SetEnabled (bool enable)
 
void Remove ()
 Remove from the scene node. If no other shared pointer references exist, causes immediate deletion.
 
unsigned GetID () const
 
bool IsReplicated () const
 
NodeGetNode () const
 
SceneGetScene () const
 Return the scene the node belongs to.
 
bool IsEnabled () const
 
bool IsEnabledEffective () const
 
ComponentGetComponent (StringHash type) const
 Return component in the same scene node by type. If there are several, returns the first.
 
void GetComponents (PODVector< Component * > &dest, StringHash type) const
 Return components in the same scene node by type.
 
template<class T >
T * GetComponent () const
 Template version of returning a component in the same scene node by type.
 
template<class T >
void GetComponents (PODVector< T * > &dest) const
 Template version of returning components in the same scene node by type.
 
void AddReplicationState (ComponentReplicationState *state)
 Add a replication state that is tracking this component.
 
void PrepareNetworkUpdate ()
 Prepare network update by comparing attributes and marking replication states dirty as necessary.
 
void CleanupConnection (Connection *connection)
 
- Public Member Functions inherited from Urho3D::Animatable
 Animatable (Context *context)
 Construct.
 
 ~Animatable () override
 Destruct.
 
bool LoadXML (const XMLElement &source) override
 Load from XML data. Return true if successful. More...
 
bool SaveXML (XMLElement &dest) const override
 Save as XML data. Return true if successful. More...
 
bool LoadJSON (const JSONValue &source) override
 Load from JSON data. Return true if successful. More...
 
bool SaveJSON (JSONValue &dest) const override
 Save as JSON data. Return true if successful. More...
 
void SetAnimationEnabled (bool enable)
 
void SetAnimationTime (float time)
 Set time position of all attribute animations or an object animation manually. Automatic update should be disabled in this case.
 
void SetObjectAnimation (ObjectAnimation *objectAnimation)
 
void SetAttributeAnimation (const String &name, ValueAnimation *attributeAnimation, WrapMode wrapMode=WM_LOOP, float speed=1.0f)
 Set attribute animation.
 
void SetAttributeAnimationWrapMode (const String &name, WrapMode wrapMode)
 Set attribute animation wrap mode.
 
void SetAttributeAnimationSpeed (const String &name, float speed)
 Set attribute animation speed.
 
void SetAttributeAnimationTime (const String &name, float time)
 Set attribute animation time position manually. Automatic update should be disabled in this case.
 
void RemoveObjectAnimation ()
 Remove object animation. Same as calling SetObjectAnimation with a null pointer.
 
void RemoveAttributeAnimation (const String &name)
 Remove attribute animation. Same as calling SetAttributeAnimation with a null pointer.
 
bool GetAnimationEnabled () const
 
ObjectAnimationGetObjectAnimation () const
 
ValueAnimationGetAttributeAnimation (const String &name) const
 Return attribute animation.
 
WrapMode GetAttributeAnimationWrapMode (const String &name) const
 Return attribute animation wrap mode.
 
float GetAttributeAnimationSpeed (const String &name) const
 Return attribute animation speed.
 
float GetAttributeAnimationTime (const String &name) const
 Return attribute animation time position.
 
void SetObjectAnimationAttr (const ResourceRef &value)
 Set object animation attribute.
 
ResourceRef GetObjectAnimationAttr () const
 Return object animation attribute.
 
- Public Member Functions inherited from Urho3D::Serializable
 Serializable (Context *context)
 Construct.
 
 ~Serializable () override
 Destruct.
 
virtual void OnSetAttribute (const AttributeInfo &attr, const Variant &src)
 Handle attribute write access. Default implementation writes to the variable at offset, or invokes the set accessor. More...
 
virtual void OnGetAttribute (const AttributeInfo &attr, Variant &dest) const
 Handle attribute read access. Default implementation reads the variable at offset, or invokes the get accessor. More...
 
virtual const Vector< AttributeInfo > * GetAttributes () const
 Return attribute descriptions, or null if none defined. More...
 
virtual const Vector< AttributeInfo > * GetNetworkAttributes () const
 Return network replication attribute descriptions, or null if none defined.
 
virtual bool Load (Deserializer &source)
 Load from binary data. Return true if successful. More...
 
virtual bool Save (Serializer &dest) const
 Save as binary data. Return true if successful. More...
 
virtual bool LoadXML (const XMLElement &source)
 Load from XML data. Return true if successful. More...
 
virtual bool SaveXML (XMLElement &dest) const
 Save as XML data. Return true if successful. More...
 
virtual bool LoadJSON (const JSONValue &source)
 Load from JSON data. Return true if successful. More...
 
virtual bool SaveJSON (JSONValue &dest) const
 Save as JSON data. Return true if successful. More...
 
virtual void ApplyAttributes ()
 Apply attribute changes that can not be applied immediately. Called after scene load or a network update. More...
 
virtual bool SaveDefaultAttributes () const
 Return whether should save default-valued attributes into XML. Default false. More...
 
virtual void MarkNetworkUpdate ()
 Mark for attribute check on the next network update. More...
 
bool SetAttribute (unsigned index, const Variant &value)
 
bool SetAttribute (const String &name, const Variant &value)
 Set attribute by name. Return true if successfully set.
 
void SetInstanceDefault (bool enable)
 Set instance-level default flag.
 
void ResetToDefault ()
 Reset all editable attributes to their default values.
 
void RemoveInstanceDefault ()
 Remove instance's default values if they are set previously.
 
void SetTemporary (bool enable)
 
void SetInterceptNetworkUpdate (const String &attributeName, bool enable)
 Enable interception of an attribute from network updates. Intercepted attributes are sent as events instead of applying directly. This can be used to implement client side prediction.
 
void AllocateNetworkState ()
 Allocate network attribute state.
 
void WriteInitialDeltaUpdate (Serializer &dest, unsigned char timeStamp)
 Write initial delta network update.
 
void WriteDeltaUpdate (Serializer &dest, const DirtyBits &attributeBits, unsigned char timeStamp)
 Write a delta network update according to dirty attribute bits.
 
void WriteLatestDataUpdate (Serializer &dest, unsigned char timeStamp)
 Write a latest data network update.
 
bool ReadDeltaUpdate (Deserializer &source)
 Read and apply a network delta update. Return true if attributes were changed.
 
bool ReadLatestDataUpdate (Deserializer &source)
 Read and apply a network latest data update. Return true if attributes were changed.
 
Variant GetAttribute (unsigned index) const
 
Variant GetAttribute (const String &name) const
 Return attribute value by name. Return empty if not found.
 
Variant GetAttributeDefault (unsigned index) const
 
Variant GetAttributeDefault (const String &name) const
 Return attribute default value by name. Return empty if not found.
 
unsigned GetNumAttributes () const
 
unsigned GetNumNetworkAttributes () const
 Return number of network replication attributes.
 
bool IsTemporary () const
 
bool GetInterceptNetworkUpdate (const String &attributeName) const
 Return whether an attribute's network updates are being intercepted.
 
NetworkStateGetNetworkState () const
 Return the network attribute state, if allocated.
 
- Public Member Functions inherited from Urho3D::Object
 Object (Context *context)
 Construct.
 
 ~Object () override
 Destruct. Clean up self from event sender & receiver structures.
 
virtual StringHash GetType () const =0
 
virtual const StringGetTypeName () const =0
 
virtual const TypeInfoGetTypeInfo () const =0
 Return type info.
 
virtual void OnEvent (Object *sender, StringHash eventType, VariantMap &eventData)
 Handle event.
 
bool IsInstanceOf (StringHash type) const
 Check current instance is type of specified type.
 
bool IsInstanceOf (const TypeInfo *typeInfo) const
 Check current instance is type of specified type.
 
template<typename T >
bool IsInstanceOf () const
 Check current instance is type of specified class.
 
template<typename T >
T * Cast ()
 Cast the object to specified most derived class.
 
template<typename T >
const T * Cast () const
 Cast the object to specified most derived class.
 
void SubscribeToEvent (StringHash eventType, EventHandler *handler)
 Subscribe to an event that can be sent by any sender.
 
void SubscribeToEvent (Object *sender, StringHash eventType, EventHandler *handler)
 Subscribe to a specific sender's event.
 
void SubscribeToEvent (StringHash eventType, const std::function< void(StringHash, VariantMap &)> &function, void *userData=nullptr)
 Subscribe to an event that can be sent by any sender.
 
void SubscribeToEvent (Object *sender, StringHash eventType, const std::function< void(StringHash, VariantMap &)> &function, void *userData=nullptr)
 Subscribe to a specific sender's event.
 
void UnsubscribeFromEvent (StringHash eventType)
 Unsubscribe from an event.
 
void UnsubscribeFromEvent (Object *sender, StringHash eventType)
 Unsubscribe from a specific sender's event.
 
void UnsubscribeFromEvents (Object *sender)
 Unsubscribe from a specific sender's events.
 
void UnsubscribeFromAllEvents ()
 Unsubscribe from all events.
 
void UnsubscribeFromAllEventsExcept (const PODVector< StringHash > &exceptions, bool onlyUserData)
 Unsubscribe from all events except those listed, and optionally only those with userdata (script registered events).
 
void SendEvent (StringHash eventType)
 Send event to all subscribers.
 
void SendEvent (StringHash eventType, VariantMap &eventData)
 Send event with parameters to all subscribers.
 
VariantMapGetEventDataMap () const
 Return a preallocated map for event data. Used for optimization to avoid constant re-allocation of event data maps.
 
template<typename... Args>
void SendEvent (StringHash eventType, Args... args)
 Send event with variadic parameter pairs to all subscribers. The parameter pairs is a list of paramID and paramValue separated by comma, one pair after another.
 
ContextGetContext () const
 Return execution context.
 
const VariantGetGlobalVar (StringHash key) const
 
const VariantMapGetGlobalVars () const
 
void SetGlobalVar (StringHash key, const Variant &value)
 
ObjectGetSubsystem (StringHash type) const
 Return subsystem by type.
 
ObjectGetEventSender () const
 Return active event sender. Null outside event handling.
 
EventHandlerGetEventHandler () const
 Return active event handler. Null outside event handling.
 
bool HasSubscribedToEvent (StringHash eventType) const
 Return whether has subscribed to an event without specific sender.
 
bool HasSubscribedToEvent (Object *sender, StringHash eventType) const
 Return whether has subscribed to a specific sender's event.
 
bool HasEventHandlers () const
 Return whether has subscribed to any event.
 
template<class T >
T * GetSubsystem () const
 Template version of returning a subsystem.
 
const StringGetCategory () const
 
void SetBlockEvents (bool block)
 Block object from sending and receiving events.
 
bool GetBlockEvents () const
 Return sending and receiving events blocking status.
 
- Public Member Functions inherited from Urho3D::RefCounted
 RefCounted ()
 Construct. Allocate the reference count structure and set an initial self weak reference.
 
virtual ~RefCounted ()
 Destruct. Mark as expired and also delete the reference count structure if no outside weak references exist.
 
 RefCounted (const RefCounted &rhs)=delete
 Prevent copy construction.
 
RefCountedoperator= (const RefCounted &rhs)=delete
 Prevent assignment.
 
void AddRef ()
 
void ReleaseRef ()
 
int Refs () const
 
int WeakRefs () const
 
RefCountRefCountPtr ()
 Return pointer to the reference count structure.
 

Static Public Member Functions

static void RegisterObject (Context *context)
 
- Static Public Member Functions inherited from Urho3D::Animatable
static void RegisterObject (Context *context)
 
- Static Public Member Functions inherited from Urho3D::Object
static const TypeInfoGetTypeInfoStatic ()
 Return type info static.
 

Private Member Functions

 URHO3D_OBJECT (IKSolver, Component)
 
void MarkChainsNeedUpdating ()
 Indicates that the internal structures of the IK library need to be updated. See the documentation of ik_solver_rebuild_chain_trees() for more info on when this happens.
 
void MarkTreeNeedsRebuild ()
 Indicates that the tree structure has changed in some way and needs updating (nodes added or removed, components added or removed).
 
bool IsSolverTreeValid () const
 Returns false if calling Solve() would cause the IK library to abort. Urho3D's error handling philosophy is to log an error and continue, not crash.
 
void OnSceneSet (Scene *scene) override
 Subscribe to drawable update finished event here. More...
 
void OnNodeSet (Node *node) override
 Destroys and creates the tree. More...
 
ik_node_t * CreateIKNodeFromUrhoNode (const Node *node)
 Creates the ik library node and sets the current rotation/position and user data correctly.
 
void DestroyTree ()
 Destroys the solver's tree.
 
void RebuildTree ()
 Builds the solver's tree to match the scene graph's tree. If a tree already exists, it is first destroyed.
 
bool BuildTreeToEffector (IKEffector *effector)
 Builds a chain of nodes up to the node of the specified effector component.
 
bool ComponentIsInOurSubtree (Component *component) const
 
void HandleComponentAdded (StringHash eventType, VariantMap &eventData)
 
void HandleComponentRemoved (StringHash eventType, VariantMap &eventData)
 
void HandleNodeAdded (StringHash eventType, VariantMap &eventData)
 
void HandleNodeRemoved (StringHash eventType, VariantMap &eventData)
 
void HandleSceneDrawableUpdateFinished (StringHash eventType, VariantMap &eventData)
 Invokes the IK solver.
 

Private Attributes

PODVector< IKEffector * > effectorList_
 
PODVector< IKConstraint * > constraintList_
 
ik_solver_t * solver_
 
Algorithm algorithm_
 
unsigned features_
 
bool chainTreesNeedUpdating_
 
bool treeNeedsRebuild
 
bool solverTreeValid_
 

Friends

class IKEffector
 

Additional Inherited Members

- Protected Member Functions inherited from Urho3D::Component
void OnAttributeAnimationAdded () override
 Handle attribute animation added. More...
 
void OnAttributeAnimationRemoved () override
 Handle attribute animation removed. More...
 
virtual void OnNodeSet (Node *node)
 Handle scene node being assigned at creation. More...
 
virtual void OnSceneSet (Scene *scene)
 Handle scene being assigned. This may happen several times during the component's lifetime. Scene-wide subsystems and events are subscribed to here. More...
 
virtual void OnMarkedDirty (Node *node)
 Handle scene node transform dirtied. More...
 
virtual void OnNodeSetEnabled (Node *node)
 Handle scene node enabled status changing. More...
 
void SetID (unsigned id)
 
void SetNode (Node *node)
 Set scene node. Called by Node when creating the component.
 
void HandleAttributeAnimationUpdate (StringHash eventType, VariantMap &eventData)
 Handle scene attribute animation update event.
 
ComponentGetFixedUpdateSource ()
 Return a component from the scene root that sends out fixed update events (either PhysicsWorld or PhysicsWorld2D). Return null if neither exists.
 
void DoAutoRemove (AutoRemoveMode mode)
 Perform autoremove. Called by subclasses. Caller should keep a weak pointer to itself to check whether was actually removed, and return immediately without further member operations in that case.
 
- Protected Member Functions inherited from Urho3D::Animatable
virtual void OnAttributeAnimationAdded ()=0
 Handle attribute animation added. More...
 
virtual void OnAttributeAnimationRemoved ()=0
 Handle attribute animation removed. More...
 
virtual AnimatableFindAttributeAnimationTarget (const String &name, String &outName)
 Find target of an attribute animation from object hierarchy by name. More...
 
void SetObjectAttributeAnimation (const String &name, ValueAnimation *attributeAnimation, WrapMode wrapMode, float speed)
 Set object attribute animation internal.
 
void OnObjectAnimationAdded (ObjectAnimation *objectAnimation)
 Handle object animation added.
 
void OnObjectAnimationRemoved (ObjectAnimation *objectAnimation)
 Handle object animation removed.
 
void UpdateAttributeAnimations (float timeStep)
 Update attribute animations.
 
bool IsAnimatedNetworkAttribute (const AttributeInfo &attrInfo) const
 Is animated network attribute.
 
AttributeAnimationInfoGetAttributeAnimationInfo (const String &name) const
 Return attribute animation info.
 
void HandleAttributeAnimationAdded (StringHash eventType, VariantMap &eventData)
 Handle attribute animation added.
 
void HandleAttributeAnimationRemoved (StringHash eventType, VariantMap &eventData)
 Handle attribute animation removed.
 
- Protected Attributes inherited from Urho3D::Component
Nodenode_
 Scene node.
 
unsigned id_
 Unique ID within the scene.
 
bool networkUpdate_
 Network update queued flag.
 
bool enabled_
 Enabled flag.
 
- Protected Attributes inherited from Urho3D::Animatable
bool animationEnabled_
 Animation enabled.
 
SharedPtr< ObjectAnimationobjectAnimation_
 Animation.
 
HashSet< const AttributeInfo * > animatedNetworkAttributes_
 Animated network attribute set.
 
HashMap< String, SharedPtr< AttributeAnimationInfo > > attributeAnimationInfos_
 Attribute animation infos.
 
- Protected Attributes inherited from Urho3D::Serializable
UniquePtr< NetworkStatenetworkState_
 Network attribute state.
 
- Protected Attributes inherited from Urho3D::Object
Contextcontext_
 Execution context.
 

Detailed Description

Marks the root or "beginning" of an IK chain or multiple IK chains. The solving algorithm can be set along with other solver related parameters. The IK problem is solved starting from the node this component is attached to and ending at all nodes that have an IKEffector component attached.

Member Enumeration Documentation

◆ Feature

Enumerator
JOINT_ROTATIONS 

Should be enabled if your model uses skinning or if you are generally interested in correct joint rotations. Has a minor performance impact.

When enabled, final joint rotations are calculated as a post processing step. If you are using IK on a model with skinning, you will want to enable this or it will look wrong. If you disable this, then you will get a slight performance boost (less calculations are required) but only the node positions are updated. This can be useful for scene IK (perhaps a chain of platforms, where each platform should retain its initial world rotation?)

TARGET_ROTATIONS 

When enabled, the effector will try to match the target's rotation as well as the effectors position. When disabled, the target node will reach the effector with any rotation necessary.

If the target position goes out of range of the effector then the rotation will no longer be matched. The chain will try to reach out to reach the target position, even if it means rotating towards it.

UPDATE_ORIGINAL_POSE 

When the solver is first initialized, it will copy the positions and rotations of the current Urho3D scene graph into an internal structure. This is referred to as the "original pose" and will by default never change for the duration of the solver's life cycle. When the solver is destroyed, the original pose is applied back to Urho3D's scene graph so the nodes are restored to whatever they were before the solver was created.

By enabling UPDATE_ORIGINAL_POSE, the original pose will be updated right before solving to reflect the current Urho3D scene graph. As a consequence, there will no longer be an original pose to restore when the solver is destroyed.

When disabled, the original pose will remain unmodified. The original pose is set when the solver is first created. You can manually update the original pose at any time by calling UpdateInitialPose().

UPDATE_ACTIVE_POSE 

Should be enabled if you are using IK on an animated model, along with disabling USE_ORIGINAL_POSE.

The "active pose" has two purposes: The solver uses it as the initial tree to derive a solution from, and at the same time uses it to store the solution into. Thus, the typical solving process is: 1) The active pose needs to be updated to reflect a preferred initial condition (such as the current frame of animation) 2) Call Solve() 3) The active pose now holds the solution, so it must be applied back to the Urho3D scene graph.

When enabled, the active pose is updated right before solving to reflect the current state of the Urho3D scene graph.

When disabled, the active pose will simply remain as it was since the last time Solve() was called.

Note
This option conflicts with USE_ORIGINAL_POSE. Make sure to disable USE_ORIGINAL_POSE if you enable this feature.
USE_ORIGINAL_POSE 

Choose between using the original pose or the active pose as a basis for a solution.

When enabled, the solver will copy the original pose (see UPDATE_ORIGINAL_POSE) into the active pose before solving (and thus use the original pose as a basis for a solution).

Note
This option conflicts with UPDATE_ACTIVE_POSE. If you enable this feature, make sure to disable UPDATE_ACTIVE_POSE.

If both UPDATE_ACTIVE_POSE and USE_ORIGINAL_POSE are disabled, then the solver will use the previously solved tree as a basis for the new calculation. The result is a more "continuous" solution that unfolds over time. This can be useful if you want to simulate chains or something similar.

CONSTRAINTS 

Due to the somewhat unfortunate performance impacts, the solver does not enable constraints by default. Enabling constraints causes the solver's tree to be written to and from Urho3D's scene graph every iteration, while calling ApplyConstraints(). Disabling constraints means ApplyConstraints() is never called.

AUTO_SOLVE 

Mostly exists because of the editor. When enabled, the solver will be invoked automatically for you. If you need to do additional calculations before being able to set the effector target data, you will want to disable this and call Solve() manually.

Member Function Documentation

◆ ApplyActivePoseToScene()

void Urho3D::IKSolver::ApplyActivePoseToScene ( )

Copies the solvers current active pose into the scene graph. You generally won't need to call this because it gets called for you automatically in Solve(). This is used to apply the solution back to the scene graph.

Here is the caller graph for this function:

◆ ApplyOriginalPoseToActivePose()

void Urho3D::IKSolver::ApplyOriginalPoseToActivePose ( )

Copies the solvers original pose into the solvers active pose. This is used in Solve() automatically if Feature::USE_ORIGINAL_POSE is set.

Here is the caller graph for this function:

◆ ApplyOriginalPoseToScene()

void Urho3D::IKSolver::ApplyOriginalPoseToScene ( )

Copies the original pose into the scene graph. This will reset the pose to whatever state it had when the IKSolver component was first created, or, if the original pose was updated since then (for example if Feature::UPDATE_ORIGINAL_POSE is set), will reset it to that state.

Here is the caller graph for this function:

◆ ApplySceneToActivePose()

void Urho3D::IKSolver::ApplySceneToActivePose ( )

Copies the current scene graph data into the solvers active pose. You generally won't need to call this because it gets called for you automatically if Feature::UPDATE_ACTIVE_POSE is set.

Here is the caller graph for this function:

◆ ApplySceneToOriginalPose()

void Urho3D::IKSolver::ApplySceneToOriginalPose ( )

Copies the current scene graph data into the solvers original pose. You generally won't need to call this, because it gets called for you automatically if Feature::UPDATE_ORIGINAL_POSE is set.

Here is the caller graph for this function:

◆ ComponentIsInOurSubtree()

bool Urho3D::IKSolver::ComponentIsInOurSubtree ( Component component) const
private

Checks if the specified component is 1) attached to a node that is below the one we are attached to and 2) isn't in the subtree of a child solver.

Note
This will return false if the component is attached to our root node, because in that case the solver can't do anything to it, it's in the hands of a parent solver (if it exists).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawDebugGeometry()

void Urho3D::IKSolver::DrawDebugGeometry ( DebugRenderer debug,
bool  depthTest 
)
overridevirtual

Visualize the component as debug geometry.

Reimplemented from Urho3D::Component.

Here is the call graph for this function:

◆ GetAlgorithm()

IKSolver::Algorithm Urho3D::IKSolver::GetAlgorithm ( ) const

Returns the active algorithm.

Here is the caller graph for this function:

◆ GetFeature()

bool Urho3D::IKSolver::GetFeature ( Feature  feature) const

Test if a certain feature is enabled (see IKSolver::Feature).

◆ GetMaximumIterations()

unsigned Urho3D::IKSolver::GetMaximumIterations ( ) const

Returns the configured maximum number of iterations.

Here is the caller graph for this function:

◆ GetTolerance()

float Urho3D::IKSolver::GetTolerance ( ) const

Returns the configured tolerance.

Here is the caller graph for this function:

◆ OnNodeSet()

void Urho3D::IKSolver::OnNodeSet ( Node node)
overrideprivatevirtual

Destroys and creates the tree.

Reimplemented from Urho3D::Component.

Here is the call graph for this function:

◆ OnSceneSet()

void Urho3D::IKSolver::OnSceneSet ( Scene scene)
overrideprivatevirtual

Subscribe to drawable update finished event here.

Reimplemented from Urho3D::Component.

Here is the call graph for this function:

◆ RebuildChainTrees()

void Urho3D::IKSolver::RebuildChainTrees ( )

Updates the solver's internal data structures, which is required whenever the tree is modified in any way (e.g. adding or removing nodes, adding or removing effectors, etc.).

Note
This gets called automatically for you in Solve().
Here is the caller graph for this function:

◆ RecalculateSegmentLengths()

void Urho3D::IKSolver::RecalculateSegmentLengths ( )

Unusual, but if you have a tree with translational motions such that the distances between nodes changes (perhaps a slider?), you can call this to recalculate the segment lengths after assigning new positions to the nodes.

Note
This function gets called by RebuildData() and by extension in Solve().

◆ RegisterObject()

void Urho3D::IKSolver::RegisterObject ( Context context)
static

Registers this class to the context.

Here is the call graph for this function:

◆ SetAlgorithm()

void Urho3D::IKSolver::SetAlgorithm ( IKSolver::Algorithm  algorithm)

Selects the solver algorithm. Default is FABRIK. Note that this may not be the most efficient algorithm available. The specialized solvers will be a lot faster.

The currently supported solvers are listed below.

  • FABRIK: This is a fairly new and highly efficient inverse kinematic solving algorithm. It requires the least iterations to reach its goal, it does not suffer from singularities (nearly no violent snapping about), and it always converges.
  • 2 Bone: A specialized solver optimized for 2 bone problems (such as a human leg)
  • 1 Bone: A specialized solver optimized for 1 bone problems (such as a look-at target, e.g. eyes or a head)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFeature()

void Urho3D::IKSolver::SetFeature ( Feature  feature,
bool  enable 
)

Enable or disable a certain feature (see IKSolver::Feature).

Here is the call graph for this function:

◆ SetMaximumIterations()

void Urho3D::IKSolver::SetMaximumIterations ( unsigned  iterations)

Sets the maximum number of iterations the solver is allowed to perform before applying the result.

Depending on the algorithm, you may want higher or lower values. FABRIK looks decent after only 10 iterations, whereas Jacobian based methods often require more than a 100.

The default value is 20.

Note
Most algorithms have a convergence criteria at which the solver will stop iterating, so most of the time the maximum number of iterations isn't even reached.
Parameters
[in]iterationsNumber of iterations. Must be greater than 0. Higher values yield more accurate results, but at the cost of performance.
Here is the caller graph for this function:

◆ SetTolerance()

void Urho3D::IKSolver::SetTolerance ( float  tolerance)

Sets the distance at which the effector is "close enough" to the target node, at which point the algorithm will stop iterating.

Parameters
toleranceThe distance to set. Smaller values yield more accurate results, but at the cost of more iterations. Generally you'll want to specify a number that is about 1/100th to 1/1000th of the total size of the IK chain, e.g. if your human character has a leg that is 1 Urho3D unit long, a good starting tolerance would be 0.01.
Here is the caller graph for this function:

◆ Solve()

void Urho3D::IKSolver::Solve ( )

Invokes the solver. The solution is applied back to the scene graph automatically.

Note
By default this is called automatically for you if the feature flag AUTO_SOLVE is set. For more complex IK problems you can disable that flag and call Solve() in response to E_SCENEDRAWABLEUPDATEFINISHED. This is right after the animations have been applied.
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: