diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-11-26 06:32:34 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-11-26 06:32:34 +0400 |
commit | 53840c7db5114da8b35fb12c1cfa49427802b0d7 (patch) | |
tree | e1676e61881c903baff02bd69290ef0393a13465 /source/blender | |
parent | b7cd9ec3ada529bf1d57cf08cc96851ceb67a47d (diff) | |
parent | 97b8a1f752fbe729c20c8398dfa9fdbc2e2e4ff3 (diff) |
Merged changes in the trunk up to revision 52546.
Conflicts resolved:
release/datafiles/startup.blend
release/scripts/startup/bl_ui/space_view3d.py
source/blender/blenkernel/intern/idcode.c
Diffstat (limited to 'source/blender')
179 files changed, 3636 insertions, 2690 deletions
diff --git a/source/blender/blenfont/BLF_translation.h b/source/blender/blenfont/BLF_translation.h index d0b5d824bb3..8eb40384044 100644 --- a/source/blender/blenfont/BLF_translation.h +++ b/source/blender/blenfont/BLF_translation.h @@ -73,6 +73,7 @@ const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid); /* The "translation-marker" macro. */ #define N_(msgid) msgid #define CTX_N_(context, msgid) msgid + /* Those macros should be used everywhere in UI code. */ #ifdef WITH_INTERNATIONAL /* #define _(msgid) BLF_gettext(msgid) */ @@ -84,10 +85,17 @@ const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid); /* #define _(msgid) msgid */ #define IFACE_(msgid) msgid #define TIP_(msgid) msgid - #define CTX_IFACE_(context, msgid) msgid - #define CTX_TIP_(context, msgid) msgid + #define CTX_IFACE_(context, msgid) ((void)context, msgid) + #define CTX_TIP_(context, msgid) ((void)context, msgid) #endif +/* Helper macro, when we want to define a same msgid for multiple msgctxt... + * Does nothing in C, but is "parsed" by our i18n py tools. + * XXX Currently limited to at most 16 contexts at most + * (but you can call it several times with the same msgid, should you need more contexts!). + */ +#define BLF_I18N_MSGID_MULTI_CTXT(msgid, ...) + /****************************************************************************** * All i18n contexts must be defined here. * This is a nice way to be sure not to use a context twice for different @@ -100,8 +108,40 @@ const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid); /* Default context for operator names/labels. */ #define BLF_I18NCONTEXT_OPERATOR_DEFAULT "Operator" -/* Audio disambiguation context. */ -#define BLF_I18NCONTEXT_AUDIO "Audio" - +/* ID-types contexts. */ +/* WARNING! Keep it in sync with idtypes in blenkernel/intern/idcode.c */ +#define BLF_I18NCONTEXT_ID_ACTION "Action" +#define BLF_I18NCONTEXT_ID_ARMATURE "Armature" +#define BLF_I18NCONTEXT_ID_BRUSH "Brush" +#define BLF_I18NCONTEXT_ID_CAMERA "Camera" +#define BLF_I18NCONTEXT_ID_CURVE "Curve" +#define BLF_I18NCONTEXT_ID_FREESTYLELINESTYLE "FreestyleLineStyle" +#define BLF_I18NCONTEXT_ID_GPENCIL "GPencil" +#define BLF_I18NCONTEXT_ID_GROUP "Group" +#define BLF_I18NCONTEXT_ID_ID "ID" +#define BLF_I18NCONTEXT_ID_IMAGE "Image" +/*#define BLF_I18NCONTEXT_ID_IPO "Ipo"*/ /* Deprecated */ +#define BLF_I18NCONTEXT_ID_SHAPEKEY "Key" +#define BLF_I18NCONTEXT_ID_LAMP "Lamp" +#define BLF_I18NCONTEXT_ID_LIBRARY "Library" +#define BLF_I18NCONTEXT_ID_LATTICE "Lattice" +#define BLF_I18NCONTEXT_ID_MATERIAL "Material" +#define BLF_I18NCONTEXT_ID_METABALL "Metaball" +#define BLF_I18NCONTEXT_ID_MESH "Mesh" +#define BLF_I18NCONTEXT_ID_NODETREE "NodeTree" +#define BLF_I18NCONTEXT_ID_OBJECT "Object" +#define BLF_I18NCONTEXT_ID_PARTICLESETTINGS "ParticleSettings" +#define BLF_I18NCONTEXT_ID_SCENE "Scene" +#define BLF_I18NCONTEXT_ID_SCREEN "Screen" +#define BLF_I18NCONTEXT_ID_SEQUENCE "Sequence" +#define BLF_I18NCONTEXT_ID_SPEAKER "Speaker" +#define BLF_I18NCONTEXT_ID_SOUND "Sound" +#define BLF_I18NCONTEXT_ID_TEXTURE "Texture" +#define BLF_I18NCONTEXT_ID_TEXT "Text" +#define BLF_I18NCONTEXT_ID_VFONT "VFont" +#define BLF_I18NCONTEXT_ID_WORLD "World" +#define BLF_I18NCONTEXT_ID_WINDOWMANAGER "WindowManager" +#define BLF_I18NCONTEXT_ID_MOVIECLIP "MovieClip" +#define BLF_I18NCONTEXT_ID_MASK "Mask" #endif /* __BLF_TRANSLATION_H__ */ diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index aaf88e4924d..accac8694a9 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -100,14 +100,6 @@ void txt_move_lines (struct Text *text, const int direction); void txt_duplicate_line (struct Text *text); int setcurr_tab_spaces (struct Text *text, int space); -void txt_add_marker (struct Text *text, struct TextLine *line, int start, int end, const unsigned char color[4], int group, int flags); -short txt_clear_marker_region (struct Text *text, struct TextLine *line, int start, int end, int group, int flags); -short txt_clear_markers (struct Text *text, int group, int flags); -struct TextMarker *txt_find_marker (struct Text *text, struct TextLine *line, int curs, int group, int flags); -struct TextMarker *txt_find_marker_region (struct Text *text, struct TextLine *line, int start, int end, int group, int flags); -struct TextMarker *txt_prev_marker (struct Text *text, struct TextMarker *marker); -struct TextMarker *txt_next_marker (struct Text *text, struct TextMarker *marker); - /* utility functions, could be moved somewhere more generic but are python/text related */ int text_check_bracket(const char ch); int text_check_delim(const char ch); @@ -161,10 +153,6 @@ enum { #define UNDO_DUPLICATE 040 -/* Marker flags */ -#define TMARK_TEMP 0x01 /* Remove on non-editing events, don't save */ -#define TMARK_EDITALL 0x02 /* Edit all markers of the same group as one */ - #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index cca425a63d8..3736395313d 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2167,6 +2167,8 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask, /* weight paint and face select need original indices because of selection buffer drawing */ int needMapping = (ob == obact) && (editing || (ob->mode & (OB_MODE_WEIGHT_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_TEXTURE_PAINT))); + BLI_assert(ob->type == OB_MESH); + clear_mesh_caches(ob); mesh_calc_modifiers(scene, ob, NULL, &ob->derivedDeform, diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index e95451252d0..dd27cc70ba3 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -512,7 +512,7 @@ const char *BKE_pose_ikparam_get_name(bPose *pose) { if (pose) { switch (pose->iksolver) { - case IKSOLVER_LEGACY: + case IKSOLVER_STANDARD: return NULL; case IKSOLVER_ITASC: return "bItasc"; @@ -587,7 +587,7 @@ void BKE_pose_ikparam_init(bPose *pose) BKE_pose_itasc_init(itasc); pose->ikparam = itasc; break; - case IKSOLVER_LEGACY: + case IKSOLVER_STANDARD: default: pose->ikparam = NULL; break; diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index b3cbc1f2b16..1970df54339 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1822,8 +1822,15 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos */ /* only happens on reload file, but violates depsgraph still... fix! */ - if ((cu->path == NULL) || (cu->path->data == NULL)) + if (ELEM(NULL, cu->path, cu->path->data)) { BKE_displist_make_curveTypes(scene, ikData->tar, 0); + + /* path building may fail in EditMode after removing verts [#33268]*/ + if (ELEM(NULL, cu->path, cu->path->data)) { + /* BLI_assert(cu->path != NULL); */ + return; + } + } } /* find the root bone and the chain of bones from the root to the tip diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 3ade51d13eb..9b1720787ed 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -2516,7 +2516,7 @@ void CDDM_calc_edges(DerivedMesh *dm) EdgeHashIterator *ehi; MPoly *mp = cddm->mpoly; MLoop *ml; - MEdge *med; + MEdge *med, *origmed; EdgeHash *eh = BLI_edgehash_new(); int v1, v2; int *eindex; @@ -2549,6 +2549,7 @@ void CDDM_calc_edges(DerivedMesh *dm) CustomData_add_layer(&edgeData, CD_MEDGE, CD_CALLOC, NULL, numEdges); CustomData_add_layer(&edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges); + origmed = cddm->medge; med = CustomData_get_layer(&edgeData, CD_MEDGE); index = CustomData_get_layer(&edgeData, CD_ORIGINDEX); @@ -2559,8 +2560,14 @@ void CDDM_calc_edges(DerivedMesh *dm) BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2); j = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); - med->flag = ME_EDGEDRAW | ME_EDGERENDER; - *index = j == 0 ? ORIGINDEX_NONE : eindex[j - 1]; + if (j == 0) { + med->flag = ME_EDGEDRAW | ME_EDGERENDER; + *index = ORIGINDEX_NONE; + } + else { + med->flag = ME_EDGEDRAW | ME_EDGERENDER | origmed[j - 1].flag; + *index = eindex[j - 1]; + } BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(i)); } diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index b488e683947..4641a02265a 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -198,8 +198,10 @@ static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3 w3[0] = 1.0f - w1[0] - w2[0]; } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdouble-promotion" +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdouble-promotion" +#endif DO_INLINE void collision_interpolateOnTriangle ( float to[3], float v1[3], float v2[3], float v3[3], double w1, double w2, double w3 ) { @@ -371,7 +373,9 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM return result; } -#pragma GCC diagnostic pop +#ifdef __GNUC__ +# pragma GCC diagnostic pop +#endif //Determines collisions on overlap, collisions are written to collpair[i] and collision+number_collision_found is returned static CollPair* cloth_collision(ModifierData *md1, ModifierData *md2, diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 89d728c0419..bb3836e3c08 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -86,11 +86,13 @@ #include "RE_shader_ext.h" #ifdef _OPENMP -#include <omp.h> +# include <omp.h> #endif /* could enable at some point but for now there are far too many conversions */ -#pragma GCC diagnostic ignored "-Wdouble-promotion" +#ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wdouble-promotion" +#endif /* precalculated gaussian factors for 5x super sampling */ static float gaussianFactors[5] = {0.996849f, diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index 828f752eaa5..75c22d06042 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -47,40 +47,41 @@ typedef struct { } IDType; /* plural need to match rna_main.c's MainCollectionDef */ +/* WARNING! Keep it in sync with i18n contexts in BLF_translation.h */ static IDType idtypes[] = { - { ID_AC, "Action", "actions", IDTYPE_FLAGS_ISLINKABLE}, - { ID_AR, "Armature", "armatures", IDTYPE_FLAGS_ISLINKABLE}, - { ID_BR, "Brush", "brushes", IDTYPE_FLAGS_ISLINKABLE}, - { ID_CA, "Camera", "cameras", IDTYPE_FLAGS_ISLINKABLE}, - { ID_CU, "Curve", "curves", IDTYPE_FLAGS_ISLINKABLE}, - { ID_GD, "GPencil", "grease_pencil", IDTYPE_FLAGS_ISLINKABLE}, /* rename gpencil */ - { ID_GR, "Group", "groups", IDTYPE_FLAGS_ISLINKABLE}, - { ID_ID, "ID", "ids", 0}, /* plural is fake */ - { ID_IM, "Image", "images", IDTYPE_FLAGS_ISLINKABLE}, - { ID_IP, "Ipo", "ipos", IDTYPE_FLAGS_ISLINKABLE}, /* deprecated */ - { ID_KE, "Key", "shape_keys", 0}, - { ID_LA, "Lamp", "lamps", IDTYPE_FLAGS_ISLINKABLE}, - { ID_LI, "Library", "libraries", 0}, - { ID_LS, "FreestyleLineStyle", "linestyles", IDTYPE_FLAGS_ISLINKABLE}, - { ID_LT, "Lattice", "lattices", IDTYPE_FLAGS_ISLINKABLE}, - { ID_MA, "Material", "materials", IDTYPE_FLAGS_ISLINKABLE}, - { ID_MB, "Metaball", "metaballs", IDTYPE_FLAGS_ISLINKABLE}, - { ID_ME, "Mesh", "meshes", IDTYPE_FLAGS_ISLINKABLE}, - { ID_NT, "NodeTree", "node_groups", IDTYPE_FLAGS_ISLINKABLE}, - { ID_OB, "Object", "objects", IDTYPE_FLAGS_ISLINKABLE}, - { ID_PA, "ParticleSettings", "particles", 0}, - { ID_SCE, "Scene", "scenes", IDTYPE_FLAGS_ISLINKABLE}, - { ID_SCR, "Screen", "screens", 0}, - { ID_SEQ, "Sequence", "sequences", 0}, /* not actually ID data */ - { ID_SPK, "Speaker", "speakers", IDTYPE_FLAGS_ISLINKABLE}, - { ID_SO, "Sound", "sounds", IDTYPE_FLAGS_ISLINKABLE}, - { ID_TE, "Texture", "textures", IDTYPE_FLAGS_ISLINKABLE}, - { ID_TXT, "Text", "texts", IDTYPE_FLAGS_ISLINKABLE}, - { ID_VF, "VFont", "fonts", IDTYPE_FLAGS_ISLINKABLE}, - { ID_WO, "World", "worlds", IDTYPE_FLAGS_ISLINKABLE}, - { ID_WM, "WindowManager", "window_managers", 0}, - { ID_MC, "MovieClip", "movieclips", IDTYPE_FLAGS_ISLINKABLE}, - { ID_MSK, "Mask", "masks", IDTYPE_FLAGS_ISLINKABLE}, + { ID_AC, "Action", "actions", IDTYPE_FLAGS_ISLINKABLE }, + { ID_AR, "Armature", "armatures", IDTYPE_FLAGS_ISLINKABLE }, + { ID_BR, "Brush", "brushes", IDTYPE_FLAGS_ISLINKABLE }, + { ID_CA, "Camera", "cameras", IDTYPE_FLAGS_ISLINKABLE }, + { ID_CU, "Curve", "curves", IDTYPE_FLAGS_ISLINKABLE }, + { ID_GD, "GPencil", "grease_pencil", IDTYPE_FLAGS_ISLINKABLE }, /* rename gpencil */ + { ID_GR, "Group", "groups", IDTYPE_FLAGS_ISLINKABLE }, + { ID_ID, "ID", "ids", 0 }, /* plural is fake */ + { ID_IM, "Image", "images", IDTYPE_FLAGS_ISLINKABLE }, + { ID_IP, "Ipo", "ipos", IDTYPE_FLAGS_ISLINKABLE }, /* deprecated */ + { ID_KE, "Key", "shape_keys", 0 }, + { ID_LA, "Lamp", "lamps", IDTYPE_FLAGS_ISLINKABLE }, + { ID_LI, "Library", "libraries", 0 }, + { ID_LS, "FreestyleLineStyle", "linestyles", IDTYPE_FLAGS_ISLINKABLE }, + { ID_LT, "Lattice", "lattices", IDTYPE_FLAGS_ISLINKABLE }, + { ID_MA, "Material", "materials", IDTYPE_FLAGS_ISLINKABLE }, + { ID_MB, "Metaball", "metaballs", IDTYPE_FLAGS_ISLINKABLE }, + { ID_MC, "MovieClip", "movieclips", IDTYPE_FLAGS_ISLINKABLE }, + { ID_ME, "Mesh", "meshes", IDTYPE_FLAGS_ISLINKABLE }, + { ID_MSK, "Mask", "masks", IDTYPE_FLAGS_ISLINKABLE }, + { ID_NT, "NodeTree", "node_groups", IDTYPE_FLAGS_ISLINKABLE }, + { ID_OB, "Object", "objects", IDTYPE_FLAGS_ISLINKABLE }, + { ID_PA, "ParticleSettings", "particles", 0 }, + { ID_SCE, "Scene", "scenes", IDTYPE_FLAGS_ISLINKABLE }, + { ID_SCR, "Screen", "screens", 0 }, + { ID_SEQ, "Sequence", "sequences", 0 }, /* not actually ID data */ + { ID_SPK, "Speaker", "speakers", IDTYPE_FLAGS_ISLINKABLE }, + { ID_SO, "Sound", "sounds", IDTYPE_FLAGS_ISLINKABLE }, + { ID_TE, "Texture", "textures", IDTYPE_FLAGS_ISLINKABLE }, + { ID_TXT, "Text", "texts", IDTYPE_FLAGS_ISLINKABLE }, + { ID_VF, "VFont", "fonts", IDTYPE_FLAGS_ISLINKABLE }, + { ID_WO, "World", "worlds", IDTYPE_FLAGS_ISLINKABLE }, + { ID_WM, "WindowManager", "window_managers", 0 }, }; static int nidtypes = sizeof(idtypes) / sizeof(idtypes[0]); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index d98c2bc2f8b..e4b9edacc7e 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2920,7 +2920,20 @@ void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock) /* checks whether there's an image buffer for given image and user */ int BKE_image_has_ibuf(Image *ima, ImageUser *iuser) { - ImBuf *ibuf = image_get_ibuf_threadsafe(ima, iuser, NULL, NULL); + ImBuf *ibuf; + + /* quick reject tests */ + if (ima == NULL) + return FALSE; + + if (iuser) { + if (iuser->ok == 0) + return FALSE; + } + else if (ima->ok == 0) + return FALSE; + + ibuf = image_get_ibuf_threadsafe(ima, iuser, NULL, NULL); if (!ibuf) { BLI_spin_lock(&image_spin); diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 469881020c1..0b7fdaa7c1d 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -139,6 +139,9 @@ static ImBuf *prepare_effect_imbufs(SeqRenderData context, ImBuf *ibuf1, ImBuf * IMB_rect_from_float(ibuf3); } + if (out->rect_float) + IMB_colormanagement_assign_float_colorspace(out, context.scene->sequencer_colorspace_settings.name); + return out; } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 547ca96e10a..e023a3e20ae 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2338,11 +2338,13 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float */ const short is_rendering = G.is_rendering; + const short is_background = G.background; const int do_seq_gl = G.is_rendering ? 0 /* (context.scene->r.seq_flag & R_SEQ_GL_REND) */ : (context.scene->r.seq_flag & R_SEQ_GL_PREV); int do_seq; int have_seq = FALSE; + int have_comp = FALSE; Scene *scene; int is_thread_main = BLI_thread_is_main(); @@ -2355,6 +2357,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float frame = scene->r.sfra + nr + seq->anim_startofs; have_seq = (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first; + have_comp = (scene->r.scemode & R_DOCOMP) && scene->use_nodes && scene->nodetree; oldcfra = scene->r.cfra; scene->r.cfra = frame; @@ -2367,7 +2370,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float camera = scene->camera; } - if (have_seq == FALSE && camera == NULL) { + if (have_comp == FALSE && camera == NULL) { scene->r.cfra = oldcfra; return NULL; } @@ -2407,11 +2410,15 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float * * disable rendered preview for sequencer while rendering -- it's very much possible * that preview render will went into conflict with final render + * + * When rendering from command line renderer is called from main thread, in this + * case it's always safe to render scene here */ - if (!is_thread_main || is_rendering == FALSE) { + if (!is_thread_main || is_rendering == FALSE || is_background) { if (re == NULL) re = RE_NewRender(scene->id.name); + BKE_scene_update_for_newframe(context.bmain, scene, scene->lay); RE_BlenderFrame(re, context.bmain, scene, NULL, camera, scene->lay, frame, FALSE); /* restore previous state after it was toggled on & off by RE_BlenderFrame */ diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index d166592424d..e6339d07e66 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -96,17 +96,6 @@ * If the user moves the cursor the st containing that cursor should * be popped ... other st's retain their own top location. * - * Markers - * -- - * The mrk->flags define the behavior and relationships between markers. The - * upper two bytes are used to hold a group ID, the lower two are normal flags. If - * TMARK_EDITALL is set the group ID defines which other markers should be edited. - * - * The mrk->clr field is used to visually group markers where the flags may not - * match. A template system, for example, may allow editing of repeating tokens - * (in one group) but include other marked positions (in another group) all in the - * same template with the same color. - * * Undo * -- * Undo/Redo works by storing @@ -174,7 +163,6 @@ void BKE_text_free(Text *text) } BLI_freelistN(&text->lines); - BLI_freelistN(&text->markers); if (text->name) MEM_freeN(text->name); MEM_freeN(text->undo_buf); @@ -202,7 +190,6 @@ Text *BKE_text_add(const char *name) ta->flags |= TXT_TABSTOSPACES; ta->lines.first = ta->lines.last = NULL; - ta->markers.first = ta->markers.last = NULL; tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); tmp->line = (char *) MEM_mallocN(1, "textline_string"); @@ -398,7 +385,6 @@ Text *BKE_text_load(const char *file, const char *relpath) ta->id.us = 1; ta->lines.first = ta->lines.last = NULL; - ta->markers.first = ta->markers.last = NULL; ta->curl = ta->sell = NULL; if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE) == 0) @@ -495,7 +481,6 @@ Text *BKE_text_copy(Text *ta) tan->flags = ta->flags | TXT_ISDIRTY; tan->lines.first = tan->lines.last = NULL; - tan->markers.first = tan->markers.last = NULL; tan->curl = tan->sell = NULL; tan->nlines = ta->nlines; @@ -1150,9 +1135,7 @@ int txt_has_sel(Text *text) static void txt_delete_sel(Text *text) { TextLine *tmpl; - TextMarker *mrk; char *buf; - int move, lineno; if (!text) return; if (!text->curl) return; @@ -1169,28 +1152,6 @@ static void txt_delete_sel(Text *text) } buf = MEM_mallocN(text->curc + (text->sell->len - text->selc) + 1, "textline_string"); - - if (text->curl != text->sell) { - txt_clear_marker_region(text, text->curl, text->curc, text->curl->len, 0, 0); - move = txt_get_span(text->curl, text->sell); - } - else { - mrk = txt_find_marker_region(text, text->curl, text->curc, text->selc, 0, 0); - if (mrk && (mrk->start > text->curc || mrk->end < text->selc)) - txt_clear_marker_region(text, text->curl, text->curc, text->selc, 0, 0); - move = 0; - } - - mrk = txt_find_marker_region(text, text->sell, text->selc - 1, text->sell->len, 0, 0); - if (mrk) { - lineno = mrk->lineno; - do { - mrk->lineno -= move; - if (mrk->start > text->curc) mrk->start -= text->selc - text->curc; - mrk->end -= text->selc - text->curc; - mrk = mrk->next; - } while (mrk && mrk->lineno == lineno); - } strncpy(buf, text->curl->line, text->curc); strcpy(buf + text->curc, text->sell->line + text->selc); @@ -1419,19 +1380,9 @@ char *txt_sel_to_buf(Text *text) return buf; } -static void txt_shift_markers(Text *text, int lineno, int count) -{ - TextMarker *marker; - - for (marker = text->markers.first; marker; marker = marker->next) - if (marker->lineno >= lineno) { - marker->lineno += count; - } -} - void txt_insert_buf(Text *text, const char *in_buffer) { - int l = 0, u, len, lineno = -1, count = 0; + int l = 0, u, len; size_t i = 0, j; TextLine *add; char *buffer; @@ -1458,9 +1409,6 @@ void txt_insert_buf(Text *text, const char *in_buffer) else { undoing = u; MEM_freeN(buffer); return; } i++; - /* Read as many full lines as we can */ - lineno = txt_get_span(text->lines.first, text->curl); - while (i < len) { l = 0; @@ -1472,14 +1420,8 @@ void txt_insert_buf(Text *text, const char *in_buffer) add = txt_new_linen(buffer + (i - l), l); BLI_insertlinkbefore(&text->lines, text->curl, add); i++; - count++; } else { - if (count) { - txt_shift_markers(text, lineno, count); - count = 0; - } - for (j = i - l; j < i && j < len; ) txt_add_raw_char(text, BLI_str_utf8_as_unicode_step(buffer, &j)); break; @@ -1488,10 +1430,6 @@ void txt_insert_buf(Text *text, const char *in_buffer) MEM_freeN(buffer); - if (count) { - txt_shift_markers(text, lineno, count); - } - undoing = u; } @@ -2324,31 +2262,13 @@ void txt_do_redo(Text *text) void txt_split_curline(Text *text) { TextLine *ins; - TextMarker *mrk; char *left, *right; - int lineno = -1; if (!text) return; if (!text->curl) return; txt_delete_sel(text); - /* Move markers */ - - lineno = txt_get_span(text->lines.first, text->curl); - mrk = text->markers.first; - while (mrk) { - if (mrk->lineno == lineno && mrk->start > text->curc) { - mrk->lineno++; - mrk->start -= text->curc; - mrk->end -= text->curc; - } - else if (mrk->lineno > lineno) { - mrk->lineno++; - } - mrk = mrk->next; - } - /* Make the two half strings */ left = MEM_mallocN(text->curc + 1, "textline_string"); @@ -2385,25 +2305,9 @@ void txt_split_curline(Text *text) static void txt_delete_line(Text *text, TextLine *line) { - TextMarker *mrk = NULL, *nxt; - if (!text) return; if (!text->curl) return; - /* warning, this can be _slow_ when deleting many lines! */ - if ((mrk = text->markers.first)) { - int lineno = txt_get_span(text->lines.first, line); - mrk = text->markers.first; - while (mrk) { - nxt = mrk->next; - if (mrk->lineno == lineno) - BLI_freelinkN(&text->markers, mrk); - else if (mrk->lineno > lineno) - mrk->lineno--; - mrk = nxt; - } - } - BLI_remlink(&text->lines, line); if (line->line) MEM_freeN(line->line); @@ -2418,27 +2322,11 @@ static void txt_delete_line(Text *text, TextLine *line) static void txt_combine_lines(Text *text, TextLine *linea, TextLine *lineb) { char *tmp; - TextMarker *mrk = NULL; if (!text) return; if (!linea || !lineb) return; - mrk = txt_find_marker_region(text, lineb, 0, lineb->len, 0, 0); - if (mrk) { - int lineno; - lineno = mrk->lineno; - do { - mrk->lineno--; - mrk->start += linea->len; - mrk->end += linea->len; - mrk = mrk->next; - } while (mrk && mrk->lineno == lineno); - } -#if 0 /* UNUSED */ - if (lineno == -1) - lineno = txt_get_span(text->lines.first, lineb); -#endif tmp = MEM_mallocN(linea->len + lineb->len + 1, "textline_string"); @@ -2492,27 +2380,7 @@ void txt_delete_char(Text *text) } else { /* Just deleting a char */ size_t c_len = 0; - TextMarker *mrk; c = BLI_str_utf8_as_unicode_and_size(text->curl->line + text->curc, &c_len); - - mrk = txt_find_marker_region(text, text->curl, text->curc - c_len, text->curl->len, 0, 0); - if (mrk) { - int lineno = mrk->lineno; - if (mrk->end == text->curc) { - if ((mrk->flags & TMARK_TEMP) && !(mrk->flags & TMARK_EDITALL)) { - txt_clear_markers(text, mrk->group, TMARK_TEMP); - } - else { - BLI_freelinkN(&text->markers, mrk); - } - return; - } - do { - if (mrk->start > text->curc) mrk->start -= c_len; - mrk->end -= c_len; - mrk = mrk->next; - } while (mrk && mrk->lineno == lineno); - } memmove(text->curl->line + text->curc, text->curl->line + text->curc + c_len, text->curl->len - text->curc - c_len + 1); @@ -2556,28 +2424,8 @@ void txt_backspace_char(Text *text) } else { /* Just backspacing a char */ size_t c_len = 0; - TextMarker *mrk; char *prev = BLI_str_prev_char_utf8(text->curl->line + text->curc); c = BLI_str_utf8_as_unicode_and_size(prev, &c_len); - - mrk = txt_find_marker_region(text, text->curl, text->curc - c_len, text->curl->len, 0, 0); - if (mrk) { - int lineno = mrk->lineno; - if (mrk->start == text->curc) { - if ((mrk->flags & TMARK_TEMP) && !(mrk->flags & TMARK_EDITALL)) { - txt_clear_markers(text, mrk->group, TMARK_TEMP); - } - else { - BLI_freelinkN(&text->markers, mrk); - } - return; - } - do { - if (mrk->start > text->curc - c_len) mrk->start -= c_len; - mrk->end -= c_len; - mrk = mrk->next; - } while (mrk && mrk->lineno == lineno); - } /* source and destination overlap, don't use memcpy() */ memmove(text->curl->line + text->curc - c_len, @@ -2619,9 +2467,7 @@ static void txt_convert_tab_to_spaces(Text *text) static int txt_add_char_intern(Text *text, unsigned int add, int replace_tabs) { - int lineno; char *tmp, ch[BLI_UTF8_MAX]; - TextMarker *mrk; size_t add_len; if (!text) return 0; @@ -2643,15 +2489,6 @@ static int txt_add_char_intern(Text *text, unsigned int add, int replace_tabs) if (!undoing) txt_undo_add_charop(text, UNDO_INSERT_1, add); add_len = BLI_str_utf8_from_unicode(add, ch); - mrk = txt_find_marker_region(text, text->curl, text->curc - 1, text->curl->len, 0, 0); - if (mrk) { - lineno = mrk->lineno; - do { - if (mrk->start > text->curc) mrk->start += add_len; - mrk->end += add_len; - mrk = mrk->next; - } while (mrk && mrk->lineno == lineno); - } tmp = MEM_mallocN(text->curl->len + add_len + 1, "textline_string"); @@ -2698,10 +2535,7 @@ int txt_replace_char(Text *text, unsigned int add) /* If text is selected or we're at the end of the line just use txt_add_char */ if (text->curc == text->curl->len || txt_has_sel(text) || add == '\n') { - int i = txt_add_char(text, add); - TextMarker *mrk = txt_find_marker(text, text->curl, text->curc, 0, 0); - if (mrk) BLI_freelinkN(&text->markers, mrk); - return i; + return txt_add_char(text, add); } del = BLI_str_utf8_as_unicode_and_size(text->curl->line + text->curc, &del_size); @@ -3039,157 +2873,6 @@ int setcurr_tab_spaces(Text *text, int space) return i; } -/*********************************/ -/* Text marker utility functions */ -/*********************************/ - -/* Creates and adds a marker to the list maintaining sorted order */ -void txt_add_marker(Text *text, TextLine *line, int start, int end, const unsigned char color[4], int group, int flags) -{ - TextMarker *tmp, *marker; - - marker = MEM_mallocN(sizeof(TextMarker), "text_marker"); - - marker->lineno = txt_get_span(text->lines.first, line); - marker->start = MIN2(start, end); - marker->end = MAX2(start, end); - marker->group = group; - marker->flags = flags; - - marker->color[0] = color[0]; - marker->color[1] = color[1]; - marker->color[2] = color[2]; - marker->color[3] = color[3]; - - for (tmp = text->markers.last; tmp; tmp = tmp->prev) - if (tmp->lineno < marker->lineno || (tmp->lineno == marker->lineno && tmp->start < marker->start)) - break; - - if (tmp) BLI_insertlinkafter(&text->markers, tmp, marker); - else BLI_addhead(&text->markers, marker); -} - -/* Returns the first matching marker on the specified line between two points. - * If the group or flags fields are non-zero the returned flag must be in the - * specified group and have at least the specified flags set. */ -TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int end, int group, int flags) -{ - TextMarker *marker, *next; - int lineno = txt_get_span(text->lines.first, line); - - for (marker = text->markers.first; marker; marker = next) { - next = marker->next; - - if (group && marker->group != group) continue; - else if ((marker->flags & flags) != flags) continue; - else if (marker->lineno < lineno) continue; - else if (marker->lineno > lineno) break; - - if ((marker->start == marker->end && start <= marker->start && marker->start <= end) || - (marker->start < end && marker->end > start)) - { - return marker; - } - } - return NULL; -} - -/* Clears all markers on the specified line between two points. If the group or - * flags fields are non-zero the returned flag must be in the specified group - * and have at least the specified flags set. */ -short txt_clear_marker_region(Text *text, TextLine *line, int start, int end, int group, int flags) -{ - TextMarker *marker, *next; - int lineno = txt_get_span(text->lines.first, line); - short cleared = 0; - - for (marker = text->markers.first; marker; marker = next) { - next = marker->next; - - if (group && marker->group != group) continue; - else if ((marker->flags & flags) != flags) continue; - else if (marker->lineno < lineno) continue; - else if (marker->lineno > lineno) break; - - if ((marker->start == marker->end && start <= marker->start && marker->start <= end) || - (marker->start < end && marker->end > start)) - { - BLI_freelinkN(&text->markers, marker); - cleared = 1; - } - } - return cleared; -} - -/* Clears all markers in the specified group (if given) with at least the - * specified flags set. Useful for clearing temporary markers (group = 0, - * flags = TMARK_TEMP) */ -short txt_clear_markers(Text *text, int group, int flags) -{ - TextMarker *marker, *next; - short cleared = 0; - - for (marker = text->markers.first; marker; marker = next) { - next = marker->next; - - if ((!group || marker->group == group) && - (marker->flags & flags) == flags) - { - BLI_freelinkN(&text->markers, marker); - cleared = 1; - } - } - return cleared; -} - -/* Finds the marker at the specified line and cursor position with at least the - * specified flags set in the given group (if non-zero). */ -TextMarker *txt_find_marker(Text *text, TextLine *line, int curs, int group, int flags) -{ - TextMarker *marker; - int lineno = txt_get_span(text->lines.first, line); - - for (marker = text->markers.first; marker; marker = marker->next) { - if (group && marker->group != group) continue; - else if ((marker->flags & flags) != flags) continue; - else if (marker->lineno < lineno) continue; - else if (marker->lineno > lineno) break; - - if (marker->start <= curs && curs <= marker->end) - return marker; - } - return NULL; -} - -/* Finds the previous marker in the same group. If no other is found, the same - * marker will be returned */ -TextMarker *txt_prev_marker(Text *text, TextMarker *marker) -{ - TextMarker *tmp = marker; - while (tmp) { - if (tmp->prev) tmp = tmp->prev; - else tmp = text->markers.last; - if (tmp->group == marker->group) - return tmp; - } - return NULL; /* Only if (marker == NULL) */ -} - -/* Finds the next marker in the same group. If no other is found, the same - * marker will be returned */ -TextMarker *txt_next_marker(Text *text, TextMarker *marker) -{ - TextMarker *tmp = marker; - while (tmp) { - if (tmp->next) tmp = tmp->next; - else tmp = text->markers.first; - if (tmp->group == marker->group) - return tmp; - } - return NULL; /* Only if (marker == NULL) */ -} - - /*******************************/ /* Character utility functions */ /*******************************/ diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index da9c919c109..0f861a7ed37 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -111,6 +111,11 @@ static void delete_picture(AVFrame *f) } } +static int use_float_audio_buffer(int codec_id) +{ + return codec_id == CODEC_ID_AAC || codec_id == CODEC_ID_AC3 || codec_id == CODEC_ID_VORBIS; +} + #ifdef WITH_AUDASPACE static int write_audio_frame(void) { @@ -599,12 +604,14 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex /* Prepare an audio stream for the output file */ -static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContext *of) +static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContext *of, char *error, int error_size) { AVStream *st; AVCodecContext *c; AVCodec *codec; + error[0] = '\0'; + st = av_new_stream(of, 1); if (!st) return NULL; @@ -616,6 +623,10 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex c->bit_rate = ffmpeg_audio_bitrate * 1000; c->sample_fmt = AV_SAMPLE_FMT_S16; c->channels = rd->ffcodecdata.audio_channels; + if (use_float_audio_buffer(codec_id)) { + c->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; + c->sample_fmt = AV_SAMPLE_FMT_FLT; + } codec = avcodec_find_encoder(c->codec_id); if (!codec) { //XXX error("Couldn't find a valid audio codec"); @@ -626,6 +637,7 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex if (avcodec_open(c, codec) < 0) { //XXX error("Couldn't initialize audio codec"); + BLI_strncpy(error, IMB_ffmpeg_last_error(), error_size); return NULL; } @@ -646,7 +658,12 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex audio_output_buffer = (uint8_t *) av_malloc(audio_outbuf_size); - audio_input_buffer = (uint8_t *) av_malloc(audio_input_samples * c->channels * sizeof(int16_t)); + if (use_float_audio_buffer(codec_id)) { + audio_input_buffer = (uint8_t *) av_malloc(audio_input_samples * c->channels * sizeof(float)); + } + else { + audio_input_buffer = (uint8_t *) av_malloc(audio_input_samples * c->channels * sizeof(int16_t)); + } audio_time = 0.0f; @@ -801,9 +818,12 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report } if (ffmpeg_audio_codec != CODEC_ID_NONE) { - audio_stream = alloc_audio_stream(rd, fmt->audio_codec, of); + audio_stream = alloc_audio_stream(rd, fmt->audio_codec, of, error, sizeof(error)); if (!audio_stream) { - BKE_report(reports, RPT_ERROR, "Error initializing audio stream"); + if (error[0]) + BKE_report(reports, RPT_ERROR, error); + else + BKE_report(reports, RPT_ERROR, "Error initializing audio stream"); av_dict_free(&opts); return 0; } @@ -943,7 +963,12 @@ int BKE_ffmpeg_start(struct Scene *scene, RenderData *rd, int rectx, int recty, AVCodecContext *c = audio_stream->codec; AUD_DeviceSpecs specs; specs.channels = c->channels; - specs.format = AUD_FORMAT_S16; + if (use_float_audio_buffer(c->codec_id)) { + specs.format = AUD_FORMAT_FLOAT32; + } + else { + specs.format = AUD_FORMAT_S16; + } specs.rate = rd->ffcodecdata.audio_mixrate; audio_mixdown_device = sound_mixdown(scene, specs, rd->sfra, rd->ffcodecdata.audio_volume); #ifdef FFMPEG_CODEC_TIME_BASE diff --git a/source/blender/blenlib/BLI_endian_switch_inline.h b/source/blender/blenlib/BLI_endian_switch_inline.h index 4bc6d3828b9..358206f1177 100644 --- a/source/blender/blenlib/BLI_endian_switch_inline.h +++ b/source/blender/blenlib/BLI_endian_switch_inline.h @@ -38,41 +38,43 @@ /* *** 16 *** */ BLI_INLINE void BLI_endian_switch_int16(short *val) { - short tval = *val; - *val = (tval >> 8) | - (tval << 8); - + BLI_endian_switch_uint16((unsigned short *)val); } BLI_INLINE void BLI_endian_switch_uint16(unsigned short *val) { - BLI_endian_switch_int16((short *)val); + unsigned short tval = *val; + *val = (tval >> 8) | + (tval << 8); } /* *** 32 *** */ BLI_INLINE void BLI_endian_switch_int32(int *val) { - int tval = *val; + BLI_endian_switch_uint32((unsigned int *)val); +} +BLI_INLINE void BLI_endian_switch_uint32(unsigned int *val) +{ + unsigned int tval = *val; *val = ((tval >> 24)) | ((tval << 8) & 0x00ff0000) | ((tval >> 8) & 0x0000ff00) | ((tval << 24)); - -} -BLI_INLINE void BLI_endian_switch_uint32(unsigned int *val) -{ - BLI_endian_switch_int32((int *)val); } BLI_INLINE void BLI_endian_switch_float(float *val) { - BLI_endian_switch_int32((int *)val); + BLI_endian_switch_uint32((unsigned int *)val); } /* *** 64 *** */ BLI_INLINE void BLI_endian_switch_int64(int64_t *val) { - int64_t tval = *val; + BLI_endian_switch_uint64((uint64_t *)val); +} +BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val) +{ + uint64_t tval = *val; *val = ((tval >> 56)) | ((tval << 40) & 0x00ff000000000000ll) | ((tval << 24) & 0x0000ff0000000000ll) | @@ -82,13 +84,9 @@ BLI_INLINE void BLI_endian_switch_int64(int64_t *val) ((tval >> 40) & 0x000000000000ff00ll) | ((tval << 56)); } -BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val) -{ - BLI_endian_switch_int64((int64_t *)val); -} BLI_INLINE void BLI_endian_switch_double(double *val) { - BLI_endian_switch_int64((int64_t *)val); + BLI_endian_switch_uint64((uint64_t *)val); } #endif /* __BLI_ENDIAN_SWITCH_INLINE_H__ */ diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index c26e6cd15b3..7eac1425a5c 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -71,7 +71,7 @@ void BLI_ghash_insert(GHash *gh, void *key, void *val); void *BLI_ghash_lookup(GHash *gh, const void *key); int BLI_ghash_remove(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); void *BLI_ghash_pop(GHash *gh, void *key, GHashKeyFreeFP keyfreefp); -int BLI_ghash_haskey(GHash *gh, void *key); +int BLI_ghash_haskey(GHash *gh, const void *key); int BLI_ghash_size(GHash *gh); /* *** */ diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index 2b513cbec41..69d6478e0e2 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -170,7 +170,7 @@ } (void)0 #endif -#ifdef __BLI_MATH_INLINE_H__ +#if BLI_MATH_DO_INLINE #include "intern/math_base_inline.c" #endif @@ -203,7 +203,7 @@ MINLINE int is_power_of_2_i(int n); MINLINE int power_of_2_max_i(int n); MINLINE int power_of_2_min_i(int n); -MINLINE float shell_angle_to_dist(float angle); +MINLINE float shell_angle_to_dist(const float angle); #if (defined(WIN32) || defined(WIN64)) && !defined(FREE_WINDOWS) extern double copysign(double x, double y); diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index 7c8bf88943d..c71463da61d 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -121,7 +121,7 @@ MINLINE int compare_rgb_uchar(const unsigned char a[3], const unsigned char b[3] void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *offset, float *slope, float *power); -#ifdef __BLI_MATH_INLINE_H__ +#if BLI_MATH_DO_INLINE #include "intern/math_color_inline.c" #endif diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 509927e589c..cfd163d4e57 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -36,7 +36,7 @@ extern "C" { #include "BLI_math_inline.h" -#ifdef __BLI_MATH_INLINE_H__ +#if BLI_MATH_DO_INLINE #include "intern/math_geom_inline.c" #endif diff --git a/source/blender/blenlib/BLI_math_inline.h b/source/blender/blenlib/BLI_math_inline.h index ce43d5fb941..6dad44644f2 100644 --- a/source/blender/blenlib/BLI_math_inline.h +++ b/source/blender/blenlib/BLI_math_inline.h @@ -35,9 +35,10 @@ extern "C" { #endif /* add platform/compiler checks here if it is not supported */ -#define __BLI_MATH_INLINE_H__ +/* all platforms support forcing inline so this is always enabled */ +#define BLI_MATH_DO_INLINE 1 -#ifdef __BLI_MATH_INLINE_H__ +#if BLI_MATH_DO_INLINE # ifdef _MSC_VER # define MINLINE static __forceinline # define MALWAYS_INLINE MINLINE diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 5f80d1e52d7..f4572afec84 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -36,7 +36,7 @@ extern "C" { #include "BLI_math_inline.h" -#ifdef __BLI_MATH_INLINE_H__ +#if BLI_MATH_DO_INLINE #include "intern/math_vector_inline.c" #endif diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index cd3a934d816..7be636fe150 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -175,3 +175,9 @@ if(WIN32) endif() blender_add_lib(bf_blenlib "${SRC}" "${INC}" "${INC_SYS}") + +if(MSVC) + # Quiet warning about inline math library files that do not export symbols. + # (normally you'd exclude from project, but we still want to see the files in MSVC) + set_target_properties(bf_blenlib PROPERTIES STATIC_LIBRARY_FLAGS /ignore:4221) +endif() diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 0cae9bab531..c4094920c2a 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -178,7 +178,7 @@ void *BLI_ghash_pop(GHash *gh, void *key, GHashKeyFreeFP keyfreefp) return NULL; } -int BLI_ghash_haskey(GHash *gh, void *key) +int BLI_ghash_haskey(GHash *gh, const void *key) { unsigned int hash = gh->hashfp(key) % gh->nbuckets; Entry *e; diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index 8dccded64d1..b9866f9c6e6 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -27,6 +27,8 @@ * \ingroup bli */ +#ifndef __MATH_BASE_INLINE_C__ +#define __MATH_BASE_INLINE_C__ #include <float.h> #include <stdio.h> @@ -35,9 +37,6 @@ #include "BLI_math.h" -#ifndef __MATH_BASE_INLINE_C__ -#define __MATH_BASE_INLINE_C__ - /* A few small defines. Keep'em local! */ #define SMALL_NUMBER 1.e-8f diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c index 01585c93bc8..ba9770e1bd1 100644 --- a/source/blender/blenlib/intern/math_geom_inline.c +++ b/source/blender/blenlib/intern/math_geom_inline.c @@ -27,11 +27,12 @@ * \ingroup bli */ +#ifndef __MATH_GEOM_INLINE_C__ +#define __MATH_GEOM_INLINE_C__ #include "BLI_math.h" -#ifndef __MATH_GEOM_INLINE_C__ -#define __MATH_GEOM_INLINE_C__ +#include <string.h> /****************************** Spherical Harmonics **************************/ diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 191b0e16025..3ede8636aa5 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -27,12 +27,11 @@ * \ingroup bli */ - -#include "BLI_math.h" - #ifndef __MATH_VECTOR_INLINE_C__ #define __MATH_VECTOR_INLINE_C__ +#include "BLI_math.h" + /********************************** Init *************************************/ MINLINE void zero_v2(float r[2]) diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index ff589764287..14e0dc2f049 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -56,7 +56,7 @@ char *BLI_strdup(const char *str) return BLI_strdupn(str, strlen(str)); } -char *BLI_strdupcat(const char *str1, const char *str2) +char *BLI_strdupcat(const char *__restrict str1, const char *__restrict str2) { size_t len; char *n; @@ -69,7 +69,7 @@ char *BLI_strdupcat(const char *str1, const char *str2) return n; } -char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy) +char *BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) { size_t srclen = strlen(src); size_t cpylen = (srclen > (maxncpy - 1)) ? (maxncpy - 1) : srclen; @@ -81,7 +81,7 @@ char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy) return dst; } -size_t BLI_vsnprintf(char *buffer, size_t count, const char *format, va_list arg) +size_t BLI_vsnprintf(char *__restrict buffer, size_t count, const char *__restrict format, va_list arg) { size_t n; @@ -97,7 +97,7 @@ size_t BLI_vsnprintf(char *buffer, size_t count, const char *format, va_list arg return n; } -size_t BLI_snprintf(char *buffer, size_t count, const char *format, ...) +size_t BLI_snprintf(char *__restrict buffer, size_t count, const char *__restrict format, ...) { size_t n; va_list arg; @@ -109,7 +109,7 @@ size_t BLI_snprintf(char *buffer, size_t count, const char *format, ...) return n; } -char *BLI_sprintfN(const char *format, ...) +char *BLI_sprintfN(const char *__restrict format, ...) { DynStr *ds; va_list arg; @@ -133,7 +133,7 @@ char *BLI_sprintfN(const char *format, ...) * TODO: support more fancy string escaping. current code is primitive * this basically is an ascii version of PyUnicode_EncodeUnicodeEscape() * which is a useful reference. */ -size_t BLI_strescape(char *dst, const char *src, const size_t maxncpy) +size_t BLI_strescape(char *__restrict dst, const char *__restrict src, const size_t maxncpy) { size_t len = 0; @@ -186,7 +186,7 @@ escape_finish: * * TODO, return the offset and a length so as to avoid doing an allocation. */ -char *BLI_str_quoted_substrN(const char *str, const char *prefix) +char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict prefix) { size_t prefixLen = strlen(prefix); char *startMatch, *endMatch; @@ -207,7 +207,7 @@ char *BLI_str_quoted_substrN(const char *str, const char *prefix) /* A rather wasteful string-replacement utility, though this shall do for now... * Feel free to replace this with an even safe + nicer alternative */ -char *BLI_replacestr(char *str, const char *oldText, const char *newText) +char *BLI_replacestr(char *__restrict str, const char *__restrict oldText, const char *__restrict newText) { DynStr *ds = NULL; size_t lenOld = strlen(oldText); diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index e80f96ee0fe..16a5f03095d 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -184,7 +184,7 @@ static const size_t utf8_skip_data[256] = { *dst = '\0'; \ } (void)0 -char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy) +char *BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy) { char *dst_r = dst; @@ -196,7 +196,7 @@ char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy) return dst_r; } -char *BLI_strncat_utf8(char *dst, const char *src, size_t maxncpy) +char *BLI_strncat_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy) { while (*dst && maxncpy > 0) { dst++; @@ -213,7 +213,7 @@ char *BLI_strncat_utf8(char *dst, const char *src, size_t maxncpy) /* --------------------------------------------------------------------------*/ /* wchar_t / utf8 functions */ -size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t maxncpy) +size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, const size_t maxncpy) { size_t len = 0; @@ -289,7 +289,7 @@ size_t BLI_strnlen_utf8(const char *start, const size_t maxlen) return len; } -size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size_t maxncpy) +size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w, const char *__restrict src_c, const size_t maxncpy) { int len = 0; @@ -419,7 +419,7 @@ unsigned int BLI_str_utf8_as_unicode(const char *p) } /* variant that increments the length */ -unsigned int BLI_str_utf8_as_unicode_and_size(const char *p, size_t *index) +unsigned int BLI_str_utf8_as_unicode_and_size(const char *__restrict p, size_t *__restrict index) { int i, mask = 0, len; unsigned int result; @@ -435,7 +435,7 @@ unsigned int BLI_str_utf8_as_unicode_and_size(const char *p, size_t *index) /* another variant that steps over the index, * note, currently this also falls back to latin1 for text drawing. */ -unsigned int BLI_str_utf8_as_unicode_step(const char *p, size_t *index) +unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__restrict index) { int i, mask = 0, len; unsigned int result; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 90fd6cad93c..b9e23f60881 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2984,7 +2984,6 @@ static void direct_link_text(FileData *fd, Text *text) #endif link_list(fd, &text->lines); - link_list(fd, &text->markers); text->curl = newdataadr(fd, text->curl); text->sell = newdataadr(fd, text->sell); @@ -8502,11 +8501,17 @@ static void do_versions(FileData *fd, Library *lib, Main *main) for (scene = main->scene.first; scene; scene = scene->id.next) { if (scene->r.tilex == 0 || scene->r.tiley == 1) { - /* scene could be set for panoramic rendering, so clamp with the - * lowest possible tile size value - */ - scene->r.tilex = max_ii(scene->r.xsch * scene->r.size / scene->r.xparts / 100, 8); - scene->r.tiley = max_ii(scene->r.ysch * scene->r.size / scene->r.yparts / 100, 8); + if (scene->r.xparts && scene->r.yparts) { + /* scene could be set for panoramic rendering, so clamp with the + * lowest possible tile size value + */ + scene->r.tilex = max_ii(scene->r.xsch * scene->r.size / scene->r.xparts / 100, 8); + scene->r.tiley = max_ii(scene->r.ysch * scene->r.size / scene->r.yparts / 100, 8); + } + else { + /* happens when mixing using current trunk and previous release */ + scene->r.tilex = scene->r.tiley = 64; + } } } } @@ -8556,10 +8561,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main) { Object *ob; for (ob = main->object.first; ob; ob = ob->id.next) { - if (ob->step_height == 0.0) { - ob->step_height = 0.150; - ob->jump_speed = 10.0; - ob->fall_speed = 55.0; + if (ob->step_height == 0.0f) { + ob->step_height = 0.15f; + ob->jump_speed = 10.0f; + ob->fall_speed = 55.0f; } } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 7c022c6f45a..5cfbf809d04 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2620,7 +2620,6 @@ static void write_texts(WriteData *wd, ListBase *idbase) { Text *text; TextLine *tmp; - TextMarker *mrk; text= idbase->first; while (text) { @@ -2644,13 +2643,6 @@ static void write_texts(WriteData *wd, ListBase *idbase) writedata(wd, DATA, tmp->len+1, tmp->line); tmp= tmp->next; } - - /* write markers */ - mrk= text->markers.first; - while (mrk) { - writestruct(wd, DATA, "TextMarker", 1, mrk); - mrk= mrk->next; - } } diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index ba600cfe6bd..eabbf6f87cd 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -99,7 +99,7 @@ BMFace *BM_face_create_quad_tri_v(BMesh *bm, BMVert **verts, int len, const BMFa if (nodouble) { /* check if face exists or overlaps */ - is_overlap = BM_face_exists(bm, verts, len, &f); + is_overlap = BM_face_exists(verts, len, &f); } /* make new face */ diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index d4539050147..03094873e25 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -134,7 +134,7 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, e->v1 = v1; e->v2 = v2; - BM_elem_flag_enable(e, BM_ELEM_SMOOTH); + BM_elem_flag_enable(e, BM_ELEM_SMOOTH | BM_ELEM_DRAW); CustomData_bmesh_set_default(&bm->edata, &e->head.data); @@ -311,7 +311,7 @@ BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, if (nodouble) { /* Check if face already exists */ - overlap = BM_face_exists(bm, verts, len, &f); + overlap = BM_face_exists(verts, len, &f); if (overlap) { return f; } diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index 062c47dc686..ba5e7569c31 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -92,6 +92,14 @@ void BM_mesh_elem_toolflags_ensure(BMesh *bm) } } +void BM_mesh_elem_toolflags_clear(BMesh *bm) +{ + if (bm->toolflagpool) { + BLI_mempool_destroy(bm->toolflagpool); + bm->toolflagpool = NULL; + } +} + /** * \brief BMesh Make Mesh * @@ -171,9 +179,7 @@ void BM_mesh_data_free(BMesh *bm) BLI_mempool_destroy(bm->fpool); /* destroy flag pool */ - if (bm->toolflagpool) { - BLI_mempool_destroy(bm->toolflagpool); - } + BM_mesh_elem_toolflags_clear(bm); #ifdef USE_BMESH_HOLES BLI_mempool_destroy(bm->looplistpool); diff --git a/source/blender/bmesh/intern/bmesh_mesh.h b/source/blender/bmesh/intern/bmesh_mesh.h index 0dcd3fc2f01..b592f863cd1 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.h +++ b/source/blender/bmesh/intern/bmesh_mesh.h @@ -30,6 +30,7 @@ struct BMAllocTemplate; void BM_mesh_elem_toolflags_ensure(BMesh *bm); +void BM_mesh_elem_toolflags_clear(BMesh *bm); BMesh *BM_mesh_create(struct BMAllocTemplate *allocsize); void BM_mesh_free(BMesh *bm); diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index c5941a6c637..ec07eb5d9f7 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -47,9 +47,9 @@ * "in" (e.g. edgefacein). for three-type slots, use geom. * * for output slots, for single-type geometry slots, use the type name plus "out", - * (e.g. vertout), for double-type slots, use the two type names plus "out", - * (e.g. vertfaceout), for three-type slots, use geom. note that you can also - * use more esohteric names (e.g. skirtout) so long as the comment next to the + * (e.g. verts.out), for double-type slots, use the two type names plus "out", + * (e.g. vertfaces.out), for three-type slots, use geom. note that you can also + * use more esohteric names (e.g. geom_skirt.out) so long as the comment next to the * slot definition tells you what types of elements are in it. * */ @@ -82,7 +82,7 @@ * would be extracted from comments * next to them, e.g. * - * {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, //output slot, boundary region + * {BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, //output slot, boundary region * * the doc generator would automatically detect the presence of "output slot" * and flag the slot as an output. the same happens for "input slot". also @@ -99,16 +99,18 @@ */ static BMOpDefine bmo_smooth_vert_def = { "smooth_vert", - {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ - {BMO_OP_SLOT_BOOL, "mirror_clip_x"}, /* set vertices close to the x axis before the operation to 0 */ - {BMO_OP_SLOT_BOOL, "mirror_clip_y"}, /* set vertices close to the y axis before the operation to 0 */ - {BMO_OP_SLOT_BOOL, "mirror_clip_z"}, /* set vertices close to the z axis before the operation to 0 */ - {BMO_OP_SLOT_FLT, "clipdist"}, /* clipping threshod for the above three slots */ - {BMO_OP_SLOT_BOOL, "use_axis_x"}, /* smooth vertices along X axis */ - {BMO_OP_SLOT_BOOL, "use_axis_y"}, /* smooth vertices along Y axis */ - {BMO_OP_SLOT_BOOL, "use_axis_z"}, /* smooth vertices along Z axis */ - {0} /* null-terminating sentinel */, + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ + {BMO_OP_SLOT_BOOL, "mirror_clip_x"}, /* set vertices close to the x axis before the operation to 0 */ + {BMO_OP_SLOT_BOOL, "mirror_clip_y"}, /* set vertices close to the y axis before the operation to 0 */ + {BMO_OP_SLOT_BOOL, "mirror_clip_z"}, /* set vertices close to the z axis before the operation to 0 */ + {BMO_OP_SLOT_FLT, "clip_dist"}, /* clipping threshod for the above three slots */ + {BMO_OP_SLOT_BOOL, "use_axis_x"}, /* smooth vertices along X axis */ + {BMO_OP_SLOT_BOOL, "use_axis_y"}, /* smooth vertices along Y axis */ + {BMO_OP_SLOT_BOOL, "use_axis_z"}, /* smooth vertices along Z axis */ + {0}, }, + {{0}}, /* no output */ bmo_smooth_vert_exec, 0 }; @@ -120,15 +122,17 @@ static BMOpDefine bmo_smooth_vert_def = { */ static BMOpDefine bmo_smooth_laplacian_vert_def = { "smooth_laplacian_vert", - {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices - {BMO_OP_SLOT_FLT, "lambda"}, //lambda param - {BMO_OP_SLOT_FLT, "lambda_border"}, //lambda param in border - {BMO_OP_SLOT_BOOL, "use_x"}, //Smooth object along X axis - {BMO_OP_SLOT_BOOL, "use_y"}, //Smooth object along Y axis - {BMO_OP_SLOT_BOOL, "use_z"}, //Smooth object along Z axis - {BMO_OP_SLOT_BOOL, "volume_preservation"}, //Apply volume preservation after smooth - {0} /* null-terminating sentinel */, + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ + {BMO_OP_SLOT_FLT, "lambda"}, /* lambda param */ + {BMO_OP_SLOT_FLT, "lambda_border"}, /* lambda param in border */ + {BMO_OP_SLOT_BOOL, "use_x"}, /* Smooth object along X axis */ + {BMO_OP_SLOT_BOOL, "use_y"}, /* Smooth object along Y axis */ + {BMO_OP_SLOT_BOOL, "use_z"}, /* Smooth object along Z axis */ + {BMO_OP_SLOT_BOOL, "preserve_volume"}, /* Apply volume preservation after smooth */ + {0}, }, + {{0}}, /* no output */ bmo_smooth_laplacian_vert_exec, 0 }; @@ -141,10 +145,12 @@ static BMOpDefine bmo_smooth_laplacian_vert_def = { static BMOpDefine bmo_recalc_face_normals_def = { "recalc_face_normals", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, - {BMO_OP_SLOT_BOOL, "do_flip"}, /* internal flag, used by bmesh_rationalize_normals */ - {0} /* null-terminating sentinel */, + {BMO_OP_SLOT_BOOL, "use_flip"}, /* internal flag, used by bmesh_rationalize_normals */ + {0}, }, + {{0}}, /* no output */ bmo_recalc_face_normals_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -154,18 +160,22 @@ static BMOpDefine bmo_recalc_face_normals_def = { * * used to implement the select more/less tools. * this puts some geometry surrounding regions of - * geometry in geom into geomout. + * geometry in geom into geom.out. * - * if usefaces is 0 then geomout spits out verts and edges, + * if usefaces is 0 then geom.out spits out verts and edges, * otherwise it spits out faces. */ static BMOpDefine bmo_region_extend_def = { "region_extend", - {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry */ - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* output slot, computed boundary geometry. */ - {BMO_OP_SLOT_BOOL, "constrict"}, /* find boundary inside the regions, not outside. */ - {BMO_OP_SLOT_BOOL, "use_faces"}, /* extend from faces instead of edges */ - {0} /* null-terminating sentinel */, + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry */ + {BMO_OP_SLOT_BOOL, "use_constrict"}, /* find boundary inside the regions, not outside. */ + {BMO_OP_SLOT_BOOL, "use_faces"}, /* extend from faces instead of edges */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, /* output slot, computed boundary geometry. */ + {0}, }, bmo_region_extend_exec, 0 @@ -179,10 +189,14 @@ static BMOpDefine bmo_region_extend_def = { */ static BMOpDefine bmo_rotate_edges_def = { "rotate_edges", - {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* newly spun edges */ - {BMO_OP_SLOT_BOOL, "ccw"}, /* rotate edge counter-clockwise if true, othewise clockwise */ - {0} /* null-terminating sentinel */, + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ + {BMO_OP_SLOT_BOOL, "use_ccw"}, /* rotate edge counter-clockwise if true, othewise clockwise */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "edges.out"}, /* newly spun edges */ + {0}, }, bmo_rotate_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES @@ -196,9 +210,11 @@ static BMOpDefine bmo_rotate_edges_def = { */ static BMOpDefine bmo_reverse_faces_def = { "reverse_faces", - {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {0} /* null-terminating sentinel */, + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ + {0}, }, + {{0}}, /* no output */ bmo_reverse_faces_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -211,10 +227,14 @@ static BMOpDefine bmo_reverse_faces_def = { */ static BMOpDefine bmo_bisect_edges_def = { "bisect_edges", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ - {BMO_OP_SLOT_INT, "numcuts"}, /* number of cuts */ - {BMO_OP_SLOT_ELEMENT_BUF, "outsplit"}, /* newly created vertices and edges */ - {0} /* null-terminating sentinel */, + {BMO_OP_SLOT_INT, "cuts"}, /* number of cuts */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom_split.out"}, /* newly created vertices and edges */ + {0}, }, bmo_bisect_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES @@ -224,20 +244,25 @@ static BMOpDefine bmo_bisect_edges_def = { * Mirror * * Mirrors geometry along an axis. The resulting geometry is welded on using - * mergedist. Pairs of original/mirrored vertices are welded using the mergedist + * merge_dist. Pairs of original/mirrored vertices are welded using the merge_dist * parameter (which defines the minimum distance for welding to happen). */ static BMOpDefine bmo_mirror_def = { "mirror", - {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry */ - {BMO_OP_SLOT_MAT, "mat"}, /* matrix defining the mirror transformation */ - {BMO_OP_SLOT_FLT, "mergedist"}, /* maximum distance for merging. does no merging if 0. */ - {BMO_OP_SLOT_ELEMENT_BUF, "newout"}, /* output geometry, mirrored */ - {BMO_OP_SLOT_INT, "axis"}, /* the axis to use, 0, 1, or 2 for x, y, z */ + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix defining the mirror transformation */ + {BMO_OP_SLOT_FLT, "merge_dist"}, /* maximum distance for merging. does no merging if 0. */ + {BMO_OP_SLOT_INT, "axis"}, /* the axis to use, 0, 1, or 2 for x, y, z */ {BMO_OP_SLOT_BOOL, "mirror_u"}, /* mirror UVs across the u axis */ {BMO_OP_SLOT_BOOL, "mirror_v"}, /* mirror UVs across the v axis */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, /* output geometry, mirrored */ + {0}, + }, bmo_mirror_exec, 0, }; @@ -253,11 +278,16 @@ static BMOpDefine bmo_mirror_def = { */ static BMOpDefine bmo_find_doubles_def = { "find_doubles", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ {BMO_OP_SLOT_ELEMENT_BUF, "keep_verts"}, /* list of verts to keep */ {BMO_OP_SLOT_FLT, "dist"}, /* minimum distance */ - {BMO_OP_SLOT_MAPPING, "targetmapout"}, - {0, /* null-terminating sentinel */}}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_MAPPING, "targetmap.out"}, + {0}, + }, bmo_find_doubles_exec, 0, }; @@ -270,9 +300,12 @@ static BMOpDefine bmo_find_doubles_def = { */ static BMOpDefine bmo_remove_doubles_def = { "remove_doubles", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input verts */ {BMO_OP_SLOT_FLT, "dist"}, /* minimum distance */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + {{0}}, /* no output */ bmo_remove_doubles_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -286,9 +319,12 @@ static BMOpDefine bmo_remove_doubles_def = { */ static BMOpDefine bmo_automerge_def = { "automerge", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input verts */ {BMO_OP_SLOT_FLT, "dist"}, /* minimum distance */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + {{0}}, /* no output */ bmo_automerge_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -300,8 +336,11 @@ static BMOpDefine bmo_automerge_def = { */ static BMOpDefine bmo_collapse_def = { "collapse", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edge */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + {{0}}, /* no output */ bmo_collapse_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -314,9 +353,12 @@ static BMOpDefine bmo_collapse_def = { */ static BMOpDefine bmo_pointmerge_facedata_def = { "pointmerge_facedata", - {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */ - {BMO_OP_SLOT_ELEMENT_BUF, "snapv"}, /* snap verte */ - {0, /* null-terminating sentinel */}}, + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ + {BMO_OP_SLOT_ELEMENT_BUF, "snapv"}, /* snap vertex */ + {0}, + }, + {{0}}, /* no output */ bmo_pointmerge_facedata_exec, 0, }; @@ -330,8 +372,11 @@ static BMOpDefine bmo_pointmerge_facedata_def = { */ static BMOpDefine bmo_average_vert_facedata_def = { "average_vert_facedata", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + {{0}}, /* no output */ bmo_average_vert_facedata_exec, 0, }; @@ -343,9 +388,12 @@ static BMOpDefine bmo_average_vert_facedata_def = { */ static BMOpDefine bmo_pointmerge_def = { "pointmerge", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */ {BMO_OP_SLOT_VEC, "merge_co"}, - {0, /* null-terminating sentinel */}}, + {0}, + }, + {{0}}, /* no output */ bmo_pointmerge_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -357,8 +405,11 @@ static BMOpDefine bmo_pointmerge_def = { */ static BMOpDefine bmo_collapse_uvs_def = { "collapse_uvs", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edge */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + {{0}}, /* no output */ bmo_collapse_uvs_exec, 0, }; @@ -372,8 +423,11 @@ static BMOpDefine bmo_collapse_uvs_def = { */ static BMOpDefine bmo_weld_verts_def = { "weld_verts", + /* slots_in */ {{BMO_OP_SLOT_MAPPING, "targetmap"}, /* maps welded vertices to verts they should weld to */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + {{0}}, /* no output */ bmo_weld_verts_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -386,9 +440,14 @@ static BMOpDefine bmo_weld_verts_def = { */ static BMOpDefine bmo_create_vert_def = { "create_vert", + /* slots_in */ {{BMO_OP_SLOT_VEC, "co"}, /* the coordinate of the new vert */ - {BMO_OP_SLOT_ELEMENT_BUF, "newvertout"}, /* the new vert */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "vert.out"}, /* the new vert */ + {0}, + }, bmo_create_vert_exec, 0, }; @@ -401,14 +460,19 @@ static BMOpDefine bmo_create_vert_def = { */ static BMOpDefine bmo_join_triangles_def = { "join_triangles", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input geometry. */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* joined faces */ {BMO_OP_SLOT_BOOL, "cmp_sharp"}, {BMO_OP_SLOT_BOOL, "cmp_uvs"}, {BMO_OP_SLOT_BOOL, "cmp_vcols"}, {BMO_OP_SLOT_BOOL, "cmp_materials"}, {BMO_OP_SLOT_FLT, "limit"}, - {0, /* null-terminating sentinel */}}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* joined faces */ + {0}, + }, bmo_join_triangles_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -426,13 +490,18 @@ static BMOpDefine bmo_join_triangles_def = { */ static BMOpDefine bmo_contextual_create_def = { "contextual_create", - {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry. */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* newly-made face(s) */ + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry. */ + {BMO_OP_SLOT_INT, "mat_nr"}, /* material to use */ + {BMO_OP_SLOT_BOOL, "use_smooth"}, /* smooth to use */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* newly-made face(s) */ /* note, this is for stand-alone edges only, not edges which are apart of newly created faces */ - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* newly-made edge(s) */ - {BMO_OP_SLOT_INT, "mat_nr"}, /* material to use */ - {BMO_OP_SLOT_BOOL, "use_smooth"}, /* material to use */ - {0, /* null-terminating sentinel */}}, + {BMO_OP_SLOT_ELEMENT_BUF, "edges.out"}, /* newly-made edge(s) */ + {0}, + }, bmo_contextual_create_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -442,27 +511,37 @@ static BMOpDefine bmo_contextual_create_def = { */ static BMOpDefine bmo_bridge_loops_def = { "bridge_loops", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edge */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* new face */ {BMO_OP_SLOT_BOOL, "use_merge"}, {BMO_OP_SLOT_FLT, "merge_factor"}, - {0, /* null-terminating sentinel */}}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* new faces */ + {0}, + }, bmo_bridge_loops_exec, 0, }; static BMOpDefine bmo_edgenet_fill_def = { "edgenet_fill", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edge */ {BMO_OP_SLOT_MAPPING, "restrict"}, /* restricts edges to groups. maps edges to integer */ {BMO_OP_SLOT_BOOL, "use_restrict"}, {BMO_OP_SLOT_BOOL, "use_fill_check"}, - {BMO_OP_SLOT_ELEMENT_BUF, "excludefaces"}, /* list of faces to ignore for manifold check */ - {BMO_OP_SLOT_MAPPING, "faceout_groupmap"}, /* maps new faces to the group numbers they came fro */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* new face */ + {BMO_OP_SLOT_ELEMENT_BUF, "exclude_faces"}, /* list of faces to ignore for manifold check */ {BMO_OP_SLOT_INT, "mat_nr"}, /* material to use */ {BMO_OP_SLOT_BOOL, "use_smooth"}, /* material to use */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_MAPPING, "face_groupmap.out"}, /* maps new faces to the group numbers they came from */ + {BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* new face */ + {0}, + }, bmo_edgenet_fill_exec, 0, }; @@ -479,9 +558,14 @@ static BMOpDefine bmo_edgenet_fill_def = { */ static BMOpDefine bmo_edgenet_prepare_def = { "edgenet_prepare", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* new edges */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "edges.out"}, /* new edges */ + {0}, + }, bmo_edgenet_prepare, 0, }; @@ -494,10 +578,13 @@ static BMOpDefine bmo_edgenet_prepare_def = { */ static BMOpDefine bmo_rotate_def = { "rotate", + /* slots_in */ {{BMO_OP_SLOT_VEC, "cent"}, /* center of rotation */ {BMO_OP_SLOT_MAT, "mat"}, /* matrix defining rotation */ {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + {{0}}, /* no output */ bmo_rotate_exec, 0, }; @@ -510,9 +597,12 @@ static BMOpDefine bmo_rotate_def = { */ static BMOpDefine bmo_translate_def = { "translate", + /* slots_in */ {{BMO_OP_SLOT_VEC, "vec"}, /* translation offset */ {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + {{0}}, /* no output */ bmo_translate_exec, 0, }; @@ -524,9 +614,12 @@ static BMOpDefine bmo_translate_def = { */ static BMOpDefine bmo_scale_def = { "scale", + /* slots_in */ {{BMO_OP_SLOT_VEC, "vec"}, /* scale factor */ {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + {{0}}, /* no output */ bmo_scale_exec, 0, }; @@ -540,9 +633,12 @@ static BMOpDefine bmo_scale_def = { */ static BMOpDefine bmo_transform_def = { "transform", + /* slots_in */ {{BMO_OP_SLOT_MAT, "mat"}, /* transform matrix */ {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + {{0}}, /* no output */ bmo_transform_exec, 0, }; @@ -555,9 +651,12 @@ static BMOpDefine bmo_transform_def = { */ static BMOpDefine bmo_object_load_bmesh_def = { "object_load_bmesh", + /* slots_in */ {{BMO_OP_SLOT_PTR, "scene"}, {BMO_OP_SLOT_PTR, "object"}, - {0, /* null-terminating sentinel */}}, + {0}, + }, + {{0}}, /* no output */ bmo_object_load_bmesh_exec, 0, }; @@ -570,10 +669,13 @@ static BMOpDefine bmo_object_load_bmesh_def = { */ static BMOpDefine bmo_bmesh_to_mesh_def = { "bmesh_to_mesh", + /* slots_in */ {{BMO_OP_SLOT_PTR, "mesh"}, /* pointer to a mesh structure to fill in */ {BMO_OP_SLOT_PTR, "object"}, /* pointer to an object structure */ - {BMO_OP_SLOT_BOOL, "notessellation"}, /* don't calculate mfaces */ - {0, /* null-terminating sentinel */}}, + {BMO_OP_SLOT_BOOL, "skip_tessface"}, /* don't calculate mfaces */ + {0}, + }, + {{0}}, /* no output */ bmo_bmesh_to_mesh_exec, 0, }; @@ -586,10 +688,13 @@ static BMOpDefine bmo_bmesh_to_mesh_def = { */ static BMOpDefine bmo_mesh_to_bmesh_def = { "mesh_to_bmesh", + /* slots_in */ {{BMO_OP_SLOT_PTR, "mesh"}, /* pointer to a Mesh structure */ {BMO_OP_SLOT_PTR, "object"}, /* pointer to an Object structure */ - {BMO_OP_SLOT_BOOL, "set_shapekey"}, /* load active shapekey coordinates into verts */ - {0, /* null-terminating sentinel */}}, + {BMO_OP_SLOT_BOOL, "use_shapekey"}, /* load active shapekey coordinates into verts */ + {0}, + }, + {{0}}, /* no output */ bmo_mesh_to_bmesh_exec, 0 }; @@ -601,10 +706,15 @@ static BMOpDefine bmo_mesh_to_bmesh_def = { */ static BMOpDefine bmo_extrude_discrete_faces_def = { "extrude_discrete_faces", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ - {BMO_OP_SLOT_ELEMENT_BUF, "skirtout"}, /* output skirt geometry, faces and edges */ - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* output faces */ + {BMO_OP_SLOT_ELEMENT_BUF, "geom_skirt.out"}, /* output skirt geometry, faces and edges */ + {0}, + }, bmo_extrude_discrete_faces_exec, 0 }; @@ -617,9 +727,14 @@ static BMOpDefine bmo_extrude_discrete_faces_def = { */ static BMOpDefine bmo_extrude_edge_only_def = { "extrude_edge_only", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input vertices */ - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* output geometry */ - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, /* output geometry */ + {0}, + }, bmo_extrude_edge_only_exec, 0 }; @@ -631,125 +746,171 @@ static BMOpDefine bmo_extrude_edge_only_def = { */ static BMOpDefine bmo_extrude_vert_indiv_def = { "extrude_vert_indiv", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* output wire edges */ - {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "edges.out"}, /* output wire edges */ + {BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output vertices */ + {0}, + }, bmo_extrude_vert_indiv_exec, 0 }; static BMOpDefine bmo_connect_verts_def = { "connect_verts", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "edges.out"}, + {0}, + }, bmo_connect_verts_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; static BMOpDefine bmo_extrude_face_region_def = { "extrude_face_region", - {{BMO_OP_SLOT_ELEMENT_BUF, "edgefacein"}, - {BMO_OP_SLOT_MAPPING, "exclude"}, - {BMO_OP_SLOT_BOOL, "alwayskeeporig"}, - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, - {0} /* null-terminating sentinel */}, + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* edges and faces */ + {BMO_OP_SLOT_MAPPING, "edges_exclude"}, + {BMO_OP_SLOT_BOOL, "use_keep_orig"}, /* keep original geometry */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, + {0}, + }, bmo_extrude_face_region_exec, 0 }; static BMOpDefine bmo_dissolve_verts_def = { "dissolve_verts", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, - {0} /* null-terminating sentinel */}, + {0}, + }, + {{0}}, /* no output */ bmo_dissolve_verts_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; static BMOpDefine bmo_dissolve_edges_def = { "dissolve_edges", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, - {BMO_OP_SLOT_ELEMENT_BUF, "regionout"}, {BMO_OP_SLOT_BOOL, "use_verts"}, /* dissolve verts left between only 2 edges. */ - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "region.out"}, + {0}, + }, bmo_dissolve_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; static BMOpDefine bmo_dissolve_edge_loop_def = { "dissolve_edge_loop", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, - {BMO_OP_SLOT_ELEMENT_BUF, "regionout"}, - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "region.out"}, + {0}, + }, bmo_dissolve_edgeloop_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; static BMOpDefine bmo_dissolve_faces_def = { "dissolve_faces", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, - {BMO_OP_SLOT_ELEMENT_BUF, "regionout"}, {BMO_OP_SLOT_BOOL, "use_verts"}, /* dissolve verts left between only 2 edges. */ - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "region.out"}, + {0}, + }, bmo_dissolve_faces_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; static BMOpDefine bmo_dissolve_limit_def = { "dissolve_limit", + /* slots_in */ {{BMO_OP_SLOT_FLT, "angle_limit"}, /* total rotation angle (degrees) */ {BMO_OP_SLOT_BOOL, "use_dissolve_boundaries"}, {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, {BMO_OP_SLOT_ELEMENT_BUF, "edges"}, - {0} /* null-terminating sentinel */}, + {0}, + }, + {{0}}, /* no output */ bmo_dissolve_limit_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; static BMOpDefine bmo_triangulate_def = { "triangulate", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, - {BMO_OP_SLOT_MAPPING, "facemap"}, {BMO_OP_SLOT_BOOL, "use_beauty"}, - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "edges.out"}, + {BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, + {BMO_OP_SLOT_MAPPING, "facemap.out"}, + {0}, + }, bmo_triangulate_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; static BMOpDefine bmo_unsubdivide_def = { "unsubdivide", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ {BMO_OP_SLOT_INT, "iterations"}, - {0} /* null-terminating sentinel */}, + {0}, + }, + {{0}}, /* no output */ bmo_unsubdivide_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; static BMOpDefine bmo_subdivide_edges_def = { "subdivide_edges", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, {BMO_OP_SLOT_FLT, "smooth"}, {BMO_OP_SLOT_FLT, "fractal"}, {BMO_OP_SLOT_FLT, "along_normal"}, - {BMO_OP_SLOT_INT, "numcuts"}, + {BMO_OP_SLOT_INT, "cuts"}, {BMO_OP_SLOT_INT, "seed"}, {BMO_OP_SLOT_MAPPING, "custompatterns"}, {BMO_OP_SLOT_MAPPING, "edgepercents"}, - /* these next three can have multiple types of elements in them */ - {BMO_OP_SLOT_ELEMENT_BUF, "outinner"}, - {BMO_OP_SLOT_ELEMENT_BUF, "outsplit"}, - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* contains all output geometr */ - - {BMO_OP_SLOT_INT, "quadcornertype"}, /* quad corner type, see bmesh_operators.h */ + {BMO_OP_SLOT_INT, "quad_corner_type"}, /* quad corner type, see bmesh_operators.h */ {BMO_OP_SLOT_BOOL, "use_gridfill"}, /* fill in fully-selected faces with a grid */ {BMO_OP_SLOT_BOOL, "use_singleedge"}, /* tessellate the case of one edge selected in a quad or triangle */ {BMO_OP_SLOT_BOOL, "use_sphere"}, /* for making new primitives only */ - - {0} /* null-terminating sentinel */, + {0}, + }, + /* slots_out */ + {/* these next three can have multiple types of elements in them */ + {BMO_OP_SLOT_ELEMENT_BUF, "geom_inner.out"}, + {BMO_OP_SLOT_ELEMENT_BUF, "geom_split.out"}, + {BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, /* contains all output geometr */ + {0}, }, bmo_subdivide_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES @@ -757,38 +918,51 @@ static BMOpDefine bmo_subdivide_edges_def = { static BMOpDefine bmo_delete_def = { "delete", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, {BMO_OP_SLOT_INT, "context"}, - {0} /* null-terminating sentinel */}, + {0}, + }, + {{0}}, /* no output */ bmo_delete_exec, 0 }; static BMOpDefine bmo_duplicate_def = { "duplicate", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, - {BMO_OP_SLOT_ELEMENT_BUF, "origout"}, - {BMO_OP_SLOT_ELEMENT_BUF, "newout"}, + {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current on */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom_orig.out"}, + {BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, /* facemap maps from source faces to dupe * faces, and from dupe faces to source faces */ - {BMO_OP_SLOT_MAPPING, "facemap"}, - {BMO_OP_SLOT_MAPPING, "boundarymap"}, - {BMO_OP_SLOT_MAPPING, "isovertmap"}, - {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current on */ - {0} /* null-terminating sentinel */}, + {BMO_OP_SLOT_MAPPING, "facemap.out"}, + {BMO_OP_SLOT_MAPPING, "boundarymap.out"}, + {BMO_OP_SLOT_MAPPING, "isovertmap.out"}, + {0}, + }, bmo_duplicate_exec, 0 }; static BMOpDefine bmo_split_def = { "split", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, - {BMO_OP_SLOT_MAPPING, "boundarymap"}, - {BMO_OP_SLOT_MAPPING, "isovertmap"}, - {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current on */ - {BMO_OP_SLOT_BOOL, "use_only_faces"}, /* when enabled. don't duplicate loose verts/edges */ - {0} /* null-terminating sentinel */}, + {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current one */ + {BMO_OP_SLOT_BOOL, "use_only_faces"}, /* when enabled. don't duplicate loose verts/edges */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, + {BMO_OP_SLOT_MAPPING, "boundarymap.out"}, + {BMO_OP_SLOT_MAPPING, "isovertmap.out"}, + {0}, + }, bmo_split_exec, 0 }; @@ -801,15 +975,20 @@ static BMOpDefine bmo_split_def = { */ static BMOpDefine bmo_spin_def = { "spin", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, - {BMO_OP_SLOT_ELEMENT_BUF, "lastout"}, /* result of last step */ - {BMO_OP_SLOT_VEC, "cent"}, /* rotation center */ - {BMO_OP_SLOT_VEC, "axis"}, /* rotation axis */ - {BMO_OP_SLOT_VEC, "dvec"}, /* translation delta per step */ - {BMO_OP_SLOT_FLT, "ang"}, /* total rotation angle (degrees) */ - {BMO_OP_SLOT_INT, "steps"}, /* number of steps */ - {BMO_OP_SLOT_BOOL, "do_dupli"}, /* duplicate or extrude? */ - {0} /* null-terminating sentinel */}, + {BMO_OP_SLOT_VEC, "cent"}, /* rotation center */ + {BMO_OP_SLOT_VEC, "axis"}, /* rotation axis */ + {BMO_OP_SLOT_VEC, "dvec"}, /* translation delta per step */ + {BMO_OP_SLOT_FLT, "angle"}, /* total rotation angle (degrees) */ + {BMO_OP_SLOT_INT, "steps"}, /* number of steps */ + {BMO_OP_SLOT_BOOL, "use_duplicate"}, /* duplicate or extrude? */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom_last.out"}, /* result of last step */ + {0}, + }, bmo_spin_exec, 0 }; @@ -822,12 +1001,17 @@ static BMOpDefine bmo_spin_def = { */ static BMOpDefine bmo_similar_faces_def = { "similar_faces", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */ {BMO_OP_SLOT_INT, "compare"}, /* comparison method */ - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* output faces */ + {0}, + }, bmo_similar_faces_exec, 0 }; @@ -839,12 +1023,17 @@ static BMOpDefine bmo_similar_faces_def = { */ static BMOpDefine bmo_similar_edges_def = { "similar_edges", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* output edges */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */ {BMO_OP_SLOT_INT, "compare"}, /* comparison method */ - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "edges.out"}, /* output edges */ + {0}, + }, bmo_similar_edges_exec, 0 }; @@ -856,12 +1045,17 @@ static BMOpDefine bmo_similar_edges_def = { */ static BMOpDefine bmo_similar_verts_def = { "similar_verts", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ - {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */ {BMO_OP_SLOT_INT, "compare"}, /* comparison method */ - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output vertices */ + {0}, + }, bmo_similar_verts_exec, 0 }; @@ -872,9 +1066,13 @@ static BMOpDefine bmo_similar_verts_def = { */ static BMOpDefine bmo_rotate_uvs_def = { "rotate_uvs", - {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {BMO_OP_SLOT_INT, "dir"}, /* direction */ - {0} /* null-terminating sentinel */}, + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ + {BMO_OP_SLOT_BOOL, "use_ccw"}, /* rotate counter-clockwise if true, othewise clockwise */ + {0}, + }, + /* slots_out */ + {{0}}, /* no output */ bmo_rotate_uvs_exec, 0 }; @@ -885,8 +1083,11 @@ static BMOpDefine bmo_rotate_uvs_def = { */ static BMOpDefine bmo_reverse_uvs_def = { "reverse_uvs", - {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {0} /* null-terminating sentinel */}, + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ + {0}, + }, + {{0}}, /* no output */ bmo_reverse_uvs_exec, 0 }; @@ -897,9 +1098,12 @@ static BMOpDefine bmo_reverse_uvs_def = { */ static BMOpDefine bmo_rotate_colors_def = { "rotate_colors", - {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {BMO_OP_SLOT_INT, "dir"}, /* direction */ - {0} /* null-terminating sentinel */}, + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ + {BMO_OP_SLOT_BOOL, "use_ccw"}, /* rotate counter-clockwise if true, othewise clockwise */ + {0}, + }, + {{0}}, /* no output */ bmo_rotate_colors_exec, 0 }; @@ -910,8 +1114,11 @@ static BMOpDefine bmo_rotate_colors_def = { */ static BMOpDefine bmo_reverse_colors_def = { "reverse_colors", - {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {0} /* null-terminating sentinel */}, + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ + {0}, + }, + {{0}}, /* no output */ bmo_reverse_colors_exec, 0 }; @@ -923,11 +1130,16 @@ static BMOpDefine bmo_reverse_colors_def = { */ static BMOpDefine bmo_shortest_path_def = { "shortest_path", - {{BMO_OP_SLOT_ELEMENT_BUF, "startv"}, /* start vertex */ - {BMO_OP_SLOT_ELEMENT_BUF, "endv"}, /* end vertex */ - {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ - {BMO_OP_SLOT_INT, "type"}, /* type of selection */ - {0} /* null-terminating sentinel */}, + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "startv"}, /* start vertex */ + {BMO_OP_SLOT_ELEMENT_BUF, "endv"}, /* end vertex */ + {BMO_OP_SLOT_INT, "type"}, /* type of selection */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output vertices */ + {0}, + }, bmo_shortest_path_exec, 0 }; @@ -939,12 +1151,17 @@ static BMOpDefine bmo_shortest_path_def = { */ static BMOpDefine bmo_split_edges_def = { "split_edges", - {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* old output disconnected edges */ + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ /* needed for vertex rip so we can rip only half an edge at a boundary wich would otherwise split off */ - {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* optional tag verts, use to have greater control of splits */ + {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* optional tag verts, use to have greater control of splits */ {BMO_OP_SLOT_BOOL, "use_verts"}, /* use 'verts' for splitting, else just find verts to split from edges */ - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "edges.out"}, /* old output disconnected edges */ + {0}, + }, bmo_split_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -956,12 +1173,17 @@ static BMOpDefine bmo_split_edges_def = { */ static BMOpDefine bmo_create_grid_def = { "create_grid", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ - {BMO_OP_SLOT_INT, "xsegments"}, /* number of x segments */ - {BMO_OP_SLOT_INT, "ysegments"}, /* number of y segments */ - {BMO_OP_SLOT_FLT, "size"}, /* size of the grid */ - {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */ - {0, /* null-terminating sentinel */}}, + /* slots_in */ + {{BMO_OP_SLOT_INT, "x_segments"}, /* number of x segments */ + {BMO_OP_SLOT_INT, "y_segments"}, /* number of y segments */ + {BMO_OP_SLOT_FLT, "size"}, /* size of the grid */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output verts */ + {0}, + }, bmo_create_grid_exec, 0, }; @@ -973,12 +1195,17 @@ static BMOpDefine bmo_create_grid_def = { */ static BMOpDefine bmo_create_uvsphere_def = { "create_uvsphere", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ - {BMO_OP_SLOT_INT, "segments"}, /* number of u segments */ - {BMO_OP_SLOT_INT, "revolutions"}, /* number of v segment */ + /* slots_in */ + {{BMO_OP_SLOT_INT, "u_segments"}, /* number of u segments */ + {BMO_OP_SLOT_INT, "v_segments"}, /* number of v segment */ {BMO_OP_SLOT_FLT, "diameter"}, /* diameter */ - {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ - {0, /* null-terminating sentinel */}}, + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output verts */ + {0}, + }, bmo_create_uvsphere_exec, 0, }; @@ -990,11 +1217,16 @@ static BMOpDefine bmo_create_uvsphere_def = { */ static BMOpDefine bmo_create_icosphere_def = { "create_icosphere", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ - {BMO_OP_SLOT_INT, "subdivisions"}, /* how many times to recursively subdivide the sphere */ + /* slots_in */ + {{BMO_OP_SLOT_INT, "subdivisions"}, /* how many times to recursively subdivide the sphere */ {BMO_OP_SLOT_FLT, "diameter"}, /* diameter */ {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */ - {0, /* null-terminating sentinel */}}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output verts */ + {0}, + }, bmo_create_icosphere_exec, 0, }; @@ -1006,9 +1238,14 @@ static BMOpDefine bmo_create_icosphere_def = { */ static BMOpDefine bmo_create_monkey_def = { "create_monkey", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ - {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ - {0, /* null-terminating sentinel */}}, + /* slots_in */ + {{BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output verts */ + {0}, + }, bmo_create_monkey_exec, 0, }; @@ -1020,15 +1257,20 @@ static BMOpDefine bmo_create_monkey_def = { */ static BMOpDefine bmo_create_cone_def = { "create_cone", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ - {BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */ - {BMO_OP_SLOT_BOOL, "cap_tris"}, /* fill ends with triangles instead of ngons */ + /* slots_in */ + {{BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */ + {BMO_OP_SLOT_BOOL, "cap_tris"}, /* fill ends with triangles instead of ngons */ {BMO_OP_SLOT_INT, "segments"}, - {BMO_OP_SLOT_FLT, "diameter1"}, /* diameter of one end */ - {BMO_OP_SLOT_FLT, "diameter2"}, /* diameter of the opposite */ - {BMO_OP_SLOT_FLT, "depth"}, /* distance between ends */ - {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ - {0, /* null-terminating sentinel */}}, + {BMO_OP_SLOT_FLT, "diameter1"}, /* diameter of one end */ + {BMO_OP_SLOT_FLT, "diameter2"}, /* diameter of the opposite */ + {BMO_OP_SLOT_FLT, "depth"}, /* distance between ends */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output verts */ + {0}, + }, bmo_create_cone_exec, 0, }; @@ -1038,13 +1280,18 @@ static BMOpDefine bmo_create_cone_def = { */ static BMOpDefine bmo_create_circle_def = { "create_circle", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ - {BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */ - {BMO_OP_SLOT_BOOL, "cap_tris"}, /* fill ends with triangles instead of ngons */ + /* slots_in */ + {{BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */ + {BMO_OP_SLOT_BOOL, "cap_tris"}, /* fill ends with triangles instead of ngons */ {BMO_OP_SLOT_INT, "segments"}, - {BMO_OP_SLOT_FLT, "diameter"}, /* diameter of one end */ - {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ - {0, /* null-terminating sentinel */}}, + {BMO_OP_SLOT_FLT, "diameter"}, /* diameter of one end */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output verts */ + {0}, + }, bmo_create_circle_exec, 0, }; @@ -1056,15 +1303,19 @@ static BMOpDefine bmo_create_circle_def = { */ static BMOpDefine bmo_create_cube_def = { "create_cube", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ - {BMO_OP_SLOT_FLT, "size"}, /* size of the cube */ - {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ - {0, /* null-terminating sentinel */}}, + /* slots_in */ + {{BMO_OP_SLOT_FLT, "size"}, /* size of the cube */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output verts */ + {0}, + }, bmo_create_cube_exec, 0, }; -#define NEW_BEVEL 1 /* * Bevel * @@ -1072,12 +1323,17 @@ static BMOpDefine bmo_create_cube_def = { */ static BMOpDefine bmo_bevel_def = { "bevel", -#ifdef NEW_BEVEL - {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input edges and vertices */ - {BMO_OP_SLOT_FLT, "offset"}, /* amount to offset beveled edge */ - {BMO_OP_SLOT_INT, "segments"}, /* number of segments in bevel */ - {0} /* null-terminating sentinel */}, -#else + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input edges and vertices */ + {BMO_OP_SLOT_FLT, "offset"}, /* amount to offset beveled edge */ + {BMO_OP_SLOT_INT, "segments"}, /* number of segments in bevel */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* output faces */ + {0}, + }, +#if 0 /* old bevel*/ {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input edges and vertices */ {BMO_OP_SLOT_ELEMENT_BUF, "face_spans"}, /* new geometry */ {BMO_OP_SLOT_ELEMENT_BUF, "face_holes"}, /* new geometry */ @@ -1087,7 +1343,8 @@ static BMOpDefine bmo_bevel_def = { * modifier uses this. We could do this as another float setting */ {BMO_OP_SLOT_INT, "lengthlayer"}, /* which PROP_FLT layer to us */ {BMO_OP_SLOT_FLT, "percent"}, /* percentage to expand beveled edge */ - {0} /* null-terminating sentinel */}, + {0}, + }, #endif bmo_bevel_exec, BMO_OP_FLAG_UNTAN_MULTIRES @@ -1100,10 +1357,15 @@ static BMOpDefine bmo_bevel_def = { */ static BMOpDefine bmo_beautify_fill_def = { "beautify_fill", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMO_OP_SLOT_ELEMENT_BUF, "constrain_edges"}, /* edges that can't be flipped */ - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* new flipped faces and edges */ - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, /* new flipped faces and edges */ + {0}, + }, bmo_beautify_fill_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -1115,9 +1377,14 @@ static BMOpDefine bmo_beautify_fill_def = { */ static BMOpDefine bmo_triangle_fill_def = { "triangle_fill", - {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* new faces and edges */ - {0} /* null-terminating sentinel */}, + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, /* new faces and edges */ + {0}, + }, bmo_triangle_fill_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -1129,10 +1396,15 @@ static BMOpDefine bmo_triangle_fill_def = { */ static BMOpDefine bmo_solidify_def = { "solidify", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, {BMO_OP_SLOT_FLT, "thickness"}, - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, - {0}}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, + {0}, + }, bmo_solidify_face_region_exec, 0 }; @@ -1144,15 +1416,20 @@ static BMOpDefine bmo_solidify_def = { */ static BMOpDefine bmo_inset_def = { "inset", - {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ + /* slots_in */ + {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMO_OP_SLOT_BOOL, "use_boundary"}, {BMO_OP_SLOT_BOOL, "use_even_offset"}, {BMO_OP_SLOT_BOOL, "use_relative_offset"}, {BMO_OP_SLOT_FLT, "thickness"}, {BMO_OP_SLOT_FLT, "depth"}, {BMO_OP_SLOT_BOOL, "use_outset"}, - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* output faces */ + {0}, + }, bmo_inset_exec, 0 }; @@ -1164,15 +1441,20 @@ static BMOpDefine bmo_inset_def = { */ static BMOpDefine bmo_wireframe_def = { "wireframe", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ {BMO_OP_SLOT_BOOL, "use_boundary"}, {BMO_OP_SLOT_BOOL, "use_even_offset"}, {BMO_OP_SLOT_BOOL, "use_crease"}, {BMO_OP_SLOT_FLT, "thickness"}, {BMO_OP_SLOT_BOOL, "use_relative_offset"}, {BMO_OP_SLOT_FLT, "depth"}, - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* output faces */ + {0}, + }, bmo_wireframe_exec, 0 }; @@ -1184,11 +1466,16 @@ static BMOpDefine bmo_wireframe_def = { */ static BMOpDefine bmo_slide_vert_def = { "slide_vert", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "vert"}, {BMO_OP_SLOT_ELEMENT_BUF, "edge"}, - {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, {BMO_OP_SLOT_FLT, "distance_t"}, - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, + {0}, + }, bmo_slide_vert_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -1202,7 +1489,7 @@ static BMOpDefine bmo_slide_vert_def = { * If 'use_existing_faces' is true, the hull will not output triangles * that are covered by a pre-existing face. * - * All hull vertices, faces, and edges are added to 'geomout'. Any + * All hull vertices, faces, and edges are added to 'geom.out'. Any * input elements that end up inside the hull (i.e. are not used by an * output face) are added to the 'interior_geom' slot. The * 'unused_geom' slot will contain all interior geometry that is @@ -1211,15 +1498,18 @@ static BMOpDefine bmo_slide_vert_def = { */ static BMOpDefine bmo_convex_hull_def = { "convex_hull", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "input"}, {BMO_OP_SLOT_BOOL, "use_existing_faces"}, - - /* Outputs */ - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, - {BMO_OP_SLOT_ELEMENT_BUF, "interior_geom"}, - {BMO_OP_SLOT_ELEMENT_BUF, "unused_geom"}, - {BMO_OP_SLOT_ELEMENT_BUF, "holes_geom"}, - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, + {BMO_OP_SLOT_ELEMENT_BUF, "geom_interior.out"}, + {BMO_OP_SLOT_ELEMENT_BUF, "geom_unused.out"}, + {BMO_OP_SLOT_ELEMENT_BUF, "geom_holes.out"}, + {0}, + }, bmo_convex_hull_exec, 0 }; @@ -1233,17 +1523,19 @@ static BMOpDefine bmo_convex_hull_def = { * the "direction" slot. The edges and faces that cross the plane of * symmetry are split as needed to enforce symmetry. * - * All new vertices, edges, and faces are added to the "geomout" slot. + * All new vertices, edges, and faces are added to the "geom.out" slot. */ static BMOpDefine bmo_symmetrize_def = { "symmetrize", + /* slots_in */ {{BMO_OP_SLOT_ELEMENT_BUF, "input"}, {BMO_OP_SLOT_INT, "direction"}, - - /* Outputs */ - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, - - {0} /* null-terminating sentinel */}, + {0}, + }, + /* slots_out */ + {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, + {0}, + }, bmo_symmetrize_exec, 0 }; diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h index 671cfbbc55e..b87e023e63a 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api.h +++ b/source/blender/bmesh/intern/bmesh_operator_api.h @@ -116,30 +116,45 @@ enum { * for when your defining an operator with BMOpDefine.*/ typedef struct BMOpSlot { + const char *slot_name; /* pointer to BMOpDefine.slot_args */ int slot_type; int len; - int flag; - int index; /* index within slot array */ +// int flag; /* UNUSED */ +// int index; /* index within slot array */ /* UNUSED */ union { int i; float f; void *p; float vec[3]; - void *buf; + void **buf; GHash *ghash; } data; } BMOpSlot; -#define BMO_OP_MAX_SLOTS 16 /* way more than probably needed */ +/* mainly for use outside bmesh internal code */ +#define BMO_SLOT_AS_BOOL(slot) ((slot)->data.i) +#define BMO_SLOT_AS_INT(slot) ((slot)->data.i) +#define BMO_SLOT_AS_FLOAT(slot) ((slot)->data.f) +#define BMO_SLOT_AS_VECTOR(slot) ((slot)->data.vec) +#define BMO_SLOT_AS_MATRIX(slot ) ((float (*)[4])((slot)->data.p)) +#define BMO_SLOT_AS_BUFFER(slot ) ((slot)->data.buf) +#define BMO_SLOT_AS_GHASH(slot ) ((slot)->data.ghash) + +#define BMO_ASSERT_SLOT_IN_OP(slot, op) \ + BLI_assert(((slot >= (op)->slots_in) && (slot < &(op)->slots_in[BMO_OP_MAX_SLOTS])) || \ + ((slot >= (op)->slots_out) && (slot < &(op)->slots_out[BMO_OP_MAX_SLOTS]))) + +/* way more than probably needed, compiler complains if limit hit */ +#define BMO_OP_MAX_SLOTS 16 typedef struct BMOperator { + struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]; + struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]; + void (*exec)(BMesh *bm, struct BMOperator *op); + struct MemArena *arena; int type; - int slot_type; int type_flag; int flag; /* runtime options */ - struct BMOpSlot slot_args[BMO_OP_MAX_SLOTS]; - void (*exec)(BMesh *bm, struct BMOperator *op); - struct MemArena *arena; } BMOperator; enum { @@ -156,8 +171,9 @@ typedef struct BMOSlotType { } BMOSlotType; typedef struct BMOpDefine { - const char *name; - BMOSlotType slot_types[BMO_OP_MAX_SLOTS]; + const char *opname; + BMOSlotType slot_types_in[BMO_OP_MAX_SLOTS]; + BMOSlotType slot_types_out[BMO_OP_MAX_SLOTS]; void (*exec)(BMesh *bm, BMOperator *op); int type_flag; } BMOpDefine; @@ -245,15 +261,22 @@ int BMO_op_initf(BMesh *bm, BMOperator *op, const int flag, const char *fmt, ... int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *fmt, va_list vlist); /* test whether a named slot exists */ -int BMO_slot_exists(BMOperator *op, const char *slot_name); +int BMO_slot_exists(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier); /* get a pointer to a slot. this may be removed layer on from the public API. */ -BMOpSlot *BMO_slot_get(BMOperator *op, const char *slot_name); +BMOpSlot *BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier); /* copies the data of a slot from one operator to another. src and dst are the * source/destination slot codes, respectively. */ -void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, - const char *src, const char *dst); +#define BMO_slot_copy(op_src, slots_src, slot_name_src, \ + op_dst, slots_dst, slot_name_dst) \ + _bmo_slot_copy((op_src)->slots_src, slot_name_src, \ + (op_dst)->slots_dst, slot_name_dst, \ + (op_dst)->arena) + +void _bmo_slot_copy(BMOpSlot slot_args_src[BMO_OP_MAX_SLOTS], const char *slot_name_src, + BMOpSlot slot_args_dst[BMO_OP_MAX_SLOTS], const char *slot_name_dst, + struct MemArena *arena_dst); /* del "context" slot values, used for operator too */ enum { @@ -279,13 +302,13 @@ typedef enum { void BMO_op_flag_enable(BMesh *bm, BMOperator *op, const int op_flag); void BMO_op_flag_disable(BMesh *bm, BMOperator *op, const int op_flag); -void BMO_slot_float_set(BMOperator *op, const char *slot_name, const float f); -float BMO_slot_float_get(BMOperator *op, const char *slot_name); -void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i); -int BMO_slot_int_get(BMOperator *op, const char *slot_name); -void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i); -int BMO_slot_bool_get(BMOperator *op, const char *slot_name); -void *BMO_slot_as_arrayN(BMOperator *op, const char *slot_name, int *len); +void BMO_slot_float_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float f); +float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name); +void BMO_slot_int_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int i); +int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name); +void BMO_slot_bool_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int i); +int BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name); +void *BMO_slot_as_arrayN(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, int *len); /* don't pass in arrays that are supposed to map to elements this way. @@ -293,69 +316,81 @@ void *BMO_slot_as_arrayN(BMOperator *op, const char *slot_name, int *len); * so, e.g. passing in list of floats per element in another slot is bad. * passing in, e.g. pointer to an editmesh for the conversion operator is fine * though. */ -void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p); -void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name); -void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3]); -void BMO_slot_vec_get(BMOperator *op, const char *slot_name, float r_vec[3]); +void BMO_slot_ptr_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, void *p); +void *BMO_slot_ptr_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name); +void BMO_slot_vec_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float vec[3]); +void BMO_slot_vec_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_vec[3]); /* only supports square mats */ /* size must be 3 or 4; this api is meant only for transformation matrices. * note that internally the matrix is stored in 4x4 form, and it's safe to * call whichever BMO_Get_MatXXX function you want. */ -void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, int size); -void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4]); -void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3]); +void BMO_slot_mat_set(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float *mat, int size); +void BMO_slot_mat4_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_mat[4][4]); +void BMO_slot_mat3_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_mat[3][3]); void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *op, const char htype, const short oflag); /* copies the values from another slot to the end of the output slot */ -void BMO_slot_buffer_append(BMOperator *output_op, const char *output_op_slot, - BMOperator *other_op, const char *other_op_slot); +#define BMO_slot_buffer_append(op_src, slots_src, slot_name_src, \ + op_dst, slots_dst, slot_name_dst) \ + _bmo_slot_buffer_append((op_src)->slots_src, slot_name_src, \ + (op_dst)->slots_dst, slot_name_dst, \ + (op_dst)->arena) +void _bmo_slot_buffer_append(BMOpSlot slot_args_dst[BMO_OP_MAX_SLOTS], const char *slot_name_dst, + BMOpSlot slot_args_src[BMO_OP_MAX_SLOTS], const char *slot_name_src, + struct MemArena *arena_dst); /* puts every element of type 'type' (which is a bitmask) with tool * flag 'flag', into a slot. */ -void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag); /* puts every element of type 'type' (which is a bitmask) without tool * flag 'flag', into a slot. */ -void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag); /* tool-flags all elements inside an element slot array with flag flag. */ -void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_flag_enable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag); /* clears tool-flag flag from all elements inside a slot array. */ -void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_flag_disable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag); /* tool-flags all elements inside an element slot array with flag flag. */ -void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_hflag_enable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag, const char do_flush); /* clears tool-flag flag from all elements inside a slot array. */ -void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_hflag_disable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag, const char do_flush); /* puts every element of type 'type' (which is a bitmask) with header * flag 'flag', into a slot. note: ignores hidden elements * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/ void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, - const char *slot_name, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag); /* puts every element of type 'type' (which is a bitmask) without * header flag 'flag', into a slot. note: ignores hidden elements * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/ void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, - const char *slot_name, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag); /* counts number of elements inside a slot array. */ -int BMO_slot_buffer_count(BMesh *bm, BMOperator *op, const char *slot_name); -int BMO_slot_map_count(BMesh *bm, BMOperator *op, const char *slot_name); +int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name); +int BMO_slot_map_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name); -void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, - void *element, void *data, int len); +void BMO_slot_map_insert(BMOperator *op, BMOpSlot *slot, + const void *element, void *data, int len); /* Counts the number of edges with tool flag toolflag around */ @@ -363,13 +398,14 @@ int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag); /* flags all elements in a mapping. note that the mapping must only have * bmesh elements in it.*/ -void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name, - const char hflag, const short oflag); +void BMO_slot_map_to_flag(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], + const char *slot_name, const char hflag, const short oflag); -void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len); +void *BMO_slot_buffer_alloc(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], + const char *slot_name, const int len); -void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, - const char htype); +void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], + const char *slot_name, const char htype); /* this part of the API is used to iterate over element buffer or * mapping slots. @@ -412,10 +448,11 @@ typedef struct BMOIter { char restrictmask; /* bitwise '&' with BMHeader.htype */ } BMOIter; -void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name); +void *BMO_slot_buffer_elem_first(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name); -void *BMO_iter_new(BMOIter *iter, BMesh *bm, BMOperator *op, - const char *slot_name, const char restrictmask); +void *BMO_iter_new(BMOIter *iter, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, + const char restrictmask); void *BMO_iter_step(BMOIter *iter); /* returns a pointer to the key value when iterating over mappings. @@ -428,8 +465,8 @@ void *BMO_iter_map_value_p(BMOIter *iter); /* use this for float mappings */ float BMO_iter_map_value_f(BMOIter *iter); -#define BMO_ITER(ele, iter, bm, op, slot_name, restrict) \ - for (ele = BMO_iter_new(iter, bm, op, slot_name, restrict); ele; ele = BMO_iter_step(iter)) +#define BMO_ITER(ele, iter, slot_args, slot_name, restrict_flag) \ + for (ele = BMO_iter_new(iter, slot_args, slot_name, restrict_flag); ele; ele = BMO_iter_step(iter)) /******************* Inlined Functions********************/ typedef void (*opexec)(BMesh *bm, BMOperator *op); diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h index 16c2b8b0505..b405ecc1841 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h +++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h @@ -69,16 +69,16 @@ BLI_INLINE void _bmo_elem_flag_toggle(BMesh *bm, BMFlagLayer *oflags, const shor oflags[bm->stackdepth - 1].f ^= oflag; } -BLI_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slot_name, +BLI_INLINE void BMO_slot_map_int_insert(BMOperator *op, BMOpSlot *slot, void *element, int val) { - BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(int)); + BMO_slot_map_insert(op, slot, element, &val, sizeof(int)); } -BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slot_name, +BLI_INLINE void BMO_slot_map_float_insert(BMOperator *op, BMOpSlot *slot, void *element, float val) { - BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(float)); + BMO_slot_map_insert(op, slot, element, &val, sizeof(float)); } @@ -87,62 +87,62 @@ BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char * do NOT use these for non-operator-api-allocated memory! instead * use BMO_slot_map_data_get and BMO_slot_map_insert, which copies the data. */ -BLI_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slot_name, - void *element, void *val) +BLI_INLINE void BMO_slot_map_ptr_insert(BMOperator *op, BMOpSlot *slot, + const void *element, void *val) { - BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(void *)); + BMO_slot_map_insert(op, slot, element, &val, sizeof(void *)); } -BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element) +BLI_INLINE int BMO_slot_map_contains(BMOpSlot *slot, const void *element) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* sanity check */ - if (!slot->data.ghash) return 0; + if (UNLIKELY(slot->data.ghash == NULL)) { + return 0; + } return BLI_ghash_haskey(slot->data.ghash, element); } -BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, - void *element) +BLI_INLINE void *BMO_slot_map_data_get(BMOpSlot *slot, const void *element) { BMOElemMapping *mapping; - BMOpSlot *slot = BMO_slot_get(op, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* sanity check */ - if (!slot->data.ghash) return NULL; + if (UNLIKELY(slot->data.ghash == NULL)) { + return NULL; + } mapping = (BMOElemMapping *)BLI_ghash_lookup(slot->data.ghash, element); - if (!mapping) return NULL; + if (!mapping) { + return NULL; + } return mapping + 1; } -BLI_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slot_name, - void *element) +BLI_INLINE float BMO_slot_map_float_get(BMOpSlot *slot, const void *element) { - float *val = (float *) BMO_slot_map_data_get(bm, op, slot_name, element); + float *val = (float *) BMO_slot_map_data_get(slot, element); if (val) return *val; return 0.0f; } -BLI_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slot_name, - void *element) +BLI_INLINE int BMO_slot_map_int_get(BMOpSlot *slot, const void *element) { - int *val = (int *) BMO_slot_map_data_get(bm, op, slot_name, element); + int *val = (int *) BMO_slot_map_data_get(slot, element); if (val) return *val; return 0; } -BLI_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slot_name, - void *element) +BLI_INLINE void *BMO_slot_map_ptr_get(BMOpSlot *slot, const void *element) { - void **val = (void **) BMO_slot_map_data_get(bm, op, slot_name, element); + void **val = (void **) BMO_slot_map_data_get(slot, element); if (val) return *val; return NULL; diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 8f38e1c9ba2..157837a13c0 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -45,8 +45,8 @@ static void bmo_flag_layer_alloc(BMesh *bm); static void bmo_flag_layer_free(BMesh *bm); static void bmo_flag_layer_clear(BMesh *bm); -static int bmo_name_to_slotcode(BMOpDefine *def, const char *name); -static int bmo_name_to_slotcode_check(BMOpDefine *def, const char *name); +static int bmo_name_to_slotcode(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier); +static int bmo_name_to_slotcode_check(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier); static int bmo_opname_to_opcode(const char *opname); static const char *bmo_error_messages[] = { @@ -80,7 +80,7 @@ const int BMO_OPSLOT_TYPEINFO[BMO_OP_SLOT_TOTAL_TYPES] = { }; /* Dummy slot so there is something to return when slot name lookup fails */ -static BMOpSlot BMOpEmptySlot = {0}; +// static BMOpSlot BMOpEmptySlot = {0}; void BMO_op_flag_enable(BMesh *UNUSED(bm), BMOperator *op, const int op_flag) { @@ -125,6 +125,18 @@ void BMO_pop(BMesh *bm) bm->stackdepth--; } + +/* use for both slot_types_in and slot_types_out */ +static void bmo_op_slots_init(BMOSlotType *slot_types, BMOpSlot *slot_args) +{ + unsigned int i; + for (i = 0; slot_types[i].type; i++) { + slot_args[i].slot_name = slot_types[i].name; + slot_args[i].slot_type = slot_types[i].type; + // slot_args[i].index = i; // UNUSED + } +} + /** * \brief BMESH OPSTACK INIT OP * @@ -132,7 +144,7 @@ void BMO_pop(BMesh *bm) */ void BMO_op_init(BMesh *bm, BMOperator *op, const int flag, const char *opname) { - int i, opcode = bmo_opname_to_opcode(opname); + int opcode = bmo_opname_to_opcode(opname); #ifdef DEBUG BM_ELEM_INDEX_VALIDATE(bm, "pre bmo", opname); @@ -150,10 +162,8 @@ void BMO_op_init(BMesh *bm, BMOperator *op, const int flag, const char *opname) op->flag = flag; /* initialize the operator slot types */ - for (i = 0; opdefines[opcode]->slot_types[i].type; i++) { - op->slot_args[i].slot_type = opdefines[opcode]->slot_types[i].type; - op->slot_args[i].index = i; - } + bmo_op_slots_init(opdefines[opcode]->slot_types_in, op->slots_in); + bmo_op_slots_init(opdefines[opcode]->slot_types_out, op->slots_out); /* callback */ op->exec = opdefines[opcode]->exec; @@ -189,6 +199,20 @@ void BMO_op_exec(BMesh *bm, BMOperator *op) BMO_pop(bm); } +static void bmo_op_slots_free(BMOSlotType *slot_types, BMOpSlot *slot_args) +{ + BMOpSlot *slot; + unsigned int i; + for (i = 0; slot_types[i].type; i++) { + slot = &slot_args[i]; + if (slot->slot_type == BMO_OP_SLOT_MAPPING) { + if (slot->data.ghash) { + BLI_ghash_free(slot->data.ghash, NULL, NULL); + } + } + } +} + /** * \brief BMESH OPSTACK FINISH OP * @@ -196,21 +220,13 @@ void BMO_op_exec(BMesh *bm, BMOperator *op) */ void BMO_op_finish(BMesh *bm, BMOperator *op) { - BMOpSlot *slot; - int i; - - for (i = 0; opdefines[op->type]->slot_types[i].type; i++) { - slot = &op->slot_args[i]; - if (slot->slot_type == BMO_OP_SLOT_MAPPING) { - if (slot->data.ghash) - BLI_ghash_free(slot->data.ghash, NULL, NULL); - } - } + bmo_op_slots_free(opdefines[op->type]->slot_types_in, op->slots_in); + bmo_op_slots_free(opdefines[op->type]->slot_types_out, op->slots_out); BLI_memarena_free(op->arena); #ifdef DEBUG - BM_ELEM_INDEX_VALIDATE(bm, "post bmo", opdefines[op->type]->name); + BM_ELEM_INDEX_VALIDATE(bm, "post bmo", opdefines[op->type]->opname); #else (void)bm; #endif @@ -221,9 +237,9 @@ void BMO_op_finish(BMesh *bm, BMOperator *op) * * \return Success if the slot if found. */ -int BMO_slot_exists(BMOperator *op, const char *slot_name) +int BMO_slot_exists(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier) { - int slot_code = bmo_name_to_slotcode(opdefines[op->type], slot_name); + int slot_code = bmo_name_to_slotcode(slot_args, identifier); return (slot_code >= 0); } @@ -232,73 +248,78 @@ int BMO_slot_exists(BMOperator *op, const char *slot_name) * * Returns a pointer to the slot of type 'slot_code' */ -BMOpSlot *BMO_slot_get(BMOperator *op, const char *slot_name) +BMOpSlot *BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier) { - int slot_code = bmo_name_to_slotcode_check(opdefines[op->type], slot_name); + int slot_code = bmo_name_to_slotcode_check(slot_args, identifier); - if (slot_code < 0) { - return &BMOpEmptySlot; + if (UNLIKELY(slot_code < 0)) { + //return &BMOpEmptySlot; + BLI_assert(0); + NULL; /* better crash */ } - return &(op->slot_args[slot_code]); + return &slot_args[slot_code]; } /** * \brief BMESH OPSTACK COPY SLOT * + * define used. * Copies data from one slot to another. */ -void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, const char *src, const char *dst) +void _bmo_slot_copy(BMOpSlot slot_args_src[BMO_OP_MAX_SLOTS], const char *slot_name_src, + BMOpSlot slot_args_dst[BMO_OP_MAX_SLOTS], const char *slot_name_dst, + struct MemArena *arena_dst) { - BMOpSlot *source_slot = BMO_slot_get(source_op, src); - BMOpSlot *dest_slot = BMO_slot_get(dest_op, dst); + BMOpSlot *slot_src = BMO_slot_get(slot_args_src, slot_name_src); + BMOpSlot *slot_dst = BMO_slot_get(slot_args_dst, slot_name_dst); - if (source_slot == dest_slot) + if (slot_src == slot_dst) return; - if (source_slot->slot_type != dest_slot->slot_type) { - /* possibly assert here? */ + BLI_assert(slot_src->slot_type == slot_dst->slot_type); + if (slot_src->slot_type != slot_dst->slot_type) { return; } - if (dest_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF) { + if (slot_dst->slot_type == BMO_OP_SLOT_ELEMENT_BUF) { /* do buffer copy */ - dest_slot->data.buf = NULL; - dest_slot->len = source_slot->len; - if (dest_slot->len) { - const int slot_alloc_size = BMO_OPSLOT_TYPEINFO[dest_slot->slot_type] * dest_slot->len; - dest_slot->data.buf = BLI_memarena_alloc(dest_op->arena, slot_alloc_size); - memcpy(dest_slot->data.buf, source_slot->data.buf, slot_alloc_size); + slot_dst->data.buf = NULL; + slot_dst->len = slot_src->len; + if (slot_dst->len) { + const int slot_alloc_size = BMO_OPSLOT_TYPEINFO[slot_dst->slot_type] * slot_dst->len; + slot_dst->data.buf = BLI_memarena_alloc(arena_dst, slot_alloc_size); + memcpy(slot_dst->data.buf, slot_src->data.buf, slot_alloc_size); } } - else if (dest_slot->slot_type == BMO_OP_SLOT_MAPPING) { + else if (slot_dst->slot_type == BMO_OP_SLOT_MAPPING) { GHashIterator it; BMOElemMapping *srcmap, *dstmap; /* sanity check */ - if (!source_slot->data.ghash) { + if (!slot_src->data.ghash) { return; } - if (!dest_slot->data.ghash) { - dest_slot->data.ghash = BLI_ghash_ptr_new("bmesh operator 2"); + if (!slot_dst->data.ghash) { + slot_dst->data.ghash = BLI_ghash_ptr_new("bmesh operator 2"); } - BLI_ghashIterator_init(&it, source_slot->data.ghash); - for ( ; (srcmap = BLI_ghashIterator_getValue(&it)); - BLI_ghashIterator_step(&it)) + for (BLI_ghashIterator_init(&it, slot_src->data.ghash); + (srcmap = BLI_ghashIterator_getValue(&it)); + BLI_ghashIterator_step(&it)) { - dstmap = BLI_memarena_alloc(dest_op->arena, sizeof(*dstmap) + srcmap->len); + dstmap = BLI_memarena_alloc(arena_dst, sizeof(*dstmap) + srcmap->len); dstmap->element = srcmap->element; dstmap->len = srcmap->len; memcpy(dstmap + 1, srcmap + 1, srcmap->len); - BLI_ghash_insert(dest_slot->data.ghash, dstmap->element, dstmap); + BLI_ghash_insert(slot_dst->data.ghash, dstmap->element, dstmap); } } else { - dest_slot->data = source_slot->data; + slot_dst->data = slot_src->data; } } @@ -308,9 +329,9 @@ void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, const char *src, * Sets the value of a slot depending on it's type */ -void BMO_slot_float_set(BMOperator *op, const char *slot_name, const float f) +void BMO_slot_float_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float f) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT); if (!(slot->slot_type == BMO_OP_SLOT_FLT)) return; @@ -318,9 +339,9 @@ void BMO_slot_float_set(BMOperator *op, const char *slot_name, const float f) slot->data.f = f; } -void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i) +void BMO_slot_int_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int i) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_INT); if (!(slot->slot_type == BMO_OP_SLOT_INT)) return; @@ -328,9 +349,9 @@ void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i) slot->data.i = i; } -void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i) +void BMO_slot_bool_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int i) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL); if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) return; @@ -339,9 +360,9 @@ void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i) } /* only supports square mats */ -void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, int size) +void BMO_slot_mat_set(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float *mat, int size) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; @@ -362,39 +383,39 @@ void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, i } } -void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4]) +void BMO_slot_mat4_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_mat[4][4]) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; if (slot->data.p) { - copy_m4_m4(r_mat, (float (*)[4])slot->data.p); + copy_m4_m4(r_mat, BMO_SLOT_AS_MATRIX(slot)); } else { unit_m4(r_mat); } } -void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3]) +void BMO_slot_mat3_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_mat[3][3]) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; if (slot->data.p) { - copy_m3_m4(r_mat, slot->data.p); + copy_m3_m4(r_mat, BMO_SLOT_AS_MATRIX(slot)); } else { unit_m3(r_mat); } } -void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p) +void BMO_slot_ptr_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, void *p) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR); if (!(slot->slot_type == BMO_OP_SLOT_PTR)) return; @@ -402,9 +423,9 @@ void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p) slot->data.p = p; } -void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3]) +void BMO_slot_vec_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float vec[3]) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC); if (!(slot->slot_type == BMO_OP_SLOT_VEC)) return; @@ -413,9 +434,9 @@ void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3]) } -float BMO_slot_float_get(BMOperator *op, const char *slot_name) +float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT); if (!(slot->slot_type == BMO_OP_SLOT_FLT)) return 0.0f; @@ -423,9 +444,9 @@ float BMO_slot_float_get(BMOperator *op, const char *slot_name) return slot->data.f; } -int BMO_slot_int_get(BMOperator *op, const char *slot_name) +int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_INT); if (!(slot->slot_type == BMO_OP_SLOT_INT)) return 0; @@ -433,9 +454,9 @@ int BMO_slot_int_get(BMOperator *op, const char *slot_name) return slot->data.i; } -int BMO_slot_bool_get(BMOperator *op, const char *slot_name) +int BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL); if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) return 0; @@ -444,23 +465,23 @@ int BMO_slot_bool_get(BMOperator *op, const char *slot_name) } /* if you want a copy of the elem buffer */ -void *BMO_slot_as_arrayN(BMOperator *op, const char *slot_name, int *len) +void *BMO_slot_as_arrayN(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, int *len) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); void *ret; /* could add support for mapping type */ BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); - ret = MEM_mallocN(sizeof(void *) * slot->len, __func__); - memcpy(ret, slot->data.buf, sizeof(void *) * slot->len); + ret = MEM_mallocN(sizeof(void **) * slot->len, __func__); + memcpy(ret, slot->data.buf, sizeof(void **) * slot->len); *len = slot->len; return ret; } -void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name) +void *BMO_slot_ptr_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR); if (!(slot->slot_type == BMO_OP_SLOT_PTR)) return NULL; @@ -468,9 +489,9 @@ void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name) return slot->data.p; } -void BMO_slot_vec_get(BMOperator *op, const char *slot_name, float r_vec[3]) +void BMO_slot_vec_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_vec[3]) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC); if (!(slot->slot_type == BMO_OP_SLOT_VEC)) return; @@ -546,9 +567,9 @@ void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *UNUSED(op), const char hty } } -int BMO_slot_buffer_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name) +int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); /* check if its actually a buffer */ @@ -558,9 +579,9 @@ int BMO_slot_buffer_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_na return slot->len; } -int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name) +int BMO_slot_map_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* check if its actually a buffer */ @@ -573,12 +594,12 @@ int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name) /* inserts a key/value mapping into a mapping slot. note that it copies the * value, it doesn't store a reference to it. */ -void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, - void *element, void *data, int len) +void BMO_slot_map_insert(BMOperator *op, BMOpSlot *slot, + const void *element, void *data, int len) { BMOElemMapping *mapping; - BMOpSlot *slot = BMO_slot_get(op, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); + BMO_ASSERT_SLOT_IN_OP(slot, op); mapping = (BMOElemMapping *) BLI_memarena_alloc(op->arena, sizeof(*mapping) + len); @@ -590,7 +611,7 @@ void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slot_nam slot->data.ghash = BLI_ghash_ptr_new("bmesh slot map hash"); } - BLI_ghash_insert(slot->data.ghash, element, mapping); + BLI_ghash_insert(slot->data.ghash, (void *)element, mapping); } #if 0 @@ -636,11 +657,11 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slot_code, int totadd) } #endif -void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_map_to_flag(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag) { GHashIterator it; - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BMElemF *ele_f; BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); @@ -656,18 +677,22 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name, } } -void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len) +void *BMO_slot_buffer_alloc(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int len) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); - BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); /* check if its actually a buffer */ if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) return NULL; slot->len = len; - if (len) + if (len) { slot->data.buf = BLI_memarena_alloc(op->arena, BMO_OPSLOT_TYPEINFO[slot->slot_type] * len); + } + else { + slot->data.buf = NULL; + } + return slot->data.buf; } @@ -676,9 +701,10 @@ void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len * * Copies all elements of a certain type into an operator slot. */ -void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, const char htype) +void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], + const char *slot_name, const char htype) { - BMOpSlot *output = BMO_slot_get(op, slot_name); + BMOpSlot *output = BMO_slot_get(slot_args, slot_name); int totelement = 0, i = 0; if (htype & BM_VERT) totelement += bm->totvert; @@ -689,27 +715,27 @@ void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, BMIter iter; BMHeader *ele; - BMO_slot_buffer_alloc(op, slot_name, totelement); + BMO_slot_buffer_alloc(op, slot_args, slot_name, totelement); /* TODO - collapse these loops into one */ if (htype & BM_VERT) { BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { - ((BMHeader **)output->data.p)[i] = ele; + output->data.buf[i] = ele; i++; } } if (htype & BM_EDGE) { BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { - ((BMHeader **)output->data.p)[i] = ele; + output->data.buf[i] = ele; i++; } } if (htype & BM_FACE) { BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) { - ((BMHeader **)output->data.p)[i] = ele; + output->data.buf[i] = ele; i++; } } @@ -722,11 +748,11 @@ void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, * Copies elements of a certain type, which have a certain header flag * enabled/disabled into a slot for an operator. */ -static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *slot_name, +static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag, const short test_for_enabled) { - BMOpSlot *output = BMO_slot_get(op, slot_name); + BMOpSlot *output = BMO_slot_get(slot_args, slot_name); int totelement = 0, i = 0; const int respecthide = (op->flag & BMO_FLAG_RESPECT_HIDE) != 0; @@ -741,7 +767,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl BMIter iter; BMElem *ele; - BMO_slot_buffer_alloc(op, slot_name, totelement); + BMO_slot_buffer_alloc(op, slot_args, slot_name, totelement); /* TODO - collapse these loops into one */ @@ -750,7 +776,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl if ((!respecthide || !BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) && BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) { - ((BMElem **)output->data.p)[i] = ele; + output->data.buf[i] = ele; i++; } } @@ -761,7 +787,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl if ((!respecthide || !BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) && BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) { - ((BMElem **)output->data.p)[i] = ele; + output->data.buf[i] = ele; i++; } } @@ -772,7 +798,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl if ((!respecthide || !BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) && BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) { - ((BMElem **)output->data.p)[i] = ele; + output->data.buf[i] = ele; i++; } } @@ -783,46 +809,51 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl } } -void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag) { - bmo_slot_buffer_from_hflag(bm, op, slot_name, htype, hflag, TRUE); + bmo_slot_buffer_from_hflag(bm, op, slot_args, slot_name, htype, hflag, TRUE); } -void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag) { - bmo_slot_buffer_from_hflag(bm, op, slot_name, htype, hflag, FALSE); + bmo_slot_buffer_from_hflag(bm, op, slot_args, slot_name, htype, hflag, FALSE); } /** * Copies the values from another slot to the end of the output slot. */ -void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name, - BMOperator *other_op, const char *other_slot_name) +void _bmo_slot_buffer_append(BMOpSlot slot_args_dst[BMO_OP_MAX_SLOTS], const char *slot_name_dst, + BMOpSlot slot_args_src[BMO_OP_MAX_SLOTS], const char *slot_name_src, + struct MemArena *arena_dst) { - BMOpSlot *output_slot = BMO_slot_get(output_op, output_slot_name); - BMOpSlot *other_slot = BMO_slot_get(other_op, other_slot_name); + BMOpSlot *slot_dst = BMO_slot_get(slot_args_dst, slot_name_dst); + BMOpSlot *slot_src = BMO_slot_get(slot_args_src, slot_name_src); - BLI_assert(output_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF && - other_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot_dst->slot_type == BMO_OP_SLOT_ELEMENT_BUF && + slot_src->slot_type == BMO_OP_SLOT_ELEMENT_BUF); - if (output_slot->len == 0) { + if (slot_dst->len == 0) { /* output slot is empty, copy rather than append */ - BMO_slot_copy(other_op, output_op, other_slot_name, output_slot_name); + _bmo_slot_copy(slot_args_src, slot_name_src, + slot_args_dst, slot_name_dst, + arena_dst); } - else if (other_slot->len != 0) { - int elem_size = BMO_OPSLOT_TYPEINFO[output_slot->slot_type]; - int alloc_size = elem_size * (output_slot->len + other_slot->len); + else if (slot_src->len != 0) { + int elem_size = BMO_OPSLOT_TYPEINFO[slot_dst->slot_type]; + int alloc_size = elem_size * (slot_dst->len + slot_src->len); /* allocate new buffer */ - void *buf = BLI_memarena_alloc(output_op->arena, alloc_size); + void *buf = BLI_memarena_alloc(arena_dst, alloc_size); /* copy slot data */ - memcpy(buf, output_slot->data.buf, elem_size * output_slot->len); - memcpy(((char *)buf) + elem_size * output_slot->len, other_slot->data.buf, elem_size * other_slot->len); + memcpy(buf, slot_dst->data.buf, elem_size * slot_dst->len); + memcpy(((char *)buf) + elem_size * slot_dst->len, slot_src->data.buf, elem_size * slot_src->len); - output_slot->data.buf = buf; - output_slot->len += other_slot->len; + slot_dst->data.buf = buf; + slot_dst->len += slot_src->len; } } @@ -832,13 +863,15 @@ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name, * Copies elements of a certain type, which have a certain flag set * into an output slot for an operator. */ -static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slot_name, +static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag, const short test_for_enabled) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); int totelement, i = 0; + BLI_assert(op->slots_in == slot_args || op->slots_out == slot_args); BLI_assert(ELEM(TRUE, FALSE, test_for_enabled)); if (test_for_enabled) @@ -853,9 +886,9 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo BMHeader *ele; BMHeader **ele_array; - BMO_slot_buffer_alloc(op, slot_name, totelement); + BMO_slot_buffer_alloc(op, slot_args, slot_name, totelement); - ele_array = (BMHeader **)slot->data.p; + ele_array = (BMHeader **)slot->data.buf; /* TODO - collapse these loops into one */ @@ -891,16 +924,18 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo } } -void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag) { - bmo_slot_buffer_from_flag(bm, op, slot_name, htype, oflag, TRUE); + bmo_slot_buffer_from_flag(bm, op, slot_args, slot_name, htype, oflag, TRUE); } -void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag) { - bmo_slot_buffer_from_flag(bm, op, slot_name, htype, oflag, FALSE); + bmo_slot_buffer_from_flag(bm, op, slot_args, slot_name, htype, oflag, FALSE); } /** @@ -909,11 +944,12 @@ void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *s * Header Flags elements in a slots buffer, automatically * using the selection API where appropriate. */ -void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_hflag_enable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag, const char do_flush) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); - BMElem **data = slot->data.p; + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); + BMElem **data = (BMElem **)slot->data.buf; int i; const char do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT)); const char do_flush_hide = (do_flush && (hflag & BM_ELEM_HIDDEN)); @@ -942,11 +978,12 @@ void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slot_na * Removes flags from elements in a slots buffer, automatically * using the selection API where appropriate. */ -void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_hflag_disable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const char hflag, const char do_flush) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); - BMElem **data = slot->data.p; + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); + BMElem **data = (BMElem **)slot->data.buf; int i; const char do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT)); const char do_flush_hide = (do_flush && (hflag & BM_ELEM_HIDDEN)); @@ -993,10 +1030,11 @@ int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag) * * Flags elements in a slots buffer */ -void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_flag_enable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BMHeader **data = slot->data.p; int i; @@ -1015,11 +1053,12 @@ void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slot_nam * * Removes flags from elements in a slots buffer */ -void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slot_name, +void BMO_slot_buffer_flag_disable(BMesh *bm, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char htype, const short oflag) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); - BMHeader **data = slot->data.p; + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); + BMHeader **data = (BMHeader **)slot->data.buf; int i; BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); @@ -1171,14 +1210,14 @@ static void bmo_flag_layer_clear(BMesh *bm) bm->elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE); } -void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name) +void *BMO_slot_buffer_elem_first(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) return NULL; - return slot->data.buf ? *(void **)slot->data.buf : NULL; + return slot->data.buf ? *slot->data.buf : NULL; } /** @@ -1187,10 +1226,11 @@ void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name) * \param restrictmask restricts the iteration to certain element types * (e.g. combination of BM_VERT, BM_EDGE, BM_FACE), if iterating * over an element buffer (not a mapping). */ -void *BMO_iter_new(BMOIter *iter, BMesh *UNUSED(bm), BMOperator *op, - const char *slot_name, const char restrictmask) +void *BMO_iter_new(BMOIter *iter, + BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, + const char restrictmask) { - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); memset(iter, 0, sizeof(BMOIter)); @@ -1219,13 +1259,13 @@ void *BMO_iter_step(BMOIter *iter) return NULL; } - h = ((void **)iter->slot->data.buf)[iter->cur++]; + h = iter->slot->data.buf[iter->cur++]; while (!(iter->restrictmask & h->htype)) { if (iter->cur >= iter->slot->len) { return NULL; } - h = ((void **)iter->slot->data.buf)[iter->cur++]; + h = iter->slot->data.buf[iter->cur++]; } return h; @@ -1324,24 +1364,26 @@ int BMO_error_pop(BMesh *bm, const char **msg, BMOperator **op) #define NEXT_CHAR(fmt) ((fmt)[0] != 0 ? (fmt)[1] : 0) -static int bmo_name_to_slotcode(BMOpDefine *def, const char *name) +static int bmo_name_to_slotcode(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier) { - int i; + int i = 0; - for (i = 0; def->slot_types[i].type; i++) { - if (!strncmp(name, def->slot_types[i].name, MAX_SLOTNAME)) { + while (slot_args->slot_name) { + if (strncmp(identifier, slot_args->slot_name, MAX_SLOTNAME) == 0) { return i; } + slot_args++; + i++; } return -1; } -static int bmo_name_to_slotcode_check(BMOpDefine *def, const char *name) +static int bmo_name_to_slotcode_check(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier) { - int i = bmo_name_to_slotcode(def, name); + int i = bmo_name_to_slotcode(slot_args, identifier); if (i < 0) { - fprintf(stderr, "%s: ! could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, name); + fprintf(stderr, "%s: ! could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, identifier); } return i; @@ -1352,12 +1394,12 @@ static int bmo_opname_to_opcode(const char *opname) int i; for (i = 0; i < bmesh_total_ops; i++) { - if (!strcmp(opname, opdefines[i]->name)) { + if (!strcmp(opname, opdefines[i]->opname)) { return i; } } - fprintf(stderr, "%s: ! could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, opname); + fprintf(stderr, "%s: could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, opname); return -1; } @@ -1367,6 +1409,8 @@ static int bmo_opname_to_opcode(const char *opname) * i - int * b - boolean (same as int but 1/0 only) * f - float + * s - slot_in + * S - slot_out * hv - header flagged verts (hflag) * he - header flagged edges (hflag) * hf - header flagged faces (hflag) @@ -1380,7 +1424,7 @@ static int bmo_opname_to_opcode(const char *opname) int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, va_list vlist) { - BMOpDefine *def; +// BMOpDefine *def; char *opname, *ofmt, *fmt; char slot_name[64] = {0}; int i /*, n = strlen(fmt) */, stop /*, slot_code = -1 */, type, state; @@ -1419,7 +1463,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v } BMO_op_init(bm, op, flag, opname); - def = opdefines[i]; +// def = opdefines[i]; i = 0; state = 1; /* 0: not inside slot_code name, 1: inside slot_code name */ @@ -1442,7 +1486,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v fmt[i] = 0; - if (bmo_name_to_slotcode_check(def, fmt) < 0) { + if (bmo_name_to_slotcode_check(op->slots_in, fmt) < 0) { GOTO_ERROR("name to slot code check failed"); } @@ -1468,47 +1512,57 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v else if (c == '4') size = 4; else GOTO_ERROR("matrix size was not 3 or 4"); - BMO_slot_mat_set(op, slot_name, va_arg(vlist, void *), size); + BMO_slot_mat_set(op, op->slots_in, slot_name, va_arg(vlist, void *), size); state = 1; break; } case 'v': { - BMO_slot_vec_set(op, slot_name, va_arg(vlist, float *)); + BMO_slot_vec_set(op->slots_in, slot_name, va_arg(vlist, float *)); state = 1; break; } case 'e': { BMHeader *ele = va_arg(vlist, void *); - BMOpSlot *slot = BMO_slot_get(op, slot_name); + BMOpSlot *slot = BMO_slot_get(op->slots_in, slot_name); slot->data.buf = BLI_memarena_alloc(op->arena, sizeof(void *) * 4); slot->len = 1; - *((void **)slot->data.buf) = ele; + *slot->data.buf = ele; state = 1; break; } case 's': + case 'S': { - BMOperator *op2 = va_arg(vlist, void *); - const char *slot_name2 = va_arg(vlist, char *); + BMOperator *op_other = va_arg(vlist, void *); + const char *slot_name_other = va_arg(vlist, char *); - BMO_slot_copy(op2, op, slot_name2, slot_name); + if (*fmt == 's') { + BLI_assert(bmo_name_to_slotcode_check(op_other->slots_in, slot_name_other) != -1); + BMO_slot_copy(op_other, slots_in, slot_name_other, + op, slots_in, slot_name); + } + else { + BLI_assert(bmo_name_to_slotcode_check(op_other->slots_out, slot_name_other) != -1); + BMO_slot_copy(op_other, slots_out, slot_name_other, + op, slots_in, slot_name); + } state = 1; break; } case 'i': - BMO_slot_int_set(op, slot_name, va_arg(vlist, int)); + BMO_slot_int_set(op->slots_in, slot_name, va_arg(vlist, int)); state = 1; break; case 'b': - BMO_slot_bool_set(op, slot_name, va_arg(vlist, int)); + BMO_slot_bool_set(op->slots_in, slot_name, va_arg(vlist, int)); state = 1; break; case 'p': - BMO_slot_ptr_set(op, slot_name, va_arg(vlist, void *)); + BMO_slot_ptr_set(op->slots_in, slot_name, va_arg(vlist, void *)); state = 1; break; case 'f': @@ -1519,7 +1573,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v type = *fmt; if (NEXT_CHAR(fmt) == ' ' || NEXT_CHAR(fmt) == '\0') { - BMO_slot_float_set(op, slot_name, va_arg(vlist, double)); + BMO_slot_float_set(op->slots_in, slot_name, va_arg(vlist, double)); } else { htype = 0; @@ -1541,19 +1595,19 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v } if (type == 'h') { - BMO_slot_buffer_from_enabled_hflag(bm, op, slot_name, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_in, slot_name, htype, va_arg(vlist, int)); } else if (type == 'H') { - BMO_slot_buffer_from_disabled_hflag(bm, op, slot_name, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_disabled_hflag(bm, op, op->slots_in, slot_name, htype, va_arg(vlist, int)); } else if (type == 'a') { - BMO_slot_buffer_from_all(bm, op, slot_name, htype); + BMO_slot_buffer_from_all(bm, op, op->slots_in, slot_name, htype); } else if (type == 'f') { - BMO_slot_buffer_from_enabled_flag(bm, op, slot_name, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_in, slot_name, htype, va_arg(vlist, int)); } else if (type == 'F') { - BMO_slot_buffer_from_disabled_flag(bm, op, slot_name, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_disabled_flag(bm, op, op->slots_in, slot_name, htype, va_arg(vlist, int)); } } diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h index 79b8c450fd9..1c62a038f34 100644 --- a/source/blender/bmesh/intern/bmesh_operators.h +++ b/source/blender/bmesh/intern/bmesh_operators.h @@ -90,11 +90,6 @@ enum { OPUVC_AXIS_Y }; -enum { - DIRECTION_CW = 1, - DIRECTION_CCW -}; - /* vertex path selection values */ enum { VPATH_SELECT_EDGE_LENGTH = 0, diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 35213c83097..2e0471863d4 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -677,6 +677,7 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int use_beauty, floa BMLoop *l_first; const float cos_threshold = 0.9f; + const float bias = 1.0f + 1e-6f; if (f->len == 4) { BMLoop *larr[4]; @@ -691,7 +692,7 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int use_beauty, floa /* pick 0/1 based on best lenth */ /* XXX Can't only rely on such test, also must check we do not get (too much) degenerated triangles!!! */ i = (((len_squared_v3v3(larr[0]->v->co, larr[2]->v->co) > - len_squared_v3v3(larr[1]->v->co, larr[3]->v->co))) != use_beauty); + len_squared_v3v3(larr[1]->v->co, larr[3]->v->co) * bias)) != use_beauty); i4 = (i + 3) % 4; /* Check produced tris aren’t too flat/narrow... * Probably not the best test, but is quite efficient and should at least avoid null-area faces! */ diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h index a5eb7e63505..850e81ba3ac 100644 --- a/source/blender/bmesh/intern/bmesh_private.h +++ b/source/blender/bmesh/intern/bmesh_private.h @@ -56,11 +56,16 @@ int bmesh_elem_check(void *element, const char htype); int bmesh_radial_length(BMLoop *l); int bmesh_disk_count(BMVert *v); -/* NOTE: ensure different parts of the API do not conflict +/** + * Internal BMHeader.api_flag + * \note Ensure different parts of the API do not conflict * on using these internal flags!*/ -#define _FLAG_JF 1 /* join faces */ -#define _FLAG_MF 2 /* make face */ -#define _FLAG_MV 2 /* make face, vertex */ +enum { + _FLAG_JF = (1 << 0), /* join faces */ + _FLAG_MF = (1 << 1), /* make face */ + _FLAG_MV = (1 << 1), /* make face, vertex */ + _FLAG_OVERLAP = (1 << 2) /* general overlap flag */ +}; #define BM_ELEM_API_FLAG_ENABLE(element, f) ((element)->head.api_flag |= (f)) #define BM_ELEM_API_FLAG_DISABLE(element, f) ((element)->head.api_flag &= ~(f)) diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index cae9b5b3b83..ec2e90591cc 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -39,8 +39,6 @@ #include "bmesh.h" #include "intern/bmesh_private.h" -#define BM_OVERLAP (1 << 13) - /** * Returns whether or not a given vertex is * is part of a given edge. @@ -240,7 +238,7 @@ int BM_vert_in_face(BMFace *f, BMVert *v) * Compares the number of vertices in an array * that appear in a given face */ -int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len) +int BM_verts_in_face(BMFace *f, BMVert **varr, int len) { BMLoop *l_iter, *l_first; @@ -251,7 +249,7 @@ int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len) int i, count = 0; for (i = 0; i < len; i++) { - BMO_elem_flag_enable(bm, varr[i], BM_OVERLAP); + BM_ELEM_API_FLAG_ENABLE(varr[i], _FLAG_OVERLAP); } #ifdef USE_BMESH_HOLES @@ -266,14 +264,16 @@ int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len) #endif do { - if (BMO_elem_flag_test(bm, l_iter->v, BM_OVERLAP)) { + if (BM_ELEM_API_FLAG_TEST(l_iter->v, _FLAG_OVERLAP)) { count++; } } while ((l_iter = l_iter->next) != l_first); } - for (i = 0; i < len; i++) BMO_elem_flag_disable(bm, varr[i], BM_OVERLAP); + for (i = 0; i < len; i++) { + BM_ELEM_API_FLAG_DISABLE(varr[i], _FLAG_OVERLAP); + } return count; } @@ -1217,7 +1217,7 @@ BMEdge *BM_edge_find_double(BMEdge *e) * \returns TRUE for overlap * */ -int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_overlapface) +int BM_face_exists_overlap(BMVert **varr, int len, BMFace **r_overlapface) { BMIter viter; BMFace *f; @@ -1225,7 +1225,7 @@ int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_overlap for (i = 0; i < len; i++) { BM_ITER_ELEM (f, &viter, varr[i], BM_FACES_OF_VERT) { - amount = BM_verts_in_face(bm, f, varr, len); + amount = BM_verts_in_face(f, varr, len); if (amount >= len) { if (r_overlapface) { *r_overlapface = f; @@ -1247,7 +1247,7 @@ int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_overlap * there is a face with exactly those vertices * (and only those vertices). */ -int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface) +int BM_face_exists(BMVert **varr, int len, BMFace **r_existface) { BMIter viter; BMFace *f; @@ -1255,7 +1255,7 @@ int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface) for (i = 0; i < len; i++) { BM_ITER_ELEM (f, &viter, varr[i], BM_FACES_OF_VERT) { - amount = BM_verts_in_face(bm, f, varr, len); + amount = BM_verts_in_face(f, varr, len); if (amount == len && amount == f->len) { if (r_existface) { *r_existface = f; diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index 7bb456df8e8..d97faebf021 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -28,7 +28,7 @@ */ int BM_vert_in_face(BMFace *f, BMVert *v); -int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len); +int BM_verts_in_face(BMFace *f, BMVert **varr, int len); int BM_edge_in_face(BMFace *f, BMEdge *e); int BM_edge_in_loop(BMEdge *e, BMLoop *l); @@ -77,9 +77,9 @@ BMLoop *BM_face_find_longest_loop(BMFace *f); BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2); BMEdge *BM_edge_find_double(BMEdge *e); -int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_existface); +int BM_face_exists_overlap(BMVert **varr, int len, BMFace **r_existface); -int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface); +int BM_face_exists(BMVert **varr, int len, BMFace **r_existface); int BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len); int BM_face_exists_multi_edge(BMEdge **earr, int len); diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 049b923315b..126d0f46119 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -20,7 +20,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/bmesh/operators/bmesh_bevel.c +/** \file blender/bmesh/operators/bmo_bevel.c * \ingroup bmesh */ @@ -32,27 +32,30 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) { - const float offset = BMO_slot_float_get(op, "offset"); - const int seg = BMO_slot_int_get(op, "segments"); + const float offset = BMO_slot_float_get(op->slots_in, "offset"); + const int seg = BMO_slot_int_get(op->slots_in, "segments"); if (offset > 0) { BMOIter siter; BMEdge *e; BMVert *v; - /* first flush 'geom' into flags, this makes it possible to check connected data */ - BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE, BM_ELEM_TAG, FALSE); + /* first flush 'geom' into flags, this makes it possible to check connected data, + * BM_FACE is cleared so we can put newly created faces into a bmesh slot. */ + BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, FALSE); - BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) { + BMO_ITER (v, &siter, op->slots_in, "geom", BM_VERT) { BM_elem_flag_enable(v, BM_ELEM_TAG); } - BMO_ITER (e, &siter, bm, op, "geom", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "geom", BM_EDGE) { if (BM_edge_is_manifold(e)) { BM_elem_flag_enable(e, BM_ELEM_TAG); } } BM_mesh_bevel(bm, offset, seg); + + BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG); } } diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c index ebd848ff8b2..b7bb57bb19d 100644 --- a/source/blender/bmesh/operators/bmo_connect.c +++ b/source/blender/bmesh/operators/bmo_connect.c @@ -52,7 +52,7 @@ void bmo_connect_verts_exec(BMesh *bm, BMOperator *op) BLI_array_declare(verts_pair); int i; - BMO_slot_buffer_flag_enable(bm, op, "verts", BM_VERT, VERT_INPUT); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "verts", BM_VERT, VERT_INPUT); for (f = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL); f; f = BM_iter_step(&iter)) { BLI_array_empty(loops_split); @@ -117,7 +117,7 @@ void bmo_connect_verts_exec(BMesh *bm, BMOperator *op) } } - BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, EDGE_OUT); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, EDGE_OUT); BLI_array_free(loops_split); BLI_array_free(verts_pair); @@ -219,12 +219,12 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op) int c = 0, cl1 = 0, cl2 = 0; /* merge-bridge support */ - const int use_merge = BMO_slot_bool_get(op, "use_merge"); - const float merge_factor = BMO_slot_float_get(op, "merge_factor"); + const int use_merge = BMO_slot_bool_get(op->slots_in, "use_merge"); + const float merge_factor = BMO_slot_float_get(op->slots_in, "merge_factor"); - BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK); - BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { if (!BMO_elem_flag_test(bm, e, EDGE_DONE)) { BMVert *v, *ov; /* BMEdge *e2, *e3, *oe = e; */ /* UNUSED */ @@ -523,7 +523,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op) } } - BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, FACE_OUT); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, FACE_OUT); cleanup: BLI_array_free(ee1); diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c index 49a2f959063..987aa8cdf99 100644 --- a/source/blender/bmesh/operators/bmo_create.c +++ b/source/blender/bmesh/operators/bmo_create.c @@ -741,7 +741,10 @@ static EPath *edge_find_shortest_path(BMesh *bm, BMOperator *op, BMEdge *edge, E BMVert *startv; BMVert *endv; EPathNode *node; - int i, use_restrict = BMO_slot_bool_get(op, "use_restrict"); + int i; + const int use_restrict = BMO_slot_bool_get(op->slots_in, "use_restrict"); + BMOpSlot *slot_restrict = BMO_slot_get(op->slots_in, "restrict"); + startv = edata[BM_elem_index_get(edge)].ftag ? edge->v2 : edge->v1; endv = edata[BM_elem_index_get(edge)].ftag ? edge->v1 : edge->v2; @@ -769,7 +772,7 @@ static EPath *edge_find_shortest_path(BMesh *bm, BMOperator *op, BMEdge *edge, E verts[i] = node->v; } - if (BM_face_exists(bm, verts, i, &f)) { + if (BM_face_exists(verts, i, &f)) { if (!BMO_elem_flag_test(bm, f, FACE_IGNORE)) { BLI_ghash_remove(gh, endv, NULL, NULL); continue; @@ -806,12 +809,13 @@ static EPath *edge_find_shortest_path(BMesh *bm, BMOperator *op, BMEdge *edge, E continue; } - if (use_restrict && BMO_slot_map_contains(bm, op, "restrict", e)) { - int group = BMO_slot_map_int_get(bm, op, "restrict", e); - - if (!(group & path->group)) { - v2 = NULL; - continue; + if (use_restrict) { + int *group = (int *)BMO_slot_map_data_get(slot_restrict, e); + if (group) { + if (!(*group & path->group)) { + v2 = NULL; + continue; + } } } @@ -895,12 +899,14 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op) BMEdge **edges = NULL; PathBase *pathbase; BLI_array_declare(edges); - int use_restrict = BMO_slot_bool_get(op, "use_restrict"); - int use_fill_check = BMO_slot_bool_get(op, "use_fill_check"); - const short mat_nr = BMO_slot_int_get(op, "mat_nr"); - const short use_smooth = BMO_slot_bool_get(op, "use_smooth"); + int use_restrict = BMO_slot_bool_get(op->slots_in, "use_restrict"); + int use_fill_check = BMO_slot_bool_get(op->slots_in, "use_fill_check"); + const short mat_nr = BMO_slot_int_get(op->slots_in, "mat_nr"); + const short use_smooth = BMO_slot_bool_get(op->slots_in, "use_smooth"); int i, j, group = 0; unsigned int winding[2]; /* accumulte winding directions for each edge which has a face */ + BMOpSlot *slot_restrict = BMO_slot_get(op->slots_in, "restrict"); + BMOpSlot *slot_face_groupmap_out = BMO_slot_get(op->slots_out, "face_groupmap.out"); if (!bm->totvert || !bm->totedge) return; @@ -910,8 +916,8 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op) edata = MEM_callocN(sizeof(EdgeData) * bm->totedge, "EdgeData"); vdata = MEM_callocN(sizeof(VertData) * bm->totvert, "VertData"); - BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK); - BMO_slot_buffer_flag_enable(bm, op, "excludefaces", BM_FACE, FACE_IGNORE); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "exclude_faces", BM_FACE, FACE_IGNORE); BM_mesh_elem_index_ensure(bm, BM_VERT); @@ -932,14 +938,14 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op) bm->elem_index_dirty &= ~BM_EDGE; init_rotsys(bm, edata, vdata); - + while (1) { edge = NULL; group = 0; - BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { /* if restrict is on, only start on faces in the restrict map */ - if (use_restrict && !BMO_slot_map_contains(bm, op, "restrict", e)) + if (use_restrict && !BMO_slot_map_contains(slot_restrict, e)) continue; if (edata[BM_elem_index_get(e)].tag < 2) { @@ -948,7 +954,7 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op) if (use_restrict) { int i = 0, j = 0, gi = 0; - group = BMO_slot_map_int_get(bm, op, "restrict", e); + group = BMO_slot_map_int_get(slot_restrict, e); for (i = 0; i < 30; i++) { if (group & (1 << i)) { @@ -1055,7 +1061,7 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op) } if (use_restrict) { - BMO_slot_map_int_insert(bm, op, "faceout_groupmap", f, path->group); + BMO_slot_map_int_insert(op, slot_face_groupmap_out, f, path->group); } } } @@ -1063,7 +1069,7 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op) edge_free_path(pathbase, path); } - BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, FACE_NEW); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, FACE_NEW); BLI_array_free(edges); BLI_array_free(verts); @@ -1103,11 +1109,11 @@ void bmo_edgenet_prepare(BMesh *bm, BMOperator *op) int ok = 1; int i, count; - BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK); /* validate that each edge has at most one other tagged edge in the * disk cycle around each of it's vertices */ - BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { for (i = 0; i < 2; i++) { count = BMO_vert_edge_flags_count(bm, i ? e->v2 : e->v1, EDGE_MARK); if (count > 2) { @@ -1129,7 +1135,7 @@ void bmo_edgenet_prepare(BMesh *bm, BMOperator *op) /* find connected loops within the input edge */ count = 0; while (1) { - BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { if (!BMO_elem_flag_test(bm, e, EDGE_VIS)) { if (BMO_vert_edge_flags_count(bm, e->v1, EDGE_MARK) == 1 || BMO_vert_edge_flags_count(bm, e->v2, EDGE_MARK) == 1) @@ -1260,7 +1266,7 @@ void bmo_edgenet_prepare(BMesh *bm, BMOperator *op) } } - BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, ELE_NEW); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, ELE_NEW); BLI_array_free(edges1); BLI_array_free(edges2); @@ -1280,11 +1286,11 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op) BMEdge *e; BMFace *f; int totv = 0, tote = 0, totf = 0, amount; - const short mat_nr = BMO_slot_int_get(op, "mat_nr"); - const short use_smooth = BMO_slot_bool_get(op, "use_smooth"); + const short mat_nr = BMO_slot_int_get(op->slots_in, "mat_nr"); + const short use_smooth = BMO_slot_bool_get(op->slots_in, "use_smooth"); /* count number of each element type we were passe */ - BMO_ITER (h, &oiter, bm, op, "geom", BM_VERT | BM_EDGE | BM_FACE) { + BMO_ITER (h, &oiter, op->slots_in, "geom", BM_VERT | BM_EDGE | BM_FACE) { switch (h->htype) { case BM_VERT: totv++; break; case BM_EDGE: tote++; break; @@ -1318,7 +1324,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op) int ok = TRUE; - BMO_ITER (v, &oiter, bm, op, "geom", BM_VERT) { + BMO_ITER (v, &oiter, op->slots_in, "geom", BM_VERT) { /* count how many flagged edges this vertex uses */ int tot_edges = 0; BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) { @@ -1366,7 +1372,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op) /* call edgenet prepare op so additional face creation cases wore */ BMO_op_initf(bm, &op2, op->flag, "edgenet_prepare edges=%fe", ELE_NEW); BMO_op_exec(bm, &op2); - BMO_slot_buffer_flag_enable(bm, &op2, "edgeout", BM_EDGE, ELE_NEW); + BMO_slot_buffer_flag_enable(bm, op2.slots_out, "edges.out", BM_EDGE, ELE_NEW); BMO_op_finish(bm, &op2); BMO_op_initf(bm, &op2, op->flag, @@ -1376,8 +1382,9 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op) BMO_op_exec(bm, &op2); /* return if edge net create did something */ - if (BMO_slot_buffer_count(bm, &op2, "faceout")) { - BMO_slot_copy(&op2, op, "faceout", "faceout"); + if (BMO_slot_buffer_count(op2.slots_out, "faces.out")) { + BMO_slot_copy(&op2, slots_out, "faces.out", + op, slots_out, "faces.out"); BMO_op_finish(bm, &op2); return; } @@ -1389,8 +1396,9 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op) BMO_op_exec(bm, &op2); /* if we dissolved anything, then return */ - if (BMO_slot_buffer_count(bm, &op2, "regionout")) { - BMO_slot_copy(&op2, op, "regionout", "faceout"); + if (BMO_slot_buffer_count(op2.slots_out, "region.out")) { + BMO_slot_copy(&op2, slots_out, "region.out", + op, slots_out, "faces.out"); BMO_op_finish(bm, &op2); return; } @@ -1414,7 +1422,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op) /* create edge */ e = BM_edge_create(bm, verts[0], verts[1], NULL, TRUE); BMO_elem_flag_enable(bm, e, ELE_OUT); - BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, ELE_OUT); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, ELE_OUT); } else if (0) { /* nice feature but perhaps it should be a different tool? */ @@ -1460,7 +1468,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op) } } } - BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, ELE_OUT); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, ELE_OUT); /* done creating edges */ } else if (amount > 2) { @@ -1470,7 +1478,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op) BMVert **vert_arr = MEM_mallocN(sizeof(BMVert **) * totv, __func__); int i = 0; - BMO_ITER (v, &oiter, bm, op, "geom", BM_VERT) { + BMO_ITER (v, &oiter, op->slots_in, "geom", BM_VERT) { vert_arr[i] = v; i++; } diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index 9addb1b1657..7c3bcd60daa 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -85,7 +85,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op) BMWalker regwalker; int i; - int use_verts = BMO_slot_bool_get(op, "use_verts"); + int use_verts = BMO_slot_bool_get(op->slots_in, "use_verts"); if (use_verts) { /* tag verts that start out with only 2 edges, @@ -98,10 +98,10 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op) } } - BMO_slot_buffer_flag_enable(bm, op, "faces", BM_FACE, FACE_MARK); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "faces", BM_FACE, FACE_MARK); /* collect region */ - BMO_ITER (f, &oiter, bm, op, "faces", BM_FACE) { + BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) { if (!BMO_elem_flag_test(bm, f, FACE_MARK)) { continue; @@ -184,7 +184,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op) goto cleanup; } - BMO_slot_buffer_from_enabled_flag(bm, op, "regionout", BM_FACE, FACE_NEW); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "region.out", BM_FACE, FACE_NEW); cleanup: /* free/cleanup */ @@ -208,7 +208,7 @@ void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op) int i; - BMO_ITER (e, &oiter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &oiter, op->slots_in, "edges", BM_EDGE) { if (BM_edge_face_pair(e, &fa, &fb)) { BMO_elem_flag_enable(bm, e->v1, VERT_MARK); BMO_elem_flag_enable(bm, e->v2, VERT_MARK); @@ -237,7 +237,7 @@ void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op) //BMO_op_initf(bm, &fop, "dissolve_faces faces=%ff", FACE_MARK); //BMO_op_exec(bm, &fop); - //BMO_slot_copy(op, &fop, "regionout", "regionout"); + //BMO_slot_copy(op, &fop, "region.out", "region.out"); //BMO_op_finish(bm, &fop); } @@ -254,7 +254,7 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op) BMIter viter; BMVert *v; - int use_verts = BMO_slot_bool_get(op, "use_verts"); + int use_verts = BMO_slot_bool_get(op->slots_in, "use_verts"); if (use_verts) { BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) { @@ -262,7 +262,7 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op) } } - BMO_ITER (e, &eiter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &eiter, op->slots_in, "edges", BM_EDGE) { BMFace *fa, *fb; if (BM_edge_face_pair(e, &fa, &fb)) { @@ -338,7 +338,7 @@ void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op) BMFace *f; /* int i; */ - BMO_slot_buffer_flag_enable(bm, op, "verts", BM_VERT, VERT_MARK); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "verts", BM_VERT, VERT_MARK); for (v = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); v; v = BM_iter_step(&iter)) { if (BMO_elem_flag_test(bm, v, VERT_MARK)) { @@ -479,13 +479,13 @@ void dummy_exec(BMesh *bm, BMOperator *op) /* Limited Dissolve */ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op) { - BMOpSlot *einput = BMO_slot_get(op, "edges"); - BMOpSlot *vinput = BMO_slot_get(op, "verts"); + BMOpSlot *einput = BMO_slot_get(op->slots_in, "edges"); + BMOpSlot *vinput = BMO_slot_get(op->slots_in, "verts"); const float angle_max = (float)M_PI / 2.0f; - const float angle_limit = min_ff(angle_max, BMO_slot_float_get(op, "angle_limit")); - const int do_dissolve_boundaries = BMO_slot_bool_get(op, "use_dissolve_boundaries"); + const float angle_limit = min_ff(angle_max, BMO_slot_float_get(op->slots_in, "angle_limit")); + const int do_dissolve_boundaries = BMO_slot_bool_get(op->slots_in, "use_dissolve_boundaries"); BM_mesh_decimate_dissolve_ex(bm, angle_limit, do_dissolve_boundaries, - vinput->data.p, vinput->len, - einput->data.p, einput->len); + (BMVert **)BMO_SLOT_AS_BUFFER(vinput), vinput->len, + (BMEdge **)BMO_SLOT_AS_BUFFER(einput), einput->len); } diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index aa502203b50..c4f6c821320 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -68,7 +68,9 @@ static BMVert *copy_vertex(BMesh *source_mesh, BMVert *source_vertex, BMesh *tar * * Copy an existing edge from one bmesh to another. */ -static BMEdge *copy_edge(BMOperator *op, BMesh *source_mesh, +static BMEdge *copy_edge(BMOperator *op, + BMOpSlot *slot_boundarymap_out, + BMesh *source_mesh, BMEdge *source_edge, BMesh *target_mesh, GHash *vhash, GHash *ehash) { @@ -102,7 +104,7 @@ static BMEdge *copy_edge(BMOperator *op, BMesh *source_mesh, if (rlen < 2) { /* not sure what non-manifold cases of greater then three * radial should do. */ - BMO_slot_map_ptr_insert(source_mesh, op, "boundarymap", + BMO_slot_map_ptr_insert(op, slot_boundarymap_out, source_edge, target_edge); } @@ -124,7 +126,9 @@ static BMEdge *copy_edge(BMOperator *op, BMesh *source_mesh, * Copy an existing face from one bmesh to another. */ -static BMFace *copy_face(BMOperator *op, BMesh *source_mesh, +static BMFace *copy_face(BMOperator *op, + BMOpSlot *slot_facemap_out, + BMesh *source_mesh, BMFace *source_face, BMesh *target_mesh, BMVert **vtar, BMEdge **edar, GHash *vhash, GHash *ehash) { @@ -151,11 +155,11 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh, vtar[i] = BLI_ghash_lookup(vhash, source_loop->v); edar[i] = BLI_ghash_lookup(ehash, source_loop->e); } - + /* create new face */ target_face = BM_face_create(target_mesh, vtar, edar, source_face->len, FALSE); - BMO_slot_map_ptr_insert(source_mesh, op, "facemap", source_face, target_face); - BMO_slot_map_ptr_insert(source_mesh, op, "facemap", target_face, source_face); + BMO_slot_map_ptr_insert(op, slot_facemap_out, source_face, target_face); + BMO_slot_map_ptr_insert(op, slot_facemap_out, target_face, source_face); BM_elem_attrs_copy(source_mesh, target_mesh, source_face, target_face); @@ -181,7 +185,7 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh, * Internal Copy function. */ -static void bmo_mesh_copy(BMOperator *op, BMesh *source, BMesh *target) +static void bmo_mesh_copy(BMOperator *op, BMesh *bm_src, BMesh *bm_dst) { BMVert *v = NULL, *v2; @@ -196,22 +200,26 @@ static void bmo_mesh_copy(BMOperator *op, BMesh *source, BMesh *target) BMIter viter, eiter, fiter; GHash *vhash, *ehash; + BMOpSlot *slot_boundarymap_out = BMO_slot_get(op->slots_out, "boundarymap.out"); + BMOpSlot *slot_facemap_out = BMO_slot_get(op->slots_out, "facemap.out"); + BMOpSlot *slot_isovertmap_out = BMO_slot_get(op->slots_out, "isovertmap.out"); + /* initialize pointer hashes */ vhash = BLI_ghash_ptr_new("bmesh dupeops v"); ehash = BLI_ghash_ptr_new("bmesh dupeops e"); /* duplicate flagged vertices */ - BM_ITER_MESH (v, &viter, source, BM_VERTS_OF_MESH) { - if (BMO_elem_flag_test(source, v, DUPE_INPUT) && - !BMO_elem_flag_test(source, v, DUPE_DONE)) + BM_ITER_MESH (v, &viter, bm_src, BM_VERTS_OF_MESH) { + if (BMO_elem_flag_test(bm_src, v, DUPE_INPUT) && + !BMO_elem_flag_test(bm_src, v, DUPE_DONE)) { BMIter iter; int isolated = 1; - v2 = copy_vertex(source, v, target, vhash); + v2 = copy_vertex(bm_src, v, bm_dst, vhash); BM_ITER_ELEM (f, &iter, v, BM_FACES_OF_VERT) { - if (BMO_elem_flag_test(source, f, DUPE_INPUT)) { + if (BMO_elem_flag_test(bm_src, f, DUPE_INPUT)) { isolated = 0; break; } @@ -219,7 +227,7 @@ static void bmo_mesh_copy(BMOperator *op, BMesh *source, BMesh *target) if (isolated) { BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) { - if (BMO_elem_flag_test(source, e, DUPE_INPUT)) { + if (BMO_elem_flag_test(bm_src, e, DUPE_INPUT)) { isolated = 0; break; } @@ -227,49 +235,49 @@ static void bmo_mesh_copy(BMOperator *op, BMesh *source, BMesh *target) } if (isolated) { - BMO_slot_map_ptr_insert(source, op, "isovertmap", v, v2); + BMO_slot_map_ptr_insert(op, slot_isovertmap_out, v, v2); } - BMO_elem_flag_enable(source, v, DUPE_DONE); + BMO_elem_flag_enable(bm_src, v, DUPE_DONE); } } /* now we dupe all the edges */ - BM_ITER_MESH (e, &eiter, source, BM_EDGES_OF_MESH) { - if (BMO_elem_flag_test(source, e, DUPE_INPUT) && - !BMO_elem_flag_test(source, e, DUPE_DONE)) + BM_ITER_MESH (e, &eiter, bm_src, BM_EDGES_OF_MESH) { + if (BMO_elem_flag_test(bm_src, e, DUPE_INPUT) && + !BMO_elem_flag_test(bm_src, e, DUPE_DONE)) { /* make sure that verts are copied */ - if (!BMO_elem_flag_test(source, e->v1, DUPE_DONE)) { - copy_vertex(source, e->v1, target, vhash); - BMO_elem_flag_enable(source, e->v1, DUPE_DONE); + if (!BMO_elem_flag_test(bm_src, e->v1, DUPE_DONE)) { + copy_vertex(bm_src, e->v1, bm_dst, vhash); + BMO_elem_flag_enable(bm_src, e->v1, DUPE_DONE); } - if (!BMO_elem_flag_test(source, e->v2, DUPE_DONE)) { - copy_vertex(source, e->v2, target, vhash); - BMO_elem_flag_enable(source, e->v2, DUPE_DONE); + if (!BMO_elem_flag_test(bm_src, e->v2, DUPE_DONE)) { + copy_vertex(bm_src, e->v2, bm_dst, vhash); + BMO_elem_flag_enable(bm_src, e->v2, DUPE_DONE); } /* now copy the actual edge */ - copy_edge(op, source, e, target, vhash, ehash); - BMO_elem_flag_enable(source, e, DUPE_DONE); + copy_edge(op, slot_boundarymap_out, bm_src, e, bm_dst, vhash, ehash); + BMO_elem_flag_enable(bm_src, e, DUPE_DONE); } } /* first we dupe all flagged faces and their elements from source */ - BM_ITER_MESH (f, &fiter, source, BM_FACES_OF_MESH) { - if (BMO_elem_flag_test(source, f, DUPE_INPUT)) { + BM_ITER_MESH (f, &fiter, bm_src, BM_FACES_OF_MESH) { + if (BMO_elem_flag_test(bm_src, f, DUPE_INPUT)) { /* vertex pass */ BM_ITER_ELEM (v, &viter, f, BM_VERTS_OF_FACE) { - if (!BMO_elem_flag_test(source, v, DUPE_DONE)) { - copy_vertex(source, v, target, vhash); - BMO_elem_flag_enable(source, v, DUPE_DONE); + if (!BMO_elem_flag_test(bm_src, v, DUPE_DONE)) { + copy_vertex(bm_src, v, bm_dst, vhash); + BMO_elem_flag_enable(bm_src, v, DUPE_DONE); } } /* edge pass */ BM_ITER_ELEM (e, &eiter, f, BM_EDGES_OF_FACE) { - if (!BMO_elem_flag_test(source, e, DUPE_DONE)) { - copy_edge(op, source, e, target, vhash, ehash); - BMO_elem_flag_enable(source, e, DUPE_DONE); + if (!BMO_elem_flag_test(bm_src, e, DUPE_DONE)) { + copy_edge(op, slot_boundarymap_out, bm_src, e, bm_dst, vhash, ehash); + BMO_elem_flag_enable(bm_src, e, DUPE_DONE); } } @@ -280,8 +288,8 @@ static void bmo_mesh_copy(BMOperator *op, BMesh *source, BMesh *target) BLI_array_grow_items(vtar, f->len); BLI_array_grow_items(edar, f->len); - copy_face(op, source, f, target, vtar, edar, vhash, ehash); - BMO_elem_flag_enable(source, f, DUPE_DONE); + copy_face(op, slot_facemap_out, bm_src, f, bm_dst, vtar, edar, vhash, ehash); + BMO_elem_flag_enable(bm_src, f, DUPE_DONE); } } @@ -317,23 +325,24 @@ static void bmo_mesh_copy(BMOperator *op, BMesh *source, BMesh *target) void bmo_duplicate_exec(BMesh *bm, BMOperator *op) { BMOperator *dupeop = op; - BMesh *bm2 = BMO_slot_ptr_get(op, "dest"); + BMesh *bm2 = BMO_slot_ptr_get(op->slots_in, "dest"); if (!bm2) bm2 = bm; /* flag input */ - BMO_slot_buffer_flag_enable(bm, dupeop, "geom", BM_ALL, DUPE_INPUT); + BMO_slot_buffer_flag_enable(bm, dupeop->slots_in, "geom", BM_ALL, DUPE_INPUT); /* use the internal copy function */ bmo_mesh_copy(dupeop, bm, bm2); /* Output */ /* First copy the input buffers to output buffers - original data */ - BMO_slot_copy(dupeop, dupeop, "geom", "origout"); + BMO_slot_copy(dupeop, slots_in, "geom", + dupeop, slots_out, "geom_orig.out"); /* Now alloc the new output buffers */ - BMO_slot_buffer_from_enabled_flag(bm, dupeop, "newout", BM_ALL, DUPE_NEW); + BMO_slot_buffer_from_enabled_flag(bm, dupeop, dupeop->slots_out, "geom.out", BM_ALL, DUPE_NEW); } #if 0 /* UNUSED */ @@ -378,16 +387,17 @@ void bmo_split_exec(BMesh *bm, BMOperator *op) BMOperator *splitop = op; BMOperator dupeop; BMOperator delop; - const short use_only_faces = BMO_slot_bool_get(op, "use_only_faces"); + const short use_only_faces = BMO_slot_bool_get(op->slots_in, "use_only_faces"); /* initialize our sub-operator */ BMO_op_init(bm, &dupeop, op->flag, "duplicate"); BMO_op_init(bm, &delop, op->flag, "delete"); - BMO_slot_copy(splitop, &dupeop, "geom", "geom"); + BMO_slot_copy(splitop, slots_in, "geom", + &dupeop, slots_in, "geom"); BMO_op_exec(bm, &dupeop); - BMO_slot_buffer_flag_enable(bm, splitop, "geom", BM_ALL, SPLIT_INPUT); + BMO_slot_buffer_flag_enable(bm, splitop->slots_in, "geom", BM_ALL, SPLIT_INPUT); if (use_only_faces) { BMVert *v; @@ -427,16 +437,22 @@ void bmo_split_exec(BMesh *bm, BMOperator *op) } /* connect outputs of dupe to delete, exluding keep geometry */ - BMO_slot_int_set(&delop, "context", DEL_FACES); - BMO_slot_buffer_from_enabled_flag(bm, &delop, "geom", BM_ALL, SPLIT_INPUT); + BMO_slot_int_set(delop.slots_in, "context", DEL_FACES); + BMO_slot_buffer_from_enabled_flag(bm, &delop, delop.slots_in, "geom", BM_ALL, SPLIT_INPUT); BMO_op_exec(bm, &delop); /* now we make our outputs by copying the dupe output */ - BMO_slot_copy(&dupeop, splitop, "newout", "geomout"); - BMO_slot_copy(&dupeop, splitop, "boundarymap", "boundarymap"); - BMO_slot_copy(&dupeop, splitop, "isovertmap", "isovertmap"); - + BMO_slot_copy(&dupeop, slots_out, "geom.out", + splitop, slots_out, "geom.out"); + + BMO_slot_copy(&dupeop, slots_out, "boundarymap.out", + splitop, slots_out, "boundarymap.out"); + + BMO_slot_copy(&dupeop, slots_out, "isovertmap.out", + splitop, slots_out, "isovertmap.out"); + + /* cleanup */ BMO_op_finish(bm, &delop); BMO_op_finish(bm, &dupeop); @@ -450,9 +466,9 @@ void bmo_delete_exec(BMesh *bm, BMOperator *op) BMOperator *delop = op; /* Mark Buffer */ - BMO_slot_buffer_flag_enable(bm, delop, "geom", BM_ALL, DEL_INPUT); + BMO_slot_buffer_flag_enable(bm, delop->slots_in, "geom", BM_ALL, DEL_INPUT); - BMO_remove_tagged_context(bm, DEL_INPUT, BMO_slot_int_get(op, "context")); + BMO_remove_tagged_context(bm, DEL_INPUT, BMO_slot_int_get(op->slots_in, "context")); #undef DEL_INPUT } @@ -473,44 +489,47 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op) float phi; int steps, do_dupli, a, usedvec; - BMO_slot_vec_get(op, "cent", cent); - BMO_slot_vec_get(op, "axis", axis); + BMO_slot_vec_get(op->slots_in, "cent", cent); + BMO_slot_vec_get(op->slots_in, "axis", axis); normalize_v3(axis); - BMO_slot_vec_get(op, "dvec", dvec); + BMO_slot_vec_get(op->slots_in, "dvec", dvec); usedvec = !is_zero_v3(dvec); - steps = BMO_slot_int_get(op, "steps"); - phi = BMO_slot_float_get(op, "ang") * DEG2RADF(1.0f) / steps; - do_dupli = BMO_slot_bool_get(op, "do_dupli"); + steps = BMO_slot_int_get(op->slots_in, "steps"); + phi = BMO_slot_float_get(op->slots_in, "angle") * DEG2RADF(1.0f) / steps; + do_dupli = BMO_slot_bool_get(op->slots_in, "use_duplicate"); axis_angle_to_mat3(rmat, axis, phi); - BMO_slot_copy(op, op, "geom", "lastout"); + BMO_slot_copy(op, slots_in, "geom", + op, slots_out, "geom_last.out"); for (a = 0; a < steps; a++) { if (do_dupli) { - BMO_op_initf(bm, &dupop, op->flag, "duplicate geom=%s", op, "lastout"); + BMO_op_initf(bm, &dupop, op->flag, "duplicate geom=%S", op, "geom_last.out"); BMO_op_exec(bm, &dupop); BMO_op_callf(bm, op->flag, - "rotate cent=%v mat=%m3 verts=%s", - cent, rmat, &dupop, "newout"); - BMO_slot_copy(&dupop, op, "newout", "lastout"); + "rotate cent=%v mat=%m3 verts=%S", + cent, rmat, &dupop, "geom.out"); + BMO_slot_copy(&dupop, slots_out, "geom.out", + op, slots_out, "geom_last.out"); BMO_op_finish(bm, &dupop); } else { - BMO_op_initf(bm, &extop, op->flag, "extrude_face_region edgefacein=%s", - op, "lastout"); + BMO_op_initf(bm, &extop, op->flag, "extrude_face_region geom=%S", + op, "geom_last.out"); BMO_op_exec(bm, &extop); BMO_op_callf(bm, op->flag, - "rotate cent=%v mat=%m3 verts=%s", - cent, rmat, &extop, "geomout"); - BMO_slot_copy(&extop, op, "geomout", "lastout"); + "rotate cent=%v mat=%m3 verts=%S", + cent, rmat, &extop, "geom.out"); + BMO_slot_copy(&extop, slots_out, "geom.out", + op, slots_out, "geom_last.out"); BMO_op_finish(bm, &extop); } if (usedvec) { mul_m3_v3(rmat, dvec); BMO_op_callf(bm, op->flag, - "translate vec=%v verts=%s", - dvec, op, "lastout"); + "translate vec=%v verts=%S", + dvec, op, "geom_last.out"); } } } diff --git a/source/blender/bmesh/operators/bmo_edgesplit.c b/source/blender/bmesh/operators/bmo_edgesplit.c index 1f6689ed06c..9e9e4b8c962 100644 --- a/source/blender/bmesh/operators/bmo_edgesplit.c +++ b/source/blender/bmesh/operators/bmo_edgesplit.c @@ -81,14 +81,14 @@ static void bm_edgesplit_validate_seams(BMesh *bm, BMOperator *op) /* single marked edges unconnected to any other marked edges * are illegal, go through and unmark them */ - BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { /* lame, but we don't want the count to exceed 255, * so just count to 2, its all we need */ unsigned char *vt; vt = &vtouch[BM_elem_index_get(e->v1)]; if (*vt < 2) (*vt)++; vt = &vtouch[BM_elem_index_get(e->v2)]; if (*vt < 2) (*vt)++; } - BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { if (vtouch[BM_elem_index_get(e->v1)] == 1 && vtouch[BM_elem_index_get(e->v2)] == 1) { @@ -104,13 +104,13 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMEdge *e; - const int use_verts = BMO_slot_bool_get(op, "use_verts"); + const int use_verts = BMO_slot_bool_get(op->slots_in, "use_verts"); - BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_SEAM); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_SEAM); if (use_verts) { /* this slows down the operation but its ok because the modifier doesn't use */ - BMO_slot_buffer_flag_enable(bm, op, "verts", BM_VERT, VERT_SEAM); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "verts", BM_VERT, VERT_SEAM); /* prevent one edge having both verts unflagged * we could alternately disable these edges, either way its a corner case. @@ -118,7 +118,7 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op) * This is needed so we don't split off the edge but then none of its verts which * would leave a duplicate edge. */ - BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { if (UNLIKELY((BMO_elem_flag_test(bm, e->v1, VERT_SEAM) == FALSE && (BMO_elem_flag_test(bm, e->v2, VERT_SEAM) == FALSE)))) { @@ -130,7 +130,7 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op) bm_edgesplit_validate_seams(bm, op); - BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { if (BMO_elem_flag_test(bm, e, EDGE_SEAM)) { /* this flag gets copied so we can be sure duplicate edges get it too (important) */ BM_elem_flag_enable(e, BM_ELEM_INTERNAL_TAG); @@ -146,7 +146,7 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op) } if (use_verts) { - BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { if (BMO_elem_flag_test(bm, e->v1, VERT_SEAM) == FALSE) { BM_elem_flag_disable(e->v1, BM_ELEM_TAG); } @@ -156,7 +156,7 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op) } } - BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { if (BMO_elem_flag_test(bm, e, EDGE_SEAM)) { if (BM_elem_flag_test(e->v1, BM_ELEM_TAG)) { BM_elem_flag_disable(e->v1, BM_ELEM_TAG); @@ -169,5 +169,5 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op) } } - BMO_slot_buffer_from_enabled_hflag(bm, op, "edgeout", BM_EDGE, BM_ELEM_INTERNAL_TAG); + BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_INTERNAL_TAG); } diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index 71048e18335..6a9d9c1e48b 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -60,7 +60,7 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) BLI_array_declare(edges); int i; - BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) { + BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) { BLI_array_empty(edges); BLI_array_grow_items(edges, f->len); @@ -122,7 +122,7 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) BMO_op_callf(bm, op->flag, "delete geom=%ff context=%i", EXT_DEL, DEL_ONLYFACES); - BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, EXT_KEEP); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, EXT_KEEP); } /** @@ -181,7 +181,7 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op) BMFace *f; BMEdge *e, *e_new; - BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { BMO_elem_flag_enable(bm, e, EXT_INPUT); BMO_elem_flag_enable(bm, e->v1, EXT_INPUT); BMO_elem_flag_enable(bm, e->v2, EXT_INPUT); @@ -193,12 +193,12 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op) /* disable root flag on all new skin nodes */ if (CustomData_has_layer(&bm->vdata, CD_MVERT_SKIN)) { BMVert *v; - BMO_ITER(v, &siter, bm, &dupeop, "newout", BM_VERT) { + BMO_ITER(v, &siter, dupeop.slots_out, "geom.out", BM_VERT) { bm_extrude_disable_skin_root(bm, v); } } - for (e = BMO_iter_new(&siter, bm, &dupeop, "boundarymap", 0); e; e = BMO_iter_step(&siter)) { + for (e = BMO_iter_new(&siter, dupeop.slots_out, "boundarymap.out", 0); e; e = BMO_iter_step(&siter)) { BMVert *f_verts[4]; e_new = *(BMEdge **)BMO_iter_map_value(&siter); @@ -230,7 +230,7 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op) BMO_op_finish(bm, &dupeop); - BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, EXT_KEEP); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_ALL, EXT_KEEP); } void bmo_extrude_vert_indiv_exec(BMesh *bm, BMOperator *op) @@ -240,7 +240,7 @@ void bmo_extrude_vert_indiv_exec(BMesh *bm, BMOperator *op) BMEdge *e; const int has_vskin = CustomData_has_layer(&bm->vdata, CD_MVERT_SKIN); - for (v = BMO_iter_new(&siter, bm, op, "verts", BM_VERT); v; v = BMO_iter_step(&siter)) { + for (v = BMO_iter_new(&siter, op->slots_in, "verts", BM_VERT); v; v = BMO_iter_step(&siter)) { dupev = BM_vert_create(bm, v->co, v); if (has_vskin) bm_extrude_disable_skin_root(bm, v); @@ -251,8 +251,8 @@ void bmo_extrude_vert_indiv_exec(BMesh *bm, BMOperator *op) BMO_elem_flag_enable(bm, dupev, EXT_KEEP); } - BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, EXT_KEEP); - BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, EXT_KEEP); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, EXT_KEEP); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, EXT_KEEP); } void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) @@ -264,15 +264,17 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) BMVert *v, *v2; BMFace *f; int found, fwd, delorig = FALSE; + BMOpSlot *slot_facemap_out; + BMOpSlot *slot_edges_exclude; /* initialize our sub-operators */ BMO_op_init(bm, &dupeop, op->flag, "duplicate"); - BMO_slot_buffer_flag_enable(bm, op, "edgefacein", BM_EDGE | BM_FACE, EXT_INPUT); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "geom", BM_EDGE | BM_FACE, EXT_INPUT); /* if one flagged face is bordered by an un-flagged face, then we delete * original geometry unless caller explicitly asked to keep it. */ - if (!BMO_slot_bool_get(op, "alwayskeeporig")) { + if (!BMO_slot_bool_get(op->slots_in, "use_keep_orig")) { BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { int edge_face_tot; @@ -339,18 +341,21 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) EXT_DEL, DEL_ONLYTAGGED); } - BMO_slot_copy(op, &dupeop, "edgefacein", "geom"); + BMO_slot_copy(op, slots_in, "geom", + &dupeop, slots_in, "geom"); BMO_op_exec(bm, &dupeop); /* disable root flag on all new skin nodes */ if (CustomData_has_layer(&bm->vdata, CD_MVERT_SKIN)) { - BMO_ITER(v, &siter, bm, &dupeop, "newout", BM_VERT) { + BMO_ITER(v, &siter, dupeop.slots_out, "geom.out", BM_VERT) { bm_extrude_disable_skin_root(bm, v); } } - if (bm->act_face && BMO_elem_flag_test(bm, bm->act_face, EXT_INPUT)) - bm->act_face = BMO_slot_map_ptr_get(bm, &dupeop, "facemap", bm->act_face); + slot_facemap_out = BMO_slot_get(dupeop.slots_out, "facemap.out"); + if (bm->act_face && BMO_elem_flag_test(bm, bm->act_face, EXT_INPUT)) { + bm->act_face = BMO_slot_map_ptr_get(slot_facemap_out, bm->act_face); + } if (delorig) { BMO_op_exec(bm, &delop); @@ -365,13 +370,15 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) } } - BMO_slot_copy(&dupeop, op, "newout", "geomout"); + BMO_slot_copy(&dupeop, slots_out, "geom.out", + op, slots_out, "geom.out"); - for (e = BMO_iter_new(&siter, bm, &dupeop, "boundarymap", 0); e; e = BMO_iter_step(&siter)) { + slot_edges_exclude = BMO_slot_get(op->slots_in, "edges_exclude"); + for (e = BMO_iter_new(&siter, dupeop.slots_out, "boundarymap.out", 0); e; e = BMO_iter_step(&siter)) { BMVert *f_verts[4]; /* this should always be wire, so this is mainly a speedup to avoid map lookup */ - if (BM_edge_is_wire(e) && BMO_slot_map_contains(bm, op, "exclude", e)) { + if (BM_edge_is_wire(e) && BMO_slot_map_contains(slot_edges_exclude, e)) { BMVert *v1 = e->v1, *v2 = e->v2; /* The original edge was excluded, @@ -421,7 +428,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) } /* link isolated vert */ - for (v = BMO_iter_new(&siter, bm, &dupeop, "isovertmap", 0); v; v = BMO_iter_step(&siter)) { + for (v = BMO_iter_new(&siter, dupeop.slots_out, "isovertmap.out", 0); v; v = BMO_iter_step(&siter)) { v2 = *((void **)BMO_iter_map_value(&siter)); BM_edge_create(bm, v, v2, v->e, TRUE); } @@ -647,25 +654,28 @@ void bmo_solidify_face_region_exec(BMesh *bm, BMOperator *op) BMOperator reverseop; float thickness; - thickness = BMO_slot_float_get(op, "thickness"); + thickness = BMO_slot_float_get(op->slots_in, "thickness"); /* Flip original faces (so the shell is extruded inward) */ BMO_op_init(bm, &reverseop, op->flag, "reverse_faces"); - BMO_slot_copy(op, &reverseop, "geom", "faces"); + BMO_slot_copy(op, slots_in, "geom", + &reverseop, slots_in, "faces"); BMO_op_exec(bm, &reverseop); BMO_op_finish(bm, &reverseop); /* Extrude the region */ - BMO_op_initf(bm, &extrudeop, op->flag, "extrude_face_region alwayskeeporig=%b", TRUE); - BMO_slot_copy(op, &extrudeop, "geom", "edgefacein"); + BMO_op_initf(bm, &extrudeop, op->flag, "extrude_face_region use_keep_orig=%b", TRUE); + BMO_slot_copy(op, slots_in, "geom", + &extrudeop, slots_in, "geom"); BMO_op_exec(bm, &extrudeop); /* Push the verts of the extruded faces inward to create thickness */ - BMO_slot_buffer_flag_enable(bm, &extrudeop, "geomout", BM_FACE, FACE_MARK); + BMO_slot_buffer_flag_enable(bm, extrudeop.slots_out, "geom.out", BM_FACE, FACE_MARK); calc_solidify_normals(bm); solidify_add_thickness(bm, thickness); - BMO_slot_copy(&extrudeop, op, "geomout", "geomout"); + BMO_slot_copy(&extrudeop, slots_out, "geom.out", + op, slots_out, "geom.out"); BMO_op_finish(bm, &extrudeop); } diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c index 80bdf9de7ed..117f65ae4ea 100644 --- a/source/blender/bmesh/operators/bmo_hull.c +++ b/source/blender/bmesh/operators/bmo_hull.c @@ -119,7 +119,7 @@ static void hull_output_triangles(BMesh *bm, GHash *hull_triangles) }; BMFace *f, *example = NULL; - if (BM_face_exists(bm, t->v, 3, &f)) { + if (BM_face_exists(t->v, 3, &f)) { /* If the operator is run with "use_existing_faces" * disabled, but an output face in the hull is the * same as a face in the existing mesh, it should not @@ -139,17 +139,17 @@ static void hull_output_triangles(BMesh *bm, GHash *hull_triangles) f = BM_face_create_quad_tri_v(bm, t->v, 3, example, TRUE); BM_face_copy_shared(bm, f); } - /* Mark face for 'geomout' slot and select */ + /* Mark face for 'geom.out' slot and select */ BMO_elem_flag_enable(bm, f, HULL_FLAG_OUTPUT_GEOM); BM_face_select_set(bm, f, TRUE); - /* Mark edges for 'geomout' slot */ + /* Mark edges for 'geom.out' slot */ for (i = 0; i < 3; i++) { BMO_elem_flag_enable(bm, edges[i], HULL_FLAG_OUTPUT_GEOM); } } else { - /* Mark input edges for 'geomout' slot */ + /* Mark input edges for 'geom.out' slot */ for (i = 0; i < 3; i++) { const int next = (i == 2 ? 0 : i + 1); BMEdge *e = BM_edge_exists(t->v[i], t->v[next]); @@ -161,7 +161,7 @@ static void hull_output_triangles(BMesh *bm, GHash *hull_triangles) } } - /* Mark verts for 'geomout' slot */ + /* Mark verts for 'geom.out' slot */ for (i = 0; i < 3; i++) { BMO_elem_flag_enable(bm, t->v[i], HULL_FLAG_OUTPUT_GEOM); } @@ -304,14 +304,14 @@ static void hull_mark_interior_elements(BMesh *bm, BMOperator *op, BMOIter oiter; /* Check for interior edges too */ - BMO_ITER (e, &oiter, bm, op, "input", BM_EDGE) { + BMO_ITER (e, &oiter, op->slots_in, "input", BM_EDGE) { if (!hull_final_edges_lookup(final_edges, e->v1, e->v2)) BMO_elem_flag_enable(bm, e, HULL_FLAG_INTERIOR_ELE); } /* Mark all input faces as interior, some may be unmarked in * hull_remove_overlapping() */ - BMO_ITER (f, &oiter, bm, op, "input", BM_FACE) { + BMO_ITER (f, &oiter, op->slots_in, "input", BM_FACE) { BMO_elem_flag_enable(bm, f, HULL_FLAG_INTERIOR_ELE); } } @@ -328,7 +328,7 @@ static void hull_tag_unused(BMesh *bm, BMOperator *op) * interior (i.e. were already part of the input, but not part of * the hull), but that aren't also used by elements outside the * input set */ - BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) { + BMO_ITER (v, &oiter, op->slots_in, "input", BM_VERT) { if (BMO_elem_flag_test(bm, v, HULL_FLAG_INTERIOR_ELE)) { int del = TRUE; @@ -351,7 +351,7 @@ static void hull_tag_unused(BMesh *bm, BMOperator *op) } } - BMO_ITER (e, &oiter, bm, op, "input", BM_EDGE) { + BMO_ITER (e, &oiter, op->slots_in, "input", BM_EDGE) { if (BMO_elem_flag_test(bm, e, HULL_FLAG_INTERIOR_ELE)) { int del = TRUE; @@ -367,7 +367,7 @@ static void hull_tag_unused(BMesh *bm, BMOperator *op) } } - BMO_ITER (f, &oiter, bm, op, "input", BM_FACE) { + BMO_ITER (f, &oiter, op->slots_in, "input", BM_FACE) { if (BMO_elem_flag_test(bm, f, HULL_FLAG_INTERIOR_ELE)) BMO_elem_flag_enable(bm, f, HULL_FLAG_DEL); } @@ -382,7 +382,7 @@ static void hull_tag_holes(BMesh *bm, BMOperator *op) /* Unmark any hole faces if they are isolated or part of a * border */ - BMO_ITER (f, &oiter, bm, op, "input", BM_FACE) { + BMO_ITER (f, &oiter, op->slots_in, "input", BM_FACE) { if (BMO_elem_flag_test(bm, f, HULL_FLAG_HOLE)) { BM_ITER_ELEM (e, &iter, f, BM_EDGES_OF_FACE) { if (BM_edge_is_boundary(e)) { @@ -395,7 +395,7 @@ static void hull_tag_holes(BMesh *bm, BMOperator *op) /* Mark edges too if all adjacent faces are holes and the edge is * not already isolated */ - BMO_ITER (e, &oiter, bm, op, "input", BM_EDGE) { + BMO_ITER (e, &oiter, op->slots_in, "input", BM_EDGE) { int hole = TRUE; int any_faces = FALSE; @@ -412,20 +412,20 @@ static void hull_tag_holes(BMesh *bm, BMOperator *op) } } -static int hull_input_vert_count(BMesh *bm, BMOperator *op) +static int hull_input_vert_count(BMOperator *op) { BMOIter oiter; BMVert *v; int count = 0; - BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) { + BMO_ITER (v, &oiter, op->slots_in, "input", BM_VERT) { count++; } return count; } -static BMVert **hull_input_verts_copy(BMesh *bm, BMOperator *op, +static BMVert **hull_input_verts_copy(BMOperator *op, const int num_input_verts) { BMOIter oiter; @@ -434,7 +434,7 @@ static BMVert **hull_input_verts_copy(BMesh *bm, BMOperator *op, num_input_verts, AT); int i = 0; - BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) { + BMO_ITER (v, &oiter, op->slots_in, "input", BM_VERT) { input_verts[i++] = v; } @@ -492,9 +492,9 @@ static void hull_from_bullet(BMesh *bm, BMOperator *op, plConvexHull hull; int i, count = 0; - const int num_input_verts = hull_input_vert_count(bm, op); + const int num_input_verts = hull_input_vert_count(op); - input_verts = hull_input_verts_copy(bm, op, num_input_verts); + input_verts = hull_input_verts_copy(op, num_input_verts); coords = hull_verts_for_bullet(input_verts, num_input_verts); hull = plConvexHullCompute(coords, num_input_verts); @@ -535,13 +535,13 @@ static void hull_from_bullet(BMesh *bm, BMOperator *op, } /* Check that there are at least three vertices in the input */ -static int hull_num_input_verts_is_ok(BMesh *bm, BMOperator *op) +static int hull_num_input_verts_is_ok(BMOperator *op) { BMOIter oiter; BMVert *v; int partial_num_verts = 0; - BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) { + BMO_ITER (v, &oiter, op->slots_in, "input", BM_VERT) { partial_num_verts++; if (partial_num_verts >= 3) break; @@ -559,14 +559,14 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op) GHash *hull_triangles; /* Verify that at least three verts in the input */ - if (!hull_num_input_verts_is_ok(bm, op)) { + if (!hull_num_input_verts_is_ok(op)) { BMO_error_raise(bm, op, BMERR_CONVEX_HULL_FAILED, "Requires at least three vertices"); return; } /* Tag input elements */ - BMO_ITER (ele, &oiter, bm, op, "input", BM_ALL) { + BMO_ITER (ele, &oiter, op->slots_in, "input", BM_ALL) { BMO_elem_flag_enable(bm, ele, HULL_FLAG_INPUT); /* Mark all vertices as interior to begin with */ @@ -584,7 +584,7 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op) hull_mark_interior_elements(bm, op, final_edges); /* Remove hull triangles covered by an existing face */ - if (BMO_slot_bool_get(op, "use_existing_faces")) { + if (BMO_slot_bool_get(op->slots_in, "use_existing_faces")) { hull_remove_overlapping(bm, hull_triangles, final_edges); hull_tag_holes(bm, op); @@ -603,23 +603,23 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op) /* Output slot of input elements that ended up inside the hull * rather than part of it */ - BMO_slot_buffer_from_enabled_flag(bm, op, "interior_geom", BM_ALL, - HULL_FLAG_INTERIOR_ELE); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_interior.out", + BM_ALL, HULL_FLAG_INTERIOR_ELE); /* Output slot of input elements that ended up inside the hull and * are are unused by other geometry. */ - BMO_slot_buffer_from_enabled_flag(bm, op, "unused_geom", BM_ALL, - HULL_FLAG_DEL); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_unused.out", + BM_ALL, HULL_FLAG_DEL); /* Output slot of faces and edges that were in the input and on * the hull (useful for cases like bridging where you want to * delete some input geometry) */ - BMO_slot_buffer_from_enabled_flag(bm, op, "holes_geom", BM_ALL, - HULL_FLAG_HOLE); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_holes.out", + BM_ALL, HULL_FLAG_HOLE); /* Output slot of all hull vertices, faces, and edges */ - BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, - HULL_FLAG_OUTPUT_GEOM); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", + BM_ALL, HULL_FLAG_OUTPUT_GEOM); } #endif /* WITH_BULLET */ diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index 132d7050b31..9abf129a529 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -92,13 +92,13 @@ static BMLoop *bm_edge_is_mixed_face_tag(BMLoop *l) void bmo_inset_exec(BMesh *bm, BMOperator *op) { - const int use_outset = BMO_slot_bool_get(op, "use_outset"); - const int use_boundary = BMO_slot_bool_get(op, "use_boundary") && (use_outset == FALSE); - const int use_even_offset = BMO_slot_bool_get(op, "use_even_offset"); + const int use_outset = BMO_slot_bool_get(op->slots_in, "use_outset"); + const int use_boundary = BMO_slot_bool_get(op->slots_in, "use_boundary") && (use_outset == FALSE); + const int use_even_offset = BMO_slot_bool_get(op->slots_in, "use_even_offset"); const int use_even_boundry = use_even_offset; /* could make own option */ - const int use_relative_offset = BMO_slot_bool_get(op, "use_relative_offset"); - const float thickness = BMO_slot_float_get(op, "thickness"); - const float depth = BMO_slot_float_get(op, "depth"); + const int use_relative_offset = BMO_slot_bool_get(op->slots_in, "use_relative_offset"); + const float thickness = BMO_slot_float_get(op->slots_in, "thickness"); + const float depth = BMO_slot_float_get(op->slots_in, "depth"); int edge_info_len = 0; @@ -113,11 +113,11 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) if (use_outset == FALSE) { BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE); - BMO_slot_buffer_hflag_enable(bm, op, "faces", BM_FACE, BM_ELEM_TAG, FALSE); + BMO_slot_buffer_hflag_enable(bm, op->slots_in, "faces", BM_FACE, BM_ELEM_TAG, FALSE); } else { BM_mesh_elem_hflag_enable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE); - BMO_slot_buffer_hflag_disable(bm, op, "faces", BM_FACE, BM_ELEM_TAG, FALSE); + BMO_slot_buffer_hflag_disable(bm, op->slots_in, "faces", BM_FACE, BM_ELEM_TAG, FALSE); } /* first count all inset edges we will split */ @@ -477,11 +477,48 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) /* copy for loop data, otherwise UV's and vcols are no good. * tiny speedup here we could be more clever and copy from known adjacent data * also - we could attempt to interpolate the loop data, this would be much slower but more useful too */ +#if 0 + /* don't use this because face boundaries have no adjacent loops and won't be filled in. + * instead copy from the opposite side with the code below */ BM_face_copy_shared(bm, f); +#else + { + /* 2 inner loops on the edge between the new face and the original */ + BMLoop *l_a; + BMLoop *l_b; + BMLoop *l_a_other; + BMLoop *l_b_other; + + l_a = BM_FACE_FIRST_LOOP(f); + l_b = l_a->next; + + /* we know this side has a radial_next because of the order of created verts in the quad */ + l_a_other = BM_edge_other_loop(l_a->e, l_a); + l_b_other = BM_edge_other_loop(l_a->e, l_b); + BM_elem_attrs_copy(bm, bm, l_a_other, l_a); + BM_elem_attrs_copy(bm, bm, l_b_other, l_b); + + /* step around to the opposite side of the quad - warning, this may have no other edges! */ + l_a = l_a->next->next; + l_b = l_a->next; + if (!BM_edge_is_boundary(l_a->e)) { + /* same as above */ + l_a_other = BM_edge_other_loop(l_a->e, l_a); + l_b_other = BM_edge_other_loop(l_a->e, l_b); + BM_elem_attrs_copy(bm, bm, l_a_other, l_a); + BM_elem_attrs_copy(bm, bm, l_b_other, l_b); + } + else { /* boundary edges have no useful data to copy from, use opposite side of face */ + /* swap a<->b intentionally */ + BM_elem_attrs_copy(bm, bm, l_a_other, l_b); + BM_elem_attrs_copy(bm, bm, l_b_other, l_a); + } + } +#endif } /* we could flag new edges/verts too, is it useful? */ - BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, ELE_NEW); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, ELE_NEW); /* cheap feature to add depth to the inset */ if (depth != 0.0f) { @@ -514,7 +551,7 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, FALSE); /* tag face verts */ - BMO_ITER (f, &oiter, bm, op, "faces", BM_FACE) { + BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) { BM_ITER_ELEM (v, &iter, f, BM_VERTS_OF_FACE) { BM_elem_flag_enable(v, BM_ELEM_TAG); } diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c index 3dbc0d0a5eb..1e18a83a0a0 100644 --- a/source/blender/bmesh/operators/bmo_join_triangles.c +++ b/source/blender/bmesh/operators/bmo_join_triangles.c @@ -204,16 +204,16 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op) BMEdge *e; BLI_array_declare(jedges); JoinEdge *jedges = NULL; - int do_sharp = BMO_slot_bool_get(op, "cmp_sharp"); - int do_uv = BMO_slot_bool_get(op, "cmp_uvs"); + int do_sharp = BMO_slot_bool_get(op->slots_in, "cmp_sharp"); + int do_uv = BMO_slot_bool_get(op->slots_in, "cmp_uvs"); int do_tf = do_uv; /* texture face, make make its own option eventually */ - int do_vcol = BMO_slot_bool_get(op, "cmp_vcols"); - int do_mat = BMO_slot_bool_get(op, "cmp_materials"); - float limit = BMO_slot_float_get(op, "limit"); + int do_vcol = BMO_slot_bool_get(op->slots_in, "cmp_vcols"); + int do_mat = BMO_slot_bool_get(op->slots_in, "cmp_materials"); + float limit = BMO_slot_float_get(op->slots_in, "limit"); int i, totedge; /* flag all edges of all input face */ - BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) { + BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) { BMO_elem_flag_enable(bm, f, FACE_INPUT); BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { BMO_elem_flag_enable(bm, l->e, EDGE_MARK); diff --git a/source/blender/bmesh/operators/bmo_mesh_conv.c b/source/blender/bmesh/operators/bmo_mesh_conv.c index c4b988ae82d..4b897a24c8a 100644 --- a/source/blender/bmesh/operators/bmo_mesh_conv.c +++ b/source/blender/bmesh/operators/bmo_mesh_conv.c @@ -53,9 +53,9 @@ void bmo_mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { - Object *ob = BMO_slot_ptr_get(op, "object"); - Mesh *me = BMO_slot_ptr_get(op, "mesh"); - int set_key = BMO_slot_bool_get(op, "set_shapekey"); + Object *ob = BMO_slot_ptr_get(op->slots_in, "object"); + Mesh *me = BMO_slot_ptr_get(op->slots_in, "mesh"); + int set_key = BMO_slot_bool_get(op->slots_in, "use_shapekey"); BM_mesh_bm_from_me(bm, me, set_key, ob->shapenr); @@ -66,20 +66,20 @@ void bmo_mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) void bmo_object_load_bmesh_exec(BMesh *bm, BMOperator *op) { - Object *ob = BMO_slot_ptr_get(op, "object"); + Object *ob = BMO_slot_ptr_get(op->slots_in, "object"); /* Scene *scene = BMO_slot_ptr_get(op, "scene"); */ Mesh *me = ob->data; BMO_op_callf(bm, op->flag, - "bmesh_to_mesh mesh=%p object=%p notessellation=%b", + "bmesh_to_mesh mesh=%p object=%p skip_tessface=%b", me, ob, TRUE); } void bmo_bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) { - Mesh *me = BMO_slot_ptr_get(op, "mesh"); + Mesh *me = BMO_slot_ptr_get(op->slots_in, "mesh"); /* Object *ob = BMO_slot_ptr_get(op, "object"); */ - int dotess = !BMO_slot_bool_get(op, "notessellation"); + int dotess = !BMO_slot_bool_get(op->slots_in, "skip_tessface"); BM_mesh_bm_to_me(bm, me, dotess); } diff --git a/source/blender/bmesh/operators/bmo_mirror.c b/source/blender/bmesh/operators/bmo_mirror.c index 937601712b0..01bce976ec0 100644 --- a/source/blender/bmesh/operators/bmo_mirror.c +++ b/source/blender/bmesh/operators/bmo_mirror.c @@ -50,27 +50,28 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) float mtx[4][4]; float imtx[4][4]; float scale[3] = {1.0f, 1.0f, 1.0f}; - float dist = BMO_slot_float_get(op, "mergedist"); + float dist = BMO_slot_float_get(op->slots_in, "merge_dist"); int i, ototvert /*, ototedge */; - int axis = BMO_slot_int_get(op, "axis"); - int mirroru = BMO_slot_bool_get(op, "mirror_u"); - int mirrorv = BMO_slot_bool_get(op, "mirror_v"); + int axis = BMO_slot_int_get(op->slots_in, "axis"); + int mirroru = BMO_slot_bool_get(op->slots_in, "mirror_u"); + int mirrorv = BMO_slot_bool_get(op->slots_in, "mirror_v"); + BMOpSlot *slot_targetmap; ototvert = bm->totvert; /* ototedge = bm->totedge; */ /* UNUSED */ - BMO_slot_mat4_get(op, "mat", mtx); + BMO_slot_mat4_get(op->slots_in, "mat", mtx); invert_m4_m4(imtx, mtx); BMO_op_initf(bm, &dupeop, op->flag, "duplicate geom=%s", op, "geom"); BMO_op_exec(bm, &dupeop); - BMO_slot_buffer_flag_enable(bm, &dupeop, "newout", BM_ALL, ELE_NEW); + BMO_slot_buffer_flag_enable(bm, dupeop.slots_out, "geom.out", BM_ALL, ELE_NEW); /* create old -> new mappin */ i = 0; /* v2 = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); */ /* UNUSED */ - BMO_ITER (v, &siter, bm, &dupeop, "newout", BM_VERT) { + BMO_ITER (v, &siter, dupeop.slots_out, "geom.out", BM_VERT) { BLI_array_grow_one(vmap); vmap[i] = v; /* v2 = BM_iter_step(&iter); */ /* UNUSED */ @@ -86,10 +87,12 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) BMO_op_init(bm, &weldop, op->flag, "weld_verts"); + slot_targetmap = BMO_slot_get(weldop.slots_in, "targetmap"); + v = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); for (i = 0; i < ototvert; i++) { if (fabsf(v->co[axis]) <= dist) { - BMO_slot_map_ptr_insert(bm, &weldop, "targetmap", vmap[i], v); + BMO_slot_map_ptr_insert(&weldop, slot_targetmap, vmap[i], v); } v = BM_iter_step(&iter); } @@ -101,7 +104,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) int totlayer; BMIter liter; - BMO_ITER (f, &siter, bm, &dupeop, "newout", BM_FACE) { + BMO_ITER (f, &siter, dupeop.slots_out, "geom.out", BM_FACE) { BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { totlayer = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV); for (i = 0; i < totlayer; i++) { @@ -120,7 +123,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) BMO_op_finish(bm, &weldop); BMO_op_finish(bm, &dupeop); - BMO_slot_buffer_from_enabled_flag(bm, op, "newout", BM_ALL, ELE_NEW); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_ALL, ELE_NEW); BLI_array_free(vmap); BLI_array_free(emap); diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c index d7b163cb760..71f63bbaf28 100644 --- a/source/blender/bmesh/operators/bmo_primitive.c +++ b/source/blender/bmesh/operators/bmo_primitive.c @@ -227,16 +227,17 @@ static signed char monkeyf[250][4] = { void bmo_create_grid_exec(BMesh *bm, BMOperator *op) { + const float dia = BMO_slot_float_get(op->slots_in, "size"); + const int tot = max_ii(2, BMO_slot_int_get(op->slots_in, "x_segments")); + const int seg = max_ii(2, BMO_slot_int_get(op->slots_in, "y_segments")); + BMOperator bmop, prevop; BMVert *eve, *preveve; BMEdge *e; - float vec[3], mat[4][4], phi, phid, dia = BMO_slot_float_get(op, "size"); - int a, tot = BMO_slot_int_get(op, "xsegments"), seg = BMO_slot_int_get(op, "ysegments"); - - if (tot < 2) tot = 2; - if (seg < 2) seg = 2; + float vec[3], mat[4][4], phi, phid; + int a; - BMO_slot_mat4_get(op, "mat", mat); + BMO_slot_mat4_get(op->slots_in, "mat", mat); /* one segment first: the X axis */ phi = 1.0f; @@ -267,39 +268,43 @@ void bmo_create_grid_exec(BMesh *bm, BMOperator *op) for (a = 0; a < seg - 1; a++) { if (a) { - BMO_op_initf(bm, &bmop, op->flag, "extrude_edge_only edges=%s", &prevop, "geomout"); + BMO_op_initf(bm, &bmop, op->flag, "extrude_edge_only edges=%S", &prevop, "geom.out"); BMO_op_exec(bm, &bmop); BMO_op_finish(bm, &prevop); - BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_VERT, VERT_MARK); + BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_VERT, VERT_MARK); } else { BMO_op_initf(bm, &bmop, op->flag, "extrude_edge_only edges=%fe", EDGE_ORIG); BMO_op_exec(bm, &bmop); - BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_VERT, VERT_MARK); + BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_VERT, VERT_MARK); } - BMO_op_callf(bm, op->flag, "translate vec=%v verts=%s", vec, &bmop, "geomout"); + BMO_op_callf(bm, op->flag, "translate vec=%v verts=%S", vec, &bmop, "geom.out"); prevop = bmop; } if (a) BMO_op_finish(bm, &bmop); - BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK); } void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op) { + const float dia = BMO_slot_float_get(op->slots_in, "diameter"); + const int seg = BMO_slot_int_get(op->slots_in, "u_segments"); + const int tot = BMO_slot_int_get(op->slots_in, "v_segments"); + BMOperator bmop, prevop; BMVert *eve, *preveve; BMEdge *e; BMIter iter; float vec[3], mat[4][4], cmat[3][3], phi, q[4]; - float phid, dia = BMO_slot_float_get(op, "diameter"); - int a, seg = BMO_slot_int_get(op, "segments"), tot = BMO_slot_int_get(op, "revolutions"); + float phid; + int a; - BMO_slot_mat4_get(op, "mat", mat); + BMO_slot_mat4_get(op->slots_in, "mat", mat); phid = 2.0f * (float)M_PI / tot; /* phi = 0.25f * (float)M_PI; */ /* UNUSED */ @@ -333,7 +338,7 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op) for (a = 0; a < seg; a++) { if (a) { - BMO_op_initf(bm, &bmop, op->flag, "extrude_edge_only edges=%s", &prevop, "geomout"); + BMO_op_initf(bm, &bmop, op->flag, "extrude_edge_only edges=%S", &prevop, "geom.out"); BMO_op_exec(bm, &bmop); BMO_op_finish(bm, &prevop); } @@ -342,8 +347,8 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op) BMO_op_exec(bm, &bmop); } - BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_VERT, VERT_MARK); - BMO_op_callf(bm, op->flag, "rotate cent=%v mat=%m3 verts=%s", vec, cmat, &bmop, "geomout"); + BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_VERT, VERT_MARK); + BMO_op_callf(bm, op->flag, "rotate cent=%v mat=%m3 verts=%S", vec, cmat, &bmop, "geom.out"); prevop = bmop; } @@ -375,30 +380,33 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op) } } - BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK); } void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op) { + const float dia = BMO_slot_float_get(op->slots_in, "diameter"); + const float dia_div = dia / 200.0f; + const int subdiv = BMO_slot_int_get(op->slots_in, "subdivisions"); + BMVert *eva[12]; BMVert *v; BMIter liter; BMIter viter; BMLoop *l; float vec[3], mat[4][4] /* , phi, phid */; - float dia = BMO_slot_float_get(op, "diameter"); - int a, subdiv = BMO_slot_int_get(op, "subdivisions"); + int a; - BMO_slot_mat4_get(op, "mat", mat); + BMO_slot_mat4_get(op->slots_in, "mat", mat); /* phid = 2.0f * (float)M_PI / subdiv; */ /* UNUSED */ /* phi = 0.25f * (float)M_PI; */ /* UNUSED */ - dia /= 200.0f; + for (a = 0; a < 12; a++) { - vec[0] = dia * icovert[a][0]; - vec[1] = dia * icovert[a][1]; - vec[2] = dia * icovert[a][2]; + vec[0] = dia_div * icovert[a][0]; + vec[1] = dia_div * icovert[a][1]; + vec[2] = dia_div * icovert[a][2]; eva[a] = BM_vert_create(bm, vec, NULL); BMO_elem_flag_enable(bm, eva[a], VERT_MARK); @@ -421,22 +429,20 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op) BMO_elem_flag_enable(bm, eftemp, FACE_MARK); } - dia *= 200.0f; - if (subdiv > 1) { BMOperator bmop; BMO_op_initf(bm, &bmop, op->flag, "subdivide_edges edges=%fe " "smooth=%f " - "numcuts=%i " + "cuts=%i " "use_gridfill=%b use_sphere=%b", EDGE_MARK, dia, (1 << (subdiv - 1)) - 1, TRUE, TRUE); BMO_op_exec(bm, &bmop); - BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_VERT, VERT_MARK); - BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_EDGE, EDGE_MARK); + BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_VERT, VERT_MARK); + BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_EDGE, EDGE_MARK); BMO_op_finish(bm, &bmop); } @@ -447,7 +453,7 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op) } } - BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK); } void bmo_create_monkey_exec(BMesh *bm, BMOperator *op) @@ -457,7 +463,7 @@ void bmo_create_monkey_exec(BMesh *bm, BMOperator *op) float mat[4][4]; int i; - BMO_slot_mat4_get(op, "mat", mat); + BMO_slot_mat4_get(op->slots_in, "mat", mat); for (i = 0; i < monkeynv; i++) { float v[3]; @@ -494,24 +500,25 @@ void bmo_create_monkey_exec(BMesh *bm, BMOperator *op) MEM_freeN(tv); - BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK); } void bmo_create_circle_exec(BMesh *bm, BMOperator *op) { + const float dia = BMO_slot_float_get(op->slots_in, "diameter"); + const int segs = BMO_slot_int_get(op->slots_in, "segments"); + const int cap_ends = BMO_slot_bool_get(op->slots_in, "cap_ends"); + const int cap_tris = BMO_slot_bool_get(op->slots_in, "cap_tris"); + BMVert *v1, *lastv1 = NULL, *cent1, *firstv1 = NULL; float vec[3], mat[4][4], phi, phid; - float dia = BMO_slot_float_get(op, "diameter"); - int segs = BMO_slot_int_get(op, "segments"); - int cap_ends = BMO_slot_bool_get(op, "cap_ends"); - int cap_tris = BMO_slot_bool_get(op, "cap_tris"); int a; if (!segs) return; - BMO_slot_mat4_get(op, "mat", mat); + BMO_slot_mat4_get(op->slots_in, "mat", mat); phid = 2.0f * (float)M_PI / segs; phi = 0; @@ -566,25 +573,25 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op) BMO_op_callf(bm, op->flag, "dissolve_faces faces=%ff", FACE_NEW); } - BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK); } void bmo_create_cone_exec(BMesh *bm, BMOperator *op) { BMVert *v1, *v2, *lastv1 = NULL, *lastv2 = NULL, *cent1, *cent2, *firstv1, *firstv2; float vec[3], mat[4][4], phi, phid; - float dia1 = BMO_slot_float_get(op, "diameter1"); - float dia2 = BMO_slot_float_get(op, "diameter2"); - float depth = BMO_slot_float_get(op, "depth"); - int segs = BMO_slot_int_get(op, "segments"); - int cap_ends = BMO_slot_bool_get(op, "cap_ends"); - int cap_tris = BMO_slot_bool_get(op, "cap_tris"); + float dia1 = BMO_slot_float_get(op->slots_in, "diameter1"); + float dia2 = BMO_slot_float_get(op->slots_in, "diameter2"); + float depth = BMO_slot_float_get(op->slots_in, "depth"); + int segs = BMO_slot_int_get(op->slots_in, "segments"); + int cap_ends = BMO_slot_bool_get(op->slots_in, "cap_ends"); + int cap_tris = BMO_slot_bool_get(op->slots_in, "cap_tris"); int a; if (!segs) return; - BMO_slot_mat4_get(op, "mat", mat); + BMO_slot_mat4_get(op->slots_in, "mat", mat); phid = 2.0f * (float)M_PI / segs; phi = 0; @@ -662,15 +669,15 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op) BM_face_create_quad_tri(bm, v1, v2, firstv2, firstv1, NULL, FALSE); BMO_op_callf(bm, op->flag, "remove_doubles verts=%fv dist=%f", VERT_MARK, 0.000001); - BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK); } void bmo_create_cube_exec(BMesh *bm, BMOperator *op) { BMVert *v1, *v2, *v3, *v4, *v5, *v6, *v7, *v8; - float vec[3], mat[4][4], off = BMO_slot_float_get(op, "size") / 2.0f; + float vec[3], mat[4][4], off = BMO_slot_float_get(op->slots_in, "size") / 2.0f; - BMO_slot_mat4_get(op, "mat", mat); + BMO_slot_mat4_get(op->slots_in, "mat", mat); if (!off) off = 0.5f; @@ -740,5 +747,5 @@ void bmo_create_cube_exec(BMesh *bm, BMOperator *op) BM_face_create_quad_tri(bm, v1, v2, v3, v4, NULL, FALSE); BM_face_create_quad_tri(bm, v8, v7, v6, v5, NULL, FALSE); - BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK); } diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c index ea6cd747037..45e678b96bb 100644 --- a/source/blender/bmesh/operators/bmo_removedoubles.c +++ b/source/blender/bmesh/operators/bmo_removedoubles.c @@ -36,7 +36,7 @@ #include "intern/bmesh_operators_private.h" /* own include */ -static void remdoubles_splitface(BMFace *f, BMesh *bm, BMOperator *op) +static void remdoubles_splitface(BMFace *f, BMesh *bm, BMOperator *op, BMOpSlot *slot_targetmap) { BMIter liter; BMLoop *l; @@ -44,7 +44,7 @@ static void remdoubles_splitface(BMFace *f, BMesh *bm, BMOperator *op) int split = FALSE; BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { - v2 = BMO_slot_map_ptr_get(bm, op, "targetmap", l->v); + v2 = BMO_slot_map_ptr_get(slot_targetmap, l->v); /* ok: if v2 is NULL (e.g. not in the map) then it's * a target vert, otherwise it's a double */ if ((v2 && BM_vert_in_face(f, v2)) && @@ -61,8 +61,8 @@ static void remdoubles_splitface(BMFace *f, BMesh *bm, BMOperator *op) BMLoop *nl; BMFace *f2 = BM_face_split(bm, f, doub, v2, &nl, NULL, FALSE); - remdoubles_splitface(f, bm, op); - remdoubles_splitface(f2, bm, op); + remdoubles_splitface(f, bm, op, slot_targetmap); + remdoubles_splitface(f2, bm, op, slot_targetmap); } } @@ -106,10 +106,11 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op) BLI_array_declare(loops); BMFace *f, *f2; int a, b; + BMOpSlot *slot_targetmap = BMO_slot_get(op->slots_in, "targetmap"); /* mark merge verts for deletion */ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - if ((v2 = BMO_slot_map_ptr_get(bm, op, "targetmap", v))) { + if ((v2 = BMO_slot_map_ptr_get(slot_targetmap, v))) { BMO_elem_flag_enable(bm, v, ELE_DEL); /* merge the vertex flags, else we get randomly selected/unselected verts */ @@ -120,13 +121,13 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op) /* check if any faces are getting their own corners merged * together, split face if so */ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - remdoubles_splitface(f, bm, op); + remdoubles_splitface(f, bm, op, slot_targetmap); } BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { if (BMO_elem_flag_test(bm, e->v1, ELE_DEL) || BMO_elem_flag_test(bm, e->v2, ELE_DEL)) { - v = BMO_slot_map_ptr_get(bm, op, "targetmap", e->v1); - v2 = BMO_slot_map_ptr_get(bm, op, "targetmap", e->v2); + v = BMO_slot_map_ptr_get(slot_targetmap, e->v1); + v2 = BMO_slot_map_ptr_get(slot_targetmap, e->v2); if (!v) v = e->v1; if (!v2) v2 = e->v2; @@ -174,10 +175,10 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op) v = l->v; v2 = l->next->v; if (BMO_elem_flag_test(bm, v, ELE_DEL)) { - v = BMO_slot_map_ptr_get(bm, op, "targetmap", v); + v = BMO_slot_map_ptr_get(slot_targetmap, v); } if (BMO_elem_flag_test(bm, v2, ELE_DEL)) { - v2 = BMO_slot_map_ptr_get(bm, op, "targetmap", v2); + v2 = BMO_slot_map_ptr_get(slot_targetmap, v2); } e2 = v != v2 ? BM_edge_exists(v, v2) : NULL; @@ -207,10 +208,10 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op) v2 = loops[1]->v; if (BMO_elem_flag_test(bm, v, ELE_DEL)) { - v = BMO_slot_map_ptr_get(bm, op, "targetmap", v); + v = BMO_slot_map_ptr_get(slot_targetmap, v); } if (BMO_elem_flag_test(bm, v2, ELE_DEL)) { - v2 = BMO_slot_map_ptr_get(bm, op, "targetmap", v2); + v2 = BMO_slot_map_ptr_get(slot_targetmap, v2); } f2 = BM_face_create_ngon(bm, v, v2, edges, a, TRUE); @@ -262,7 +263,7 @@ void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op) float fac; int i, tot; - snapv = BMO_iter_new(&siter, bm, op, "snapv", BM_VERT); + snapv = BMO_iter_new(&siter, op->slots_in, "snapv", BM_VERT); tot = BM_vert_face_count(snapv); if (!tot) @@ -290,7 +291,7 @@ void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op) } } - BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { + BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) { BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) { if (l == firstl) { continue; @@ -318,7 +319,7 @@ void bmo_average_vert_facedata_exec(BMesh *bm, BMOperator *op) type = bm->ldata.layers[i].type; CustomData_data_initminmax(type, &min, &max); - BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { + BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) { BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) { block = CustomData_bmesh_get_layer_n(&bm->ldata, l->head.data, i); CustomData_data_dominmax(type, block, &min, &max); @@ -329,7 +330,7 @@ void bmo_average_vert_facedata_exec(BMesh *bm, BMOperator *op) CustomData_data_multiply(type, &max, 0.5f); CustomData_data_add(type, &min, &max); - BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { + BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) { BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) { block = CustomData_bmesh_get_layer_n(&bm->ldata, l->head.data, i); CustomData_data_copy_value(type, &min, block); @@ -344,19 +345,22 @@ void bmo_pointmerge_exec(BMesh *bm, BMOperator *op) BMOIter siter; BMVert *v, *snapv = NULL; float vec[3]; + BMOpSlot *slot_targetmap; - BMO_slot_vec_get(op, "merge_co", vec); + BMO_slot_vec_get(op->slots_in, "merge_co", vec); //BMO_op_callf(bm, op->flag, "collapse_uvs edges=%s", op, "edges"); BMO_op_init(bm, &weldop, op->flag, "weld_verts"); - - BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { + + slot_targetmap = BMO_slot_get(weldop.slots_in, "targetmap"); + + BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) { if (!snapv) { snapv = v; copy_v3_v3(snapv->co, vec); } else { - BMO_slot_map_ptr_insert(bm, &weldop, "targetmap", v, snapv); + BMO_slot_map_ptr_insert(&weldop, slot_targetmap, v, snapv); } } @@ -373,11 +377,13 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op) BLI_array_declare(edges); float min[3], max[3], center[3]; int i, tot; + BMOpSlot *slot_targetmap; BMO_op_callf(bm, op->flag, "collapse_uvs edges=%s", op, "edges"); BMO_op_init(bm, &weldop, op->flag, "weld_verts"); + slot_targetmap = BMO_slot_get(weldop.slots_in, "targetmap"); - BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK); BMW_init(&walker, bm, BMW_SHELL, BMW_MASK_NOP, EDGE_MARK, BMW_MASK_NOP, @@ -408,9 +414,9 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op) copy_v3_v3(edges[i]->v2->co, center); if (edges[i]->v1 != edges[0]->v1) - BMO_slot_map_ptr_insert(bm, &weldop, "targetmap", edges[i]->v1, edges[0]->v1); + BMO_slot_map_ptr_insert(&weldop, slot_targetmap, edges[i]->v1, edges[0]->v1); if (edges[i]->v2 != edges[0]->v1) - BMO_slot_map_ptr_insert(bm, &weldop, "targetmap", edges[i]->v2, edges[0]->v1); + BMO_slot_map_ptr_insert(&weldop, slot_targetmap, edges[i]->v2, edges[0]->v1); } } @@ -436,7 +442,7 @@ static void bmo_collapsecon_do_layer(BMesh *bm, BMOperator *op, int layer) /* clear all short flags */ BMO_mesh_flag_disable_all(bm, op, BM_ALL, (1 << 16) - 1); - BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK); BMW_init(&walker, bm, BMW_LOOPDATA_ISLAND, BMW_MASK_NOP, EDGE_MARK, BMW_MASK_NOP, @@ -486,31 +492,32 @@ void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op) } } -static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, const char *targetmapname) +static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, + BMOperator *optarget, BMOpSlot *optarget_slot) { BMVert **verts; int verts_len; int i, j, keepvert = 0; - const float dist = BMO_slot_float_get(op, "dist"); + const float dist = BMO_slot_float_get(op->slots_in, "dist"); const float dist3 = dist * 3.0f; /* Test whether keep_verts arg exists and is non-empty */ - if (BMO_slot_exists(op, "keep_verts")) { + if (BMO_slot_exists(op->slots_in, "keep_verts")) { BMOIter oiter; - keepvert = BMO_iter_new(&oiter, bm, op, "keep_verts", BM_VERT) != NULL; + keepvert = BMO_iter_new(&oiter, op->slots_in, "keep_verts", BM_VERT) != NULL; } /* get the verts as an array we can sort */ - verts = BMO_slot_as_arrayN(op, "verts", &verts_len); + verts = BMO_slot_as_arrayN(op->slots_in, "verts", &verts_len); /* sort by vertex coordinates added together */ qsort(verts, verts_len, sizeof(BMVert *), vergaverco); /* Flag keep_verts */ if (keepvert) { - BMO_slot_buffer_flag_enable(bm, op, "keep_verts", BM_VERT, VERT_KEEP); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "keep_verts", BM_VERT, VERT_KEEP); } for (i = 0; i < verts_len; i++) { @@ -547,7 +554,7 @@ static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *opt BMO_elem_flag_enable(bm, v_other, VERT_DOUBLE); BMO_elem_flag_enable(bm, v_check, VERT_TARGET); - BMO_slot_map_ptr_insert(bm, optarget, targetmapname, v_other, v_check); + BMO_slot_map_ptr_insert(optarget, optarget_slot, v_other, v_check); } } } @@ -558,9 +565,12 @@ static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *opt void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op) { BMOperator weldop; + BMOpSlot *slot_targetmap; BMO_op_init(bm, &weldop, op->flag, "weld_verts"); - bmesh_find_doubles_common(bm, op, &weldop, "targetmap"); + slot_targetmap = BMO_slot_get(weldop.slots_in, "targetmap"); + bmesh_find_doubles_common(bm, op, + &weldop, slot_targetmap); BMO_op_exec(bm, &weldop); BMO_op_finish(bm, &weldop); } @@ -568,7 +578,10 @@ void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op) void bmo_find_doubles_exec(BMesh *bm, BMOperator *op) { - bmesh_find_doubles_common(bm, op, op, "targetmapout"); + BMOpSlot *slot_targetmap_out; + slot_targetmap_out = BMO_slot_get(op->slots_out, "targetmap.out"); + bmesh_find_doubles_common(bm, op, + op, slot_targetmap_out); } void bmo_automerge_exec(BMesh *bm, BMOperator *op) @@ -580,7 +593,7 @@ void bmo_automerge_exec(BMesh *bm, BMOperator *op) /* The "verts" input sent to this op is the set of verts that * can be merged away into any other verts. Mark all other verts * as VERT_KEEP. */ - BMO_slot_buffer_flag_enable(bm, op, "verts", BM_VERT, VERT_IN); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "verts", BM_VERT, VERT_IN); BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) { if (!BMO_elem_flag_test(bm, v, VERT_IN)) { BMO_elem_flag_enable(bm, v, VERT_KEEP); @@ -590,12 +603,14 @@ void bmo_automerge_exec(BMesh *bm, BMOperator *op) /* Search for doubles among all vertices, but only merge non-VERT_KEEP * vertices into VERT_KEEP vertices. */ BMO_op_initf(bm, &findop, op->flag, "find_doubles verts=%av keep_verts=%fv", VERT_KEEP); - BMO_slot_copy(op, &findop, "dist", "dist"); + BMO_slot_copy(op, slots_in, "dist", + &findop, slots_in, "dist"); BMO_op_exec(bm, &findop); /* weld the vertices */ BMO_op_init(bm, &weldop, op->flag, "weld_verts"); - BMO_slot_copy(&findop, &weldop, "targetmapout", "targetmap"); + BMO_slot_copy(&findop, slots_out, "targetmap.out", + &weldop, slots_in, "targetmap"); BMO_op_exec(bm, &weldop); BMO_op_finish(bm, &findop); diff --git a/source/blender/bmesh/operators/bmo_similar.c b/source/blender/bmesh/operators/bmo_similar.c index 0954cfafb38..74f77d538bd 100644 --- a/source/blender/bmesh/operators/bmo_similar.c +++ b/source/blender/bmesh/operators/bmo_similar.c @@ -103,10 +103,10 @@ void bmo_similar_faces_exec(BMesh *bm, BMOperator *op) SimSel_FaceExt *f_ext = NULL; int *indices = NULL; float t_no[3]; /* temporary normal */ - const int type = BMO_slot_int_get(op, "type"); - const float thresh = BMO_slot_float_get(op, "thresh"); + const int type = BMO_slot_int_get(op->slots_in, "type"); + const float thresh = BMO_slot_float_get(op->slots_in, "thresh"); const float thresh_radians = thresh * (float)M_PI; - const int compare = BMO_slot_int_get(op, "compare"); + const int compare = BMO_slot_int_get(op->slots_in, "compare"); /* initial_elem - other_elem */ float delta_fl; @@ -121,7 +121,7 @@ void bmo_similar_faces_exec(BMesh *bm, BMOperator *op) * so the overall complexity will be less than $O(mn)$ where is the total number of selected faces, * and n is the total number of faces */ - BMO_ITER (fs, &fs_iter, bm, op, "faces", BM_FACE) { + BMO_ITER (fs, &fs_iter, op->slots_in, "faces", BM_FACE) { if (!BMO_elem_flag_test(bm, fs, FACE_MARK)) { /* is this really needed ? */ BMO_elem_flag_enable(bm, fs, FACE_MARK); num_sels++; @@ -262,7 +262,7 @@ void bmo_similar_faces_exec(BMesh *bm, BMOperator *op) MEM_freeN(indices); /* transfer all marked faces to the output slot */ - BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, FACE_MARK); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, FACE_MARK); #undef FACE_MARK } @@ -305,9 +305,9 @@ void bmo_similar_edges_exec(BMesh *bm, BMOperator *op) float angle; int num_sels = 0, num_total = 0; - const int type = BMO_slot_int_get(op, "type"); - const float thresh = BMO_slot_float_get(op, "thresh"); - const int compare = BMO_slot_int_get(op, "compare"); + const int type = BMO_slot_int_get(op->slots_in, "type"); + const float thresh = BMO_slot_float_get(op->slots_in, "thresh"); + const int compare = BMO_slot_int_get(op->slots_in, "compare"); /* initial_elem - other_elem */ float delta_fl; @@ -330,7 +330,7 @@ void bmo_similar_edges_exec(BMesh *bm, BMOperator *op) num_total = BM_mesh_elem_count(bm, BM_EDGE); /* iterate through all selected edges and mark them */ - BMO_ITER (es, &es_iter, bm, op, "edges", BM_EDGE) { + BMO_ITER (es, &es_iter, op->slots_in, "edges", BM_EDGE) { BMO_elem_flag_enable(bm, es, EDGE_MARK); num_sels++; } @@ -486,7 +486,7 @@ void bmo_similar_edges_exec(BMesh *bm, BMOperator *op) MEM_freeN(indices); /* transfer all marked edges to the output slot */ - BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, EDGE_MARK); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, EDGE_MARK); #undef EDGE_MARK } @@ -519,10 +519,10 @@ void bmo_similar_verts_exec(BMesh *bm, BMOperator *op) SimSel_VertExt *v_ext = NULL; int *indices = NULL; int num_total = 0, num_sels = 0, i = 0, idx = 0; - const int type = BMO_slot_int_get(op, "type"); - const float thresh = BMO_slot_float_get(op, "thresh"); + const int type = BMO_slot_int_get(op->slots_in, "type"); + const float thresh = BMO_slot_float_get(op->slots_in, "thresh"); const float thresh_radians = thresh * (float)M_PI; - const int compare = BMO_slot_int_get(op, "compare"); + const int compare = BMO_slot_int_get(op->slots_in, "compare"); /* initial_elem - other_elem */ // float delta_fl; @@ -531,7 +531,7 @@ void bmo_similar_verts_exec(BMesh *bm, BMOperator *op) num_total = BM_mesh_elem_count(bm, BM_VERT); /* iterate through all selected edges and mark them */ - BMO_ITER (vs, &vs_iter, bm, op, "verts", BM_VERT) { + BMO_ITER (vs, &vs_iter, op->slots_in, "verts", BM_VERT) { BMO_elem_flag_enable(bm, vs, VERT_MARK); num_sels++; } @@ -620,7 +620,7 @@ void bmo_similar_verts_exec(BMesh *bm, BMOperator *op) MEM_freeN(indices); MEM_freeN(v_ext); - BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK); #undef VERT_MARK } diff --git a/source/blender/bmesh/operators/bmo_slide.c b/source/blender/bmesh/operators/bmo_slide.c index 6db76119205..9dde2461364 100644 --- a/source/blender/bmesh/operators/bmo_slide.c +++ b/source/blender/bmesh/operators/bmo_slide.c @@ -53,10 +53,10 @@ void bmo_slide_vert_exec(BMesh *bm, BMOperator *op) int selected_edges = 0; /* Get slide amount */ - const float distance_t = BMO_slot_float_get(op, "distance_t"); + const float distance_t = BMO_slot_float_get(op->slots_in, "distance_t"); /* Get start vertex */ - vertex = BMO_iter_new(&oiter, bm, op, "vert", BM_VERT); + vertex = BMO_iter_new(&oiter, op->slots_in, "vert", BM_VERT); if (!vertex) { @@ -68,7 +68,7 @@ void bmo_slide_vert_exec(BMesh *bm, BMOperator *op) } /* Count selected edges */ - BMO_ITER (h, &oiter, bm, op, "edge", BM_VERT | BM_EDGE) { + BMO_ITER (h, &oiter, op->slots_in, "edge", BM_VERT | BM_EDGE) { switch (h->htype) { case BM_EDGE: selected_edges++; @@ -108,7 +108,7 @@ void bmo_slide_vert_exec(BMesh *bm, BMOperator *op) } /* Return the new edge. The same previously marked with VERT_MARK */ - BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK); return; } diff --git a/source/blender/bmesh/operators/bmo_smooth_laplacian.c b/source/blender/bmesh/operators/bmo_smooth_laplacian.c index 362123e412d..4137c31961c 100644 --- a/source/blender/bmesh/operators/bmo_smooth_laplacian.c +++ b/source/blender/bmesh/operators/bmo_smooth_laplacian.c @@ -78,8 +78,8 @@ static void delete_laplacian_system(LaplacianSystem *sys); static void delete_void_pointer(void *data); static void fill_laplacian_matrix(LaplacianSystem *sys); static void memset_laplacian_system(LaplacianSystem *sys, int val); -static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez, int volumepreservation); -static void volume_preservation(BMesh *bm, BMOperator *op, float vini, float vend, int usex, int usey, int usez); +static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez, int preserve_volume); +static void volume_preservation(BMOperator *op, float vini, float vend, int usex, int usey, int usez); static void delete_void_pointer(void *data) { @@ -455,7 +455,7 @@ static float compute_volume(BMesh *bm) return fabs(vol); } -static void volume_preservation(BMesh *bm, BMOperator *op, float vini, float vend, int usex, int usey, int usez) +static void volume_preservation(BMOperator *op, float vini, float vend, int usex, int usey, int usez) { float beta; BMOIter siter; @@ -463,9 +463,9 @@ static void volume_preservation(BMesh *bm, BMOperator *op, float vini, float ven if (vend != 0.0f) { beta = pow(vini / vend, 1.0f / 3.0f); - BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { + BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) { if (usex) { - v->co[0] *= beta; + v->co[0] *= beta; } if (usey) { v->co[1] *= beta; @@ -478,7 +478,7 @@ static void volume_preservation(BMesh *bm, BMOperator *op, float vini, float ven } } -static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez, int volumepreservation) +static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez, int preserve_volume) { int m_vertex_id; float leni, lene; @@ -509,10 +509,10 @@ static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez } } - if (volumepreservation) { + if (preserve_volume) { vini = compute_volume(sys->bm); } - BMO_ITER (v, &siter, sys->bm, sys->op, "verts", BM_VERT) { + BMO_ITER (v, &siter, sys->op->slots_in, "verts", BM_VERT) { m_vertex_id = BM_elem_index_get(v); if (sys->zerola[m_vertex_id] == 0) { if (usex) { @@ -526,9 +526,9 @@ static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez } } } - if (volumepreservation) { + if (preserve_volume) { vend = compute_volume(sys->bm); - volume_preservation(sys->bm, sys->op, vini, vend, usex, usey, usez); + volume_preservation(sys->op, vini, vend, usex, usey, usez); } } @@ -537,7 +537,7 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op) { int i; int m_vertex_id; - int usex, usey, usez, volumepreservation; + int usex, usey, usez, preserve_volume; float lambda, lambda_border; float w; BMOIter siter; @@ -552,13 +552,13 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op) memset_laplacian_system(sys, 0); BM_mesh_elem_index_ensure(bm, BM_VERT); - lambda = BMO_slot_float_get(op, "lambda"); - lambda_border = BMO_slot_float_get(op, "lambda_border"); + lambda = BMO_slot_float_get(op->slots_in, "lambda"); + lambda_border = BMO_slot_float_get(op->slots_in, "lambda_border"); sys->min_area = 0.00001f; - usex = BMO_slot_bool_get(op, "use_x"); - usey = BMO_slot_bool_get(op, "use_y"); - usez = BMO_slot_bool_get(op, "use_z"); - volumepreservation = BMO_slot_bool_get(op, "volume_preservation"); + usex = BMO_slot_bool_get(op->slots_in, "use_x"); + usey = BMO_slot_bool_get(op->slots_in, "use_y"); + usez = BMO_slot_bool_get(op->slots_in, "use_z"); + preserve_volume = BMO_slot_bool_get(op->slots_in, "preserve_volume"); nlNewContext(); @@ -573,7 +573,7 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op) for (i = 0; i < bm->totvert; i++) { nlLockVariable(i); } - BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { + BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) { m_vertex_id = BM_elem_index_get(v); nlUnlockVariable(m_vertex_id); nlSetVariable(0, m_vertex_id, v->co[0]); @@ -583,7 +583,7 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op) nlBegin(NL_MATRIX); init_laplacian_matrix(sys); - BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { + BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) { m_vertex_id = BM_elem_index_get(v); nlRightHandSideAdd(0, m_vertex_id, v->co[0]); nlRightHandSideAdd(1, m_vertex_id, v->co[1]); @@ -612,7 +612,7 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op) nlEnd(NL_SYSTEM); if (nlSolveAdvanced(NULL, NL_TRUE) ) { - validate_solution(sys, usex, usey, usez, volumepreservation); + validate_solution(sys, usex, usey, usez, preserve_volume); } delete_laplacian_system(sys); diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index b2f6761b1bc..f9b6611c88b 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -225,8 +225,9 @@ static BMVert *subdivideedgenum(BMesh *bm, BMEdge *edge, BMEdge *oedge, BMVert *ev; float percent, percent2 = 0.0f; - if (BMO_elem_flag_test(bm, edge, EDGE_PERCENT) && totpoint == 1) - percent = BMO_slot_map_float_get(bm, params->op, "edgepercents", edge); + if (BMO_elem_flag_test(bm, edge, EDGE_PERCENT) && totpoint == 1) { + percent = BMO_slot_map_float_get(params->slot_edgepercents, edge); + } else { percent = 1.0f / (float)(totpoint + 1 - curpoint); percent2 = (float)(curpoint + 1) / (float)(totpoint + 1); @@ -717,18 +718,18 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) int use_sphere, cornertype, use_singleedge, use_gridfill; int skey, seed, i, j, matched, a, b, numcuts, totesel; - BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, SUBD_SPLIT); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, SUBD_SPLIT); - numcuts = BMO_slot_int_get(op, "numcuts"); - seed = BMO_slot_int_get(op, "seed"); - smooth = BMO_slot_float_get(op, "smooth"); - fractal = BMO_slot_float_get(op, "fractal"); - along_normal = BMO_slot_float_get(op, "along_normal"); - cornertype = BMO_slot_int_get(op, "quadcornertype"); - - use_singleedge = BMO_slot_bool_get(op, "use_singleedge"); - use_gridfill = BMO_slot_bool_get(op, "use_gridfill"); - use_sphere = BMO_slot_bool_get(op, "use_sphere"); + numcuts = BMO_slot_int_get(op->slots_in, "cuts"); + seed = BMO_slot_int_get(op->slots_in, "seed"); + smooth = BMO_slot_float_get(op->slots_in, "smooth"); + fractal = BMO_slot_float_get(op->slots_in, "fractal"); + along_normal = BMO_slot_float_get(op->slots_in, "along_normal"); + cornertype = BMO_slot_int_get(op->slots_in, "quad_corner_type"); + + use_singleedge = BMO_slot_bool_get(op->slots_in, "use_singleedge"); + use_gridfill = BMO_slot_bool_get(op->slots_in, "use_gridfill"); + use_sphere = BMO_slot_bool_get(op->slots_in, "use_sphere"); BLI_srandom(seed); @@ -774,10 +775,12 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) } /* first go through and tag edges */ - BMO_slot_buffer_from_enabled_flag(bm, op, "edges", BM_EDGE, SUBD_SPLIT); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_in, "edges", BM_EDGE, SUBD_SPLIT); params.numcuts = numcuts; params.op = op; + params.slot_edgepercents = BMO_slot_get(op->slots_in, "edgepercents"); + params.slot_custompatterns = BMO_slot_get(op->slots_in, "custompatterns"); params.smooth = smooth; params.seed = seed; params.fractal = fractal; @@ -790,10 +793,10 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) params.off[1] = (float)BLI_drand() * 200.0f; params.off[2] = (float)BLI_drand() * 200.0f; - BMO_slot_map_to_flag(bm, op, "custompatterns", + BMO_slot_map_to_flag(bm, op->slots_in, "custompatterns", BM_FACE, FACE_CUSTOMFILL); - BMO_slot_map_to_flag(bm, op, "edgepercents", + BMO_slot_map_to_flag(bm, op->slots_in, "edgepercents", BM_EDGE, EDGE_PERCENT); @@ -837,8 +840,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) } if (BMO_elem_flag_test(bm, face, FACE_CUSTOMFILL)) { - pat = BMO_slot_map_data_get(bm, op, - "custompatterns", face); + pat = BMO_slot_map_data_get(params.slot_custompatterns, face); for (i = 0; i < pat->len; i++) { matched = 1; for (j = 0; j < pat->len; j++) { @@ -910,11 +912,11 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) } } - einput = BMO_slot_get(op, "edges"); + einput = BMO_slot_get(op->slots_in, "edges"); /* go through and split edges */ for (i = 0; i < einput->len; i++) { - edge = ((BMEdge **)einput->data.p)[i]; + edge = einput->data.buf[i]; bm_subdivide_multicut(bm, edge, ¶ms, edge->v1, edge->v2); } @@ -1075,10 +1077,10 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) BLI_array_free(loops_split); BLI_array_free(loops); - BMO_slot_buffer_from_enabled_flag(bm, op, "outinner", BM_ALL, ELE_INNER); - BMO_slot_buffer_from_enabled_flag(bm, op, "outsplit", BM_ALL, ELE_SPLIT); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_inner.out", BM_ALL, ELE_INNER); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_split.out", BM_ALL, ELE_SPLIT); - BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, ELE_INNER | ELE_SPLIT | SUBD_SPLIT); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_ALL, ELE_INNER | ELE_SPLIT | SUBD_SPLIT); } /* editmesh-emulating function */ @@ -1095,8 +1097,8 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, BMO_op_initf(bm, &op, BMO_FLAG_DEFAULTS, "subdivide_edges edges=%he " "smooth=%f fractal=%f along_normal=%f " - "numcuts=%i " - "quadcornertype=%i " + "cuts=%i " + "quad_corner_type=%i " "use_singleedge=%b use_gridfill=%b " "seed=%i", edge_hflag, @@ -1112,7 +1114,7 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, BMOIter iter; BMElem *ele; - for (ele = BMO_iter_new(&iter, bm, &op, "outinner", BM_EDGE | BM_VERT); ele; ele = BMO_iter_step(&iter)) { + for (ele = BMO_iter_new(&iter, op.slots_out, "geom_inner.out", BM_EDGE | BM_VERT); ele; ele = BMO_iter_step(&iter)) { BM_elem_select_set(bm, ele, TRUE); } } @@ -1123,7 +1125,7 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, /* deselect input */ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); - for (ele = BMO_iter_new(&iter, bm, &op, "outinner", BM_EDGE | BM_VERT); ele; ele = BMO_iter_step(&iter)) { + for (ele = BMO_iter_new(&iter, op.slots_out, "geom_inner.out", BM_EDGE | BM_VERT); ele; ele = BMO_iter_step(&iter)) { BM_elem_select_set(bm, ele, TRUE); if (ele->head.htype == BM_VERT) { @@ -1158,8 +1160,9 @@ void bmo_bisect_edges_exec(BMesh *bm, BMOperator *op) SubDParams params = {0}; int skey; - params.numcuts = BMO_slot_int_get(op, "numcuts"); + params.numcuts = BMO_slot_int_get(op->slots_in, "cuts"); params.op = op; + params.slot_edgepercents = BMO_slot_get(op->slots_in, "edgepercents"); BM_data_layer_add(bm, &bm->vdata, CD_SHAPEKEY); skey = CustomData_number_of_layers(&bm->vdata, CD_SHAPEKEY) - 1; @@ -1167,11 +1170,11 @@ void bmo_bisect_edges_exec(BMesh *bm, BMOperator *op) params.origkey = skey; /* go through and split edges */ - BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { bm_subdivide_multicut(bm, e, ¶ms, e->v1, e->v2); } - BMO_slot_buffer_from_enabled_flag(bm, op, "outsplit", BM_ALL, ELE_SPLIT); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_split.out", BM_ALL, ELE_SPLIT); BM_data_layer_free_n(bm, &bm->vdata, CD_SHAPEKEY, skey); } diff --git a/source/blender/bmesh/operators/bmo_subdivide.h b/source/blender/bmesh/operators/bmo_subdivide.h index d4b926b9275..d0676508917 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.h +++ b/source/blender/bmesh/operators/bmo_subdivide.h @@ -39,6 +39,8 @@ typedef struct SubDParams { int seed; int origkey; /* shapekey holding displaced vertex coordinates for current geometry */ BMOperator *op; + BMOpSlot *slot_edgepercents; /* BMO_slot_get(params->op->slots_in, "edgepercents"); */ + BMOpSlot *slot_custompatterns; /* BMO_slot_get(params->op->slots_in, "custompatterns"); */ float off[3]; } SubDParams; diff --git a/source/blender/bmesh/operators/bmo_symmetrize.c b/source/blender/bmesh/operators/bmo_symmetrize.c index 5d4698a0c7a..8c440cae83e 100644 --- a/source/blender/bmesh/operators/bmo_symmetrize.c +++ b/source/blender/bmesh/operators/bmo_symmetrize.c @@ -96,7 +96,7 @@ static void symm_verts_mirror(Symm *symm) symm->vert_symm_map = BLI_ghash_ptr_new(AT); - BMO_ITER (src_v, &oiter, symm->bm, symm->op, "input", BM_VERT) { + BMO_ITER (src_v, &oiter, symm->op->slots_in, "input", BM_VERT) { SymmSide side = symm_co_side(symm, src_v->co); float co[3]; @@ -145,7 +145,7 @@ static void symm_split_asymmetric_edges(Symm *symm) symm->edge_split_map = BLI_ghash_ptr_new(AT); - BMO_ITER (e, &oiter, symm->bm, symm->op, "input", BM_EDGE) { + BMO_ITER (e, &oiter, symm->op->slots_in, "input", BM_EDGE) { float flipped[3]; copy_v3_v3(flipped, e->v1->co); @@ -195,7 +195,7 @@ static void symm_mirror_edges(Symm *symm) BMOIter oiter; BMEdge *e; - BMO_ITER (e, &oiter, symm->bm, symm->op, "input", BM_EDGE) { + BMO_ITER (e, &oiter, symm->op->slots_in, "input", BM_EDGE) { BMVert *v1 = NULL, *v2 = NULL; BMEdge *e_new; @@ -448,7 +448,7 @@ static void symm_mirror_polygons(Symm *symm) BLI_array_declare(fv); BLI_array_declare(fe); - BMO_ITER (f, &oiter, symm->bm, symm->op, "input", BM_FACE) { + BMO_ITER (f, &oiter, symm->op->slots_in, "input", BM_FACE) { BMIter iter; BMLoop *l; int mirror_all = TRUE, ignore_all = TRUE; @@ -607,7 +607,7 @@ static void symm_kill_unused(Symm *symm) BMVert *v; /* Kill unused edges */ - BMO_ITER (e, &oiter, symm->bm, symm->op, "input", BM_EDGE) { + BMO_ITER (e, &oiter, symm->op->slots_in, "input", BM_EDGE) { const int crosses = symm_edge_crosses_axis(symm, e); const int symmetric = (crosses && (!BLI_ghash_haskey(symm->edge_split_map, e))); @@ -623,7 +623,7 @@ static void symm_kill_unused(Symm *symm) } /* Kill unused vertices */ - BMO_ITER (v, &oiter, symm->bm, symm->op, "input", BM_VERT) { + BMO_ITER (v, &oiter, symm->op->slots_in, "input", BM_VERT) { if (symm_co_side(symm, v->co) == SYMM_SIDE_KILL) { if (BM_vert_edge_count(v) == 0) BM_vert_kill(symm->bm, v); @@ -634,7 +634,7 @@ static void symm_kill_unused(Symm *symm) void bmo_symmetrize_exec(BMesh *bm, BMOperator *op) { Symm symm; - BMO_SymmDirection direction = BMO_slot_int_get(op, "direction"); + BMO_SymmDirection direction = BMO_slot_int_get(op->slots_in, "direction"); symm.bm = bm; symm.op = op; @@ -658,6 +658,6 @@ void bmo_symmetrize_exec(BMesh *bm, BMOperator *op) BLI_ghash_free(symm.vert_symm_map, NULL, NULL); BLI_ghash_free(symm.edge_split_map, NULL, NULL); - BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, - SYMM_OUTPUT_GEOM); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", + BM_ALL, SYMM_OUTPUT_GEOM); } diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c index de876477e5a..775fa0cb60d 100644 --- a/source/blender/bmesh/operators/bmo_triangulate.c +++ b/source/blender/bmesh/operators/bmo_triangulate.c @@ -52,9 +52,10 @@ void bmo_triangulate_exec(BMesh *bm, BMOperator *op) float (*projectverts)[3] = NULL; BLI_array_declare(projectverts); int i; - const int use_beauty = BMO_slot_bool_get(op, "use_beauty"); + const int use_beauty = BMO_slot_bool_get(op->slots_in, "use_beauty"); + BMOpSlot *slot_facemap_out = BMO_slot_get(op->slots_out, "facemap.out"); - for (face = BMO_iter_new(&siter, bm, op, "faces", BM_FACE); face; face = BMO_iter_step(&siter)) { + for (face = BMO_iter_new(&siter, op->slots_in, "faces", BM_FACE); face; face = BMO_iter_step(&siter)) { BLI_array_empty(projectverts); BLI_array_empty(newfaces); @@ -64,16 +65,14 @@ void bmo_triangulate_exec(BMesh *bm, BMOperator *op) BM_face_triangulate(bm, face, projectverts, EDGE_NEW, FACE_NEW, newfaces, use_beauty); - BMO_slot_map_ptr_insert(bm, op, "facemap", face, face); + BMO_slot_map_ptr_insert(op, slot_facemap_out, face, face); for (i = 0; newfaces[i]; i++) { - BMO_slot_map_ptr_insert(bm, op, "facemap", - newfaces[i], face); - + BMO_slot_map_ptr_insert(op, slot_facemap_out, newfaces[i], face); } } - BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, EDGE_NEW); - BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, FACE_NEW); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, EDGE_NEW); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, FACE_NEW); BLI_array_free(projectverts); BLI_array_free(newfaces); @@ -87,9 +86,9 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op) BMEdge *e; int stop = 0; - BMO_slot_buffer_flag_enable(bm, op, "constrain_edges", BM_EDGE, EDGE_MARK); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "constrain_edges", BM_EDGE, EDGE_MARK); - BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) { + BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) { if (f->len == 3) { BMO_elem_flag_enable(bm, f, FACE_MARK); } @@ -152,7 +151,7 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op) } } - BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_EDGE | BM_FACE, ELE_NEW); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_EDGE | BM_FACE, ELE_NEW); } void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op) @@ -170,7 +169,7 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op) BLI_scanfill_begin(&sf_ctx); - BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { BMO_elem_flag_enable(bm, e, EDGE_MARK); if (!BLI_smallhash_haskey(&hash, (uintptr_t)e->v1)) { @@ -214,8 +213,8 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op) /* clean up fill */ BMO_op_initf(bm, &bmop, op->flag, "beautify_fill faces=%ff constrain_edges=%fe", ELE_NEW, EDGE_MARK); BMO_op_exec(bm, &bmop); - BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_FACE | BM_EDGE, ELE_NEW); + BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_FACE | BM_EDGE, ELE_NEW); BMO_op_finish(bm, &bmop); - BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_EDGE | BM_FACE, ELE_NEW); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_EDGE | BM_FACE, ELE_NEW); } diff --git a/source/blender/bmesh/operators/bmo_unsubdivide.c b/source/blender/bmesh/operators/bmo_unsubdivide.c index 3d44feac380..fae7db3d175 100644 --- a/source/blender/bmesh/operators/bmo_unsubdivide.c +++ b/source/blender/bmesh/operators/bmo_unsubdivide.c @@ -39,10 +39,10 @@ void bmo_unsubdivide_exec(BMesh *bm, BMOperator *op) BMVert *v; BMIter iter; - const int iterations = max_ii(1, BMO_slot_int_get(op, "iterations")); + const int iterations = max_ii(1, BMO_slot_int_get(op->slots_in, "iterations")); - BMOpSlot *vinput = BMO_slot_get(op, "verts"); - BMVert **vinput_arr = (BMVert **)vinput->data.p; + BMOpSlot *vinput = BMO_slot_get(op->slots_in, "verts"); + BMVert **vinput_arr = (BMVert **)vinput->data.buf; int v_index; /* tag verts */ diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index aa514a5c0a7..d56b2ca0d73 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -45,21 +45,21 @@ void bmo_create_vert_exec(BMesh *bm, BMOperator *op) { float vec[3]; - BMO_slot_vec_get(op, "co", vec); + BMO_slot_vec_get(op->slots_in, "co", vec); BMO_elem_flag_enable(bm, BM_vert_create(bm, vec, NULL), 1); - BMO_slot_buffer_from_enabled_flag(bm, op, "newvertout", BM_VERT, 1); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "vert.out", BM_VERT, 1); } -void bmo_transform_exec(BMesh *bm, BMOperator *op) +void bmo_transform_exec(BMesh *UNUSED(bm), BMOperator *op) { BMOIter iter; BMVert *v; float mat[4][4]; - BMO_slot_mat4_get(op, "mat", mat); + BMO_slot_mat4_get(op->slots_in, "mat", mat); - BMO_ITER (v, &iter, bm, op, "verts", BM_VERT) { + BMO_ITER (v, &iter, op->slots_in, "verts", BM_VERT) { mul_m4_v3(mat, v->co); } } @@ -68,7 +68,7 @@ void bmo_translate_exec(BMesh *bm, BMOperator *op) { float mat[4][4], vec[3]; - BMO_slot_vec_get(op, "vec", vec); + BMO_slot_vec_get(op->slots_in, "vec", vec); unit_m4(mat); copy_v3_v3(mat[3], vec); @@ -80,7 +80,7 @@ void bmo_scale_exec(BMesh *bm, BMOperator *op) { float mat[3][3], vec[3]; - BMO_slot_vec_get(op, "vec", vec); + BMO_slot_vec_get(op->slots_in, "vec", vec); unit_m3(mat); mat[0][0] = vec[0]; @@ -94,7 +94,7 @@ void bmo_rotate_exec(BMesh *bm, BMOperator *op) { float vec[3]; - BMO_slot_vec_get(op, "cent", vec); + BMO_slot_vec_get(op->slots_in, "cent", vec); /* there has to be a proper matrix way to do this, but * this is how editmesh did it and I'm too tired to think @@ -113,7 +113,7 @@ void bmo_reverse_faces_exec(BMesh *bm, BMOperator *op) BMOIter siter; BMFace *f; - BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) { + BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) { BM_face_normal_flip(bm, f); } } @@ -122,8 +122,8 @@ void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMEdge *e, *e2; - int ccw = BMO_slot_bool_get(op, "ccw"); - int is_single = BMO_slot_buffer_count(bm, op, "edges") == 1; + const int use_ccw = BMO_slot_bool_get(op->slots_in, "use_ccw"); + const int is_single = BMO_slot_buffer_count(op->slots_in, "edges") == 1; short check_flag = is_single ? BM_EDGEROT_CHECK_EXISTS : BM_EDGEROT_CHECK_EXISTS | BM_EDGEROT_CHECK_DEGENERATE; @@ -131,7 +131,7 @@ void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op) #define EDGE_OUT 1 #define FACE_TAINT 1 - BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { + BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { /** * this ends up being called twice, could add option to not to call check in * #BM_edge_rotate to get some extra speed */ @@ -144,7 +144,7 @@ void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op) BMO_elem_flag_test(bm, fb, FACE_TAINT) == FALSE) { - if (!(e2 = BM_edge_rotate(bm, e, ccw, check_flag))) { + if (!(e2 = BM_edge_rotate(bm, e, use_ccw, check_flag))) { #if 0 BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Could not rotate edge"); return; @@ -162,7 +162,7 @@ void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op) } } - BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, EDGE_OUT); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, EDGE_OUT); #undef EDGE_OUT #undef FACE_TAINT @@ -180,7 +180,7 @@ static void bmo_region_extend_extend(BMesh *bm, BMOperator *op, int usefaces) BMOIter siter; if (!usefaces) { - BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) { + BMO_ITER (v, &siter, op->slots_in, "geom", BM_VERT) { BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) if (!BMO_elem_flag_test(bm, e, SEL_ORIG)) @@ -202,7 +202,7 @@ static void bmo_region_extend_extend(BMesh *bm, BMOperator *op, int usefaces) BMFace *f, *f2; BMLoop *l; - BMO_ITER (f, &siter, bm, op, "geom", BM_FACE) { + BMO_ITER (f, &siter, op->slots_in, "geom", BM_FACE) { BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { BM_ITER_ELEM (f2, &fiter, l->e, BM_FACES_OF_EDGE) { if (!BM_elem_flag_test(f2, BM_ELEM_HIDDEN)) { @@ -224,7 +224,7 @@ static void bmo_region_extend_constrict(BMesh *bm, BMOperator *op, int usefaces) BMOIter siter; if (!usefaces) { - BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) { + BMO_ITER (v, &siter, op->slots_in, "geom", BM_VERT) { BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) if (!BMO_elem_flag_test(bm, e, SEL_ORIG)) @@ -248,7 +248,7 @@ static void bmo_region_extend_constrict(BMesh *bm, BMOperator *op, int usefaces) BMFace *f, *f2; BMLoop *l; - BMO_ITER (f, &siter, bm, op, "geom", BM_FACE) { + BMO_ITER (f, &siter, op->slots_in, "geom", BM_FACE) { BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { BM_ITER_ELEM (f2, &fiter, l->e, BM_FACES_OF_EDGE) { if (!BM_elem_flag_test(f2, BM_ELEM_HIDDEN)) { @@ -265,17 +265,17 @@ static void bmo_region_extend_constrict(BMesh *bm, BMOperator *op, int usefaces) void bmo_region_extend_exec(BMesh *bm, BMOperator *op) { - int use_faces = BMO_slot_bool_get(op, "use_faces"); - int constrict = BMO_slot_bool_get(op, "constrict"); + int use_faces = BMO_slot_bool_get(op->slots_in, "use_faces"); + int constrict = BMO_slot_bool_get(op->slots_in, "use_constrict"); - BMO_slot_buffer_flag_enable(bm, op, "geom", BM_ALL, SEL_ORIG); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "geom", BM_ALL, SEL_ORIG); if (constrict) bmo_region_extend_constrict(bm, op, use_faces); else bmo_region_extend_extend(bm, op, use_faces); - BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, SEL_FLAG); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_ALL, SEL_FLAG); } /********* righthand faces implementation ****** */ @@ -314,15 +314,15 @@ void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op) BLI_array_declare(fstack); BMLoop *l, *l2; float maxx, maxx_test, cent[3]; - int i, i_max, flagflip = BMO_slot_bool_get(op, "do_flip"); + int i, i_max, flagflip = BMO_slot_bool_get(op->slots_in, "use_flip"); startf = NULL; maxx = -1.0e10; - BMO_slot_buffer_flag_enable(bm, op, "faces", BM_FACE, FACE_FLAG); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "faces", BM_FACE, FACE_FLAG); /* find a starting face */ - BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) { + BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) { /* clear dirty flag */ BM_elem_flag_disable(f, BM_ELEM_TAG); @@ -405,7 +405,7 @@ void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op) BLI_array_free(fstack); /* check if we have faces yet to do. if so, recurse */ - BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) { + BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) { if (!BMO_elem_flag_test(bm, f, FACE_VIS)) { bmo_recalc_face_normals_exec(bm, op); break; @@ -413,7 +413,7 @@ void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op) } } -void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op) +void bmo_smooth_vert_exec(BMesh *UNUSED(bm), BMOperator *op) { BMOIter siter; BMIter iter; @@ -421,20 +421,20 @@ void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op) BMEdge *e; BLI_array_declare(cos); float (*cos)[3] = NULL; - float *co, *co2, clipdist = BMO_slot_float_get(op, "clipdist"); + float *co, *co2, clip_dist = BMO_slot_float_get(op->slots_in, "clip_dist"); int i, j, clipx, clipy, clipz; int xaxis, yaxis, zaxis; - clipx = BMO_slot_bool_get(op, "mirror_clip_x"); - clipy = BMO_slot_bool_get(op, "mirror_clip_y"); - clipz = BMO_slot_bool_get(op, "mirror_clip_z"); + clipx = BMO_slot_bool_get(op->slots_in, "mirror_clip_x"); + clipy = BMO_slot_bool_get(op->slots_in, "mirror_clip_y"); + clipz = BMO_slot_bool_get(op->slots_in, "mirror_clip_z"); - xaxis = BMO_slot_bool_get(op, "use_axis_x"); - yaxis = BMO_slot_bool_get(op, "use_axis_y"); - zaxis = BMO_slot_bool_get(op, "use_axis_z"); + xaxis = BMO_slot_bool_get(op->slots_in, "use_axis_x"); + yaxis = BMO_slot_bool_get(op->slots_in, "use_axis_y"); + zaxis = BMO_slot_bool_get(op->slots_in, "use_axis_z"); i = 0; - BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { + BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) { BLI_array_grow_one(cos); co = cos[i]; @@ -454,18 +454,18 @@ void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op) mul_v3_fl(co, 1.0f / (float)j); mid_v3_v3v3(co, co, v->co); - if (clipx && fabsf(v->co[0]) <= clipdist) + if (clipx && fabsf(v->co[0]) <= clip_dist) co[0] = 0.0f; - if (clipy && fabsf(v->co[1]) <= clipdist) + if (clipy && fabsf(v->co[1]) <= clip_dist) co[1] = 0.0f; - if (clipz && fabsf(v->co[2]) <= clipdist) + if (clipz && fabsf(v->co[2]) <= clip_dist) co[2] = 0.0f; i++; } i = 0; - BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { + BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) { if (xaxis) v->co[0] = cos[i][0]; if (yaxis) @@ -489,11 +489,11 @@ void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op) BMFace *fs; /* current face */ BMIter l_iter; /* iteration loop */ - int dir = BMO_slot_int_get(op, "dir"); + const int use_ccw = BMO_slot_bool_get(op->slots_in, "use_ccw"); - BMO_ITER (fs, &fs_iter, bm, op, "faces", BM_FACE) { + BMO_ITER (fs, &fs_iter, op->slots_in, "faces", BM_FACE) { if (CustomData_has_layer(&(bm->ldata), CD_MLOOPUV)) { - if (dir == DIRECTION_CW) { /* same loops direction */ + if (use_ccw == FALSE) { /* same loops direction */ BMLoop *lf; /* current face loops */ MLoopUV *f_luv; /* first face loop uv */ float p_uv[2]; /* previous uvs */ @@ -517,7 +517,7 @@ void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op) copy_v2_v2(f_luv->uv, p_uv); } - else if (dir == DIRECTION_CCW) { /* counter loop direction */ + else { /* counter loop direction */ BMLoop *lf; /* current face loops */ MLoopUV *p_luv; /* previous loop uv */ MLoopUV *luv; @@ -556,7 +556,7 @@ void bmo_reverse_uvs_exec(BMesh *bm, BMOperator *op) BLI_array_declare(uvs); float (*uvs)[2] = NULL; - BMO_ITER (fs, &fs_iter, bm, op, "faces", BM_FACE) { + BMO_ITER (fs, &fs_iter, op->slots_in, "faces", BM_FACE) { if (CustomData_has_layer(&(bm->ldata), CD_MLOOPUV)) { BMLoop *lf; /* current face loops */ int i; @@ -594,11 +594,11 @@ void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op) BMFace *fs; /* current face */ BMIter l_iter; /* iteration loop */ - int dir = BMO_slot_int_get(op, "dir"); + const int use_ccw = BMO_slot_bool_get(op->slots_in, "use_ccw"); - BMO_ITER (fs, &fs_iter, bm, op, "faces", BM_FACE) { + BMO_ITER (fs, &fs_iter, op->slots_in, "faces", BM_FACE) { if (CustomData_has_layer(&(bm->ldata), CD_MLOOPCOL)) { - if (dir == DIRECTION_CW) { /* same loops direction */ + if (use_ccw == FALSE) { /* same loops direction */ BMLoop *lf; /* current face loops */ MLoopCol *f_lcol; /* first face loop color */ MLoopCol p_col; /* previous color */ @@ -622,7 +622,7 @@ void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op) *f_lcol = p_col; } - else if (dir == DIRECTION_CCW) { /* counter loop direction */ + else { /* counter loop direction */ BMLoop *lf; /* current face loops */ MLoopCol *p_lcol; /* previous loop color */ MLoopCol *lcol; @@ -661,7 +661,7 @@ void bmo_reverse_colors_exec(BMesh *bm, BMOperator *op) BLI_array_declare(cols); MLoopCol *cols = NULL; - BMO_ITER (fs, &fs_iter, bm, op, "faces", BM_FACE) { + BMO_ITER (fs, &fs_iter, op->slots_in, "faces", BM_FACE) { if (CustomData_has_layer(&(bm->ldata), CD_MLOOPCOL)) { BMLoop *lf; /* current face loops */ int i; @@ -710,12 +710,13 @@ void bmo_shortest_path_exec(BMesh *bm, BMOperator *op) ElemNode *vert_list = NULL; int num_total = 0 /*, num_sels = 0 */, i = 0; - const int type = BMO_slot_int_get(op, "type"); + const int type = BMO_slot_int_get(op->slots_in, "type"); - BMO_ITER (vs, &vs_iter, bm, op, "startv", BM_VERT) { + /* BMESH_TODO use BMO_slot_buffer_elem_first here? */ + BMO_ITER (vs, &vs_iter, op->slots_in, "startv", BM_VERT) { sv = vs; } - BMO_ITER (vs, &vs_iter, bm, op, "endv", BM_VERT) { + BMO_ITER (vs, &vs_iter, op->slots_in, "endv", BM_VERT) { ev = vs; } @@ -795,5 +796,5 @@ void bmo_shortest_path_exec(BMesh *bm, BMOperator *op) BLI_heap_free(h, NULL); MEM_freeN(vert_list); - BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK); + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK); } diff --git a/source/blender/bmesh/operators/bmo_wireframe.c b/source/blender/bmesh/operators/bmo_wireframe.c index d572a1c5863..532145ab129 100644 --- a/source/blender/bmesh/operators/bmo_wireframe.c +++ b/source/blender/bmesh/operators/bmo_wireframe.c @@ -77,39 +77,60 @@ static void bm_vert_boundary_tangent(BMVert *v, float r_no[3], float r_no_face[3 } } - l_a = bm_edge_tag_faceloop(e_a); - l_b = bm_edge_tag_faceloop(e_b); + if (e_a && e_b) { + l_a = bm_edge_tag_faceloop(e_a); + l_b = bm_edge_tag_faceloop(e_b); + + /* average edge face normal */ + add_v3_v3v3(no_face, l_a->f->no, l_b->f->no); + + /* average edge direction */ + v_a = BM_edge_other_vert(e_a, v); + v_b = BM_edge_other_vert(e_b, v); + + sub_v3_v3v3(tvec_a, v->co, v_a->co); + sub_v3_v3v3(tvec_b, v_b->co, v->co); + normalize_v3(tvec_a); + normalize_v3(tvec_b); + add_v3_v3v3(no_edge, tvec_a, tvec_b); /* not unit length but this is ok */ + + /* check are we flipped the right way */ + BM_edge_calc_face_tangent(e_a, l_a, tvec_a); + BM_edge_calc_face_tangent(e_b, l_b, tvec_b); + add_v3_v3(tvec_a, tvec_b); + + *r_va_other = v_a; + *r_vb_other = v_b; + } + else { + /* degenerate case - vertex connects a boundary edged face to other faces, + * so we have only one boundary face - only use it for calculations */ + l_a = bm_edge_tag_faceloop(e_a); - /* average edge face normal */ - add_v3_v3v3(no_face, l_a->f->no, l_b->f->no); + copy_v3_v3(no_face, l_a->f->no); - /* average edge direction */ - v_a = BM_edge_other_vert(e_a, v); - v_b = BM_edge_other_vert(e_b, v); + /* edge direction */ + v_a = BM_edge_other_vert(e_a, v); + v_b = NULL; - sub_v3_v3v3(tvec_a, v->co, v_a->co); - sub_v3_v3v3(tvec_b, v_b->co, v->co); - normalize_v3(tvec_a); - normalize_v3(tvec_b); - add_v3_v3v3(no_edge, tvec_a, tvec_b); /* not unit length but this is ok */ + sub_v3_v3v3(no_edge, v->co, v_a->co); + /* check are we flipped the right way */ + BM_edge_calc_face_tangent(e_a, l_a, tvec_a); + + *r_va_other = NULL; + *r_vb_other = NULL; + } /* find the normal */ cross_v3_v3v3(r_no, no_edge, no_face); normalize_v3(r_no); - /* check are we flipped the right way */ - BM_edge_calc_face_tangent(e_a, l_a, tvec_a); - BM_edge_calc_face_tangent(e_b, l_b, tvec_b); - add_v3_v3(tvec_a, tvec_b); - if (dot_v3v3(r_no, tvec_a) > 0.0f) { negate_v3(r_no); } copy_v3_v3(r_no_face, no_face); - *r_va_other = v_a; - *r_vb_other = v_b; } /* check if we are the only tagged loop-face around this edge */ @@ -134,12 +155,12 @@ extern float BM_vert_calc_mean_tagged_edge_length(BMVert *v); void bmo_wireframe_exec(BMesh *bm, BMOperator *op) { - const int use_boundary = BMO_slot_bool_get(op, "use_boundary"); - const int use_even_offset = BMO_slot_bool_get(op, "use_even_offset"); - const int use_relative_offset = BMO_slot_bool_get(op, "use_relative_offset"); - const int use_crease = (BMO_slot_bool_get(op, "use_crease") && + const int use_boundary = BMO_slot_bool_get(op->slots_in, "use_boundary"); + const int use_even_offset = BMO_slot_bool_get(op->slots_in, "use_even_offset"); + const int use_relative_offset = BMO_slot_bool_get(op->slots_in, "use_relative_offset"); + const int use_crease = (BMO_slot_bool_get(op->slots_in, "use_crease") && CustomData_has_layer(&bm->edata, CD_CREASE)); - const float depth = BMO_slot_float_get(op, "thickness"); + const float depth = BMO_slot_float_get(op->slots_in, "thickness"); const float inset = depth; const int totvert_orig = bm->totvert; @@ -184,7 +205,7 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op) /* setup tags, all faces and verts will be tagged which will be duplicated */ BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE); - BMO_ITER (f_src, &oiter, bm, op, "faces", BM_FACE) { + BMO_ITER (f_src, &oiter, op->slots_in, "faces", BM_FACE) { verts_loop_tot += f_src->len; BM_elem_flag_enable(f_src, BM_ELEM_TAG); BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) { @@ -230,7 +251,7 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op) verts_loop = MEM_mallocN(sizeof(BMVert **) * verts_loop_tot, __func__); verts_loop_tot = 0; /* count up again */ - BMO_ITER (f_src, &oiter, bm, op, "faces", BM_FACE) { + BMO_ITER (f_src, &oiter, op->slots_in, "faces", BM_FACE) { BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) { BM_elem_index_set(l, verts_loop_tot); /* set_loop */ @@ -269,10 +290,12 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op) /* similar to code above but different angle calc */ fac = inset; if (use_even_offset) { - fac *= shell_angle_to_dist(((float)M_PI - angle_on_axis_v3v3v3_v3(va_other->co, - l_pair[i]->v->co, - vb_other->co, - no_face)) * 0.5f); + if (va_other) { /* for verts with only one boundary edge - this will be NULL */ + fac *= shell_angle_to_dist(((float)M_PI - angle_on_axis_v3v3v3_v3(va_other->co, + l_pair[i]->v->co, + vb_other->co, + no_face)) * 0.5f); + } } if (use_relative_offset) { fac *= verts_relfac[BM_elem_index_get(l_pair[i]->v)]; @@ -288,7 +311,7 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op) } } - BMO_ITER (f_src, &oiter, bm, op, "faces", BM_FACE) { + BMO_ITER (f_src, &oiter, op->slots_in, "faces", BM_FACE) { BM_elem_flag_disable(f_src, BM_ELEM_TAG); BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) { BMFace *f_new; @@ -400,5 +423,5 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op) MEM_freeN(verts_pos); MEM_freeN(verts_loop); - BMO_slot_buffer_from_enabled_hflag(bm, op, "faceout", BM_FACE, BM_ELEM_TAG); + BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG); } diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index cfc7edb2400..75e74155f66 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -52,7 +52,7 @@ typedef struct NewVert { BMVert *v; float co[3]; - int _pad; +// int _pad; } NewVert; struct BoundVert; @@ -242,20 +242,24 @@ static BMFace *boundvert_rep_face(BoundVert *v) return fans; } -/* Make ngon from verts alone. +/** + * Make ngon from verts alone. * Make sure to properly copy face attributes and do custom data interpolation from - * example face, facerep. */ -static BMFace *bev_create_ngon(BMesh *bm, BMVert **vert_arr, int totv, BMFace *facerep) + * example face, facerep. + * + * \note ALL face creation goes through this function, this is important to keep! + */ +static BMFace *bev_create_ngon(BMesh *bm, BMVert **vert_arr, const int totv, BMFace *facerep) { BMIter iter; BMLoop *l; BMFace *f; if (totv == 3) { - f = BM_face_create_quad_tri_v(bm, vert_arr, 3, facerep, 0); + f = BM_face_create_quad_tri_v(bm, vert_arr, 3, facerep, FALSE); } else if (totv == 4) { - f = BM_face_create_quad_tri_v(bm, vert_arr, 4, facerep, 0); + f = BM_face_create_quad_tri_v(bm, vert_arr, 4, facerep, FALSE); } else { int i; @@ -278,18 +282,20 @@ static BMFace *bev_create_ngon(BMesh *bm, BMVert **vert_arr, int totv, BMFace *f BM_loop_interp_multires(bm, l, facerep); } } + + /* not essential for bevels own internal logic, + * this is done so the operator can select newly created faces */ + if (f) { + BM_elem_flag_enable(f, BM_ELEM_TAG); + } + return f; } static BMFace *bev_create_quad_tri(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4, BMFace *facerep) { - BMVert *varr[4]; - - varr[0] = v1; - varr[1] = v2; - varr[2] = v3; - varr[3] = v4; + BMVert *varr[4] = {v1, v2, v3, v4}; return bev_create_ngon(bm, varr, v4 ? 4 : 3, facerep); } @@ -313,12 +319,7 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, sub_v3_v3v3(dir1, v->co, BM_edge_other_vert(e1->e, v)->co); sub_v3_v3v3(dir2, BM_edge_other_vert(e2->e, v)->co, v->co); - /* get normal to plane where meet point should be */ - cross_v3_v3v3(norm_v, dir2, dir1); - normalize_v3(norm_v); - if (!on_right) - negate_v3(norm_v); - if (is_zero_v3(norm_v)) { + if (angle_v3v3(dir1, dir2) < 100.0f * (float)BEVEL_EPSILON) { /* special case: e1 and e2 are parallel; put offset point perp to both, from v. * need to find a suitable plane. * if offsets are different, we're out of luck: just use e1->offset */ @@ -333,6 +334,12 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, copy_v3_v3(meetco, off1a); } else { + /* get normal to plane where meet point should be */ + cross_v3_v3v3(norm_v, dir2, dir1); + normalize_v3(norm_v); + if (!on_right) + negate_v3(norm_v); + /* get vectors perp to each edge, perp to norm_v, and pointing into face */ if (f) { copy_v3_v3(norm_v, f->no); @@ -387,7 +394,7 @@ static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, madd_v3_v3fl(off2a, norm_perp2, e2->offset); add_v3_v3v3(off2b, off2a, dir2); - if (angle_v3v3(dir1, dir2) < (float)BEVEL_EPSILON) { + if (angle_v3v3(dir1, dir2) < 100.0f * (float)BEVEL_EPSILON) { /* lines are parallel; off1a is a good meet point */ copy_v3_v3(meetco, off1a); } @@ -471,15 +478,13 @@ static int bev_ccw_test(BMEdge *a, BMEdge *b, BMFace *f) static void vmesh_cent(VMesh *vm, float r_cent[3]) { BoundVert *v; - int tot = 0; zero_v3(r_cent); v = vm->boundstart; do { add_v3_v3(r_cent, v->nv.co); - tot++; } while ((v = v->next) != vm->boundstart); - mul_v3_fl(r_cent, 1.0f / (float)tot); + mul_v3_fl(r_cent, 1.0f / (float)vm->count); } /** @@ -608,7 +613,7 @@ static void get_point_on_round_edge(EdgeHalf *e, int k, else sub_v3_v3v3(dir, e->e->v2->co, e->e->v1->co); normalize_v3(dir); - if (fabsf(angle_v3v3(vva, vvb) - (float)M_PI) > (float)BEVEL_EPSILON) { + if (fabsf(angle_v3v3(vva, vvb) - (float)M_PI) > 100.f *(float)BEVEL_EPSILON) { copy_v3_v3(vaadj, va); madd_v3_v3fl(vaadj, dir, -len_v3(vva) * cosf(angle_v3v3(vva, dir))); copy_v3_v3(vbadj, vb); @@ -1402,8 +1407,9 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) BMFace *f; BMIter iter, iter2; EdgeHalf *e; - int i, ntot, found_shared_face, ccw_test_sum; + int i, found_shared_face, ccw_test_sum; int nsel = 0; + int ntot = 0; /* Gather input selected edges. * Only bevel selected edges that have exactly two incident faces. @@ -1414,12 +1420,19 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) BLI_assert(BM_edge_is_manifold(bme)); nsel++; } + ntot++; } - if (nsel == 0) + if (nsel == 0) { + /* signal this vert isn't being beveled */ + BM_elem_flag_disable(v, BM_ELEM_TAG); return; + } + + /* avoid calling BM_vert_edge_count since we loop over edges already */ + // ntot = BM_vert_edge_count(v); + // BLI_assert(ntot == BM_vert_edge_count(v)); - ntot = BM_vert_edge_count(v); bv = (BevVert *)BLI_memarena_alloc(bp->mem_arena, (sizeof(BevVert))); bv->v = v; bv->edgecount = ntot; @@ -1489,10 +1502,13 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) } } + /* do later when we loop over edges */ +#if 0 /* clear BEVEL_EDGE_TAG now that we are finished with it*/ for (i = 0; i < ntot; i++) { BM_BEVEL_EDGE_TAG_DISABLE(bv->edges[i].e); } +#endif /* if edge array doesn't go CCW around vertex from average normal side, * reverse the array, being careful to reverse face pointers too */ @@ -1514,10 +1530,10 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) } } - for (i = 0; i < ntot; i++) { - e = &bv->edges[i]; + for (i = 0, e = bv->edges; i < ntot; i++, e++) { e->next = &bv->edges[(i + 1) % ntot]; e->prev = &bv->edges[(i + ntot - 1) % ntot]; + BM_BEVEL_EDGE_TAG_DISABLE(e->e); } build_boundary(bp->mem_arena, bv); @@ -1525,7 +1541,7 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) } /* Face f has at least one beveled vertex. Rebuild f */ -static void rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) +static int bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) { BMIter liter; BMLoop *l, *lprev; @@ -1534,14 +1550,15 @@ static void rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) EdgeHalf *e, *eprev; VMesh *vm; int i, k; + int do_rebuild = FALSE; BMVert *bmv; BMVert **vv = NULL; - BLI_array_declare(vv); + BLI_array_staticdeclare(vv, BM_DEFAULT_NGON_STACK_SIZE); BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { - bv = find_bevvert(bp, l->v); - if (bv) { + if (BM_elem_flag_test(l->v, BM_ELEM_TAG)) { lprev = l->prev; + bv = find_bevvert(bp, l->v); e = find_edge_half(bv, l->e); eprev = find_edge_half(bv, lprev->e); BLI_assert(e != NULL && eprev != NULL); @@ -1566,13 +1583,24 @@ static void rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) v = v->prev; BLI_array_append(vv, v->nv.v); } + + do_rebuild = TRUE; } else { BLI_array_append(vv, l->v); } } - bev_create_ngon(bm, vv, BLI_array_count(vv), f); + if (do_rebuild) { + BMFace *f_new = bev_create_ngon(bm, vv, BLI_array_count(vv), f); + + /* don't select newly created boundary faces... */ + if (f_new) { + BM_elem_flag_disable(f_new, BM_ELEM_TAG); + } + } + BLI_array_free(vv); + return do_rebuild; } /* All polygons touching v need rebuilding because beveling v has made new vertices */ @@ -1586,8 +1614,9 @@ static void bevel_rebuild_existing_polygons(BMesh *bm, BevelParams *bp, BMVert * if (LIKELY(faces != NULL)) { for (f_index = 0; f_index < faces_len; f_index++) { BMFace *f = faces[f_index]; - rebuild_polygon(bm, bp, f); - BM_face_kill(bm, f); + if (bev_rebuild_polygon(bm, bp, f)) { + BM_face_kill(bm, f); + } } if (faces != (BMFace **)faces_stack) { @@ -1597,7 +1626,6 @@ static void bevel_rebuild_existing_polygons(BMesh *bm, BevelParams *bp, BMVert * } - /* * Build the polygons along the selected Edge */ @@ -1664,8 +1692,13 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme) } /** - * currently only bevels BM_ELEM_TAG'd verts and edges - * all tagged edges _must_ be manifold. + * - Currently only bevels BM_ELEM_TAG'd verts and edges. + * + * - Newly created faces are BM_ELEM_TAG'd too, + * the caller needs to ensure this is cleared before calling + * if its going to use this face tag. + * + * \warning all tagged edges _must_ be manifold. */ void BM_mesh_bevel(BMesh *bm, const float offset, const float segments) { @@ -1705,9 +1738,8 @@ void BM_mesh_bevel(BMesh *bm, const float offset, const float segments) BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_TAG)) { - if (find_bevvert(&bp, v)) { - BM_vert_kill(bm, v); - } + BLI_assert(find_bevvert(&bp, v) != NULL); + BM_vert_kill(bm, v); } } diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index c6e0f6c2cfb..1ec4ac7699b 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -247,9 +247,14 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation) */ static void debug_check_node_connections(Node *node) { + /* note: connected inputs are not checked here, + * it would break quite a lot and such inputs are ignored later anyway + */ +#if 0 for (int i = 0; i < node->getNumberOfInputSockets(); ++i) { BLI_assert(!node->getInputSocket(i)->isConnected()); } +#endif for (int i = 0; i < node->getNumberOfOutputSockets(); ++i) { BLI_assert(!node->getOutputSocket(i)->isConnected()); } diff --git a/source/blender/compositor/nodes/COM_MuteNode.cpp b/source/blender/compositor/nodes/COM_MuteNode.cpp index 4502dcf469c..de12fff3591 100644 --- a/source/blender/compositor/nodes/COM_MuteNode.cpp +++ b/source/blender/compositor/nodes/COM_MuteNode.cpp @@ -43,6 +43,10 @@ void MuteNode::reconnect(ExecutionSystem *graph, OutputSocket *output) if (input->getDataType() == output->getDataType()) { if (input->isConnected()) { output->relinkConnections(input->getConnection()->getFromSocket(), false); + /* output connections have been redirected, + * remove the input connection to completely unlink the node. + */ + input->unlinkConnections(graph); return; } } diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp index 921b9e63a73..3b1871b307b 100644 --- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp +++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp @@ -41,6 +41,12 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte * otherwise, it overwrites the output files just * scrubbing through the timeline when the compositor updates. */ + + /* still, need to unlink input sockets to remove the node from the graph completely */ + int num_inputs = getNumberOfInputSockets(); + for (int i = 0; i < num_inputs; ++i) { + getInputSocket(i)->unlinkConnections(graph); + } return; } diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index 4bdb2591cb7..9231261986d 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -230,6 +230,7 @@ FastGaussianBlurValueOperation::FastGaussianBlurValueOperation() : NodeOperation this->m_iirgaus = NULL; this->m_inputprogram = NULL; this->m_sigma = 1.0f; + this->m_overlay = 0; setComplex(true); } @@ -281,7 +282,7 @@ void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect) if (this->m_overlay == FAST_GAUSS_OVERLAY_MIN) { float *src = newBuf->getBuffer(); float *dst = copy->getBuffer(); - for (int i = copy->getWidth() * copy->getHeight() * COM_NUMBER_OF_CHANNELS; i != 0; i--, src++, dst++) { + for (int i = copy->getWidth() * copy->getHeight(); i != 0; i--, src += COM_NUMBER_OF_CHANNELS, dst += COM_NUMBER_OF_CHANNELS) { if (*src < *dst) { *dst = *src; } @@ -290,7 +291,7 @@ void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect) else if (this->m_overlay == FAST_GAUSS_OVERLAY_MAX) { float *src = newBuf->getBuffer(); float *dst = copy->getBuffer(); - for (int i = copy->getWidth() * copy->getHeight() * COM_NUMBER_OF_CHANNELS; i != 0; i--, src++, dst++) { + for (int i = copy->getWidth() * copy->getHeight(); i != 0; i--, src += COM_NUMBER_OF_CHANNELS, dst += COM_NUMBER_OF_CHANNELS) { if (*src > *dst) { *dst = *src; } diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp index c36a6f896c2..8f92dc02a57 100644 --- a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp +++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp @@ -48,6 +48,7 @@ void GammaCorrectOperation::executePixel(float output[4], float x, float y, Pixe output[0] = inputColor[0] > 0.0f ? inputColor[0] * inputColor[0] : 0.0f; output[1] = inputColor[1] > 0.0f ? inputColor[1] * inputColor[1] : 0.0f; output[2] = inputColor[2] > 0.0f ? inputColor[2] * inputColor[2] : 0.0f; + output[3] = inputColor[3]; if (inputColor[3] > 0.0f) { output[0] *= inputColor[3]; @@ -86,6 +87,7 @@ void GammaUncorrectOperation::executePixel(float output[4], float x, float y, Pi output[0] = inputColor[0] > 0.0f ? sqrtf(inputColor[0]) : 0.0f; output[1] = inputColor[1] > 0.0f ? sqrtf(inputColor[1]) : 0.0f; output[2] = inputColor[2] > 0.0f ? sqrtf(inputColor[2]) : 0.0f; + output[3] = inputColor[3]; if (inputColor[3] > 0.0f) { output[0] *= inputColor[3]; diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index f6459bfc542..bb324337ffb 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1564,6 +1564,8 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op) /* duplicate of 'ANIM_OT_channels_setting_toggle' for menu title only, weak! */ static void ANIM_OT_channels_setting_enable(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Enable Channel Setting"; ot->idname = "ANIM_OT_channels_setting_enable"; @@ -1579,13 +1581,16 @@ static void ANIM_OT_channels_setting_enable(wmOperatorType *ot) /* props */ /* flag-setting mode */ - RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_ADD, "Mode", ""); + prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_ADD, "Mode", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); /* setting to set */ ot->prop = RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); } /* duplicate of 'ANIM_OT_channels_setting_toggle' for menu title only, weak! */ static void ANIM_OT_channels_setting_disable(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Disable Channel Setting"; ot->idname = "ANIM_OT_channels_setting_disable"; @@ -1601,13 +1606,16 @@ static void ANIM_OT_channels_setting_disable(wmOperatorType *ot) /* props */ /* flag-setting mode */ - RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_CLEAR, "Mode", ""); + prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_CLEAR, "Mode", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); /* internal hack - don't expose */ /* setting to set */ ot->prop = RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); } static void ANIM_OT_channels_setting_toggle(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Toggle Channel Setting"; ot->idname = "ANIM_OT_channels_setting_toggle"; @@ -1623,13 +1631,16 @@ static void ANIM_OT_channels_setting_toggle(wmOperatorType *ot) /* props */ /* flag-setting mode */ - RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", ""); + prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); /* internal hack - don't expose */ /* setting to set */ ot->prop = RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); } static void ANIM_OT_channels_editable_toggle(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Toggle Channel Editability"; ot->idname = "ANIM_OT_channels_editable_toggle"; @@ -1646,7 +1657,8 @@ static void ANIM_OT_channels_editable_toggle(wmOperatorType *ot) /* flag-setting mode */ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", ""); /* setting to set */ - RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, ACHANNEL_SETTING_PROTECT, "Type", ""); + prop = RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, ACHANNEL_SETTING_PROTECT, "Type", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); /* internal hack - don't expose */ } /* ********************** Expand Channels Operator *********************** */ diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 852f3fa5469..4ac7b61fccb 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -706,8 +706,13 @@ static int ed_marker_move_invoke_wrapper(bContext *C, wmOperator *op, wmEvent *e } /* note, init has to be called succesfully */ -static void ed_marker_move_apply(wmOperator *op) +static void ed_marker_move_apply(bContext *C, wmOperator *op) { +#ifdef DURIAN_CAMERA_SWITCH + bScreen *sc = CTX_wm_screen(C); + Scene *scene = CTX_data_scene(C); + Object *camera = scene->camera; +#endif MarkerMove *mm = op->customdata; TimeMarker *marker; int a, offs; @@ -719,17 +724,27 @@ static void ed_marker_move_apply(wmOperator *op) a++; } } + + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); + +#ifdef DURIAN_CAMERA_SWITCH + /* so we get view3d redraws */ + BKE_scene_camera_switch_update(scene); + + if(camera != scene->camera) { + BKE_screen_view3d_scene_sync(sc); + WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); + } +#endif } /* only for modal */ static int ed_marker_move_cancel(bContext *C, wmOperator *op) { RNA_int_set(op->ptr, "frames", 0); - ed_marker_move_apply(op); + ed_marker_move_apply(C, op); ed_marker_move_exit(C, op); - - WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return OPERATOR_CANCELLED; } @@ -789,7 +804,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) offs = (int)fac; RNA_int_set(op->ptr, "frames", offs); - ed_marker_move_apply(op); + ed_marker_move_apply(C, op); /* cruft below is for header print */ for (a = 0, marker = mm->markers->first; marker; marker = marker->next) { @@ -840,8 +855,6 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) } } - WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); ED_area_headerprint(CTX_wm_area(C), str); } } @@ -855,14 +868,11 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) outputNumInput(&mm->num, str_tx); RNA_int_set(op->ptr, "frames", vec); - ed_marker_move_apply(op); + ed_marker_move_apply(C, op); // ed_marker_header_update(C, op, str, (int)vec[0]); // strcat(str, str_tx); BLI_snprintf(str, sizeof(str), "Marker offset %s", str_tx); ED_area_headerprint(CTX_wm_area(C), str); - - WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); } } @@ -872,7 +882,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) static int ed_marker_move_exec(bContext *C, wmOperator *op) { if (ed_marker_move_init(C, op)) { - ed_marker_move_apply(op); + ed_marker_move_apply(C, op); ed_marker_move_exit(C, op); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 48da23d5e8d..e801d3689e5 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -3569,16 +3569,16 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); bArmature *arm = obedit->data; EditBone *newbone, *tbone; - int numcuts, i; + int cuts, i; /* there may not be a number_cuts property defined (for 'simple' subdivide) */ - numcuts = RNA_int_get(op->ptr, "number_cuts"); + cuts = RNA_int_get(op->ptr, "number_cuts"); /* loop over all editable bones */ // XXX the old code did this in reverse order though! CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { - for (i = numcuts + 1; i > 1; i--) { + for (i = cuts + 1; i > 1; i--) { /* compute cut ratio first */ float cutratio = 1.0f / (float)i; float cutratioI = 1.0f - cutratio; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 348b98a0380..23fed4ce8fc 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1069,7 +1069,7 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) Nurb *nu = editnurb->nurbs.first; CVKeyIndex *keyIndex; char rna_path[64], orig_rna_path[64]; - AnimData *ad = BKE_animdata_from_id(&cu->id); + AnimData *adt = BKE_animdata_from_id(&cu->id); ListBase curves = {NULL, NULL}; FCurve *fcu, *next; @@ -1089,14 +1089,14 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) char handle_path[64], orig_handle_path[64]; BLI_snprintf(orig_handle_path, sizeof(orig_rna_path), "%s.handle_left", orig_rna_path); BLI_snprintf(handle_path, sizeof(rna_path), "%s.handle_right", rna_path); - fcurve_path_rename(ad, orig_handle_path, handle_path, orig_curves, &curves); + fcurve_path_rename(adt, orig_handle_path, handle_path, orig_curves, &curves); BLI_snprintf(orig_handle_path, sizeof(orig_rna_path), "%s.handle_right", orig_rna_path); BLI_snprintf(handle_path, sizeof(rna_path), "%s.handle_left", rna_path); - fcurve_path_rename(ad, orig_handle_path, handle_path, orig_curves, &curves); + fcurve_path_rename(adt, orig_handle_path, handle_path, orig_curves, &curves); } - fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves); + fcurve_path_rename(adt, orig_rna_path, rna_path, orig_curves, &curves); keyIndex->nu_index = nu_index; keyIndex->pt_index = pt_index; @@ -1116,7 +1116,7 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) if (keyIndex) { BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].points[%d]", nu_index, pt_index); BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index); - fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves); + fcurve_path_rename(adt, orig_rna_path, rna_path, orig_curves, &curves); keyIndex->nu_index = nu_index; keyIndex->pt_index = pt_index; @@ -1140,7 +1140,7 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) char *ch = strchr(fcu->rna_path, '.'); if (ch && (!strncmp(ch, ".bezier_points", 14) || !strncmp(ch, ".points", 7))) - fcurve_remove(ad, orig_curves, fcu); + fcurve_remove(adt, orig_curves, fcu); } } @@ -1156,7 +1156,7 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) if (keyIndex) { BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d]", nu_index); BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d]", keyIndex->nu_index); - fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves); + fcurve_path_rename(adt, orig_rna_path, rna_path, orig_curves, &curves); } nu_index++; @@ -1168,7 +1168,7 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) for (fcu = orig_curves->first; fcu; fcu = next) { next = fcu->next; - if (!strncmp(fcu->rna_path, "splines", 7)) fcurve_remove(ad, orig_curves, fcu); + if (!strncmp(fcu->rna_path, "splines", 7)) fcurve_remove(adt, orig_curves, fcu); else BLI_addtail(&curves, fcu); } @@ -1178,14 +1178,14 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) /* return 0 if animation data wasn't changed, 1 otherwise */ int ED_curve_updateAnimPaths(Curve *cu) { - AnimData *ad = BKE_animdata_from_id(&cu->id); + AnimData *adt = BKE_animdata_from_id(&cu->id); if (!curve_is_animated(cu)) return 0; - if (ad->action) - curve_rename_fcurves(cu, &ad->action->curves); + if (adt->action) + curve_rename_fcurves(cu, &adt->action->curves); - curve_rename_fcurves(cu, &ad->drivers); + curve_rename_fcurves(cu, &adt->drivers); return 1; } diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index e400e44e944..10c585aa802 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -593,6 +593,7 @@ DEF_ICON(MOD_REMESH) DEF_ICON(MOD_OCEAN) DEF_ICON(MOD_WARP) DEF_ICON(MOD_SKIN) +DEF_ICON(MOD_TRIANGULATE) #ifndef DEF_ICON_BLANK_SKIP DEF_ICON(BLANK166) DEF_ICON(BLANK167) @@ -606,7 +607,6 @@ DEF_ICON(MOD_SKIN) DEF_ICON(BLANK175) DEF_ICON(BLANK176) DEF_ICON(BLANK177) - DEF_ICON(BLANK177b) #endif /* ANIMATION */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index e2f105b5761..535239cd462 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1677,7 +1677,7 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen) { if (but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { PropertyType type; - char *buf = NULL; + const char *buf = NULL; int buf_len; type = RNA_property_type(but->rnaprop); @@ -1686,11 +1686,22 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen) /* RNA string */ buf = RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen, &buf_len); } + else if (type == PROP_ENUM) { + /* RNA enum */ + int value = RNA_property_enum_get(&but->rnapoin, but->rnaprop); + if (RNA_property_enum_name(but->block->evil_C, &but->rnapoin, but->rnaprop, value, &buf)) { + BLI_strncpy(str, buf, maxlen); + buf = str; + } + } else if (type == PROP_POINTER) { /* RNA pointer */ PointerRNA ptr = RNA_property_pointer_get(&but->rnapoin, but->rnaprop); buf = RNA_struct_name_get_alloc(&ptr, str, maxlen, &buf_len); } + else { + BLI_assert(0); + } if (!buf) { str[0] = '\0'; @@ -1698,7 +1709,7 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen) else if (buf && buf != str) { /* string was too long, we have to truncate */ memcpy(str, buf, MIN2(maxlen, (size_t)buf_len + 1)); - MEM_freeN(buf); + MEM_freeN((void *)buf); } } else if (but->type == IDPOIN) { @@ -1841,6 +1852,17 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) return 0; } + else if (type == PROP_ENUM) { + int value; + if (RNA_property_enum_value(but->block->evil_C, &but->rnapoin, but->rnaprop, str, &value)) { + RNA_property_enum_set(&but->rnapoin, but->rnaprop, value); + return 1; + } + return 0; + } + else { + BLI_assert(0); + } } } else if (but->type == IDPOIN) { diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index e000265bb1e..9759c22f30e 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1384,6 +1384,12 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN but->rnasearchprop = searchprop; but->flag |= UI_ICON_LEFT | UI_TEXT_LEFT; + if (RNA_property_type(prop) == PROP_ENUM) { + /* XXX, this will have a menu string, + * but in this case we just want the text */ + but->str[0] = 0; + } + uiButSetSearchFunc(but, rna_search_cb, but, NULL, NULL); } } @@ -1401,13 +1407,14 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna prop = RNA_struct_find_property(ptr, propname); if (!prop) { - RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); + RNA_warning("property not found: %s.%s", + RNA_struct_identifier(ptr->type), propname); return; } type = RNA_property_type(prop); - if (!ELEM(type, PROP_POINTER, PROP_STRING)) { - RNA_warning("Property %s must be a pointer or string", propname); + if (!ELEM3(type, PROP_POINTER, PROP_STRING, PROP_ENUM)) { + RNA_warning("Property %s must be a pointer, string or enum", propname); return; } @@ -1415,11 +1422,13 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna if (!searchprop) { - RNA_warning("search collection property not found: %s.%s", RNA_struct_identifier(ptr->type), searchpropname); + RNA_warning("search collection property not found: %s.%s", + RNA_struct_identifier(searchptr->type), searchpropname); return; } else if (RNA_property_type(searchprop) != PROP_COLLECTION) { - RNA_warning("search collection property is not a collection type: %s.%s", RNA_struct_identifier(ptr->type), searchpropname); + RNA_warning("search collection property is not a collection type: %s.%s", + RNA_struct_identifier(searchptr->type), searchpropname); return; } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index dbb401c898b..309fbdb1cea 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -185,7 +185,8 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem) /* fake button, it holds space for search items */ uiDefBut(block, LABEL, 0, "", 10, 15, w, h, NULL, 0, 0, 0, 0, NULL); - but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, w, 19, template.prv_rows, template.prv_cols, ""); + but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, w, 19, + template.prv_rows, template.prv_cols, ""); uiButSetSearchFunc(but, id_search_cb, &template, id_search_call_cb, idptr.data); } /* list view */ @@ -315,34 +316,70 @@ static const char *template_id_browse_tip(StructRNA *type) if (type) { switch (RNA_type_to_ID_code(type)) { case ID_SCE: return N_("Browse Scene to be linked"); - case ID_OB: return N_("Browse Object to be linked"); - case ID_ME: return N_("Browse Mesh Data to be linked"); - case ID_CU: return N_("Browse Curve Data to be linked"); - case ID_MB: return N_("Browse Metaball Data to be linked"); - case ID_MA: return N_("Browse Material to be linked"); - case ID_TE: return N_("Browse Texture to be linked"); - case ID_IM: return N_("Browse Image to be linked"); - case ID_LT: return N_("Browse Lattice Data to be linked"); - case ID_LA: return N_("Browse Lamp Data to be linked"); - case ID_CA: return N_("Browse Camera Data to be linked"); - case ID_WO: return N_("Browse World Settings to be linked"); + case ID_OB: return N_("Browse Object to be linked"); + case ID_ME: return N_("Browse Mesh Data to be linked"); + case ID_CU: return N_("Browse Curve Data to be linked"); + case ID_MB: return N_("Browse Metaball Data to be linked"); + case ID_MA: return N_("Browse Material to be linked"); + case ID_TE: return N_("Browse Texture to be linked"); + case ID_IM: return N_("Browse Image to be linked"); + case ID_LS: return N_("Browse Line Style Data to be linked"); + case ID_LT: return N_("Browse Lattice Data to be linked"); + case ID_LA: return N_("Browse Lamp Data to be linked"); + case ID_CA: return N_("Browse Camera Data to be linked"); + case ID_WO: return N_("Browse World Settings to be linked"); case ID_SCR: return N_("Choose Screen lay-out"); case ID_TXT: return N_("Browse Text to be linked"); case ID_SPK: return N_("Browse Speaker Data to be linked"); - case ID_SO: return N_("Browse Sound to be linked"); - case ID_AR: return N_("Browse Armature data to be linked"); - case ID_AC: return N_("Browse Action to be linked"); - case ID_NT: return N_("Browse Node Tree to be linked"); - case ID_BR: return N_("Browse Brush to be linked"); - case ID_PA: return N_("Browse Particle System to be linked"); - case ID_GD: return N_("Browse Grease Pencil Data to be linked"); - case ID_LS: return N_("Browse Line Style Data to be linked"); + case ID_SO: return N_("Browse Sound to be linked"); + case ID_AR: return N_("Browse Armature data to be linked"); + case ID_AC: return N_("Browse Action to be linked"); + case ID_NT: return N_("Browse Node Tree to be linked"); + case ID_BR: return N_("Browse Brush to be linked"); + case ID_PA: return N_("Browse Particle System to be linked"); + case ID_GD: return N_("Browse Grease Pencil Data to be linked"); } } return N_("Browse ID data to be linked"); } -static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, short idcode, int flag, const char *newop, const char *openop, const char *unlinkop) +/* Return a type-based i18n context, needed e.g. by "New" button. + * In most languages, this adjective takes different form based on gender of type name... + */ +static const char *template_id_context(StructRNA *type) +{ + if (type) { + switch (RNA_type_to_ID_code(type)) { + case ID_SCE: return BLF_I18NCONTEXT_ID_SCENE; + case ID_OB: return BLF_I18NCONTEXT_ID_OBJECT; + case ID_ME: return BLF_I18NCONTEXT_ID_MESH; + case ID_CU: return BLF_I18NCONTEXT_ID_CURVE; + case ID_MB: return BLF_I18NCONTEXT_ID_METABALL; + case ID_MA: return BLF_I18NCONTEXT_ID_MATERIAL; + case ID_TE: return BLF_I18NCONTEXT_ID_TEXTURE; + case ID_IM: return BLF_I18NCONTEXT_ID_IMAGE; + case ID_LS: return BLF_I18NCONTEXT_ID_FREESTYLELINESTYLE; + case ID_LT: return BLF_I18NCONTEXT_ID_LATTICE; + case ID_LA: return BLF_I18NCONTEXT_ID_LAMP; + case ID_CA: return BLF_I18NCONTEXT_ID_CAMERA; + case ID_WO: return BLF_I18NCONTEXT_ID_WORLD; + case ID_SCR: return BLF_I18NCONTEXT_ID_SCREEN; + case ID_TXT: return BLF_I18NCONTEXT_ID_TEXT; + case ID_SPK: return BLF_I18NCONTEXT_ID_SPEAKER; + case ID_SO: return BLF_I18NCONTEXT_ID_SOUND; + case ID_AR: return BLF_I18NCONTEXT_ID_ARMATURE; + case ID_AC: return BLF_I18NCONTEXT_ID_ACTION; + case ID_NT: return BLF_I18NCONTEXT_ID_NODETREE; + case ID_BR: return BLF_I18NCONTEXT_ID_BRUSH; + case ID_PA: return BLF_I18NCONTEXT_ID_PARTICLESETTINGS; + case ID_GD: return BLF_I18NCONTEXT_ID_GPENCIL; + } + } + return BLF_I18NCONTEXT_DEFAULT; +} + +static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, short idcode, int flag, + const char *newop, const char *openop, const char *unlinkop) { uiBut *but; uiBlock *block; @@ -350,6 +387,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str // ListBase *lb; // UNUSED ID *id, *idfrom; int editable = RNA_property_editable(&template->ptr, template->prop); + const char *i18n_ctxt = template_id_context(type); idptr = RNA_property_pointer_get(&template->ptr, template->prop); id = idptr.data; @@ -401,19 +439,20 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str //text_idbutton(id, name); name[0] = '\0'; - but = uiDefButR(block, TEX, 0, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, RNA_struct_ui_description(type)); + but = uiDefButR(block, TEX, 0, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, + &idptr, "name", -1, 0, 0, -1, -1, RNA_struct_ui_description(type)); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_RENAME)); if (user_alert) uiButSetFlag(but, UI_BUT_REDALERT); if (id->lib) { if (id->flag & LIB_INDIRECT) { - but = uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_INDIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, - TIP_("Indirect library datablock, cannot change")); + but = uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_INDIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, + NULL, 0, 0, 0, 0, TIP_("Indirect library datablock, cannot change")); uiButSetFlag(but, UI_BUT_DISABLED); } else { - but = uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_DIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, - TIP_("Direct linked library datablock, click to make local")); + but = uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_DIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, + NULL, 0, 0, 0, 0, TIP_("Direct linked library datablock, click to make local")); if (!id_make_local(id, 1 /* test */) || (idfrom && idfrom->lib)) uiButSetFlag(but, UI_BUT_DISABLED); } @@ -426,7 +465,8 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str BLI_snprintf(numstr, sizeof(numstr), "%d", id->us); - but = uiDefBut(block, BUT, 0, numstr, 0, 0, UI_UNIT_X + ((id->us < 10) ? 0 : 10), UI_UNIT_Y, NULL, 0, 0, 0, 0, + but = uiDefBut(block, BUT, 0, numstr, 0, 0, UI_UNIT_X + ((id->us < 10) ? 0 : 10), UI_UNIT_Y, + NULL, 0, 0, 0, 0, TIP_("Display number of users of this data (click to make a single-user copy)")); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE)); @@ -451,12 +491,39 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str if (flag & UI_ID_ADD_NEW) { int w = id ? UI_UNIT_X : (flag & UI_ID_OPEN) ? UI_UNIT_X * 3 : UI_UNIT_X * 6; + /* i18n markup, does nothing! */ + BLF_I18N_MSGID_MULTI_CTXT("New", BLF_I18NCONTEXT_DEFAULT, + BLF_I18NCONTEXT_ID_SCENE, + BLF_I18NCONTEXT_ID_OBJECT, + BLF_I18NCONTEXT_ID_MESH, + BLF_I18NCONTEXT_ID_CURVE, + BLF_I18NCONTEXT_ID_METABALL, + BLF_I18NCONTEXT_ID_MATERIAL, + BLF_I18NCONTEXT_ID_TEXTURE, + BLF_I18NCONTEXT_ID_IMAGE, + BLF_I18NCONTEXT_ID_LATTICE, + BLF_I18NCONTEXT_ID_LAMP, + BLF_I18NCONTEXT_ID_CAMERA, + BLF_I18NCONTEXT_ID_WORLD, + BLF_I18NCONTEXT_ID_SCREEN, + BLF_I18NCONTEXT_ID_TEXT); + BLF_I18N_MSGID_MULTI_CTXT("New", BLF_I18NCONTEXT_ID_SPEAKER, + BLF_I18NCONTEXT_ID_SOUND, + BLF_I18NCONTEXT_ID_ARMATURE, + BLF_I18NCONTEXT_ID_ACTION, + BLF_I18NCONTEXT_ID_NODETREE, + BLF_I18NCONTEXT_ID_BRUSH, + BLF_I18NCONTEXT_ID_PARTICLESETTINGS, + BLF_I18NCONTEXT_ID_GPENCIL); + if (newop) { - but = uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, (id) ? "" : IFACE_("New"), 0, 0, w, UI_UNIT_Y, NULL); + but = uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, + (id) ? "" : CTX_IFACE_(i18n_ctxt, "New"), 0, 0, w, UI_UNIT_Y, NULL); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); } else { - but = uiDefIconTextBut(block, BUT, 0, ICON_ZOOMIN, (id) ? "" : IFACE_("New"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + but = uiDefIconTextBut(block, BUT, 0, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(i18n_ctxt, "New"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); } @@ -468,11 +535,13 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str int w = id ? UI_UNIT_X : (flag & UI_ID_ADD_NEW) ? UI_UNIT_X * 3 : UI_UNIT_X * 6; if (openop) { - but = uiDefIconTextButO(block, BUT, openop, WM_OP_INVOKE_DEFAULT, ICON_FILESEL, (id) ? "" : IFACE_("Open"), 0, 0, w, UI_UNIT_Y, NULL); + but = uiDefIconTextButO(block, BUT, openop, WM_OP_INVOKE_DEFAULT, ICON_FILESEL, (id) ? "" : IFACE_("Open"), + 0, 0, w, UI_UNIT_Y, NULL); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN)); } else { - but = uiDefIconTextBut(block, BUT, 0, ICON_FILESEL, (id) ? "" : IFACE_("Open"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + but = uiDefIconTextBut(block, BUT, 0, ICON_FILESEL, (id) ? "" : IFACE_("Open"), 0, 0, w, UI_UNIT_Y, + NULL, 0, 0, 0, 0, NULL); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN)); } @@ -489,7 +558,8 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str } else { but = uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, - TIP_("Unlink datablock. Shift + Click to set users to zero, data will then not be saved")); + TIP_("Unlink datablock " + "(Shift + Click to set users to zero, data will then not be saved)")); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_DELETE)); if (RNA_property_flag(template->prop) & PROP_NEVER_NULL) @@ -506,7 +576,8 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str uiBlockEndAlign(block); } -static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int flag, int prv_rows, int prv_cols) +static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, + const char *openop, const char *unlinkop, int flag, int prv_rows, int prv_cols) { TemplateID *template; PropertyRNA *prop; @@ -546,19 +617,24 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const MEM_freeN(template); } -void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop) +void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, + const char *openop, const char *unlinkop) { - ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE, 0, 0); + ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, + UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE, 0, 0); } -void uiTemplateIDBrowse(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop) +void uiTemplateIDBrowse(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, + const char *openop, const char *unlinkop) { ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE | UI_ID_RENAME, 0, 0); } -void uiTemplateIDPreview(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int rows, int cols) +void uiTemplateIDPreview(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, + const char *openop, const char *unlinkop, int rows, int cols) { - ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS, rows, cols); + ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, + UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS, rows, cols); } /************************ ID Chooser Template ***************************/ @@ -568,7 +644,8 @@ void uiTemplateIDPreview(uiLayout *layout, bContext *C, PointerRNA *ptr, const c * - propname: property identifier for property that ID-pointer gets stored to * - proptypename: property identifier for property used to determine the type of ID-pointer that can be used */ -void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *proptypename, const char *text) +void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *proptypename, + const char *text) { PropertyRNA *propID, *propType; uiLayout *row; @@ -615,7 +692,8 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co * - propname: property identifier for property that path gets stored to * - root_ptr: struct that path gets built from */ -void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *UNUSED(root_ptr), const char *text) +void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *UNUSED(root_ptr), + const char *text) { PropertyRNA *propPath; uiLayout *row; @@ -780,7 +858,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, uiBlockBeginAlign(block); /* Softbody not allowed in this situation, enforce! */ if (((md->type != eModifierType_Softbody && md->type != eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && - (md->type != eModifierType_Surface) ) + (md->type != eModifierType_Surface) ) { uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE); uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE); @@ -792,7 +870,8 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, if (ob->type == OB_MESH) { if (modifier_couldBeCage(scene, md) && (index <= lastCageIndex)) { /* -- convert to rna ? */ - but = uiDefIconButBitI(block, TOG, eModifierMode_OnCage, 0, ICON_MESH_DATA, 0, 0, UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, + but = uiDefIconButBitI(block, TOG, eModifierMode_OnCage, 0, ICON_MESH_DATA, 0, 0, + UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, TIP_("Apply modifier to editing cage during Edit mode")); if (index < cageIndex) uiButSetFlag(but, UI_BUT_DISABLED); @@ -803,7 +882,8 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, /* place holder button */ uiBlockSetEmboss(block, UI_EMBOSSN); - but = uiDefIconBut(block, BUT, 0, ICON_NONE, 0, 0, UI_UNIT_X - 2, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, NULL); + but = uiDefIconBut(block, BUT, 0, ICON_NONE, 0, 0, UI_UNIT_X - 2, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, NULL); uiButSetFlag(but, UI_BUT_DISABLED); uiBlockSetEmboss(block, UI_EMBOSS); } @@ -813,7 +893,8 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, if (ELEM3(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_MeshDeform)) { /* add disabled pre-tessellated button, so users could have * message for this modifiers */ - but = uiDefIconButBitI(block, TOG, eModifierMode_ApplyOnSpline, 0, ICON_SURFACE_DATA, 0, 0, UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, + but = uiDefIconButBitI(block, TOG, eModifierMode_ApplyOnSpline, 0, ICON_SURFACE_DATA, 0, 0, + UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, TIP_("This modifier could be applied on splines' points only")); uiButSetFlag(but, UI_BUT_DISABLED); } @@ -867,15 +948,20 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT); uiItemEnumO(row, "OBJECT_OT_modifier_apply", IFACE_("Apply"), 0, "apply_as", MODIFIER_APPLY_DATA); - if (modifier_isSameTopology(md) && !modifier_isNonGeometrical(md)) - uiItemEnumO(row, "OBJECT_OT_modifier_apply", IFACE_("Apply as Shape Key"), 0, "apply_as", MODIFIER_APPLY_SHAPE); + if (modifier_isSameTopology(md) && !modifier_isNonGeometrical(md)) { + uiItemEnumO(row, "OBJECT_OT_modifier_apply", IFACE_("Apply as Shape Key"), 0, + "apply_as", MODIFIER_APPLY_SHAPE); + } } uiBlockClearButLock(block); uiBlockSetButLock(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE); - if (!ELEM5(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem, eModifierType_Cloth, eModifierType_Smoke)) + if (!ELEM5(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem, + eModifierType_Cloth, eModifierType_Smoke)) + { uiItemO(row, IFACE_("Copy"), ICON_NONE, "OBJECT_OT_modifier_copy"); + } } /* result is the layout block inside the box, that we return so that modifier settings can be drawn */ @@ -1047,8 +1133,10 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) uiBlockSetEmboss(block, UI_EMBOSSN); /* draw a ghost icon (for proxy) and also a lock beside it, to show that constraint is "proxy locked" */ - uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, ICON_GHOST, xco + 244, yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected")); - uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, ICON_LOCKED, xco + 262, yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected")); + uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, ICON_GHOST, xco + 244, yco, 19, 19, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected")); + uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, ICON_LOCKED, xco + 262, yco, 19, 19, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected")); uiBlockSetEmboss(block, UI_EMBOSS); } @@ -1077,7 +1165,8 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) /* enabled */ uiBlockSetEmboss(block, UI_EMBOSSN); - uiItemR(row, &ptr, "mute", 0, "", (con->flag & CONSTRAINT_OFF) ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF); + uiItemR(row, &ptr, "mute", 0, "", + (con->flag & CONSTRAINT_OFF) ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF); uiBlockSetEmboss(block, UI_EMBOSS); uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT); @@ -1234,14 +1323,22 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M RNA_pointer_create(id, &RNA_Texture, tex, &texture_ptr); uiLayoutRow(layout, TRUE); - uiDefButS(block, ROW, B_MATPRV, IFACE_("Texture"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_TEXTURE, 0, 0, ""); - if (GS(parent->name) == ID_MA) - uiDefButS(block, ROW, B_MATPRV, IFACE_("Material"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); - else if (GS(parent->name) == ID_LA) - uiDefButS(block, ROW, B_MATPRV, IFACE_("Lamp"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); - else if (GS(parent->name) == ID_WO) - uiDefButS(block, ROW, B_MATPRV, IFACE_("World"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); - uiDefButS(block, ROW, B_MATPRV, IFACE_("Both"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_BOTH, 0, 0, ""); + uiDefButS(block, ROW, B_MATPRV, IFACE_("Texture"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, + pr_texture, 10, TEX_PR_TEXTURE, 0, 0, ""); + if (GS(parent->name) == ID_MA) { + uiDefButS(block, ROW, B_MATPRV, IFACE_("Material"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, + pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); + } + else if (GS(parent->name) == ID_LA) { + uiDefButS(block, ROW, B_MATPRV, IFACE_("Lamp"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, + pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); + } + else if (GS(parent->name) == ID_WO) { + uiDefButS(block, ROW, B_MATPRV, IFACE_("World"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, + pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); + } + uiDefButS(block, ROW, B_MATPRV, IFACE_("Both"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, + pr_texture, 10, TEX_PR_BOTH, 0, 0, ""); /* Alpha button for texture preview */ if (*pr_texture != TEX_PR_OTHER) { @@ -1331,7 +1428,8 @@ static void colorband_update_cb(bContext *UNUSED(C), void *bt_v, void *coba_v) } /* offset aligns from bottom, standard width 300, height 115 */ -static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand *coba, int xoffs, int yoffs, RNAUpdateCb *cb) +static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand *coba, + int xoffs, int yoffs, RNAUpdateCb *cb) { uiBut *bt; uiLayout *row; @@ -1350,13 +1448,16 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand /* XXX, todo for later - convert to operator - campbell */ - bt = uiDefBut(block, BUT, 0, "F", 95 + xoffs, line1_y, 20, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Flip colorband")); + bt = uiDefBut(block, BUT, 0, "F", 95 + xoffs, line1_y, 20, UI_UNIT_Y, + NULL, 0, 0, 0, 0, TIP_("Flip colorband")); uiButSetNFunc(bt, colorband_flip_cb, MEM_dupallocN(cb), coba); - uiDefButS(block, NUM, 0, "", 120 + xoffs, line1_y, 80, UI_UNIT_Y, &coba->cur, 0.0, (float)(MAX2(0, coba->tot - 1)), 0, 0, TIP_("Choose active color stop")); + uiDefButS(block, NUM, 0, "", 120 + xoffs, line1_y, 80, UI_UNIT_Y, &coba->cur, 0.0, (float)(MAX2(0, coba->tot - 1)), + 0, 0, TIP_("Choose active color stop")); - bt = uiDefButS(block, MENU, 0, IFACE_("Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4"), - 210 + xoffs, line1_y, 90, UI_UNIT_Y, &coba->ipotype, 0.0, 0.0, 0, 0, TIP_("Set interpolation between color stops")); + bt = uiDefButS(block, MENU, 0, IFACE_("Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4"), + 210 + xoffs, line1_y, 90, UI_UNIT_Y, &coba->ipotype, 0.0, 0.0, 0, 0, + TIP_("Set interpolation between color stops")); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); uiBlockEndAlign(block); @@ -1392,10 +1493,11 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand bt = uiDefBut(block, BUT, 0, IFACE_("Add"), xs, butr->ymin + UI_UNIT_Y, 2.0f * unit, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Add a new color stop to the colorband")); uiButSetNFunc(bt, colorband_add_cb, MEM_dupallocN(cb), coba); - bt = uiDefBut(block, BUT, 0, IFACE_("Delete"), xs + 2.0f * unit, butr->ymin + UI_UNIT_Y, 1.5f * unit, UI_UNIT_Y, NULL, 0, 0, 0, 0, - TIP_("Delete the active position")); + bt = uiDefBut(block, BUT, 0, IFACE_("Delete"), xs + 2.0f * unit, butr->ymin + UI_UNIT_Y, 1.5f * unit, UI_UNIT_Y, + NULL, 0, 0, 0, 0, TIP_("Delete the active position")); uiButSetNFunc(bt, colorband_del_cb, MEM_dupallocN(cb), coba); - bt = uiDefBut(block, BUT, 0, "F", xs + 3.5f * unit, butr->ymin + UI_UNIT_Y, 0.5f * unit, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Flip the color ramp")); + bt = uiDefBut(block, BUT, 0, "F", xs + 3.5f * unit, butr->ymin + UI_UNIT_Y, 0.5f * unit, UI_UNIT_Y, + NULL, 0, 0, 0, 0, TIP_("Flip the color ramp")); uiButSetNFunc(bt, colorband_flip_cb, MEM_dupallocN(cb), coba); uiBlockEndAlign(block); @@ -1407,7 +1509,7 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand } bt = uiDefButS(block, MENU, 0, IFACE_("Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4"), - xs + 10.0f * unit, butr->ymin + UI_UNIT_Y, unit * 4, UI_UNIT_Y, &coba->ipotype, 0.0, 0.0, 0, 0, + xs + 10.0f * unit, butr->ymin + UI_UNIT_Y, unit * 4, UI_UNIT_Y, &coba->ipotype, 0.0, 0.0, 0, 0, TIP_("Set interpolation between color stops")); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); @@ -1417,7 +1519,8 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand uiBlockEndAlign(block); } -static void colorband_buttons_layout(uiLayout *layout, uiBlock *block, ColorBand *coba, rctf *butr, int small, RNAUpdateCb *cb) +static void colorband_buttons_layout(uiLayout *layout, uiBlock *block, ColorBand *coba, rctf *butr, + int small, RNAUpdateCb *cb) { if (small) colorband_buttons_small(layout, block, coba, butr, cb); @@ -1486,7 +1589,8 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname hist->height = (hist->height <= UI_UNIT_Y) ? UI_UNIT_Y : hist->height; - bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), hist->height, hist, 0, 0, 0, 0, ""); + bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), hist->height, hist, + 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); MEM_freeN(cb); @@ -1523,7 +1627,8 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname) scopes->wavefrm_height = (scopes->wavefrm_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->wavefrm_height; - bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), scopes->wavefrm_height, scopes, 0, 0, 0, 0, ""); + bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), scopes->wavefrm_height, scopes, + 0, 0, 0, 0, ""); (void)bt; /* UNUSED */ MEM_freeN(cb); @@ -1560,7 +1665,8 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna scopes->vecscope_height = (scopes->vecscope_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->vecscope_height; - bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), scopes->vecscope_height, scopes, 0, 0, 0, 0, ""); + bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), + scopes->vecscope_height, scopes, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); MEM_freeN(cb); @@ -1659,10 +1765,14 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *ar, void *cumap_v) uiButSetFunc(bt, curvemap_buttons_setclip, cumap, NULL); uiBlockBeginAlign(block); - uiDefButF(block, NUM, 0, IFACE_("Min X "), 0, 4 * UI_UNIT_Y, width, UI_UNIT_Y, &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 0, ""); - uiDefButF(block, NUM, 0, IFACE_("Min Y "), 0, 3 * UI_UNIT_Y, width, UI_UNIT_Y, &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 0, ""); - uiDefButF(block, NUM, 0, IFACE_("Max X "), 0, 2 * UI_UNIT_Y, width, UI_UNIT_Y, &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 0, ""); - uiDefButF(block, NUM, 0, IFACE_("Max Y "), 0, UI_UNIT_Y, width, UI_UNIT_Y, &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 0, ""); + uiDefButF(block, NUM, 0, IFACE_("Min X "), 0, 4 * UI_UNIT_Y, width, UI_UNIT_Y, + &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 0, ""); + uiDefButF(block, NUM, 0, IFACE_("Min Y "), 0, 3 * UI_UNIT_Y, width, UI_UNIT_Y, + &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 0, ""); + uiDefButF(block, NUM, 0, IFACE_("Max X "), 0, 2 * UI_UNIT_Y, width, UI_UNIT_Y, + &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 0, ""); + uiDefButF(block, NUM, 0, IFACE_("Max Y "), 0, UI_UNIT_Y, width, UI_UNIT_Y, + &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 0, ""); uiBlockSetDirection(block, UI_RIGHT); @@ -1711,12 +1821,18 @@ static uiBlock *curvemap_tools_func(bContext *C, ARegion *ar, void *cumap_v) block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Extend Horizontal"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 4, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Extend Extrapolated"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 5, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y, + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y, + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y, + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Extend Horizontal"), 0, yco -= UI_UNIT_Y, + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 4, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Extend Extrapolated"), 0, yco -= UI_UNIT_Y, + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 5, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y, + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 50); @@ -1733,10 +1849,14 @@ static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *ar, void *cumap_ block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y, + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y, + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y, + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y, + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 50); @@ -1776,7 +1896,8 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v) } /* still unsure how this call evolves... we use labeltype for defining what curve-channels to show */ -static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labeltype, int levels, int brush, RNAUpdateCb *cb) +static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labeltype, int levels, + int brush, RNAUpdateCb *cb) { CurveMapping *cumap = ptr->data; CurveMap *cm = &cumap->cm[cumap->cur]; @@ -1957,7 +2078,8 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propn #define WHEEL_SIZE 100 /* This template now follows User Preference for type - name is not correct anymore... */ -void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic) +void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, const char *propname, int value_slider, + int lock, int lock_luminosity, int cubic) { PropertyRNA *prop = RNA_struct_find_property(ptr, propname); uiBlock *block = uiLayoutGetBlock(layout); @@ -1977,16 +2099,20 @@ void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, const char *propna switch (U.color_picker_type) { case USER_CP_CIRCLE: - but = uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, 0, 0, ""); + but = uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, + -1, 0.0, 0.0, 0, 0, ""); break; case USER_CP_SQUARE_SV: - but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, UI_GRAD_SV, 0, ""); + but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, + -1, 0.0, 0.0, UI_GRAD_SV, 0, ""); break; case USER_CP_SQUARE_HS: - but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, UI_GRAD_HS, 0, ""); + but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, + -1, 0.0, 0.0, UI_GRAD_HS, 0, ""); break; case USER_CP_SQUARE_HV: - but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, UI_GRAD_HV, 0, ""); + but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, + -1, 0.0, 0.0, UI_GRAD_HV, 0, ""); break; } @@ -2011,19 +2137,23 @@ void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, const char *propna switch (U.color_picker_type) { case USER_CP_CIRCLE: uiItemS(row); - uiDefButR_prop(block, HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop, -1, softmin, softmax, UI_GRAD_V_ALT, 0, ""); + uiDefButR_prop(block, HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop, + -1, softmin, softmax, UI_GRAD_V_ALT, 0, ""); break; case USER_CP_SQUARE_SV: uiItemS(col); - uiDefButR_prop(block, HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, -1, softmin, softmax, UI_GRAD_SV + 3, 0, ""); + uiDefButR_prop(block, HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, + -1, softmin, softmax, UI_GRAD_SV + 3, 0, ""); break; case USER_CP_SQUARE_HS: uiItemS(col); - uiDefButR_prop(block, HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, -1, softmin, softmax, UI_GRAD_HS + 3, 0, ""); + uiDefButR_prop(block, HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, + -1, softmin, softmax, UI_GRAD_HS + 3, 0, ""); break; case USER_CP_SQUARE_HV: uiItemS(col); - uiDefButR_prop(block, HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, -1, softmin, softmax, UI_GRAD_HV + 3, 0, ""); + uiDefButR_prop(block, HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, + -1, softmin, softmax, UI_GRAD_HV + 3, 0, ""); break; } @@ -2185,7 +2315,8 @@ void uiTemplateGameStates(uiLayout *layout, PointerRNA *ptr, const char *propnam else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, state)) icon = ICON_LAYER_USED; - but = uiDefIconButR_prop(block, ICONTOG, 0, icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2, ptr, prop, state, 0, 0, -1, -1, sca_state_name_get(ob, state)); + but = uiDefIconButR_prop(block, ICONTOG, 0, icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2, ptr, prop, + state, 0, 0, -1, -1, sca_state_name_get(ob, state)); uiButSetFunc(but, handle_layer_buttons, but, SET_INT_IN_POINTER(state)); but->type = TOG; } @@ -2233,7 +2364,8 @@ static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon, int return rnaicon; } -static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *itemptr, int i, int rnaicon, PointerRNA *activeptr, PropertyRNA *activeprop, const char *prop_list_id) +static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *itemptr, int i, + int rnaicon, PointerRNA *activeptr, PropertyRNA *activeprop, const char *prop_list_id) { uiBlock *block = uiLayoutGetBlock(layout); uiBut *but; @@ -2247,7 +2379,8 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe /* list item behind label & other buttons */ sub = uiLayoutRow(overlap, FALSE); - but = uiDefButR_prop(block, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, activeptr, activeprop, 0, 0, i, 0, 0, ""); + but = uiDefButR_prop(block, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, activeptr, activeprop, + 0, 0, i, 0, 0, ""); uiButSetFlag(but, UI_BUT_NO_TOOLTIP); sub = uiLayoutRow(overlap, FALSE); @@ -2264,7 +2397,8 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe if (itemptr->type == &RNA_MeshTexturePolyLayer || itemptr->type == &RNA_MeshLoopColorLayer) { uiItemL(sub, name, icon); uiBlockSetEmboss(block, UI_EMBOSSN); - uiDefIconButR(block, TOG, 0, ICON_SCENE, 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "active_render", 0, 0, 0, 0, 0, NULL); + uiDefIconButR(block, TOG, 0, ICON_SCENE, 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "active_render", + 0, 0, 0, 0, 0, NULL); uiBlockSetEmboss(block, UI_EMBOSS); } else if (RNA_struct_is_a(itemptr->type, &RNA_MaterialTextureSlot)) { @@ -2357,7 +2491,8 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe uiItemL(sub, name_final, icon); if (dynamicPaint_surfaceHasColorPreview(surface)) { uiBlockSetEmboss(block, UI_EMBOSSN); - uiDefIconButR(block, OPTION, 0, (surface->flags & MOD_DPAINT_PREVIEW) ? ICON_RESTRICT_VIEW_OFF : ICON_RESTRICT_VIEW_ON, + uiDefIconButR(block, OPTION, 0, + (surface->flags & MOD_DPAINT_PREVIEW) ? ICON_RESTRICT_VIEW_OFF : ICON_RESTRICT_VIEW_ON, 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "show_preview", 0, 0, 0, 0, 0, NULL); uiBlockSetEmboss(block, UI_EMBOSS); } @@ -2446,7 +2581,8 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe } } -void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *activeptr, const char *activepropname, const char *prop_list, int rows, int maxrows, int listtype) +void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *activeptr, + const char *activepropname, const char *prop_list, int rows, int maxrows, int listtype) { PropertyRNA *prop = NULL, *activeprop; PropertyType type, activetype; @@ -2522,7 +2658,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * row = uiLayoutRow(col, FALSE); icon = list_item_icon_get(C, &itemptr, rnaicon, 1); - but = uiDefIconButR_prop(block, LISTROW, 0, icon, 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, activeptr, activeprop, 0, 0, i, 0, 0, ""); + but = uiDefIconButR_prop(block, LISTROW, 0, icon, 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, activeptr, + activeprop, 0, 0, i, 0, 0, ""); uiButSetFlag(but, UI_BUT_NO_TOOLTIP); @@ -2564,7 +2701,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * /* next/prev button */ BLI_snprintf(numstr, sizeof(numstr), "%d :", i); - but = uiDefIconTextButR_prop(block, NUM, 0, 0, numstr, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, activeptr, activeprop, 0, 0, 0, 0, 0, ""); + but = uiDefIconTextButR_prop(block, NUM, 0, 0, numstr, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, activeptr, + activeprop, 0, 0, 0, 0, 0, ""); if (i == 0) uiButSetFlag(but, UI_BUT_DISABLED); } @@ -2621,7 +2759,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * /* add scrollbar */ if (len > items) { col = uiLayoutColumn(row, FALSE); - uiDefButI(block, SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * items, &pa->list_scroll, 0, len - items, items, 0, ""); + uiDefButI(block, SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * items, &pa->list_scroll, + 0, len - items, items, 0, ""); } } } @@ -2768,19 +2907,19 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) ui_abs = uiLayoutAbsolute(layout, FALSE); (void)ui_abs; /* UNUSED */ - uiDefIconBut(block, BUT, handle_event, ICON_PANEL_CLOSE, - 0, UI_UNIT_Y * 0.1, UI_UNIT_X * 0.8, UI_UNIT_Y * 0.8, NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop this job")); + uiDefIconBut(block, BUT, handle_event, ICON_PANEL_CLOSE, 0, UI_UNIT_Y * 0.1, UI_UNIT_X * 0.8, UI_UNIT_Y * 0.8, + NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop this job")); uiDefBut(block, PROGRESSBAR, 0, WM_jobs_name(wm, owner), UI_UNIT_X, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, WM_jobs_progress(wm, owner), 0, TIP_("Progress")); uiLayoutRow(layout, FALSE); } if (WM_jobs_test(wm, screen, WM_JOB_TYPE_SCREENCAST)) - uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0, 0, 85, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, - TIP_("Stop screencast")); + uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0, 0, 85, UI_UNIT_Y, + NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop screencast")); if (screen->animtimer) - uiDefIconTextBut(block, BUT, B_STOPANIM, ICON_CANCEL, IFACE_("Anim Player"), 0, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, - TIP_("Stop animation playback")); + uiDefIconTextBut(block, BUT, B_STOPANIM, ICON_CANCEL, IFACE_("Anim Player"), 0, 0, 100, UI_UNIT_Y, + NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop animation playback")); } /************************* Reports for Last Operator Template **************************/ @@ -2819,7 +2958,8 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) rgb_float_to_uchar(but->col, rti->col); but->col[3] = 255; - but = uiDefBut(block, ROUNDBOX, 0, "", UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); + but = uiDefBut(block, ROUNDBOX, 0, "", UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, + NULL, 0.0f, 0.0f, 0, 0, ""); but->col[0] = but->col[1] = but->col[2] = FTOCHAR(rti->grayscale); but->col[3] = 255; @@ -2840,14 +2980,15 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) uiBlockSetEmboss(block, UI_EMBOSSN); if (reports->list.first != reports->list.last) - uiDefIconButO(block, BUT, "UI_OT_reports_to_textblock", WM_OP_INVOKE_REGION_WIN, icon, 2, 0, - UI_UNIT_X, UI_UNIT_Y, TIP_("Click to see the remaining reports in text block: 'Recent Reports'")); + uiDefIconButO(block, BUT, "UI_OT_reports_to_textblock", WM_OP_INVOKE_REGION_WIN, icon, 2, 0, UI_UNIT_X, + UI_UNIT_Y, TIP_("Click to see the remaining reports in text block: 'Recent Reports'")); else uiDefIconBut(block, LABEL, 0, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); uiBlockSetEmboss(block, UI_EMBOSS); - uiDefBut(block, LABEL, 0, report->message, UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); + uiDefBut(block, LABEL, 0, report->message, UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, + NULL, 0.0f, 0.0f, 0, 0, ""); } /********************************* Keymap *************************************/ diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index b8736d4f1d0..65d70e231a4 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -108,8 +108,8 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op) obedit = make_prim_init(C, "Plane", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); - if (!EDBM_op_call_and_selectf(em, op, "vertout", - "create_grid xsegments=%i ysegments=%i size=%f mat=%m4", 1, 1, dia, mat)) + if (!EDBM_op_call_and_selectf(em, op, "verts.out", + "create_grid x_segments=%i y_segments=%i size=%f mat=%m4", 1, 1, dia, mat)) { return OPERATOR_CANCELLED; } @@ -149,7 +149,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op) obedit = make_prim_init(C, "Cube", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); - if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_cube mat=%m4 size=%f", mat, dia * 2.0f)) { + if (!EDBM_op_call_and_selectf(em, op, "verts.out", "create_cube mat=%m4 size=%f", mat, dia * 2.0f)) { return OPERATOR_CANCELLED; } @@ -198,7 +198,7 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op) obedit = make_prim_init(C, "Circle", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); - if (!EDBM_op_call_and_selectf(em, op, "vertout", + if (!EDBM_op_call_and_selectf(em, op, "verts.out", "create_circle segments=%i diameter=%f cap_ends=%b cap_tris=%b mat=%m4", RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius") * dia, cap_end, cap_tri, mat)) @@ -253,7 +253,7 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op) em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf( - em, op, "vertout", + em, op, "verts.out", "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f mat=%m4", RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius") * dia, @@ -313,7 +313,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op) em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf( - em, op, "vertout", + em, op, "verts.out", "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f mat=%m4", RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1") * dia, RNA_float_get(op->ptr, "radius2") * dia, cap_end, cap_tri, RNA_float_get(op->ptr, "depth") * dia, mat)) @@ -368,8 +368,8 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op) obedit = make_prim_init(C, "Grid", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); - if (!EDBM_op_call_and_selectf(em, op, "vertout", - "create_grid xsegments=%i ysegments=%i size=%f mat=%m4", + if (!EDBM_op_call_and_selectf(em, op, "verts.out", + "create_grid x_segments=%i y_segments=%i size=%f mat=%m4", RNA_int_get(op->ptr, "x_subdivisions"), RNA_int_get(op->ptr, "y_subdivisions"), RNA_float_get(op->ptr, "size") * dia, mat)) @@ -427,7 +427,7 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op) em = BMEdit_FromObject(obedit); - if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_monkey mat=%m4", mat)) { + if (!EDBM_op_call_and_selectf(em, op, "verts.out", "create_monkey mat=%m4", mat)) { return OPERATOR_CANCELLED; } @@ -466,8 +466,8 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) obedit = make_prim_init(C, "Sphere", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); - if (!EDBM_op_call_and_selectf(em, op, "vertout", - "create_uvsphere segments=%i revolutions=%i diameter=%f mat=%m4", + if (!EDBM_op_call_and_selectf(em, op, "verts.out", + "create_uvsphere u_segments=%i v_segments=%i diameter=%f mat=%m4", RNA_int_get(op->ptr, "segments"), RNA_int_get(op->ptr, "ring_count"), RNA_float_get(op->ptr, "size") * dia, mat)) { @@ -518,7 +518,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op) em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf( - em, op, "vertout", + em, op, "verts.out", "create_icosphere subdivisions=%i diameter=%f mat=%m4", RNA_int_get(op->ptr, "subdivisions"), RNA_float_get(op->ptr, "size") * dia, mat)) diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 5ba85115b2f..aed16be5b73 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1823,7 +1823,7 @@ static void remerge_faces(KnifeTool_OpData *kcd) BMO_op_initf(bm, &bmop, "beautify_fill faces=%ff constrain_edges=%fe", FACE_NEW, BOUNDARY); BMO_op_exec(bm, &bmop); - BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_FACE, FACE_NEW); + BMO_slot_buffer_flag_enable(bm, &bmop, "geom.out", BM_FACE, FACE_NEW); BMO_op_finish(bm, &bmop); diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index 6379bdbc0ca..d3a4c951e06 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -489,7 +489,7 @@ static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *u } /* face should never exist */ - BLI_assert(BM_face_exists(bm, f_verts, f_verts[3] ? 4 : 3, &f) == FALSE); + BLI_assert(BM_face_exists(f_verts, f_verts[3] ? 4 : 3, &f) == FALSE); f = BM_face_create_quad_tri_v(bm, f_verts, f_verts[3] ? 4 : 3, f_example, FALSE); diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 8b217223907..2f40d281505 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -734,7 +734,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) EDBM_flag_disable_all(em, BM_ELEM_SELECT); /* select the output */ - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_ALL, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_ALL, BM_ELEM_SELECT, TRUE); /* finish the operator */ if (!EDBM_op_finish(em, &bmop, op, TRUE)) { @@ -775,7 +775,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) EDBM_flag_disable_all(em, BM_ELEM_SELECT); /* select the output */ - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "edgeout", BM_ALL, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "edges.out", BM_ALL, BM_ELEM_SELECT, TRUE); EDBM_selectmode_flush(em); /* finish the operator */ @@ -819,7 +819,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) EDBM_flag_disable_all(em, BM_ELEM_SELECT); /* select the output */ - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "vertout", BM_ALL, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_ALL, BM_ELEM_SELECT, TRUE); /* finish the operator */ if (!EDBM_op_finish(em, &bmop, op, TRUE)) { @@ -1085,7 +1085,7 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot) /* ***************** loop select (non modal) ************** */ -static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) +static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short deselect, short toggle, short ring) { ViewContext vc; BMEditMesh *em; @@ -1104,14 +1104,20 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) eed = EDBM_edge_find_nearest(&vc, &dist); if (eed) { - if (extend == 0) { + if (extend == 0 && deselect == 0 && toggle == 0) { EDBM_flag_disable_all(em, BM_ELEM_SELECT); } - if (BM_elem_flag_test(eed, BM_ELEM_SELECT) == 0) { + if (extend) { select = TRUE; } - else if (extend) { + else if (deselect) { + select = FALSE; + } + else if (BM_elem_flag_test(eed, BM_ELEM_SELECT) == 0) { + select = TRUE; + } + else if (toggle) { select = FALSE; } @@ -1204,6 +1210,8 @@ static int edbm_select_loop_invoke(bContext *C, wmOperator *op, wmEvent *event) view3d_operator_needs_opengl(C); mouse_mesh_loop(C, event->mval, RNA_boolean_get(op->ptr, "extend"), + RNA_boolean_get(op->ptr, "deselect"), + RNA_boolean_get(op->ptr, "toggle"), RNA_boolean_get(op->ptr, "ring")); /* cannot do tweaks for as long this keymap is after transform map */ @@ -1226,6 +1234,8 @@ void MESH_OT_loop_select(wmOperatorType *ot) /* properties */ RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "Extend the selection"); + RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Remove from the selection"); + RNA_def_boolean(ot->srna, "toggle", 0, "Toggle Select", "Toggle the selection"); RNA_def_boolean(ot->srna, "ring", 0, "Select Ring", "Select ring"); } @@ -1244,6 +1254,8 @@ void MESH_OT_edgering_select(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); + RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Remove from the selection"); + RNA_def_boolean(ot->srna, "toggle", 0, "Toggle Select", "Toggle the selection"); RNA_def_boolean(ot->srna, "ring", 1, "Select Ring", "Select ring"); } @@ -2248,6 +2260,8 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent * return OPERATOR_CANCELLED; if (limit) { + /* grr, shouldn't need to alloc BMO flags here */ + BM_mesh_elem_toolflags_ensure(bm); /* hflag no-seam --> bmo-tag */ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { /* BMESH_TODO, don't use 'BM_ELEM_SELECT' here, its a HFLAG only! */ @@ -2340,6 +2354,8 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) } if (limit) { + /* grr, shouldn't need to alloc BMO flags here */ + BM_mesh_elem_toolflags_ensure(bm); BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { /* BMESH_TODO, don't use 'BM_ELEM_SELECT' here, its a HFLAG only! */ BMO_elem_flag_set(bm, e, BM_ELEM_SELECT, !BM_elem_flag_test(e, BM_ELEM_SEAM)); @@ -2360,6 +2376,10 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) } } BMW_end(&walker); + + if (limit) { + BM_mesh_elem_toolflags_clear(bm); + } } else { BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { @@ -2505,6 +2525,9 @@ static void walker_deselect_nth(BMEditMesh *em, int nth, int offset, BMHeader *h break; } + /* grr, shouldn't need to alloc BMO flags here */ + BM_mesh_elem_toolflags_ensure(bm); + /* Walker restrictions uses BMO flags, not header flags, * so transfer BM_ELEM_SELECT from HFlags onto a BMO flag layer. */ BMO_push(bm, NULL); diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c index d370b5a881e..c32033054e0 100644 --- a/source/blender/editors/mesh/editmesh_slide.c +++ b/source/blender/editors/mesh/editmesh_slide.c @@ -738,10 +738,10 @@ static int edbm_vertex_slide_exec_ex(bContext *C, wmOperator *op, const int do_u BMO_op_exec(bm, &bmop); /* Deselect the input edges */ - BMO_slot_buffer_hflag_disable(bm, &bmop, "edge", BM_ALL, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_disable(bm, bmop.slots_in, "edge", BM_ALL, BM_ELEM_SELECT, TRUE); /* Select the output vert */ - BMO_slot_buffer_hflag_enable(bm, &bmop, "vertout", BM_ALL, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "verts.out", BM_ALL, BM_ELEM_SELECT, TRUE); /* Flush the select buffers */ EDBM_selectmode_flush(em); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 2b3f7faf8fc..eb98efdfea3 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -72,6 +72,7 @@ #include "RE_render_ext.h" #include "UI_interface.h" +#include "UI_resources.h" #include "mesh_intern.h" @@ -242,7 +243,7 @@ static short edbm_extrude_discrete_faces(BMEditMesh *em, wmOperator *op, const c BMO_op_exec(em->bm, &bmop); - BMO_ITER (f, &siter, em->bm, &bmop, "faceout", BM_FACE) { + BMO_ITER (f, &siter, bmop.slots_out, "faces.out", BM_FACE) { BM_face_select_set(em->bm, f, TRUE); /* set face vertex normals to face normal */ @@ -269,7 +270,7 @@ static short edbm_extrude_edges_indiv(BMEditMesh *em, wmOperator *op, const char EDBM_flag_disable_all(em, BM_ELEM_SELECT); BMO_op_exec(em->bm, &bmop); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_VERT | BM_EDGE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_VERT | BM_EDGE, BM_ELEM_SELECT, TRUE); if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return 0; @@ -286,10 +287,10 @@ static short edbm_extrude_verts_indiv(BMEditMesh *em, wmOperator *op, const char EDBM_op_init(em, &bmop, op, "extrude_vert_indiv verts=%hv", hflag); /* deselect original verts */ - BMO_slot_buffer_hflag_disable(em->bm, &bmop, "verts", BM_VERT, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_in, "verts", BM_VERT, BM_ELEM_SELECT, TRUE); BMO_op_exec(em->bm, &bmop); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "vertout", BM_VERT, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_VERT, BM_ELEM_SELECT, TRUE); if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return 0; @@ -308,9 +309,12 @@ static short edbm_extrude_edge(Object *obedit, BMEditMesh *em, const char hflag, BMFace *f; ModifierData *md; BMElem *ele; + BMOpSlot *slot_edges_exclude; BMO_op_init(bm, &extop, BMO_FLAG_DEFAULTS, "extrude_face_region"); - BMO_slot_buffer_from_enabled_hflag(bm, &extop, "edgefacein", BM_VERT | BM_EDGE | BM_FACE, hflag); + BMO_slot_buffer_from_enabled_hflag(bm, &extop, extop.slots_in, "geom", BM_VERT | BM_EDGE | BM_FACE, hflag); + + slot_edges_exclude = BMO_slot_get(extop.slots_in, "edges_exclude"); /* If a mirror modifier with clipping is on, we need to adjust some * of the cases above to handle edges on the line of symmetry. @@ -350,21 +354,21 @@ static short edbm_extrude_edge(Object *obedit, BMEditMesh *em, const char hflag, if ((fabsf(co1[0]) < mmd->tolerance) && (fabsf(co2[0]) < mmd->tolerance)) { - BMO_slot_map_ptr_insert(bm, &extop, "exclude", edge, NULL); + BMO_slot_map_ptr_insert(&extop, slot_edges_exclude, edge, NULL); } } if (mmd->flag & MOD_MIR_AXIS_Y) { if ((fabsf(co1[1]) < mmd->tolerance) && (fabsf(co2[1]) < mmd->tolerance)) { - BMO_slot_map_ptr_insert(bm, &extop, "exclude", edge, NULL); + BMO_slot_map_ptr_insert(&extop, slot_edges_exclude, edge, NULL); } } if (mmd->flag & MOD_MIR_AXIS_Z) { if ((fabsf(co1[2]) < mmd->tolerance) && (fabsf(co2[2]) < mmd->tolerance)) { - BMO_slot_map_ptr_insert(bm, &extop, "exclude", edge, NULL); + BMO_slot_map_ptr_insert(&extop, slot_edges_exclude, edge, NULL); } } } @@ -379,7 +383,7 @@ static short edbm_extrude_edge(Object *obedit, BMEditMesh *em, const char hflag, zero_v3(nor); - BMO_ITER (ele, &siter, bm, &extop, "geomout", BM_ALL) { + BMO_ITER (ele, &siter, extop.slots_out, "geom.out", BM_ALL) { BM_elem_select_set(bm, ele, TRUE); if (ele->head.htype == BM_FACE) { @@ -449,7 +453,7 @@ static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op) for (a = 0; a < steps; a++) { edbm_extrude_edge(obedit, em, BM_ELEM_SELECT, nor); - //BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS, "extrude_face_region edgefacein=%hef", BM_ELEM_SELECT); + //BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS, "extrude_face_region geom=%hef", BM_ELEM_SELECT); BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS, "translate vec=%v verts=%hv", (float *)dvec, BM_ELEM_SELECT); @@ -915,7 +919,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent EDBM_op_init(vc.em, &bmop, op, "create_vert co=%v", min); BMO_op_exec(vc.em->bm, &bmop); - BMO_ITER (v1, &oiter, vc.em->bm, &bmop, "newvertout", BM_VERT) { + BMO_ITER (v1, &oiter, bmop.slots_out, "vert.out", BM_VERT) { BM_vert_select_set(vc.em->bm, v1, TRUE); } @@ -1110,8 +1114,8 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op) } BMO_op_exec(em->bm, &bmop); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_FACE, BM_ELEM_SELECT, TRUE); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "edgeout", BM_EDGE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_SELECT, TRUE); if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; @@ -1261,7 +1265,7 @@ static int edbm_vert_connect(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } BMO_op_exec(bm, &bmop); - len = BMO_slot_get(&bmop, "edgeout")->len; + len = BMO_slot_get(bmop.slots_out, "edges.out")->len; if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; } @@ -1301,7 +1305,7 @@ static int edbm_edge_split_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } BMO_op_exec(bm, &bmop); - len = BMO_slot_get(&bmop, "edgeout")->len; + len = BMO_slot_get(bmop.slots_out, "edges.out")->len; if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; } @@ -1339,7 +1343,7 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op) BMO_op_exec(em->bm, &bmop); EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "newout", BM_ALL, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_ALL, BM_ELEM_SELECT, TRUE); if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; @@ -1405,8 +1409,8 @@ void MESH_OT_flip_normals(wmOperatorType *ot) } static const EnumPropertyItem direction_items[] = { - {DIRECTION_CW, "CW", 0, "Clockwise", ""}, - {DIRECTION_CCW, "CCW", 0, "Counter Clockwise", ""}, + {FALSE, "CW", 0, "Clockwise", ""}, + {TRUE, "CCW", 0, "Counter Clockwise", ""}, {0, NULL, 0, NULL, NULL} }; @@ -1418,7 +1422,7 @@ static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op) BMOperator bmop; BMEdge *eed; BMIter iter; - const int do_ccw = RNA_enum_get(op->ptr, "direction") == 1; + const int use_ccw = RNA_boolean_get(op->ptr, "use_ccw"); int tot = 0; if (em->bm->totedgesel == 0) { @@ -1448,17 +1452,17 @@ static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Could not find any selected edges that can be rotated"); return OPERATOR_CANCELLED; } - - EDBM_op_init(em, &bmop, op, "rotate_edges edges=%he ccw=%b", BM_ELEM_TAG, do_ccw); + + EDBM_op_init(em, &bmop, op, "rotate_edges edges=%he use_ccw=%b", BM_ELEM_TAG, use_ccw); /* avoids leaving old verts selected which can be a problem running multiple times, * since this means the edges become selected around the face which then attempt to rotate */ - BMO_slot_buffer_hflag_disable(em->bm, &bmop, "edges", BM_EDGE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_in, "edges", BM_EDGE, BM_ELEM_SELECT, TRUE); BMO_op_exec(em->bm, &bmop); /* edges may rotate into hidden vertices, if this does _not_ run we get an ilogical state */ - BMO_slot_buffer_hflag_disable(em->bm, &bmop, "edgeout", BM_EDGE, BM_ELEM_HIDDEN, TRUE); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "edgeout", BM_EDGE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_HIDDEN, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_SELECT, TRUE); EDBM_selectmode_flush(em); if (!EDBM_op_finish(em, &bmop, op, TRUE)) { @@ -1485,7 +1489,7 @@ void MESH_OT_edge_rotate(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - RNA_def_enum(ot->srna, "direction", direction_items, DIRECTION_CW, "Direction", "Direction to rotate edge around"); + RNA_def_boolean(ot->srna, "use_ccw", FALSE, "Counter Clockwise", ""); } @@ -1553,7 +1557,7 @@ static int edbm_normals_make_consistent_exec(bContext *C, wmOperator *op) /* doflip has to do with bmesh_rationalize_normals, it's an internal * thing */ - if (!EDBM_op_callf(em, op, "recalc_face_normals faces=%hf do_flip=%b", BM_ELEM_SELECT, TRUE)) + if (!EDBM_op_callf(em, op, "recalc_face_normals faces=%hf use_flip=%b", BM_ELEM_SELECT, TRUE)) return OPERATOR_CANCELLED; if (RNA_boolean_get(op->ptr, "inside")) @@ -1590,7 +1594,7 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op) ModifierData *md; int mirrx = FALSE, mirry = FALSE, mirrz = FALSE; int i, repeat; - float clipdist = 0.0f; + float clip_dist = 0.0f; int xaxis = RNA_boolean_get(op->ptr, "xaxis"); int yaxis = RNA_boolean_get(op->ptr, "yaxis"); @@ -1616,7 +1620,7 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op) if (mmd->flag & MOD_MIR_AXIS_Z) mirrz = TRUE; - clipdist = mmd->tolerance; + clip_dist = mmd->tolerance; } } } @@ -1627,9 +1631,9 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op) for (i = 0; i < repeat; i++) { if (!EDBM_op_callf(em, op, - "smooth_vert verts=%hv mirror_clip_x=%b mirror_clip_y=%b mirror_clip_z=%b clipdist=%f " + "smooth_vert verts=%hv mirror_clip_x=%b mirror_clip_y=%b mirror_clip_z=%b clip_dist=%f " "use_axis_x=%b use_axis_y=%b use_axis_z=%b", - BM_ELEM_SELECT, mirrx, mirry, mirrz, clipdist, xaxis, yaxis, zaxis)) + BM_ELEM_SELECT, mirrx, mirry, mirrz, clip_dist, xaxis, yaxis, zaxis)) { return OPERATOR_CANCELLED; } @@ -1670,7 +1674,7 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - int usex = TRUE, usey = TRUE, usez = TRUE, volume_preservation = TRUE; + int usex = TRUE, usey = TRUE, usez = TRUE, preserve_volume = TRUE; int i, repeat; float lambda; float lambda_border; @@ -1698,14 +1702,14 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op) usex = RNA_boolean_get(op->ptr, "use_x"); usey = RNA_boolean_get(op->ptr, "use_y"); usez = RNA_boolean_get(op->ptr, "use_z"); - volume_preservation = RNA_boolean_get(op->ptr, "volume_preservation"); + preserve_volume = RNA_boolean_get(op->ptr, "preserve_volume"); if (!repeat) repeat = 1; for (i = 0; i < repeat; i++) { if (!EDBM_op_callf(em, op, - "smooth_laplacian_vert verts=%hv lambda=%f lambda_border=%f use_x=%b use_y=%b use_z=%b volume_preservation=%b", - BM_ELEM_SELECT, lambda, lambda_border, usex, usey, usez, volume_preservation)) + "smooth_laplacian_vert verts=%hv lambda=%f lambda_border=%f use_x=%b use_y=%b use_z=%b preserve_volume=%b", + BM_ELEM_SELECT, lambda, lambda_border, usex, usey, usez, preserve_volume)) { return OPERATOR_CANCELLED; } @@ -1745,7 +1749,7 @@ void MESH_OT_vertices_smooth_laplacian(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_x", 1, "Smooth X Axis", "Smooth object along X axis"); RNA_def_boolean(ot->srna, "use_y", 1, "Smooth Y Axis", "Smooth object along Y axis"); RNA_def_boolean(ot->srna, "use_z", 1, "Smooth Z Axis", "Smooth object along Z axis"); - RNA_def_boolean(ot->srna, "volume_preservation", 1, "Preserve Volume", "Apply volume preservation after smooth"); + RNA_def_boolean(ot->srna, "preserve_volume", 1, "Preserve Volume", "Apply volume preservation after smooth"); } /********************** Smooth/Solid Operators *************************/ @@ -1828,10 +1832,10 @@ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op) BMOperator bmop; /* get the direction from RNA */ - int dir = RNA_enum_get(op->ptr, "direction"); + const int use_ccw = RNA_boolean_get(op->ptr, "use_ccw"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "rotate_uvs faces=%hf dir=%i", BM_ELEM_SELECT, dir); + EDBM_op_init(em, &bmop, op, "rotate_uvs faces=%hf use_ccw=%b", BM_ELEM_SELECT, use_ccw); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -1877,10 +1881,10 @@ static int edbm_rotate_colors_exec(bContext *C, wmOperator *op) BMOperator bmop; /* get the direction from RNA */ - int dir = RNA_enum_get(op->ptr, "direction"); + const int use_ccw = RNA_boolean_get(op->ptr, "use_ccw"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "rotate_colors faces=%hf dir=%i", BM_ELEM_SELECT, dir); + EDBM_op_init(em, &bmop, op, "rotate_colors faces=%hf use_ccw=%b", BM_ELEM_SELECT, use_ccw); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -1936,7 +1940,7 @@ void MESH_OT_uvs_rotate(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - RNA_def_enum(ot->srna, "direction", direction_items, DIRECTION_CW, "Direction", "Direction to rotate UVs around"); + RNA_def_boolean(ot->srna, "use_ccw", FALSE, "Counter Clockwise", ""); } //void MESH_OT_uvs_mirror(wmOperatorType *ot) @@ -1973,7 +1977,7 @@ void MESH_OT_colors_rotate(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - RNA_def_enum(ot->srna, "direction", direction_items, DIRECTION_CCW, "Direction", "Direction to rotate edge around"); + RNA_def_boolean(ot->srna, "use_ccw", FALSE, "Counter Clockwise", ""); } void MESH_OT_colors_reverse(wmOperatorType *ot) @@ -2174,7 +2178,7 @@ void MESH_OT_merge(wmOperatorType *ot) /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", merge_type_items, 3, "Type", "Merge method to use"); RNA_def_enum_funcs(ot->prop, merge_type_itemf); - RNA_def_boolean(ot->srna, "uvs", 1, "UVs", "Move UVs according to merge"); + RNA_def_boolean(ot->srna, "uvs", 0, "UVs", "Move UVs according to merge"); } @@ -2204,7 +2208,7 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) BM_ELEM_SELECT, threshold); BMO_op_exec(em->bm, &bmop); - if (!EDBM_op_callf(em, op, "weld_verts targetmap=%s", &bmop, "targetmapout")) { + if (!EDBM_op_callf(em, op, "weld_verts targetmap=%S", &bmop, "targetmap.out")) { BMO_op_finish(em->bm, &bmop); return OPERATOR_CANCELLED; } @@ -2313,7 +2317,7 @@ static int edbm_select_vertex_path_exec(bContext *C, wmOperator *op) /* EDBM_flag_disable_all(em, BM_ELEM_SELECT); */ /* select the output */ - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "vertout", BM_ALL, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_ALL, BM_ELEM_SELECT, TRUE); /* finish the operator */ if (!EDBM_op_finish(em, &bmop, op, TRUE)) { @@ -2505,6 +2509,22 @@ static EnumPropertyItem *shape_itemf(bContext *C, PointerRNA *UNUSED(ptr), Prop return item; } +static void edbm_blend_from_shape_ui(bContext *C, wmOperator *op) +{ + uiLayout *layout = op->layout; + PointerRNA ptr; + Object *obedit = CTX_data_edit_object(C); + Mesh *me = obedit->data; + PointerRNA ptr_key; + + RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); + RNA_id_pointer_create((ID *)me->key, &ptr_key); + + uiItemPointerR(layout, &ptr, "shape", &ptr_key, "key_blocks", "", ICON_SHAPEKEY_DATA); + uiItemR(layout, &ptr, "blend", 0, NULL, ICON_NONE); + uiItemR(layout, &ptr, "add", 0, NULL, ICON_NONE); +} + void MESH_OT_blend_from_shape(wmOperatorType *ot) { PropertyRNA *prop; @@ -2517,7 +2537,8 @@ void MESH_OT_blend_from_shape(wmOperatorType *ot) /* api callbacks */ ot->exec = edbm_blend_from_shape_exec; - ot->invoke = WM_operator_props_popup_call; +// ot->invoke = WM_operator_props_popup_call; /* disable because search popup closes too easily */ + ot->ui = edbm_blend_from_shape_ui; ot->poll = ED_operator_editmesh; /* flags */ @@ -2630,13 +2651,13 @@ static int edbm_solidify_exec(bContext *C, wmOperator *op) /* deselect only the faces in the region to be solidified (leave wire * edges and loose verts selected, as there will be no corresponding * geometry selected below) */ - BMO_slot_buffer_hflag_disable(bm, &bmop, "geom", BM_FACE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_disable(bm, bmop.slots_in, "geom", BM_FACE, BM_ELEM_SELECT, TRUE); /* run the solidify operator */ BMO_op_exec(bm, &bmop); /* select the newly generated faces */ - BMO_slot_buffer_hflag_enable(bm, &bmop, "geomout", BM_FACE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "geom.out", BM_FACE, BM_ELEM_SELECT, TRUE); if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; @@ -2868,6 +2889,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) float isect = 0.0f; int len = 0, isected, i; short numcuts = 1, mode = RNA_int_get(op->ptr, "type"); + BMOpSlot *slot_edgepercents; /* allocd vars */ float (*screen_vert_coords)[2], (*sco)[2], (*mouse_path)[2]; @@ -2922,6 +2944,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) } /* store percentage of edge cut for KNIFE_EXACT here.*/ + slot_edgepercents = BMO_slot_get(bmop.slots_in, "edgepercents"); for (be = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL); be; be = BM_iter_step(&iter)) { int is_cut = FALSE; if (BM_elem_flag_test(be, BM_ELEM_SELECT)) { @@ -2934,9 +2957,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) if (isect != 0.0f) { if (mode != KNIFE_MULTICUT && mode != KNIFE_MIDPOINT) { - BMO_slot_map_float_insert(bm, &bmop, - "edgepercents", - be, isect); + BMO_slot_map_float_insert(&bmop, slot_edgepercents, be, isect); } } } @@ -2951,16 +2972,16 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) MEM_freeN(mouse_path); - BMO_slot_buffer_from_enabled_flag(bm, &bmop, "edges", BM_EDGE, ELE_EDGE_CUT); + BMO_slot_buffer_from_enabled_flag(bm, &bmop, bmop.slots_in, "edges", BM_EDGE, ELE_EDGE_CUT); if (mode == KNIFE_MIDPOINT) numcuts = 1; - BMO_slot_int_set(&bmop, "numcuts", numcuts); + BMO_slot_int_set(bmop.slots_in, "cuts", numcuts); - BMO_slot_int_set(&bmop, "quadcornertype", SUBD_STRAIGHT_CUT); - BMO_slot_bool_set(&bmop, "use_singleedge", FALSE); - BMO_slot_bool_set(&bmop, "use_gridfill", FALSE); + BMO_slot_int_set(bmop.slots_in, "quad_corner_type", SUBD_STRAIGHT_CUT); + BMO_slot_bool_set(bmop.slots_in, "use_singleedge", FALSE); + BMO_slot_bool_set(bmop.slots_in, "use_gridfill", FALSE); - BMO_slot_float_set(&bmop, "radius", 0); + BMO_slot_float_set(bmop.slots_in, "radius", 0); BMO_op_exec(bm, &bmop); if (!EDBM_op_finish(em, &bmop, op, TRUE)) { @@ -3303,7 +3324,7 @@ static int edbm_fill_exec(bContext *C, wmOperator *op) BMO_op_exec(em->bm, &bmop); /* select new geometry */ - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_FACE | BM_EDGE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_FACE | BM_EDGE, BM_ELEM_SELECT, TRUE); if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; @@ -3575,7 +3596,7 @@ static int edbm_split_exec(bContext *C, wmOperator *op) EDBM_op_init(em, &bmop, op, "split geom=%hvef use_only_faces=%b", BM_ELEM_SELECT, FALSE); BMO_op_exec(em->bm, &bmop); BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_ALL, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_ALL, BM_ELEM_SELECT, TRUE); if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; } @@ -3630,14 +3651,14 @@ static int edbm_spin_exec(bContext *C, wmOperator *op) mul_m3_v3(imat, axis); if (!EDBM_op_init(em, &spinop, op, - "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i ang=%f do_dupli=%b", + "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f use_duplicate=%b", BM_ELEM_SELECT, cent, axis, d, steps, degr, dupli)) { return OPERATOR_CANCELLED; } BMO_op_exec(bm, &spinop); EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(bm, &spinop, "lastout", BM_ALL, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(bm, spinop.slots_out, "geom_last.out", BM_ALL, BM_ELEM_SELECT, TRUE); if (!EDBM_op_finish(em, &spinop, op, TRUE)) { return OPERATOR_CANCELLED; } @@ -3754,14 +3775,14 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) negate_v3(dvec); if (!EDBM_op_init(em, &spinop, op, - "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i ang=%f do_dupli=%b", + "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f use_duplicate=%b", BM_ELEM_SELECT, cent, axis, dvec, turns * steps, 360.0f * turns, FALSE)) { return OPERATOR_CANCELLED; } BMO_op_exec(bm, &spinop); EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(bm, &spinop, "lastout", BM_ALL, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(bm, spinop.slots_out, "geom_last.out", BM_ALL, BM_ELEM_SELECT, TRUE); if (!EDBM_op_finish(em, &spinop, op, TRUE)) { return OPERATOR_CANCELLED; } @@ -4757,11 +4778,20 @@ static int edbm_bevel_calc(bContext *C, wmOperator *op) if (!EDBM_op_init(em, &bmop, op, "bevel geom=%hev offset=%f segments=%i", BM_ELEM_SELECT, offset, segments)) - { - return 0; - } - + { + return 0; + } + BMO_op_exec(em->bm, &bmop); + + if (offset != 0.0f) { + /* not essential, but we may have some loose geometry that + * won't get bevel'd and better not leave it selected */ + EDBM_flag_disable_all(em, BM_ELEM_SELECT); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, TRUE); + } + + /* no need to de-select existing geometry */ if (!EDBM_op_finish(em, &bmop, op, TRUE)) return 0; #else @@ -5095,7 +5125,7 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op) /* when merge is used the edges are joined and remain selected */ if (use_merge == FALSE) { EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_FACE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, TRUE); } if (!EDBM_op_finish(em, &bmop, op, TRUE)) { @@ -5268,11 +5298,11 @@ static int edbm_inset_calc(bContext *C, wmOperator *op) if (use_select_inset) { /* deselect original faces/verts */ EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_FACE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, TRUE); } else { BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE, BM_ELEM_SELECT, FALSE); - BMO_slot_buffer_hflag_disable(em->bm, &bmop, "faceout", BM_FACE, BM_ELEM_SELECT, FALSE); + BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, FALSE); /* re-select faces so the verts and edges get selected too */ BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, TRUE, BM_ELEM_SELECT); } @@ -5529,7 +5559,7 @@ static int edbm_wireframe_exec(bContext *C, wmOperator *op) if (use_replace) { BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, FALSE); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faces", BM_FACE, BM_ELEM_TAG, FALSE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_in, "faces", BM_FACE, BM_ELEM_TAG, FALSE); BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS, "delete geom=%hvef context=%i", @@ -5537,7 +5567,7 @@ static int edbm_wireframe_exec(bContext *C, wmOperator *op) } BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_FACE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, TRUE); if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; @@ -5600,8 +5630,8 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) /* Delete unused vertices, edges, and faces */ if (RNA_boolean_get(op->ptr, "delete_unused")) { - if (!EDBM_op_callf(em, op, "delete geom=%s context=%i", - &bmop, "unused_geom", DEL_ONLYTAGGED)) + if (!EDBM_op_callf(em, op, "delete geom=%S context=%i", + &bmop, "geom_unused.out", DEL_ONLYTAGGED)) { EDBM_op_finish(em, &bmop, op, TRUE); return OPERATOR_CANCELLED; @@ -5610,8 +5640,8 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) /* Delete hole edges/faces */ if (RNA_boolean_get(op->ptr, "make_holes")) { - if (!EDBM_op_callf(em, op, "delete geom=%s context=%i", - &bmop, "holes_geom", DEL_ONLYTAGGED)) + if (!EDBM_op_callf(em, op, "delete geom=%S context=%i", + &bmop, "geom_holes.out", DEL_ONLYTAGGED)) { EDBM_op_finish(em, &bmop, op, TRUE); return OPERATOR_CANCELLED; @@ -5620,8 +5650,8 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) /* Merge adjacent triangles */ if (RNA_boolean_get(op->ptr, "join_triangles")) { - if (!EDBM_op_callf(em, op, "join_triangles faces=%s limit=%f", - &bmop, "geomout", + if (!EDBM_op_callf(em, op, "join_triangles faces=%S limit=%f", + &bmop, "geom.out", RNA_float_get(op->ptr, "limit"))) { EDBM_op_finish(em, &bmop, op, TRUE); diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index ef3d8db4156..22c71d5d3ca 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -263,7 +263,7 @@ int EDBM_op_callf(BMEditMesh *em, wmOperator *op, const char *fmt, ...) return EDBM_op_finish(em, &bmop, op, TRUE); } -int EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *selectslot, const char *fmt, ...) +int EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *select_slot_out, const char *fmt, ...) { BMesh *bm = em->bm; BMOperator bmop; @@ -285,7 +285,7 @@ int EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *selects BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); - BMO_slot_buffer_hflag_enable(em->bm, &bmop, selectslot, BM_ALL, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, select_slot_out, BM_ALL, BM_ELEM_SELECT, TRUE); va_end(list); return EDBM_op_finish(em, &bmop, op, TRUE); @@ -494,11 +494,11 @@ void EDBM_select_more(BMEditMesh *em) int use_faces = em->selectmode == SCE_SELECT_FACE; BMO_op_initf(em->bm, &bmop, BMO_FLAG_DEFAULTS, - "region_extend geom=%hvef constrict=%b use_faces=%b", + "region_extend geom=%hvef use_constrict=%b use_faces=%b", BM_ELEM_SELECT, FALSE, use_faces); BMO_op_exec(em->bm, &bmop); /* don't flush selection in edge/vertex mode */ - BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_ALL, BM_ELEM_SELECT, use_faces ? TRUE : FALSE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_ALL, BM_ELEM_SELECT, use_faces ? TRUE : FALSE); BMO_op_finish(em->bm, &bmop); EDBM_select_flush(em); @@ -510,11 +510,11 @@ void EDBM_select_less(BMEditMesh *em) int use_faces = em->selectmode == SCE_SELECT_FACE; BMO_op_initf(em->bm, &bmop, BMO_FLAG_DEFAULTS, - "region_extend geom=%hvef constrict=%b use_faces=%b", + "region_extend geom=%hvef use_constrict=%b use_faces=%b", BM_ELEM_SELECT, TRUE, use_faces); BMO_op_exec(em->bm, &bmop); /* don't flush selection in edge/vertex mode */ - BMO_slot_buffer_hflag_disable(em->bm, &bmop, "geomout", BM_ALL, BM_ELEM_SELECT, use_faces ? TRUE : FALSE); + BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "geom.out", BM_ALL, BM_ELEM_SELECT, use_faces ? TRUE : FALSE); BMO_op_finish(em->bm, &bmop); EDBM_selectmode_flush(em); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 95c4691e440..a2ac08268e0 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -280,13 +280,21 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) /* standard mouse selection goes via space_view3d */ kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "deselect", FALSE); + RNA_boolean_set(kmi->ptr, "toggle", FALSE); kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "deselect", FALSE); + RNA_boolean_set(kmi->ptr, "toggle", TRUE); kmi = WM_keymap_add_item(keymap, "MESH_OT_edgering_select", SELECTMOUSE, KM_PRESS, KM_ALT | KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "deselect", FALSE); + RNA_boolean_set(kmi->ptr, "toggle", FALSE); kmi = WM_keymap_add_item(keymap, "MESH_OT_edgering_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT | KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "deselect", FALSE); + RNA_boolean_set(kmi->ptr, "toggle", TRUE); WM_keymap_add_item(keymap, "MESH_OT_select_shortest_path", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 4d6b9ed10bb..d39e34824b9 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -550,7 +550,8 @@ static int editmode_toggle_poll(bContext *C) if (ELEM(NULL, ob, ob->data) || ((ID *)ob->data)->lib) return 0; - if (ob->restrictflag & OB_RESTRICT_VIEW) + /* if hidden but in edit mode, we still display */ + if ((ob->restrictflag & OB_RESTRICT_VIEW) && !(ob->mode & OB_MODE_EDIT)) return 0; return (ob->type == OB_MESH || ob->type == OB_ARMATURE || diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 2b6d69ca694..6a511d4d924 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -137,9 +137,11 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob) } if (key->totkey == 0) { - if (GS(key->from->name) == ID_ME) ((Mesh *)key->from)->key = NULL; - else if (GS(key->from->name) == ID_CU) ((Curve *)key->from)->key = NULL; - else if (GS(key->from->name) == ID_LT) ((Lattice *)key->from)->key = NULL; + switch (GS(key->from->name)) { + case ID_ME: ((Mesh *)key->from)->key = NULL; break; + case ID_CU: ((Curve *)key->from)->key = NULL; break; + case ID_LT: ((Lattice *)key->from)->key = NULL; break; + } BKE_libblock_free_us(&(bmain->key), key); } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index e56ca20dfcc..d7c7d4c04ef 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -2574,7 +2574,7 @@ static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op)) ED_vgroup_add(ob); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); + WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); return OPERATOR_FINISHED; @@ -2605,7 +2605,7 @@ static int vertex_group_remove_exec(bContext *C, wmOperator *op) vgroup_delete(ob); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); + WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); return OPERATOR_FINISHED; @@ -2771,7 +2771,7 @@ static int vertex_group_copy_exec(bContext *C, wmOperator *UNUSED(op)) vgroup_duplicate(ob); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); + WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data); return OPERATOR_FINISHED; } @@ -3199,7 +3199,7 @@ static int vertex_group_copy_to_linked_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, base->object); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, base->object->data); + WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, base->object->data); retval = OPERATOR_FINISHED; } @@ -3356,7 +3356,7 @@ static int set_active_group_exec(bContext *C, wmOperator *op) ob->actdef = nr + 1; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob); + WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob); return OPERATOR_FINISHED; } @@ -3520,7 +3520,7 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op) if (ret != OPERATOR_CANCELLED) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob); + WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob); } if (name_array) MEM_freeN(name_array); @@ -3575,7 +3575,7 @@ static int vgroup_move_exec(bContext *C, wmOperator *op) if (ret != OPERATOR_CANCELLED) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob); + WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob); } return ret; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 0c88519b62b..2ac5f98927c 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -401,6 +401,7 @@ static void PE_set_view3d_data(bContext *C, PEData *data) static int key_test_depth(PEData *data, const float co[3], const int screen_co[2]) { View3D *v3d= data->vc.v3d; + ViewDepths *vd = data->vc.rv3d->depths; double ux, uy, uz; float depth; @@ -428,12 +429,15 @@ static int key_test_depth(PEData *data, const float co[3], const int screen_co[2 /* view3d_validate_backbuf(&data->vc); */ glReadPixels(screen_co[0], screen_co[1], 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth); #else /* faster to use depths, these are calculated in PE_set_view3d_data */ - { - ViewDepths *vd = data->vc.rv3d->depths; - assert(vd && vd->depths); + + /* check if screen_co is within bounds because brush_cut uses out of screen coords */ + if(screen_co[0] >= 0 && screen_co[0] < vd->w && screen_co[1] >= 0 && screen_co[1] < vd->h) { + BLI_assert(vd && vd->depths); /* we know its not clipped */ depth = vd->depths[screen_co[1] * vd->w + screen_co[0]]; } + else + return 0; #endif if ((float)uz - 0.00001f > depth) diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 7cd153d9564..5304c64c2a9 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -446,7 +446,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid for (fobj=fobjects->first; fobj; fobj=fobj->next) { Object *ob = fobj->object; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); - float active= (float)(fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE); + float active= (float) ((fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE) > 0 ? 1 : 0); float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f}; if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) @@ -467,6 +467,8 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid set_channel(fobj->Scale, timeAtFrame, ob->size, i, CHANNEL_VEC); set_channel(fobj->Active, timeAtFrame, &active, i, CHANNEL_FLOAT); set_channel(fobj->InitialVelocity, timeAtFrame, &fluidmd->fss->iniVelx, i, CHANNEL_VEC); + + // printf("Active: %f, Frame: %f\n", active, timeAtFrame); if (fluidmd->fss->type == OB_FLUIDSIM_CONTROL) { set_channel(fobj->AttractforceStrength, timeAtFrame, &fluidmd->fss->attractforceStrength, i, CHANNEL_FLOAT); @@ -962,8 +964,8 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* ******** prepare output file paths ******** */ outStringsChanged = fluid_init_filepaths(fsDomain, targetDir, targetFile, debugStrBuffer); - channels->length = scene->r.efra; - channels->aniFrameTime = (double)(domainSettings->animEnd - domainSettings->animStart) / (double)noFrames; + channels->length = scene->r.efra; // DG TODO: why using endframe and not "noFrames" here? .. because "noFrames" is buggy too? (not using sfra) + channels->aniFrameTime = (double)((double)domainSettings->animEnd - (double)domainSettings->animStart) / (double)noFrames; /* ******** initialize and allocate animation channels ******** */ fluid_init_all_channels(C, fsDomain, domainSettings, channels, fobjects); diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 5155f1001ab..3f438c5948e 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -250,6 +250,24 @@ static void material_changed(Main *bmain, Material *ma) } } +static void lamp_changed(Main *bmain, Lamp *la) +{ + Object *ob; + Material *ma; + + /* icons */ + BKE_icon_changed(BKE_icon_getid(&la->id)); + + /* glsl */ + for (ob = bmain->object.first; ob; ob = ob->id.next) + if (ob->data == la && ob->gpulamp.first) + GPU_lamp_free(ob); + + for (ma = bmain->mat.first; ma; ma = ma->id.next) + if (ma->gpumaterial.first) + GPU_material_free(ma); +} + static void texture_changed(Main *bmain, Tex *tex) { Material *ma; @@ -282,16 +300,14 @@ static void texture_changed(Main *bmain, Tex *tex) /* find lamps */ for (la = bmain->lamp.first; la; la = la->id.next) { if (mtex_use_tex(la->mtex, MAX_MTEX, tex)) { - /* pass */ + lamp_changed(bmain, la); } else if (la->nodetree && nodes_use_tex(la->nodetree, tex)) { - /* pass */ + lamp_changed(bmain, la); } else { continue; } - - BKE_icon_changed(BKE_icon_getid(&la->id)); } /* find worlds */ @@ -320,24 +336,6 @@ static void texture_changed(Main *bmain, Tex *tex) } } -static void lamp_changed(Main *bmain, Lamp *la) -{ - Object *ob; - Material *ma; - - /* icons */ - BKE_icon_changed(BKE_icon_getid(&la->id)); - - /* glsl */ - for (ob = bmain->object.first; ob; ob = ob->id.next) - if (ob->data == la && ob->gpulamp.first) - GPU_lamp_free(ob); - - for (ma = bmain->mat.first; ma; ma = ma->id.next) - if (ma->gpumaterial.first) - GPU_material_free(ma); -} - static void world_changed(Main *bmain, World *wo) { Material *ma; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 6a9c24d2913..67d4af916aa 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -293,29 +293,35 @@ int ED_operator_console_active(bContext *C) return ed_spacetype_test(C, SPACE_CONSOLE); } +static int ed_object_hidden(Object *ob) +{ + /* if hidden but in edit mode, we still display, can happen with animation */ + return ((ob->restrictflag & OB_RESTRICT_VIEW) && !(ob->mode & OB_MODE_EDIT)); +} + int ED_operator_object_active(bContext *C) { Object *ob = ED_object_active_context(C); - return ((ob != NULL) && !(ob->restrictflag & OB_RESTRICT_VIEW)); + return ((ob != NULL) && !ed_object_hidden(ob)); } int ED_operator_object_active_editable(bContext *C) { Object *ob = ED_object_active_context(C); - return ((ob != NULL) && !(ob->id.lib) && !(ob->restrictflag & OB_RESTRICT_VIEW)); + return ((ob != NULL) && !(ob->id.lib) && !ed_object_hidden(ob)); } int ED_operator_object_active_editable_mesh(bContext *C) { Object *ob = ED_object_active_context(C); - return ((ob != NULL) && !(ob->id.lib) && !(ob->restrictflag & OB_RESTRICT_VIEW) && + return ((ob != NULL) && !(ob->id.lib) && !ed_object_hidden(ob) && (ob->type == OB_MESH) && !(((ID *)ob->data)->lib)); } int ED_operator_object_active_editable_font(bContext *C) { Object *ob = ED_object_active_context(C); - return ((ob != NULL) && !(ob->id.lib) && !(ob->restrictflag & OB_RESTRICT_VIEW) && + return ((ob != NULL) && !(ob->id.lib) && !ed_object_hidden(ob) && (ob->type == OB_FONT)); } diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index ffe4762ad15..77e2a1bb3d3 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1028,17 +1028,14 @@ static void clip_refresh(const bContext *C, ScrArea *sa) static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip_get_clip(sc); - float x1, y1, w, h; + float x1, y1, w, h, aspx, aspy; int width, height, winx, winy; ED_space_clip_get_size(sc, &width, &height); + ED_space_clip_get_aspect(sc, &aspx, &aspy); - w = width; - h = height; - - if (clip) - h *= clip->aspy / clip->aspx / clip->tracking.camera.pixel_aspect; + w = width * aspx; + h = height * aspy; winx = BLI_rcti_size_x(&ar->winrct) + 1; winy = BLI_rcti_size_y(&ar->winrct) + 1; diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index d3ae5373a18..bb46135545c 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -157,10 +157,9 @@ static ConsoleLine *console_lb_add__internal(ListBase *lb, ConsoleLine *from) ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"); if (from) { - ci->line = BLI_strdup(from->line); - ci->len = strlen(ci->line); - ci->len_alloc = ci->len; - + BLI_assert(strlen(from->line) == from->len); + ci->line = BLI_strdupn(from->line, from->len); + ci->len = ci->len_alloc = from->len; ci->cursor = from->cursor; ci->type = from->type; } @@ -174,10 +173,8 @@ static ConsoleLine *console_lb_add__internal(ListBase *lb, ConsoleLine *from) return ci; } -static ConsoleLine *console_history_add(const bContext *C, ConsoleLine *from) +static ConsoleLine *console_history_add(SpaceConsole *sc, ConsoleLine *from) { - SpaceConsole *sc = CTX_wm_space_console(C); - return console_lb_add__internal(&sc->history, from); } @@ -217,7 +214,7 @@ ConsoleLine *console_history_verify(const bContext *C) SpaceConsole *sc = CTX_wm_space_console(C); ConsoleLine *ci = sc->history.last; if (ci == NULL) - ci = console_history_add(C, NULL); + ci = console_history_add(sc, NULL); return ci; } @@ -623,8 +620,9 @@ static int console_clear_line_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - console_history_add(C, ci); - console_history_add(C, NULL); + console_history_add(sc, ci); + console_history_add(sc, NULL); + console_select_offset(sc, -ci->len); console_textview_update_rect(sc, ar); @@ -727,7 +725,7 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) while ((cl = console_history_find(sc, ci->line, ci))) console_history_free(sc, cl); - console_history_add(C, (ConsoleLine *)sc->history.last); + console_history_add(sc, (ConsoleLine *)sc->history.last); } ci = sc->history.last; diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 8bb57a32090..483348db18e 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -714,7 +714,17 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) row = uiLayoutRow(box, TRUE); uiItemL(row, IFACE_("Value:"), ICON_NONE); - BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval); + if ((dvar->type == DVAR_TYPE_ROT_DIFF) || + (dvar->type == DVAR_TYPE_TRANSFORM_CHAN && + dvar->targets[0].transChan >= DTAR_TRANSCHAN_ROTX && + dvar->targets[0].transChan < DTAR_TRANSCHAN_SCALEX)) + { + BLI_snprintf(valBuf, sizeof(valBuf), "%.3f (%4.1f°)", dvar->curval, RAD2DEGF(dvar->curval)); + } + else { + BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval); + } + uiItemL(row, valBuf, ICON_NONE); } } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index d4f24babff6..0d0fdc6be1c 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -81,6 +81,8 @@ #include "WM_api.h" #include "WM_types.h" +#include "PIL_time.h" + #include "image_intern.h" /******************** view navigation utilities *********************/ @@ -367,10 +369,18 @@ void IMAGE_OT_view_pan(wmOperatorType *ot) /********************** view zoom operator *********************/ typedef struct ViewZoomData { - float x, y; + float origx, origy; float zoom; int event_type; float location[2]; + + /* needed for continuous zoom */ + wmTimer *timer; + double timer_lastdraw; + + /* */ + SpaceImage *sima; + ARegion *ar; } ViewZoomData; static void image_view_zoom_init(bContext *C, wmOperator *op, wmEvent *event) @@ -382,13 +392,22 @@ static void image_view_zoom_init(bContext *C, wmOperator *op, wmEvent *event) op->customdata = vpd = MEM_callocN(sizeof(ViewZoomData), "ImageViewZoomData"); WM_cursor_modal(CTX_wm_window(C), BC_NSEW_SCROLLCURSOR); - vpd->x = event->x; - vpd->y = event->y; + vpd->origx = event->x; + vpd->origy = event->y; vpd->zoom = sima->zoom; vpd->event_type = event->type; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &vpd->location[0], &vpd->location[1]); + if (U.viewzoom == USER_ZOOM_CONT) { + /* needs a timer to continue redrawing */ + vpd->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f); + vpd->timer_lastdraw = PIL_check_seconds_timer(); + } + + vpd->sima = sima; + vpd->ar = ar; + WM_event_add_modal_handler(C, op); } @@ -402,6 +421,9 @@ static void image_view_zoom_exit(bContext *C, wmOperator *op, int cancel) ED_region_tag_redraw(CTX_wm_region(C)); } + if (vpd->timer) + WM_event_remove_timer(CTX_wm_manager(C), vpd->timer->win, vpd->timer); + WM_cursor_restore(CTX_wm_window(C)); MEM_freeN(op->customdata); } @@ -427,6 +449,12 @@ static int image_view_zoom_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +enum { + VIEW_PASS = 0, + VIEW_APPLY, + VIEW_CONFIRM +}; + static int image_view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event) { if (event->type == MOUSEZOOM) { @@ -454,31 +482,72 @@ static int image_view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event) } } +static void image_zoom_apply(ViewZoomData *vpd, wmOperator *op, const int x, const int y, const short viewzoom, const short zoom_invert) +{ + float factor; + + if (viewzoom == USER_ZOOM_CONT) { + double time = PIL_check_seconds_timer(); + float time_step = (float)(time - vpd->timer_lastdraw); + float fac; + float zfac; + + if (U.uiflag & USER_ZOOM_HORIZ) { + fac = (float)(x - vpd->origx); + } + else { + fac = (float)(y - vpd->origy); + } + + if (zoom_invert) { + fac = -fac; + } + + /* oldstyle zoom */ + zfac = 1.0f + ((fac / 20.0f) * time_step); + vpd->timer_lastdraw = time; + /* this is the final zoom, but instead make it into a factor */ + //zoom = vpd->sima->zoom * zfac; + factor = (vpd->sima->zoom * zfac) / vpd->zoom; + } + else { + /* for now do the same things for scale and dolly */ + float delta = x - vpd->origx + y - vpd->origy; + + if (zoom_invert) + delta *= -1.0f; + + factor = 1.0f + delta / 300.0f; + } + + RNA_float_set(op->ptr, "factor", factor); + sima_zoom_set(vpd->sima, vpd->ar, vpd->zoom * factor, vpd->location); + ED_region_tag_redraw(vpd->ar); +} + static int image_view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceImage *sima = CTX_wm_space_image(C); - ARegion *ar = CTX_wm_region(C); ViewZoomData *vpd = op->customdata; - float delta, factor; - - switch (event->type) { - case MOUSEMOVE: - delta = event->x - vpd->x + event->y - vpd->y; + short event_code = VIEW_PASS; - if (U.uiflag & USER_ZOOM_INVERT) - delta *= -1; + /* execute the events */ + if (event->type == TIMER && event->customdata == vpd->timer) { + /* continuous zoom */ + event_code = VIEW_APPLY; + } + else if (event->type == MOUSEMOVE) { + event_code = VIEW_APPLY; + } + else if (event->type == vpd->event_type && event->val == KM_RELEASE) { + event_code = VIEW_CONFIRM; + } - factor = 1.0f + delta / 300.0f; - RNA_float_set(op->ptr, "factor", factor); - sima_zoom_set(sima, ar, vpd->zoom * factor, vpd->location); - ED_region_tag_redraw(CTX_wm_region(C)); - break; - default: - if (event->type == vpd->event_type && event->val == KM_RELEASE) { - image_view_zoom_exit(C, op, 0); - return OPERATOR_FINISHED; - } - break; + if (event_code == VIEW_APPLY) { + image_zoom_apply(vpd, op, event->x, event->y, U.viewzoom, (U.uiflag & USER_ZOOM_INVERT) != 0); + } + else if (event_code == VIEW_CONFIRM) { + image_view_zoom_exit(C, op, 0); + return OPERATOR_FINISHED; } return OPERATOR_RUNNING_MODAL; diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 2c40e0e656d..61d513929ad 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1038,6 +1038,8 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto UI_icon_draw(x, y, ICON_MOD_WARP); break; case eModifierType_Skin: UI_icon_draw(x, y, ICON_MOD_SKIN); break; + case eModifierType_Triangulate: + UI_icon_draw(x, y, ICON_MOD_TRIANGULATE); break; /* Default */ case eModifierType_None: diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 6cfc3f97b31..f8856cb9646 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -337,8 +337,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn) break; case NC_GEOM: switch (wmn->data) { - case ND_DATA: - /* needed for vertex groups only, no special notifier atm so use NC_GEOM|ND_DATA */ + case ND_VERTEX_GROUP: ED_region_tag_redraw(ar); break; } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 37e57a1e850..5fefafaa54a 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -822,6 +822,7 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int int rectx, recty; float render_size = 0.0; float proxy_size = 100.0; + short is_break = G.is_break; render_size = sseq->render_size; if (render_size == 0) { @@ -840,6 +841,11 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int context = BKE_sequencer_new_render_data(bmain, scene, rectx, recty, proxy_size); + /* sequencer could start rendering, in this case we need to be sure it wouldn't be canceled + * by Esc pressed somewhere in the past + */ + G.is_break = FALSE; + if (special_seq_update) ibuf = BKE_sequencer_give_ibuf_direct(context, cfra + frame_ofs, special_seq_update); else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) { @@ -847,6 +853,9 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int else ibuf = BKE_sequencer_give_ibuf_threaded(context, cfra + frame_ofs, sseq->chanshown); + /* restore state so real rendering would be canceled (if needed) */ + G.is_break = is_break; + return ibuf; } diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 3f70b2cb66e..d74e32620af 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -196,10 +196,6 @@ static void text_operatortypes(void) WM_operatortype_append(TEXT_OT_unindent); WM_operatortype_append(TEXT_OT_indent); - WM_operatortype_append(TEXT_OT_markers_clear); - WM_operatortype_append(TEXT_OT_next_marker); - WM_operatortype_append(TEXT_OT_previous_marker); - WM_operatortype_append(TEXT_OT_select_line); WM_operatortype_append(TEXT_OT_select_all); WM_operatortype_append(TEXT_OT_select_word); @@ -227,7 +223,6 @@ static void text_operatortypes(void) WM_operatortype_append(TEXT_OT_find_set_selected); WM_operatortype_append(TEXT_OT_replace); WM_operatortype_append(TEXT_OT_replace_set_selected); - WM_operatortype_append(TEXT_OT_mark_all); WM_operatortype_append(TEXT_OT_to_3d_object); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 76908e5b369..46ab2d9e688 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -734,7 +734,7 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w if (st->showsyntax && format) format_draw_color(format[a]); x += text_font_draw_character_utf8(st, x, y, str + ma); } - y -= st->lheight; + y -= st->lheight + TXT_LINE_SPACING; x = basex; lines++; start = end; mstart = mend; @@ -1070,40 +1070,6 @@ int text_get_total_lines(SpaceText *st, ARegion *ar) return drawcache->total_lines; } -/* Move pointer to first visible line (top) */ -static TextLine *first_visible_line(SpaceText *st, ARegion *ar, int *wrap_top) -{ - Text *text = st->text; - TextLine *pline = text->lines.first; - int i = st->top, lineno = 0; - - text_update_drawcache(st, ar); - - if (wrap_top) *wrap_top = 0; - - if (st->wordwrap) { - while (i > 0 && pline) { - int lines = text_get_visible_lines_no(st, lineno); - - if (i - lines < 0) { - if (wrap_top) *wrap_top = i; - break; - } - else { - pline = pline->next; - i -= lines; - lineno++; - } - } - } - else { - for (i = st->top; pline->next && i > 0; i--) - pline = pline->next; - } - - return pline; -} - /************************ draw scrollbar *****************************/ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) @@ -1241,90 +1207,6 @@ static void draw_textscroll(SpaceText *st, rcti *scroll, rcti *back) glDisable(GL_BLEND); } -/************************** draw markers **************************/ - -static void draw_markers(SpaceText *st, ARegion *ar) -{ - Text *text = st->text; - TextMarker *marker, *next; - TextLine *top, *line; - int offl, offc, i, x1, x2, y1, y2, x, y; - int topi, topy; - - /* Move pointer to first visible line (top) */ - top = first_visible_line(st, ar, NULL); - topi = BLI_findindex(&text->lines, top); - - topy = txt_get_span(text->lines.first, top); - - for (marker = text->markers.first; marker; marker = next) { - next = marker->next; - - /* invisible line (before top) */ - if (marker->lineno < topi) continue; - - line = BLI_findlink(&text->lines, marker->lineno); - - /* Remove broken markers */ - if (marker->end > line->len || marker->start > marker->end) { - BLI_freelinkN(&text->markers, marker); - continue; - } - - wrap_offset(st, ar, line, marker->start, &offl, &offc); - y1 = txt_get_span(top, line) - st->top + offl + topy; - x1 = text_get_char_pos(st, line->line, marker->start) - st->left + offc; - - wrap_offset(st, ar, line, marker->end, &offl, &offc); - y2 = txt_get_span(top, line) - st->top + offl + topy; - x2 = text_get_char_pos(st, line->line, marker->end) - st->left + offc; - - /* invisible part of line (before top, after last visible line) */ - if (y2 < 0 || y1 > st->top + st->viewlines) continue; - - glColor3ubv(marker->color); - x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; - y = ar->winy - 3; - - if (y1 == y2) { - y -= y1 * st->lheight; - glBegin(GL_LINE_LOOP); - glVertex2i(x + x2 * st->cwidth + 1, y); - glVertex2i(x + x1 * st->cwidth - 2, y); - glVertex2i(x + x1 * st->cwidth - 2, y - st->lheight); - glVertex2i(x + x2 * st->cwidth + 1, y - st->lheight); - glEnd(); - } - else { - y -= y1 * st->lheight; - glBegin(GL_LINE_STRIP); - glVertex2i(ar->winx, y); - glVertex2i(x + x1 * st->cwidth - 2, y); - glVertex2i(x + x1 * st->cwidth - 2, y - st->lheight); - glVertex2i(ar->winx, y - st->lheight); - glEnd(); - y -= st->lheight; - - for (i = y1 + 1; i < y2; i++) { - glBegin(GL_LINES); - glVertex2i(x, y); - glVertex2i(ar->winx, y); - glVertex2i(x, y - st->lheight); - glVertex2i(ar->winx, y - st->lheight); - glEnd(); - y -= st->lheight; - } - - glBegin(GL_LINE_STRIP); - glVertex2i(x, y); - glVertex2i(x + x2 * st->cwidth + 1, y); - glVertex2i(x + x2 * st->cwidth + 1, y - st->lheight); - glVertex2i(x, y - st->lheight); - glEnd(); - } - } -} - /*********************** draw documentation *******************************/ static void draw_documentation(SpaceText *st, ARegion *ar) @@ -1834,16 +1716,14 @@ void draw_text_main(SpaceText *st, ARegion *ar) if (st->wordwrap) { /* draw word wrapped text */ int lines = text_draw_wrapped(st, tmp->line, x, y, winx - x, tmp->format, wrap_skip); - y -= lines * st->lheight; + y -= lines * (st->lheight + TXT_LINE_SPACING); } else { /* draw unwrapped text */ text_draw(st, tmp->line, st->left, ar->winx / st->cwidth, 1, x, y, tmp->format); - y -= st->lheight; + y -= st->lheight + TXT_LINE_SPACING; } - y-= TXT_LINE_SPACING; - wrap_skip = 0; } @@ -1862,7 +1742,6 @@ void draw_text_main(SpaceText *st, ARegion *ar) /* draw other stuff */ draw_brackets(st, ar); - draw_markers(st, ar); glTranslatef(GLA_PIXEL_OFS, GLA_PIXEL_OFS, 0.0f); /* XXX scroll requires exact pixel space */ draw_textscroll(st, &scroll, &back); draw_documentation(st, ar); diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index d687f4cdd8a..ea61644cee9 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -69,9 +69,6 @@ void text_update_cursor_moved(struct bContext *C); #define TOOL_SUGG_LIST 0x01 #define TOOL_DOCUMENT 0x02 -#define TMARK_GRP_CUSTOM 0x00010000 /* Lower 2 bytes used for Python groups */ -#define TMARK_GRP_FINDALL 0x00020000 - typedef struct FlattenString { char fixedbuf[256]; int fixedaccum[256]; @@ -130,10 +127,6 @@ void TEXT_OT_indent(struct wmOperatorType *ot); void TEXT_OT_line_break(struct wmOperatorType *ot); void TEXT_OT_insert(struct wmOperatorType *ot); -void TEXT_OT_markers_clear(struct wmOperatorType *ot); -void TEXT_OT_next_marker(struct wmOperatorType *ot); -void TEXT_OT_previous_marker(struct wmOperatorType *ot); - void TEXT_OT_select_line(struct wmOperatorType *ot); void TEXT_OT_select_all(struct wmOperatorType *ot); void TEXT_OT_select_word(struct wmOperatorType *ot); @@ -158,7 +151,6 @@ void TEXT_OT_find(struct wmOperatorType *ot); void TEXT_OT_find_set_selected(struct wmOperatorType *ot); void TEXT_OT_replace(struct wmOperatorType *ot); void TEXT_OT_replace_set_selected(struct wmOperatorType *ot); -void TEXT_OT_mark_all(struct wmOperatorType *ot); void TEXT_OT_to_3d_object(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index ae5de4c6a25..cd6d8719544 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1377,104 +1377,6 @@ void TEXT_OT_move_lines(wmOperatorType *ot) RNA_def_enum(ot->srna, "direction", direction_items, 1, "Direction", ""); } -/******************* previous marker operator *********************/ - -static int text_previous_marker_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Text *text = CTX_data_edit_text(C); - TextMarker *mrk; - int lineno; - - lineno = txt_get_span(text->lines.first, text->curl); - mrk = text->markers.last; - while (mrk && (mrk->lineno > lineno || (mrk->lineno == lineno && mrk->end > text->curc))) - mrk = mrk->prev; - if (!mrk) mrk = text->markers.last; - if (mrk) { - txt_move_to(text, mrk->lineno, mrk->start, 0); - txt_move_to(text, mrk->lineno, mrk->end, 1); - } - - text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); - - return OPERATOR_FINISHED; -} - -void TEXT_OT_previous_marker(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Previous Marker"; - ot->idname = "TEXT_OT_previous_marker"; - ot->description = "Move to previous marker"; - - /* api callbacks */ - ot->exec = text_previous_marker_exec; - ot->poll = text_edit_poll; -} - -/******************* next marker operator *********************/ - -static int text_next_marker_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Text *text = CTX_data_edit_text(C); - TextMarker *mrk; - int lineno; - - lineno = txt_get_span(text->lines.first, text->curl); - mrk = text->markers.first; - while (mrk && (mrk->lineno < lineno || (mrk->lineno == lineno && mrk->start <= text->curc))) - mrk = mrk->next; - if (!mrk) mrk = text->markers.first; - if (mrk) { - txt_move_to(text, mrk->lineno, mrk->start, 0); - txt_move_to(text, mrk->lineno, mrk->end, 1); - } - - text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); - - return OPERATOR_FINISHED; -} - -void TEXT_OT_next_marker(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Next Marker"; - ot->idname = "TEXT_OT_next_marker"; - ot->description = "Move to next marker"; - - /* api callbacks */ - ot->exec = text_next_marker_exec; - ot->poll = text_edit_poll; -} - -/******************* clear all markers operator *********************/ - -static int text_clear_all_markers_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Text *text = CTX_data_edit_text(C); - - txt_clear_markers(text, 0, 0); - - text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); - - return OPERATOR_FINISHED; -} - -void TEXT_OT_markers_clear(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Clear All Markers"; - ot->idname = "TEXT_OT_markers_clear"; - ot->description = "Clear all markers"; - - /* api callbacks */ - ot->exec = text_clear_all_markers_exec; - ot->poll = text_edit_poll; -} - /************************ move operator ************************/ static EnumPropertyItem move_type_items[] = { @@ -2956,14 +2858,13 @@ void TEXT_OT_insert(wmOperatorType *ot) /* mode */ #define TEXT_FIND 0 #define TEXT_REPLACE 1 -#define TEXT_MARK_ALL 2 static int text_find_and_replace(bContext *C, wmOperator *op, short mode) { Main *bmain = CTX_data_main(C); SpaceText *st = CTX_wm_space_text(C); - Text *start = NULL, *text = st->text; - int flags, first = 1; + Text *text = st->text; + int flags; int found = 0; char *tmp; @@ -2972,79 +2873,48 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode) flags = st->flags; if (flags & ST_FIND_ALL) - flags ^= ST_FIND_WRAP; - - do { - int proceed = 0; - - if (first) { - if (text->markers.first) - WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); + flags &= ~ST_FIND_WRAP; - txt_clear_markers(text, TMARK_GRP_FINDALL, 0); - } - - first = 0; - - /* Replace current */ - if (mode != TEXT_FIND && txt_has_sel(text)) { - tmp = txt_sel_to_buf(text); - - if (flags & ST_MATCH_CASE) proceed = strcmp(st->findstr, tmp) == 0; - else proceed = BLI_strcasecmp(st->findstr, tmp) == 0; - - if (proceed) { - if (mode == TEXT_REPLACE) { - txt_insert_buf(text, st->replacestr); - if (text->curl && text->curl->format) { - MEM_freeN(text->curl->format); - text->curl->format = NULL; - } - text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); - text_drawcache_tag_update(CTX_wm_space_text(C), 1); - } - else if (mode == TEXT_MARK_ALL) { - unsigned char color[4]; - UI_GetThemeColor4ubv(TH_SHADE2, color); + /* Replace current */ + if (mode != TEXT_FIND && txt_has_sel(text)) { + tmp = txt_sel_to_buf(text); - if (txt_find_marker(text, text->curl, text->selc, TMARK_GRP_FINDALL, 0)) { - if (tmp) MEM_freeN(tmp), tmp = NULL; - break; - } + if (flags & ST_MATCH_CASE) found = strcmp(st->findstr, tmp) == 0; + else found = BLI_strcasecmp(st->findstr, tmp) == 0; - txt_add_marker(text, text->curl, text->curc, text->selc, color, TMARK_GRP_FINDALL, TMARK_EDITALL); - text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); + if (found) { + if (mode == TEXT_REPLACE) { + txt_insert_buf(text, st->replacestr); + if (text->curl && text->curl->format) { + MEM_freeN(text->curl->format); + text->curl->format = NULL; } + text_update_cursor_moved(C); + WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); + text_drawcache_tag_update(CTX_wm_space_text(C), 1); } - MEM_freeN(tmp); - tmp = NULL; } + MEM_freeN(tmp); + tmp = NULL; + } - /* Find next */ - if (txt_find_string(text, st->findstr, flags & ST_FIND_WRAP, flags & ST_MATCH_CASE)) { - text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text); - } - else if (flags & ST_FIND_ALL) { - if (text == start) break; - if (!start) start = text; - if (text->id.next) - text = st->text = text->id.next; - else - text = st->text = bmain->text.first; - txt_move_toline(text, 0, 0); - text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text); - first = 1; - } - else { - if (!found && !proceed) BKE_reportf(op->reports, RPT_ERROR, "Text not found: %s", st->findstr); - break; - } - found = 1; - } while (mode == TEXT_MARK_ALL); + /* Find next */ + if (txt_find_string(text, st->findstr, flags & ST_FIND_WRAP, flags & ST_MATCH_CASE)) { + text_update_cursor_moved(C); + WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text); + } + else if (flags & ST_FIND_ALL) { + if (text->id.next) + text = st->text = text->id.next; + else + text = st->text = bmain->text.first; + txt_move_toline(text, 0, 0); + text_update_cursor_moved(C); + WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text); + } + else { + if (!found) BKE_reportf(op->reports, RPT_ERROR, "Text not found: %s", st->findstr); + } return OPERATOR_FINISHED; } @@ -3085,25 +2955,6 @@ void TEXT_OT_replace(wmOperatorType *ot) ot->poll = text_space_edit_poll; } -/******************* mark all operator *********************/ - -static int text_mark_all_exec(bContext *C, wmOperator *op) -{ - return text_find_and_replace(C, op, TEXT_MARK_ALL); -} - -void TEXT_OT_mark_all(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Mark All"; - ot->idname = "TEXT_OT_mark_all"; - ot->description = "Mark all specified text"; - - /* api callbacks */ - ot->exec = text_mark_all_exec; - ot->poll = text_space_edit_poll; -} - /******************* find set selected *********************/ static int text_find_set_selected_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_text/text_python.c b/source/blender/editors/space_text/text_python.c index 966afe22e42..4c9b4b900cc 100644 --- a/source/blender/editors/space_text/text_python.c +++ b/source/blender/editors/space_text/text_python.c @@ -359,177 +359,3 @@ static short UNUSED_FUNCTION(do_texttools) (SpaceText * st, char ascii, unsigned return swallow; } - -static short UNUSED_FUNCTION(do_textmarkers) (SpaceText * st, char ascii, unsigned short evnt, short val) -{ - Text *text; - TextMarker *marker, *mrk, *nxt; - int c, s, draw = 0, swallow = 0; - int qual = 0; // XXX - - text = st->text; - if (!text || text->id.lib || text->curl != text->sell) return 0; - - marker = txt_find_marker(text, text->sell, text->selc, 0, 0); - if (marker && (marker->start > text->curc || marker->end < text->curc)) - marker = NULL; - - if (!marker) { - /* Find the next temporary marker */ - if (evnt == TABKEY) { - int lineno = txt_get_span(text->lines.first, text->curl); - mrk = text->markers.first; - while (mrk) { - if (!marker && (mrk->flags & TMARK_TEMP)) marker = mrk; - if ((mrk->flags & TMARK_TEMP) && (mrk->lineno > lineno || (mrk->lineno == lineno && mrk->end > text->curc))) { - marker = mrk; - break; - } - mrk = mrk->next; - } - if (marker) { - txt_move_to(text, marker->lineno, marker->start, 0); - txt_move_to(text, marker->lineno, marker->end, 1); - // XXX text_update_cursor_moved(C); - // XXX WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); - evnt = ascii = val = 0; - draw = 1; - swallow = 1; - } - } - else if (evnt == ESCKEY) { - if (txt_clear_markers(text, 0, TMARK_TEMP)) swallow = 1; - else if (txt_clear_markers(text, 0, 0)) swallow = 1; - else return 0; - evnt = ascii = val = 0; - draw = 1; - } - if (!swallow) return 0; - } - - if (ascii) { - if (marker->flags & TMARK_EDITALL) { - c = text->curc - marker->start; - s = text->selc - marker->start; - if (s < 0 || s > marker->end - marker->start) return 0; - - mrk = txt_next_marker(text, marker); - while (mrk) { - nxt = txt_next_marker(text, mrk); /* mrk may become invalid */ - txt_move_to(text, mrk->lineno, mrk->start + c, 0); - if (s != c) txt_move_to(text, mrk->lineno, mrk->start + s, 1); - if (st->overwrite) { - if (txt_replace_char(text, ascii)) - text_update_line_edited(st->text->curl); - } - else { - if (txt_add_char(text, ascii)) { - text_update_line_edited(st->text->curl); - } - } - - if (mrk == marker || mrk == nxt) break; - mrk = nxt; - } - swallow = 1; - draw = 1; - } - } - else if (val) { - switch (evnt) { - case BACKSPACEKEY: - if (marker->flags & TMARK_EDITALL) { - c = text->curc - marker->start; - s = text->selc - marker->start; - if (s < 0 || s > marker->end - marker->start) return 0; - - mrk = txt_next_marker(text, marker); - while (mrk) { - nxt = txt_next_marker(text, mrk); /* mrk may become invalid */ - txt_move_to(text, mrk->lineno, mrk->start + c, 0); - if (s != c) txt_move_to(text, mrk->lineno, mrk->start + s, 1); - txt_backspace_char(text); - text_update_line_edited(st->text->curl); - if (mrk == marker || mrk == nxt) break; - mrk = nxt; - } - swallow = 1; - draw = 1; - } - break; - case DELKEY: - if (marker->flags & TMARK_EDITALL) { - c = text->curc - marker->start; - s = text->selc - marker->start; - if (s < 0 || s > marker->end - marker->start) return 0; - - mrk = txt_next_marker(text, marker); - while (mrk) { - nxt = txt_next_marker(text, mrk); /* mrk may become invalid */ - txt_move_to(text, mrk->lineno, mrk->start + c, 0); - if (s != c) txt_move_to(text, mrk->lineno, mrk->start + s, 1); - txt_delete_char(text); - text_update_line_edited(st->text->curl); - if (mrk == marker || mrk == nxt) break; - mrk = nxt; - } - swallow = 1; - draw = 1; - } - break; - case TABKEY: - if (qual & LR_SHIFTKEY) { - nxt = marker->prev; - if (!nxt) nxt = text->markers.last; - } - else { - nxt = marker->next; - if (!nxt) nxt = text->markers.first; - } - if (marker->flags & TMARK_TEMP) { - if (nxt == marker) nxt = NULL; - BLI_freelinkN(&text->markers, marker); - } - mrk = nxt; - if (mrk) { - txt_move_to(text, mrk->lineno, mrk->start, 0); - txt_move_to(text, mrk->lineno, mrk->end, 1); - // XXX text_update_cursor_moved(C); - // XXX WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); - } - swallow = 1; - draw = 1; - break; - - /* Events that should clear markers */ - case UKEY: if (!(qual & LR_ALTKEY)) break; - case ZKEY: if (evnt == ZKEY && !(qual & LR_CTRLKEY)) break; - case RETKEY: - case ESCKEY: - if (marker->flags & (TMARK_EDITALL | TMARK_TEMP)) - txt_clear_markers(text, marker->group, 0); - else - BLI_freelinkN(&text->markers, marker); - swallow = 1; - draw = 1; - break; - case RIGHTMOUSE: /* Marker context menu? */ - case LEFTMOUSE: - break; - case FKEY: /* Allow find */ - if (qual & LR_SHIFTKEY) swallow = 1; - break; - - default: - if (qual != 0 && qual != LR_SHIFTKEY) - swallow = 1; /* Swallow all other shortcut events */ - } - } - - if (draw) { - // XXX redraw_alltext(); - } - - return swallow; -} - diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index ec564e95c65..726fd26b11d 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -702,6 +702,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) case NC_GEOM: switch (wmn->data) { case ND_DATA: + case ND_VERTEX_GROUP: case ND_SELECT: ED_region_tag_redraw(ar); break; @@ -920,6 +921,7 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn) case NC_GEOM: switch (wmn->data) { case ND_DATA: + case ND_VERTEX_GROUP: case ND_SELECT: ED_region_tag_redraw(ar); break; @@ -1119,16 +1121,21 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes return 1; } else if (CTX_data_equals(member, "active_base")) { - if (scene->basact && (scene->basact->lay & lay)) - if ((scene->basact->object->restrictflag & OB_RESTRICT_VIEW) == 0) + if (scene->basact && (scene->basact->lay & lay)) { + Object *ob = scene->basact->object; + /* if hidden but in edit mode, we still display, can happen with animation */ + if ((ob->restrictflag & OB_RESTRICT_VIEW) == 0 || (ob->mode & OB_MODE_EDIT)) CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, scene->basact); + } return 1; } else if (CTX_data_equals(member, "active_object")) { - if (scene->basact && (scene->basact->lay & lay)) - if ((scene->basact->object->restrictflag & OB_RESTRICT_VIEW) == 0) + if (scene->basact && (scene->basact->lay & lay)) { + Object *ob = scene->basact->object; + if ((ob->restrictflag & OB_RESTRICT_VIEW) == 0 || (ob->mode & OB_MODE_EDIT)) CTX_data_id_pointer_set(result, &scene->basact->object->id); + } return 1; } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 7a1b97ff1d6..fcd92cd5639 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1422,8 +1422,8 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax, ibuf = IMB_allocImBuf((xmaxc - xminc + 1), (ymaxc - yminc + 1), 32, IB_rect); - view3d_validate_backbuf(vc); - + view3d_validate_backbuf(vc); + glReadPixels(vc->ar->winrct.xmin + xminc, vc->ar->winrct.ymin + yminc, (xmaxc - xminc + 1), @@ -1931,10 +1931,17 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas for (; dob; dob_prev = dob, dob = dob_next, dob_next = dob_next ? dupli_step(dob_next->next) : NULL) { tbase.object = dob->ob; - /* extra service: draw the duplicator in drawtype of parent */ - /* MIN2 for the drawtype to allow bounding box objects in groups for lods */ - dt = tbase.object->dt; tbase.object->dt = MIN2(tbase.object->dt, base->object->dt); - dtx = tbase.object->dtx; tbase.object->dtx = base->object->dtx; + /* extra service: draw the duplicator in drawtype of parent, minimum taken + * to allow e.g. boundbox box objects in groups for LOD */ + dt = tbase.object->dt; + tbase.object->dt = MIN2(tbase.object->dt, base->object->dt); + + /* inherit draw extra, but not if a boundbox under the assumption that this + * is intended to speed up drawing, and drawing extra (especially wire) can + * slow it down too much */ + dtx = tbase.object->dtx; + if(tbase.object->dt != OB_BOUNDBOX) + tbase.object->dtx = base->object->dtx; /* negative scale flag has to propagate */ transflag = tbase.object->transflag; @@ -2996,9 +3003,10 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const v3d->zbuf = FALSE; /* enables anti-aliasing for 3D view drawing */ - if (U.ogl_multisamples) - if (!(U.gameflags & USER_DISABLE_AA)) - glEnable(GL_MULTISAMPLE_ARB); + if (U.ogl_multisamples != USER_MULTISAMPLE_NONE) { + // if (!(U.gameflags & USER_DISABLE_AA)) + glEnable(GL_MULTISAMPLE_ARB); + } /* needs to be done always, gridview is adjusted in drawgrid() now */ @@ -3113,9 +3121,10 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const BIF_draw_manipulator(C); /* Disable back anti-aliasing */ - if (U.ogl_multisamples) - if (!(U.gameflags & USER_DISABLE_AA)) - glDisable(GL_MULTISAMPLE_ARB); + if (U.ogl_multisamples != USER_MULTISAMPLE_NONE) { + // if (!(U.gameflags & USER_DISABLE_AA)) + glDisable(GL_MULTISAMPLE_ARB); + } if (v3d->zbuf) { @@ -3235,12 +3244,16 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) #ifdef DEBUG_DRAW /* debug drawing */ #define _DEBUG_DRAW_QUAD_TOT 1024 +#define _DEBUG_DRAW_EDGE_TOT 1024 static float _bl_debug_draw_quads[_DEBUG_DRAW_QUAD_TOT][4][3]; static int _bl_debug_draw_quads_tot = 0; +static float _bl_debug_draw_edges[_DEBUG_DRAW_QUAD_TOT][2][3]; +static int _bl_debug_draw_edges_tot = 0; void bl_debug_draw_quad_clear(void) { _bl_debug_draw_quads_tot = 0; + _bl_debug_draw_edges_tot = 0; } void bl_debug_draw_quad_add(const float v0[3], const float v1[3], const float v2[3], const float v3[3]) { @@ -3258,16 +3271,14 @@ void bl_debug_draw_quad_add(const float v0[3], const float v1[3], const float v2 } void bl_debug_draw_edge_add(const float v0[3], const float v1[3]) { - if (_bl_debug_draw_quads_tot >= _DEBUG_DRAW_QUAD_TOT) { - printf("%s: max edge count hit %d!", __func__, _bl_debug_draw_quads_tot); + if (_bl_debug_draw_quads_tot >= _DEBUG_DRAW_EDGE_TOT) { + printf("%s: max edge count hit %d!", __func__, _bl_debug_draw_edges_tot); } else { - float *pt = &_bl_debug_draw_quads[_bl_debug_draw_quads_tot][0][0]; + float *pt = &_bl_debug_draw_edges[_bl_debug_draw_edges_tot][0][0]; copy_v3_v3(pt, v0); pt += 3; copy_v3_v3(pt, v1); pt += 3; - copy_v3_v3(pt, v0); pt += 3; - copy_v3_v3(pt, v1); pt += 3; - _bl_debug_draw_quads_tot++; + _bl_debug_draw_edges_tot++; } } static void bl_debug_draw(void) @@ -3284,5 +3295,22 @@ static void bl_debug_draw(void) } glEnd(); } + if (_bl_debug_draw_edges_tot) { + int i; + cpack(0x00FFFF00); + glBegin(GL_LINES); + for (i = 0; i < _bl_debug_draw_edges_tot; i ++) { + glVertex3fv(_bl_debug_draw_edges[i][0]); + glVertex3fv(_bl_debug_draw_edges[i][1]); + } + glEnd(); + glPointSize(4.0); + glBegin(GL_POINTS); + for (i = 0; i < _bl_debug_draw_edges_tot; i ++) { + glVertex3fv(_bl_debug_draw_edges[i][0]); + glVertex3fv(_bl_debug_draw_edges[i][1]); + } + glEnd(); + } } #endif diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index c7ba3378073..0d8567b256d 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1653,7 +1653,7 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my) } -static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, const short zoom_invert) +static void viewzoom_apply(ViewOpsData *vod, const int x, const int y, const short viewzoom, const short zoom_invert) { float zfac = 1.0; short use_cam_zoom; @@ -1674,10 +1674,10 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, float fac; if (U.uiflag & USER_ZOOM_HORIZ) { - fac = (float)(x - vod->origx); + fac = (float)(vod->origx - x); } else { - fac = (float)(y - vod->origy); + fac = (float)(vod->origy - y); } if (zoom_invert) { diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 5aee90f0860..cddfae53f6f 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -369,8 +369,6 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event } /* store the original camera loc and rot */ - /* TODO. axis angle etc */ - fly->obtfm = BKE_object_tfm_backup(ob_back); BKE_object_where_is_calc(fly->scene, fly->v3d->camera); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 73f1563417c..6105b5e4eb5 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -274,8 +274,8 @@ void view3d_keymap(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, KM_ALT, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.viewport_shade"); - RNA_string_set(kmi->ptr, "value_1", "TEXTURED"); - RNA_string_set(kmi->ptr, "value_2", "SOLID"); + RNA_string_set(kmi->ptr, "value_1", "SOLID"); + RNA_string_set(kmi->ptr, "value_2", "TEXTURED"); /* selection*/ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 23c764f9252..b26718bb516 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2860,11 +2860,21 @@ static void headerResize(TransInfo *t, float vec[3], char *str) (void)spos; } -#define SIGN(a) (a<-FLT_EPSILON ? 1 : a>FLT_EPSILON ? 2 : 3) -#define VECSIGNFLIP(a, b) ((SIGN(a[0]) & SIGN(b[0])) == 0 || (SIGN(a[1]) & SIGN(b[1])) == 0 || (SIGN(a[2]) & SIGN(b[2])) == 0) +/* FLT_EPSILON is too small [#29633], 0.0000001f starts to flip */ +#define TX_FLIP_EPS 0.00001f +BLI_INLINE int tx_sign(const float a) +{ + return (a < -TX_FLIP_EPS ? 1 : a > TX_FLIP_EPS ? 2 : 3); +} +BLI_INLINE int tx_vec_sign_flip(const float a[3], const float b[3]) +{ + return ((tx_sign(a[0]) & tx_sign(b[0])) == 0 || + (tx_sign(a[1]) & tx_sign(b[1])) == 0 || + (tx_sign(a[2]) & tx_sign(b[2])) == 0); +} /* smat is reference matrix, only scaled */ -static void TransMat3ToSize(float mat[][3], float smat[][3], float *size) +static void TransMat3ToSize(float mat[][3], float smat[][3], float size[3]) { float vec[3]; @@ -2876,9 +2886,9 @@ static void TransMat3ToSize(float mat[][3], float smat[][3], float *size) size[2] = normalize_v3(vec); /* first tried with dotproduct... but the sign flip is crucial */ - if (VECSIGNFLIP(mat[0], smat[0]) ) size[0] = -size[0]; - if (VECSIGNFLIP(mat[1], smat[1]) ) size[1] = -size[1]; - if (VECSIGNFLIP(mat[2], smat[2]) ) size[2] = -size[2]; + if (tx_vec_sign_flip(mat[0], smat[0]) ) size[0] = -size[0]; + if (tx_vec_sign_flip(mat[1], smat[1]) ) size[1] = -size[1]; + if (tx_vec_sign_flip(mat[2], smat[2]) ) size[2] = -size[2]; } diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 311cb5ee94d..947bdf53bee 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -150,8 +150,8 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) if (hasNumInput(&t->num)) { applyNumInput(&t->num, vec); - removeAspectRatio(t, vec); constraintNumInput(t, vec); + removeAspectRatio(t, vec); } /* autovalues is operator param, use that directly but not if snapping is forced */ diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c index fa39a52444b..1c32c01b8f0 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.c +++ b/source/blender/editors/uvedit/uvedit_buttons.c @@ -94,14 +94,19 @@ static int uvedit_center(Scene *scene, BMEditMesh *em, Image *ima, float center[ return tot; } -static void uvedit_translate(Scene *scene, BMEditMesh *em, Image *UNUSED(ima), float delta[2]) +static void uvedit_translate(Scene *scene, BMEditMesh *em, Image *ima, float delta[2]) { BMFace *f; BMLoop *l; BMIter iter, liter; MLoopUV *luv; + MTexPoly *tf; BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { + tf = CustomData_bmesh_get(&em->bm->pdata, f->head.data, CD_MTEXPOLY); + if (!uvedit_face_visible_test(scene, ima, f, tf)) + continue; + BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); if (uvedit_uv_select_test(em, scene, l)) { diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 6664f8e860e..0feaec514d2 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1705,7 +1705,7 @@ static void UV_OT_remove_doubles(wmOperatorType *ot) { /* identifiers */ ot->name = "Remove Doubles UV"; - ot->description = "Selected UV vertices that are within a radius of eachother are welded together"; + ot->description = "Selected UV vertices that are within a radius of each other are welded together"; ot->idname = "UV_OT_remove_doubles"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/gpu/shaders/gpu_shader_vertex.glsl b/source/blender/gpu/shaders/gpu_shader_vertex.glsl index a86431bdd7a..574455e42b3 100644 --- a/source/blender/gpu/shaders/gpu_shader_vertex.glsl +++ b/source/blender/gpu/shaders/gpu_shader_vertex.glsl @@ -10,3 +10,11 @@ void main() varnormal = normalize(gl_NormalMatrix * gl_Normal); gl_Position = gl_ProjectionMatrix * co; + // Setting gl_ClipVertex is necessary to get glClipPlane working on NVIDIA graphic cards. + // gl_ClipVertex works only on NVIDIA graphic cards so we have to check with + // __GLSL_CG_DATA_TYPES if a NVIDIA graphic card is used (Cg support). + // gl_ClipVerte is supported up to GLSL 1.20. + #ifdef __GLSL_CG_DATA_TYPES + gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex; + #endif + diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index af15333ece5..ca81f4c915a 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -379,6 +379,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) copy_v3_v3(goalpos, goal[3]); copy_m3_m4(goalrot, goal); + normalize_m3(goalrot); /* same for pole vector target */ if (data->poletar) { @@ -433,7 +434,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) iktarget = iktree[target->tip]; - if (data->weight != 0.0f) { + if ((data->flag & CONSTRAINT_IK_POS) && data->weight != 0.0f) { if (poleconstrain) IK_SolverSetPoleVectorConstraint(solver, iktarget, goalpos, polepos, data->poleangle, (poleangledata == data)); diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c index d20c6dec9d3..c8bc3f8ebb8 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c @@ -139,9 +139,19 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon if (ibuf->rect_float != 0 && bitspersample != 8) { /* don't use the float buffer to save 8 bpp picture to prevent color banding (there's no dithering algorithm behing the logImageSetDataRGBA function) */ - IMB_flipy(ibuf); - rvalue = (logImageSetDataRGBA(logImage, ibuf->rect_float, 1) == 0); - IMB_flipy(ibuf); + + fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float), "fbuf in imb_save_dpx_cineon"); + + for (y = 0; y < ibuf->y; y++) { + float *dst_ptr = fbuf + 4 * ((ibuf->y - y - 1) * ibuf->x); + float *src_ptr = ibuf->rect_float + 4 * (y * ibuf->x); + + memcpy(dst_ptr, src_ptr, 4 * ibuf->x * sizeof(float)); + } + + rvalue = (logImageSetDataRGBA(logImage, fbuf, 1) == 0); + + MEM_freeN(fbuf); } else { if (ibuf->rect == 0) diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c index 9926d8c8562..3049a5be514 100644 --- a/source/blender/imbuf/intern/cineon/cineonlib.c +++ b/source/blender/imbuf/intern/cineon/cineonlib.c @@ -188,7 +188,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t } else { if (verbose) printf("Cineon: Bad magic number %lu in \"%s\".\n", - (uintptr_t)header.fileHeader.magic_num, byteStuff); + (unsigned long)header.fileHeader.magic_num, byteStuff); logImageClose(cineon); return 0; } diff --git a/source/blender/imbuf/intern/openexr/CMakeLists.txt b/source/blender/imbuf/intern/openexr/CMakeLists.txt index d5cb8e8a3b6..6c428afe535 100644 --- a/source/blender/imbuf/intern/openexr/CMakeLists.txt +++ b/source/blender/imbuf/intern/openexr/CMakeLists.txt @@ -52,4 +52,6 @@ if(WITH_IMAGE_OPENEXR) add_definitions(-DWITH_OPENEXR) endif() +message(STATUS "EXR ${INC_SYS}") + blender_add_lib(bf_imbuf_openexr "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 5d2632ec0d7..da7b31cc2ba 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -72,21 +72,6 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #include <iostream> -#if defined(_WIN32) && !defined(FREE_WINDOWS) -#include <half.h> -#include <Iex/Iex.h> -#include <IlmImf/ImfVersion.h> -#include <IlmImf/ImfArray.h> -#include <IlmImf/ImfIO.h> -#include <IlmImf/ImfChannelList.h> -#include <IlmImf/ImfPixelType.h> -#include <IlmImf/ImfInputFile.h> -#include <IlmImf/ImfOutputFile.h> -#include <IlmImf/ImfCompression.h> -#include <IlmImf/ImfCompressionAttribute.h> -#include <IlmImf/ImfStringAttribute.h> -#include <Imath/ImathBox.h> -#else #include <half.h> #include <Iex.h> #include <ImfVersion.h> @@ -100,7 +85,6 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #include <ImfCompression.h> #include <ImfCompressionAttribute.h> #include <ImfStringAttribute.h> -#endif using namespace Imf; using namespace Imath; diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index fe138a71a4a..42fb0c79b62 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -228,16 +228,27 @@ static int isqtime(const char *name) #ifdef WITH_FFMPEG +#ifdef _MSC_VER +#define va_copy(dst, src) ((dst) = (src)) +#endif + /* BLI_vsnprintf in ffmpeg_log_callback() causes invalid warning */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wmissing-format-attribute" +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wmissing-format-attribute" +#endif static char ffmpeg_last_error[1024]; static void ffmpeg_log_callback(void *ptr, int level, const char *format, va_list arg) { if (ELEM(level, AV_LOG_FATAL, AV_LOG_ERROR)) { - size_t n = BLI_vsnprintf(ffmpeg_last_error, sizeof(ffmpeg_last_error), format, arg); + size_t n; + va_list arg2; + + va_copy(arg2, arg); + + n = BLI_vsnprintf(ffmpeg_last_error, sizeof(ffmpeg_last_error), format, arg2); /* strip trailing \n */ ffmpeg_last_error[n - 1] = '\0'; @@ -249,7 +260,9 @@ static void ffmpeg_log_callback(void *ptr, int level, const char *format, va_lis } } -#pragma GCC diagnostic pop +#ifdef __GNUC__ +# pragma GCC diagnostic pop +#endif void IMB_ffmpeg_init(void) { diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index a730bee4f79..94d8ed00cf7 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -372,7 +372,7 @@ typedef enum ePose_Flags { /* bPose->iksolver and bPose->ikparam->iksolver */ typedef enum ePose_IKSolverType { - IKSOLVER_LEGACY = 0, + IKSOLVER_STANDARD = 0, IKSOLVER_ITASC = 1 } ePose_IKSolverType; diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 2c896e4893f..3875a0d5799 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -76,6 +76,7 @@ typedef enum ModifierType { eModifierType_Remesh = 41, eModifierType_Skin = 42, eModifierType_LaplacianSmooth = 43, + eModifierType_Triangulate = 44, NUM_MODIFIER_TYPES } ModifierType; @@ -1114,11 +1115,23 @@ enum { MOD_SKIN_SMOOTH_SHADING = 1 }; +/* Triangulate modifier */ + +typedef struct TriangulateModifierData { + ModifierData modifier; + int flag; + int pad; +} TriangulateModifierData; + +enum { + MOD_TRIANGULATE_BEAUTY = (1 << 0), +}; + /* Smooth modifier flags */ #define MOD_LAPLACIANSMOOTH_X (1<<1) #define MOD_LAPLACIANSMOOTH_Y (1<<2) #define MOD_LAPLACIANSMOOTH_Z (1<<3) -#define MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION (1<<4) +#define MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME (1 << 4) typedef struct LaplacianSmoothModifierData { ModifierData modifier; diff --git a/source/blender/makesdna/DNA_text_types.h b/source/blender/makesdna/DNA_text_types.h index 810628ac29b..6ce883905d4 100644 --- a/source/blender/makesdna/DNA_text_types.h +++ b/source/blender/makesdna/DNA_text_types.h @@ -44,15 +44,6 @@ typedef struct TextLine { int len, blen; /* blen unused */ } TextLine; -typedef struct TextMarker { - struct TextMarker *next, *prev; - - int lineno, start, end, pad1; /* line number and start/end character indices */ - - int group, flags; /* see BKE_text.h for flag defines */ - unsigned char color[4], pad[4]; /* draw color of the marker */ -} TextMarker; - typedef struct Text { ID id; @@ -63,7 +54,6 @@ typedef struct Text { ListBase lines; TextLine *curl, *sell; int curc, selc; - ListBase markers; char *undo_buf; int undo_pos, undo_len; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 1770a6e497c..b8bb7a5846d 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -601,7 +601,7 @@ typedef enum eOpenGL_RenderingOptions { /* backwards compatibilty in do_versions! */ USER_DISABLE_MIPMAP = (1 << 2), USER_DISABLE_VBO = (1 << 3), - USER_DISABLE_AA = (1 << 4), + /* USER_DISABLE_AA = (1 << 4), */ /* DEPRECATED */ } eOpenGL_RenderingOptions; /* wm draw method */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 8885349ecc5..0df6fc41269 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -561,7 +561,6 @@ extern StructRNA RNA_TextBox; extern StructRNA RNA_TextCharacterFormat; extern StructRNA RNA_TextCurve; extern StructRNA RNA_TextLine; -extern StructRNA RNA_TextMarker; extern StructRNA RNA_Texture; extern StructRNA RNA_TextureNode; extern StructRNA RNA_TextureNodeBricks; @@ -1089,6 +1088,11 @@ __attribute__ ((format(printf, 1, 2))) #endif ; +/* Equals test (skips pointers and collections) */ + +int RNA_property_equals(struct PointerRNA *a, struct PointerRNA *b, struct PropertyRNA *prop); +int RNA_struct_equals(struct PointerRNA *a, struct PointerRNA *b); + #ifdef __cplusplus } #endif diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index c057739a28f..075dc959173 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1223,6 +1223,89 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property return func; } +static char *rna_def_property_lookup_string_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, + const char *manualfunc, const char *item_type) +{ + char *func; + StructRNA *item_srna, *item_name_base; + PropertyRNA *item_name_prop; + const int namebuflen = 1024; + + if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL) + return NULL; + + if (!manualfunc) { + if (!dp->dnastructname || !dp->dnaname) + return NULL; + + /* only supported for collection items with name properties */ + item_srna = rna_find_struct(item_type); + if (item_srna && item_srna->nameproperty) { + item_name_prop = item_srna->nameproperty; + item_name_base = item_srna; + while (item_name_base->base && item_name_base->base->nameproperty == item_name_prop) + item_name_base = item_name_base->base; + } + else + return NULL; + } + + func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "lookup_string"); + + fprintf(f, "int %s(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)\n", func); + fprintf(f, "{\n"); + + if (manualfunc) { + fprintf(f, " return %s(ptr, key, r_ptr);\n", manualfunc); + fprintf(f, "}\n\n"); + return func; + } + + /* XXX extern declaration could be avoid by including RNA_blender.h, but this has lots of unknown + * DNA types in functions, leading to conflicting function signatures. + */ + fprintf(f, " extern int %s_%s_length(PointerRNA *);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier)); + fprintf(f, " extern void %s_%s_get(PointerRNA *, char *);\n\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier)); + + fprintf(f, " int found= 0;\n"); + fprintf(f, " CollectionPropertyIterator iter;\n"); + fprintf(f, " char namebuf[%d];\n", namebuflen); + fprintf(f, " char *name;\n\n"); + + fprintf(f, " %s_%s_begin(&iter, ptr);\n\n", srna->identifier, rna_safe_id(prop->identifier)); + + fprintf(f, " while (iter.valid) {\n"); + fprintf(f, " int namelen = %s_%s_length(&iter.ptr);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier)); + fprintf(f, " if (namelen < %d) {\n", namebuflen); + fprintf(f, " %s_%s_get(&iter.ptr, namebuf);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier)); + fprintf(f, " if (strcmp(namebuf, key) == 0) {\n"); + fprintf(f, " found = 1;\n"); + fprintf(f, " *r_ptr = iter.ptr;\n"); + fprintf(f, " break;\n"); + fprintf(f, " }\n"); + fprintf(f, " }\n"); + fprintf(f, " else {\n"); + fprintf(f, " name = MEM_mallocN(namelen+1, \"name string\");\n"); + fprintf(f, " %s_%s_get(&iter.ptr, name);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier)); + fprintf(f, " if (strcmp(name, key) == 0) {\n"); + fprintf(f, " MEM_freeN(name);\n\n"); + fprintf(f, " found = 1;\n"); + fprintf(f, " *r_ptr = iter.ptr;\n"); + fprintf(f, " break;\n"); + fprintf(f, " }\n"); + fprintf(f, " else\n"); + fprintf(f, " MEM_freeN(name);\n"); + fprintf(f, " }\n"); + fprintf(f, " %s_%s_next(&iter);\n", srna->identifier, rna_safe_id(prop->identifier)); + fprintf(f, " }\n"); + fprintf(f, " %s_%s_end(&iter);\n\n", srna->identifier, rna_safe_id(prop->identifier)); + + fprintf(f, " return found;\n"); + fprintf(f, "}\n\n"); + + return func; +} + static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *UNUSED(dp), const char *manualfunc) { @@ -1403,6 +1486,7 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp) { CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop; const char *nextfunc = (const char *)cprop->next; + const char *item_type = (const char *)cprop->item_type; if (dp->dnatype && strcmp(dp->dnatype, "ListBase") == 0) { /* pass */ @@ -1426,6 +1510,8 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp) cprop->end = (void *)rna_def_property_end_func(f, srna, prop, dp, (const char *)cprop->end); cprop->lookupint = (void *)rna_def_property_lookup_int_func(f, srna, prop, dp, (const char *)cprop->lookupint, nextfunc); + cprop->lookupstring = (void *)rna_def_property_lookup_string_func(f, srna, prop, dp, + (const char *)cprop->lookupstring, item_type); if (!(prop->flag & PROP_IDPROPERTY)) { if (!cprop->begin) { @@ -3172,6 +3258,8 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const fprintf(f, "#include <string.h>\n\n"); fprintf(f, "#include <stddef.h>\n\n"); + fprintf(f, "#include \"MEM_guardedalloc.h\"\n\n"); + fprintf(f, "#include \"DNA_ID.h\"\n"); fprintf(f, "#include \"DNA_scene_types.h\"\n"); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 81e738ed82f..470e87daeea 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2551,7 +2551,10 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop) pprop = (PointerPropertyRNA *)prop; /* for groups, data is idprop itself */ - return rna_pointer_inherit_refine(ptr, pprop->type, idprop); + if (pprop->typef) + return rna_pointer_inherit_refine(ptr, pprop->typef(ptr), idprop); + else + return rna_pointer_inherit_refine(ptr, pprop->type, idprop); } else if (pprop->get) { return pprop->get(ptr); @@ -4147,12 +4150,15 @@ char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop) path = BLI_sprintfN(is_rna ? "%s.%s" : "%s[\"%s\"]", ptrpath, propname); MEM_freeN(ptrpath); } - else { + else if (RNA_struct_is_ID(ptr->type)) { if (is_rna) path = BLI_strdup(propname); else path = BLI_sprintfN("[\"%s\"]", propname); } + else { + path = NULL; + } return path; } @@ -5718,7 +5724,7 @@ int RNA_property_copy(PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, i /* get the length of the array to work with */ len = RNA_property_array_length(ptr, prop); - fromlen = RNA_property_array_length(ptr, prop); + fromlen = RNA_property_array_length(fromptr, prop); if (len != fromlen) return 0; @@ -5832,3 +5838,146 @@ void _RNA_warning(const char *format, ...) } #endif } + +int RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop) +{ + /* get the length of the array to work with */ + int len = RNA_property_array_length(a, prop); + int fromlen = RNA_property_array_length(b, prop); + + if (len != fromlen) + return 0; + + /* get and set the default values as appropriate for the various types */ + switch (RNA_property_type(prop)) { + case PROP_BOOLEAN: { + if (len) { + int fixed_a[16], fixed_b[16]; + int *array_a, *array_b; + int equals; + + array_a = (len > 16)? MEM_callocN(sizeof(int) * len, "RNA equals"): fixed_a; + array_b = (len > 16)? MEM_callocN(sizeof(int) * len, "RNA equals"): fixed_b; + + RNA_property_boolean_get_array(a, prop, array_a); + RNA_property_boolean_get_array(b, prop, array_b); + + equals = memcmp(array_a, array_b, sizeof(int) * len) == 0; + + if (array_a != fixed_a) MEM_freeN(array_a); + if (array_b != fixed_b) MEM_freeN(array_b); + + return equals; + } + else { + int value = RNA_property_boolean_get(a, prop); + return value == RNA_property_boolean_get(b, prop); + } + } + + case PROP_INT: { + if (len) { + int fixed_a[16], fixed_b[16]; + int *array_a, *array_b; + int equals; + + array_a = (len > 16)? MEM_callocN(sizeof(int) * len, "RNA equals"): fixed_a; + array_b = (len > 16)? MEM_callocN(sizeof(int) * len, "RNA equals"): fixed_b; + + RNA_property_int_get_array(a, prop, array_a); + RNA_property_int_get_array(b, prop, array_b); + + equals = memcmp(array_a, array_b, sizeof(int) * len) == 0; + + if (array_a != fixed_a) MEM_freeN(array_a); + if (array_b != fixed_b) MEM_freeN(array_b); + + return equals; + } + else { + int value = RNA_property_int_get(a, prop); + return value == RNA_property_int_get(b, prop); + } + } + + case PROP_FLOAT: { + if (len) { + float fixed_a[16], fixed_b[16]; + float *array_a, *array_b; + int equals; + + array_a = (len > 16)? MEM_callocN(sizeof(float) * len, "RNA equals"): fixed_a; + array_b = (len > 16)? MEM_callocN(sizeof(float) * len, "RNA equals"): fixed_b; + + RNA_property_float_get_array(a, prop, array_a); + RNA_property_float_get_array(b, prop, array_b); + + equals = memcmp(array_a, array_b, sizeof(float) * len) == 0; + + if (array_a != fixed_a) MEM_freeN(array_a); + if (array_b != fixed_b) MEM_freeN(array_b); + + return equals; + } + else { + float value = RNA_property_float_get(a, prop); + return value == RNA_property_float_get(b, prop); + } + } + + case PROP_ENUM: { + int value = RNA_property_enum_get(a, prop); + return value == RNA_property_enum_get(b, prop); + } + + case PROP_STRING: { + char fixed_a[128], fixed_b[128]; + int len_a, len_b; + char *value_a = RNA_property_string_get_alloc(a, prop, fixed_a, sizeof(fixed_a), &len_a); + char *value_b = RNA_property_string_get_alloc(b, prop, fixed_b, sizeof(fixed_b), &len_b); + int equals = strcmp(value_a, value_b) == 0; + + if (value_a != fixed_a) MEM_freeN(value_a); + if (value_b != fixed_b) MEM_freeN(value_b); + + return equals; + } + + default: + break; + } + + return 1; +} + +int RNA_struct_equals(PointerRNA *a, PointerRNA *b) +{ + CollectionPropertyIterator iter; +// CollectionPropertyRNA *citerprop; /* UNUSED */ + PropertyRNA *iterprop; + int equals = 1; + + if (a == NULL && b == NULL) + return 1; + else if (a == NULL || b == NULL) + return 0; + else if (a->type != b->type) + return 0; + + iterprop = RNA_struct_iterator_property(a->type); +// citerprop = (CollectionPropertyRNA *)rna_ensure_property(iterprop); /* UNUSED */ + + RNA_property_collection_begin(a, iterprop, &iter); + for (; iter.valid; RNA_property_collection_next(&iter)) { + PropertyRNA *prop = iter.ptr.data; + + if (!RNA_property_equals(a, b, prop)) { + equals = 0; + break; + } + } + RNA_property_collection_end(&iter); + + return equals; +} + diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index b1fdfccd0be..b653289e44d 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -973,13 +973,13 @@ static void rna_def_sound_actuator(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 2); RNA_def_property_range(prop, 0.0, 2.0); RNA_def_property_ui_text(prop, "Volume", "Initial volume of the sound"); - RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_AUDIO); + RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_SOUND); RNA_def_property_update(prop, NC_LOGIC, NULL); prop = RNA_def_property(srna, "pitch", PROP_FLOAT, PROP_NONE); RNA_def_property_ui_range(prop, -12.0, 12.0, 1, 2); RNA_def_property_ui_text(prop, "Pitch", "Pitch of the sound"); - RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_AUDIO); + RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_SOUND); RNA_def_property_update(prop, NC_LOGIC, NULL); /* floats - 3D Parameters */ diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 7b6b629ca82..30a9bfd81f6 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -614,7 +614,7 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 1, 10000); + RNA_def_property_range(prop, 0, 10000); RNA_def_property_ui_text(prop, "Iterations", "Maximum number of solving iterations"); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index 9d63e0e687d..af39500442d 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -421,7 +421,7 @@ static void rna_def_lamp(BlenderRNA *brna) /* textures */ rna_def_mtex_common(brna, srna, "rna_Lamp_mtex_begin", "rna_Lamp_active_texture_get", - "rna_Lamp_active_texture_set", NULL, "LampTextureSlot", "LampTextureSlots", "rna_Lamp_update"); + "rna_Lamp_active_texture_set", NULL, "LampTextureSlot", "LampTextureSlots", "rna_Lamp_draw_update"); } static void rna_def_lamp_falloff(StructRNA *srna) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 2e3f8feda44..06df6c5afbc 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -78,6 +78,7 @@ EnumPropertyItem modifier_type_items[] = { {eModifierType_Skin, "SKIN", ICON_MOD_SKIN, "Skin", ""}, {eModifierType_Solidify, "SOLIDIFY", ICON_MOD_SOLIDIFY, "Solidify", ""}, {eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subdivision Surface", ""}, + {eModifierType_Triangulate, "TRIANGULATE", ICON_MOD_TRIANGULATE, "Triangulate", ""}, {0, "", 0, N_("Deform"), ""}, {eModifierType_Armature, "ARMATURE", ICON_MOD_ARMATURE, "Armature", ""}, {eModifierType_Cast, "CAST", ICON_MOD_CAST, "Cast", ""}, @@ -213,6 +214,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr) return &RNA_SkinModifier; case eModifierType_LaplacianSmooth: return &RNA_LaplacianSmoothModifier; + case eModifierType_Triangulate: + return &RNA_TriangulateModifier; default: return &RNA_Modifier; } @@ -1814,7 +1817,7 @@ static void rna_def_modifier_laplaciansmooth(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "use_volume_preserve", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME); RNA_def_property_ui_text(prop, "Preserve Volume", "Apply volume preservation after smooth"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -3361,6 +3364,22 @@ static void rna_def_modifier_skin(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); } +static void rna_def_modifier_triangulate(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "TriangulateModifier", "Modifier"); + RNA_def_struct_ui_text(srna, "Triangulate Modifier", "Triangulate Mesh"); + RNA_def_struct_sdna(srna, "TriangulateModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_TRIANGULATE); + + prop = RNA_def_property(srna, "use_beauty", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_TRIANGULATE_BEAUTY); + RNA_def_property_ui_text(prop, "Beauty Subdivide", "Subdivide across shortest diagonal"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); +} + void RNA_def_modifier(BlenderRNA *brna) { StructRNA *srna; @@ -3468,6 +3487,7 @@ void RNA_def_modifier(BlenderRNA *brna) rna_def_modifier_remesh(brna); rna_def_modifier_skin(brna); rna_def_modifier_laplaciansmooth(brna); + rna_def_modifier_triangulate(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 412aad20a41..5c90fb8787c 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -675,7 +675,7 @@ static void rna_def_bone_group(BlenderRNA *brna) } static EnumPropertyItem prop_iksolver_items[] = { - {IKSOLVER_LEGACY, "LEGACY", 0, "Legacy", "Original IK solver"}, + {IKSOLVER_STANDARD, "LEGACY", 0, "Standard", "Original IK solver"}, {IKSOLVER_ITASC, "ITASC", 0, "iTaSC", "Multi constraint, stateful IK solver"}, {0, NULL, 0, NULL, NULL} }; @@ -1126,7 +1126,7 @@ static void rna_def_pose_itasc(BlenderRNA *brna) prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "numiter"); - RNA_def_property_range(prop, 1.f, 1000.f); + RNA_def_property_range(prop, 0, 1000); RNA_def_property_ui_text(prop, "Iterations", "Maximum number of iterations for convergence in case of reiteration"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update"); @@ -1221,8 +1221,7 @@ static void rna_def_pose_ikparam(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "iksolver"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_enum_items(prop, prop_iksolver_items); - RNA_def_property_ui_text(prop, "IK Solver", - "IK solver for which these parameters are defined, 0 for Legacy, 1 for iTaSC"); + RNA_def_property_ui_text(prop, "IK Solver", "IK solver for which these parameters are defined"); } /* pose.bone_groups */ @@ -1285,8 +1284,7 @@ static void rna_def_pose(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "iksolver"); RNA_def_property_enum_funcs(prop, NULL, "rna_Pose_ik_solver_set", NULL); RNA_def_property_enum_items(prop, prop_iksolver_items); - RNA_def_property_ui_text(prop, "IK Solver", - "Selection of IK solver for IK chain, current choice is 0 for Legacy, 1 for iTaSC"); + RNA_def_property_ui_text(prop, "IK Solver", "Selection of IK solver for IK chain"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_ik_solver_update"); prop = RNA_def_property(srna, "ik_param", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 09d0eeb1e34..ffcca772764 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -3575,7 +3575,7 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Volume", "Audio volume"); - RNA_def_property_translation_context(prop, "Audio"); + RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_SOUND); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); #endif @@ -4408,6 +4408,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop = RNA_def_property(srna, "use_sequencer_gl_preview", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_GL_PREV); RNA_def_property_ui_text(prop, "Sequencer OpenGL", ""); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update"); #if 0 /* see R_SEQ_GL_REND comment */ prop = RNA_def_property(srna, "use_sequencer_gl_render", PROP_BOOLEAN, PROP_NONE); @@ -5017,7 +5018,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "audio.volume"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Volume", "Audio volume"); - RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_AUDIO); + RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_SOUND); RNA_def_property_update(prop, NC_SCENE, NULL); RNA_def_property_float_funcs(prop, NULL, "rna_Scene_volume_set", NULL); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index c2fa64698e4..18a9b9683f8 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -1875,7 +1875,7 @@ static void rna_def_sound(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "volume"); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_text(prop, "Volume", "Playback volume of the sound"); - RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_AUDIO); + RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_SOUND); RNA_def_property_float_funcs(prop, NULL, "rna_Sequence_volume_set", NULL); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); @@ -1883,7 +1883,7 @@ static void rna_def_sound(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "pitch"); RNA_def_property_range(prop, 0.1f, 10.0f); RNA_def_property_ui_text(prop, "Pitch", "Playback pitch of the sound"); - RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_AUDIO); + RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_SOUND); RNA_def_property_float_funcs(prop, NULL, "rna_Sequence_pitch_set", NULL); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); diff --git a/source/blender/makesrna/intern/rna_speaker.c b/source/blender/makesrna/intern/rna_speaker.c index a160aaf94e2..139582104ee 100644 --- a/source/blender/makesrna/intern/rna_speaker.c +++ b/source/blender/makesrna/intern/rna_speaker.c @@ -152,7 +152,7 @@ static void rna_def_speaker(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "volume"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Volume", "How loud the sound is"); - RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_AUDIO); + RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_SOUND); /* RNA_def_property_float_funcs(prop, NULL, "rna_Speaker_volume_set", NULL); */ /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */ @@ -160,7 +160,7 @@ static void rna_def_speaker(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "pitch"); RNA_def_property_range(prop, 0.1f, 10.0f); RNA_def_property_ui_text(prop, "Pitch", "Playback pitch of the sound"); - RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_AUDIO); + RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_SOUND); /* RNA_def_property_float_funcs(prop, NULL, "rna_Speaker_pitch_set", NULL); */ /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */ diff --git a/source/blender/makesrna/intern/rna_text.c b/source/blender/makesrna/intern/rna_text.c index e46373b250c..b1637ef4c8a 100644 --- a/source/blender/makesrna/intern/rna_text.c +++ b/source/blender/makesrna/intern/rna_text.c @@ -129,49 +129,6 @@ static void rna_def_text_line(BlenderRNA *brna) RNA_def_property_update(prop, NC_TEXT | NA_EDITED, NULL); } -static void rna_def_text_marker(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "TextMarker", NULL); - RNA_def_struct_ui_text(srna, "Text Marker", "Marker highlighting a portion of text in a Text datablock"); - - prop = RNA_def_property(srna, "line", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "lineno"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Line", "Line in which the marker is located"); - - prop = RNA_def_property(srna, "character_index_start", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "start"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Start", "Start position of the marker in the line"); - - prop = RNA_def_property(srna, "character_index_end", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "end"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "End", "Start position of the marker in the line"); - - prop = RNA_def_property(srna, "group", PROP_INT, PROP_UNSIGNED); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_range(prop, 0, (int)0xFFFF); - RNA_def_property_ui_text(prop, "Group", ""); - - prop = RNA_def_property(srna, "is_temporary", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", TMARK_TEMP); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Temporary", "Marker is temporary"); - - prop = RNA_def_property(srna, "use_edit_all", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", TMARK_EDITALL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Edit All", "Edit all markers of the same group as one"); - - prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Color", "Color to display the marker with"); -} - static void rna_def_text(BlenderRNA *brna) { StructRNA *srna; @@ -241,17 +198,12 @@ static void rna_def_text(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Selection End Character", "Index of character after end of selection in the selection end line"); - prop = RNA_def_property(srna, "markers", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "TextMarker"); - RNA_def_property_ui_text(prop, "Markers", "Text markers highlighting part of the text"); - RNA_api_text(srna); } void RNA_def_text(BlenderRNA *brna) { rna_def_text_line(brna); - rna_def_text_marker(brna); rna_def_text(brna); } diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index e77c5d13a6b..e67985f68c5 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -233,6 +233,7 @@ void rna_TextureSlot_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN break; case ID_LA: WM_main_add_notifier(NC_LAMP | ND_LIGHTING, id); + WM_main_add_notifier(NC_LAMP | ND_LIGHTING_DRAW, id); break; case ID_BR: WM_main_add_notifier(NC_BRUSH, id); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index de53ef1f90a..59a3a8c2522 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -3246,10 +3246,12 @@ static void rna_def_userdef_system(BlenderRNA *brna) /* this isn't essential but nice to check if VBO draws any differently */ RNA_def_property_update(prop, NC_WINDOW, NULL); +#if 0 prop = RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflags", USER_DISABLE_AA); RNA_def_property_ui_text(prop, "Anti-aliasing", "Use anti-aliasing for the 3D view (may impact redraw performance)"); +#endif prop = RNA_def_property(srna, "anisotropic_filter", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "anisotropic_filter"); diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index 3a7066ff41a..cf3bb05849a 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -94,6 +94,7 @@ set(SRC intern/MOD_weightvgedit.c intern/MOD_weightvgmix.c intern/MOD_weightvgproximity.c + intern/MOD_triangulate.c MOD_modifiertypes.h intern/MOD_boolean_util.h diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h index a4817ff775d..290ba193567 100644 --- a/source/blender/modifiers/MOD_modifiertypes.h +++ b/source/blender/modifiers/MOD_modifiertypes.h @@ -76,6 +76,7 @@ extern ModifierTypeInfo modifierType_DynamicPaint; extern ModifierTypeInfo modifierType_Remesh; extern ModifierTypeInfo modifierType_Skin; extern ModifierTypeInfo modifierType_LaplacianSmooth; +extern ModifierTypeInfo modifierType_Triangulate; /* MOD_util.c */ void modifier_type_init(ModifierTypeInfo *types[]); diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 8ddae9f3c57..d4463098f07 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -178,14 +178,14 @@ static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op, amd->merge_dist, dupe_op, "geom"); BMO_op_exec(bm, &find_op); - + i = 0; - BMO_ITER (ele, &oiter, bm, dupe_op, "geom", BM_ALL) { + BMO_ITER (ele, &oiter, dupe_op->slots_in, "geom", BM_ALL) { BM_elem_index_set(ele, i); /* set_dirty */ i++; } - BMO_ITER (ele, &oiter, bm, dupe_op, "newout", BM_ALL) { + BMO_ITER (ele, &oiter, dupe_op->slots_out, "geom.out", BM_ALL) { BM_elem_index_set(ele, i); /* set_dirty */ i++; } @@ -197,7 +197,7 @@ static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op, index_map = MEM_callocN(sizeof(int) * (*index_map_length), "index_map"); /*element type argument doesn't do anything here*/ - BMO_ITER (v, &oiter, bm, &find_op, "targetmapout", 0) { + BMO_ITER (v, &oiter, find_op.slots_out, "targetmap.out", 0) { v2 = BMO_iter_map_value_p(&oiter); index_map[BM_elem_index_get(v)] = BM_elem_index_get(v2) + 1; @@ -218,9 +218,10 @@ static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op, static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4], const ArrayModifierData *amd, BMOperator *dupe_op, - const char *dupe_slot_name, + BMOpSlot dupe_op_slot_args[BMO_OP_MAX_SLOTS], const char *dupe_slot_name, BMOperator *weld_op) { + const int is_input = (dupe_op->slots_in == dupe_op_slot_args); BMVert *v, *v2, *v3; BMIter iter; @@ -234,14 +235,27 @@ static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4], BMOIter oiter; BMOperator find_op; + BMOpSlot *slot_targetmap; BMO_op_initf(bm, &find_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), - "find_doubles verts=%Hv dist=%f keep_verts=%s", + is_input ? /* ugh */ + "find_doubles verts=%Hv dist=%f keep_verts=%s" : + "find_doubles verts=%Hv dist=%f keep_verts=%S", BM_ELEM_TAG, amd->merge_dist, dupe_op, dupe_slot_name); /* append the dupe's geom to the findop input verts */ - BMO_slot_buffer_append(&find_op, "verts", dupe_op, dupe_slot_name); + if (is_input) { + BMO_slot_buffer_append(&find_op, slots_in, "verts", + dupe_op, slots_in, dupe_slot_name); + } + else if (dupe_op->slots_out == dupe_op_slot_args) { + BMO_slot_buffer_append(&find_op, slots_in, "verts", + dupe_op, slots_out, dupe_slot_name); + } + else { + BLI_assert(0); + } /* transform and tag verts */ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { @@ -253,15 +267,17 @@ static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4], BMO_op_exec(bm, &find_op); + slot_targetmap = BMO_slot_get(weld_op->slots_in, "targetmap"); + /* add new merge targets to weld operator */ - BMO_ITER (v, &oiter, bm, &find_op, "targetmapout", 0) { + BMO_ITER (v, &oiter, find_op.slots_out, "targetmap.out", 0) { v2 = BMO_iter_map_value_p(&oiter); /* check in case the target vertex (v2) is already marked * for merging */ - while ((v3 = BMO_slot_map_ptr_get(bm, weld_op, "targetmap", v2))) { + while ((v3 = BMO_slot_map_ptr_get(slot_targetmap, v2))) { v2 = v3; } - BMO_slot_map_ptr_insert(bm, weld_op, "targetmap", v, v2); + BMO_slot_map_ptr_insert(weld_op, slot_targetmap, v, v2); } BMO_op_finish(bm, &find_op); @@ -286,6 +302,7 @@ static void merge_first_last(BMesh *bm, BMOperator find_op; BMOIter oiter; BMVert *v, *v2; + BMOpSlot *slot_targetmap; BMO_op_initf(bm, &find_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), "find_doubles verts=%s dist=%f keep_verts=%s", @@ -293,14 +310,16 @@ static void merge_first_last(BMesh *bm, dupe_first, "geom"); /* append the last dupe's geom to the findop input verts */ - BMO_slot_buffer_append(&find_op, "verts", dupe_last, "newout"); + BMO_slot_buffer_append(&find_op, slots_in, "verts", + dupe_last, slots_out, "geom.out"); BMO_op_exec(bm, &find_op); /* add new merge targets to weld operator */ - BMO_ITER (v, &oiter, bm, &find_op, "targetmapout", 0) { + slot_targetmap = BMO_slot_get(weld_op->slots_in, "targetmap"); + BMO_ITER (v, &oiter, find_op.slots_out, "targetmap.out", 0) { v2 = BMO_iter_map_value_p(&oiter); - BMO_slot_map_ptr_insert(bm, weld_op, "targetmap", v, v2); + BMO_slot_map_ptr_insert(weld_op, slot_targetmap, v, v2); } BMO_op_finish(bm, &find_op); @@ -325,6 +344,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, int *indexMap = NULL; DerivedMesh *start_cap = NULL, *end_cap = NULL; MVert *src_mvert; + BMOpSlot *slot_targetmap = NULL; /* for weldop */ /* need to avoid infinite recursion here */ if (amd->start_cap && amd->start_cap != ob) @@ -412,10 +432,13 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, BMO_push(bm, NULL); bmesh_edit_begin(bm, 0); - if (amd->flags & MOD_ARR_MERGE) + if (amd->flags & MOD_ARR_MERGE) { BMO_op_init(bm, &weld_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), "weld_verts"); + slot_targetmap = BMO_slot_get(weld_op.slots_in, "targetmap"); + } + BMO_op_initf(bm, &dupe_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), "duplicate geom=%avef"); first_dupe_op = dupe_op; @@ -423,18 +446,18 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, for (j = 0; j < count - 1; j++) { BMVert *v, *v2, *v3; BMOpSlot *geom_slot; - BMOpSlot *newout_slot; + BMOpSlot *geom_out_slot; BMOIter oiter; if (j != 0) { BMO_op_initf(bm, &dupe_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), - "duplicate geom=%s", &old_dupe_op, "newout"); + "duplicate geom=%S", &old_dupe_op, "geom.out"); } BMO_op_exec(bm, &dupe_op); - geom_slot = BMO_slot_get(&dupe_op, "geom"); - newout_slot = BMO_slot_get(&dupe_op, "newout"); + geom_slot = BMO_slot_get(dupe_op.slots_in, "geom"); + geom_out_slot = BMO_slot_get(dupe_op.slots_out, "geom.out"); if ((amd->flags & MOD_ARR_MERGEFINAL) && j == 0) { int first_geom_bytes = sizeof(BMVert *) * geom_slot->len; @@ -446,7 +469,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, } /* apply transformation matrix */ - BMO_ITER (v, &oiter, bm, &dupe_op, "newout", BM_VERT) { + BMO_ITER (v, &oiter, dupe_op.slots_out, "geom.out", BM_VERT) { mul_m4_v3(offset, v->co); } @@ -465,17 +488,17 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, for (i = 0; i < index_len; i++) { if (!indexMap[i]) continue; - /* merge v (from 'newout') into v2 (from old 'geom') */ - v = _E(newout_slot, i - geom_slot->len); + /* merge v (from 'geom.out') into v2 (from old 'geom') */ + v = _E(geom_out_slot, i - geom_slot->len); v2 = _E(geom_slot, indexMap[i] - 1); /* check in case the target vertex (v2) is already marked * for merging */ - while ((v3 = BMO_slot_map_ptr_get(bm, &weld_op, "targetmap", v2))) { + while ((v3 = BMO_slot_map_ptr_get(slot_targetmap, v2))) { v2 = v3; } - BMO_slot_map_ptr_insert(bm, &weld_op, "targetmap", v, v2); + BMO_slot_map_ptr_insert(&weld_op, slot_targetmap, v, v2); } #undef _E @@ -511,14 +534,15 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, float startoffset[4][4]; invert_m4_m4(startoffset, offset); bm_merge_dm_transform(bm, start_cap, startoffset, amd, - &first_dupe_op, "geom", &weld_op); + &first_dupe_op, first_dupe_op.slots_in, "geom", &weld_op); } if (end_cap) { float endoffset[4][4]; mult_m4_m4m4(endoffset, offset, final_offset); bm_merge_dm_transform(bm, end_cap, endoffset, amd, - &dupe_op, count == 1 ? "geom" : "newout", &weld_op); + &dupe_op, (count == 1) ? dupe_op.slots_in : dupe_op.slots_out, + (count == 1) ? "geom" : "geom.out", &weld_op); } } /* done capping */ diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 47523286229..13d409dc941 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -426,7 +426,11 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, FluidsimModifierData *fluidmd, int framenr, int useRenderParams) { int displaymode = 0; - int curFrame = framenr - 1 /*scene->r.sfra*/; /* start with 0 at start frame */ + + int curFrame = framenr /* - 1 */ /*scene->r.sfra*/; /* start with 0 at start frame */ + /* why start with 0 as start frame?? Animations + time are frozen for frame 0 anyway. (See physics_fluid.c for that. - DG */ + /* If we start with frame 0, we need to remap all animation channels, too, because they will all be 1 frame late if using frame-1! - DG */ + char targetFile[FILE_MAX]; FluidsimSettings *fss = fluidmd->fss; DerivedMesh *dm = NULL; diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c index 6f6589d4d14..266226040a3 100644 --- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c +++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c @@ -199,7 +199,7 @@ static void init_data(ModifierData *md) smd->lambda = 0.00001f; smd->lambda_border = 0.00005f; smd->repeat = 1; - smd->flag = MOD_LAPLACIANSMOOTH_X | MOD_LAPLACIANSMOOTH_Y | MOD_LAPLACIANSMOOTH_Z | MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION; + smd->flag = MOD_LAPLACIANSMOOTH_X | MOD_LAPLACIANSMOOTH_Y | MOD_LAPLACIANSMOOTH_Z | MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME; smd->defgrp_name[0] = '\0'; } @@ -511,7 +511,7 @@ static void validate_solution(LaplacianSystem *sys, short flag) float leni, lene; float vini, vend; float *vi1, *vi2, ve1[3], ve2[3]; - if (flag & MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION) { + if (flag & MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME) { vini = compute_volume(sys->vertexCos, sys->mfaces, sys->numFaces); } for (i = 0; i < sys->numEdges; i++) { @@ -545,7 +545,7 @@ static void validate_solution(LaplacianSystem *sys, short flag) } } } - if (flag & MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION) { + if (flag & MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME) { vend = compute_volume(sys->vertexCos, sys->mfaces, sys->numFaces); volume_preservation(sys, vini, vend, flag); } diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 96f97a6fa8a..9f702957fa5 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -249,14 +249,14 @@ static int build_hull(SkinOutput *so, Frame **frames, int totframe) } /* Apply face attributes to hull output */ - BMO_ITER (f, &oiter, bm, &op, "geomout", BM_FACE) { + BMO_ITER (f, &oiter, op.slots_out, "geom.out", BM_FACE) { if (so->smd->flag & MOD_SKIN_SMOOTH_SHADING) BM_elem_flag_enable(f, BM_ELEM_SMOOTH); f->mat_nr = so->mat_nr; } /* Mark interior frames */ - BMO_ITER (v, &oiter, bm, &op, "interior_geom", BM_VERT) { + BMO_ITER (v, &oiter, op.slots_out, "geom_interior.out", BM_VERT) { for (i = 0; i < totframe; i++) { Frame *frame = frames[i]; @@ -309,7 +309,7 @@ static int build_hull(SkinOutput *so, Frame **frames, int totframe) /* Check if removing triangles above will create wire triangles, * mark them too */ - BMO_ITER (e, &oiter, bm, &op, "geomout", BM_EDGE) { + BMO_ITER (e, &oiter, op.slots_out, "geom.out", BM_EDGE) { int is_wire = TRUE; BM_ITER_ELEM (f, &iter, e, BM_FACES_OF_EDGE) { if (!BM_elem_flag_test(f, BM_ELEM_TAG)) { @@ -1080,17 +1080,20 @@ static BMFace *collapse_face_corners(BMesh *bm, BMFace *f, int n, BMOperator op; BMIter iter; int i; + BMOpSlot *slot_targetmap; shortest_edge = BM_face_find_shortest_loop(f)->e; BMO_op_initf(bm, &op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), "weld_verts"); + slot_targetmap = BMO_slot_get(op.slots_in, "targetmap"); + /* Note: could probably calculate merges in one go to be * faster */ v_safe = shortest_edge->v1; v_merge = shortest_edge->v2; mid_v3_v3v3(v_safe->co, v_safe->co, v_merge->co); - BMO_slot_map_ptr_insert(bm, &op, "targetmap", v_merge, v_safe); + BMO_slot_map_ptr_insert(&op, slot_targetmap, v_merge, v_safe); BMO_op_exec(bm, &op); BMO_op_finish(bm, &op); @@ -1216,6 +1219,7 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f BMOIter oiter; BMOperator op; int i, best_order[4]; + BMOpSlot *slot_targetmap; BLI_assert(split_face->len >= 3); @@ -1229,7 +1233,7 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f /* Update split face (should only be one new face created * during extrusion) */ split_face = NULL; - BMO_ITER (f, &oiter, bm, &op, "faceout", BM_FACE) { + BMO_ITER (f, &oiter, op.slots_out, "faces.out", BM_FACE) { BLI_assert(!split_face); split_face = f; } @@ -1247,7 +1251,7 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f BM_elem_flag_enable(longest_edge, BM_ELEM_TAG); BMO_op_callf(bm, BMO_FLAG_DEFAULTS, - "subdivide_edges edges=%he numcuts=%i quadcornertype=%i", + "subdivide_edges edges=%he cuts=%i quad_corner_type=%i", BM_ELEM_TAG, 1, SUBD_STRAIGHT_CUT); } else if (split_face->len > 4) { @@ -1281,8 +1285,9 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f BM_face_kill(bm, split_face); BMO_op_init(bm, &op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), "weld_verts"); + slot_targetmap = BMO_slot_get(op.slots_in, "targetmap"); for (i = 0; i < 4; i++) { - BMO_slot_map_ptr_insert(bm, &op, "targetmap", + BMO_slot_map_ptr_insert(&op, slot_targetmap, verts[i], frame->verts[best_order[i]]); } BMO_op_exec(bm, &op); diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c new file mode 100644 index 00000000000..645fd5eb2cf --- /dev/null +++ b/source/blender/modifiers/intern/MOD_triangulate.c @@ -0,0 +1,144 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Antony Riakiotakis + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +/** \file blender/modifiers/intern/MOD_triangulate.c + * \ingroup modifiers + */ + +#include "DNA_object_types.h" + +#include "BLI_utildefines.h" + +#include "BKE_cdderivedmesh.h" +#include "BKE_modifier.h" +#include "BKE_tessmesh.h" + +/* triangulation modifier, directly calls the bmesh operator */ + +static DerivedMesh *triangulate_dm(DerivedMesh *dm, const int flag) +{ + DerivedMesh *result; + BMesh *bm; + int total_edges, i; + MEdge *me; + + bm = DM_to_bmesh(dm); + + BM_mesh_elem_toolflags_ensure(bm); + BMO_push(bm, NULL); + + BMO_op_callf(bm, BMO_FLAG_DEFAULTS, + "triangulate faces=%af use_beauty=%b", + (flag & MOD_TRIANGULATE_BEAUTY)); + BMO_pop(bm); + + result = CDDM_from_bmesh(bm, FALSE); + BM_mesh_free(bm); + + total_edges = result->getNumEdges(result); + me = CDDM_get_edges(result); + + /* force drawing of all edges (seems to be omitted in CDDM_from_bmesh) */ + for (i = 0; i < total_edges; i++, me++) + me->flag |= ME_EDGEDRAW | ME_EDGERENDER; + + CDDM_calc_normals(result); + + return result; +} + + +static void initData(ModifierData *md) +{ + TriangulateModifierData *tmd = (TriangulateModifierData *)md; + + /* Enable in editmode by default */ + md->mode |= eModifierMode_Editmode; + tmd->flag = MOD_TRIANGULATE_BEAUTY; +} + + +static void copyData(ModifierData *md, ModifierData *target) +{ + TriangulateModifierData *smd = (TriangulateModifierData *) md; + TriangulateModifierData *tsmd = (TriangulateModifierData *) target; + + *tsmd = *smd; +} + +static DerivedMesh *applyModifierEM(ModifierData *md, + Object *UNUSED(ob), + struct BMEditMesh *UNUSED(em), + DerivedMesh *dm) +{ + TriangulateModifierData *tmd = (TriangulateModifierData *)md; + DerivedMesh *result; + if (!(result = triangulate_dm(dm, tmd->flag))) { + return dm; + } + + return result; +} + +static DerivedMesh *applyModifier(ModifierData *md, + Object *UNUSED(ob), + DerivedMesh *dm, + ModifierApplyFlag UNUSED(flag)) +{ + TriangulateModifierData *tmd = (TriangulateModifierData *)md; + DerivedMesh *result; + if (!(result = triangulate_dm(dm, tmd->flag))) { + return dm; + } + + return result; +} + +ModifierTypeInfo modifierType_Triangulate = { + /* name */ "Triangulate", + /* structName */ "TriangulateModifierData", + /* structSize */ sizeof(TriangulateModifierData), + /* type */ eModifierTypeType_Constructive, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_EnableInEditmode | + eModifierTypeFlag_AcceptsCVs, + + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ applyModifierEM, + /* initData */ initData, + /* requiredDataMask */ NULL, //requiredDataMask, + /* freeData */ NULL, + /* isDisabled */ NULL, + /* updateDepgraph */ NULL, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, + /* foreachObjectLink */ NULL, + /* foreachIDLink */ NULL, +}; diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index 3b769a30994..a27d5e5e03b 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -278,5 +278,6 @@ void modifier_type_init(ModifierTypeInfo *types[]) INIT_TYPE(Remesh); INIT_TYPE(Skin); INIT_TYPE(LaplacianSmooth); + INIT_TYPE(Triangulate); #undef INIT_TYPE } diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 9e412785467..141a3680df2 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -123,7 +123,6 @@ set(SRC composite/nodes/node_composite_pixelate.c composite/node_composite_tree.c - composite/node_composite_util.c shader/nodes/node_shader_camera.c shader/nodes/node_shader_common.c @@ -223,7 +222,6 @@ set(SRC intern/node_common.c intern/node_socket.c - composite/node_composite_util.h shader/node_shader_util.h texture/node_texture_util.h @@ -236,6 +234,13 @@ set(SRC intern/node_common.h ) +if(WITH_COMPOSITOR_LEGACY) + list(APPEND SRC + composite/node_composite_util.h + composite/node_composite_util.c + ) +endif() + if(WITH_PYTHON) list(APPEND INC ../python diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.c b/source/blender/nodes/shader/nodes/node_shader_normal_map.c index ee83699abdb..6a4eb9d81df 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal_map.c +++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c @@ -31,7 +31,7 @@ static bNodeSocketTemplate sh_node_normal_map_in[] = { { SOCK_FLOAT, 1, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f}, - { SOCK_RGBA, 0, N_("Color"), 0.5f, 0.5f, 1.0f, 1.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 1, N_("Color"), 0.5f, 0.5f, 1.0f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c index fb5b94249e6..2b82826eb04 100644 --- a/source/blender/python/bmesh/bmesh_py_ops.c +++ b/source/blender/python/bmesh/bmesh_py_ops.c @@ -90,6 +90,7 @@ static PyObject *bpy_bmesh_op_repr(BPy_BMeshOpFunc *self) static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw) { + PyObject *ret; BPy_BMesh *py_bm; BMesh *bm; @@ -122,7 +123,7 @@ static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject * Py_ssize_t pos = 0; while (PyDict_Next(kw, &pos, &key, &value)) { const char *slot_name = _PyUnicode_AsString(key); - BMOpSlot *slot = BMO_slot_get(&bmop, slot_name); + BMOpSlot *slot = BMO_slot_get(bmop.slots_in, slot_name); if (slot == NULL) { PyErr_Format(PyExc_TypeError, @@ -146,7 +147,7 @@ static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject * return NULL; } else { - slot->data.i = param; + BMO_SLOT_AS_BOOL(slot) = param; } break; @@ -169,7 +170,7 @@ static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject * return NULL; } else { - slot->data.i = (int)param; + BMO_SLOT_AS_INT(slot) = (int)param; } break; } @@ -183,7 +184,7 @@ static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject * return NULL; } else { - slot->data.f = param; + BMO_SLOT_AS_FLOAT(slot) = param; } break; } @@ -210,13 +211,13 @@ static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject * return NULL; } - BMO_slot_mat_set(&bmop, slot_name, ((MatrixObject *)value)->matrix, size); + BMO_slot_mat_set(&bmop, bmop.slots_in, slot_name, ((MatrixObject *)value)->matrix, size); break; } case BMO_OP_SLOT_VEC: { /* passing slot name here is a bit non-descriptive */ - if (mathutils_array_parse(slot->data.vec, 3, 3, value, slot_name) == -1) { + if (mathutils_array_parse(BMO_SLOT_AS_VECTOR(slot), 3, 3, value, slot_name) == -1) { return NULL; } break; @@ -243,15 +244,15 @@ static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject * if (BPy_BMVertSeq_Check(value)) { BPY_BM_GENERIC_MESH_TEST("verts"); - BMO_slot_buffer_from_all(bm, &bmop, slot_name, BM_VERT); + BMO_slot_buffer_from_all(bm, &bmop, bmop.slots_in, slot_name, BM_VERT); } else if (BPy_BMEdgeSeq_Check(value)) { BPY_BM_GENERIC_MESH_TEST("edges"); - BMO_slot_buffer_from_all(bm, &bmop, slot_name, BM_EDGE); + BMO_slot_buffer_from_all(bm, &bmop, bmop.slots_in, slot_name, BM_EDGE); } else if (BPy_BMFaceSeq_Check(value)) { BPY_BM_GENERIC_MESH_TEST("faces"); - BMO_slot_buffer_from_all(bm, &bmop, slot_name, BM_FACE); + BMO_slot_buffer_from_all(bm, &bmop, bmop.slots_in, slot_name, BM_FACE); } else if (BPy_BMElemSeq_Check(value)) { BMIter iter; @@ -266,11 +267,11 @@ static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject * /* calls bpy_bmelemseq_length() */ tot = Py_TYPE(value)->tp_as_sequence->sq_length((PyObject *)self); - BMO_slot_buffer_alloc(&bmop, slot_name, tot); + BMO_slot_buffer_alloc(&bmop, bmop.slots_in, slot_name, tot); i = 0; BM_ITER_BPY_BM_SEQ (ele, &iter, ((BPy_BMElemSeq *)value)) { - ((void **)slot->data.buf)[i] = (void *)ele; + slot->data.buf[i] = ele; i++; } } @@ -288,7 +289,7 @@ static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject * return NULL; } - BMO_slot_buffer_alloc(&bmop, slot_name, elem_array_len); + BMO_slot_buffer_alloc(&bmop, bmop.slots_in, slot_name, elem_array_len); memcpy(slot->data.buf, elem_array, sizeof(void *) * elem_array_len); PyMem_FREE(elem_array); } @@ -316,13 +317,104 @@ static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject * } BMO_op_exec(bm, &bmop); - BMO_op_finish(bm, &bmop); - if (bpy_bm_op_as_py_error(bm) == -1) { - return NULL; + /* from here until the end of the function, no returns, just set 'ret' */ + if (UNLIKELY(bpy_bm_op_as_py_error(bm) == -1)) { + ret = NULL; /* exception raised above */ } + else if (bmop.slots_out[0].slot_name == NULL) { + ret = (Py_INCREF(Py_None), Py_None); + } + else { + /* build return value */ + int i; + ret = PyDict_New(); - Py_RETURN_NONE; + for (i = 0; bmop.slots_out[i].slot_name; i++) { + // BMOpDefine *op_def = opdefines[bmop.type]; + // BMOSlotType *slot_type = op_def->slot_types_out[i]; + BMOpSlot *slot = &bmop.slots_out[i]; + PyObject *item = NULL; + + /* keep switch in same order as above */ + switch (slot->slot_type) { + case BMO_OP_SLOT_BOOL: + item = PyBool_FromLong((BMO_SLOT_AS_BOOL(slot))); + break; + case BMO_OP_SLOT_INT: + item = PyLong_FromLong(BMO_SLOT_AS_INT(slot)); + break; + case BMO_OP_SLOT_FLT: + item = PyFloat_FromDouble((double)BMO_SLOT_AS_FLOAT(slot)); + break; + case BMO_OP_SLOT_MAT: + item = Matrix_CreatePyObject((float *)BMO_SLOT_AS_MATRIX(slot), 4, 4, Py_NEW, NULL); + break; + case BMO_OP_SLOT_VEC: + item = Vector_CreatePyObject(BMO_SLOT_AS_VECTOR(slot), slot->len, Py_NEW, NULL); + break; + case BMO_OP_SLOT_ELEMENT_BUF: + { + const int size = slot->len; + void **buffer = BMO_SLOT_AS_BUFFER(slot); + int j; + + item = PyList_New(size); + for (j = 0; j < size; j++) { + BMHeader *ele = buffer[i]; + PyList_SET_ITEM(item, j, ele ? BPy_BMElem_CreatePyObject(bm, ele) : (Py_INCREF(Py_None), Py_None)); + } + break; + } + case BMO_OP_SLOT_MAPPING: + { + GHash *slot_hash = BMO_SLOT_AS_GHASH(slot); + GHashIterator *hash_iter; + item = PyDict_New(); + + for (hash_iter = BLI_ghashIterator_new(slot_hash); + !BLI_ghashIterator_isDone(hash_iter); + BLI_ghashIterator_step(hash_iter) ) + { + BMHeader *ele_key = BLI_ghashIterator_getKey(hash_iter); + BMHeader **ele_val = BLI_ghashIterator_getValue(hash_iter); + + PyObject *py_key = ele_key ? BPy_BMElem_CreatePyObject(bm, ele_key) : (Py_INCREF(Py_None), Py_None); + PyObject *py_val = *ele_val ? BPy_BMElem_CreatePyObject(bm, *ele_val) : (Py_INCREF(Py_None), Py_None); + + PyDict_SetItem(ret, py_key, py_val); + Py_DECREF(py_key); + Py_DECREF(py_val); + } + BLI_ghashIterator_free(hash_iter); + break; + } + } + BLI_assert(item != NULL); + if (item == NULL) { + item = (Py_INCREF(Py_None), Py_None); + } + +#if 1 + /* temp code, strip off '.out' while we keep this convention */ + { + char slot_name_strip[MAX_SLOTNAME]; + char *ch = strchr(slot->slot_name, '.'); /* can't fail! */ + int tot = ch - slot->slot_name; + BLI_assert(ch != NULL); + memcpy(slot_name_strip, slot->slot_name, tot); + slot_name_strip[tot] = '\0'; + PyDict_SetItemString(ret, slot_name_strip, item); + } +#else + PyDict_SetItemString(ret, slot->slot_name, item); +#endif + Py_DECREF(item); + } + } + + BMO_op_finish(bm, &bmop); + return ret; } @@ -413,17 +505,17 @@ static PyObject *bpy_bmesh_fmod_getattro(PyObject *UNUSED(self), PyObject *pynam { const unsigned int tot = bmesh_total_ops; unsigned int i; - const char *name = _PyUnicode_AsString(pyname); + const char *opname = _PyUnicode_AsString(pyname); for (i = 0; i < tot; i++) { - if (strcmp(opdefines[i]->name, name) == 0) { - return bpy_bmesh_op_CreatePyObject(opdefines[i]->name); + if (strcmp(opdefines[i]->opname, opname) == 0) { + return bpy_bmesh_op_CreatePyObject(opdefines[i]->opname); } } PyErr_Format(PyExc_AttributeError, "BMeshOpsModule: operator \"%.200s\" doesn't exist", - name); + opname); return NULL; } @@ -436,7 +528,7 @@ static PyObject *bpy_bmesh_fmod_dir(PyObject *UNUSED(self)) ret = PyList_New(bmesh_total_ops); for (i = 0; i < tot; i++) { - PyList_SET_ITEM(ret, i, PyUnicode_FromString(opdefines[i]->name)); + PyList_SET_ITEM(ret, i, PyUnicode_FromString(opdefines[i]->opname)); } return ret; diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index 2cae10101d1..ee4528df50d 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -801,34 +801,92 @@ static PyObject *bpy_bmesh_to_mesh(BPy_BMesh *self, PyObject *args) Py_RETURN_NONE; } -/* note: rna_Object_to_mesh() also has apply_modifiers arg that works the same way */ PyDoc_STRVAR(bpy_bmesh_from_object_doc, -".. method:: from_object(mesh, apply_modifiers=True)\n" +".. method:: from_object(object, scene, deform=True, render=False, cage=False)\n" "\n" -" Initialize this bmesh from existing object datablock.\n" +" Initialize this bmesh from existing object datablock (currently only meshes are supported).\n" "\n" " :arg object: The object data to load.\n" " :type object: :class:`Object`\n" -" :arg apply_modifiers: Use the final display mesh rather then the deformed cage.\n" -" :type apply_modifiers: boolean\n" +" :arg deform: Apply deformation modifiers.\n" +" :type deform: boolean\n" +" :arg render: Use render settings.\n" +" :type render: boolean\n" +" :arg cage: Get the mesh as a deformed cage.\n" +" :type cage: boolean\n" ); static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args) { PyObject *py_object; + PyObject *py_scene; Object *ob; + struct Scene *scene; BMesh *bm; - int apply_modifiers = TRUE; + int use_deform = TRUE; + int use_render = FALSE; + int use_cage = FALSE; DerivedMesh *dm; + const int mask = CD_MASK_BMESH; BPY_BM_CHECK_OBJ(self); - if (!PyArg_ParseTuple(args, "O|i:from_object", &py_object, &apply_modifiers) || - !(ob = PyC_RNA_AsPointer(py_object, "Object"))) + if (!PyArg_ParseTuple(args, "OO|iii:from_object", &py_object, &py_scene, &use_render, &use_cage) || + !(ob = PyC_RNA_AsPointer(py_object, "Object")) || + !(scene = PyC_RNA_AsPointer(py_scene, "Scene"))) { return NULL; } - dm = apply_modifiers ? ob->derivedFinal : ob->derivedDeform; + if (ob->type != OB_MESH) { + PyErr_SetString(PyExc_ValueError, + "from_object(...): currently only mesh objects are supported"); + return NULL; + } + + /* Write the display mesh into the dummy mesh */ + if (use_deform) { + if (use_render) { + if (use_cage) { + PyErr_SetString(PyExc_ValueError, + "from_object(...): cage arg is unsupported when (render=True)"); + return NULL; + } + else { + dm = mesh_create_derived_render(scene, ob, mask); + } + } + else { + if (use_cage) { + dm = mesh_get_derived_deform(scene, ob, mask); /* ob->derivedDeform */ + } + else { + dm = mesh_get_derived_final(scene, ob, mask); /* ob->derivedFinal */ + } + } + } + else { + /* !use_deform */ + if (use_render) { + if (use_cage) { + PyErr_SetString(PyExc_ValueError, + "from_object(...): cage arg is unsupported when (render=True)"); + return NULL; + } + else { + dm = mesh_create_derived_no_deform_render(scene, ob, NULL, mask); + } + } + else { + if (use_cage) { + PyErr_SetString(PyExc_ValueError, + "from_object(...): cage arg is unsupported when (deform=False, render=False)"); + return NULL; + } + else { + dm = mesh_create_derived_no_deform(scene, ob, NULL, mask); + } + } + } if (dm == NULL) { PyErr_Format(PyExc_ValueError, @@ -840,6 +898,8 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args) DM_to_bmesh_ex(dm, bm); + dm->release(dm); + Py_RETURN_NONE; } @@ -1790,7 +1850,7 @@ static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args) } /* check if the face exists */ - if (BM_face_exists(bm, vert_array, vert_seq_len, NULL)) { + if (BM_face_exists(vert_array, vert_seq_len, NULL)) { PyErr_SetString(PyExc_ValueError, "faces.new(verts): face already exists"); goto cleanup; @@ -2012,7 +2072,7 @@ static PyObject *bpy_bmfaceseq_get__method(BPy_BMElemSeq *self, PyObject *args) return NULL; } - if (BM_face_exists(bm, vert_array, vert_seq_len, &f)) { + if (BM_face_exists(vert_array, vert_seq_len, &f)) { ret = BPy_BMFace_CreatePyObject(bm, f); } else { @@ -3306,6 +3366,7 @@ PyObject *BPy_BMElem_CreatePyObject(BMesh *bm, BMHeader *ele) case BM_LOOP: return BPy_BMLoop_CreatePyObject(bm, (BMLoop *)ele); default: + BLI_assert(0); PyErr_SetString(PyExc_SystemError, "internal error"); return NULL; } diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c index 1fea12d105c..14132d08fe6 100644 --- a/source/blender/python/bmesh/bmesh_py_types_customdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c @@ -981,7 +981,7 @@ PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer) } case CD_PROP_INT: { - ret = PyLong_FromSsize_t((Py_ssize_t)(*(int *)value)); + ret = PyLong_FromLong(*(int *)value); break; } case CD_PROP_STR: @@ -1060,7 +1060,7 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj } case CD_PROP_INT: { - int tmp_val = PyLong_AsSsize_t(py_value); + int tmp_val = PyLong_AsLong(py_value); if (UNLIKELY(tmp_val == -1 && PyErr_Occurred())) { PyErr_Format(PyExc_TypeError, "expected an int, not a %.200s", Py_TYPE(py_value)->tp_name); ret = -1; diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c index 8316d33ea38..b0870578f5a 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c @@ -527,7 +527,7 @@ static PyObject *bpy_bmdeformvert_keys(BPy_BMDeformVert *self) ret = PyList_New(self->data->totweight); for (i = 0; i < self->data->totweight; i++, dw++) { - PyList_SET_ITEM(ret, i, PyLong_FromSsize_t(dw->def_nr)); + PyList_SET_ITEM(ret, i, PyLong_FromLong(dw->def_nr)); } return ret; @@ -576,7 +576,7 @@ static PyObject *bpy_bmdeformvert_items(BPy_BMDeformVert *self) for (i = 0; i < self->data->totweight; i++, dw++) { item = PyTuple_New(2); - PyTuple_SET_ITEM(item, 0, PyLong_FromSsize_t(dw->def_nr)); + PyTuple_SET_ITEM(item, 0, PyLong_FromLong(dw->def_nr)); PyTuple_SET_ITEM(item, 1, PyFloat_FromDouble(dw->weight)); PyList_SET_ITEM(ret, i, item); diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index a10bfef2a8d..22b9c1a2208 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -613,15 +613,15 @@ static PyObject *Buffer_repr(Buffer *self) } -BGL_Wrap(2, Accum, void, (GLenum, GLfloat)) -BGL_Wrap(1, ActiveTexture, void, (GLenum)) -BGL_Wrap(2, AlphaFunc, void, (GLenum, GLclampf)) +BGL_Wrap(2, Accum, void, (GLenum, GLfloat)) +BGL_Wrap(1, ActiveTexture, void, (GLenum)) +BGL_Wrap(2, AlphaFunc, void, (GLenum, GLclampf)) BGL_Wrap(3, AreTexturesResident, GLboolean, (GLsizei, GLuintP, GLbooleanP)) BGL_Wrap(2, AttachShader, void, (GLuint, GLuint)) -BGL_Wrap(1, Begin, void, (GLenum)) -BGL_Wrap(2, BindTexture, void, (GLenum, GLuint)) -BGL_Wrap(7, Bitmap, void, (GLsizei, GLsizei, GLfloat, - GLfloat, GLfloat, GLfloat, GLubyteP)) +BGL_Wrap(1, Begin, void, (GLenum)) +BGL_Wrap(2, BindTexture, void, (GLenum, GLuint)) +BGL_Wrap(7, Bitmap, void, (GLsizei, GLsizei, GLfloat, + GLfloat, GLfloat, GLfloat, GLubyteP)) BGL_Wrap(2, BlendFunc, void, (GLenum, GLenum)) BGL_Wrap(1, CallList, void, (GLuint)) BGL_Wrap(3, CallLists, void, (GLsizei, GLenum, GLvoidP)) @@ -675,7 +675,7 @@ BGL_Wrap(1, CullFace, void, (GLenum)) BGL_Wrap(2, DeleteLists, void, (GLuint, GLsizei)) BGL_Wrap(1, DeleteProgram, void, (GLuint)) BGL_Wrap(1, DeleteShader, void, (GLuint)) -BGL_Wrap(2, DeleteTextures, void, (GLsizei, GLuintP)) +BGL_Wrap(2, DeleteTextures, void, (GLsizei, GLuintP)) BGL_Wrap(1, DepthFunc, void, (GLenum)) BGL_Wrap(1, DepthMask, void, (GLboolean)) BGL_Wrap(2, DepthRange, void, (GLclampd, GLclampd)) @@ -773,7 +773,7 @@ BGL_Wrap(3, Lighti, void, (GLenum, GLenum, GLint)) BGL_Wrap(3, Lightiv, void, (GLenum, GLenum, GLintP)) BGL_Wrap(2, LineStipple, void, (GLint, GLushort)) BGL_Wrap(1, LineWidth, void, (GLfloat)) -BGL_Wrap(1, LinkProgram, void, (GLuint)) +BGL_Wrap(1, LinkProgram, void, (GLuint)) BGL_Wrap(1, ListBase, void, (GLuint)) BGL_Wrap(1, LoadIdentity, void, (void)) BGL_Wrap(1, LoadMatrixd, void, (GLdoubleP)) @@ -1907,9 +1907,9 @@ PyObject *BPyInit_bgl(void) return submodule; } -static PyObject *Method_ShaderSource (PyObject *UNUSED(self), PyObject *args) +static PyObject *Method_ShaderSource(PyObject *UNUSED(self), PyObject *args) { - int shader; + unsigned int shader; char *source; if (!PyArg_ParseTuple(args, "Is", &shader, &source)) diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index 529b2e708ad..53112d46098 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -249,7 +249,7 @@ static int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void *UNUS #if 0 static PyObject *BPy_IDGroup_GetType(BPy_IDProperty *self) { - return PyLong_FromSsize_t(self->prop->type); + return PyLong_FromLong(self->prop->type); } #endif @@ -351,7 +351,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty prop = IDP_New(IDP_DOUBLE, &val, name); } else if (PyLong_Check(ob)) { - val.i = (int) PyLong_AsSsize_t(ob); + val.i = (int)PyLong_AsLong(ob); prop = IDP_New(IDP_INT, &val, name); } else if (PyUnicode_Check(ob)) { @@ -409,7 +409,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty prop = IDP_New(IDP_ARRAY, &val, name); for (i = 0; i < val.array.len; i++) { item = PySequence_Fast_GET_ITEM(ob_seq_fast, i); - ((int *)IDP_Array(prop))[i] = (int)PyLong_AsSsize_t(item); + ((int *)IDP_Array(prop))[i] = (int)PyLong_AsLong(item); } break; case IDP_IDPARRAY: @@ -1072,7 +1072,7 @@ static int BPy_IDArray_SetItem(BPy_IDArray *self, int index, PyObject *value) ((double *)IDP_Array(self->prop))[index] = d; break; case IDP_INT: - i = PyLong_AsSsize_t(value); + i = PyLong_AsLong(value); if (i == -1 && PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "expected an int type"); return -1; diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index b8537a1359f..f62fdaf09db 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -83,13 +83,13 @@ int PyC_AsArray(void *array, PyObject *value, const Py_ssize_t length, /* could use is_double for 'long int' but no use now */ int *array_int = array; for (i = 0; i < length; i++) { - array_int[i] = PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value_fast, i)); + array_int[i] = PyLong_AsLong(PySequence_Fast_GET_ITEM(value_fast, i)); } } else if (type == &PyBool_Type) { int *array_bool = array; for (i = 0; i < length; i++) { - array_bool[i] = (PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value_fast, i)) != 0); + array_bool[i] = (PyLong_AsLong(PySequence_Fast_GET_ITEM(value_fast, i)) != 0); } } else { @@ -567,7 +567,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...) ret = PyObject_CallFunction(calcsize, (char *)"s", format); if (ret) { - sizes[i] = PyLong_AsSsize_t(ret); + sizes[i] = PyLong_AsLong(ret); Py_DECREF(ret); ret = PyObject_CallFunction(unpack, (char *)"sy#", format, (char *)ptr, sizes[i]); } diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index a8aa7269b72..b1eeff8b3ae 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -195,12 +195,12 @@ PyDoc_STRVAR(bpy_app_debug_value_doc, ); static PyObject *bpy_app_debug_value_get(PyObject *UNUSED(self), void *UNUSED(closure)) { - return PyLong_FromSsize_t(G.debug_value); + return PyLong_FromLong(G.debug_value); } static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void *UNUSED(closure)) { - int param = PyLong_AsSsize_t(value); + int param = PyLong_AsLong(value); if (param == -1 && PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "bpy.app.debug_value can only be set to a whole number"); diff --git a/source/blender/python/intern/bpy_intern_string.c b/source/blender/python/intern/bpy_intern_string.c index 7c8291d62d3..70ea57bb33f 100644 --- a/source/blender/python/intern/bpy_intern_string.c +++ b/source/blender/python/intern/bpy_intern_string.c @@ -38,6 +38,8 @@ PyObject *bpy_intern_str_bl_rna; PyObject *bpy_intern_str_order; PyObject *bpy_intern_str_attr; PyObject *bpy_intern_str___slots__; +PyObject *bpy_intern_str___name__; +PyObject *bpy_intern_str___doc__; void bpy_intern_string_init(void) { @@ -47,6 +49,8 @@ void bpy_intern_string_init(void) bpy_intern_str_order = PyUnicode_FromString("order"); bpy_intern_str_attr = PyUnicode_FromString("attr"); bpy_intern_str___slots__ = PyUnicode_FromString("__slots__"); + bpy_intern_str___name__ = PyUnicode_FromString("__name__"); + bpy_intern_str___doc__ = PyUnicode_FromString("__doc__"); } void bpy_intern_string_exit(void) @@ -57,4 +61,6 @@ void bpy_intern_string_exit(void) Py_DECREF(bpy_intern_str_order); Py_DECREF(bpy_intern_str_attr); Py_DECREF(bpy_intern_str___slots__); + Py_DECREF(bpy_intern_str___name__); + Py_DECREF(bpy_intern_str___doc__); } diff --git a/source/blender/python/intern/bpy_intern_string.h b/source/blender/python/intern/bpy_intern_string.h index dc7af735743..0b7ca2cd47b 100644 --- a/source/blender/python/intern/bpy_intern_string.h +++ b/source/blender/python/intern/bpy_intern_string.h @@ -33,3 +33,5 @@ extern PyObject *bpy_intern_str_bl_rna; extern PyObject *bpy_intern_str_order; extern PyObject *bpy_intern_str_attr; extern PyObject *bpy_intern_str___slots__; +extern PyObject *bpy_intern_str___name__; +extern PyObject *bpy_intern_str___doc__; diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index eaaced416fe..a0df8988068 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1344,7 +1344,7 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) ret = PyBool_FromLong(RNA_property_boolean_get(ptr, prop)); break; case PROP_INT: - ret = PyLong_FromSsize_t((Py_ssize_t)RNA_property_int_get(ptr, prop)); + ret = PyLong_FromLong(RNA_property_int_get(ptr, prop)); break; case PROP_FLOAT: ret = PyFloat_FromDouble(RNA_property_float_get(ptr, prop)); @@ -2371,7 +2371,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po RNA_property_int_get_array(ptr, prop, values); for (count = start; count < stop; count++) - PyTuple_SET_ITEM(tuple, count - start, PyLong_FromSsize_t(values[count])); + PyTuple_SET_ITEM(tuple, count - start, PyLong_FromLong(values[count])); if (values != values_stack) { PyMem_FREE(values); @@ -4077,7 +4077,7 @@ static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self) } else { /* a bit strange but better then returning an empty list */ - PyTuple_SET_ITEM(item, 0, PyLong_FromSsize_t(i)); + PyTuple_SET_ITEM(item, 0, PyLong_FromLong(i)); } PyTuple_SET_ITEM(item, 1, pyrna_struct_CreatePyObject(&itemptr)); @@ -4256,7 +4256,7 @@ static PyObject *pyrna_prop_collection_find(BPy_PropertyRNA *self, PyObject *key } RNA_PROP_END; - return PyLong_FromSsize_t(index); + return PyLong_FromLong(index); } static void foreach_attr_type(BPy_PropertyRNA *self, const char *attr, @@ -4463,13 +4463,13 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) switch (raw_type) { case PROP_RAW_CHAR: - item = PyLong_FromSsize_t((Py_ssize_t) ((char *)array)[i]); + item = PyLong_FromLong((long) ((char *)array)[i]); break; case PROP_RAW_SHORT: - item = PyLong_FromSsize_t((Py_ssize_t) ((short *)array)[i]); + item = PyLong_FromLong((long) ((short *)array)[i]); break; case PROP_RAW_INT: - item = PyLong_FromSsize_t((Py_ssize_t) ((int *)array)[i]); + item = PyLong_FromLong((long) ((int *)array)[i]); break; case PROP_RAW_FLOAT: item = PyFloat_FromDouble((double) ((float *)array)[i]); @@ -4756,7 +4756,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat case PROP_INT: ret = PyTuple_New(len); for (a = 0; a < len; a++) - PyTuple_SET_ITEM(ret, a, PyLong_FromSsize_t((Py_ssize_t)((int *)data)[a])); + PyTuple_SET_ITEM(ret, a, PyLong_FromLong(((int *)data)[a])); break; case PROP_FLOAT: switch (RNA_property_subtype(prop)) { @@ -4797,7 +4797,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat ret = PyBool_FromLong(*(int *)data); break; case PROP_INT: - ret = PyLong_FromSsize_t((Py_ssize_t)*(int *)data); + ret = PyLong_FromLong(*(int *)data); break; case PROP_FLOAT: ret = PyFloat_FromDouble(*(float *)data); @@ -6883,8 +6883,8 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v /* Sneaky workaround to use the class name as the bl_idname */ #define BPY_REPLACEMENT_STRING(rna_attr, py_attr) \ - if (strcmp(identifier, rna_attr) == 0) { \ - item = PyObject_GetAttrString(py_class, py_attr); \ + (strcmp(identifier, rna_attr) == 0) { \ + item = PyObject_GetAttr(py_class, py_attr); \ if (item && item != Py_None) { \ if (pyrna_py_to_prop(dummyptr, prop, NULL, \ item, "validating class:") != 0) \ @@ -6894,11 +6894,10 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v } \ } \ Py_XDECREF(item); \ - } (void)0 - + } /* intendionally allow else here */ - BPY_REPLACEMENT_STRING("bl_idname", "__name__"); - BPY_REPLACEMENT_STRING("bl_description", "__doc__"); + if BPY_REPLACEMENT_STRING("bl_idname", bpy_intern_str___name__) + else if BPY_REPLACEMENT_STRING("bl_description", bpy_intern_str___doc__) #undef BPY_REPLACEMENT_STRING @@ -6912,10 +6911,11 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v PyErr_Clear(); } else { - Py_DECREF(item); /* no need to keep a ref, the class owns it */ - - if (pyrna_py_to_prop(dummyptr, prop, NULL, item, "validating class:") != 0) + if (pyrna_py_to_prop(dummyptr, prop, NULL, item, "validating class:") != 0) { + Py_DECREF(item); return -1; + } + Py_DECREF(item); } } diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c index e66d8f05309..62c0ced9eab 100644 --- a/source/blender/python/intern/bpy_rna_array.c +++ b/source/blender/python/intern/bpy_rna_array.c @@ -507,7 +507,7 @@ static void py_to_float(PyObject *py, char *data) static void py_to_int(PyObject *py, char *data) { - *(int *)data = (int)PyLong_AsSsize_t(py); + *(int *)data = (int)PyLong_AsLong(py); } static void py_to_bool(PyObject *py, char *data) @@ -609,7 +609,7 @@ PyObject *pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index) item = PyBool_FromLong(RNA_property_boolean_get_index(ptr, prop, index)); break; case PROP_INT: - item = PyLong_FromSsize_t(RNA_property_int_get_index(ptr, prop, index)); + item = PyLong_FromLong(RNA_property_int_get_index(ptr, prop, index)); break; default: PyErr_SetString(PyExc_TypeError, "not an array type"); @@ -766,7 +766,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) case PROP_BOOLEAN: case PROP_INT: { - int value_i = PyLong_AsSsize_t(value); + int value_i = PyLong_AsLong(value); if (value_i == -1 && PyErr_Occurred()) { PyErr_Clear(); return 0; diff --git a/source/blender/render/intern/include/initrender.h b/source/blender/render/intern/include/initrender.h index 43ab9552194..73dc29c8feb 100644 --- a/source/blender/render/intern/include/initrender.h +++ b/source/blender/render/intern/include/initrender.h @@ -40,8 +40,9 @@ struct Object; void free_sample_tables(Render *re); void make_sample_tables(Render *re); -void initparts(Render *re, int do_crop); -void freeparts(Render *re); +void RE_parts_clamp(Render *re); +void RE_parts_init(Render *re, int do_crop); +void RE_parts_free(Render *re); #endif /* __INITRENDER_H__ */ diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 47bff762d13..6993e1baab4 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -126,7 +126,9 @@ #define FLT_EPSILON10 1.19209290e-06F /* could enable at some point but for now there are far too many conversions */ -#pragma GCC diagnostic ignored "-Wdouble-promotion" +#ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wdouble-promotion" +#endif /* ------------------------------------------------------------------------- */ diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index 9053bc84bbc..6fdf11ba48c 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -376,7 +376,7 @@ int RE_engine_render(Render *re, int do_all) if ((re->r.scemode & (R_NO_FRAME_UPDATE | R_PREVIEWBUTS)) == 0) BKE_scene_update_for_newframe(re->main, re->scene, re->lay); - initparts(re, FALSE); + RE_parts_init(re, FALSE); engine->tile_x = re->partx; engine->tile_y = re->party; @@ -393,6 +393,8 @@ int RE_engine_render(Render *re, int do_all) engine->tile_y = 0; engine->flag &= ~RE_ENGINE_RENDERING; + render_result_free_list(&engine->fullresult, engine->fullresult.first); + /* re->engine becomes zero if user changed active render engine during render */ if (!persistent_data || !re->engine) { RE_engine_free(engine); @@ -405,9 +407,7 @@ int RE_engine_render(Render *re, int do_all) BLI_rw_mutex_unlock(&re->resultmutex); } - freeparts(re); - - render_result_free_list(&engine->fullresult, engine->fullresult.first); + RE_parts_free(re); if (BKE_reports_contain(re->reports, RPT_ERROR)) G.is_break = TRUE; diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index b2cf8db7995..3ea74abbcc2 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -525,7 +525,7 @@ void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, flo /* ~~~~~~~~~~~~~~~~ part (tile) calculus ~~~~~~~~~~~~~~~~~~~~~~ */ -void freeparts(Render *re) +void RE_parts_free(Render *re) { RenderPart *part = re->parts.first; @@ -537,12 +537,19 @@ void freeparts(Render *re) BLI_freelistN(&re->parts); } -void initparts(Render *re, int do_crop) +void RE_parts_clamp(Render *re) +{ + /* part size */ + re->partx = min_ii(re->r.tilex, re->rectx); + re->party = min_ii(re->r.tiley, re->recty); +} + +void RE_parts_init(Render *re, int do_crop) { int nr, xd, yd, partx, party, xparts, yparts; int xminb, xmaxb, yminb, ymaxb; - freeparts(re); + RE_parts_free(re); /* this is render info for caller, is not reset when parts are freed! */ re->i.totpart = 0; @@ -555,13 +562,10 @@ void initparts(Render *re, int do_crop) xmaxb = re->disprect.xmax; ymaxb = re->disprect.ymax; - /* part size */ - partx = min_ii(re->r.tilex, re->rectx); - party = min_ii(re->r.tiley, re->recty); - - re->partx = partx; - re->party = party; - + RE_parts_clamp(re); + + partx = re->partx; + party = re->party; /* part count */ xparts = (re->rectx + partx - 1) / partx; yparts = (re->recty + party - 1) / party; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 75d45144ccd..24b0830e651 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -696,7 +696,7 @@ static void *do_part_thread(void *pa_v) /* calculus for how much 1 pixel rendered should rotate the 3d geometry */ /* is not that simple, needs to be corrected for errors of larger viewplane sizes */ -/* called in initrender.c, initparts() and convertblender.c, for speedvectors */ +/* called in initrender.c, RE_parts_init() and convertblender.c, for speedvectors */ float panorama_pixel_rot(Render *re) { float psize, phi, xfac; @@ -839,7 +839,7 @@ static void threaded_tile_processor(Render *re) /* warning; no return here without closing exr file */ - initparts(re, TRUE); + RE_parts_init(re, TRUE); if (re->result->do_exr_tile) render_result_exr_file_begin(re); @@ -931,7 +931,7 @@ static void threaded_tile_processor(Render *re) g_break = 0; BLI_end_threads(&threads); - freeparts(re); + RE_parts_free(re); re->viewplane = viewplane; /* restore viewplane, modified by pano render */ } @@ -952,6 +952,7 @@ static void do_render_3d(Render *re) return; /* internal */ + RE_parts_clamp(re); // re->cfra= cfra; /* <- unused! */ re->scene->r.subframe = re->mblur_offs + re->field_offs; diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 7a7602dcce2..44daaf516e1 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -1179,30 +1179,36 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater /* -------------------------- operations on entire database ----------------------- */ /* ugly function for halos in panorama */ -static int panotestclip(Render *re, int do_pano, float *v) +static int panotestclip(Render *re, int do_pano, float v[4]) { - /* to be used for halos en infos */ - float abs4; - short c=0; - int xparts = (re->rectx + re->partx - 1) / re->partx; + /* part size (ensure we run RE_parts_clamp first) */ + BLI_assert(re->partx == min_ii(re->r.tilex, re->rectx)); + BLI_assert(re->party == min_ii(re->r.tiley, re->recty)); if (do_pano == FALSE) { return testclip(v); } + else { + /* to be used for halos en infos */ + float abs4; + short c = 0; + + int xparts = (re->rectx + re->partx - 1) / re->partx; - abs4= fabs(v[3]); + abs4= fabsf(v[3]); - if (v[2]< -abs4) c=16; /* this used to be " if (v[2]<0) ", see clippz() */ - else if (v[2]> abs4) c+= 32; + if (v[2]< -abs4) c=16; /* this used to be " if (v[2]<0) ", see clippz() */ + else if (v[2]> abs4) c+= 32; - if ( v[1]>abs4) c+=4; - else if ( v[1]< -abs4) c+=8; + if ( v[1]>abs4) c+=4; + else if ( v[1]< -abs4) c+=8; - abs4*= xparts; - if ( v[0]>abs4) c+=2; - else if ( v[0]< -abs4) c+=1; + abs4*= xparts; + if ( v[0]>abs4) c+=2; + else if ( v[0]< -abs4) c+=1; - return c; + return c; + } } /** diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index dfa1bec5f8c..a425d9a330b 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -58,7 +58,9 @@ #include "shading.h" /* own include */ /* could enable at some point but for now there are far too many conversions */ -#pragma GCC diagnostic ignored "-Wdouble-promotion" +#ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wdouble-promotion" +#endif /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* defined in pipeline.c, is hardcopy of active dynamic allocated Render */ diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 62bf9ac2005..c52fb84a7f8 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -77,7 +77,9 @@ #include "zbuf.h" /* could enable at some point but for now there are far too many conversions */ -#pragma GCC diagnostic ignored "-Wdouble-promotion" +#ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wdouble-promotion" +#endif /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* defined in pipeline.c, is hardcopy of active dynamic allocated Render */ diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 4dbb3a85425..1d8949292ce 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -327,6 +327,7 @@ typedef struct wmNotifier { /* Mesh, Curve, MetaBall, Armature, .. */ #define ND_SELECT (90<<16) #define ND_DATA (91<<16) +#define ND_VERTEX_GROUP (92<<16) /* NC_NODE Nodes */ diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index bd6e752076d..a92ed65392c 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -753,6 +753,15 @@ void wm_draw_update(bContext *C) GPU_free_unused_buffers(); for (win = wm->windows.first; win; win = win->next) { + int state = GHOST_GetWindowState(win->ghostwin);; + + if (state == GHOST_kWindowStateMinimized) { + /* do not update minimized windows, it gives issues on intel drivers (see [#33223]) + * anyway, it seems logical to skip update for invisile windows + */ + continue; + } + if (win->drawmethod != U.wmdrawmethod) { wm_draw_window_clear(win); win->drawmethod = U.wmdrawmethod; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 5cbad42134c..b3c9cfbc79e 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1310,7 +1310,8 @@ static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi) if (kmi->oskey != KM_ANY) if (winevent->oskey != kmi->oskey && !(winevent->oskey & kmi->oskey)) return 0; - if (winevent->keymodifier != kmi->keymodifier) return 0; + if (kmi->keymodifier) + if (winevent->keymodifier != kmi->keymodifier) return 0; return 1; diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index f5c83d48cb9..7481c01d72b 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -405,9 +405,11 @@ void WM_jobs_kill_all(wmWindowManager *wm) /* wait until every job ended, except for one owner (used in undo to keep screen job alive) */ void WM_jobs_kill_all_except(wmWindowManager *wm, void *owner) { - wmJob *wm_job; + wmJob *wm_job, *next_job; - for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) { + for (wm_job = wm->jobs.first; wm_job; wm_job = next_job) { + next_job = wm_job->next; + if (wm_job->owner != owner) wm_jobs_kill_job(wm, wm_job); } diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 024b6017699..4fe1e3b64ab 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -101,11 +101,8 @@ static int wm_keymap_item_equals_result(wmKeyMapItem *a, wmKeyMapItem *b) if (strcmp(a->idname, b->idname) != 0) return 0; - if (!((a->ptr == NULL && b->ptr == NULL) || - (a->ptr && b->ptr && IDP_EqualsProperties(a->ptr->data, b->ptr->data)))) - { + if (!RNA_struct_equals(a->ptr, b->ptr)) return 0; - } if ((a->flag & KMI_INACTIVE) != (b->flag & KMI_INACTIVE)) return 0; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 896a24f3fba..84cfe791bce 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1450,7 +1450,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiItemL(col, "Links", ICON_NONE); uiItemStringO(col, IFACE_("Donations"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment"); uiItemStringO(col, IFACE_("Credits"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/credits"); - uiItemStringO(col, IFACE_("Release Log"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-264"); + uiItemStringO(col, IFACE_("Release Log"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-265"); uiItemStringO(col, IFACE_("Manual"), ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:2.6/Manual"); uiItemStringO(col, IFACE_("Blender Website"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org"); uiItemStringO(col, IFACE_("User Community"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community"); diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index f4c2c13dcac..d29d08a5431 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -189,21 +189,6 @@ static void playanim_event_qual_update(void) GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyRightAlt, &val); if (val) g_WS.qual |= WS_QUAL_RALT; else g_WS.qual &= ~WS_QUAL_RALT; - - /* LMB */ - GHOST_GetButtonState(g_WS.ghost_system, GHOST_kButtonMaskLeft, &val); - if (val) g_WS.qual |= WS_QUAL_LMOUSE; - else g_WS.qual &= ~WS_QUAL_LMOUSE; - - /* MMB */ - GHOST_GetButtonState(g_WS.ghost_system, GHOST_kButtonMaskMiddle, &val); - if (val) g_WS.qual |= WS_QUAL_MMOUSE; - else g_WS.qual &= ~WS_QUAL_MMOUSE; - - /* RMB */ - GHOST_GetButtonState(g_WS.ghost_system, GHOST_kButtonMaskRight, &val); - if (val) g_WS.qual |= WS_QUAL_RMOUSE; - else g_WS.qual &= ~WS_QUAL_RMOUSE; } typedef struct PlayAnimPict { @@ -455,33 +440,42 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) case GHOST_kKeyP: if (val) ps->pingpong = !ps->pingpong; break; + case GHOST_kKey1: case GHOST_kKeyNumpad1: if (val) swaptime = ps->fstep / 60.0; break; + case GHOST_kKey2: case GHOST_kKeyNumpad2: if (val) swaptime = ps->fstep / 50.0; break; + case GHOST_kKey3: case GHOST_kKeyNumpad3: if (val) swaptime = ps->fstep / 30.0; break; + case GHOST_kKey4: case GHOST_kKeyNumpad4: if (g_WS.qual & WS_QUAL_SHIFT) swaptime = ps->fstep / 24.0; else swaptime = ps->fstep / 25.0; break; + case GHOST_kKey5: case GHOST_kKeyNumpad5: if (val) swaptime = ps->fstep / 20.0; break; + case GHOST_kKey6: case GHOST_kKeyNumpad6: if (val) swaptime = ps->fstep / 15.0; break; + case GHOST_kKey7: case GHOST_kKeyNumpad7: if (val) swaptime = ps->fstep / 12.0; break; + case GHOST_kKey8: case GHOST_kKeyNumpad8: if (val) swaptime = ps->fstep / 10.0; break; + case GHOST_kKey9: case GHOST_kKeyNumpad9: if (val) swaptime = ps->fstep / 6.0; break; @@ -548,6 +542,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) } } break; + case GHOST_kKey0: case GHOST_kKeyNumpad0: if (val) { if (ps->once) { @@ -566,6 +561,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) ps->wait2 = ps->sstep = FALSE; } break; + case GHOST_kKeyPeriod: case GHOST_kKeyNumpadPeriod: if (val) { if (ps->sstep) ps->wait2 = FALSE; @@ -607,6 +603,44 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) } break; } + case GHOST_kEventButtonDown: + case GHOST_kEventButtonUp: + { + GHOST_TEventButtonData *bd = GHOST_GetEventData(evt); + int cx, cy, sizex, sizey, inside_window; + + GHOST_GetCursorPosition(g_WS.ghost_system, &cx, &cy); + GHOST_ScreenToClient(g_WS.ghost_window, cx, cy, &cx, &cy); + playanim_window_get_size(&sizex, &sizey); + + inside_window = (cx >= 0 && cx < sizex && cy >= 0 && cy <= sizey); + + if (bd->button == GHOST_kButtonMaskLeft) { + if (type == GHOST_kEventButtonDown) { + if (inside_window) + g_WS.qual |= WS_QUAL_LMOUSE; + } + else + g_WS.qual &= ~WS_QUAL_LMOUSE; + } + else if (bd->button == GHOST_kButtonMaskMiddle) { + if (type == GHOST_kEventButtonDown) { + if (inside_window) + g_WS.qual |= WS_QUAL_MMOUSE; + } + else + g_WS.qual &= ~WS_QUAL_MMOUSE; + } + else if (bd->button == GHOST_kButtonMaskRight) { + if (type == GHOST_kEventButtonDown) { + if (inside_window) + g_WS.qual |= WS_QUAL_RMOUSE; + } + else + g_WS.qual &= ~WS_QUAL_RMOUSE; + } + break; + } case GHOST_kEventCursorMove: { if (g_WS.qual & WS_QUAL_LMOUSE) { @@ -638,6 +672,11 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) } break; } + case GHOST_kEventWindowActivate: + case GHOST_kEventWindowDeactivate: { + g_WS.qual &= ~WS_QUAL_MOUSE; + break; + } case GHOST_kEventWindowSize: case GHOST_kEventWindowMove: { |