71 if (ps1->
factor < ps2->factor) {
75 if (ps1->
factor > ps2->factor) {
88 for (
int i = 0; i < totpoints; i++) {
89 point_elem = &points_array[i];
125 short add_frame_mode;
163 for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
202 const bool clear_point,
221 for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
241 gps_array[idx] = gps;
255 float(*points2d)[2] =
MEM_mallocN(
sizeof(*points2d) * totpoints,
"GP Stroke temp 2d points");
259 float center[2] = {0.0f, 0.0f};
260 for (
int i = 0; i < totpoints; i++) {
261 center[0] += points2d[i][0];
262 center[1] += points2d[i][1];
267 const float axis[2] = {1.0f, 0.0f};
269 for (
int i = 0; i < totpoints; i++) {
287 sort_pt->
gps = gps_array[i];
313 for (
int i = 0; i < totpoints; i++) {
318 idx = totpoints - i - 1;
320 src_elem = &src_array[idx];
326 dst_elem = &dst_array[last];
330 dst_elem->
gps = src_elem->
gps;
347 for (
int i = 0; i < totpoints; i++) {
348 array_pt = &src_array[i];
349 if (gps_filter == array_pt->
gps) {
355 for (
int i = totpoints - 1; i >= 0; i--) {
356 array_pt = &src_array[i];
357 if (gps_filter == array_pt->
gps) {
384 bool loop = (bool)(totstrokes > 1);
388 float dist_start = 0.0f;
389 float dist_end = 0.0f;
390 float dist = FLT_MAX;
391 bool reverse =
false;
393 for (i = 0; i < totpoints; i++) {
394 sort_pt = &src_array[i];
402 dist_start =
len_v3v3(end_prv, start);
405 if (dist > dist_start) {
406 gps_next = sort_pt->
gps;
410 if (dist > dist_end) {
411 gps_next = sort_pt->
gps;
421 if (gps_next !=
NULL) {
425 sort_pt = &dst_array[last - 1];
430 if (last >= totpoints) {
494 if (totpoints == 0) {
549 ot->
name =
"Merge Strokes";
550 ot->
idname =
"GPENCIL_OT_stroke_merge";
551 ot->
description =
"Create a new stroke with the selected stroke points";
563 ot->
srna,
"back", 0,
"Draw on Back",
"Draw new stroke below all previous strokes");
598 ob, hue_threshold, sat_threshold, val_threshold, &removed);
617 ot->
name =
"Merge Grease Pencil Materials";
618 ot->
idname =
"GPENCIL_OT_stroke_merge_material";
619 ot->
description =
"Replace materials in strokes merging similar";
630 ot->
srna,
"hue_threshold", 0.001f, 0.0f, 1.0f,
"Hue Threshold",
"", 0.0f, 1.0f);
632 ot->
srna,
"sat_threshold", 0.001f, 0.0f, 1.0f,
"Saturation Threshold",
"", 0.0f, 1.0f);
634 ot->
srna,
"val_threshold", 0.001f, 0.0f, 1.0f,
"Value Threshold",
"", 0.0f, 1.0f);
typedef float(TangentPoint)[2]
void BKE_brush_gpencil_paint_presets(struct Main *bmain, struct ToolSettings *ts, const bool reset)
struct Scene * CTX_data_scene(const bContext *C)
#define CTX_DATA_BEGIN(C, Type, instance, member)
struct bGPDlayer * CTX_data_active_gpencil_layer(const bContext *C)
struct Object * CTX_data_active_object(const bContext *C)
#define CTX_DATA_COUNT(C, member)
struct Main * CTX_data_main(const bContext *C)
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
void BKE_gpencil_stroke_select_index_set(struct bGPdata *gpd, struct bGPDstroke *gps)
void BKE_gpencil_stroke_select_index_reset(struct bGPDstroke *gps)
struct bGPDstroke * BKE_gpencil_stroke_new(int mat_idx, int totpoints, short thickness)
struct bGPDframe * BKE_gpencil_layer_frame_get(struct bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew)
bool BKE_gpencil_merge_materials(struct Object *ob, const float hue_threshold, const float sat_threshold, const float val_threshold, int *r_removed)
void BKE_gpencil_stroke_2d_flat(const struct bGPDspoint *points, int totpoints, float(*points2d)[2], int *r_direction)
struct bGPDstroke * BKE_gpencil_stroke_delete_tagged_points(struct bGPdata *gpd, struct bGPDframe *gpf, struct bGPDstroke *gps, struct bGPDstroke *next_stroke, int tag_flags, const bool select, const bool flat_cap, const int limit)
void BKE_gpencil_stroke_geometry_update(struct bGPdata *gpd, struct bGPDstroke *gps)
General operations, lookup, etc. for materials.
struct Material * BKE_gpencil_material(struct Object *ob, short act)
short * BKE_object_material_len_p(struct Object *ob)
void BKE_report(ReportList *reports, ReportType type, const char *message)
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
bool BLI_ghash_haskey(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
GHash * BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
float angle_signed_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float len_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
void DEG_id_tag_update(struct ID *id, int flag)
bool ED_operator_view3d_active(struct bContext *C)
NSNotificationCenter * center
_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 GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
static void clear_stroke(bGPDframe *gpf, bGPDstroke *gps)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
void GPENCIL_OT_stroke_merge(wmOperatorType *ot)
static void gpencil_get_elements_len(bContext *C, int *totstrokes, int *totpoints)
static int gpencil_analyze_strokes(tGPencilPointCache *src_array, int totstrokes, int totpoints, tGPencilPointCache *dst_array)
static int gpencil_stroke_merge_material_exec(bContext *C, wmOperator *op)
static int gpencil_sort_points(const void *a1, const void *a2)
void GPENCIL_OT_stroke_merge_material(wmOperatorType *ot)
static int gpencil_stroke_merge_exec(bContext *C, wmOperator *op)
static void gpencil_insert_points_to_stroke(bGPDstroke *gps, tGPencilPointCache *points_array, int totpoints)
static bool gpencil_strokes_merge_poll(bContext *C)
static void gpencil_dissolve_points(bContext *C)
static bGPDstroke * gpencil_prepare_stroke(bContext *C, wmOperator *op, int totpoints)
static void gpencil_get_extremes(tGPencilPointCache *src_array, int totpoints, bGPDstroke *gps_filter, float *start, float *end)
static bool gpencil_stroke_merge_material_poll(bContext *C)
static void gpencil_calc_points_factor(bContext *C, const int mode, int totpoints, const bool clear_point, const bool clear_stroke, tGPencilPointCache *src_array)
static int gpencil_insert_to_array(tGPencilPointCache *src_array, tGPencilPointCache *dst_array, int totpoints, bGPDstroke *gps_filter, bool reverse, int last)
struct tGPencilPointCache tGPencilPointCache
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
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_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
struct BrushGpencilSettings * gpencil_settings
struct MaterialGPencilStyle * gp_style
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
void WM_event_add_notifier(const bContext *C, uint type, void *reference)