28 this->fcurve =
nullptr;
29 this->curve_is_local_copy =
false;
34 this->min = other.min;
35 this->max = other.max;
36 this->fcurve = other.fcurve;
37 this->curve_key = other.curve_key;
38 this->curve_is_local_copy =
false;
39 this->id_ptr = other.id_ptr;
50 this->curve_key = key;
52 this->curve_is_local_copy =
false;
58 this->curve_key = key;
59 this->fcurve =
nullptr;
60 this->curve_is_local_copy =
false;
64void BCAnimationCurve::init_pointer_rna(
Object *ob)
93 stderr,
"BC_animation_curve_type %d not supported", this->curve_key.get_array_index());
98void BCAnimationCurve::delete_fcurve(
FCurve *fcu)
103FCurve *BCAnimationCurve::create_fcurve(
int array_index,
const char *rna_path)
112void BCAnimationCurve::create_bezt(
float frame,
float output)
117 bez.
vec[1][0] = frame;
128 if (curve_is_local_copy && fcurve) {
130 delete_fcurve(fcurve);
131 this->fcurve =
nullptr;
137 return curve_key.get_animation_type() == type;
142 const std::string path = curve_key.get_path();
160 if (pose_bone_name == channel) {
167 return pose_bone_name;
174 switch (curve_key.get_animation_type()) {
180 if (fcurve ==
nullptr || fcurve->rna_path ==
nullptr) {
186 name =
id_name(ob) +
"_" + std::string(boneName);
219 return curve_key.get_array_index();
224 return curve_key.get_subindex();
229 return curve_key.get_path();
234 if (fcurve ==
nullptr) {
237 return fcurve->totvert;
242 if (fcurve ==
nullptr) {
246 const int cframe = fcurve->bezt[start_at].vec[1][0];
248 if (
fabs(cframe - sample_frame) < 0.00001) {
251 return (fcurve->totvert > start_at + 1) ? start_at + 1 : start_at;
256 if (fcurve ==
nullptr) {
260 float lower_frame = sample_frame;
261 float upper_frame = sample_frame;
265 for (
int fcu_index = 0; fcu_index < fcurve->totvert; fcu_index++) {
266 upper_index = fcu_index;
268 const int cframe = fcurve->bezt[fcu_index].vec[1][0];
269 if (cframe <= sample_frame) {
270 lower_frame = cframe;
271 lower_index = fcu_index;
273 if (cframe >= sample_frame) {
274 upper_frame = cframe;
279 if (lower_index == upper_index) {
283 const float fraction = float(sample_frame - lower_frame) / (upper_frame - lower_frame);
284 return (fraction < 0.5) ? lower_index : upper_index;
293 return fcurve->bezt[index].ipo;
303 if (!curve_is_local_copy) {
304 const int index = curve_key.get_array_index();
305 const std::string &path = curve_key.get_path();
306 fcurve = create_fcurve(index, path.c_str());
313 curve_is_local_copy =
true;
321 if (fcurve ==
nullptr) {
329 int totvert = fcurve->totvert;
330 fcurve->bezt =
nullptr;
333 for (
int i = 0;
i < totvert;
i++) {
335 float x = bezt->
vec[1][0];
336 float y = bezt->
vec[1][1];
338 BezTriple *lastb = fcurve->bezt + (fcurve->totvert - 1);
339 lastb->
f1 = lastb->f2 = lastb->f3 = 0;
351 return (
is_rotation_curve() || channel_type ==
"scale" || channel_type ==
"location");
357 return ELEM(channel_type,
"rotation",
"rotation_euler",
"rotation_quaternion");
368void BCAnimationCurve::update_range(
float val)
374void BCAnimationCurve::init_range(
float val)
381 if (fcurve && fcurve->totvert > 1) {
384 int first_frame = fcurve->bezt[0].vec[1][0];
385 if (first_frame == frame_index) {
412 int array_index = curve_key.get_array_index();
421 bool good =
sample.get_value(channel_target, array_index, &val);
433 int array_index = curve_key.get_array_index();
434 const std::string full_path = curve_key.get_full_path();
438 &id_ptr, full_path.c_str(), &
ptr, &prop, &array_index);
439 if (!path_resolved && array_index == 0) {
440 const std::string rna_path = curve_key.get_path();
465 "Out of Bounds while reading data for Curve %s\n",
466 curve_key.get_full_path().c_str());
487 "property type %d not supported for Curve %s\n",
489 curve_key.get_full_path().c_str());
497 fprintf(stderr,
"Path not recognized for Curve %s\n", curve_key.get_full_path().c_str());
508 if (fcurve ==
nullptr) {
512 for (
int i = 0;
i < fcurve->totvert;
i++) {
513 const float frame = fcurve->bezt[
i].vec[1][0];
514 const float val = fcurve->bezt[
i].vec[1][1];
515 value_map[frame] = val;
523 for (
int i = 0;
i < fcurve->totvert;
i++) {
524 const float val = fcurve->bezt[
i].vec[1][0];
525 frames.push_back(val);
534 for (
int i = 0;
i < fcurve->totvert;
i++) {
535 const float val = fcurve->bezt[
i].vec[1][1];
536 values.push_back(val);
543 static float MIN_DISTANCE = 0.00001;
544 return fabs(max - min) > MIN_DISTANCE;
549 if (this->fcurve ==
nullptr) {
553 for (
int i = 0;
i < fcurve->totvert;
i++) {
554 const int cframe = nearbyint(fcurve->bezt[
i].vec[1][0]);
555 if (cframe == frame) {
558 if (cframe > frame) {
569 std::string rhtgt =
rhs.get_channel_target();
570 if (lhtgt == rhtgt) {
572 const int rha =
rhs.get_channel_index();
576 return lhtgt < rhtgt;
583 this->curve_array_index = 0;
584 this->curve_subindex = -1;
588 const std::string path,
589 const int array_index,
592 this->key_type = type;
593 this->rna_path = path;
594 this->curve_array_index = array_index;
595 this->curve_subindex = subindex;
600 this->key_type = other.key_type;
601 this->rna_path = other.rna_path;
602 this->curve_array_index = other.curve_array_index;
603 this->curve_subindex = other.curve_subindex;
608 return this->rna_path +
'[' + std::to_string(this->curve_array_index) +
']';
613 return this->rna_path;
618 return this->curve_array_index;
623 return this->curve_subindex;
628 this->key_type = object_type;
633 return this->key_type;
639 if (this->key_type != other.key_type) {
640 return this->key_type < other.key_type;
643 if (this->curve_subindex != other.curve_subindex) {
644 return this->curve_subindex < other.curve_subindex;
647 if (this->rna_path != other.rna_path) {
648 return this->rna_path < other.rna_path;
651 return this->curve_array_index < other.curve_array_index;
658 return bezt.vec[1][0];
668 return bezt.vec[1][1];
699 point[1] =
bezt.vec[index][1];
Functions to modify FCurves.
bool operator<(const BCAnimationCurve &lhs, const BCAnimationCurve &rhs)
std::vector< float > BCValues
std::vector< float > BCFrames
@ BC_ANIMATION_TYPE_MATERIAL
@ BC_ANIMATION_TYPE_LIGHT
@ BC_ANIMATION_TYPE_OBJECT
@ BC_ANIMATION_TYPE_CAMERA
std::map< int, float > BCValueMap
FCurve * BKE_fcurve_create()
void BKE_fcurve_handles_recalc(FCurve *fcu)
float evaluate_fcurve(const FCurve *fcu, float evaltime)
void BKE_fcurve_free(FCurve *fcu)
General operations, lookup, etc. for materials.
Material * BKE_object_material_get(Object *ob, short act)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
bool bool BLI_str_quoted_substr(const char *__restrict str, const char *__restrict prefix, char *result, size_t result_maxncpy)
struct BezTriple BezTriple
std::string get_rna_path() const
FCurve * get_edit_fcurve()
FCurve * get_fcurve() const
float get_value(float frame)
void get_values(BCValues &values) const
void add_value(float val, int frame)
bool add_value_from_matrix(const BCSample &sample, int frame)
std::string get_channel_type() const
void adjust_range(int frame)
bool is_rotation_curve() const
void get_value_map(BCValueMap &value_map)
bool is_keyframe(int frame)
int get_interpolation_type(float sample_frame) const
bool is_of_animation_type(BC_animation_type type) const
int closest_index_below(float sample_frame) const
void get_frames(BCFrames &frames) const
int closest_index_above(float sample_frame, int start_at) const
bool is_transform_curve() const
std::string get_channel_posebone() const
bool add_value_from_rna(int frame)
std::string get_channel_target() const
int get_channel_index() const
std::string get_animation_name(Object *ob) const
void get_tangent(Scene *scene, float point[2], bool as_angle, int index) const
BCBezTriple(BezTriple &bezt)
float get_time(Scene *scene) const
void get_out_tangent(Scene *scene, float point[2], bool as_angle) const
void get_in_tangent(Scene *scene, float point[2], bool as_angle) const
std::string get_path() const
std::string get_full_path() const
void set_object_type(BC_animation_type object_type)
int get_array_index() const
void operator=(const BCCurveKey &other)
BC_animation_type get_animation_type() const
bool operator<(const BCCurveKey &other) const
std::string id_name(void *id)
bool bc_startswith(std::string const &value, std::string const &starting)
std::string bc_string_before(const std::string &s, const std::string &probe)
std::string bc_string_after(const std::string &s, const std::string &probe)
void MEM_freeN(void *vmemh)
ccl_device_inline float2 fabs(const float2 a)
KeyframeSettings get_keyframe_settings(bool from_userprefs)
SingleKeyingResult insert_vert_fcurve(FCurve *fcu, const float2 position, const KeyframeSettings &settings, eInsertKeyFlags flag)
Main Key-framing API call.
int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
Lesser Key-framing API call.
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_array_check(PropertyRNA *prop)
int RNA_property_int_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
PropertyType RNA_property_type(PropertyRNA *prop)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_boolean_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
PointerRNA RNA_id_pointer_create(ID *id)
bool RNA_path_resolve_full(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)