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)
464 for (
int sel = 0; sel < 2; sel++) {
469 for (
const int i : index_range) {
553 scale[1] /= hsize / unit_scale;
557 last = (first) ? (first + (fcu->
totvert - 1)) : (
nullptr);
593 const bool use_nla_remap,
594 const bool draw_extrapolation)
605 FCurve fcurve_for_draw = *fcu_;
606 fcurve_for_draw.
driver =
nullptr;
611 ac->
scene,
id, &fcurve_for_draw, mapping_flag, &offset);
628 float pixels_per_sample = 1.5f;
641 samplefreq = std::max(samplefreq, 0.1f);
645 samplefreq = std::max(samplefreq, 0.00001f);
656 if (!draw_extrapolation) {
665 if (fcu_end < fcu_start) {
666 std::swap(fcu_start, fcu_end);
670 stime =
max_ff(stime, fcu_start);
671 etime =
min_ff(etime, fcu_end);
674 const int total_samples = roundf((etime - stime) / samplefreq);
675 if (total_samples <= 0) {
692 for (
int i = 0;
i < total_samples;
i++) {
693 const float ctime = stime +
i * samplefreq;
694 float eval_time = eval_start +
i * eval_freq;
703 eval_time = std::min(eval_time, eval_end);
726 const bool draw_extrapolation)
728 if (!draw_extrapolation && fcu->
totvert == 1) {
733 FPoint *fpt = prevfpt + 1;
736 float unit_scale, offset;
740 const bool extrap_left = draw_extrapolation && prevfpt->
vec[0] > v2d->
cur.
xmin;
745 const bool extrap_right = draw_extrapolation && (prevfpt +
b - 1)->vec[0] < v2d->
cur.
xmax;
767 v[1] = prevfpt->
vec[1];
771 fac = (prevfpt->
vec[0] - fpt->
vec[0]) / (prevfpt->
vec[0] -
v[0]);
775 v[1] = prevfpt->
vec[1] - fac * (prevfpt->
vec[1] - fpt->
vec[1]);
802 v[1] = prevfpt->
vec[1];
807 fac = (prevfpt->
vec[0] - fpt->
vec[0]) / (prevfpt->
vec[0] -
v[0]);
811 v[1] = prevfpt->
vec[1] - fac * (prevfpt->
vec[1] - fpt->
vec[1]);
826 const float points_per_pixel = 0.25f;
827 const int resolution_x = int(((bezt->
vec[1][0] - prevbezt->
vec[1][0]) * pixels_per_unit[0]) *
832 bezt->
vec[1][1], bezt->
vec[2][1], prevbezt->
vec[1][1], prevbezt->
vec[0][1]);
834 bezt->
vec[1][1], bezt->
vec[2][1], prevbezt->
vec[1][1], prevbezt->
vec[0][1]);
835 const int resolution_y = int(((max_y - min_y) * pixels_per_unit[1]) * points_per_pixel);
840 return resolution_x + resolution_y;
852 if (resolution < 2) {
853 curve_vertices.
append({prevbezt->
vec[1][0], prevbezt->
vec[1][1]});
859 resolution =
min_ii(64, resolution);
861 float prev_key[2], prev_handle[2], bez_handle[2], bez_key[2];
866 prev_key[0] = prevbezt->
vec[1][0];
867 prev_key[1] = prevbezt->
vec[1][1];
868 prev_handle[0] = prevbezt->
vec[2][0];
869 prev_handle[1] = prevbezt->
vec[2][1];
871 bez_handle[0] = bezt->
vec[0][0];
872 bez_handle[1] = bezt->
vec[0][1];
873 bez_key[0] = bezt->
vec[1][0];
874 bez_key[1] = bezt->
vec[1][1];
889 bezier_diff_points + 1,
893 for (
float *fp = bezier_diff_points; resolution; resolution--, fp += 2) {
895 const float y = *(fp + 1);
902 const float v2d_xmin,
906 float vertex_position[2];
907 vertex_position[0] = v2d_xmin;
915 vertex_position[1] = bezt->
vec[1][1];
920 float fac = (bezt->
vec[1][0] - next_bezt->
vec[1][0]) / (bezt->
vec[1][0] - vertex_position[0]);
924 vertex_position[1] = bezt->
vec[1][1] - fac * (bezt->
vec[1][1] - next_bezt->
vec[1][1]);
928 float fac = (bezt->
vec[0][0] - bezt->
vec[1][0]) / (bezt->
vec[1][0] - vertex_position[0]);
932 vertex_position[1] = bezt->
vec[1][1] - fac * (bezt->
vec[0][1] - bezt->
vec[1][1]);
935 curve_vertices.
append(vertex_position);
939 const float v2d_xmax,
942 float vertex_position[2];
943 vertex_position[0] = v2d_xmax;
951 vertex_position[1] = bezt->
vec[1][1];
956 float fac = (bezt->
vec[1][0] - prev_bezt->
vec[1][0]) / (bezt->
vec[1][0] - vertex_position[0]);
960 vertex_position[1] = bezt->
vec[1][1] - fac * (bezt->
vec[1][1] - prev_bezt->
vec[1][1]);
964 float fac = (bezt->
vec[2][0] - bezt->
vec[1][0]) / (bezt->
vec[1][0] - vertex_position[0]);
968 vertex_position[1] = bezt->
vec[1][1] - fac * (bezt->
vec[2][1] - bezt->
vec[1][1]);
971 curve_vertices.
append(vertex_position);
981 const blender::float2 pixels_per_unit = {window_width / v2d_frame_range,
982 (window_height / v2d_value_range) * unit_scale};
983 return pixels_per_unit;
998 bounds.ymin, right_key->
vec[1][1], right_key->
vec[0][1], left_key->
vec[2][1]);
1000 bounds.ymax, right_key->
vec[1][1], right_key->
vec[0][1], left_key->
vec[2][1]);
1013 if (!draw_extrapolation && fcu->
totvert == 1) {
1028 if (draw_extrapolation && fcu->
bezt[0].
vec[1][0] > v2d->
cur.
xmin) {
1041 const float pixel_width = v2d_frame_range / window_width;
1042 const float samples_per_pixel = 0.66f;
1043 const float evaluation_step = pixel_width / samples_per_pixel;
1047 first_key->
vec[1][0], first_key->
vec[1][0], first_key->
vec[1][1], first_key->
vec[1][1]};
1049 bool has_skipped_keys =
false;
1050 const float min_pixel_distance = 3.0f;
1059 if (pixel_distance >= min_pixel_distance && has_skipped_keys) {
1065 has_skipped_keys =
false;
1067 prevbezt->
vec[1][0], prevbezt->
vec[1][0], prevbezt->
vec[1][1], prevbezt->
vec[1][1]};
1073 if (pixel_distance < min_pixel_distance) {
1075 has_skipped_keys =
true;
1079 switch (prevbezt->
ipo) {
1084 curve_vertices.
append({prevbezt->
vec[1][0], prevbezt->
vec[1][1]});
1085 curve_vertices.
append({bezt->
vec[1][0], prevbezt->
vec[1][1]});
1090 curve_vertices.
append({prevbezt->
vec[1][0], prevbezt->
vec[1][1]});
1101 curve_vertices.
append(prevbezt->
vec[1]);
1102 float current_frame = prevbezt->
vec[1][0] + evaluation_step;
1103 while (current_frame < bezt->vec[1][0]) {
1105 current_frame += evaluation_step;
1123 if (curve_vertices.
size() < 2) {
1129 for (
const float2 vertex : curve_vertices) {
1174 float viewport_size[4];
1224 draw_extrapolation);
1233 else if (fcu->
fpt) {
1256 switch (fcm->
type) {
1267 ac->
scene, ale->
id, fcu, mapping_flag, &offset);
1325 float viewport_size[4];
1362 float y = fcu->
curval * unitfac;
1443 float viewport_size[4];
1454 const bool draw_extrapolation =
false;
1477 ListBase anim_data = {
nullptr,
nullptr};
1494 ale_active_fcurve = ale;
1502 if (ale_active_fcurve !=
nullptr) {
1529 size_t channel_index = 0;
1533 ale = ale->
next, ymax -= channel_step, channel_index++)
1548 size_t channel_index = 0;
1555 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_blend(eGPUBlend blend)
void GPU_line_width(float width)
void GPU_line_smooth(bool enable)
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 @064345207361167251075330302113175271221317160336::@201157344026354305110036153026103256267276205234 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