68 last = replace ? last + 1 : last;
104 float viewport_size[4];
184 color[3] = 1.0f - (
diff * 0.5f);
185 CLAMP(color[3], 0.2f, 1.0f);
201 const float line_length = 0.7f;
222 for (
const int i : index_range) {
294 immUniform4f(
"outlineColor", hcolor[0], hcolor[1], hcolor[2], 1.0f);
300 for (
const int i : index_range) {
339 const bool sel_handle_only,
359 const BezTriple *left_bezt = active_keyframe_index > 0 ? &fcu->
bezt[active_keyframe_index - 1] :
390 bool sel_handle_only)
451 format,
"color", blender::gpu::VertAttrType::SFLOAT_32_32_32_32);
466 for (
int sel = 0; sel < 2; sel++) {
471 for (
const int i : index_range) {
555 scale[1] /= hsize / unit_scale;
559 last = (first) ? (first + (fcu->
totvert - 1)) : (
nullptr);
596 const bool use_nla_remap,
597 const bool draw_extrapolation)
608 FCurve fcurve_for_draw = *fcu_;
609 fcurve_for_draw.
driver =
nullptr;
614 ac->
scene,
id, &fcurve_for_draw, mapping_flag, &offset);
631 float pixels_per_sample = 1.5f;
644 samplefreq = std::max(samplefreq, 0.1f);
648 samplefreq = std::max(samplefreq, 0.00001f);
659 if (!draw_extrapolation) {
668 if (fcu_end < fcu_start) {
669 std::swap(fcu_start, fcu_end);
673 stime =
max_ff(stime, fcu_start);
674 etime =
min_ff(etime, fcu_end);
677 const int total_samples =
roundf((etime - stime) / samplefreq);
678 if (total_samples <= 0) {
695 for (
int i = 0;
i < total_samples;
i++) {
696 const float ctime = stime +
i * samplefreq;
697 float eval_time = eval_start +
i * eval_freq;
706 eval_time = std::min(eval_time, eval_end);
729 const bool draw_extrapolation)
731 if (!draw_extrapolation && fcu->
totvert == 1) {
736 FPoint *fpt = prevfpt + 1;
739 float unit_scale, offset;
743 const bool extrap_left = draw_extrapolation && prevfpt->
vec[0] > v2d->
cur.
xmin;
748 const bool extrap_right = draw_extrapolation && (prevfpt +
b - 1)->vec[0] < v2d->
cur.
xmax;
770 v[1] = prevfpt->
vec[1];
774 fac = (prevfpt->
vec[0] - fpt->
vec[0]) / (prevfpt->
vec[0] -
v[0]);
778 v[1] = prevfpt->
vec[1] - fac * (prevfpt->
vec[1] - fpt->
vec[1]);
805 v[1] = prevfpt->
vec[1];
810 fac = (prevfpt->
vec[0] - fpt->
vec[0]) / (prevfpt->
vec[0] -
v[0]);
814 v[1] = prevfpt->
vec[1] - fac * (prevfpt->
vec[1] - fpt->
vec[1]);
829 const float points_per_pixel = 0.25f;
830 const int resolution_x = int(((bezt->
vec[1][0] - prevbezt->
vec[1][0]) * pixels_per_unit[0]) *
835 bezt->
vec[1][1], bezt->
vec[2][1], prevbezt->
vec[1][1], prevbezt->
vec[0][1]);
837 bezt->
vec[1][1], bezt->
vec[2][1], prevbezt->
vec[1][1], prevbezt->
vec[0][1]);
838 const int resolution_y = int(((max_y - min_y) * pixels_per_unit[1]) * points_per_pixel);
843 return resolution_x + resolution_y;
855 if (resolution < 2) {
856 curve_vertices.
append({prevbezt->
vec[1][0], prevbezt->
vec[1][1]});
862 resolution =
min_ii(64, resolution);
864 float prev_key[2], prev_handle[2], bez_handle[2], bez_key[2];
869 prev_key[0] = prevbezt->
vec[1][0];
870 prev_key[1] = prevbezt->
vec[1][1];
871 prev_handle[0] = prevbezt->
vec[2][0];
872 prev_handle[1] = prevbezt->
vec[2][1];
874 bez_handle[0] = bezt->
vec[0][0];
875 bez_handle[1] = bezt->
vec[0][1];
876 bez_key[0] = bezt->
vec[1][0];
877 bez_key[1] = bezt->
vec[1][1];
892 bezier_diff_points + 1,
896 for (
float *fp = bezier_diff_points; resolution; resolution--, fp += 2) {
898 const float y = *(fp + 1);
905 const float v2d_xmin,
909 float vertex_position[2];
910 vertex_position[0] = v2d_xmin;
918 vertex_position[1] = bezt->
vec[1][1];
923 float fac = (bezt->
vec[1][0] - next_bezt->
vec[1][0]) / (bezt->
vec[1][0] - vertex_position[0]);
927 vertex_position[1] = bezt->
vec[1][1] - fac * (bezt->
vec[1][1] - next_bezt->
vec[1][1]);
931 float fac = (bezt->
vec[0][0] - bezt->
vec[1][0]) / (bezt->
vec[1][0] - vertex_position[0]);
935 vertex_position[1] = bezt->
vec[1][1] - fac * (bezt->
vec[0][1] - bezt->
vec[1][1]);
938 curve_vertices.
append(vertex_position);
942 const float v2d_xmax,
945 float vertex_position[2];
946 vertex_position[0] = v2d_xmax;
954 vertex_position[1] = bezt->
vec[1][1];
959 float fac = (bezt->
vec[1][0] - prev_bezt->
vec[1][0]) / (bezt->
vec[1][0] - vertex_position[0]);
963 vertex_position[1] = bezt->
vec[1][1] - fac * (bezt->
vec[1][1] - prev_bezt->
vec[1][1]);
967 float fac = (bezt->
vec[2][0] - bezt->
vec[1][0]) / (bezt->
vec[1][0] - vertex_position[0]);
971 vertex_position[1] = bezt->
vec[1][1] - fac * (bezt->
vec[2][1] - bezt->
vec[1][1]);
974 curve_vertices.
append(vertex_position);
984 const blender::float2 pixels_per_unit = {window_width / v2d_frame_range,
985 (window_height / v2d_value_range) * unit_scale};
986 return pixels_per_unit;
1001 bounds.ymin, right_key->
vec[1][1], right_key->
vec[0][1], left_key->
vec[2][1]);
1003 bounds.ymax, right_key->
vec[1][1], right_key->
vec[0][1], left_key->
vec[2][1]);
1016 if (!draw_extrapolation && fcu->
totvert == 1) {
1031 if (draw_extrapolation && fcu->
bezt[0].
vec[1][0] > v2d->
cur.
xmin) {
1044 const float pixel_width = v2d_frame_range / window_width;
1045 const float samples_per_pixel = 0.66f;
1046 const float evaluation_step = pixel_width / samples_per_pixel;
1050 first_key->
vec[1][0], first_key->
vec[1][0], first_key->
vec[1][1], first_key->
vec[1][1]};
1052 bool has_skipped_keys =
false;
1053 const float min_pixel_distance = 3.0f;
1062 if (pixel_distance >= min_pixel_distance && has_skipped_keys) {
1068 has_skipped_keys =
false;
1070 prevbezt->
vec[1][0], prevbezt->
vec[1][0], prevbezt->
vec[1][1], prevbezt->
vec[1][1]};
1076 if (pixel_distance < min_pixel_distance) {
1078 has_skipped_keys =
true;
1082 switch (prevbezt->
ipo) {
1087 curve_vertices.
append({prevbezt->
vec[1][0], prevbezt->
vec[1][1]});
1088 curve_vertices.
append({bezt->
vec[1][0], prevbezt->
vec[1][1]});
1093 curve_vertices.
append({prevbezt->
vec[1][0], prevbezt->
vec[1][1]});
1104 curve_vertices.
append(prevbezt->
vec[1]);
1105 float current_frame = prevbezt->
vec[1][0] + evaluation_step;
1106 while (current_frame < bezt->vec[1][0]) {
1108 current_frame += evaluation_step;
1126 if (curve_vertices.
size() < 2) {
1132 for (
const float2 vertex : curve_vertices) {
1177 float viewport_size[4];
1227 draw_extrapolation);
1236 else if (fcu->
fpt) {
1259 switch (fcm->
type) {
1270 ac->
scene, ale->
id, fcu, mapping_flag, &offset);
1328 float viewport_size[4];
1365 float y = fcu->
curval * unitfac;
1446 float viewport_size[4];
1457 const bool draw_extrapolation =
false;
1480 ListBase anim_data = {
nullptr,
nullptr};
1497 ale_active_fcurve = ale;
1505 if (ale_active_fcurve !=
nullptr) {
1532 size_t channel_index = 0;
1536 ale = ale->
next, ymax -= channel_step, channel_index++)
1551 size_t channel_index = 0;
1558 ale = ale->
next, ymax -= channel_step, channel_index++)
AnimData * BKE_animdata_from_id(const ID *id)
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
int BKE_fcurve_bezt_binarysearch_index(const BezTriple array[], float frame, int arraylen, bool *r_replace)
int BKE_fcurve_active_keyframe_index(const FCurve *fcu)
bool BKE_fcurve_is_protected(const FCurve *fcu)
bool BKE_fcurve_are_keyframes_usable(const FCurve *fcu)
FModifier * find_active_fmodifier(ListBase *modifiers)
float evaluate_fcurve(const FCurve *fcu, float evaltime)
bool BKE_fcurve_calc_range(const FCurve *fcu, float *r_min, float *r_max, bool selected_keys_only)
void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2])
float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, eNlaTime_ConvertModes mode)
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
MINLINE float max_ffff(float a, float b, float c, float d)
MINLINE float max_ff(float a, float b)
MINLINE int min_ii(int a, int b)
MINLINE float min_ffff(float a, float b, float c, float d)
MINLINE float min_ff(float a, float b)
MINLINE int clamp_i(int value, int min, int max)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
#define IN_RANGE(a, b, c)
@ FMODIFIER_TYPE_ENVELOPE
#define FCURVE_ACTIVE_KEYFRAME_NONE
@ FCURVE_EXTRAPOLATE_CONSTANT
#define BEZT_ISSEL_ANY(bezt)
@ SIPO_NO_DRAW_EXTRAPOLATION
@ USER_ANIM_HIGH_QUALITY_DRAWING
@ USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS
@ ANIMFILTER_DATA_VISIBLE
@ ANIMFILTER_CURVE_VISIBLE
void GPU_matrix_translate_2fv(const float vec[2])
void GPU_matrix_scale_2f(float x, float y)
void GPU_matrix_translate_2f(float x, float y)
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
@ GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_3D_FLAT_COLOR
@ GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA
@ GPU_SHADER_3D_POINT_UNIFORM_COLOR
void GPU_program_point_size(bool enable)
void GPU_line_width(float width)
void GPU_line_smooth(bool enable)
void GPU_blend(GPUBlend blend)
float GPU_line_width_get()
void GPU_point_size(float size)
void GPU_viewport_size_get_f(float coords[4])
uiBlock * UI_block_begin(const bContext *C, ARegion *region, std::string name, blender::ui::EmbossType emboss)
void UI_block_draw(const bContext *C, uiBlock *block)
void UI_block_end(const bContext *C, uiBlock *block)
void UI_GetThemeColor3fv(int colorid, float col[3])
@ TH_HANDLE_VERTEX_SELECT
void UI_GetThemeColor4fv(int colorid, float col[4])
void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4])
float UI_GetThemeValuef(int colorid)
void UI_view2d_scale_get(const View2D *v2d, float *r_x, float *r_y)
float UI_view2d_scale_get_x(const View2D *v2d)
void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListElem *ale, uiBlock *block, const rctf *rect, size_t channel_index)
void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc, size_t channel_index)
float ANIM_UI_get_channel_step()
float ANIM_UI_get_first_channel_top(View2D *v2d)
float ANIM_UI_get_channel_height()
void ANIM_animdata_freelist(ListBase *anim_data)
short ANIM_get_normalization_flags(SpaceLink *space_link)
void ANIM_nla_mapping_apply_if_needed_fcurve(bAnimListElem *ale, FCurve *fcu, const bool restore, const bool only_keys)
bool ANIM_nla_mapping_allowed(const bAnimListElem *ale)
float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag, float *r_offset)
float ANIM_nla_tweakedit_remap(bAnimListElem *ale, const float cframe, const eNlaTime_ConvertModes mode)
size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, const eAnimFilter_Flags filter_mode, void *data, const eAnimCont_Types datatype)
ATTR_WARN_UNUSED_RESULT const BMVert * v
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
constexpr int64_t first() const
constexpr int64_t last(const int64_t n=0) const
constexpr IndexRange drop_front(int64_t n) const
void append(const T &value)
void append(const T &value)
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
struct @021025263243242147216143265077100330027142264337::@240232116316110053135047106323056371161236243121 attr_id
static float fcurve_display_alpha(const FCurve *fcu)
static void draw_fcurve_keyframe_vertices(FCurve *fcu, View2D *v2d, const uint pos)
static void draw_fcurve_samples(ARegion *region, const FCurve *fcu, const float unit_scale)
static void draw_fcurve_handles(SpaceGraph *sipo, ARegion *region, const FCurve *fcu)
static int calculate_bezt_draw_resolution(BezTriple *bezt, BezTriple *prevbezt, const blender::float2 pixels_per_unit)
static float calculate_pixel_distance(const rctf &bounds, const blender::float2 pixels_per_unit)
static void draw_cross(float position[2], const float scale[2], uint attr_id)
static void add_extrapolation_point_left(const FCurve *fcu, const float v2d_xmin, blender::Vector< blender::float2 > &curve_vertices)
static void draw_fcurve_selected_keyframe_vertices(FCurve *fcu, bool sel, uint pos, const blender::IndexRange index_range)
static void add_bezt_vertices(BezTriple *bezt, BezTriple *prevbezt, int resolution, blender::Vector< blender::float2 > &curve_vertices)
static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
static void draw_fcurve_active_handle_vertices(const FCurve *fcu, const bool sel_handle_only, const uint pos)
static void draw_fcurve_selected_handle_vertices(FCurve *fcu, View2D *v2d, bool sel, bool sel_handle_only, uint pos)
static void set_fcurve_vertex_color(FCurve *fcu, bool sel)
void graph_draw_ghost_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region)
static void expand_key_bounds(const BezTriple *left_key, const BezTriple *right_key, rctf &bounds)
static void draw_fcurve_handle_vertices(FCurve *fcu, View2D *v2d, bool sel_handle_only, uint pos)
static void draw_fcurve_vertices(ARegion *region, FCurve *fcu, bool do_handles, bool sel_handle_only)
static void draw_fcurve_curve_keys(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d, uint pos, const bool draw_extrapolation)
static void draw_fcurve_curve(bAnimContext *ac, ID *id, const FCurve *fcu_, View2D *v2d, uint pos, const bool use_nla_remap, const bool draw_extrapolation)
static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d, const uint shdr_pos, const bool draw_extrapolation)
static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d, bAnimListElem *ale_nla_remap)
static void draw_fcurve_active_vertex(const FCurve *fcu, const View2D *v2d, const uint pos)
void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region, const ListBase &anim_data)
static bool draw_fcurve_handles_check(const SpaceGraph *sipo, const FCurve *fcu)
static void draw_fcurve(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, bAnimListElem *ale)
static blender::float2 calculate_pixels_per_unit(View2D *v2d, const float unit_scale)
void graph_draw_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, short sel)
static blender::IndexRange get_bounding_bezt_index_range(const FCurve *fcu, const float min, const float max)
static void add_extrapolation_point_right(const FCurve *fcu, const float v2d_xmax, blender::Vector< blender::float2 > &curve_vertices)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
VecBase< float, 2 > float2
SpaceGraph_Runtime runtime