55 if (ps1->
factor < ps2->factor) {
59 if (ps1->
factor > ps2->factor) {
72 for (
int i = 0; i < totpoints; i++) {
73 point_elem = &points_array[i];
109 short add_frame_mode;
147 for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
186 const bool clear_point,
205 for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
225 gps_array[idx] = gps;
239 float(*points2d)[2] =
MEM_mallocN(
sizeof(*points2d) * totpoints,
"GP Stroke temp 2d points");
243 float center[2] = {0.0f, 0.0f};
244 for (
int i = 0; i < totpoints; i++) {
245 center[0] += points2d[i][0];
246 center[1] += points2d[i][1];
251 const float axis[2] = {1.0f, 0.0f};
253 for (
int i = 0; i < totpoints; i++) {
271 sort_pt->
gps = gps_array[i];
297 for (
int i = 0; i < totpoints; i++) {
302 idx = totpoints - i - 1;
304 src_elem = &src_array[idx];
310 dst_elem = &dst_array[last];
314 dst_elem->
gps = src_elem->
gps;
331 for (
int i = 0; i < totpoints; i++) {
332 array_pt = &src_array[i];
333 if (gps_filter == array_pt->
gps) {
339 for (
int i = totpoints - 1; i >= 0; i--) {
340 array_pt = &src_array[i];
341 if (gps_filter == array_pt->
gps) {
368 bool loop = (
bool)(totstrokes > 1);
372 float dist_start = 0.0f;
373 float dist_end = 0.0f;
374 float dist = FLT_MAX;
375 bool reverse =
false;
377 for (i = 0; i < totpoints; i++) {
378 sort_pt = &src_array[i];
386 dist_start =
len_v3v3(end_prv, start);
389 if (dist > dist_start) {
390 gps_next = sort_pt->
gps;
394 if (dist > dist_end) {
395 gps_next = sort_pt->
gps;
405 if (gps_next !=
NULL) {
409 sort_pt = &dst_array[last - 1];
414 if (last >= totpoints) {
478 if (totpoints == 0) {
533 ot->
name =
"Merge Strokes";
534 ot->
idname =
"GPENCIL_OT_stroke_merge";
535 ot->
description =
"Create a new stroke with the selected stroke points";
547 ot->
srna,
"back", 0,
"Draw on Back",
"Draw new stroke below all previous strokes");
582 ob, hue_threshold, sat_threshold, val_threshold, &removed);
601 ot->
name =
"Merge Grease Pencil Materials";
602 ot->
idname =
"GPENCIL_OT_stroke_merge_material";
603 ot->
description =
"Replace materials in strokes merging similar";
614 ot->
srna,
"hue_threshold", 0.001f, 0.0f, 1.0f,
"Hue Threshold",
"", 0.0f, 1.0f);
616 ot->
srna,
"sat_threshold", 0.001f, 0.0f, 1.0f,
"Saturation Threshold",
"", 0.0f, 1.0f);
618 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, 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)
bool BKE_gpencil_merge_materials(struct Object *ob, float hue_threshold, float sat_threshold, float val_threshold, int *r_removed)
struct bGPDframe * BKE_gpencil_layer_frame_get(struct bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew)
void BKE_gpencil_stroke_2d_flat(const struct bGPDspoint *points, int totpoints, float(*points2d)[2], int *r_direction)
void BKE_gpencil_stroke_geometry_update(struct bGPdata *gpd, struct bGPDstroke *gps)
struct bGPDstroke * BKE_gpencil_stroke_delete_tagged_points(struct bGPdata *gpd, struct bGPDframe *gpf, struct bGPDstroke *gps, struct bGPDstroke *next_stroke, int tag_flags, bool select, bool flat_cap, int limit)
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_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
bool BLI_ghash_haskey(const 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)