Blender V4.3
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 "BCSampleData.h"
8#include "collada_utils.h"
9
10#include "MEM_guardedalloc.h"
11
12#include "BKE_armature.hh"
13#include "BKE_fcurve.hh"
14#include "BKE_material.h"
15
16#include "ED_anim_api.hh"
17#include "ED_keyframes_edit.hh"
18
19#include "ANIM_fcurve.hh"
20
21typedef float(TangentPoint)[2];
22
23typedef std::set<float> BCFrameSet;
24typedef std::vector<float> BCFrames;
25typedef std::vector<float> BCValues;
26typedef std::vector<float> BCTimes;
27typedef std::map<int, float> BCValueMap;
28
36
38 private:
39 BC_animation_type key_type;
40 std::string rna_path;
41 int curve_array_index;
42 int curve_subindex; /* only needed for materials */
43
44 public:
45 BCCurveKey();
47 const std::string path,
48 int array_index,
49 int subindex = -1);
50 void operator=(const BCCurveKey &other);
51 std::string get_full_path() const;
52 std::string get_path() const;
53 int get_array_index() const;
54 int get_subindex() const;
55 void set_object_type(BC_animation_type object_type);
57 bool operator<(const BCCurveKey &other) const;
58};
59
61 public:
63
65 float get_frame() const;
66 float get_time(Scene *scene) const;
67 float get_value() const;
68 float get_angle() const;
69 void get_in_tangent(Scene *scene, float point[2], bool as_angle) const;
70 void get_out_tangent(Scene *scene, float point[2], bool as_angle) const;
71 void get_tangent(Scene *scene, float point[2], bool as_angle, int index) const;
72};
73
75 private:
76 BCCurveKey curve_key;
77 float min = 0;
78 float max = 0;
79
80 bool curve_is_local_copy = false;
81 FCurve *fcurve;
82 PointerRNA id_ptr;
83 void init_pointer_rna(Object *ob);
84 void delete_fcurve(FCurve *fcu);
85 FCurve *create_fcurve(int array_index, const char *rna_path);
86 void create_bezt(float frame, float output);
87 void update_range(float val);
88 void init_range(float val);
89
90 public:
93 BCAnimationCurve(const BCCurveKey &key, Object *ob);
96
98 int get_interpolation_type(float sample_frame) const;
99 bool is_animated();
100 bool is_transform_curve() const;
101 bool is_rotation_curve() const;
102 bool is_keyframe(int frame);
103 void adjust_range(int frame);
104
105 std::string get_animation_name(Object *ob) const; /* XXX: this is COLLADA specific. */
106 std::string get_channel_target() const;
107 std::string get_channel_type() const;
108 std::string get_channel_posebone() const; /* returns "" if channel is not a bone channel */
109
110 int get_channel_index() const;
111 int get_subindex() const;
112 std::string get_rna_path() const;
113 FCurve *get_fcurve() const;
114 int sample_count() const;
115
116 float get_value(float frame);
117 void get_values(BCValues &values) const;
118 void get_value_map(BCValueMap &value_map);
119
120 void get_frames(BCFrames &frames) const;
121
122 /* Curve edit functions create a copy of the underlying #FCurve. */
124 bool add_value_from_rna(int frame);
125 bool add_value_from_matrix(const BCSample &sample, int frame);
126 void add_value(float val, int frame);
127 void clean_handles();
128
129 /* experimental stuff */
130 int closest_index_above(float sample_frame, int start_at) const;
131 int closest_index_below(float sample_frame) const;
132};
133
134typedef std::map<BCCurveKey, BCAnimationCurve *> BCAnimationCurveMap;
Functions to modify FCurves.
std::vector< float > BCValues
std::vector< float > BCTimes
std::map< int, float > BCValueMap
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< BCCurveKey, BCAnimationCurve * > BCAnimationCurveMap
std::vector< float > BCFrames
std::set< float > BCFrameSet
General operations, lookup, etc. for materials.
Read Guarded memory(de)allocation.
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
draw_view in_light_buf[] float