Blender V4.5
BCAnimationCurve.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include <map>
8#include <set>
9#include <vector>
10
11#include "BCSampleData.h"
12
13#include "BKE_fcurve.hh"
14
15#include "RNA_types.hh"
16
17#include "ED_anim_api.hh"
18
19using TangentPoint = float[2];
20
21using BCFrameSet = std::set<float>;
22using BCFrames = std::vector<float>;
23using BCValues = std::vector<float>;
24using BCTimes = std::vector<float>;
25using BCValueMap = std::map<int, float>;
26
34
36 private:
37 BC_animation_type key_type;
38 std::string rna_path;
39 int curve_array_index;
40 int curve_subindex; /* only needed for materials */
41
42 public:
43 BCCurveKey();
45 const std::string path,
46 int array_index,
47 int subindex = -1);
48 void operator=(const BCCurveKey &other);
49 std::string get_full_path() const;
50 std::string get_path() const;
51 int get_array_index() const;
52 int get_subindex() const;
53 void set_object_type(BC_animation_type object_type);
55 bool operator<(const BCCurveKey &other) const;
56};
57
59 public:
61
63 float get_frame() const;
64 float get_time(Scene *scene) const;
65 float get_value() const;
66 float get_angle() const;
67 void get_in_tangent(Scene *scene, float point[2], bool as_angle) const;
68 void get_out_tangent(Scene *scene, float point[2], bool as_angle) const;
69 void get_tangent(Scene *scene, float point[2], bool as_angle, int index) const;
70};
71
73 private:
74 BCCurveKey curve_key;
75 float min = 0;
76 float max = 0;
77
78 bool curve_is_local_copy = false;
79 FCurve *fcurve;
80 PointerRNA id_ptr;
81 void init_pointer_rna(Object *ob);
82 void delete_fcurve(FCurve *fcu);
83 FCurve *create_fcurve(int array_index, const char *rna_path);
84 void create_bezt(float frame, float output);
85 void update_range(float val);
86 void init_range(float val);
87
88 public:
91 BCAnimationCurve(const BCCurveKey &key, Object *ob);
94
96 int get_interpolation_type(float sample_frame) const;
97 bool is_animated();
98 bool is_transform_curve() const;
99 bool is_rotation_curve() const;
100 bool is_keyframe(int frame);
101 void adjust_range(int frame);
102
103 std::string get_animation_name(Object *ob) const; /* XXX: this is COLLADA specific. */
104 std::string get_channel_target() const;
105 std::string get_channel_type() const;
106 std::string get_channel_posebone() const; /* returns "" if channel is not a bone channel */
107
108 int get_channel_index() const;
109 int get_subindex() const;
110 std::string get_rna_path() const;
111 FCurve *get_fcurve() const;
112 int sample_count() const;
113
114 float get_value(float frame);
115 void get_values(BCValues &values) const;
116 void get_value_map(BCValueMap &value_map);
117
118 void get_frames(BCFrames &frames) const;
119
120 /* Curve edit functions create a copy of the underlying #FCurve. */
122 bool add_value_from_rna(int frame);
123 bool add_value_from_matrix(const BCSample &sample, int frame);
124 void add_value(float val, int frame);
125 void clean_handles();
126
127 /* experimental stuff */
128 int closest_index_above(float sample_frame, int start_at) const;
129 int closest_index_below(float sample_frame) const;
130};
131
132using BCAnimationCurveMap = std::map<BCCurveKey, BCAnimationCurve *>;
std::vector< float > BCValues
std::set< float > BCFrameSet
std::map< BCCurveKey, BCAnimationCurve * > BCAnimationCurveMap
std::vector< float > BCTimes
std::vector< float > BCFrames
float[2] TangentPoint
BC_animation_type
@ BC_ANIMATION_TYPE_MATERIAL
@ BC_ANIMATION_TYPE_LIGHT
@ BC_ANIMATION_TYPE_OBJECT
@ BC_ANIMATION_TYPE_BONE
@ BC_ANIMATION_TYPE_CAMERA
std::map< int, float > BCValueMap
std::string get_rna_path() const
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
float get_frame() const
BezTriple & bezt
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
float get_value() const
float get_angle() const
std::string get_path() const
int get_subindex() 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
#define output