Blender  V3.3
BCAnimationCurve.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2008 Blender Foundation. All rights reserved. */
3 
4 #pragma once
5 
6 #include "BCSampleData.h"
7 #include "collada_utils.h"
8 
9 #include "MEM_guardedalloc.h"
10 
11 #include "BKE_armature.h"
12 #include "BKE_fcurve.h"
13 #include "BKE_material.h"
14 
15 #include "ED_anim_api.h"
16 #include "ED_keyframes_edit.h"
17 #include "ED_keyframing.h"
18 
19 typedef float(TangentPoint)[2];
20 
21 typedef std::set<float> BCFrameSet;
22 typedef std::vector<float> BCFrames;
23 typedef std::vector<float> BCValues;
24 typedef std::vector<float> BCTimes;
25 typedef std::map<int, float> BCValueMap;
26 
27 typedef enum BC_animation_type {
34 
35 class BCCurveKey {
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 
58 class BCBezTriple {
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:
90  BCAnimationCurve(const BCAnimationCurve &other);
91  BCAnimationCurve(const BCCurveKey &key, Object *ob);
92  BCAnimationCurve(BCCurveKey key, Object *ob, FCurve *fcu);
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 
132 typedef std::map<BCCurveKey, BCAnimationCurve *> BCAnimationCurveMap;
std::vector< float > BCValues
typedef float(TangentPoint)[2]
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.
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
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
int get_subindex() const
bool add_value_from_rna(int frame)
int sample_count() const
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
Scene scene
ccl_global KernelShaderEvalInput ccl_global float * output