Blender  V3.3
Classes | Macros | Typedefs | Enumerations | Functions | Variables
itasc_plugin.cpp File Reference
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include "MEM_guardedalloc.h"
#include "BIK_api.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_constraint.h"
#include "BKE_global.h"
#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 = void(*)(const iTaSC::ConstraintValues *values, unsigned int nvalues, IK_Target *iktarget)
 

Enumerations

enum  IK_SegmentFlag {
  IK_XDOF = 1 , IK_YDOF = 2 , IK_ZDOF = 4 , IK_SWING = 8 ,
  IK_REVOLUTE = 16 , IK_TRANSY = 32 , IK_XDOF = 1 , IK_YDOF = 2 ,
  IK_ZDOF = 4 , IK_TRANS_XDOF = 8 , IK_TRANS_YDOF = 16 , IK_TRANS_ZDOF = 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 , 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 *ob, bPoseChannel *pchan_tip, bConstraint *con)
 
static bool is_cartesian_constraint (bConstraint *con)
 
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 &timestamp, const iTaSC::Frame &current, iTaSC::Frame &next, void *param)
 
static bool base_callback (const iTaSC::Timestamp &timestamp, const iTaSC::Frame &current, iTaSC::Frame &next, void *param)
 
static bool copypose_callback (const iTaSC::Timestamp &timestamp, iTaSC::ConstraintValues *const _values, unsigned int _nvalues, void *_param)
 
static void copypose_error (const iTaSC::ConstraintValues *values, unsigned int nvalues, IK_Target *iktarget)
 
static bool distance_callback (const iTaSC::Timestamp &timestamp, iTaSC::ConstraintValues *const _values, unsigned int _nvalues, void *_param)
 
static void distance_error (const iTaSC::ConstraintValues *values, unsigned int _nvalues, IK_Target *iktarget)
 
static bool joint_callback (const iTaSC::Timestamp &timestamp, iTaSC::ConstraintValues *const _values, unsigned int _nvalues, void *_param)
 
static int convert_channels (struct 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 (struct Depsgraph *depsgraph, Scene *blscene, Object *ob, bPoseChannel *pchan, float ctime)
 
static void create_scene (struct Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime)
 
static int init_scene (Object *ob)
 
static void execute_scene (struct Depsgraph *depsgraph, Scene *blscene, IK_Scene *ikscene, bItasc *ikparam, float ctime, float frtime)
 
Plugin Interface
void itasc_initialize_tree (struct Depsgraph *depsgraph, struct Scene *scene, Object *ob, float ctime)
 
void itasc_execute_tree (struct Depsgraph *depsgraph, struct Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
 
void itasc_release_tree (struct Scene *scene, struct Object *ob, float ctime)
 
void itasc_clear_data (struct bPose *pose)
 
void itasc_clear_cache (struct bPose *pose)
 
void itasc_update_param (struct bPose *pose)
 
void itasc_test_constraint (struct Object *ob, struct bConstraint *cons)
 

Variables

static bItasc DefIKParam
 

Macro Definition Documentation

◆ ANIM_FEEDBACK

#define ANIM_FEEDBACK   0.8

Definition at line 49 of file itasc_plugin.cpp.

Typedef Documentation

◆ ErrorCallback

using ErrorCallback = void (*)(const iTaSC::ConstraintValues *values, unsigned int nvalues, IK_Target *iktarget)

Definition at line 62 of file itasc_plugin.cpp.

◆ Vector3

using Vector3 = float[3]

Definition at line 59 of file itasc_plugin.cpp.

◆ Vector4

using Vector4 = float[4]

Definition at line 60 of file itasc_plugin.cpp.

Enumeration Type Documentation

◆ IK_SegmentAxis

Enumerator
IK_X 
IK_Y 
IK_Z 
IK_TRANS_X 
IK_TRANS_Y 
IK_TRANS_Z 
IK_X 
IK_Y 
IK_Z 
IK_TRANS_X 
IK_TRANS_Y 
IK_TRANS_Z 

Definition at line 203 of file itasc_plugin.cpp.

◆ IK_SegmentFlag

Enumerator
IK_XDOF 
IK_YDOF 
IK_ZDOF 
IK_SWING 
IK_REVOLUTE 
IK_TRANSY 
IK_XDOF 
IK_YDOF 
IK_ZDOF 
IK_TRANS_XDOF 
IK_TRANS_YDOF 
IK_TRANS_ZDOF 

Definition at line 194 of file itasc_plugin.cpp.

Function Documentation

◆ base_callback()

static bool base_callback ( const iTaSC::Timestamp timestamp,
const iTaSC::Frame current,
iTaSC::Frame next,
void param 
)
static

◆ BKE_pose_rest()

static void BKE_pose_rest ( IK_Scene ikscene)
static

◆ ComputeTwist()

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

Definition at line 450 of file itasc_plugin.cpp.

References KDL::atan2(), and R.

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

◆ constraint_valid()

static bool constraint_valid ( bConstraint con)
static

◆ convert_channels()

static int convert_channels ( struct Depsgraph depsgraph,
IK_Scene ikscene,
PoseTree tree,
float  ctime 
)
static

◆ convert_pose()

static void convert_pose ( IK_Scene ikscene)
static

◆ convert_tree()

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

Definition at line 1127 of file itasc_plugin.cpp.

References Freestyle::a, iTaSC::ACT_ALPHA, iTaSC::ACT_VALUE, Bone::arm_mat, Bone::arm_tail, base_callback(), BKE_pose_rest(), IK_Target::bldepsgraph, IK_Target::blenderConstraint, IK_Target::blscene, IK_Scene::blscene, bPoseChannel::bone, BONE_CONNECTED, BONE_IK_ROTCTL, BONE_IK_XLIMIT, BONE_IK_YLIMIT, BONE_IK_ZLIMIT, IK_Target::channel, 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, 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, KDL::Rotation::GetRot(), Object::id, iTaSC::Distance::ID_DISTANCE, iTaSC::CopyPose::ID_POSITION, iTaSC::CopyPose::ID_ROTATION, if(), 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, joint_callback(), len_v3(), blender::math::length(), bPoseChannel::limitmax, bPoseChannel::limitmin, KDL::Frame::M, min_ff(), mul_m3_v3(), mul_m4_m4m4(), Bone::name, ID::name, KDL::Joint::None, KDL::Vector::Norm(), normalize_m3(), Object::obmat, IK_Target::owner, KDL::Frame::p, bPoseChannel::parent, 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, scene, iTaSC::MovingFrame::setCallback(), iTaSC::ConstraintSet::setControlParameter(), IK_Target::simulation, KDL::Joint::Sphere, bPoseChannel::stiffness, sub_v3_v3v3(), iTaSC::ConstraintSet::substep(), KDL::Joint::Swing, t, IK_Target::target, target_callback(), IK_Target::targetName, KDL::Joint::TransY, tree, unit_m3(), and unit_m4().

Referenced by create_scene().

◆ copypose_callback()

static bool copypose_callback ( const iTaSC::Timestamp timestamp,
iTaSC::ConstraintValues *const  _values,
unsigned int  _nvalues,
void _param 
)
static

◆ copypose_error()

static void copypose_error ( const iTaSC::ConstraintValues values,
unsigned int  nvalues,
IK_Target iktarget 
)
static

◆ create_scene()

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

◆ distance_callback()

static bool distance_callback ( const iTaSC::Timestamp timestamp,
iTaSC::ConstraintValues *const  _values,
unsigned int  _nvalues,
void _param 
)
static

◆ distance_error()

static void distance_error ( const iTaSC::ConstraintValues values,
unsigned int  _nvalues,
IK_Target iktarget 
)
static

◆ EulerAngleFromMatrix()

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

◆ execute_scene()

static void execute_scene ( struct 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 411 of file itasc_plugin.cpp.

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

Referenced by create_scene().

◆ GetJointRotation()

static void GetJointRotation ( KDL::Rotation boneRot,
int  type,
double rot 
)
static

◆ init_scene()

static int init_scene ( Object ob)
static

◆ initialize_chain()

static int initialize_chain ( Object ob,
bPoseChannel pchan_tip,
bConstraint con 
)
static

◆ initialize_scene()

static int initialize_scene ( Object ob,
bPoseChannel pchan_tip 
)
static

◆ is_cartesian_constraint()

static bool is_cartesian_constraint ( bConstraint con)
static

Definition at line 365 of file itasc_plugin.cpp.

Referenced by constraint_valid(), and convert_tree().

◆ itasc_clear_cache()

void itasc_clear_cache ( struct bPose pose)

Definition at line 1941 of file itasc_plugin.cpp.

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

◆ itasc_clear_data()

void itasc_clear_data ( struct bPose pose)

Definition at line 1928 of file itasc_plugin.cpp.

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

Referenced by itasc_initialize_tree().

◆ itasc_execute_tree()

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

◆ itasc_initialize_tree()

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

◆ itasc_release_tree()

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

Definition at line 1923 of file itasc_plugin.cpp.

◆ itasc_test_constraint()

void itasc_test_constraint ( struct Object ob,
struct bConstraint cons 
)

◆ itasc_update_param()

void itasc_update_param ( struct bPose pose)

◆ joint_callback()

static bool joint_callback ( const iTaSC::Timestamp timestamp,
iTaSC::ConstraintValues *const  _values,
unsigned int  _nvalues,
void _param 
)
static

◆ RemoveEulerAngleFromMatrix()

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

Definition at line 461 of file itasc_plugin.cpp.

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

Referenced by GetJointRotation().

◆ target_callback()

static bool target_callback ( const iTaSC::Timestamp timestamp,
const iTaSC::Frame current,
iTaSC::Frame next,
void param 
)
static

Variable Documentation

◆ DefIKParam

bItasc DefIKParam
static