28#include "RNA_prototypes.hh"
44 return axis_flag & (1 <<
index);
51 copy[i] = *(value[i]);
81 values[i] += factor * (target - values[i]);
99 values[i] += factor * (target[i] - values[i]);
108 interpolated[i] =
interpf(
b[i], a[i], factor);
129 {*id_cast<Object *>(ptr.owner_id), *
static_cast<bPoseChannel *
>(ptr.data)});
137 return transformables;
151 const Rotation *reference_euler)
const
153 if (
mode == this->mode) {
158 switch (this->mode) {
191 if (reference_euler) {
227 return {{1, 0, 0, 0}, mode};
229 return {{0, 0, 1, 0}, mode};
232 return {{0, 0, 0}, mode};
311 fcurve_group_name_(pchan.
name),
313 location_({pchan.
loc, 3}),
314 rotation_mode_(&pchan.rotmode),
315 scale_({pchan.scale, 3})
325 fcurve_group_name_(
"Object Transforms"),
327 location_({obj.
loc, 3}),
329 scale_({obj.scale, 3})
332 rna_path_from_id_ =
"";
344 return static_cast<Object *
>(data_);
349 return rna_path_from_id_;
359 property_name =
"location";
365 property_name =
"scale";
373 if (rna_path_from_id_.empty()) {
374 return property_name;
376 return fmt::format(
"{}.{}", rna_path_from_id_, property_name);
394 return location_.as_span();
397 const TransformFloatPtrs *rotation_array = get_rotation_array_from_mode(*rotation_mode_);
401 return scale_.as_span();
418 const TransformFloatPtrs *rotation_array = get_rotation_array_from_mode(*rotation_mode_);
420 if (rotation_array->
size() > values.
size()) {
427 for (
const int i : rotation_array->
index_range()) {
431 *(*rotation_array)[i] = values[i];
452 const TransformFloatPtrs *rotation_array = get_rotation_array_from_mode(*rotation_mode_);
453 if (rotation_array->
size() != target.
size()) {
456 BLI_assert_msg(
false,
"Cannot do blending with differing rotation modes");
461 rotation.mode = *rotation_mode_;
462 rotation.values = target;
484 const TransformFloatPtrs *rotation_array = get_rotation_array_from_mode(*rotation_mode_);
487 rotation.mode = *rotation_mode_;
488 rotation.values.reinitialize(rotation_array->
size());
489 rotation.values.fill(target);
515 return rotations_array;
526 rotation.mode = mode;
527 const Array<float *> *rotations_array = get_rotation_array_from_mode(mode);
535 const TransformFloatPtrs *rotations_array = get_rotation_array_from_mode(*rotation_mode_);
537 if (rotation.mode == *rotation_mode_) {
539 for (
const int i : rotations_array->
index_range()) {
540 *(*rotations_array)[i] = rotation.values[i];
545 Rotation rot_in_correct_mode = rotation.converted_to_mode(*rotation_mode_);
546 for (
const int i : rotations_array->
index_range()) {
547 *(*rotations_array)[i] = rot_in_correct_mode.
values[i];
553 return *rotation_mode_;
558 *rotation_mode_ = mode;
568 const TransformFloatPtrs *rotations_array = get_rotation_array_from_mode(*rotation_mode_);
572 switch (*rotation_mode_) {
576 current_quat[i] = *((*rotations_array)[i]);
588 result[i] = *((*rotations_array)[i]);
592 compatible_rotation.
values[0],
593 &compatible_rotation.
values[1],
603 result[i] = *((*rotations_array)[i]);
611 for (
const int i :
result.index_range()) {
612 *(*rotations_array)[i] =
result[i];
620 switch (this->type_) {
622 Object *ob_eval = id_cast<Object *>(evaluated_id);
624 if (!pose_bone_eval) {
631 Object *ob_eval = id_cast<Object *>(evaluated_id);
632 return ob_eval->object_to_world();
645 switch (this->type_) {
647 Object *ob_eval = id_cast<Object *>(evaluated_id);
649 if (!pose_bone_eval) {
653 Bone *bone = pose_bone_eval->bone_get(*ob_eval);
654 float4x4 object_local = ob_eval->world_to_object() * world_matrix;
663 Object *ob_eval = id_cast<Object *>(evaluated_id);
667 ob_eval->
parent->world_to_object();
671 return math::invert(delta_matrix) * parent_matrix * world_matrix;
Helper functions for animation to interact with the RNA system.
Blender kernel action and pose functionality.
General operations, lookup, etc. for blender objects.
Object is a sort of wrapper for general info.
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
IndexRange index_range() const
void reinitialize(const int64_t new_size)
constexpr IndexRange()=default
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
void append(const T &value)
StringRefNull get_rotation_mode_path(eRotationModes rotation_mode)
std::string get_pose_bone_rna_path(const bPoseChannel &pose_bone)
Rotation identity_rotation(const eRotationModes mode)
Array< float *, 4 > TransformFloatPtrs
static TransformFloats copy_pointers_to_values(const Span< float * > value)
static void build_rotations_array(Array< TransformFloatPtrs > &rotations, float *euler, float *quat, float *axis, float *angle)
Rotation rotation_interpolated(const Rotation &a, const Rotation &b, const float factor)
static void interpolate_axis_angle(const float a_angle, const float3 &a_axis, const float b_angle, const float3 &b_axis, const float factor, float *r_angle, float r_axis[3])
static void copy_span_into_mutable_span(const Span< float > value, MutableSpan< float > target, const AxisMutable axis_flag)
static void blend_linear(MutableSpan< float > values, const float target, const float factor, const AxisMutable axis_flag)
static bool is_axis_mutable(const int index, const AxisMutable axis_flag)
Array< float > property_interpolated(const Span< float > a, const Span< float > b, const float factor)
Array< float, 4 > TransformFloats
Vector< ed::AnimTransformable > selected_transformables_from_context(bContext &C)
CartesianBasis invert(const CartesianBasis &basis)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
float normalize_qt(float q[4])
void axis_angle_to_quat(float r[4], const float axis[3], float angle)
ID * DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
MatBase< float, 4, 4 > float4x4
void quat_to_compatible_eulO(float eul[3], const float oldrot[3], short order, const float quat[4])
VecBase< float, 4 > float4
void BKE_armature_mat_pose_to_bone(bke::PChanBoneConst pchanbone, const float inmat[4][4], float outmat[4][4])
void copy_qt_qt(float q[4], const float a[4])
void interp_qt_qtqt(float q[4], const float a[4], const float b[4], float t)
float4x4 BKE_object_delta_matrix_get(const Object &obj)
void quat_to_eulO(float e[3], short order, const float q[4])
void quat_to_axis_angle(float axis[3], float *angle, const float q[4])
bool CTX_data_selected_pose_bones(const bContext *C, Vector< PointerRNA > *list)
void eulO_to_quat(float q[4], const float e[3], short order)
MINLINE float interpf(float target, float origin, float t)
VecBase< float, 3 > float3
bool CTX_data_selected_objects(const bContext *C, Vector< PointerRNA > *list)
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
const c_style_mat & ptr() const
static MatBase identity()
Rotation converted_to_mode(eRotationModes mode, const Rotation *reference_euler=nullptr) const