Blender V4.3
itasc_plugin.cc File Reference
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include "MEM_guardedalloc.h"
#include "BIK_api.h"
#include "BLI_blenlib.h"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_utildefines.h"
#include "BKE_action.hh"
#include "BKE_armature.hh"
#include "BKE_constraint.h"
#include "BKE_global.hh"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "itasc_plugin.h"

Go to the source code of this file.

Classes

struct  IK_Data
 
struct  IK_Target
 
struct  IK_Channel
 
struct  IK_Scene
 

Macros

#define ANIM_FEEDBACK   0.8
 

Typedefs

using Vector3 = float[3]
 
using Vector4 = float[4]
 
using ErrorCallback
 

Enumerations

enum  IK_SegmentFlag {
  IK_XDOF = 1 , IK_YDOF = 2 , IK_ZDOF = 4 , IK_SWING = 8 ,
  IK_REVOLUTE = 16 , IK_TRANSY = 32
}
 
enum  IK_SegmentAxis {
  IK_X = 0 , IK_Y = 1 , IK_Z = 2 , IK_TRANS_X = 3 ,
  IK_TRANS_Y = 4 , IK_TRANS_Z = 5
}
 

Functions

static int initialize_chain (Object *, bPoseChannel *pchan_tip, bConstraint *con)
 
static bool is_cartesian_constraint (bConstraint *)
 
static bool constraint_valid (bConstraint *con)
 
static int initialize_scene (Object *ob, bPoseChannel *pchan_tip)
 
static IK_Dataget_ikdata (bPose *pose)
 
static double EulerAngleFromMatrix (const KDL::Rotation &R, int axis)
 
static double ComputeTwist (const KDL::Rotation &R)
 
static void RemoveEulerAngleFromMatrix (KDL::Rotation &R, double angle, int axis)
 
static void GetJointRotation (KDL::Rotation &boneRot, int type, double *rot)
 
static bool target_callback (const iTaSC::Timestamp &, const iTaSC::Frame &, iTaSC::Frame &next, void *param)
 
static bool base_callback (const iTaSC::Timestamp &timestamp, const iTaSC::Frame &, iTaSC::Frame &next, void *param)
 
static bool copypose_callback (const iTaSC::Timestamp &, iTaSC::ConstraintValues *const _values, uint, void *_param)
 
static void copypose_error (const iTaSC::ConstraintValues *values, uint, IK_Target *iktarget)
 
static bool distance_callback (const iTaSC::Timestamp &timestamp, iTaSC::ConstraintValues *const _values, uint, void *_param)
 
static void distance_error (const iTaSC::ConstraintValues *values, uint, IK_Target *iktarget)
 
static bool joint_callback (const iTaSC::Timestamp &, iTaSC::ConstraintValues *const _values, uint _nvalues, void *_param)
 
static int convert_channels (Depsgraph *depsgraph, IK_Scene *ikscene, PoseTree *tree, float ctime)
 
static void convert_pose (IK_Scene *ikscene)
 
static void BKE_pose_rest (IK_Scene *ikscene)
 
static IK_Sceneconvert_tree (Depsgraph *depsgraph, Scene *blscene, Object *ob, bPoseChannel *pchan, float ctime)
 
static void create_scene (Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime)
 
static int init_scene (Object *ob)
 
static void execute_scene (Depsgraph *depsgraph, Scene *blscene, IK_Scene *ikscene, bItasc *ikparam, float ctime, float frtime)
 
Plugin Interface
void itasc_initialize_tree (Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime)
 
void itasc_execute_tree (Depsgraph *depsgraph, Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
 
void itasc_release_tree (Scene *, Object *, float)
 
void itasc_clear_data (bPose *pose)
 
void itasc_clear_cache (bPose *pose)
 
void itasc_update_param (bPose *pose)
 
void itasc_test_constraint (Object *, bConstraint *cons)
 

Variables

static bItasc DefIKParam
 

Macro Definition Documentation

◆ ANIM_FEEDBACK

#define ANIM_FEEDBACK   0.8

Definition at line 53 of file itasc_plugin.cc.

Referenced by copypose_callback(), and distance_callback().

Typedef Documentation

◆ ErrorCallback

Initial value:
void (*)(const iTaSC::ConstraintValues *values,
uint nvalues,
IK_Target *iktarget)
unsigned int uint

Definition at line 66 of file itasc_plugin.cc.

◆ Vector3

using Vector3 = float[3]

Definition at line 63 of file itasc_plugin.cc.

◆ Vector4

using Vector4 = float[4]

Definition at line 64 of file itasc_plugin.cc.

Enumeration Type Documentation

◆ IK_SegmentAxis

Enumerator
IK_X 
IK_Y 
IK_Z 
IK_TRANS_X 
IK_TRANS_Y 
IK_TRANS_Z 

Definition at line 207 of file itasc_plugin.cc.

◆ IK_SegmentFlag

Enumerator
IK_XDOF 
IK_YDOF 
IK_ZDOF 
IK_SWING 
IK_REVOLUTE 
IK_TRANSY 

Definition at line 198 of file itasc_plugin.cc.

Function Documentation

◆ base_callback()

◆ BKE_pose_rest()

◆ ComputeTwist()

static double ComputeTwist ( const KDL::Rotation & R)
static

Definition at line 453 of file itasc_plugin.cc.

References KDL::atan2(), and R.

Referenced by GetJointRotation(), IK_QElbowSegment::SetBasis(), and IK_QRevoluteSegment::SetBasis().

◆ constraint_valid()

static bool constraint_valid ( bConstraint * con)
static

◆ convert_channels()

◆ convert_pose()

◆ convert_tree()

static IK_Scene * convert_tree ( Depsgraph * depsgraph,
Scene * blscene,
Object * ob,
bPoseChannel * pchan,
float ctime )
static

Definition at line 1132 of file itasc_plugin.cc.

References iTaSC::ACT_ALPHA, iTaSC::ACT_VALUE, iTaSC::Armature::addConstraint(), iTaSC::Armature::addEndEffector(), iTaSC::Armature::addLimitConstraint(), iTaSC::Armature::addSegment(), Bone::arm_mat, Bone::arm_tail, IK_Scene::armature, IK_Scene::base, base_callback(), BKE_pose_rest(), IK_Scene::blArmature, IK_Scene::bldepsgraph, IK_Target::bldepsgraph, IK_Target::blenderConstraint, IK_Scene::blInvScale, IK_Scene::blScale, IK_Scene::blscene, IK_Target::blscene, bPoseChannel::bone, BONE_CONNECTED, BONE_IK_ROTCTL, BONE_IK_XLIMIT, BONE_IK_YLIMIT, BONE_IK_ZLIMIT, Bone::bone_mat, IK_Scene::cache, IK_Target::channel, IK_Scene::channels, IK_Target::constraint, CONSTRAINT_IK_COPYPOSE, CONSTRAINT_IK_DISTANCE, CONSTRAINT_IK_NO_POS_X, CONSTRAINT_IK_NO_POS_Y, CONSTRAINT_IK_NO_POS_Z, CONSTRAINT_IK_NO_ROT_X, CONSTRAINT_IK_NO_ROT_Y, CONSTRAINT_IK_NO_ROT_Z, CONSTRAINT_IK_POS, CONSTRAINT_IK_ROT, CONSTRAINT_IK_TARGETAXIS, IK_Target::constraintName, IK_Target::controlType, convert_channels(), copy_m3_m4(), copy_m4_m4(), copy_v3_v3(), copypose_callback(), copypose_error(), iTaSC::CopyPose::CTL_POSITION, iTaSC::CopyPose::CTL_POSITIONX, iTaSC::CopyPose::CTL_POSITIONY, iTaSC::CopyPose::CTL_POSITIONZ, iTaSC::CopyPose::CTL_ROTATION, iTaSC::CopyPose::CTL_ROTATIONX, iTaSC::CopyPose::CTL_ROTATIONY, iTaSC::CopyPose::CTL_ROTATIONZ, bConstraint::data, DefIKParam, depsgraph, bKinematicConstraint::dist, distance_callback(), distance_error(), e_matrix, IK_Target::ee, IK_Target::eeBlend, IK_Target::eeRest, KDL::epsilon, IK_Target::errorCallback, iTaSC::F_identity, ListBase::first, bItasc::flag, bKinematicConstraint::flag, Bone::flag, KDL::Rotation::GetRot(), iTaSC::ControlledObject::getWq(), IK_Channel::head, Object::id, iTaSC::Distance::ID_DISTANCE, iTaSC::CopyPose::ID_POSITION, iTaSC::CopyPose::ID_ROTATION, IK_REVOLUTE, IK_SWING, IK_TRANSY, IK_XDOF, IK_YDOF, IK_ZDOF, bPoseChannel::ikflag, bPose::ikparam, bPoseChannel::ikstretch, bPoseChannel::iktree, invert_m3_m3(), invert_m4_m4(), is_cartesian_constraint(), ITASC_SIMULATION, ITASC_SOLVER_DLS, ITASC_SOLVER_SDLS, ITASC_TRANSLATE_ROOT_BONES, joint_callback(), IK_Scene::jointArray, IK_Channel::jointType, len_v3(), Bone::length, length(), bPoseChannel::limitmax, bPoseChannel::limitmin, KDL::Frame::M, min_ff(), mul_m3_v3(), mul_m4_m4m4(), Bone::name, ID::name, IK_Channel::ndof, bConstraint::next, KDL::Joint::None, KDL::Vector::Norm(), normalize_m3(), IK_Scene::numchan, bKinematicConstraint::orientweight, IK_Target::owner, KDL::Frame::p, bPoseChannel::parent, IK_Channel::pchan, IK_Scene::polarConstraint, bKinematicConstraint::poletar, Object::pose, bPoseChannel::pose_head, bPoseChannel::pose_mat, bPoseChannel::pose_tail, iTaSC::ConstraintSet::registerCallback(), ret, IK_Target::rootChannel, rot, KDL::Joint::RotX, KDL::Joint::RotY, KDL::Joint::RotZ, IK_Scene::scene, scene, iTaSC::MovingFrame::setCallback(), iTaSC::ConstraintSet::setControlParameter(), IK_Target::simulation, bItasc::solver, IK_Scene::solver, KDL::Joint::Sphere, bPoseChannel::stiffness, sub_v3_v3v3(), iTaSC::ConstraintSet::substep(), KDL::Joint::Swing, IK_Channel::tail, IK_Target::target, target_callback(), IK_Target::targetName, IK_Scene::targets, KDL::Joint::TransY, tree, bKinematicConstraint::type, unit_m3(), unit_m4(), and bKinematicConstraint::weight.

Referenced by create_scene().

◆ copypose_callback()

◆ copypose_error()

◆ create_scene()

static void create_scene ( Depsgraph * depsgraph,
Scene * scene,
Object * ob,
float ctime )
static

◆ distance_callback()

◆ distance_error()

static void distance_error ( const iTaSC::ConstraintValues * values,
uint ,
IK_Target * iktarget )
static

Definition at line 831 of file itasc_plugin.cc.

References IK_Target::blenderConstraint, float, and bConstraint::lin_error.

Referenced by convert_tree().

◆ EulerAngleFromMatrix()

static double EulerAngleFromMatrix ( const KDL::Rotation & R,
int axis )
static

◆ execute_scene()

static void execute_scene ( Depsgraph * depsgraph,
Scene * blscene,
IK_Scene * ikscene,
bItasc * ikparam,
float ctime,
float frtime )
static

◆ get_ikdata()

static IK_Data * get_ikdata ( bPose * pose)
static

Definition at line 414 of file itasc_plugin.cc.

References BKE_pose_itasc_init(), DefIKParam, bPose::ikdata, bItasc::iksolver, and MEM_callocN.

Referenced by create_scene().

◆ GetJointRotation()

◆ init_scene()

static int init_scene ( Object * ob)
static

◆ initialize_chain()

◆ initialize_scene()

static int initialize_scene ( Object * ob,
bPoseChannel * pchan_tip )
static

◆ is_cartesian_constraint()

static bool is_cartesian_constraint ( bConstraint * )
static

Definition at line 371 of file itasc_plugin.cc.

Referenced by constraint_valid(), and convert_tree().

◆ itasc_clear_cache()

void itasc_clear_cache ( bPose * pose)

Definition at line 1943 of file itasc_plugin.cc.

References IK_Data::first, bPose::ikdata, and scene.

◆ itasc_clear_data()

void itasc_clear_data ( bPose * pose)

Definition at line 1930 of file itasc_plugin.cc.

References IK_Data::first, bPose::ikdata, MEM_freeN(), IK_Scene::next, and scene.

Referenced by itasc_initialize_tree().

◆ itasc_execute_tree()

void itasc_execute_tree ( Depsgraph * depsgraph,
Scene * scene,
Object * ob,
bPoseChannel * pchan_root,
float ctime )

◆ itasc_initialize_tree()

void itasc_initialize_tree ( Depsgraph * depsgraph,
Scene * scene,
Object * ob,
float ctime )

◆ itasc_release_tree()

void itasc_release_tree ( Scene * scene,
Object * ob,
float ctime )

Definition at line 1925 of file itasc_plugin.cc.

◆ itasc_test_constraint()

void itasc_test_constraint ( Object * ob,
bConstraint * cons )

◆ itasc_update_param()

◆ joint_callback()

◆ RemoveEulerAngleFromMatrix()

static void RemoveEulerAngleFromMatrix ( KDL::Rotation & R,
double angle,
int axis )
static

Definition at line 464 of file itasc_plugin.cc.

References R, KDL::Rotation::RotX(), KDL::Rotation::RotY(), KDL::Rotation::RotZ(), and T.

Referenced by GetJointRotation().

◆ target_callback()

Variable Documentation

◆ DefIKParam

bItasc DefIKParam
static