55 const float point_co[2],
59 const bool reference_adjacent)
69 bezt = &new_point->
bezt;
73 if (reference_point) {
78 int point_index = reference_point - spline->
points;
79 int delta = new_point == spline->
points ? 1 : -1;
80 for (
int i = 0; i < spline->
tot_point - 1; i++) {
84 if (point_index == -1 || point_index >= spline->
tot_point) {
86 if (point_index == -1) {
89 else if (point_index >= spline->
tot_point) {
98 current_point = &spline->
points[point_index];
109 reference_parent_point = reference_point;
111 else if (reference_adjacent) {
115 const int index = (int)(new_point - spline->
points);
121 prev_point = (index != 0) ? &spline->
points[index - 1] :
NULL;
125 if (prev_point && next_point) {
132 close_point = prev_point ? prev_point : next_point;
136 char handle_type = 0;
138 handle_type = prev_point->
bezt.
h2;
141 handle_type =
MAX2(next_point->
bezt.
h2, handle_type);
143 bezt->
h1 = bezt->
h2 = handle_type;
146 reference_parent_point = close_point;
156 if (reference_parent_point) {
160 float parent_matrix[3][3];
202 for (
int i = 0; i < cur_spline->
tot_point; i++) {
206 if (!
ELEM(*spline,
NULL, cur_spline)) {
215 *spline = cur_spline;
221 cur_spline = cur_spline->
next;
232 "add mask vert points");
235 memcpy(new_point_array + point_index + 2,
236 spline->
points + point_index + 1,
240 spline->
points = new_point_array;
249 const float threshold = 9;
267 const float ctime =
CFRA;
270 int point_index = point - spline->
points;
276 new_point = &spline->
points[point_index + 1];
304 const float ctime =
CFRA;
312 float tangent_point[2];
314 bool do_cyclic_correct =
false;
324 point_index = (point - spline->
points);
329 (point_index > 0 && point_index != spline->
tot_point - 1)) {
333 if (
dot_v2v2(tangent_point, tangent_co) < 0.0f) {
355 if (point_index < 0) {
358 do_cyclic_correct =
true;
369 if (do_cyclic_correct) {
370 ref_point = &spline->
points[point_index + 1];
371 new_point = &spline->
points[point_index];
372 *ref_point = *new_point;
373 memset(new_point, 0,
sizeof(*new_point));
376 ref_point = &spline->
points[point_index];
377 new_point = &spline->
points[point_index + 1];
385 point_index = (((int)(new_point - spline->
points) + 0) % spline->
tot_point);
401 const float ctime =
CFRA;
409 mask->masklay_act =
mask->masklay_tot - 1;
417 new_point = spline->
points;
424 int point_index = (((int)(new_point - spline->
points) + 0) % spline->
tot_point);
440 const float point_normalized[2],
441 float point_pixel[2])
446 float scalex, scaley;
449 point_pixel[0] = point_normalized[0] * scalex;
450 point_pixel[1] = point_normalized[1] * scaley;
460 const float tolerance_in_pixels_squared = 4 * 4;
472 float point_pixel[2];
476 if (dist_squared > tolerance_in_pixels_squared) {
498 const bool is_first_point_active = (active_point == first_point);
499 const bool is_last_point_active = (active_point == last_point);
500 if (is_last_point_active) {
503 if (is_first_point_active) {
536 return cyclic_result;
597 "Location of vertex in normalized space",
610 const float threshold = 9;
636 if (weight_scalar != 0.0f) {
637 w =
w / weight_scalar;
669 ot->
name =
"Add Feather Vertex";
671 ot->
idname =
"MASK_OT_add_feather_vertex";
689 "Location of vertex in normalized space",
697 const int num_points,
698 const char handle_type,
700 const float location[2])
703 for (
int i = 0; i < num_points; i++) {
704 copy_v2_v2(bezier_points[i].vec[1], points[i]);
705 mul_v2_fl(bezier_points[i].vec[1], scale);
706 add_v2_v2(bezier_points[i].vec[1], location);
708 bezier_points[i].
h1 = handle_type;
709 bezier_points[i].
h2 = handle_type;
712 for (
int i = 0; i < num_points; i++) {
714 &bezier_points[(i - 1 + num_points) % num_points],
715 &bezier_points[(i + 1) % num_points],
720 return bezier_points;
738 frame_size[0] =
width;
742 location[0] /=
width;
747 location[0] -= 0.5f * scale;
748 location[1] -= 0.5f * scale;
750 bool added_mask =
false;
767 for (
int i = 0; i < num_points; i++) {
773 new_point->
bezt = bezier_points[i];
816 ot->
srna,
"size", 100, -FLT_MAX, FLT_MAX,
"Size",
"Size of new circle", -FLT_MAX, FLT_MAX);
824 "Location of new circle",
833 const float points[4][2] = {{0.0f, 0.5f}, {0.5f, 1.0f}, {1.0f, 0.5f}, {0.5f, 0.0f}};
834 int num_points =
sizeof(points) / (
sizeof(
float[2]));
846 ot->
idname =
"MASK_OT_primitive_circle_add";
864 const float points[4][2] = {{0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}};
865 int num_points =
sizeof(points) / (
sizeof(
float[2]));
877 ot->
idname =
"MASK_OT_primitive_square_add";
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
struct Scene * CTX_data_scene(const bContext *C)
struct Mask * CTX_data_edit_mask(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
void BKE_nurb_handle_calc(struct BezTriple *bezt, struct BezTriple *prev, struct BezTriple *next, const bool is_fcurve, const char smoothing)
void BKE_mask_calc_handle_adjacent_interp(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u)
#define MASKPOINT_ISSEL_ANY(p)
void BKE_mask_layer_shape_changed_add(struct MaskLayer *masklay, int index, bool do_init, bool do_init_interpolate)
void BKE_mask_calc_tangent_polyline(struct MaskSpline *spline, struct MaskSplinePoint *point, float t[2])
void BKE_mask_point_select_set(struct MaskSplinePoint *point, const bool do_select)
struct MaskLayer * BKE_mask_layer_new(struct Mask *mask, const char *name)
#define MASKPOINT_SEL_ALL(p)
struct MaskLayer * BKE_mask_layer_active(struct Mask *mask)
void BKE_mask_point_parent_matrix_get(struct MaskSplinePoint *point, float ctime, float parent_matrix[3][3])
void BKE_mask_calc_handle_point_auto(struct MaskSpline *spline, struct MaskSplinePoint *point, const bool do_recalc_length)
Resets auto handles even for non-auto bezier points.
void BKE_mask_point_add_uw(struct MaskSplinePoint *point, float u, float w)
int BKE_mask_layer_shape_spline_to_index(struct MaskLayer *masklay, struct MaskSpline *spline)
void BKE_mask_parent_init(struct MaskParent *parent)
float BKE_mask_point_weight_scalar(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u)
#define MASKPOINT_DESEL_ALL(p)
float BKE_mask_point_weight(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u)
void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2])
struct MaskSpline * BKE_mask_spline_add(struct MaskLayer *masklay)
MINLINE int max_ii(int a, int b)
MINLINE int mod_i(int i, int n)
void mul_m3_v2(const float m[3][3], float r[2])
bool invert_m3(float R[3][3])
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v2_v2(float r[2], const float a[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
void DEG_id_tag_update(struct ID *id, int flag)
#define MASK_RESTRICT_SELECT
#define MASK_RESTRICT_VIEW
void ED_mask_mouse_pos(struct ScrArea *area, struct ARegion *region, const int mval[2], float co[2])
void ED_mask_pixelspace_factor(struct ScrArea *area, struct ARegion *region, float *scalex, float *scaley)
void ED_mask_cursor_location_get(struct ScrArea *area, float cursor[2])
void ED_mask_get_size(struct ScrArea *area, int *width, int *height)
bool ED_operator_mask(struct bContext *C)
_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 const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
Read Guarded memory(de)allocation.
#define MEM_recallocN(vmemh, len)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void(* MEM_freeN)(void *vmemh)
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
void *(* MEM_callocN)(size_t len, const char *str)
void MASK_OT_add_feather_vertex(wmOperatorType *ot)
static int create_primitive_from_points(bContext *C, wmOperator *op, const float(*points)[2], int num_points, char handle_type)
static int add_vertex_exec(bContext *C, wmOperator *op)
static int primitive_circle_add_exec(bContext *C, wmOperator *op)
static BezTriple * points_to_bezier(const float(*points)[2], const int num_points, const char handle_type, const float scale, const float location[2])
static int primitive_square_add_exec(bContext *C, wmOperator *op)
static bool add_vertex_extrude(const bContext *C, Mask *mask, MaskLayer *mask_layer, const float co[2])
static void setup_vertex_point(Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point, const float point_co[2], const float u, const float ctime, const MaskSplinePoint *reference_point, const bool reference_adjacent)
void MASK_OT_primitive_square_add(wmOperatorType *ot)
static int add_feather_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int add_feather_vertex_exec(bContext *C, wmOperator *op)
void MASK_OT_primitive_circle_add(wmOperatorType *ot)
static void define_primitive_add_properties(wmOperatorType *ot)
static int add_vertex_handle_cyclic(bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *active_point, float co[2])
static void mask_point_make_pixel_space(bContext *C, const float point_normalized[2], float point_pixel[2])
static int primitive_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *mask_layer, const float co[2])
static int add_vertex_handle_cyclic_at_point(bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *active_point, MaskSplinePoint *other_point, float co[2])
static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2])
void MASK_OT_add_vertex(wmOperatorType *ot)
static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void finSelectedSplinePoint(MaskLayer *mask_layer, MaskSpline **spline, MaskSplinePoint **point, bool check_active)
static void mask_spline_add_point_at_index(MaskSpline *spline, int point_index)
void ED_mask_view_lock_state_restore_no_jump(const bContext *C, const MaskViewLockState *state)
bool ED_maskedit_mask_poll(bContext *C)
void ED_mask_view_lock_state_store(const bContext *C, MaskViewLockState *state)
void ED_mask_select_flush_all(struct Mask *mask)
struct MaskSplinePoint * ED_mask_point_find_nearest(const struct bContext *C, struct Mask *mask, const float normal_co[2], const float threshold, struct MaskLayer **r_mask_layer, struct MaskSpline **r_spline, eMaskWhichHandle *r_which_handle, float *r_score)
struct Mask * ED_mask_new(struct bContext *C, const char *name)
bool ED_mask_find_nearest_diff_point(const struct bContext *C, struct Mask *mask, const float normal_co[2], int threshold, bool feather, float tangent[2], const bool use_deform, const bool use_project, struct MaskLayer **r_mask_layer, struct MaskSpline **r_spline, struct MaskSplinePoint **r_point, float *r_u, float *r_score)
void ED_mask_select_toggle_all(struct Mask *mask, int action)
struct MaskLayer * ED_mask_layer_ensure(struct bContext *C, bool *r_added_mask)
static void area(int d1, int d2, int e1, int e2, float weights[2])
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
float RNA_float_get(PointerRNA *ptr, const char *name)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
struct MaskSplinePoint * act_point
struct MaskSpline * act_spline
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct wmOperatorType * type
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)