Blender
V3.3
|
#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 } |
Variables | |
static bItasc | DefIKParam |
#define ANIM_FEEDBACK 0.8 |
Definition at line 49 of file itasc_plugin.cpp.
using ErrorCallback = void (*)(const iTaSC::ConstraintValues *values, unsigned int nvalues, IK_Target *iktarget) |
Definition at line 62 of file itasc_plugin.cpp.
Definition at line 59 of file itasc_plugin.cpp.
Definition at line 60 of file itasc_plugin.cpp.
enum 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.
enum 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.
|
static |
Definition at line 601 of file itasc_plugin.cpp.
References IK_Scene::armature, IK_Scene::baseFrame, BKE_constraint_target_matrix_get(), IK_Scene::blArmature, IK_Scene::bldepsgraph, IK_Scene::blScale, IK_Scene::blscene, IK_Scene::channels, CONSTRAINT_OBTYPE_OBJECT, copy_m4_m4(), copy_v3_v3(), KDL::cos(), bConstraint::data, IK_Target::ee, iTaSC::F_identity, iTaSC::Armature::getPose(), iTaSC::Object::getPose(), iTaSC::Armature::getRelativeFrame(), iTaSC::Armature::getSegment(), KDL::Joint::getType(), KDL::Frame::getValue(), KDL::Rotation::Inverse(), invert_m4_m4(), blender::math::length(), KDL::Frame::M, mul_m4_m4m4(), next, KDL::Normalize(), Object::obmat, KDL::Frame::p, bPoseChannel::parent, IK_Channel::pchan, IK_Scene::polarConstraint, bKinematicConstraint::poleangle, bPoseChannel::pose_mat, bPoseChannel::pose_tail, result, KDL::Frame::setValue(), KDL::sin(), IK_Channel::tail, IK_Target::target, IK_Scene::targets, KDL::Joint::TransY, KDL::Rotation::UnitX(), KDL::Rotation::UnitY(), KDL::Rotation::UnitZ(), iTaSC::Timestamp::update, and x.
Referenced by convert_tree().
Definition at line 1098 of file itasc_plugin.cpp.
References Freestyle::a, IK_Scene::blArmature, bPoseChannel::bone, IK_Scene::channels, IK_TRANSY, IK_Scene::jointArray, IK_Channel::jointType, len_v3(), Bone::length, IK_Channel::ndof, Object::obmat, IK_Channel::pchan, rot, and SetToZero().
Referenced by convert_tree().
|
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().
|
static |
Definition at line 372 of file itasc_plugin.cpp.
References CONSTRAINT_DISABLE, CONSTRAINT_IK_AUTO, CONSTRAINT_OFF, data, bConstraint::data, bConstraint::flag, if(), is_cartesian_constraint(), and OB_ARMATURE.
Referenced by initialize_scene().
|
static |
Definition at line 922 of file itasc_plugin.cpp.
References Freestyle::a, BKE_pose_where_is_bone(), IK_Scene::blArmature, IK_Scene::blscene, BONE_IK_NO_XDOF, BONE_IK_NO_XDOF_TEMP, BONE_IK_NO_YDOF, BONE_IK_NO_YDOF_TEMP, BONE_IK_NO_ZDOF, BONE_IK_NO_ZDOF_TEMP, BONE_IK_XLIMIT, BONE_IK_YLIMIT, BONE_IK_ZLIMIT, IK_Scene::channels, depsgraph, bPoseChannel::flag, bConstraint::flag, if(), IK_REVOLUTE, IK_SWING, IK_TRANSY, IK_XDOF, IK_YDOF, IK_ZDOF, bPoseChannel::ikflag, bPoseChannel::ikstretch, IK_Scene::jointArray, IK_Channel::jointType, bPoseChannel::limitmax, bPoseChannel::limitmin, IK_Channel::ndof, IK_Scene::numjoint, IK_Channel::owner, IK_Channel::parent, IK_Channel::pchan, POSE_CHAIN, POSE_DONE, KDL::JntArray::resize(), and tree.
Referenced by convert_tree().
Definition at line 1055 of file itasc_plugin.cpp.
References Freestyle::a, Bone::arm_mat, IK_Scene::blArmature, bPoseChannel::bone, Bone::bone_mat, IK_Scene::channels, copy_m4_m4(), GetJointRotation(), IK_TRANSY, invert_m4_m4(), IK_Scene::jointArray, IK_Channel::jointType, len_v3(), len_v3v3(), mul_m4_m4m3(), mul_m4_m4m4(), IK_Channel::ndof, normalize_m4(), Object::obmat, bPoseChannel::parent, IK_Channel::pchan, bPoseChannel::pose_head, bPoseChannel::pose_mat, bPoseChannel::pose_tail, rot, KDL::Rotation::setValue(), and unit_m4().
Referenced by execute_scene().
|
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().
|
static |
Definition at line 705 of file itasc_plugin.cpp.
References iTaSC::ACT_ALPHA, iTaSC::ACT_FEEDBACK, iTaSC::ConstraintValues::action, iTaSC::ConstraintValues::alpha, ANIM_FEEDBACK, IK_Target::blenderConstraint, CONSTRAINT_OFF, IK_Target::controlType, iTaSC::CopyPose::CTL_POSITION, iTaSC::CopyPose::CTL_ROTATION, bConstraint::data, DefIKParam, iTaSC::ConstraintValues::feedback, bConstraint::flag, bPose::ikparam, bKinematicConstraint::orientweight, IK_Target::owner, Object::pose, IK_Target::simulation, and bKinematicConstraint::weight.
Referenced by convert_tree().
|
static |
Definition at line 751 of file itasc_plugin.cpp.
References IK_Target::blenderConstraint, IK_Target::controlType, iTaSC::CopyPose::CTL_POSITION, iTaSC::CopyPose::CTL_ROTATION, error(), float(), bConstraint::lin_error, bConstraint::rot_error, KDL::sqr(), KDL::sqrt(), iTaSC::ConstraintValues::values, iTaSC::ConstraintSingleValue::y, and iTaSC::ConstraintSingleValue::yd.
Referenced by convert_tree().
|
static |
Definition at line 1629 of file itasc_plugin.cpp.
References BLI_freelistN(), BLI_remlink(), bPose::chanbase, convert_tree(), depsgraph, IK_Data::first, ListBase::first, get_ikdata(), if(), bPoseChannel::iktree, MEM_freeN, IK_Scene::next, bPoseChannel::next, Object::pose, scene, and tree.
Referenced by itasc_initialize_tree().
|
static |
Definition at line 777 of file itasc_plugin.cpp.
References iTaSC::ACT_ALPHA, iTaSC::ACT_FEEDBACK, iTaSC::ACT_VALUE, iTaSC::ConstraintSingleValue::action, iTaSC::ConstraintValues::action, iTaSC::ConstraintValues::alpha, ANIM_FEEDBACK, IK_Target::blenderConstraint, CONSTRAINT_OFF, bConstraint::data, DefIKParam, bKinematicConstraint::dist, iTaSC::ConstraintValues::feedback, bConstraint::flag, bPose::ikparam, LIMITDIST_INSIDE, LIMITDIST_OUTSIDE, bKinematicConstraint::mode, IK_Target::owner, Object::pose, IK_Target::simulation, iTaSC::Timestamp::substep, iTaSC::ConstraintValues::values, bKinematicConstraint::weight, iTaSC::ConstraintSingleValue::y, and iTaSC::ConstraintSingleValue::yd.
Referenced by convert_tree().
|
static |
Definition at line 828 of file itasc_plugin.cpp.
References IK_Target::blenderConstraint, float(), bConstraint::lin_error, iTaSC::ConstraintValues::values, iTaSC::ConstraintSingleValue::y, and iTaSC::ConstraintSingleValue::yd.
Referenced by convert_tree().
|
static |
Definition at line 425 of file itasc_plugin.cpp.
References KDL::atan2(), KDL::epsilon, R, KDL::sqrt(), and t.
Referenced by GetJointRotation(), IK_QRevoluteSegment::SetBasis(), and IK_QElbowSegment::SetBasis().
|
static |
Definition at line 1684 of file itasc_plugin.cpp.
References IK_Scene::armature, IK_Scene::baseFrame, BKE_pose_where_is_bone(), IK_Scene::blArmature, IK_Target::blenderConstraint, IK_Scene::blInvScale, IK_Scene::cache, IK_Scene::channels, IK_Target::constraint, CONSTRAINT_OFF, convert_pose(), copy_v3_v3(), depsgraph, iTaSC::Solver::DLS_QMAX, IK_Target::errorCallback, bPoseChannel::flag, bItasc::flag, bConstraint::flag, float(), IK_Channel::frame, iTaSC::ConstraintSet::getControlParameters(), iTaSC::Armature::getMaxEndEffectorChange(), iTaSC::Armature::getMaxJointChange(), iTaSC::ControlledObject::getNrOfConstraints(), iTaSC::Cache::getPreviousCacheItem(), iTaSC::Armature::getRelativeFrame(), iTaSC::Armature::getSegment(), KDL::Joint::getType(), KDL::Frame::getValue(), if(), ITASC_AUTO_STEP, ITASC_INITIAL_REITERATION, ITASC_REITERATION, ITASC_SIMULATION, IK_Scene::jointArray, IK_Channel::jointValid, blender::math::length(), bItasc::maxvel, mul_v3_fl(), bItasc::numiter, bItasc::numstep, KDL::Frame::p, IK_Channel::parent, IK_Channel::pchan, POSE_CHAIN, POSE_DONE, bPoseChannel::pose_head, bPoseChannel::pose_mat, bPoseChannel::pose_tail, bItasc::precision, IK_Scene::scene, iTaSC::Armature::setJointArray(), iTaSC::Solver::setParam(), simulation, IK_Scene::solver, sub_v3_v3v3(), IK_Channel::tail, IK_Scene::targets, KDL::Joint::TransY, and iTaSC::Scene::update().
Referenced by itasc_execute_tree().
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().
|
static |
Definition at line 512 of file itasc_plugin.cpp.
References ComputeTwist(), EulerAngleFromMatrix(), KDL::Rotation::GetRot(), KDL::Vector2::GetValue(), KDL::Vector::GetValue(), KDL::Rotation::GetXZRot(), IK_REVOLUTE, IK_SWING, IK_TRANSY, IK_XDOF, IK_YDOF, IK_ZDOF, RemoveEulerAngleFromMatrix(), rot, and type.
Referenced by convert_pose(), and joint_callback().
|
static |
Definition at line 1667 of file itasc_plugin.cpp.
References KDL::epsilon, fabs(), Scene::flag, bPose::ikdata, len_v3(), Object::obmat, Object::pose, POSE_IKTREE, and scene.
Referenced by itasc_initialize_tree().
|
static |
Definition at line 212 of file itasc_plugin.cpp.
References Freestyle::a, BLI_addtail(), BLI_listbase_is_empty(), PoseTarget::con, CONSTRAINT_IK_STRETCH, CONSTRAINT_IK_TIP, data, bConstraint::data, ListBase::first, bPoseChannel::flag, if(), bPoseChannel::iktree, MAX2, MEM_callocN, MEM_freeN, MIN2, bPoseChannel::parent, POSE_CHAIN, POSE_IKTREE, size(), t, PoseTarget::tip, and tree.
Referenced by initialize_scene().
|
static |
Definition at line 394 of file itasc_plugin.cpp.
References CONSTRAINT_TYPE_KINEMATIC, constraint_valid(), bPoseChannel::constraints, ListBase::first, initialize_chain(), bConstraint::next, and bConstraint::type.
Referenced by itasc_initialize_tree().
|
static |
Definition at line 365 of file itasc_plugin.cpp.
Referenced by constraint_valid(), and convert_tree().
Definition at line 1941 of file itasc_plugin.cpp.
References IK_Data::first, bPose::ikdata, and scene.
Definition at line 1928 of file itasc_plugin.cpp.
References IK_Data::first, bPose::ikdata, MEM_freeN, and scene.
Referenced by itasc_initialize_tree().
void itasc_execute_tree | ( | struct Depsgraph * | depsgraph, |
struct Scene * | scene, | ||
Object * | ob, | ||
bPoseChannel * | pchan_root, | ||
float | ctime | ||
) |
Definition at line 1899 of file itasc_plugin.cpp.
References DefIKParam, depsgraph, execute_scene(), IK_Data::first, RenderData::frs_sec, RenderData::frs_sec_base, bPose::ikdata, bPose::ikparam, IK_Scene::next, Object::pose, Scene::r, and scene.
void itasc_initialize_tree | ( | struct Depsgraph * | depsgraph, |
struct Scene * | scene, | ||
Object * | ob, | ||
float | ctime | ||
) |
Definition at line 1866 of file itasc_plugin.cpp.
References bPose::chanbase, bPoseChannel::constflag, count, create_scene(), depsgraph, ListBase::first, bPose::flag, bPose::ikdata, init_scene(), initialize_scene(), itasc_clear_data(), itasc_update_param(), bPoseChannel::next, PCHAN_HAS_IK, Object::pose, POSE_WAS_REBUILT, and scene.
Definition at line 1923 of file itasc_plugin.cpp.
void itasc_test_constraint | ( | struct Object * | ob, |
struct bConstraint * | cons | ||
) |
Definition at line 1983 of file itasc_plugin.cpp.
References CONSTRAINT_IK_COPYPOSE, CONSTRAINT_IK_DISTANCE, CONSTRAINT_TYPE_KINEMATIC, data, bConstraint::data, if(), and bConstraint::type.
Definition at line 1954 of file itasc_plugin.cpp.
References iTaSC::ACT_FEEDBACK, CONSTRAINT_ID_ALL, iTaSC::Solver::DLS_EPSILON, iTaSC::Solver::DLS_LAMBDA_MAX, iTaSC::Solver::DLS_QMAX, IK_Data::first, iTaSC::Armature::ID_JOINT, bPose::ikdata, bPose::ikparam, ITASC_SIMULATION, iTaSC::Scene::MAX_TIMESTEP, iTaSC::Scene::MIN_TIMESTEP, and IK_Scene::next.
Referenced by itasc_initialize_tree().
|
static |
Definition at line 835 of file itasc_plugin.cpp.
References iTaSC::ConstraintValues::alpha, axis_angle_to_mat3(), eulO_to_mat3(), iTaSC::ConstraintValues::feedback, bItasc::feedback, GetJointRotation(), iTaSC::ConstraintValues::id, iTaSC::Armature::ID_JOINT_RX, iTaSC::Armature::ID_JOINT_RY, iTaSC::Armature::ID_JOINT_RZ, if(), IK_REVOLUTE, IK_SWING, IK_TRANSY, IK_XDOF, IK_YDOF, IK_ZDOF, bPose::ikparam, IK_Channel::jointType, IK_Channel::jointValid, IK_Channel::jointValue, normalize_qt(), IK_Channel::owner, IK_Channel::pchan, Object::pose, quat_to_mat3(), ROT_MODE_AXISANGLE, iTaSC::ConstraintValues::values, and iTaSC::ConstraintSingleValue::yd.
Referenced by convert_tree().
|
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().
|
static |
Definition at line 556 of file itasc_plugin.cpp.
References BKE_constraint_target_matrix_get(), IK_Target::bldepsgraph, blend_m4_m4m4(), IK_Target::blenderConstraint, IK_Target::blscene, CONSTRAINT_OBTYPE_OBJECT, copy_m4_m4(), copy_v3_v3(), IK_Target::eeBlend, IK_Target::eeRest, bConstraint::enforce, mul_m4_m4m4(), mul_m4_series, next, Object::obmat, IK_Target::owner, bPoseChannel::parent, bPoseChannel::pose_mat, bPoseChannel::pose_tail, and IK_Target::rootChannel.
Referenced by convert_tree().
|
static |
Definition at line 45 of file itasc_plugin.cpp.
Referenced by convert_tree(), copypose_callback(), distance_callback(), get_ikdata(), and itasc_execute_tree().