66 last = replace ? last + 1 : last;
101 float viewport_size[4];
133 for (i = 0, fed = env->
data; i < env->
totvert; i++, fed++) {
181 color[3] = 1.0f - (
diff * 0.5f);
182 CLAMP(color[3], 0.2f, 1.0f);
198 const float line_length = 0.7f;
219 for (
const int i : index_range) {
291 immUniform4f(
"outlineColor", hcolor[0], hcolor[1], hcolor[2], 1.0f);
297 for (
const int i : index_range) {
336 const bool sel_handle_only,
356 const BezTriple *left_bezt = active_keyframe_index > 0 ? &fcu->
bezt[active_keyframe_index - 1] :
387 bool sel_handle_only)
389 View2D *v2d = ®ion->v2d;
457 fcu, region->v2d.cur.xmin, region->v2d.cur.xmax);
462 for (
int sel = 0; sel < 2; sel++) {
467 for (
const int i : index_range) {
551 scale[1] /= hsize / unit_scale;
555 last = (first) ? (first + (fcu->
totvert - 1)) : (
nullptr);
591 const bool use_nla_remap,
592 const bool draw_extrapolation)
603 FCurve fcurve_for_draw = *fcu_;
604 fcurve_for_draw.
driver =
nullptr;
609 ac->
scene,
id, &fcurve_for_draw, mapping_flag, &offset);
626 float pixels_per_sample = 1.5f;
639 if (samplefreq < 0.1f) {
645 if (samplefreq < 0.00001f) {
646 samplefreq = 0.00001f;
658 if (!draw_extrapolation) {
667 if (fcu_end < fcu_start) {
668 std::swap(fcu_start, fcu_end);
672 stime =
max_ff(stime, fcu_start);
673 etime =
min_ff(etime, fcu_end);
676 const int total_samples = roundf((etime - stime) / samplefreq);
677 if (total_samples <= 0) {
694 for (
int i = 0; i < total_samples; i++) {
695 const float ctime = stime + i * samplefreq;
696 float eval_time = eval_start + i * eval_freq;
705 if (eval_time > eval_end) {
706 eval_time = eval_end;
730 const bool draw_extrapolation)
732 if (!draw_extrapolation && fcu->
totvert == 1) {
737 FPoint *fpt = prevfpt + 1;
740 float unit_scale, offset;
744 const bool extrap_left = draw_extrapolation && prevfpt->
vec[0] > v2d->
cur.
xmin;
749 const bool extrap_right = draw_extrapolation && (prevfpt +
b - 1)->vec[0] < v2d->
cur.
xmax;
771 v[1] = prevfpt->
vec[1];
775 fac = (prevfpt->
vec[0] - fpt->
vec[0]) / (prevfpt->
vec[0] -
v[0]);
779 v[1] = prevfpt->
vec[1] - fac * (prevfpt->
vec[1] - fpt->
vec[1]);
806 v[1] = prevfpt->
vec[1];
811 fac = (prevfpt->
vec[0] - fpt->
vec[0]) / (prevfpt->
vec[0] -
v[0]);
815 v[1] = prevfpt->
vec[1] - fac * (prevfpt->
vec[1] - fpt->
vec[1]);
830 const float points_per_pixel = 0.25f;
831 const int resolution_x =
int(((bezt->
vec[1][0] - prevbezt->
vec[1][0]) * pixels_per_unit[0]) *
836 bezt->
vec[1][1], bezt->
vec[2][1], prevbezt->
vec[1][1], prevbezt->
vec[0][1]);
838 bezt->
vec[1][1], bezt->
vec[2][1], prevbezt->
vec[1][1], prevbezt->
vec[0][1]);
839 const int resolution_y =
int(((max_y - min_y) * pixels_per_unit[1]) * points_per_pixel);
844 return resolution_x + resolution_y;
856 if (resolution < 2) {
857 curve_vertices.
append({prevbezt->
vec[1][0], prevbezt->
vec[1][1]});
863 resolution =
min_ii(64, resolution);
865 float prev_key[2], prev_handle[2], bez_handle[2], bez_key[2];
868 float *bezier_diff_points =
static_cast<float *
>(
869 MEM_mallocN(
sizeof(
float) * ((resolution + 1) * 2),
"Draw bezt data"));
871 prev_key[0] = prevbezt->
vec[1][0];
872 prev_key[1] = prevbezt->
vec[1][1];
873 prev_handle[0] = prevbezt->
vec[2][0];
874 prev_handle[1] = prevbezt->
vec[2][1];
876 bez_handle[0] = bezt->
vec[0][0];
877 bez_handle[1] = bezt->
vec[0][1];
878 bez_key[0] = bezt->
vec[1][0];
879 bez_key[1] = bezt->
vec[1][1];
894 bezier_diff_points + 1,
898 for (
float *fp = bezier_diff_points; resolution; resolution--, fp += 2) {
900 const float y = *(fp + 1);
907 const float v2d_xmin,
911 float vertex_position[2];
912 vertex_position[0] = v2d_xmin;
920 vertex_position[1] = bezt->
vec[1][1];
925 float fac = (bezt->
vec[1][0] - next_bezt->
vec[1][0]) / (bezt->
vec[1][0] - vertex_position[0]);
929 vertex_position[1] = bezt->
vec[1][1] - fac * (bezt->
vec[1][1] - next_bezt->
vec[1][1]);
933 float fac = (bezt->
vec[0][0] - bezt->
vec[1][0]) / (bezt->
vec[1][0] - vertex_position[0]);
937 vertex_position[1] = bezt->
vec[1][1] - fac * (bezt->
vec[0][1] - bezt->
vec[1][1]);
940 curve_vertices.
append(vertex_position);
944 const float v2d_xmax,
947 float vertex_position[2];
948 vertex_position[0] = v2d_xmax;
956 vertex_position[1] = bezt->
vec[1][1];
961 float fac = (bezt->
vec[1][0] - prev_bezt->
vec[1][0]) / (bezt->
vec[1][0] - vertex_position[0]);
965 vertex_position[1] = bezt->
vec[1][1] - fac * (bezt->
vec[1][1] - prev_bezt->
vec[1][1]);
969 float fac = (bezt->
vec[2][0] - bezt->
vec[1][0]) / (bezt->
vec[1][0] - vertex_position[0]);
973 vertex_position[1] = bezt->
vec[1][1] - fac * (bezt->
vec[2][1] - bezt->
vec[1][1]);
976 curve_vertices.
append(vertex_position);
986 const blender::float2 pixels_per_unit = {window_width / v2d_frame_range,
987 (window_height / v2d_value_range) * unit_scale};
988 return pixels_per_unit;
1003 bounds.ymin, right_key->
vec[1][1], right_key->
vec[0][1], left_key->
vec[2][1]);
1005 bounds.ymax, right_key->
vec[1][1], right_key->
vec[0][1], left_key->
vec[2][1]);
1018 if (!draw_extrapolation && fcu->
totvert == 1) {
1030 Vector<float2> curve_vertices;
1033 if (draw_extrapolation && fcu->
bezt[0].
vec[1][0] > v2d->
cur.
xmin) {
1040 curve_vertices.append(
1046 const float pixel_width = v2d_frame_range / window_width;
1047 const float samples_per_pixel = 0.66f;
1048 const float evaluation_step = pixel_width / samples_per_pixel;
1052 first_key->
vec[1][0], first_key->
vec[1][0], first_key->
vec[1][1], first_key->
vec[1][1]};
1054 bool has_skipped_keys =
false;
1055 const float min_pixel_distance = 3.0f;
1058 for (
const int i : index_range.
drop_front(1)) {
1064 if (pixel_distance >= min_pixel_distance && has_skipped_keys) {
1070 has_skipped_keys =
false;
1072 prevbezt->
vec[1][0], prevbezt->
vec[1][0], prevbezt->
vec[1][1], prevbezt->
vec[1][1]};
1078 if (pixel_distance < min_pixel_distance) {
1080 has_skipped_keys =
true;
1084 switch (prevbezt->
ipo) {
1089 curve_vertices.append({prevbezt->
vec[1][0], prevbezt->
vec[1][1]});
1090 curve_vertices.append({bezt->
vec[1][0], prevbezt->
vec[1][1]});
1095 curve_vertices.append({prevbezt->
vec[1][0], prevbezt->
vec[1][1]});
1106 curve_vertices.append(prevbezt->
vec[1]);
1107 float current_frame = prevbezt->
vec[1][0] + evaluation_step;
1108 while (current_frame < bezt->vec[1][0]) {
1109 curve_vertices.append({current_frame,
evaluate_fcurve(fcu, current_frame)});
1110 current_frame += evaluation_step;
1120 curve_vertices.append(
1128 if (curve_vertices.size() < 2) {
1134 for (
const float2 vertex : curve_vertices) {
1180 float viewport_size[4];
1236 else if (fcu->
fpt) {
1259 switch (fcm->
type) {
1270 ac->
scene, ale->
id, fcu, mapping_flag, &offset);
1330 float viewport_size[4];
1366 float x = driver->
curval;
1367 float y = fcu->
curval * unitfac;
1448 float viewport_size[4];
1459 const bool draw_extrapolation =
false;
1482 ListBase anim_data = {
nullptr,
nullptr};
1499 ale_active_fcurve = ale;
1507 if (ale_active_fcurve !=
nullptr) {
1528 View2D *v2d = ®ion->v2d;
1534 size_t channel_index = 0;
1538 ale = ale->
next, ymax -= channel_step, channel_index++)
1553 size_t channel_index = 0;
1560 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, short mode)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
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
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])
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
uiBlock * UI_block_begin(const bContext *C, ARegion *region, std::string name, eUIEmbossType 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_GetThemeColor3ubv(int colorid, unsigned char col[3])
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)
AnimData * ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, bool restore, bool only_keys)
float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag, float *r_offset)
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)
local_group_size(16, 16) .push_constant(Type b
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
struct @620::@623 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 draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d, AnimData *adt_nla_remap)
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_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)
DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
SpaceGraph_Runtime runtime