12 this->fcurve =
nullptr;
13 this->curve_is_local_copy =
false;
18 this->min = other.min;
19 this->max = other.max;
20 this->fcurve = other.fcurve;
21 this->curve_key = other.curve_key;
22 this->curve_is_local_copy =
false;
23 this->id_ptr = other.id_ptr;
34 this->curve_key = key;
36 this->curve_is_local_copy =
false;
42 this->curve_key = key;
43 this->fcurve =
nullptr;
44 this->curve_is_local_copy =
false;
48void BCAnimationCurve::init_pointer_rna(
Object *ob)
77 stderr,
"BC_animation_curve_type %d not supported", this->curve_key.
get_array_index());
82void BCAnimationCurve::delete_fcurve(
FCurve *fcu)
87FCurve *BCAnimationCurve::create_fcurve(
int array_index,
const char *rna_path)
96void BCAnimationCurve::create_bezt(
float frame,
float output)
101 bez.
vec[1][0] = frame;
112 if (curve_is_local_copy && fcurve) {
114 delete_fcurve(fcurve);
115 this->fcurve =
nullptr;
126 const std::string path = curve_key.
get_path();
144 if (pose_bone_name == channel) {
151 return pose_bone_name;
164 if (fcurve ==
nullptr || fcurve->
rna_path ==
nullptr) {
170 name =
id_name(ob) +
"_" + std::string(boneName);
218 if (fcurve ==
nullptr) {
226 if (fcurve ==
nullptr) {
230 const int cframe = fcurve->
bezt[start_at].
vec[1][0];
232 if (
fabs(cframe - sample_frame) < 0.00001) {
235 return (fcurve->
totvert > start_at + 1) ? start_at + 1 : start_at;
240 if (fcurve ==
nullptr) {
244 float lower_frame = sample_frame;
245 float upper_frame = sample_frame;
249 for (
int fcu_index = 0; fcu_index < fcurve->
totvert; fcu_index++) {
250 upper_index = fcu_index;
252 const int cframe = fcurve->
bezt[fcu_index].
vec[1][0];
253 if (cframe <= sample_frame) {
254 lower_frame = cframe;
255 lower_index = fcu_index;
257 if (cframe >= sample_frame) {
258 upper_frame = cframe;
263 if (lower_index == upper_index) {
267 const float fraction =
float(sample_frame - lower_frame) / (upper_frame - lower_frame);
268 return (fraction < 0.5) ? lower_index : upper_index;
277 return fcurve->
bezt[index].
ipo;
287 if (!curve_is_local_copy) {
289 const std::string &path = curve_key.
get_path();
290 fcurve = create_fcurve(index, path.c_str());
297 curve_is_local_copy =
true;
305 if (fcurve ==
nullptr) {
314 fcurve->
bezt =
nullptr;
317 for (
int i = 0; i < totvert; i++) {
319 float x = bezt->
vec[1][0];
320 float y = bezt->
vec[1][1];
323 lastb->
f1 = lastb->f2 = lastb->f3 = 0;
335 return (
is_rotation_curve() || channel_type ==
"scale" || channel_type ==
"location");
341 return ELEM(channel_type,
"rotation",
"rotation_euler",
"rotation_quaternion");
352void BCAnimationCurve::update_range(
float val)
362void BCAnimationCurve::init_range(
float val)
369 if (fcurve && fcurve->
totvert > 1) {
372 int first_frame = fcurve->
bezt[0].
vec[1][0];
373 if (first_frame == frame_index) {
409 bool good =
sample.get_value(channel_target, array_index, &val);
426 &id_ptr, full_path.c_str(), &
ptr, &prop, &array_index);
427 if (!path_resolved && array_index == 0) {
428 const std::string rna_path = curve_key.
get_path();
453 "Out of Bounds while reading data for Curve %s\n",
475 "property type %d not supported for Curve %s\n",
485 fprintf(stderr,
"Path not recognized for Curve %s\n", curve_key.
get_full_path().c_str());
496 if (fcurve ==
nullptr) {
500 for (
int i = 0; i < fcurve->
totvert; i++) {
501 const float frame = fcurve->
bezt[i].
vec[1][0];
502 const float val = fcurve->
bezt[i].
vec[1][1];
503 value_map[frame] = val;
511 for (
int i = 0; i < fcurve->
totvert; i++) {
512 const float val = fcurve->
bezt[i].
vec[1][0];
513 frames.push_back(val);
522 for (
int i = 0; i < fcurve->
totvert; i++) {
523 const float val = fcurve->
bezt[i].
vec[1][1];
524 values.push_back(val);
531 static float MIN_DISTANCE = 0.00001;
532 return fabs(max - min) > MIN_DISTANCE;
537 if (this->fcurve ==
nullptr) {
541 for (
int i = 0; i < fcurve->
totvert; i++) {
542 const int cframe = nearbyint(fcurve->
bezt[i].
vec[1][0]);
543 if (cframe == frame) {
546 if (cframe > frame) {
557 std::string rhtgt =
rhs.get_channel_target();
558 if (lhtgt == rhtgt) {
560 const int rha =
rhs.get_channel_index();
564 return lhtgt < rhtgt;
571 this->curve_array_index = 0;
572 this->curve_subindex = -1;
576 const std::string path,
577 const int array_index,
580 this->key_type = type;
581 this->rna_path = path;
582 this->curve_array_index = array_index;
583 this->curve_subindex = subindex;
588 this->key_type = other.key_type;
589 this->rna_path = other.rna_path;
590 this->curve_array_index = other.curve_array_index;
591 this->curve_subindex = other.curve_subindex;
596 return this->rna_path +
'[' + std::to_string(this->curve_array_index) +
']';
601 return this->rna_path;
606 return this->curve_array_index;
611 return this->curve_subindex;
616 this->key_type = object_type;
621 return this->key_type;
627 if (this->key_type != other.key_type) {
628 return this->key_type < other.key_type;
631 if (this->curve_subindex != other.curve_subindex) {
632 return this->curve_subindex < other.curve_subindex;
635 if (this->rna_path != other.rna_path) {
636 return this->rna_path < other.rna_path;
639 return this->curve_array_index < other.curve_array_index;
bool operator<(const BCAnimationCurve &lhs, const BCAnimationCurve &rhs)
std::vector< float > BCValues
std::map< int, float > BCValueMap
@ BC_ANIMATION_TYPE_MATERIAL
@ BC_ANIMATION_TYPE_LIGHT
@ BC_ANIMATION_TYPE_OBJECT
@ BC_ANIMATION_TYPE_CAMERA
std::vector< float > BCFrames
void BKE_fcurve_handles_recalc(FCurve *fcu)
FCurve * BKE_fcurve_create(void)
float evaluate_fcurve(const FCurve *fcu, float evaltime)
void BKE_fcurve_free(FCurve *fcu)
struct Material * BKE_object_material_get(struct 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)
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)
std::string bc_string_after(const std::string &s, const std::string probe)
std::string bc_string_before(const std::string &s, const std::string probe)
bool bc_startswith(std::string const &value, std::string const &starting)
local_group_size(16, 16) .push_constant(Type rhs
draw_view in_light_buf[] float
void MEM_freeN(void *vmemh)
ccl_device_inline float2 fabs(const float2 a)
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)