Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-04-04 17:37:07 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-04-04 17:37:07 +0400
commit83fff218cca47147183c1177de9db1381cfa48e6 (patch)
tree2576a9f8c61393a346c53eb85077ede1ba2b1d33 /source/blender/editors
parent69035e183ba91877489e8aae2d0425b13813ac18 (diff)
parent19dd08a4828ac1883138b2a65f0b8df1498e0d15 (diff)
svn merge ^/trunk/blender -r55700:55776
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/anim_filter.c2
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c22
-rw-r--r--source/blender/editors/include/BIF_glutil.h45
-rw-r--r--source/blender/editors/include/ED_mesh.h1
-rw-r--r--source/blender/editors/include/ED_space_api.h4
-rw-r--r--source/blender/editors/include/ED_transform.h33
-rw-r--r--source/blender/editors/include/ED_util.h1
-rw-r--r--source/blender/editors/include/UI_interface.h29
-rw-r--r--source/blender/editors/include/UI_interface_icons.h2
-rw-r--r--source/blender/editors/interface/interface.c126
-rw-r--r--source/blender/editors/interface/interface_draw.c61
-rw-r--r--source/blender/editors/interface/interface_handlers.c26
-rw-r--r--source/blender/editors/interface/interface_icons.c6
-rw-r--r--source/blender/editors/interface/interface_intern.h22
-rw-r--r--source/blender/editors/interface/interface_layout.c54
-rw-r--r--source/blender/editors/interface/interface_ops.c2
-rw-r--r--source/blender/editors/interface/interface_regions.c32
-rw-r--r--source/blender/editors/interface/interface_templates.c18
-rw-r--r--source/blender/editors/interface/interface_widgets.c4
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c29
-rw-r--r--source/blender/editors/mesh/editmesh_inset.c44
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c4
-rw-r--r--source/blender/editors/object/object_add.c4
-rw-r--r--source/blender/editors/object/object_group.c24
-rw-r--r--source/blender/editors/object/object_relations.c2
-rw-r--r--source/blender/editors/object/object_select.c6
-rw-r--r--source/blender/editors/physics/rigidbody_constraint.c6
-rw-r--r--source/blender/editors/physics/rigidbody_object.c6
-rw-r--r--source/blender/editors/render/render_internal.c32
-rw-r--r--source/blender/editors/render/render_opengl.c15
-rw-r--r--source/blender/editors/screen/CMakeLists.txt1
-rw-r--r--source/blender/editors/screen/glutil.c239
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c22
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h2
-rw-r--r--source/blender/editors/space_action/action_select.c2
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c12
-rw-r--r--source/blender/editors/space_clip/clip_draw.c73
-rw-r--r--source/blender/editors/space_clip/clip_editor.c79
-rw-r--r--source/blender/editors/space_clip/clip_intern.h2
-rw-r--r--source/blender/editors/space_clip/clip_ops.c41
-rw-r--r--source/blender/editors/space_clip/space_clip.c29
-rw-r--r--source/blender/editors/space_file/file_draw.c4
-rw-r--r--source/blender/editors/space_image/image_draw.c10
-rw-r--r--source/blender/editors/space_image/space_image.c12
-rw-r--r--source/blender/editors/space_node/drawnode.c4
-rw-r--r--source/blender/editors/space_node/node_draw.c2
-rw-r--r--source/blender/editors/space_node/node_edit.c13
-rw-r--r--source/blender/editors/space_node/node_intern.h7
-rw-r--r--source/blender/editors/space_node/node_ops.c6
-rw-r--r--source/blender/editors/space_node/node_relationships.c30
-rw-r--r--source/blender/editors/space_node/node_select.c106
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c5
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c153
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h4
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c78
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c6
-rw-r--r--source/blender/editors/space_sequencer/sequencer_intern.h6
-rw-r--r--source/blender/editors/space_sequencer/sequencer_scopes.c37
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c1
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c12
-rw-r--r--source/blender/editors/space_view3d/drawobject.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c19
-rw-r--r--source/blender/editors/space_view3d/view3d_ruler.c90
-rw-r--r--source/blender/editors/space_view3d/view3d_toolbar.c2
-rw-r--r--source/blender/editors/transform/transform.c5
-rw-r--r--source/blender/editors/transform/transform.h24
-rw-r--r--source/blender/editors/transform/transform_constraints.c55
-rw-r--r--source/blender/editors/transform/transform_conversions.c137
-rw-r--r--source/blender/editors/transform/transform_manipulator.c50
-rw-r--r--source/blender/editors/transform/transform_orientations.c14
-rw-r--r--source/blender/editors/transform/transform_snap.c213
-rw-r--r--source/blender/editors/util/CMakeLists.txt4
-rw-r--r--source/blender/editors/util/SConscript2
-rw-r--r--source/blender/editors/util/ed_util.c37
76 files changed, 1335 insertions, 993 deletions
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 61e03806391..df840df05e7 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -2326,7 +2326,7 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, b
* - used to ease the process of doing multiple-character choreographies
*/
if (ads->filterflag & ADS_FILTER_ONLYOBGROUP) {
- if (object_in_group(ob, ads->filter_grp) == 0)
+ if (BKE_group_object_exists(ads->filter_grp, ob) == 0)
continue;
}
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index a3515e0983d..7a20f0727c0 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -626,7 +626,7 @@ static void sk_drawStrokeSubdivision(ToolSettings *toolsettings, SK_Stroke *stk)
}
}
-static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], int *dist, int *index, int all_pts)
+static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], float *r_dist_px, int *index, int all_pts)
{
ARegion *ar = CTX_wm_region(C);
SK_Point *pt = NULL;
@@ -641,8 +641,8 @@ static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], in
pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
- if (pdist < *dist) {
- *dist = pdist;
+ if (pdist < *r_dist_px) {
+ *r_dist_px = pdist;
pt = stk->points + i;
if (index != NULL) {
@@ -729,13 +729,13 @@ static void sk_updateOverdraw(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK
if (sketch->over.target == NULL) {
SK_Stroke *target;
int closest_index = -1;
- int dist = SNAP_MIN_DISTANCE * 2;
+ float dist_px = SNAP_MIN_DISTANCE * 2;
for (target = sketch->strokes.first; target; target = target->next) {
if (target != stk) {
int index;
- SK_Point *spt = sk_snapPointStroke(C, target, dd->mval, &dist, &index, 1);
+ SK_Point *spt = sk_snapPointStroke(C, target, dd->mval, &dist_px, &index, 1);
if (spt != NULL) {
sketch->over.target = target;
@@ -764,10 +764,10 @@ static void sk_updateOverdraw(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK
}
else if (sketch->over.target != NULL) {
SK_Point *closest_pt = NULL;
- int dist = SNAP_MIN_DISTANCE * 2;
+ float dist_px = SNAP_MIN_DISTANCE * 2;
int index;
- closest_pt = sk_snapPointStroke(C, sketch->over.target, dd->mval, &dist, &index, 1);
+ closest_pt = sk_snapPointStroke(C, sketch->over.target, dd->mval, &dist_px, &index, 1);
if (closest_pt != NULL) {
if (sk_lastStrokePoint(stk)->type == PT_EXACT) {
@@ -1064,17 +1064,17 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
float no[3];
float mval[2];
int found = 0;
- int dist = SNAP_MIN_DISTANCE; // Use a user defined value here
+ float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here
/* snap to strokes */
// if (ts->snap_mode == SCE_SNAP_MODE_VERTEX) /* snap all the time to strokes */
for (snap_stk = sketch->strokes.first; snap_stk; snap_stk = snap_stk->next) {
SK_Point *spt = NULL;
if (snap_stk == stk) {
- spt = sk_snapPointStroke(C, snap_stk, dd->mval, &dist, NULL, 0);
+ spt = sk_snapPointStroke(C, snap_stk, dd->mval, &dist_px, NULL, 0);
}
else {
- spt = sk_snapPointStroke(C, snap_stk, dd->mval, &dist, NULL, 1);
+ spt = sk_snapPointStroke(C, snap_stk, dd->mval, &dist_px, NULL, 1);
}
if (spt != NULL) {
@@ -1087,7 +1087,7 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
mval[1] = dd->mval[1];
/* try to snap to closer object */
- found = snapObjectsContext(C, mval, &dist, vec, no, SNAP_NOT_SELECTED);
+ found = snapObjectsContext(C, mval, &dist_px, vec, no, SNAP_NOT_SELECTED);
if (found == 1) {
pt->type = dd->type;
pt->mode = PT_SNAP;
diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h
index 5774a057eb5..af2dc884508 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -33,6 +33,9 @@
struct rcti;
struct rctf;
+struct ImBuf;
+struct bContext;
+
void fdrawbezier(float vec[4][3]);
void fdrawline(float x1, float y1, float x2, float y2);
void fdrawbox(float x1, float y1, float x2, float y2);
@@ -141,17 +144,17 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo
* 1-to-1 mapping to screen space.
*/
-void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, int zoomfilter, void *rect);
+void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect);
/**
* glaDrawPixelsAuto - Switches between texture or pixel drawing using UserDef.
* only RGBA
* needs glaDefine2DArea to be set.
*/
-void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, int zoomfilter, void *rect);
+void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect);
-void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int zoomfilter, void *rect, float scaleX, float scaleY);
+void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY);
/* 2D Drawing Assistance */
@@ -170,35 +173,19 @@ void glaDefine2DArea(struct rcti *screen_rect);
typedef struct gla2DDrawInfo gla2DDrawInfo;
-/** Save the current OpenGL state and initialize OpenGL for 2D
- * rendering. glaEnd2DDraw should be called on the returned structure
- * to free it and to return OpenGL to its previous state. The
- * scissor rectangle is set to match the viewport.
- *
- * See glaDefine2DArea for an explanation of why this function uses integers.
- *
- * \param screen_rect The screen rectangle to be used for 2D drawing.
- * \param world_rect The world rectangle that the 2D area represented
- * by \a screen_rect is supposed to represent. If NULL it is assumed the
- * world has a 1 to 1 mapping to the screen.
- */
-gla2DDrawInfo *glaBegin2DDraw(struct rcti *screen_rect, struct rctf *world_rect);
-
-/** Translate the (\a wo_x, \a wo_y) point from world coordinates into screen space. */
-void gla2DDrawTranslatePt(gla2DDrawInfo *di, float wo_x, float wo_y, int *sc_x_r, int *sc_y_r);
+/* UNUSED */
+#if 0
-/** Translate the \a world point from world coordiantes into screen space. */
+gla2DDrawInfo *glaBegin2DDraw(struct rcti *screen_rect, struct rctf *world_rect);
+void gla2DDrawTranslatePt(gla2DDrawInfo *di, float wo_x, float wo_y, int *sc_x_r, int *sc_y_r);
void gla2DDrawTranslatePtv(gla2DDrawInfo *di, float world[2], int screen_r[2]);
-/* Restores the previous OpenGL state and free's the auxilary
- * gla data.
- */
-void glaEnd2DDraw(gla2DDrawInfo *di);
+void glaEnd2DDraw(gla2DDrawInfo *di);
/** Adjust the transformation mapping of a 2d area */
void gla2DGetMap(gla2DDrawInfo *di, struct rctf *rect);
void gla2DSetMap(gla2DDrawInfo *di, struct rctf *rect);
-
+#endif
/* use this for platform hacks. glPointSize is solved here */
void bglBegin(int mode);
@@ -223,5 +210,13 @@ typedef struct bglMats {
} bglMats;
void bgl_get_mats(bglMats *mats);
+/* **** Color management helper functions for GLSL display/transform ***** */
+
+/* Draw imbuf on a screen, preferably using GLSL display transform */
+void glaDrawImBuf_glsl_ctx(const struct bContext *C, struct ImBuf *ibuf, float x, float y, int zoomfilter);
+
+/* Transform buffer from role to scene linear space using GLSL OCIO conversion */
+int glaBufferTransformFromRole_glsl(float *buffer, int width, int height, int role);
+
#endif /* __BIF_GLUTIL_H__ */
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index ab112fde48d..a39476dad66 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -251,7 +251,6 @@ void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, int
void ED_mesh_transform(struct Mesh *me, float *mat);
void ED_mesh_calc_normals(struct Mesh *me);
void ED_mesh_calc_tessface(struct Mesh *mesh);
-void ED_mesh_material_link(struct Mesh *me, struct Material *ma);
void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges, int calc_tessface);
int ED_mesh_uv_texture_add(struct Mesh *me, const char *name, const bool active_set);
diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h
index a40cf90f7ad..4fbe01a5fc7 100644
--- a/source/blender/editors/include/ED_space_api.h
+++ b/source/blender/editors/include/ED_space_api.h
@@ -74,6 +74,8 @@ void *ED_region_draw_cb_activate(struct ARegionType *,
void ED_region_draw_cb_draw(const struct bContext *, struct ARegion *, int);
void ED_region_draw_cb_exit(struct ARegionType *, void *);
void *ED_region_draw_cb_customdata(void *handle);
+/* generic callbacks */
+/* ed_util.c */
+void ED_region_draw_mouse_line_cb(const struct bContext *C, struct ARegion *ar, void *arg_info);
#endif /* __ED_SPACE_API_H__ */
-
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index d43582fa8d1..5fe44aa17f7 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -34,17 +34,18 @@
/* ******************* Registration Function ********************** */
-struct wmWindowManager;
-struct wmOperatorType;
+struct ARegion;
+struct EnumPropertyItem;
struct ListBase;
-struct wmEvent;
-struct bContext;
struct Object;
+struct View3D;
+struct bContext;
struct uiLayout;
-struct EnumPropertyItem;
-struct wmOperatorType;
-struct wmKeyMap;
+struct wmEvent;
struct wmKeyConfig;
+struct wmKeyMap;
+struct wmOperatorType;
+struct wmWindowManager;
void transform_keymap_for_space(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap, int spaceid);
void transform_operatortypes(void);
@@ -112,7 +113,8 @@ struct Base;
struct Scene;
struct Object;
-int BIF_snappingSupported(struct Object *obedit);
+/* UNUSED */
+// int BIF_snappingSupported(struct Object *obedit);
struct TransformOrientation;
struct bContext;
@@ -179,10 +181,17 @@ typedef enum SnapMode {
bool peelObjectsTransForm(struct TransInfo *t, struct ListBase *depth_peels, const float mval[2], SnapMode mode);
bool peelObjectsContext(struct bContext *C, struct ListBase *depth_peels, const float mval[2], SnapMode mode);
-bool snapObjectsTransform(struct TransInfo *t, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode);
-bool snapObjectsContext(struct bContext *C, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode);
-bool snapNodesTransform(struct TransInfo *t, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode);
-bool snapNodesContext(struct bContext *C, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode);
+bool snapObjectsTransform(struct TransInfo *t, const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode);
+bool snapObjectsContext(struct bContext *C, const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode);
+/* taks args for all settings */
+bool snapObjectsEx(struct Scene *scene, struct Base *base_act, struct View3D *v3d, struct ARegion *ar, struct Object *obedit, short snap_mode,
+ const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode);
+bool snapObjectsRayEx(struct Scene *scene, struct Base *base_act, struct View3D *v3d, struct ARegion *ar, struct Object *obedit, short snap_mode,
+ const float ray_start[3], const float ray_normal[3],
+ const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode);
+
+bool snapNodesTransform(struct TransInfo *t, const int mval[2], float *r_dist_px, float r_loc[2], char *r_node_border, SnapMode mode);
+bool snapNodesContext(struct bContext *C, const int mval[2], float *r_dist_px, float r_loc[2], char *r_node_border, SnapMode mode);
#endif
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index d0ca079b8c9..67f790f0b46 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -90,7 +90,6 @@ void ED_clipboard_posebuf_free(void);
/* ************** XXX OLD CRUFT WARNING ************* */
void apply_keyb_grid(int shift, int ctrl, float *val, float fac1, float fac2, float fac3, int invert);
-int GetButStringLength(const char *str);
/* where else to go ? */
void unpack_menu(struct bContext *C, const char *opname, const char *id_name, const char *abs_name, const char *folder, struct PackedFile *pf);
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 2572d4b4d99..7e1bd2b9eb6 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -280,7 +280,6 @@ typedef enum {
* Functions to draw various shapes, taking theme settings into account.
* Used for code that draws its own UI style elements. */
-void uiEmboss(float x1, float y1, float x2, float y2, int sel);
void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad);
void uiSetRoundBox(int type);
int uiGetRoundBox(void);
@@ -398,7 +397,7 @@ void uiFreeActiveButtons(const struct bContext *C, struct bScreen *screen);
void uiBlockSetRegion(uiBlock *block, struct ARegion *region);
-void uiBlockSetButLock(uiBlock *block, int val, const char *lockstr);
+void uiBlockSetButLock(uiBlock *block, bool val, const char *lockstr);
void uiBlockClearButLock(uiBlock *block);
/* automatic aligning, horiz or verical */
@@ -448,7 +447,7 @@ void uiButSetDrawFlag(uiBut *but, int flag);
void uiButClearDrawFlag(uiBut *but, int flag);
/* special button case, only draw it when used actively, for outliner etc */
-int uiButActiveOnly(const struct bContext *C, struct ARegion *ar, uiBlock *block, uiBut *but);
+bool uiButActiveOnly(const struct bContext *C, struct ARegion *ar, uiBlock *block, uiBut *but);
void uiButExecute(const struct bContext *C, uiBut *but);
@@ -621,7 +620,7 @@ void uiComposeLinks(uiBlock *block);
uiBut *uiFindInlink(uiBlock *block, void *poin);
/* use inside searchfunc to add items */
-int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid);
+bool uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid);
/* bfunc gets search item *poin as arg2, or if NULL the old string */
void uiButSetSearchFunc(uiBut *but, uiButSearchFunc sfunc, void *arg1, uiButHandleFunc bfunc, void *active);
/* height in pixels, it's using hardcoded values still */
@@ -770,20 +769,20 @@ void uiLayoutOperatorButs(const struct bContext *C, struct uiLayout *layout, str
struct MenuType *uiButGetMenuType(uiBut *but);
void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext);
-void uiLayoutSetActive(uiLayout *layout, int active);
-void uiLayoutSetEnabled(uiLayout *layout, int enabled);
-void uiLayoutSetRedAlert(uiLayout *layout, int redalert);
-void uiLayoutSetAlignment(uiLayout *layout, int alignment);
-void uiLayoutSetKeepAspect(uiLayout *layout, int keepaspect);
+void uiLayoutSetActive(uiLayout *layout, bool active);
+void uiLayoutSetEnabled(uiLayout *layout, bool enabled);
+void uiLayoutSetRedAlert(uiLayout *layout, bool redalert);
+void uiLayoutSetAlignment(uiLayout *layout, char alignment);
+void uiLayoutSetKeepAspect(uiLayout *layout, bool keepaspect);
void uiLayoutSetScaleX(uiLayout *layout, float scale);
void uiLayoutSetScaleY(uiLayout *layout, float scale);
int uiLayoutGetOperatorContext(uiLayout *layout);
-int uiLayoutGetActive(uiLayout *layout);
-int uiLayoutGetEnabled(uiLayout *layout);
-int uiLayoutGetRedAlert(uiLayout *layout);
+bool uiLayoutGetActive(uiLayout *layout);
+bool uiLayoutGetEnabled(uiLayout *layout);
+bool uiLayoutGetRedAlert(uiLayout *layout);
int uiLayoutGetAlignment(uiLayout *layout);
-int uiLayoutGetKeepAspect(uiLayout *layout);
+bool uiLayoutGetKeepAspect(uiLayout *layout);
int uiLayoutGetWidth(uiLayout *layout);
float uiLayoutGetScaleX(uiLayout *layout);
float uiLayoutGetScaleY(uiLayout *layout);
@@ -803,7 +802,6 @@ uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout);
/* templates */
void uiTemplateHeader(uiLayout *layout, struct bContext *C, int menus);
-void uiTemplateDopeSheetFilter(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
const char *newop, const char *openop, const char *unlinkop);
void uiTemplateIDBrowse(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
@@ -836,7 +834,6 @@ void uiOperatorSearch_But(uiBut *but);
void uiTemplateOperatorSearch(uiLayout *layout);
void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
-void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *tex);
void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
void uiTemplateKeymapItemProperties(uiLayout *layout, struct PointerRNA *ptr);
void uiTemplateComponentMenu(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name);
@@ -922,7 +919,7 @@ uiStyle *UI_GetStyleDraw(void); /* DPI scaled settings for drawing */
void UI_template_fix_linking(void);
/* UI_OT_editsource helpers */
-int UI_editsource_enable_check(void);
+bool UI_editsource_enable_check(void);
void UI_editsource_active_but_test(uiBut *but);
#endif /* __UI_INTERFACE_H__ */
diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h
index 10026bbd50f..6104505ef58 100644
--- a/source/blender/editors/include/UI_interface_icons.h
+++ b/source/blender/editors/include/UI_interface_icons.h
@@ -79,6 +79,6 @@ int UI_iconfile_get_index(const char *filename);
struct PreviewImage *UI_icon_to_preview(int icon_id);
-int UI_rnaptr_icon_get(struct bContext *C, struct PointerRNA *ptr, int rnaicon, int big);
+int UI_rnaptr_icon_get(struct bContext *C, struct PointerRNA *ptr, int rnaicon, const bool big);
#endif /* __UI_INTERFACE_ICONS_H__ */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index be51651dee7..0c484a82778 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -549,22 +549,22 @@ static void ui_draw_links(uiBlock *block)
/* ************** BLOCK ENDING FUNCTION ************* */
/* NOTE: if but->poin is allocated memory for every defbut, things fail... */
-static int ui_but_equals_old(uiBut *but, uiBut *oldbut)
+static bool ui_but_equals_old(uiBut *but, uiBut *oldbut)
{
/* various properties are being compared here, hopefully sufficient
* to catch all cases, but it is simple to add more checks later */
- if (but->retval != oldbut->retval) return 0;
- if (but->rnapoin.data != oldbut->rnapoin.data) return 0;
+ if (but->retval != oldbut->retval) return false;
+ if (but->rnapoin.data != oldbut->rnapoin.data) return false;
if (but->rnaprop != oldbut->rnaprop)
- if (but->rnaindex != oldbut->rnaindex) return 0;
- if (but->func != oldbut->func) return 0;
- if (but->funcN != oldbut->funcN) return 0;
- if (oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) return 0;
- if (oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) return 0;
- if (!but->funcN && ((but->poin != oldbut->poin && (uiBut *)oldbut->poin != oldbut) || but->pointype != oldbut->pointype)) return 0;
- if (but->optype != oldbut->optype) return 0;
+ if (but->rnaindex != oldbut->rnaindex) return false;
+ if (but->func != oldbut->func) return false;
+ if (but->funcN != oldbut->funcN) return false;
+ if (oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) return false;
+ if (oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) return false;
+ if (!but->funcN && ((but->poin != oldbut->poin && (uiBut *)oldbut->poin != oldbut) || but->pointype != oldbut->pointype)) return false;
+ if (but->optype != oldbut->optype) return false;
- return 1;
+ return true;
}
/* oldbut is being inserted in new block, so we use the lines from new button, and replace button pointers */
@@ -682,37 +682,38 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut
/* needed for temporarily rename buttons, such as in outliner or file-select,
* they should keep calling uiDefButs to keep them alive */
/* returns 0 when button removed */
-int uiButActiveOnly(const bContext *C, ARegion *ar, uiBlock *block, uiBut *but)
+bool uiButActiveOnly(const bContext *C, ARegion *ar, uiBlock *block, uiBut *but)
{
uiBlock *oldblock;
uiBut *oldbut;
- int activate = FALSE, found = FALSE, isactive = FALSE;
+ bool activate = false, found = false, isactive = false;
oldblock = block->oldblock;
- if (!oldblock)
- activate = TRUE;
+ if (!oldblock) {
+ activate = true;
+ }
else {
for (oldbut = oldblock->buttons.first; oldbut; oldbut = oldbut->next) {
if (ui_but_equals_old(oldbut, but)) {
- found = TRUE;
+ found = true;
if (oldbut->active)
- isactive = TRUE;
+ isactive = true;
break;
}
}
}
- if ((activate == TRUE) || (found == FALSE)) {
+ if ((activate == true) || (found == false)) {
ui_button_activate_do((bContext *)C, ar, but);
}
- else if ((found == TRUE) && (isactive == FALSE)) {
+ else if ((found == true) && (isactive == false)) {
BLI_remlink(&block->buttons, but);
ui_free_but(C, but);
- return 0;
+ return false;
}
- return 1;
+ return true;
}
/* simulate button click */
@@ -1243,17 +1244,17 @@ void uiComposeLinks(uiBlock *block)
/* ************************************************ */
-void uiBlockSetButLock(uiBlock *block, int val, const char *lockstr)
+void uiBlockSetButLock(uiBlock *block, bool val, const char *lockstr)
{
if (val) {
- block->lock = val ? TRUE : FALSE;
+ block->lock = val;
block->lockstr = lockstr;
}
}
void uiBlockClearButLock(uiBlock *block)
{
- block->lock = FALSE;
+ block->lock = false;
block->lockstr = NULL;
}
@@ -1392,63 +1393,63 @@ void ui_set_but_vectorf(uiBut *but, const float vec[3])
}
}
-int ui_is_but_float(uiBut *but)
+bool ui_is_but_float(uiBut *but)
{
if (but->pointype == UI_BUT_POIN_FLOAT && but->poin)
- return 1;
+ return true;
if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_FLOAT)
- return 1;
+ return true;
- return 0;
+ return false;
}
-int ui_is_but_bool(uiBut *but)
+bool ui_is_but_bool(uiBut *but)
{
if (ELEM5(but->type, TOG, TOGN, TOGR, ICONTOG, ICONTOGN))
- return 1;
+ return true;
if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_BOOLEAN)
- return 1;
+ return true;
- return 0;
+ return false;
}
-int ui_is_but_unit(uiBut *but)
+bool ui_is_but_unit(uiBut *but)
{
UnitSettings *unit = but->block->unit;
const int unit_type = uiButGetUnitType(but);
if (unit_type == PROP_UNIT_NONE)
- return 0;
+ return false;
#if 1 /* removed so angle buttons get correct snapping */
if (unit->system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION)
- return 0;
+ return false;
#endif
/* for now disable time unit conversion */
if (unit_type == PROP_UNIT_TIME)
- return 0;
+ return false;
if (unit->system == USER_UNIT_NONE) {
if (unit_type != PROP_UNIT_ROTATION) {
- return 0;
+ return false;
}
}
- return 1;
+ return true;
}
-int ui_is_but_rna_valid(uiBut *but)
+bool ui_is_but_rna_valid(uiBut *but)
{
if (but->rnaprop == NULL || RNA_struct_contains_property(&but->rnapoin, but->rnaprop)) {
- return TRUE;
+ return true;
}
else {
printf("property removed %s: %p\n", but->drawstr, but->rnaprop);
- return FALSE;
+ return false;
}
}
@@ -1789,7 +1790,7 @@ void ui_get_but_string(uiBut *but, char *str, const size_t maxlen)
#ifdef WITH_PYTHON
-static int ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char *str, double *value)
+static bool ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char *str, double *value)
{
char str_unit_convert[256];
const int unit_type = uiButGetUnitType(but);
@@ -1807,9 +1808,9 @@ static int ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char *
#endif /* WITH_PYTHON */
-int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double *value)
+bool ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double *value)
{
- int ok = FALSE;
+ bool ok = false;
#ifdef WITH_PYTHON
@@ -1825,7 +1826,7 @@ int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double
ok = ui_set_but_string_eval_num_unit(C, but, str_new, value);
}
else {
- ok = TRUE; /* parse normal string via py (no unit conversion needed) */
+ ok = true; /* parse normal string via py (no unit conversion needed) */
}
}
else if (is_unit_but) {
@@ -1848,7 +1849,7 @@ int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double
}
-int ui_set_but_string(bContext *C, uiBut *but, const char *str)
+bool ui_set_but_string(bContext *C, uiBut *but, const char *str)
{
if (but->rnaprop && ELEM4(but->type, TEX, IDPOIN, SEARCH_MENU, SEARCH_MENU_UNLINK)) {
if (RNA_property_editable(&but->rnapoin, but->rnaprop)) {
@@ -1859,7 +1860,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
if (type == PROP_STRING) {
/* RNA string */
RNA_property_string_set(&but->rnapoin, but->rnaprop, str);
- return 1;
+ return true;
}
else if (type == PROP_POINTER) {
/* RNA pointer */
@@ -1868,7 +1869,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
if (str == NULL || str[0] == '\0') {
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, PointerRNA_NULL);
- return 1;
+ return true;
}
else {
ptr = but->rnasearchpoin;
@@ -1877,18 +1878,18 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr))
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr);
- return 1;
+ return true;
}
- return 0;
+ return false;
}
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 true;
}
- return 0;
+ return false;
}
else {
BLI_assert(0);
@@ -1898,23 +1899,23 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
else if (but->type == IDPOIN) {
/* ID pointer */
but->idpoin_func(C, str, but->idpoin_idpp);
- return 1;
+ return true;
}
else if (but->type == TEX) {
/* string */
if (ui_is_but_utf8(but)) BLI_strncpy_utf8(but->poin, str, but->hardmax);
else BLI_strncpy(but->poin, str, but->hardmax);
- return 1;
+ return true;
}
else if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) {
/* string */
BLI_strncpy(but->poin, str, but->hardmax);
- return 1;
+ return true;
}
else if (ui_but_anim_expression_set(but, str)) {
/* driver expression */
- return 1;
+ return true;
}
else if (str[0] == '#') {
/* shortcut to create new driver expression (versus immediate Py-execution) */
@@ -1924,8 +1925,8 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
/* number editing */
double value;
- if (ui_set_but_string_eval_num(C, but, str, &value) == FALSE) {
- return 0;
+ if (ui_set_but_string_eval_num(C, but, str, &value) == false) {
+ return false;
}
if (!ui_is_but_float(but)) value = (int)floor(value + 0.5);
@@ -1936,10 +1937,10 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
if (value > (double)but->hardmax) value = but->hardmax;
ui_set_but_val(but, value);
- return 1;
+ return true;
}
- return 0;
+ return false;
}
void ui_set_but_default(bContext *C, short all)
@@ -2464,15 +2465,14 @@ void uiBlockBeginAlign(uiBlock *block)
/* buttons declared after this call will get this align nr */ // XXX flag?
}
-static int buts_are_horiz(uiBut *but1, uiBut *but2)
+static bool buts_are_horiz(uiBut *but1, uiBut *but2)
{
float dx, dy;
dx = fabs(but1->rect.xmax - but2->rect.xmin);
dy = fabs(but1->rect.ymin - but2->rect.ymax);
- if (dx > dy) return 0;
- return 1;
+ return (dx <= dy);
}
void uiBlockEndAlign(uiBlock *block)
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index b9b877c1fb6..cd2a2161315 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -61,15 +61,6 @@
/* own include */
#include "interface_intern.h"
-/* only for bug workaround [#34346] */
-#if !defined(WIN32) && !defined(__APPLE__)
-# define GPU_OSS_BUG_WOKAROUND
-#endif
-
-#ifdef GPU_OSS_BUG_WOKAROUND
-# include "GPU_extensions.h"
-#endif
-
static int roundboxtype = UI_CNR_ALL;
void uiSetRoundBox(int type)
@@ -402,32 +393,6 @@ void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad)
ui_draw_anti_roundbox(GL_POLYGON, minx, miny, maxx, maxy, rad, roundboxtype & UI_RB_ALPHA);
}
-
-/* ************** generic embossed rect, for window sliders etc ************* */
-
-
-/* text_draw.c uses this */
-void uiEmboss(float x1, float y1, float x2, float y2, int sel)
-{
-
- /* below */
- if (sel) glColor3ub(200, 200, 200);
- else glColor3ub(50, 50, 50);
- fdrawline(x1, y1, x2, y1);
-
- /* right */
- fdrawline(x2, y1, x2, y2);
-
- /* top */
- if (sel) glColor3ub(50, 50, 50);
- else glColor3ub(200, 200, 200);
- fdrawline(x1, y2, x2, y2);
-
- /* left */
- fdrawline(x1, y1, x1, y2);
-
-}
-
/* ************** SPECIAL BUTTON DRAWING FUNCTIONS ************* */
void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect)
@@ -463,7 +428,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
float facy = (float)h / (float)ibuf->y;
glPixelZoom(facx, facy);
}
- glaDrawPixelsAuto((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect);
+ glaDrawPixelsAuto((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect);
glPixelZoom(1.0f, 1.0f);
@@ -1245,7 +1210,6 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect)
void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
{
- static int use_displist = -1;
static GLuint displist = 0;
int a, old[8];
GLfloat diff[4], diffn[4] = {1.0f, 1.0f, 1.0f, 1.0f};
@@ -1294,20 +1258,12 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
size = BLI_rcti_size_y(rect) / 200.f;
glScalef(size, size, size);
-
-#ifdef GPU_OSS_BUG_WOKAROUND
- if (use_displist == -1) {
- use_displist = !GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE);
- }
-#endif
- if (displist == 0 || use_displist == 0) {
+ if (displist == 0) {
GLUquadricObj *qobj;
- if (use_displist) {
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE_AND_EXECUTE);
- }
+ displist = glGenLists(1);
+ glNewList(displist, GL_COMPILE);
qobj = gluNewQuadric();
gluQuadricDrawStyle(qobj, GLU_FILL);
@@ -1316,14 +1272,11 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
glShadeModel(GL_FLAT);
gluDeleteQuadric(qobj);
- if (use_displist) {
- glEndList();
- }
- }
- else {
- glCallList(displist);
+ glEndList();
}
+ glCallList(displist);
+
/* restore */
glDisable(GL_LIGHTING);
glDisable(GL_CULL_FACE);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 6d30db9c4d6..a644feca080 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -215,8 +215,8 @@ typedef struct uiAfterFunc {
int autokey;
} uiAfterFunc;
-static int ui_but_contains_pt(uiBut *but, int mx, int my);
-static int ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y);
+static bool ui_but_contains_pt(uiBut *but, int mx, int my);
+static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y);
static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state);
static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *userdata);
static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type);
@@ -333,7 +333,7 @@ static void ui_mouse_scale_warp(uiHandleButtonData *data,
}
/* file selectors are exempt from utf-8 checks */
-int ui_is_but_utf8(uiBut *but)
+bool ui_is_but_utf8(uiBut *but)
{
if (but->rnaprop) {
const int subtype = RNA_property_subtype(but->rnaprop);
@@ -5507,7 +5507,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
/* ************************ button utilities *********************** */
-static int ui_but_contains_pt(uiBut *but, int mx, int my)
+static bool ui_but_contains_pt(uiBut *but, int mx, int my)
{
return BLI_rctf_isect_pt(&but->rect, mx, my);
}
@@ -5525,7 +5525,7 @@ static uiBut *ui_but_find_activated(ARegion *ar)
return NULL;
}
-int ui_button_is_active(ARegion *ar)
+bool ui_button_is_active(ARegion *ar)
{
return (ui_but_find_activated(ar) != NULL);
}
@@ -5580,7 +5580,7 @@ static void ui_blocks_set_tooltips(ARegion *ar, int enable)
block->tooltipdisabled = !enable;
}
-static int ui_mouse_inside_region(ARegion *ar, int x, int y)
+static bool ui_mouse_inside_region(ARegion *ar, int x, int y)
{
uiBlock *block;
@@ -5589,7 +5589,7 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y)
for (block = ar->uiblocks.first; block; block = block->next)
block->auto_open = FALSE;
- return 0;
+ return false;
}
/* also, check that with view2d, that the mouse is not over the scrollbars
@@ -5608,23 +5608,23 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y)
/* check if in the rect */
if (!BLI_rcti_isect_pt(&v2d->mask, mx, my))
- return 0;
+ return false;
}
- return 1;
+ return true;
}
-static int ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y)
+static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y)
{
if (!ui_mouse_inside_region(ar, x, y))
- return 0;
+ return false;
ui_window_to_block(ar, but->block, &x, &y);
if (!ui_but_contains_pt(but, x, y))
- return 0;
+ return false;
- return 1;
+ return true;
}
/**
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 09686d7b416..52710a62855 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1164,7 +1164,7 @@ static void ui_id_preview_image_render_size(bContext *C, ID *id, PreviewImage *p
}
}
-static void ui_id_icon_render(bContext *C, ID *id, int big)
+static void ui_id_icon_render(bContext *C, ID *id, const bool big)
{
PreviewImage *pi = BKE_previewimg_get(id);
@@ -1248,7 +1248,7 @@ static int ui_id_brush_get_icon(bContext *C, ID *id)
return id->icon_id;
}
-int ui_id_icon_get(bContext *C, ID *id, int big)
+int ui_id_icon_get(bContext *C, ID *id, const bool big)
{
int iconid = 0;
@@ -1273,7 +1273,7 @@ int ui_id_icon_get(bContext *C, ID *id, int big)
return iconid;
}
-int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, int big)
+int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, const bool big)
{
ID *id = NULL;
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index e7b659f99fc..41ceeb141c9 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -391,18 +391,18 @@ extern void ui_hsvcircle_vals_from_pos(float *val_rad, float *val_dist, const rc
extern void ui_get_but_string_ex(uiBut *but, char *str, const size_t maxlen, const int float_precision);
extern void ui_get_but_string(uiBut *but, char *str, const size_t maxlen);
extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen);
-extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str);
-extern int ui_get_but_string_max_length(uiBut *but);
-extern int ui_set_but_string_eval_num(struct bContext *C, uiBut *but, const char *str, double *value);
+extern bool ui_set_but_string(struct bContext *C, uiBut *but, const char *str);
+extern bool ui_set_but_string_eval_num(struct bContext *C, uiBut *but, const char *str, double *value);
+extern int ui_get_but_string_max_length(uiBut *but);
extern void ui_set_but_default(struct bContext *C, short all);
extern void ui_check_but(uiBut *but);
-extern int ui_is_but_float(uiBut *but);
-extern int ui_is_but_bool(uiBut *but);
-extern int ui_is_but_unit(uiBut *but);
-extern int ui_is_but_rna_valid(uiBut *but);
-extern int ui_is_but_utf8(uiBut *but);
+extern bool ui_is_but_float(uiBut *but);
+extern bool ui_is_but_bool(uiBut *but);
+extern bool ui_is_but_unit(uiBut *but);
+extern bool ui_is_but_rna_valid(uiBut *but);
+extern bool ui_is_but_utf8(uiBut *but);
extern bool ui_is_but_interactive(uiBut *but);
extern int ui_is_but_push_ex(uiBut *but, double *value);
@@ -464,7 +464,7 @@ void ui_popup_block_scrolltest(struct uiBlock *block);
/* searchbox for string button */
ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
-int ui_searchbox_inside(struct ARegion *ar, int x, int y);
+bool ui_searchbox_inside(struct ARegion *ar, int x, int y);
void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but, int reset);
void ui_searchbox_autocomplete(struct bContext *C, struct ARegion *ar, uiBut *but, char *str);
void ui_searchbox_event(struct bContext *C, struct ARegion *ar, uiBut *but, const struct wmEvent *event);
@@ -511,7 +511,7 @@ extern void ui_pan_to_scroll(const struct wmEvent *event, int *type, int *val);
extern void ui_button_activate_do(struct bContext *C, struct ARegion *ar, uiBut *but);
extern void ui_button_execute_do(struct bContext *C, struct ARegion *ar, uiBut *but);
extern void ui_button_active_free(const struct bContext *C, uiBut *but);
-extern int ui_button_is_active(struct ARegion *ar);
+extern bool ui_button_is_active(struct ARegion *ar);
extern int ui_button_open_menu_direction(uiBut *but);
extern void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, int restore);
@@ -544,7 +544,7 @@ extern unsigned char checker_stipple_sml[32 * 32 / 8];
void uiStyleInit(void);
/* interface_icons.c */
-int ui_id_icon_get(struct bContext *C, struct ID *id, int preview);
+int ui_id_icon_get(struct bContext *C, struct ID *id, const bool big);
/* resources.c */
void init_userdef_do_versions(void);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 53887163778..4b1b96f7975 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -140,11 +140,11 @@ struct uiLayout {
int x, y, w, h;
float scale[2];
short space;
- char align;
- char active;
- char enabled;
- char redalert;
- char keepaspect;
+ bool align;
+ bool active;
+ bool enabled;
+ bool redalert;
+ bool keepaspect;
char alignment;
};
@@ -1333,7 +1333,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s
BLI_strncpy(name_ui, id->name + 2, sizeof(name_ui));
#endif
name = BLI_strdup(name_ui);
- iconid = ui_id_icon_get((bContext *)C, id, 0);
+ iconid = ui_id_icon_get((bContext *)C, id, false);
}
else {
name = RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); /* could use the string length here */
@@ -1359,7 +1359,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s
/* add search items from temporary list */
for (cis = items_list->first; cis; cis = cis->next) {
- if (!uiSearchItemAdd(items, cis->name, SET_INT_IN_POINTER(cis->index), cis->iconid)) {
+ if (false == uiSearchItemAdd(items, cis->name, SET_INT_IN_POINTER(cis->index), cis->iconid)) {
break;
}
}
@@ -2267,8 +2267,8 @@ uiLayout *uiLayoutRow(uiLayout *layout, int align)
litem->item.type = ITEM_LAYOUT_ROW;
litem->root = layout->root;
litem->align = align;
- litem->active = 1;
- litem->enabled = 1;
+ litem->active = true;
+ litem->enabled = true;
litem->context = layout->context;
litem->space = (align) ? 0 : layout->root->style->buttonspacex;
litem->redalert = layout->redalert;
@@ -2288,8 +2288,8 @@ uiLayout *uiLayoutColumn(uiLayout *layout, int align)
litem->item.type = ITEM_LAYOUT_COLUMN;
litem->root = layout->root;
litem->align = align;
- litem->active = 1;
- litem->enabled = 1;
+ litem->active = true;
+ litem->enabled = true;
litem->context = layout->context;
litem->space = (litem->align) ? 0 : layout->root->style->buttonspacey;
litem->redalert = layout->redalert;
@@ -2309,8 +2309,8 @@ uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align)
flow->litem.item.type = ITEM_LAYOUT_COLUMN_FLOW;
flow->litem.root = layout->root;
flow->litem.align = align;
- flow->litem.active = 1;
- flow->litem.enabled = 1;
+ flow->litem.active = true;
+ flow->litem.enabled = true;
flow->litem.context = layout->context;
flow->litem.space = (flow->litem.align) ? 0 : layout->root->style->columnspace;
flow->litem.redalert = layout->redalert;
@@ -2402,8 +2402,8 @@ uiLayout *uiLayoutOverlap(uiLayout *layout)
litem = MEM_callocN(sizeof(uiLayout), "uiLayoutOverlap");
litem->item.type = ITEM_LAYOUT_OVERLAP;
litem->root = layout->root;
- litem->active = 1;
- litem->enabled = 1;
+ litem->active = true;
+ litem->enabled = true;
litem->context = layout->context;
litem->redalert = layout->redalert;
BLI_addtail(&layout->items, litem);
@@ -2421,8 +2421,8 @@ uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align)
split->litem.item.type = ITEM_LAYOUT_SPLIT;
split->litem.root = layout->root;
split->litem.align = align;
- split->litem.active = 1;
- split->litem.enabled = 1;
+ split->litem.active = true;
+ split->litem.enabled = true;
split->litem.context = layout->context;
split->litem.space = layout->root->style->columnspace;
split->litem.redalert = layout->redalert;
@@ -2435,27 +2435,27 @@ uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align)
return &split->litem;
}
-void uiLayoutSetActive(uiLayout *layout, int active)
+void uiLayoutSetActive(uiLayout *layout, bool active)
{
layout->active = active;
}
-void uiLayoutSetEnabled(uiLayout *layout, int enabled)
+void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
{
layout->enabled = enabled;
}
-void uiLayoutSetRedAlert(uiLayout *layout, int redalert)
+void uiLayoutSetRedAlert(uiLayout *layout, bool redalert)
{
layout->redalert = redalert;
}
-void uiLayoutSetKeepAspect(uiLayout *layout, int keepaspect)
+void uiLayoutSetKeepAspect(uiLayout *layout, bool keepaspect)
{
layout->keepaspect = keepaspect;
}
-void uiLayoutSetAlignment(uiLayout *layout, int alignment)
+void uiLayoutSetAlignment(uiLayout *layout, char alignment)
{
layout->alignment = alignment;
}
@@ -2470,22 +2470,22 @@ void uiLayoutSetScaleY(uiLayout *layout, float scale)
layout->scale[1] = scale;
}
-int uiLayoutGetActive(uiLayout *layout)
+bool uiLayoutGetActive(uiLayout *layout)
{
return layout->active;
}
-int uiLayoutGetEnabled(uiLayout *layout)
+bool uiLayoutGetEnabled(uiLayout *layout)
{
return layout->enabled;
}
-int uiLayoutGetRedAlert(uiLayout *layout)
+bool uiLayoutGetRedAlert(uiLayout *layout)
{
return layout->redalert;
}
-int uiLayoutGetKeepAspect(uiLayout *layout)
+bool uiLayoutGetKeepAspect(uiLayout *layout)
{
return layout->keepaspect;
}
@@ -2937,7 +2937,7 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,
/* poll() on this operator may still fail, at the moment there is no nice feedback when this happens
* just fails silently */
if (!WM_operator_repeat_check(C, op)) {
- uiBlockSetButLock(uiLayoutGetBlock(layout), TRUE, "Operator can't' redo");
+ uiBlockSetButLock(uiLayoutGetBlock(layout), true, "Operator can't' redo");
/* XXX, could give some nicer feedback or not show redo panel at all? */
uiItemL(layout, IFACE_("* Redo Unsupported *"), ICON_NONE);
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 145deb35667..52a26f4f528 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -716,7 +716,7 @@ struct uiEditSourceButStore {
/* should only ever be set while the edit source operator is running */
static struct uiEditSourceStore *ui_editsource_info = NULL;
-int UI_editsource_enable_check(void)
+bool UI_editsource_enable_check(void)
{
return (ui_editsource_info != NULL);
}
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index febd1820e5c..2ccba2e35f0 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -514,7 +514,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
opptr = uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */
/* so the context is passed to itemf functions (some py itemf functions use it) */
- WM_operator_properties_sanitize(opptr, FALSE);
+ WM_operator_properties_sanitize(opptr, false);
str = WM_operator_pystring(C, but->optype, opptr, 0);
@@ -742,8 +742,8 @@ typedef struct uiSearchboxData {
uiFontStyle fstyle;
uiSearchItems items;
int active; /* index in items array */
- int noback; /* when menu opened with enough space for this */
- int preview; /* draw thumbnail previews, rather than list */
+ bool noback; /* when menu opened with enough space for this */
+ bool preview; /* draw thumbnail previews, rather than list */
int prv_rows, prv_cols;
} uiSearchboxData;
@@ -751,12 +751,12 @@ typedef struct uiSearchboxData {
/* exported for use by search callbacks */
/* returns zero if nothing to add */
-int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid)
+bool uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid)
{
/* hijack for autocomplete */
if (items->autocpl) {
autocomplete_do_name(items->autocpl, name);
- return 1;
+ return true;
}
/* hijack for finding active item */
@@ -764,18 +764,18 @@ int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int icon
if (poin == items->active)
items->offset_i = items->totitem;
items->totitem++;
- return 1;
+ return true;
}
if (items->totitem >= items->maxitem) {
items->more = 1;
- return 0;
+ return false;
}
/* skip first items in list */
if (items->offset_i > 0) {
items->offset_i--;
- return 1;
+ return true;
}
if (items->names)
@@ -787,7 +787,7 @@ int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int icon
items->totitem++;
- return 1;
+ return true;
}
int uiSearchBoxHeight(void)
@@ -867,11 +867,11 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr)
}
/* x and y in screencoords */
-int ui_searchbox_inside(ARegion *ar, int x, int y)
+bool ui_searchbox_inside(ARegion *ar, int x, int y)
{
uiSearchboxData *data = ar->regiondata;
- return(BLI_rcti_isect_pt(&data->bbox, x - ar->winrct.xmin, y - ar->winrct.ymin));
+ return BLI_rcti_isect_pt(&data->bbox, x - ar->winrct.xmin, y - ar->winrct.ymin);
}
/* string validated to be of correct length (but->hardmax) */
@@ -1023,7 +1023,7 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
/* pixel space */
wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f);
- if (!data->noback)
+ if (data->noback == false)
ui_draw_search_back(NULL, NULL, &data->bbox); /* style not used yet */
/* draw text */
@@ -1136,10 +1136,10 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
/* special case, hardcoded feature, not draw backdrop when called from menus,
* assume for design that popup already added it */
if (but->block->flag & UI_BLOCK_SEARCH_MENU)
- data->noback = 1;
+ data->noback = true;
if (but->a1 > 0 && but->a2 > 0) {
- data->preview = 1;
+ data->preview = true;
data->prv_rows = but->a1;
data->prv_cols = but->a2;
}
@@ -2236,7 +2236,7 @@ uiBlock *ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_
{
uiBut *but = arg_but;
uiBlock *block;
- int show_picker = TRUE;
+ bool show_picker = true;
block = uiBeginBlock(C, handle->region, __func__, UI_EMBOSS);
@@ -2703,7 +2703,7 @@ void uiPupMenuInvoke(bContext *C, const char *idname)
uiPopupMenu *pup;
uiLayout *layout;
Menu menu;
- MenuType *mt = WM_menutype_find(idname, TRUE);
+ MenuType *mt = WM_menutype_find(idname, true);
if (mt == NULL) {
printf("%s: named menu \"%s\" not found\n", __func__, idname);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 4b70b6bd63b..dd575dbf522 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -106,7 +106,7 @@ typedef struct TemplateID {
ListBase *idlb;
int prv_rows, prv_cols;
- int preview;
+ bool preview;
} TemplateID;
/* Search browse menu, assign */
@@ -156,7 +156,7 @@ static void id_search_cb(const bContext *C, void *arg_template, const char *str,
iconid = ui_id_icon_get((bContext *)C, id, template->preview);
- if (!uiSearchItemAdd(items, name_ui, id, iconid))
+ if (false == uiSearchItemAdd(items, name_ui, id, iconid))
break;
}
}
@@ -413,13 +413,13 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
type = idptr.type;
if (flag & UI_ID_PREVIEWS) {
- template->preview = TRUE;
+ template->preview = true;
but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6,
TIP_(template_id_browse_tip(type)));
if (type) {
but->icon = RNA_struct_ui_icon(type);
- if (id) but->icon = ui_id_icon_get(C, id, 1);
+ if (id) but->icon = ui_id_icon_get(C, id, true);
uiButSetFlag(but, UI_HAS_ICON | UI_ICON_PREVIEW);
}
if ((idfrom && idfrom->lib) || !editable)
@@ -1217,7 +1217,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
/* Set but-locks for protected settings (magic numbers are used here!) */
if (proxy_protected)
- uiBlockSetButLock(block, 1, IFACE_("Cannot edit Proxy-Protected Constraint"));
+ uiBlockSetButLock(block, true, IFACE_("Cannot edit Proxy-Protected Constraint"));
/* Draw constraint data */
if ((con->flag & CONSTRAINT_EXPAND) == 0) {
@@ -2631,7 +2631,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
sub = uiLayoutRow(overlap, FALSE);
- icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, FALSE);
+ icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, false);
if (icon == ICON_DOT)
icon = ICON_NONE;
draw_item(ui_list, C, sub, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
@@ -2665,7 +2665,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
found = (activei == i);
if (found) {
- icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, FALSE);
+ icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, false);
if (icon == ICON_DOT)
icon = ICON_NONE;
draw_item(ui_list, C, row, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
@@ -2712,7 +2712,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
sub = uiLayoutRow(overlap, FALSE);
- icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, FALSE);
+ icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, false);
draw_item(ui_list, C, sub, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
i++;
@@ -2760,7 +2760,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
}
}
- if (0 == uiSearchItemAdd(items, name, ot, 0))
+ if (false == uiSearchItemAdd(items, name, ot, 0))
break;
}
}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index b5b10b623d2..e5f9e48c3b0 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1349,8 +1349,8 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
/* unlink icon for this button type */
if (but->type == SEARCH_MENU_UNLINK && but->drawstr[0]) {
rcti temp = *rect;
-
- temp.xmin = temp.xmax - BLI_rcti_size_y(rect);
+
+ temp.xmin = temp.xmax - (BLI_rcti_size_y(rect) * 1.08f);
widget_draw_icon(but, ICON_X, alpha, &temp);
}
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index d79f12551dd..a34ca4dcb9e 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -34,6 +34,7 @@
#include "BLF_translation.h"
#include "BKE_context.h"
+#include "BKE_global.h"
#include "BKE_tessmesh.h"
#include "RNA_define.h"
@@ -45,6 +46,7 @@
#include "ED_mesh.h"
#include "ED_numinput.h"
#include "ED_screen.h"
+#include "ED_space_api.h"
#include "ED_transform.h"
#include "ED_view3d.h"
@@ -55,13 +57,17 @@
typedef struct {
BMEditMesh *em;
- BMBackup mesh_backup;
- int mcenter[2];
float initial_length;
float pixel_size; /* use when mouse input is interpreted as spatial distance */
- int is_modal;
+ bool is_modal;
NumInput num_input;
float shift_factor; /* The current factor when shift is pressed. Negative when shift not active. */
+
+ /* modal only */
+ int mcenter[2];
+ BMBackup mesh_backup;
+ void *draw_handle_pixel;
+ short twtype;
} BevelData;
#define HEADER_LENGTH 180
@@ -85,7 +91,7 @@ static void edbm_bevel_update_header(wmOperator *op, bContext *C)
}
}
-static int edbm_bevel_init(bContext *C, wmOperator *op, int is_modal)
+static int edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
{
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BMEdit_FromObject(obedit);
@@ -105,8 +111,16 @@ static int edbm_bevel_init(bContext *C, wmOperator *op, int is_modal)
opdata->num_input.flag = NUM_NO_NEGATIVE;
/* avoid the cost of allocating a bm copy */
- if (is_modal)
+ if (is_modal) {
+ View3D *v3d = CTX_wm_view3d(C);
+ ARegion *ar = CTX_wm_region(C);
+
opdata->mesh_backup = EDBM_redo_state_store(em);
+ opdata->draw_handle_pixel = ED_region_draw_cb_activate(ar->type, ED_region_draw_mouse_line_cb, opdata->mcenter, REGION_DRAW_POST_PIXEL);
+ G.moving = true;
+ opdata->twtype = v3d->twtype;
+ v3d->twtype = 0;
+ }
return 1;
}
@@ -163,7 +177,12 @@ static void edbm_bevel_exit(bContext *C, wmOperator *op)
}
if (opdata->is_modal) {
+ View3D *v3d = CTX_wm_view3d(C);
+ ARegion *ar = CTX_wm_region(C);
EDBM_redo_state_free(&opdata->mesh_backup, NULL, false);
+ ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel);
+ v3d->twtype = opdata->twtype;
+ G.moving = false;
}
MEM_freeN(opdata);
op->customdata = NULL;
diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c
index 10f384f5b7c..f7cf32a074f 100644
--- a/source/blender/editors/mesh/editmesh_inset.c
+++ b/source/blender/editors/mesh/editmesh_inset.c
@@ -34,6 +34,7 @@
#include "BLF_translation.h"
#include "BKE_context.h"
+#include "BKE_global.h"
#include "BKE_tessmesh.h"
#include "RNA_define.h"
@@ -45,6 +46,7 @@
#include "ED_mesh.h"
#include "ED_numinput.h"
#include "ED_screen.h"
+#include "ED_space_api.h"
#include "ED_transform.h"
#include "ED_view3d.h"
@@ -56,16 +58,20 @@
typedef struct {
float old_thickness;
float old_depth;
- int mcenter[2];
- int modify_depth;
+ bool modify_depth;
float initial_length;
float pixel_size; /* use when mouse input is interpreted as spatial distance */
- int is_modal;
- int shift;
+ bool is_modal;
+ bool shift;
float shift_amount;
- BMBackup backup;
BMEditMesh *em;
NumInput num_input;
+
+ /* modal only */
+ int mcenter[2];
+ BMBackup mesh_backup;
+ void *draw_handle_pixel;
+ short twtype;
} InsetData;
@@ -100,7 +106,7 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C)
}
-static int edbm_inset_init(bContext *C, wmOperator *op, int is_modal)
+static int edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal)
{
InsetData *opdata;
Object *obedit = CTX_data_edit_object(C);
@@ -119,8 +125,16 @@ static int edbm_inset_init(bContext *C, wmOperator *op, int is_modal)
initNumInput(&opdata->num_input);
opdata->num_input.idx_max = 1; /* Two elements. */
- if (is_modal)
- opdata->backup = EDBM_redo_state_store(em);
+ if (is_modal) {
+ View3D *v3d = CTX_wm_view3d(C);
+ ARegion *ar = CTX_wm_region(C);
+
+ opdata->mesh_backup = EDBM_redo_state_store(em);
+ opdata->draw_handle_pixel = ED_region_draw_cb_activate(ar->type, ED_region_draw_mouse_line_cb, opdata->mcenter, REGION_DRAW_POST_PIXEL);
+ G.moving = true;
+ opdata->twtype = v3d->twtype;
+ v3d->twtype = 0;
+ }
return 1;
}
@@ -132,8 +146,14 @@ static void edbm_inset_exit(bContext *C, wmOperator *op)
opdata = op->customdata;
- if (opdata->is_modal)
- EDBM_redo_state_free(&opdata->backup, NULL, false);
+ if (opdata->is_modal) {
+ View3D *v3d = CTX_wm_view3d(C);
+ ARegion *ar = CTX_wm_region(C);
+ EDBM_redo_state_free(&opdata->mesh_backup, NULL, false);
+ ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel);
+ v3d->twtype = opdata->twtype;
+ G.moving = false;
+ }
if (sa) {
ED_area_headerprint(sa, NULL);
@@ -147,7 +167,7 @@ static int edbm_inset_cancel(bContext *C, wmOperator *op)
opdata = op->customdata;
if (opdata->is_modal) {
- EDBM_redo_state_free(&opdata->backup, opdata->em, true);
+ EDBM_redo_state_free(&opdata->mesh_backup, opdata->em, true);
EDBM_update_generic(opdata->em, false, true);
}
@@ -176,7 +196,7 @@ static int edbm_inset_calc(wmOperator *op)
em = opdata->em;
if (opdata->is_modal) {
- EDBM_redo_state_restore(opdata->backup, em, false);
+ EDBM_redo_state_restore(opdata->mesh_backup, em, false);
}
EDBM_op_init(em, &bmop, op,
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 5befcd7b5f2..0e4161d232d 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -199,9 +199,9 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
float mval[2], co_proj[3], no_dummy[3];
- int dist_dummy;
+ float dist_px_dummy;
if (ED_view3d_project_float_object(ar, eve->co, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
- if (snapObjectsContext(C, mval, &dist_dummy, co_proj, no_dummy, SNAP_NOT_OBEDIT)) {
+ if (snapObjectsContext(C, mval, &dist_px_dummy, co_proj, no_dummy, SNAP_NOT_OBEDIT)) {
mul_v3_m4v3(eve->co, obedit->imat, co_proj);
}
}
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index b33c7212f0e..d63a964c26a 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1786,8 +1786,8 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
if ((basen->flag & OB_FROMGROUP) || ob->rigidbody_object || ob->rigidbody_constraint) {
Group *group;
for (group = bmain->group.first; group; group = group->id.next) {
- if (object_in_group(ob, group))
- add_to_group(group, obn, scene, basen);
+ if (BKE_group_object_exists(group, ob))
+ BKE_group_object_add(group, obn, scene, basen);
}
}
diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c
index 3112bb21091..8afd3049b84 100644
--- a/source/blender/editors/object/object_group.c
+++ b/source/blender/editors/object/object_group.c
@@ -78,7 +78,7 @@ static EnumPropertyItem *group_object_active_itemf(bContext *C, PointerRNA *UNUS
Group *group = NULL;
int i = 0;
- while ((group = find_group(ob, group))) {
+ while ((group = BKE_group_object_find(group, ob))) {
item_tmp.identifier = item_tmp.name = group->id.name + 2;
/* item_tmp.icon = ICON_ARMATURE_DATA; */
item_tmp.value = i;
@@ -98,7 +98,7 @@ static Group *group_object_active_find_index(Object *ob, const int group_object_
{
Group *group = NULL;
int i = 0;
- while ((group = find_group(ob, group))) {
+ while ((group = BKE_group_object_find(group, ob))) {
if (i == group_object_index) {
break;
}
@@ -125,7 +125,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
{
if (base->object->dup_group != group) {
- add_to_group(group, base->object, scene, base);
+ BKE_group_object_add(group, base->object, scene, base);
}
else {
is_cycle = TRUE;
@@ -184,11 +184,11 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
* looking up the active objects groups each time */
for (group = bmain->group.first; group; group = group->id.next) {
- if (object_in_group(ob, group)) {
+ if (BKE_group_object_exists(group, ob)) {
/* Assign groups to selected objects */
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
{
- rem_from_group(group, base->object, scene, base);
+ BKE_group_object_unlink(group, base->object, scene, base);
ok = 1;
}
CTX_DATA_END;
@@ -265,7 +265,7 @@ static int group_objects_remove_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
{
- rem_from_group(group, base->object, scene, base);
+ BKE_group_object_unlink(group, base->object, scene, base);
}
CTX_DATA_END;
@@ -311,11 +311,11 @@ static int group_create_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "name", name);
- group = add_group(bmain, name);
+ group = BKE_group_add(bmain, name);
CTX_DATA_BEGIN (C, Base *, base, selected_bases)
{
- add_to_group(group, base->object, scene, base);
+ BKE_group_object_add(group, base->object, scene, base);
}
CTX_DATA_END;
@@ -354,8 +354,8 @@ static int group_add_exec(bContext *C, wmOperator *UNUSED(op))
if (ob == NULL)
return OPERATOR_CANCELLED;
- group = add_group(bmain, "Group");
- add_to_group(group, ob, scene, NULL);
+ group = BKE_group_add(bmain, "Group");
+ BKE_group_object_add(group, ob, scene, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -386,7 +386,7 @@ static int group_link_exec(bContext *C, wmOperator *op)
if (ELEM(NULL, ob, group))
return OPERATOR_CANCELLED;
- add_to_group(group, ob, scene, NULL);
+ BKE_group_object_add(group, ob, scene, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -425,7 +425,7 @@ static int group_remove_exec(bContext *C, wmOperator *UNUSED(op))
if (!ob || !group)
return OPERATOR_CANCELLED;
- rem_from_group(group, ob, scene, NULL); /* base will be used if found */
+ BKE_group_object_unlink(group, ob, scene, NULL); /* base will be used if found */
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 34a6d359f6b..cdc920ba3ec 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1486,7 +1486,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
/* now add in the groups from the link nodes */
for (group_node = ob_groups; group_node; group_node = group_node->next) {
if (ob_dst->dup_group != group_node->link) {
- add_to_group(group_node->link, ob_dst, scene, base_dst);
+ BKE_group_object_add(group_node->link, ob_dst, scene, base_dst);
}
else {
is_cycle = TRUE;
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index b7303b2af51..974dc3acef9 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -586,7 +586,7 @@ static short select_grouped_group(bContext *C, Object *ob) /* Select objects in
uiLayout *layout;
for (group = CTX_data_main(C)->group.first; group && group_count < GROUP_MENU_MAX; group = group->id.next) {
- if (object_in_group(ob, group)) {
+ if (BKE_group_object_exists(group, ob)) {
ob_groups[group_count] = group;
group_count++;
}
@@ -598,7 +598,7 @@ static short select_grouped_group(bContext *C, Object *ob) /* Select objects in
group = ob_groups[0];
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
- if (!(base->flag & SELECT) && object_in_group(base->object, group)) {
+ if (!(base->flag & SELECT) && BKE_group_object_exists(group, base->object)) {
ED_base_object_select(base, BA_SELECT);
changed = 1;
}
@@ -1040,7 +1040,7 @@ static int object_select_same_group_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
- if (!(base->flag & SELECT) && object_in_group(base->object, group))
+ if (!(base->flag & SELECT) && BKE_group_object_exists(group, base->object))
ED_base_object_select(base, BA_SELECT);
}
CTX_DATA_END;
diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c
index b3f92d3de46..d38ffa491e2 100644
--- a/source/blender/editors/physics/rigidbody_constraint.c
+++ b/source/blender/editors/physics/rigidbody_constraint.c
@@ -88,14 +88,14 @@ void ED_rigidbody_con_add(wmOperator *op, Scene *scene, Object *ob, int type)
}
/* create constraint group if it doesn't already exits */
if (rbw->constraints == NULL) {
- rbw->constraints = add_group(G.main, "RigidBodyConstraints");
+ rbw->constraints = BKE_group_add(G.main, "RigidBodyConstraints");
}
/* make rigidbody constraint settings */
ob->rigidbody_constraint = BKE_rigidbody_create_constraint(scene, ob, type);
ob->rigidbody_constraint->flag |= RBC_FLAG_NEEDS_VALIDATE;
/* add constraint to rigid body constraint group */
- add_to_group(rbw->constraints, ob, scene, NULL);
+ BKE_group_object_add(rbw->constraints, ob, scene, NULL);
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
}
@@ -106,7 +106,7 @@ void ED_rigidbody_con_remove(Scene *scene, Object *ob)
BKE_rigidbody_remove_constraint(scene, ob);
if (rbw)
- rem_from_group(rbw->constraints, ob, scene, NULL);
+ BKE_group_object_unlink(rbw->constraints, ob, scene, NULL);
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
}
diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c
index 9c03c6173a5..9f981256a31 100644
--- a/source/blender/editors/physics/rigidbody_object.c
+++ b/source/blender/editors/physics/rigidbody_object.c
@@ -111,7 +111,7 @@ void ED_rigidbody_ob_add(wmOperator *op, Scene *scene, Object *ob, int type)
scene->rigidbody_world = rbw;
}
if (rbw->group == NULL) {
- rbw->group = add_group(G.main, "RigidBodyWorld");
+ rbw->group = BKE_group_add(G.main, "RigidBodyWorld");
}
/* make rigidbody object settings */
@@ -122,7 +122,7 @@ void ED_rigidbody_ob_add(wmOperator *op, Scene *scene, Object *ob, int type)
ob->rigidbody_object->flag |= RBO_FLAG_NEEDS_VALIDATE;
/* add object to rigid body group */
- add_to_group(rbw->group, ob, scene, NULL);
+ BKE_group_object_add(rbw->group, ob, scene, NULL);
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
}
@@ -133,7 +133,7 @@ void ED_rigidbody_ob_remove(Scene *scene, Object *ob)
BKE_rigidbody_remove_object(scene, ob);
if (rbw)
- rem_from_group(rbw->group, ob, scene, NULL);
+ BKE_group_object_unlink(rbw->group, ob, scene, NULL);
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
}
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 365ac02d15b..6832cd5baa0 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -143,7 +143,7 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
if (ibuf->rect == NULL)
imb_addrectImBuf(ibuf);
-
+
rectf += 4 * (rr->rectx * ymin + xmin);
IMB_partial_display_buffer_update(ibuf, rectf, NULL, rr->rectx, rxmin, rymin,
@@ -429,10 +429,38 @@ static void render_endjob(void *rjv)
nodeUpdateID(rj->scene->nodetree, &rj->scene->id);
WM_main_add_notifier(NC_NODE | NA_EDITED, rj->scene);
}
-
+
/* XXX render stability hack */
G.is_rendering = FALSE;
WM_main_add_notifier(NC_WINDOW, NULL);
+
+ /* Partial render result will always update display buffer
+ * for first render layer only. This is nice because you'll
+ * see render progress during rendering, but it ends up in
+ * wrong display buffer shown after rendering.
+ *
+ * The code below will mark display buffer as invalid after
+ * rendering in case multiple layers were rendered, which
+ * ensures display buffer matches render layer after
+ * rendering.
+ *
+ * Perhaps proper way would be to toggle active render
+ * layer in image editor and job, so we always display
+ * layer being currently rendered. But this is not so much
+ * trivial at this moment, especially because of external
+ * engine API, so lets use simple and robust way for now
+ * - sergey -
+ */
+ if (rj->scene->r.layers.first != rj->scene->r.layers.last) {
+ void *lock;
+ Image *ima = rj->image;
+ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &rj->iuser, &lock);
+
+ if (ibuf)
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+
+ BKE_image_release_ibuf(ima, ibuf, lock);
+ }
}
/* called by render, check job 'stop' value or the global */
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index f47d737beca..9d443fab552 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -69,6 +69,8 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
#include "GPU_extensions.h"
@@ -261,11 +263,14 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
*/
if (!oglrender->is_sequencer) {
- /* sequencer has got tricker ocnversion happened above */
-
- IMB_buffer_float_from_float(rr->rectf, rr->rectf,
- 4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, TRUE,
- oglrender->sizex, oglrender->sizey, oglrender->sizex, oglrender->sizex);
+ /* sequencer has got trickier conversion happened above
+ * also assume opengl's space matches byte buffer color space
+ */
+ if (!glaBufferTransformFromRole_glsl(rr->rectf, oglrender->sizex, oglrender->sizey, COLOR_ROLE_DEFAULT_BYTE)) {
+ IMB_buffer_float_from_float(rr->rectf, rr->rectf,
+ 4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, TRUE,
+ oglrender->sizex, oglrender->sizey, oglrender->sizex, oglrender->sizex);
+ }
}
/* rr->rectf is now filled with image data */
diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt
index 33373354aa4..c9c4c253e28 100644
--- a/source/blender/editors/screen/CMakeLists.txt
+++ b/source/blender/editors/screen/CMakeLists.txt
@@ -25,6 +25,7 @@ set(INC
../../blenlib
../../blenloader
../../bmesh
+ ../../gpu
../../imbuf
../../makesdna
../../makesrna
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 89315e041de..3469604b3dd 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -42,11 +42,18 @@
#include "BLI_threads.h"
#include "BKE_blender.h"
+#include "BKE_global.h"
#include "BKE_colortools.h"
+#include "BKE_context.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
+#include "GPU_extensions.h"
+
+#include "IMB_colormanagement.h"
+#include "IMB_imbuf_types.h"
+
#ifndef GL_CLAMP_TO_EDGE
#define GL_CLAMP_TO_EDGE 0x812F
#endif
@@ -482,7 +489,7 @@ static int get_cached_work_texture(int *w_r, int *h_r)
return texid;
}
-void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int zoomfilter, void *rect, float scaleX, float scaleY)
+void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY)
{
unsigned char *uc_rect = (unsigned char *) rect;
float *f_rect = (float *)rect;
@@ -492,7 +499,8 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format,
int subpart_x, subpart_y, tex_w, tex_h;
int seamless, offset_x, offset_y, nsubparts_x, nsubparts_y;
int texid = get_cached_work_texture(&tex_w, &tex_h);
-
+ int components;
+
/* Specify the color outside this function, and tex will modulate it.
* This is useful for changing alpha without using glPixelTransferf()
*/
@@ -519,13 +527,24 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format,
nsubparts_x = (img_w + (offset_x - 1)) / (offset_x);
nsubparts_y = (img_h + (offset_y - 1)) / (offset_y);
- if (format == GL_FLOAT) {
+ if (format == GL_RGBA)
+ components = 4;
+ else if (format == GL_RGB)
+ components = 3;
+ else if (format == GL_LUMINANCE)
+ components = 1;
+ else {
+ BLI_assert(!"Incompatible format passed to glaDrawPixelsTexScaled");
+ return;
+ }
+
+ if (type == GL_FLOAT) {
/* need to set internal format to higher range float */
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, tex_w, tex_h, 0, GL_RGBA, GL_FLOAT, NULL);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, tex_w, tex_h, 0, format, GL_FLOAT, NULL);
}
else {
/* switch to 8bit RGBA for byte buffer */
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tex_w, tex_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tex_w, tex_h, 0, format, GL_UNSIGNED_BYTE, NULL);
}
for (subpart_y = 0; subpart_y < nsubparts_y; subpart_y++) {
@@ -545,26 +564,26 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format,
if (subpart_w <= seamless || subpart_h <= seamless)
continue;
- if (format == GL_FLOAT) {
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_FLOAT, &f_rect[subpart_y * offset_y * img_w * 4 + subpart_x * offset_x * 4]);
+ if (type == GL_FLOAT) {
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, format, GL_FLOAT, &f_rect[subpart_y * offset_y * img_w * components + subpart_x * offset_x * components]);
/* add an extra border of pixels so linear looks ok at edges of full image. */
if (subpart_w < tex_w)
- glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, GL_RGBA, GL_FLOAT, &f_rect[subpart_y * offset_y * img_w * 4 + (subpart_x * offset_x + subpart_w - 1) * 4]);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, format, GL_FLOAT, &f_rect[subpart_y * offset_y * img_w * components + (subpart_x * offset_x + subpart_w - 1) * components]);
if (subpart_h < tex_h)
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, subpart_h, subpart_w, 1, GL_RGBA, GL_FLOAT, &f_rect[(subpart_y * offset_y + subpart_h - 1) * img_w * 4 + subpart_x * offset_x * 4]);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, subpart_h, subpart_w, 1, format, GL_FLOAT, &f_rect[(subpart_y * offset_y + subpart_h - 1) * img_w * components + subpart_x * offset_x * components]);
if (subpart_w < tex_w && subpart_h < tex_h)
- glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, GL_RGBA, GL_FLOAT, &f_rect[(subpart_y * offset_y + subpart_h - 1) * img_w * 4 + (subpart_x * offset_x + subpart_w - 1) * 4]);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, format, GL_FLOAT, &f_rect[(subpart_y * offset_y + subpart_h - 1) * img_w * components + (subpart_x * offset_x + subpart_w - 1) * components]);
}
else {
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[subpart_y * offset_y * img_w * 4 + subpart_x * offset_x * 4]);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, format, GL_UNSIGNED_BYTE, &uc_rect[subpart_y * offset_y * img_w * components + subpart_x * offset_x * components]);
if (subpart_w < tex_w)
- glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[subpart_y * offset_y * img_w * 4 + (subpart_x * offset_x + subpart_w - 1) * 4]);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, format, GL_UNSIGNED_BYTE, &uc_rect[subpart_y * offset_y * img_w * components + (subpart_x * offset_x + subpart_w - 1) * components]);
if (subpart_h < tex_h)
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, subpart_h, subpart_w, 1, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[(subpart_y * offset_y + subpart_h - 1) * img_w * 4 + subpart_x * offset_x * 4]);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, subpart_h, subpart_w, 1, format, GL_UNSIGNED_BYTE, &uc_rect[(subpart_y * offset_y + subpart_h - 1) * img_w * components + subpart_x * offset_x * components]);
if (subpart_w < tex_w && subpart_h < tex_h)
- glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[(subpart_y * offset_y + subpart_h - 1) * img_w * 4 + (subpart_x * offset_x + subpart_w - 1) * 4]);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, format, GL_UNSIGNED_BYTE, &uc_rect[(subpart_y * offset_y + subpart_h - 1) * img_w * components + (subpart_x * offset_x + subpart_w - 1) * components]);
}
glEnable(GL_TEXTURE_2D);
@@ -595,9 +614,9 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format,
#endif
}
-void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, int zoomfilter, void *rect)
+void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect)
{
- glaDrawPixelsTexScaled(x, y, img_w, img_h, format, zoomfilter, rect, 1.0f, 1.0f);
+ glaDrawPixelsTexScaled(x, y, img_w, img_h, format, type, zoomfilter, rect, 1.0f, 1.0f);
}
void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int format, int type, void *rect)
@@ -680,7 +699,7 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo
}
/* uses either DrawPixelsSafe or DrawPixelsTex, based on user defined maximum */
-void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, int zoomfilter, void *rect)
+void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect)
{
if (U.image_gpubuffer_limit) {
/* Megapixels, use float math to prevent overflow */
@@ -688,11 +707,11 @@ void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, int z
if (U.image_gpubuffer_limit > (int)img_size) {
glColor4f(1.0, 1.0, 1.0, 1.0);
- glaDrawPixelsTex(x, y, img_w, img_h, format, zoomfilter, rect);
+ glaDrawPixelsTex(x, y, img_w, img_h, format, type, zoomfilter, rect);
return;
}
}
- glaDrawPixelsSafe(x, y, img_w, img_h, img_w, GL_RGBA, format, rect);
+ glaDrawPixelsSafe(x, y, img_w, img_h, img_w, format, type, rect);
}
/* 2D Drawing Assistance */
@@ -753,6 +772,18 @@ void gla2DSetMap(gla2DDrawInfo *di, rctf *rect)
di->wo_to_sc[1] = sc_h / wo_h;
}
+/** Save the current OpenGL state and initialize OpenGL for 2D
+ * rendering. glaEnd2DDraw should be called on the returned structure
+ * to free it and to return OpenGL to its previous state. The
+ * scissor rectangle is set to match the viewport.
+ *
+ * See glaDefine2DArea for an explanation of why this function uses integers.
+ *
+ * \param screen_rect The screen rectangle to be used for 2D drawing.
+ * \param world_rect The world rectangle that the 2D area represented
+ * by \a screen_rect is supposed to represent. If NULL it is assumed the
+ * world has a 1 to 1 mapping to the screen.
+ */
gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect)
{
gla2DDrawInfo *di = MEM_mallocN(sizeof(*di), "gla2DDrawInfo");
@@ -788,17 +819,27 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect)
return di;
}
+/**
+ * Translate the (\a wo_x, \a wo_y) point from world coordinates into screen space.
+ */
void gla2DDrawTranslatePt(gla2DDrawInfo *di, float wo_x, float wo_y, int *sc_x_r, int *sc_y_r)
{
*sc_x_r = (wo_x - di->world_rect.xmin) * di->wo_to_sc[0];
*sc_y_r = (wo_y - di->world_rect.ymin) * di->wo_to_sc[1];
}
+
+/**
+ * Translate the \a world point from world coordiantes into screen space.
+ */
void gla2DDrawTranslatePtv(gla2DDrawInfo *di, float world[2], int screen_r[2])
{
screen_r[0] = (world[0] - di->world_rect.xmin) * di->wo_to_sc[0];
screen_r[1] = (world[1] - di->world_rect.ymin) * di->wo_to_sc[1];
}
+/**
+ * Restores the previous OpenGL state and free's the auxilary gla data.
+ */
void glaEnd2DDraw(gla2DDrawInfo *di)
{
glViewport(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]);
@@ -983,3 +1024,163 @@ void bglFlush(void)
#endif
}
#endif
+
+/* **** Color management helper functions for GLSL display/transform ***** */
+
+/* Draw given image buffer on a screen using GLSL for display transform */
+void glaDrawImBuf_glsl_ctx(const bContext *C, ImBuf *ibuf, float x, float y, int zoomfilter)
+{
+ bool force_fallback = false;
+ bool need_fallback = true;
+
+ /* Early out */
+ if (ibuf->rect == NULL && ibuf->rect_float == NULL)
+ return;
+
+ /* Dithering is not supported on GLSL yet */
+ force_fallback = ibuf->dither != 0.0f;
+
+ /* Single channel images could not be transformed using GLSL yet */
+ force_fallback = ibuf->channels == 1;
+
+ /* This is actually lots of crap, but currently not sure about
+ * more clear way to bypass partial buffer update crappyness
+ * while rendering.
+ *
+ * The thing is -- render engines are only updating byte and
+ * display buffers for active render result opened in image
+ * editor. This works fine to show render progress without
+ * switching render layers in image editor user, but this is
+ * completely useless for GLSL display, where we need to have
+ * original buffer which we could color manage.
+ *
+ * For the time of rendering, we'll stick back to slower CPU
+ * display buffer update. GLSL could be used as soon as some
+ * fixes (?) are done in render itself, so we'll always have
+ * image buffer with relevant float buffer opened while
+ * rendering.
+ *
+ * On the other hand, when using Cycles, stressing GPU with
+ * GLSL could backfire on a performance.
+ * - sergey -
+ */
+ if (G.is_rendering) {
+ /* Try to detect whether we're drawing render result,
+ * other images could have both rect and rect_float
+ * but they'll be synchronized
+ */
+ if (ibuf->rect_float && ibuf->rect &&
+ ((ibuf->mall & IB_rectfloat) == 0))
+ {
+ force_fallback = true;
+ }
+ }
+
+ /* Try to draw buffer using GLSL display transform */
+ if (force_fallback == false) {
+ int ok;
+
+ if (ibuf->rect_float)
+ ok = IMB_colormanagement_setup_glsl_draw_ctx(C, TRUE);
+ else
+ ok = IMB_colormanagement_setup_glsl_draw_from_space_ctx(C, ibuf->rect_colorspace, FALSE);
+
+ if (ok) {
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ glColor4f(1.0, 1.0, 1.0, 1.0);
+
+ if (ibuf->rect_float) {
+ int format = 0;
+
+ if (ibuf->channels == 3)
+ format = GL_RGB;
+ else if (ibuf->channels == 4)
+ format = GL_RGBA;
+ else
+ BLI_assert(!"Incompatible number of channels for GLSL display");
+
+ if (format != 0) {
+ glaDrawPixelsTex(x, y, ibuf->x, ibuf->y, format, GL_FLOAT,
+ zoomfilter, ibuf->rect_float);
+ }
+ }
+ else if (ibuf->rect) {
+ /* ibuf->rect is always RGBA */
+ glaDrawPixelsTex(x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE,
+ zoomfilter, ibuf->rect);
+ }
+
+ IMB_colormanagement_finish_glsl_draw();
+
+ need_fallback = false;
+ }
+ }
+
+ /* In case GLSL failed or not usable, fallback to glaDrawPixelsAuto */
+ if (need_fallback) {
+ unsigned char *display_buffer;
+ void *cache_handle;
+
+ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
+
+ if (display_buffer)
+ glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE,
+ zoomfilter, display_buffer);
+
+ IMB_display_buffer_release(cache_handle);
+ }
+}
+
+/* Transform buffer from role to scene linear space using GLSL OCIO conversion
+ *
+ * See IMB_colormanagement_setup_transform_from_role_glsl description for
+ * some more details
+ *
+ * NOTE: this only works for RGBA buffers!
+ */
+int glaBufferTransformFromRole_glsl(float *buffer, int width, int height, int role)
+{
+ GPUOffScreen *ofs;
+ char err_out[256];
+ rcti display_rect;
+
+ ofs = GPU_offscreen_create(width, height, err_out);
+
+ if (!ofs)
+ return FALSE;
+
+ GPU_offscreen_bind(ofs);
+
+ if (!IMB_colormanagement_setup_transform_from_role_glsl(role, TRUE)) {
+ GPU_offscreen_unbind(ofs);
+ GPU_offscreen_free(ofs);
+ return FALSE;
+ }
+
+ BLI_rcti_init(&display_rect, 0, width, 0, height);
+
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+
+ glaDefine2DArea(&display_rect);
+
+ glaDrawPixelsTex(0, 0, width, height, GL_RGBA, GL_FLOAT,
+ GL_NEAREST, buffer);
+
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+
+ GPU_offscreen_read_pixels(ofs, GL_FLOAT, buffer);
+
+ IMB_colormanagement_finish_glsl_transform();
+
+ /* unbind */
+ GPU_offscreen_unbind(ofs);
+ GPU_offscreen_free(ofs);
+
+ return TRUE;
+}
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index cd9523f8ff6..40a18734948 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -62,7 +62,7 @@ static int brush_add_exec(bContext *C, wmOperator *UNUSED(op))
{
/*int type = RNA_enum_get(op->ptr, "type");*/
Paint *paint = paint_get_active_from_context(C);
- struct Brush *br = paint_brush(paint);
+ Brush *br = paint_brush(paint);
Main *bmain = CTX_data_main(C);
if (br)
@@ -94,7 +94,7 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Paint *paint = paint_get_active_from_context(C);
- struct Brush *brush = paint_brush(paint);
+ Brush *brush = paint_brush(paint);
// Object *ob = CTX_data_active_object(C);
float scalar = RNA_float_get(op->ptr, "scalar");
@@ -176,10 +176,10 @@ static void PAINT_OT_vertex_color_set(wmOperatorType *ot)
static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
{
Paint *paint = paint_get_active_from_context(C);
- struct Brush *brush = paint_brush(paint);
+ Brush *brush = paint_brush(paint);
Object *ob = CTX_data_active_object(C);
- if (!ob) return OPERATOR_CANCELLED;
+ if (!ob || !brush) return OPERATOR_CANCELLED;
if (ob->mode & OB_MODE_SCULPT)
BKE_brush_sculpt_reset(brush);
@@ -215,7 +215,7 @@ static void brush_tool_set(const Brush *brush, size_t tool_offset, int tool)
/* generic functions for setting the active brush based on the tool */
static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, const size_t tool_offset, const int ob_mode)
{
- struct Brush *brush;
+ Brush *brush;
if (!brush_orig && !(brush_orig = bmain->brush.first)) {
return NULL;
@@ -266,7 +266,7 @@ static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool,
const char *tool_name, int create_missing,
int toggle)
{
- struct Brush *brush, *brush_orig = paint_brush(paint);
+ Brush *brush, *brush_orig = paint_brush(paint);
if (toggle)
brush = brush_tool_toggle(bmain, brush_orig, tool, tool_offset, ob_mode);
@@ -467,7 +467,7 @@ typedef struct {
static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Paint *paint = paint_get_active_from_context(C);
- Brush *br = paint->brush;
+ Brush *br = paint_brush(paint);
int mdiff[2];
StencilControlData *scd = MEM_mallocN(sizeof(StencilControlData), "stencil_control");
@@ -520,7 +520,7 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve
float len, factor;
sub_v2_v2v2_int(mdiff, event->mval, scd->br->stencil_pos);
len = sqrtf(mdiff[0] * mdiff[0] + mdiff[1] * mdiff[1]);
- factor = len/scd->lenorig;
+ factor = len / scd->lenorig;
mdiff[0] = factor * scd->init_sdim[0];
mdiff[1] = factor * scd->init_sdim[1];
copy_v2_v2_int(scd->br->stencil_dimension, mdiff);
@@ -567,15 +567,15 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve
static int stencil_control_poll(bContext *C)
{
Paint *paint = paint_get_active_from_context(C);
- Brush *br = paint->brush;
+ Brush *br = paint_brush(paint);
- return br->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL;
+ return (br && br->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL);
}
static void BRUSH_OT_stencil_control(wmOperatorType *ot)
{
static EnumPropertyItem stencil_control_items[] = {
- {STENCIL_TRANSLATE, "TRANSLATION", 0, "Transation", ""},
+ {STENCIL_TRANSLATE, "TRANSLATION", 0, "Translation", ""},
{STENCIL_SCALE, "SCALE", 0, "Scale", ""},
{STENCIL_ROTATE, "ROTATION", 0, "Rotation", ""},
{0, NULL, 0, NULL, NULL}
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 47e20bcc5fb..315fdd2fb32 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -381,7 +381,9 @@ void paint_sample_color(const bContext *C, ARegion *ar, int x, int y) /* fron
static int brush_curve_preset_exec(bContext *C, wmOperator *op)
{
Brush *br = paint_brush(paint_get_active_from_context(C));
- BKE_brush_curve_preset(br, RNA_enum_get(op->ptr, "shape"));
+
+ if (br)
+ BKE_brush_curve_preset(br, RNA_enum_get(op->ptr, "shape"));
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 82a07c9e3be..1060999e13f 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -54,8 +54,6 @@ struct SculptUndoNode;
/* Interface */
struct MultiresModifierData *sculpt_multires_active(struct Scene *scene, struct Object *ob);
-void sculpt(struct Sculpt *sd);
-
int sculpt_mode_poll(struct bContext *C);
int sculpt_mode_poll_view3d(struct bContext *C);
int sculpt_poll(struct bContext *C);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index b6d2d31f0ad..eb755e162a3 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -277,7 +277,7 @@ static void borderselect_action(bAnimContext *ac, rcti rect, short mode, short s
Mask *mask = ale->data;
MaskLayer *masklay;
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- ED_masklayer_frames_select_border(ale->data, rectf.xmin, rectf.xmax, selectmode);
+ ED_masklayer_frames_select_border(masklay, rectf.xmin, rectf.xmax, selectmode);
}
break;
}
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c
index b108f9fa4b5..5a7d70d279c 100644
--- a/source/blender/editors/space_buttons/buttons_texture.c
+++ b/source/blender/editors/space_buttons/buttons_texture.c
@@ -205,7 +205,6 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
/* particle systems */
if (psys) {
- /* todo: these slots are not in the UI */
for (a = 0; a < MAX_MTEX; a++) {
mtex = psys->part->mtex[a];
@@ -333,6 +332,17 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg)
tex = (RNA_struct_is_a(texptr.type, &RNA_Texture)) ? texptr.data : NULL;
ct->texture = tex;
+
+ if (user->ptr.type == &RNA_ParticleSettingsTextureSlot) {
+ /* stupid exception for particle systems which still uses influence
+ * from the old texture system, set the active texture slots as well */
+ ParticleSettings *part = user->ptr.id.data;
+ int a;
+
+ for (a = 0; a < MAX_MTEX; a++)
+ if (user->ptr.data == part->mtex[a])
+ part->texact = a;
+ }
}
ct->user = user;
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index cbca2f0c46e..1000aced3a9 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -248,53 +248,6 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar)
ED_region_info_draw(ar, str, block, 0.6f);
}
-static void draw_movieclip_buffer_glsl(SpaceClip *sc, ImBuf *ibuf, int x, int y,
- float zoomx, float zoomy)
-{
- MovieClip *clip = ED_space_clip_get_clip(sc);
- int filter = GL_LINEAR;
-
- glPushMatrix();
- glTranslatef(x, y, 0.0f);
- glScalef(zoomx, zoomy, 1.0f);
-
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- glColor4f(1.0, 1.0, 1.0, 1.0);
-
- /* non-scaled proxy shouldn;t use diltering */
- if ((clip->flag & MCLIP_USE_PROXY) == 0 ||
- ELEM(sc->user.render_size, MCLIP_PROXY_RENDER_SIZE_FULL, MCLIP_PROXY_RENDER_SIZE_100))
- {
- filter = GL_NEAREST;
- }
-
- glaDrawPixelsTex(0, 0, ibuf->x, ibuf->y, GL_FLOAT, filter, ibuf->rect_float);
-
- glPopMatrix();
-}
-
-static void draw_movieclip_buffer_fallback(const bContext *C, ImBuf *ibuf, int x, int y,
- int width, int height, float zoomx, float zoomy)
-{
- unsigned char *display_buffer;
- void *cache_handle;
-
- display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
-
- if (display_buffer) {
- /* set zoom */
- glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y);
-
- glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer);
-
- /* reset zoom */
- glPixelZoom(1.0f, 1.0f);
- }
-
- IMB_display_buffer_release(cache_handle);
-}
-
static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
int width, int height, float zoomx, float zoomy)
{
@@ -308,7 +261,8 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar,
glRectf(x, y, x + zoomx * width, y + zoomy * height);
}
else {
- bool need_fallback = true;
+ MovieClip *clip = ED_space_clip_get_clip(sc);
+ int filter = GL_LINEAR;
/* checkerboard for case alpha */
if (ibuf->planes == 32) {
@@ -318,19 +272,20 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar,
fdrawcheckerboard(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y);
}
- /* GLSL display transform for byte buffers is not supported yet */
- if (ibuf->rect_float && IMB_coloemanagement_setup_glsl_draw_from_ctx(C)) {
- draw_movieclip_buffer_glsl(sc, ibuf, x, y, zoomx, zoomy);
+ /* non-scaled proxy shouldn't use filtering */
+ if ((clip->flag & MCLIP_USE_PROXY) == 0 ||
+ ELEM(sc->user.render_size, MCLIP_PROXY_RENDER_SIZE_FULL, MCLIP_PROXY_RENDER_SIZE_100))
+ {
+ filter = GL_NEAREST;
+ }
- IMB_coloemanagement_finish_glsl_draw();
+ /* set zoom */
+ glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y);
- need_fallback = false;
- }
+ glaDrawImBuf_glsl_ctx(C, ibuf, x, y, filter);
- /* if GLSL display failed, fallback to regular glaDrawPixelsAuto method */
- if (need_fallback) {
- draw_movieclip_buffer_fallback(C, ibuf, x, y, width, height, zoomx, zoomy);
- }
+ /* reset zoom */
+ glPixelZoom(1.0f, 1.0f);
if (ibuf->planes == 32)
glDisable(GL_BLEND);
@@ -1501,8 +1456,6 @@ void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar)
if (ibuf) {
draw_movieclip_buffer(C, sc, ar, ibuf, width, height, zoomx, zoomy);
IMB_freeImBuf(ibuf);
-
- clip_start_prefetch_job(C);
}
else {
ED_region_grid_draw(ar, zoomx, zoomy);
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index d297d0485e3..08d0af817a8 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -528,6 +528,7 @@ MovieClip *ED_space_clip_get_clip(SpaceClip *sc)
void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *clip)
{
MovieClip *old_clip;
+ bool old_clip_visible = false;
if (!screen && C)
screen = CTX_wm_screen(C);
@@ -546,9 +547,15 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl
if (sl->spacetype == SPACE_CLIP) {
SpaceClip *cur_sc = (SpaceClip *) sl;
- if (cur_sc != sc && cur_sc->view != SC_VIEW_CLIP) {
- if (cur_sc->clip == old_clip || cur_sc->clip == NULL) {
- cur_sc->clip = clip;
+ if (cur_sc != sc) {
+ if (cur_sc->view == SC_VIEW_CLIP) {
+ if (cur_sc->clip == old_clip)
+ old_clip_visible = true;
+ }
+ else {
+ if (cur_sc->clip == old_clip || cur_sc->clip == NULL) {
+ cur_sc->clip = clip;
+ }
}
}
}
@@ -556,6 +563,11 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl
}
}
+ /* If clip is no longer visible on screen, free memory used by it's cache */
+ if (old_clip && old_clip != clip && !old_clip_visible) {
+ BKE_movieclip_clear_cache(old_clip);
+ }
+
if (C)
WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip);
}
@@ -605,26 +617,9 @@ typedef struct PrefetchThread {
} PrefetchThread;
/* check whether pre-fetching is allowed */
-static bool check_prefetch_allowed(void)
+static bool check_prefetch_break(void)
{
- wmWindowManager *wm;
-
- /* if there's any job started, better to leave all CPU and
- * HDD bandwidth to it
- *
- * also, display transform could be needed during playback,
- * so better to avoid prefetching in this case and reserve
- * all the power for display transform
- */
- for (wm = G.main->wm.first; wm; wm = wm->id.next) {
- if (WM_jobs_has_running_except(wm, WM_JOB_TYPE_CLIP_PREFETCH))
- return false;
-
- if (ED_screen_animation_playing(wm))
- return false;
- }
-
- return true;
+ return G.is_break;
}
/* read file for specified frame number to the memory */
@@ -706,7 +701,7 @@ static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip
unsigned char *mem = NULL;
BLI_spin_lock(&queue->spin);
- if (!*queue->stop && check_prefetch_allowed() &&
+ if (!*queue->stop && !check_prefetch_break() &&
IN_RANGE_INCL(queue->current_frame, queue->start_frame, queue->end_frame))
{
int current_frame;
@@ -848,7 +843,7 @@ static bool prefetch_movie_frame(MovieClip *clip, int frame, short render_size,
MovieClipUser user = {0};
ImBuf *ibuf;
- if (!check_prefetch_allowed() || *stop)
+ if (check_prefetch_break() || *stop)
return false;
user.framenr = frame;
@@ -968,26 +963,6 @@ static bool prefetch_check_early_out(const bContext *C)
int first_uncached_frame, end_frame;
int clip_len;
- if (clip->prefetch_ok)
- return true;
-
- if (clip->source == MCLIP_SRC_MOVIE) {
- /* for movies we only prefetch undistorted proxy,
- * in other cases prefetching could lead to issues
- * due to timecodes issues.
- */
-
- if (clip->flag & MCLIP_USE_PROXY) {
- MovieClipUser *user = &sc->user;
-
- if ((user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT) == 0)
- return true;
- }
- else {
- return true;
- }
- }
-
clip_len = BKE_movieclip_get_duration(clip);
/* check whether all the frames from prefetch range are cached */
@@ -1016,7 +991,6 @@ void clip_start_prefetch_job(const bContext *C)
wmJob *wm_job;
PrefetchJob *pj;
SpaceClip *sc = CTX_wm_space_clip(C);
- MovieClip *clip = ED_space_clip_get_clip(sc);
if (prefetch_check_early_out(C))
return;
@@ -1024,17 +998,6 @@ void clip_start_prefetch_job(const bContext *C)
wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), CTX_wm_area(C), "Prefetching",
WM_JOB_PROGRESS, WM_JOB_TYPE_CLIP_PREFETCH);
- if (WM_jobs_is_running(wm_job)) {
- /* if job is already running, it'll call clip editor redraw when
- * it's finished, so cache line is nicely updated
- * this will also trigger call of this function, which will ensure
- * all needed frames are prefetched
- */
- return;
- }
-
- clip->prefetch_ok = true;
-
/* create new job */
pj = MEM_callocN(sizeof(PrefetchJob), "prefetch job");
pj->clip = ED_space_clip_get_clip(sc);
@@ -1045,9 +1008,11 @@ void clip_start_prefetch_job(const bContext *C)
pj->render_flag = sc->user.render_flag;
WM_jobs_customdata_set(wm_job, pj, prefetch_freejob);
- WM_jobs_timer(wm_job, 0.2, NC_MOVIECLIP, 0);
+ WM_jobs_timer(wm_job, 0.2, NC_MOVIECLIP | ND_DISPLAY, 0);
WM_jobs_callbacks(wm_job, prefetch_startjob, NULL, NULL, NULL);
+ G.is_break = FALSE;
+
/* and finally start the job */
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h
index 99222ec63ac..3d589ff120c 100644
--- a/source/blender/editors/space_clip/clip_intern.h
+++ b/source/blender/editors/space_clip/clip_intern.h
@@ -108,6 +108,8 @@ void CLIP_OT_mode_set(struct wmOperatorType *ot);
void CLIP_OT_view_ndof(struct wmOperatorType *ot);
+void CLIP_OT_prefetch(struct wmOperatorType *ot);
+
/* clip_toolbar.c */
struct ARegion *ED_clip_has_properties_region(struct ScrArea *sa);
void CLIP_OT_tools(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 8e03691e64f..ab00c078226 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -1378,6 +1378,47 @@ void CLIP_OT_view_ndof(wmOperatorType *ot)
ot->invoke = clip_view_ndof_invoke;
}
+/********************** Prefetch operator *********************/
+
+static int clip_prefetch_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
+{
+ /* no running blender, remove handler and pass through */
+ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_CLIP_PREFETCH))
+ return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
+
+ /* running render */
+ switch (event->type) {
+ case ESCKEY:
+ return OPERATOR_RUNNING_MODAL;
+ break;
+ }
+
+ return OPERATOR_PASS_THROUGH;
+}
+
+static int clip_prefetch_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(_event))
+{
+ clip_start_prefetch_job(C);
+
+ /* add modal handler for ESC */
+ WM_event_add_modal_handler(C, op);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void CLIP_OT_prefetch(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Prefetch Frames";
+ ot->idname = "CLIP_OT_prefetch";
+ ot->description = "Prefetch frames from disk for faster playback/tracking";
+
+ /* api callbacks */
+ ot->poll = ED_space_clip_view_clip_poll;
+ ot->invoke = clip_prefetch_invoke;
+ ot->modal = clip_prefetch_modal;
+}
+
/********************** macroses *********************/
void ED_operatormacros_clip(void)
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 64b643f8a58..96e127cfde6 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -236,16 +236,6 @@ static void clip_stabilization_tag_refresh(ScrArea *sa)
}
}
-static void clip_prefetch_tag_refresh(ScrArea *sa)
-{
- SpaceClip *sc = (SpaceClip *) sa->spacedata.first;
- MovieClip *clip = ED_space_clip_get_clip(sc);
-
- if (clip) {
- clip->prefetch_ok = FALSE;
- }
-}
-
/* ******************** default callbacks for clip space ***************** */
static SpaceLink *clip_new(const bContext *C)
@@ -358,7 +348,6 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
switch (wmn->data) {
case ND_FRAME:
clip_scopes_tag_refresh(sa);
- clip_prefetch_tag_refresh(sa);
/* no break! */
case ND_FRAME_RANGE:
@@ -367,19 +356,11 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
}
break;
case NC_MOVIECLIP:
- if (wmn->data == 0 && wmn->action == 0) {
- /* a nit funky, happens from prefetch job to update
- * cache line and job progress
- */
- ED_area_tag_redraw(sa);
- }
-
switch (wmn->data) {
case ND_DISPLAY:
case ND_SELECT:
clip_scopes_tag_refresh(sa);
ED_area_tag_redraw(sa);
- clip_prefetch_tag_refresh(sa);
break;
}
switch (wmn->action) {
@@ -423,7 +404,6 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
case NC_SCREEN:
switch (wmn->data) {
case ND_ANIMPLAY:
- clip_prefetch_tag_refresh(sa);
ED_area_tag_redraw(sa);
break;
}
@@ -432,7 +412,6 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
if (wmn->data == ND_SPACE_CLIP) {
clip_scopes_tag_refresh(sa);
clip_stabilization_tag_refresh(sa);
- clip_prefetch_tag_refresh(sa);
ED_area_tag_redraw(sa);
}
break;
@@ -442,10 +421,6 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
ED_area_tag_redraw(sa);
}
break;
- case NC_WM:
- if (wmn->data == ND_FILEREAD)
- clip_prefetch_tag_refresh(sa);
- break;
}
}
@@ -465,6 +440,7 @@ static void clip_operatortypes(void)
WM_operatortype_append(CLIP_OT_rebuild_proxy);
WM_operatortype_append(CLIP_OT_mode_set);
WM_operatortype_append(CLIP_OT_view_ndof);
+ WM_operatortype_append(CLIP_OT_prefetch);
/* ** clip_toolbar.c ** */
WM_operatortype_append(CLIP_OT_tools);
@@ -598,6 +574,9 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "CLIP_OT_set_solver_keyframe", EKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "keyframe", 1);
+ /* io/playback */
+ WM_keymap_add_item(keymap, "CLIP_OT_prefetch", PKEY, KM_PRESS, 0, 0);
+
/* ******** Hotkeys avalaible for main region only ******** */
keymap = WM_keymap_find(keyconf, "Clip Editor", SPACE_CLIP, 0);
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 1c677d7c006..4a0665d663e 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -376,7 +376,7 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int
/* the image */
glColor4f(1.0, 1.0, 1.0, 1.0);
- glaDrawPixelsTexScaled((float)xco, (float)yco, imb->x, imb->y, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect, scale, scale);
+ glaDrawPixelsTexScaled((float)xco, (float)yco, imb->x, imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect, scale, scale);
/* border */
if (dropshadow) {
@@ -538,7 +538,7 @@ void file_draw_list(const bContext *C, ARegion *ar)
uiButSetRenameFunc(but, renamebutton_cb, file);
uiButSetFlag(but, UI_BUT_NO_UTF8); /* allow non utf8 names */
uiButClearFlag(but, UI_BUT_UNDO);
- if (0 == uiButActiveOnly(C, ar, block, but)) {
+ if (false == uiButActiveOnly(C, ar, block, but)) {
file->selflag &= ~EDITING_FILE;
}
}
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index f27a99ac44b..7fc83809b60 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -505,9 +505,6 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float);
}
else {
- unsigned char *display_buffer;
- void *cache_handle;
-
if (sima->flag & SI_USE_ALPHA) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -515,12 +512,7 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
fdrawcheckerboard(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy);
}
- display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
-
- if (display_buffer)
- glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer);
-
- IMB_display_buffer_release(cache_handle);
+ glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST);
if (sima->flag & SI_USE_ALPHA)
glDisable(GL_BLEND);
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 761becdbf8e..1b4ff44bb6b 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -435,6 +435,12 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
/* context changes */
switch (wmn->category) {
+ case NC_WINDOW:
+ /* notifier comes from editing color space */
+ image_scopes_tag_refresh(sa);
+ ED_area_tag_refresh(sa);
+ ED_area_tag_redraw(sa);
+ break;
case NC_SCENE:
switch (wmn->data) {
case ND_FRAME:
@@ -801,11 +807,15 @@ static void image_scope_area_draw(const bContext *C, ARegion *ar)
Scene *scene = CTX_data_scene(C);
void *lock;
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
+
if (ibuf) {
if (!sima->scopes.ok) {
BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings);
}
- scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings);
+ if (sima->image->flag & IMA_VIEW_AS_RENDER)
+ scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings);
+ else
+ scopes_update(&sima->scopes, ibuf, NULL, &scene->display_settings);
}
ED_space_image_release_buffer(sima, ibuf, lock);
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 5e5b2ece8c9..d7206c9b111 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3011,7 +3011,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glPixelZoom(snode->zoom, snode->zoom);
- glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer);
+ glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer);
glPixelZoom(1.0f, 1.0f);
glDisable(GL_BLEND);
@@ -3019,7 +3019,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
else {
glPixelZoom(snode->zoom, snode->zoom);
- glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer);
+ glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer);
glPixelZoom(1.0f, 1.0f);
}
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index f1915a82f69..39b12b321dd 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -710,7 +710,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
glColor4f(1.0, 1.0, 1.0, 1.0);
glPixelZoom(scale, scale);
- glaDrawPixelsTex(draw_rect.xmin, draw_rect.ymin, preview->xsize, preview->ysize, GL_UNSIGNED_BYTE, GL_LINEAR, preview->rect);
+ glaDrawPixelsTex(draw_rect.xmin, draw_rect.ymin, preview->xsize, preview->ysize, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, preview->rect);
glPixelZoom(1.0f, 1.0f);
glDisable(GL_BLEND);
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index cba807a436f..25b2180dbb1 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -1978,7 +1978,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
bNodeLink *link;
int num_nodes;
float center[2];
- int is_clipboard_valid;
+ int is_clipboard_valid, all_nodes_valid;
/* validate pointers in the clipboard */
is_clipboard_valid = BKE_node_clipboard_validate();
@@ -2000,6 +2000,17 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_WARNING, "Some nodes references could not be restored, will be left empty");
}
+ /* make sure all clipboard nodes would be valid in the target tree */
+ all_nodes_valid = TRUE;
+ for (node = clipboard_nodes_lb->first; node; node = node->next) {
+ if (!node->typeinfo->poll_instance(node, ntree)) {
+ all_nodes_valid = FALSE;
+ BKE_reportf(op->reports, RPT_ERROR, "Cannot add node %s into node tree %s", node->name, ntree->id.name + 2);
+ }
+ }
+ if (!all_nodes_valid)
+ return OPERATOR_CANCELLED;
+
ED_preview_kill_jobs(C);
/* deselect old nodes */
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 7e4397a6cb0..b45ca8b228f 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -122,6 +122,7 @@ void NODE_OT_select_border(struct wmOperatorType *ot);
void NODE_OT_select_lasso(struct wmOperatorType *ot);
void NODE_OT_select_same_type(struct wmOperatorType *ot);
void NODE_OT_select_same_type_step(struct wmOperatorType *ot);
+void NODE_OT_find_node(struct wmOperatorType *ot);
/* node_view.c */
int space_node_view_flag(struct bContext *C, SpaceNode *snode, ARegion *ar, const int node_flag);
@@ -154,10 +155,6 @@ void NODE_OT_group_insert(struct wmOperatorType *ot);
void NODE_OT_group_ungroup(struct wmOperatorType *ot);
void NODE_OT_group_separate(struct wmOperatorType *ot);
void NODE_OT_group_edit(struct wmOperatorType *ot);
-void NODE_OT_group_socket_add(struct wmOperatorType *ot);
-void NODE_OT_group_socket_remove(struct wmOperatorType *ot);
-void NODE_OT_group_socket_move_up(struct wmOperatorType *ot);
-void NODE_OT_group_socket_move_down(struct wmOperatorType *ot);
/* node_relationships.c */
@@ -180,9 +177,7 @@ void snode_notify(struct bContext *C, struct SpaceNode *snode);
void snode_dag_update(struct bContext *C, struct SpaceNode *snode);
void snode_set_context(const struct bContext *C);
-bNode *node_tree_get_editgroup(bNodeTree *ntree);
void snode_update(struct SpaceNode *snode, struct bNode *node);
-bNode *editnode_get_active(bNodeTree *ntree);
int composite_node_active(struct bContext *C);
int node_has_hidden_sockets(bNode *node);
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index 4d229c6fe18..513bde4375c 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -60,6 +60,8 @@ void node_operatortypes(void)
WM_operatortype_append(NODE_OT_select_same_type);
WM_operatortype_append(NODE_OT_select_same_type_step);
+ WM_operatortype_append(NODE_OT_find_node);
+
WM_operatortype_append(NODE_OT_view_all);
WM_operatortype_append(NODE_OT_view_selected);
@@ -280,7 +282,7 @@ void node_keymap(struct wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "replace", FALSE);
- kmi = WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, KM_CTRL, 0);
+ kmi = WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "replace", TRUE);
WM_keymap_add_menu(keymap, "NODE_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
@@ -323,6 +325,8 @@ void node_keymap(struct wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "NODE_OT_select_same_type_step", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "prev", TRUE);
+ WM_keymap_add_item(keymap, "NODE_OT_find_node", FKEY, KM_PRESS, KM_CTRL, 0);
+
node_group_operators(keymap, "ShaderNodeGroup");
node_group_operators(keymap, "CompositorNodeGroup");
node_group_operators(keymap, "TextureNodeGroup");
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 8ff964aa932..b552aff27f9 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -1408,17 +1408,23 @@ void ED_node_link_insert(ScrArea *sa)
break;
if (link) {
- node = link->tonode;
- sockto = link->tosock;
-
- link->tonode = select;
- link->tosock = socket_best_match(&select->inputs);
- node_remove_extra_links(snode, link->tosock, link);
- link->flag &= ~NODE_LINKFLAG_HILITE;
-
- nodeAddLink(snode->edittree, select, socket_best_match(&select->outputs), node, sockto);
- ntreeUpdateTree(snode->edittree); /* needed for pointers */
- snode_update(snode, select);
- ED_node_tag_update_id(snode->id);
+ bNodeSocket *best_input = socket_best_match(&select->inputs);
+ bNodeSocket *best_output = socket_best_match(&select->outputs);
+
+ if (best_input && best_output) {
+ node = link->tonode;
+ sockto = link->tosock;
+
+ link->tonode = select;
+ link->tosock = best_input;
+ node_remove_extra_links(snode, link->tosock, link);
+ link->flag &= ~NODE_LINKFLAG_HILITE;
+
+ nodeAddLink(snode->edittree, select, best_output, node, sockto);
+
+ ntreeUpdateTree(snode->edittree); /* needed for pointers */
+ snode_update(snode, select);
+ ED_node_tag_update_id(snode->id);
+ }
}
}
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index 62537fb713f..366fcce3dd5 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -28,10 +28,13 @@
* \ingroup spnode
*/
+#include <stdlib.h>
+
#include "DNA_node_types.h"
#include "BLI_rect.h"
#include "BLI_lasso.h"
+#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
@@ -48,6 +51,8 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "UI_interface.h"
+#include "UI_resources.h"
#include "UI_view2d.h"
#include "MEM_guardedalloc.h"
@@ -853,3 +858,104 @@ void NODE_OT_select_same_type_step(wmOperatorType *ot)
}
+/* *************** find a node **************** */
+
+/* generic search invoke */
+static void node_find_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items)
+{
+ SpaceNode *snode = CTX_wm_space_node(C);
+ bNode *node;
+
+ for (node = snode->edittree->nodes.first; node; node = node->next) {
+
+ if (BLI_strcasestr(node->name, str) || BLI_strcasestr(node->label, str)) {
+ char name[256];
+
+ if (node->label[0])
+ BLI_snprintf(name, 256, "%s (%s)", node->name, node->label);
+ else
+ BLI_strncpy(name, node->name, 256);
+ if (false == uiSearchItemAdd(items, name, node, 0))
+ break;
+ }
+ }
+}
+
+static void node_find_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2)
+{
+ SpaceNode *snode = CTX_wm_space_node(C);
+ bNode *active = arg2;
+
+ if (active) {
+ ARegion *ar = CTX_wm_region(C);
+ node_select_single(C, active);
+
+ /* is note outside view? */
+ if (active->totr.xmax < ar->v2d.cur.xmin || active->totr.xmin > ar->v2d.cur.xmax ||
+ active->totr.ymax < ar->v2d.cur.ymin || active->totr.ymin > ar->v2d.cur.ymax)
+ {
+ space_node_view_flag(C, snode, ar, NODE_SELECT);
+ }
+
+ }
+}
+
+static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op)
+{
+ static char search[256] = "";
+ wmEvent event;
+ wmWindow *win = CTX_wm_window(C);
+ uiBlock *block;
+ uiBut *but;
+ wmOperator *op = (wmOperator *)arg_op;
+
+ block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
+
+ but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, "");
+ uiButSetSearchFunc(but, node_find_cb, op->type, node_find_call_cb, NULL);
+
+ /* fake button, it holds space for search items */
+ uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxHeight(), uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL);
+
+ uiPopupBoundsBlock(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */
+ uiEndBlock(C, block);
+
+ // uiButActiveOnly(C, ar, block, but); XXX using this here makes Blender hang - investigate
+ event = *(win->eventstate); /* XXX huh huh? make api call */
+ event.type = EVT_BUT_OPEN;
+ event.val = KM_PRESS;
+ event.customdata = but;
+ event.customdatafree = FALSE;
+ wm_event_add(win, &event);
+
+ return block;
+}
+
+
+static int node_find_node_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ uiPupBlock(C, node_find_menu, op);
+ return OPERATOR_CANCELLED;
+}
+
+
+void NODE_OT_find_node(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Find Node";
+ ot->description = "Search for named node and allow to select and activate it";
+ ot->idname = "NODE_OT_find_node";
+
+ /* api callbacks */
+ ot->invoke = node_find_node_invoke;
+ ot->poll = ED_operator_node_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna, "prev", 0, "Previous", "");
+
+}
+
+
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 418d4ff04a4..d22ea674668 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -754,7 +754,7 @@ static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(ar
/* display name for menu */
WM_operator_py_idname(name, ot->idname);
- if (0 == uiSearchItemAdd(items, name, ot, 0))
+ if (false == uiSearchItemAdd(items, name, ot, 0))
break;
}
}
@@ -1043,8 +1043,9 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Spa
uiButSetRenameFunc(bt, namebutton_cb, tselem);
/* returns false if button got removed */
- if (0 == uiButActiveOnly(C, ar, block, bt) )
+ if (false == uiButActiveOnly(C, ar, block, bt)) {
tselem->flag &= ~TSE_TEXTBUT;
+ }
}
}
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 1e67e099508..0a1d3a63f2c 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -113,6 +113,37 @@ static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *te
}
#endif
+static TreeElement *outliner_dropzone_element(const SpaceOops *soops, TreeElement *te, const float fmval[2], const int children)
+{
+ if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) {
+ /* name and first icon */
+ if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend))
+ return te;
+ }
+ /* Not it. Let's look at its children. */
+ if (children && (TREESTORE(te)->flag & TSE_CLOSED) == 0 && (te->subtree.first)) {
+ for (te = te->subtree.first; te; te = te->next) {
+ TreeElement *te_valid = outliner_dropzone_element(soops, te, fmval, children);
+ if (te_valid)
+ return te_valid;
+ }
+ }
+ return NULL;
+}
+
+/* Used for drag and drop parenting */
+TreeElement *outliner_dropzone_find(const SpaceOops *soops, const float fmval[2], const int children)
+{
+ TreeElement *te;
+
+ for (te = soops->tree.first; te; te = te->next) {
+ TreeElement *te_valid = outliner_dropzone_element(soops, te, fmval, children);
+ if (te_valid)
+ return te_valid;
+ }
+ return NULL;
+}
+
/* ************************************************************** */
/* Click Activated */
@@ -1447,36 +1478,6 @@ static int parent_drop_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-/* Used for drag and drop parenting */
-TreeElement *outliner_dropzone_parent(bContext *C, const wmEvent *event, TreeElement *te, const float fmval[2])
-{
- SpaceOops *soops = CTX_wm_space_outliner(C);
- TreeStoreElem *tselem = TREESTORE(te);
-
- if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) {
- /* name and first icon */
- if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) {
- /* always makes active object */
- if (te->idcode == ID_OB && tselem->type == 0) {
- return te;
- }
- else {
- return NULL;
- }
- }
- }
-
- /* Not it. Let's look at its children. */
- if ((tselem->flag & TSE_CLOSED) == 0 && (te->subtree.first)) {
- for (te = te->subtree.first; te; te = te->next) {
- TreeElement *te_valid;
- te_valid = outliner_dropzone_parent(C, event, te, fmval);
- if (te_valid) return te_valid;
- }
- }
- return NULL;
-}
-
static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Object *par = NULL;
@@ -1486,7 +1487,6 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Main *bmain = CTX_data_main(C);
Scene *scene = NULL;
TreeElement *te = NULL;
- TreeElement *te_found = NULL;
char childname[MAX_ID_NAME];
char parname[MAX_ID_NAME];
int partype = 0;
@@ -1495,13 +1495,10 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
/* Find object hovered over */
- for (te = soops->tree.first; te; te = te->next) {
- te_found = outliner_dropzone_parent(C, event, te, fmval);
- if (te_found) break;
- }
+ te = outliner_dropzone_find(soops, fmval, 1);
- if (te_found) {
- RNA_string_set(op->ptr, "parent", te_found->name);
+ if (te) {
+ RNA_string_set(op->ptr, "parent", te->name);
/* Identify parent and child */
RNA_string_get(op->ptr, "child", childname);
ob = (Object *)BKE_libblock_find_name(ID_OB, childname);
@@ -1516,7 +1513,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
}
- scene = (Scene *)outliner_search_back(soops, te_found, ID_SCE);
+ scene = (Scene *)outliner_search_back(soops, te, ID_SCE);
if (scene == NULL) {
/* currently outlier organized in a way, that if there's no parent scene
@@ -1651,44 +1648,6 @@ void OUTLINER_OT_parent_drop(wmOperatorType *ot)
RNA_def_enum(ot->srna, "type", prop_make_parent_types, 0, "Type", "");
}
-int outliner_dropzone_parent_clear(bContext *C, const wmEvent *event, TreeElement *te, const float fmval[2])
-{
- SpaceOops *soops = CTX_wm_space_outliner(C);
- TreeStoreElem *tselem = TREESTORE(te);
-
- /* Check for row */
- if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) {
- /* Ignore drop on scene tree elements */
- if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) {
- if ((te->idcode == ID_SCE) &&
- !ELEM3(tselem->type, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS))
- {
- return 0;
- }
- // Other codes to ignore?
- }
-
- /* Left or right of: (+), first icon, and name */
- if ((fmval[0] < (te->xs + UI_UNIT_X)) || (fmval[0] > te->xend)) {
- return 1;
- }
- else if (te->idcode != ID_OB || ELEM(tselem->type, TSE_MODIFIER_BASE, TSE_CONSTRAINT_BASE)) {
- return 1;
- }
-
- return 0; // ID_OB, but mouse in undefined dropzone.
- }
-
- /* Not this row. Let's look at its children. */
- if ((tselem->flag & TSE_CLOSED) == 0 && (te->subtree.first)) {
- for (te = te->subtree.first; te; te = te->next) {
- if (outliner_dropzone_parent_clear(C, event, te, fmval))
- return 1;
- }
- }
- return 0;
-}
-
static int parent_clear_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
Main *bmain = CTX_data_main(C);
@@ -1738,22 +1697,6 @@ void OUTLINER_OT_parent_clear(wmOperatorType *ot)
RNA_def_enum(ot->srna, "type", prop_clear_parent_types, 0, "Type", "");
}
-TreeElement *outliner_dropzone_scene(bContext *C, const wmEvent *UNUSED(event), TreeElement *te, const float fmval[2])
-{
- SpaceOops *soops = CTX_wm_space_outliner(C);
- TreeStoreElem *tselem = TREESTORE(te);
-
- if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) {
- /* name and first icon */
- if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) {
- if (te->idcode == ID_SCE && tselem->type == 0) {
- return te;
- }
- }
- }
- return NULL;
-}
-
static int scene_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Scene *scene = NULL;
@@ -1762,24 +1705,19 @@ static int scene_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ARegion *ar = CTX_wm_region(C);
Main *bmain = CTX_data_main(C);
TreeElement *te = NULL;
- TreeElement *te_found = NULL;
char obname[MAX_ID_NAME];
float fmval[2];
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
/* Find object hovered over */
- for (te = soops->tree.first; te; te = te->next) {
- te_found = outliner_dropzone_scene(C, event, te, fmval);
- if (te_found)
- break;
- }
+ te = outliner_dropzone_find(soops, fmval, 0);
- if (te_found) {
+ if (te) {
Base *base;
- RNA_string_set(op->ptr, "scene", te_found->name);
- scene = (Scene *)BKE_libblock_find_name(ID_SCE, te_found->name);
+ RNA_string_set(op->ptr, "scene", te->name);
+ scene = (Scene *)BKE_libblock_find_name(ID_SCE, te->name);
RNA_string_get(op->ptr, "object", obname);
ob = (Object *)BKE_libblock_find_name(ID_OB, obname);
@@ -1837,22 +1775,17 @@ static int material_drop_invoke(bContext *C, wmOperator *op, const wmEvent *even
SpaceOops *soops = CTX_wm_space_outliner(C);
ARegion *ar = CTX_wm_region(C);
TreeElement *te = NULL;
- TreeElement *te_found = NULL;
char mat_name[MAX_ID_NAME - 2];
float fmval[2];
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
/* Find object hovered over */
- for (te = soops->tree.first; te; te = te->next) {
- te_found = outliner_dropzone_parent(C, event, te, fmval);
- if (te_found)
- break;
- }
+ te = outliner_dropzone_find(soops, fmval, 1);
- if (te_found) {
- RNA_string_set(op->ptr, "object", te_found->name);
- ob = (Object *)BKE_libblock_find_name(ID_OB, te_found->name);
+ if (te) {
+ RNA_string_set(op->ptr, "object", te->name);
+ ob = (Object *)BKE_libblock_find_name(ID_OB, te->name);
RNA_string_get(op->ptr, "material", mat_name);
ma = (Material *)BKE_libblock_find_name(ID_MA, mat_name);
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index a918357ced2..3ab412f0ddc 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -190,9 +190,7 @@ void group_toggle_renderability_cb(struct bContext *C, struct Scene *scene, Tree
void item_rename_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem);
-TreeElement *outliner_dropzone_parent(struct bContext *C, const struct wmEvent *event, struct TreeElement *te, const float fmval[2]);
-int outliner_dropzone_parent_clear(struct bContext *C, const struct wmEvent *event, struct TreeElement *te, const float fmval[2]);
-TreeElement *outliner_dropzone_scene(struct bContext *C, const struct wmEvent *event, struct TreeElement *te, const float fmval[2]);
+TreeElement *outliner_dropzone_find(const struct SpaceOops *soops, const float fmval[2], const int children);
/* ...................................................... */
void OUTLINER_OT_item_activate(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 3849aaf78c1..76a3da23d57 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -94,7 +94,6 @@ static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *e
{
ARegion *ar = CTX_wm_region(C);
SpaceOops *soops = CTX_wm_space_outliner(C);
- TreeElement *te = NULL;
float fmval[2];
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
@@ -102,25 +101,25 @@ static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *e
ID *id = (ID *)drag->poin;
if (GS(id->name) == ID_OB) {
/* Ensure item under cursor is valid drop target */
- /* Find object hovered over */
- for (te = soops->tree.first; te; te = te->next) {
- TreeElement *te_valid;
- te_valid = outliner_dropzone_parent(C, event, te, fmval);
- if (te_valid) {
- /* check that parent/child are both in the same scene */
- Scene *scene = (Scene *)outliner_search_back(soops, te_valid, ID_SCE);
-
- if (!scene) {
- /* currently outlier organized in a way, that if there's no parent scene
- * element for object it means that all displayed objects belong to
- * active scene and parenting them is allowed (sergey)
- */
- return 1;
- }
+ TreeElement *te = outliner_dropzone_find(soops, fmval, 1);
- if (scene && BKE_scene_base_find(scene, (Object *)id)) {
- return 1;
- }
+ if (te && te->idcode == ID_OB && TREESTORE(te)->type == 0) {
+ Scene *scene;
+ ID *te_id = TREESTORE(te)->id;
+
+ /* check if dropping self or parent */
+ if (te_id == id || (Object *)te_id == ((Object *)id)->parent)
+ return 0;
+
+ /* check that parent/child are both in the same scene */
+ scene = (Scene *)outliner_search_back(soops, te, ID_SCE);
+
+ /* currently outliner organized in a way that if there's no parent scene
+ * element for object it means that all displayed objects belong to
+ * active scene and parenting them is allowed (sergey)
+ */
+ if (!scene || BKE_scene_base_find(scene, (Object *)id)) {
+ return 1;
}
}
}
@@ -147,19 +146,20 @@ static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *
if (drag->type == WM_DRAG_ID) {
ID *id = (ID *)drag->poin;
if (GS(id->name) == ID_OB) {
- if (((Object *)id)->parent == NULL) {
- return 0;
- }
- /* Ensure location under cursor is valid dropzone */
- for (te = soops->tree.first; te; te = te->next) {
- if (outliner_dropzone_parent_clear(C, event, te, fmval)) return 1;
- }
- /* Check if mouse cursor is below the tree */
- te = soops->tree.last;
- while (((te->flag & TE_LAZY_CLOSED) == 0) && (te->subtree.last)) {
- te = te->subtree.last;
+ if (((Object *)id)->parent) {
+ if ((te = outliner_dropzone_find(soops, fmval, 1))) {
+ TreeStoreElem *tselem = TREESTORE(te);
+
+ switch (te->idcode) {
+ case ID_SCE:
+ return (ELEM3(tselem->type, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS));
+ case ID_OB:
+ return (ELEM(tselem->type, TSE_MODIFIER_BASE, TSE_CONSTRAINT_BASE));
+ /* Other codes to ignore? */
+ }
+ }
+ return (te == NULL);
}
- if (fmval[1] < te->ys) return 1;
}
}
return 0;
@@ -180,7 +180,6 @@ static int outliner_scene_drop_poll(bContext *C, wmDrag *drag, const wmEvent *ev
{
ARegion *ar = CTX_wm_region(C);
SpaceOops *soops = CTX_wm_space_outliner(C);
- TreeElement *te = NULL;
float fmval[2];
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
@@ -188,11 +187,8 @@ static int outliner_scene_drop_poll(bContext *C, wmDrag *drag, const wmEvent *ev
ID *id = (ID *)drag->poin;
if (GS(id->name) == ID_OB) {
/* Ensure item under cursor is valid drop target */
- /* Find object hovered over */
- for (te = soops->tree.first; te; te = te->next) {
- if (outliner_dropzone_scene(C, event, te, fmval))
- return 1;
- }
+ TreeElement *te = outliner_dropzone_find(soops, fmval, 0);
+ return (te && te->idcode == ID_SCE && TREESTORE(te)->type == 0);
}
}
return 0;
@@ -209,7 +205,6 @@ static int outliner_material_drop_poll(bContext *C, wmDrag *drag, const wmEvent
{
ARegion *ar = CTX_wm_region(C);
SpaceOops *soops = CTX_wm_space_outliner(C);
- TreeElement *te = NULL;
float fmval[2];
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
@@ -217,11 +212,8 @@ static int outliner_material_drop_poll(bContext *C, wmDrag *drag, const wmEvent
ID *id = (ID *)drag->poin;
if (GS(id->name) == ID_MA) {
/* Ensure item under cursor is valid drop target */
- /* Find object hovered over */
- for (te = soops->tree.first; te; te = te->next) {
- if (outliner_dropzone_parent(C, event, te, fmval))
- return 1;
- }
+ TreeElement *te = outliner_dropzone_find(soops, fmval, 1);
+ return (te && te->idcode == ID_OB && TREESTORE(te)->type == 0);
}
}
return 0;
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 3c2c715efc2..141af5d5ba4 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -896,11 +896,9 @@ static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scop
{
ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
ImBuf *scope;
-
- if (display_ibuf->rect_float) {
- IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings,
+
+ IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings,
&scene->display_settings);
- }
scope = make_scope_cb(display_ibuf);
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index 32a6c49da89..a0212bd17fa 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -54,7 +54,8 @@ struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa);
void draw_timeline_seq(const struct bContext *C, struct ARegion *ar);
void draw_image_seq(const struct bContext *C, struct Scene *scene, struct ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset, int draw_overlay);
-void seq_reset_imageofs(struct SpaceSeq *sseq);
+/* UNUSED */
+// void seq_reset_imageofs(struct SpaceSeq *sseq);
struct ImBuf *sequencer_ibuf_get(struct Main *bmain, struct Scene *scene, struct SpaceSeq *sseq, int cfra, int frame_ofs);
@@ -69,7 +70,8 @@ int seq_effect_find_selected(struct Scene *scene, struct Sequence *activeseq, in
/* operator helpers */
int sequencer_edit_poll(struct bContext *C);
-int sequencer_strip_poll(struct bContext *C);
+/* UNUSED */
+//int sequencer_strip_poll(struct bContext *C);
int sequencer_strip_has_path_poll(struct bContext *C);
int sequencer_view_poll(struct bContext *C);
diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c
index c8b70c0ce4a..79b50f2d3ae 100644
--- a/source/blender/editors/space_sequencer/sequencer_scopes.c
+++ b/source/blender/editors/space_sequencer/sequencer_scopes.c
@@ -531,7 +531,7 @@ BLI_INLINE int get_bin_float(float f)
static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
{
ImBuf *rval = IMB_allocImBuf(515, 128, 32, IB_rect);
- int n, c, x, y;
+ int nr, ng, nb, x, y;
float *src = ibuf->rect_float;
unsigned int bins[3][HIS_STEPS];
@@ -563,23 +563,30 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
}
}
- draw_histogram_marker(rval, get_bin_float(0.0));
- draw_histogram_marker(rval, get_bin_float(1.0));
-
- n = 0;
- for (c = 0; c < 3; c++) {
- for (x = 0; x < HIS_STEPS; x++) {
- if (bins[c][x] > n) {
- n = bins[c][x];
- }
- }
+ nr = nb = ng = 0;
+ for (x = 0; x < HIS_STEPS; x++) {
+ if (bins[0][x] > nr)
+ nr = bins[0][x];
+ if (bins[1][x] > ng)
+ ng = bins[1][x];
+ if (bins[2][x] > nb)
+ nb = bins[2][x];
}
- for (c = 0; c < 3; c++) {
- for (x = 0; x < HIS_STEPS; x++) {
- draw_histogram_bar(rval, x + 1, (float) bins[c][x] / n, c);
+
+ for (x = 0; x < HIS_STEPS; x++) {
+ if (nr) {
+ draw_histogram_bar(rval, x + 1, ((float) bins[0][x]) / nr, 0);
+ }
+ if (ng) {
+ draw_histogram_bar(rval, x + 1, ((float) bins[1][x]) / ng, 1);
+ }
+ if (nb) {
+ draw_histogram_bar(rval, x + 1, ((float) bins[2][x]) / nb, 2);
}
}
-
+
+ draw_histogram_marker(rval, get_bin_float(0.0));
+ draw_histogram_marker(rval, get_bin_float(1.0));
wform_put_border((unsigned char *) rval->rect, rval->x, rval->y);
return rval;
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index ffe89407715..c933bbff0b3 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -330,6 +330,7 @@ static void sequencer_listener(ScrArea *sa, wmNotifier *wmn)
break;
}
break;
+ case NC_WINDOW:
case NC_SPACE:
if (wmn->data == ND_SPACE_SEQUENCER)
sequencer_scopes_tag_refresh(sa);
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index cb685b59b64..2ff52b51069 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -1573,8 +1573,8 @@ static void draw_pose_dofs(Object *ob)
for (i = 0; i < 3; i++) {
/* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */
- amin[i] = (float)sin(pchan->limitmin[i] * 0.5f);
- amax[i] = (float)sin(pchan->limitmax[i] * 0.5f);
+ amin[i] = sinf(pchan->limitmin[i] * 0.5f);
+ amax[i] = sinf(pchan->limitmax[i] * 0.5f);
}
glScalef(1.0f, -1.0f, 1.0f);
@@ -1605,8 +1605,8 @@ static void draw_pose_dofs(Object *ob)
phi = fac * (pchan->limitmax[2] - pchan->limitmin[2]);
i = (a == -16) ? 0 : 1;
- corner[i][0] = (float)sin(phi);
- corner[i][1] = (float)cos(phi);
+ corner[i][0] = sinf(phi);
+ corner[i][1] = cosf(phi);
corner[i][2] = 0.0f;
glVertex3fv(corner[i]);
}
@@ -1629,8 +1629,8 @@ static void draw_pose_dofs(Object *ob)
i = (a == -16) ? 2 : 3;
corner[i][0] = 0.0f;
- corner[i][1] = (float)sin(phi);
- corner[i][2] = (float)cos(phi);
+ corner[i][1] = sinf(phi);
+ corner[i][2] = cosf(phi);
glVertex3fv(corner[i]);
}
glEnd();
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 265fef0f59b..cd68fbf126e 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -622,7 +622,7 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char
glColor4fv(ob->col);
/* Draw the Image on the screen */
- glaDrawPixelsTex(ofs_x, ofs_y, ima_x, ima_y, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect);
+ glaDrawPixelsTex(ofs_x, ofs_y, ima_x, ima_y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect);
glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
glDisable(GL_BLEND);
@@ -6452,6 +6452,14 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
ED_view3d_after_add(&v3d->afterdraw_xray, base, dflag);
return;
}
+
+ /* allow transp option for empty images */
+ if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
+ if (!v3d->xray && !v3d->transp && !(ob->dtx & OB_DRAWXRAY) && (ob->dtx & OB_DRAWTRANSP)) {
+ ED_view3d_after_add(&v3d->afterdraw_transp, base, dflag);
+ return;
+ }
+ }
}
}
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index b6d46f82e6a..d0437c77af7 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1831,7 +1831,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
* glaDrawPixelsSafe in some cases, which will end up in misssing
* alpha transparency for the background image (sergey)
*/
- glaDrawPixelsTex(x1, y1, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect);
+ glaDrawPixelsTex(x1, y1, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect);
glPixelZoom(1.0, 1.0);
glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 9dbdd8a9789..3767f3011ff 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -365,7 +365,8 @@ typedef struct ViewOpsData {
float viewquat[4]; /* working copy of rv3d->viewquat */
float trackvec[3];
float mousevec[3]; /* dolly only */
- float reverse, dist0, camzoom0;
+ float reverse;
+ float dist_prev, camzoom_prev;
float grid, far;
bool axis_snap; /* view rotate only */
float zfac;
@@ -425,8 +426,8 @@ static void viewops_data_create(bContext *C, wmOperator *op, const wmEvent *even
* we may want to make this optional but for now its needed always */
ED_view3d_camera_lock_init(vod->v3d, vod->rv3d);
- vod->dist0 = rv3d->dist;
- vod->camzoom0 = rv3d->camzoom;
+ vod->dist_prev = rv3d->dist;
+ vod->camzoom_prev = rv3d->camzoom;
copy_qt_qt(vod->viewquat, rv3d->viewquat);
copy_qt_qt(vod->oldquat, rv3d->viewquat);
vod->origx = vod->oldx = event->x;
@@ -439,7 +440,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, const wmEvent *even
Scene *scene = CTX_data_scene(C);
Object *ob = OBACT;
- if (ob && ob->mode & OB_MODE_ALL_PAINT) {
+ if (ob && (ob->mode & OB_MODE_ALL_PAINT) && (BKE_object_pose_armature_get(ob) == NULL)) {
/* transformation is disabled for painting modes, which will make it
* so previous offset is used. This is annoying when you open file
* saved with active object in painting mode
@@ -484,7 +485,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, const wmEvent *even
/* find a new ofs value that is along the view axis (rather than the mouse location) */
closest_to_line_v3(dvec, vod->dyn_ofs, my_pivot, my_origin);
- vod->dist0 = rv3d->dist = len_v3v3(my_pivot, dvec);
+ vod->dist_prev = rv3d->dist = len_v3v3(my_pivot, dvec);
negate_v3_v3(rv3d->ofs, dvec);
}
@@ -1711,7 +1712,7 @@ static void viewzoom_apply(ViewOpsData *vod, const int x, const int y, const sho
if (use_cam_zoom) {
float delta;
delta = (x - vod->origx + y - vod->origy) / 10.0f;
- vod->rv3d->camzoom = vod->camzoom0 + (zoom_invert ? -delta : delta);
+ vod->rv3d->camzoom = vod->camzoom_prev + (zoom_invert ? -delta : delta);
CLAMP(vod->rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX);
}
@@ -1746,7 +1747,7 @@ static void viewzoom_apply(ViewOpsData *vod, const int x, const int y, const sho
len1 = (int)sqrt((ctr[0] - x) * (ctr[0] - x) + (ctr[1] - y) * (ctr[1] - y)) + 5;
len2 = (int)sqrt((ctr[0] - vod->origx) * (ctr[0] - vod->origx) + (ctr[1] - vod->origy) * (ctr[1] - vod->origy)) + 5;
- zfac = vod->dist0 * ((float)len2 / len1) / vod->rv3d->dist;
+ zfac = vod->dist_prev * ((float)len2 / len1) / vod->rv3d->dist;
}
else { /* USER_ZOOM_DOLLY */
float len1, len2;
@@ -1766,11 +1767,11 @@ static void viewzoom_apply(ViewOpsData *vod, const int x, const int y, const sho
if (use_cam_zoom) {
/* zfac is ignored in this case, see below */
#if 0
- zfac = vod->camzoom0 * (2.0f * ((len1 / len2) - 1.0f) + 1.0f) / vod->rv3d->camzoom;
+ zfac = vod->camzoom_prev * (2.0f * ((len1 / len2) - 1.0f) + 1.0f) / vod->rv3d->camzoom;
#endif
}
else {
- zfac = vod->dist0 * (2.0f * ((len1 / len2) - 1.0f) + 1.0f) / vod->rv3d->dist;
+ zfac = vod->dist_prev * (2.0f * ((len1 / len2) - 1.0f) + 1.0f) / vod->rv3d->dist;
}
}
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
index ef8c2b5eff6..ad3f941bd17 100644
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_ruler.c
@@ -59,43 +59,53 @@
/* Snapping (could be own function) */
/* NOTE - this is not very nice use of transform snapping */
#include "ED_transform.h"
-#include "../transform/transform.h"
-static bool ED_view3d_snap_co(bContext *C, float r_co[3], const float co_ss[2],
+static bool ED_view3d_snap_co(bContext *C, float r_co[3], const float co_ss[2], float r_no[3],
bool use_vert, bool use_edge, bool use_face)
{
- TransInfo t = {0};
- int dist = 12; /* snap dist */
+ float dist_px = 12; /* snap dist */
float r_no_dummy[3];
bool ret = false;
- char backup_snap_mode;
- Base *backup_baseact;
+ float *r_no_ptr = r_no ? r_no : r_no_dummy;
- t.scene = CTX_data_scene(C);
- t.view = CTX_wm_view3d(C);
- t.ar = CTX_wm_region(C);
- t.obedit = CTX_data_edit_object(C);
-
- backup_snap_mode = t.scene->toolsettings->snap_mode;
- backup_baseact = t.scene->basact;
- t.scene->basact = NULL;
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ ARegion *ar = CTX_wm_region(C);
+ struct Object *obedit = CTX_data_edit_object(C);
/* try snap edge, then face if it fails */
if (use_vert) {
- t.scene->toolsettings->snap_mode = SCE_SNAP_MODE_VERTEX;
- ret = snapObjectsTransform(&t, co_ss, &dist, r_co, r_no_dummy, SNAP_ALL);
+ ret = snapObjectsEx(scene, NULL, v3d, ar, obedit, SCE_SNAP_MODE_VERTEX,
+ co_ss, &dist_px, r_co, r_no_ptr, SNAP_ALL);
}
if (use_edge && (ret == false)) {
- t.scene->toolsettings->snap_mode = SCE_SNAP_MODE_EDGE;
- ret = snapObjectsTransform(&t, co_ss, &dist, r_co, r_no_dummy, SNAP_ALL);
+ ret = snapObjectsEx(scene, NULL, v3d, ar, obedit, SCE_SNAP_MODE_EDGE,
+ co_ss, &dist_px, r_co, r_no_ptr, SNAP_ALL);
}
if (use_face && (ret == false)) {
- t.scene->toolsettings->snap_mode = SCE_SNAP_MODE_FACE;
- ret = snapObjectsTransform(&t, co_ss, &dist, r_co, r_no_dummy, SNAP_ALL);
+ ret = snapObjectsEx(scene, NULL, v3d, ar, obedit, SCE_SNAP_MODE_FACE,
+ co_ss, &dist_px, r_co, r_no_ptr, SNAP_ALL);
}
- t.scene->toolsettings->snap_mode = backup_snap_mode;
- t.scene->basact = backup_baseact;
+ return ret;
+}
+
+static bool ED_view3d_snap_ray(bContext *C, float r_co[3],
+ const float ray_start[3], const float ray_normal[3])
+{
+ float dist_px = 12; /* snap dist */
+ float r_no_dummy[3];
+ bool ret = false;
+
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ ARegion *ar = CTX_wm_region(C);
+ struct Object *obedit = CTX_data_edit_object(C);
+
+ /* try snap edge, then face if it fails */
+ ret = snapObjectsRayEx(scene, NULL, v3d, ar, obedit, SCE_SNAP_MODE_FACE,
+ ray_start, ray_normal,
+ NULL, &dist_px, r_co, r_no_dummy, SNAP_ALL);
return ret;
}
@@ -657,16 +667,36 @@ static void view3d_ruler_item_project(RulerInfo *ruler_info, float r_co[3],
}
/* use for mousemove events */
-static bool view3d_ruler_item_mousemove(bContext *C, RulerInfo *ruler_info, const int mval[2], const bool do_snap)
+static bool view3d_ruler_item_mousemove(bContext *C, RulerInfo *ruler_info, const int mval[2],
+ const bool do_thickness, const bool do_snap)
{
RulerItem *ruler_item = ruler_item_active_get(ruler_info);
if (ruler_item) {
float *co = ruler_item->co[ruler_item->co_index];
view3d_ruler_item_project(ruler_info, co, mval);
- if (do_snap) {
+ if (do_thickness && ruler_item->co_index != 1) {
+ const float mval_fl[2] = {UNPACK2(mval)};
+ float ray_normal[3];
+ float ray_start[3];
+ float *co_other;
+
+ co_other = ruler_item->co[ruler_item->co_index == 0 ? 2 : 0];
+
+ if (ED_view3d_snap_co(C, co, mval_fl, ray_normal,
+ false, false, true))
+ {
+ negate_v3(ray_normal);
+ /* add some bias */
+ madd_v3_v3v3fl(ray_start, co, ray_normal, 0.0001f);
+ ED_view3d_snap_ray(C, co_other,
+ ray_start, ray_normal);
+ }
+ }
+ else if (do_snap) {
const float mval_fl[2] = {UNPACK2(mval)};
- ED_view3d_snap_co(C, co, mval_fl, true, true, true);
+ ED_view3d_snap_co(C, co, mval_fl, NULL,
+ true, true, true);
}
return true;
}
@@ -680,6 +710,7 @@ static void view3d_ruler_header_update(ScrArea *sa)
const char *text = "Ctrl+LMB: Add, "
"Del: Remove, "
"Ctrl+Drag: Snap, "
+ "Shift+Drag: Thickness, "
"Ctrl+C: Copy Value, "
"Enter: Store, "
"Esc: Cancel";
@@ -774,7 +805,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* snap the first point added, not essential but handy */
{
ruler_item->co_index = 0;
- view3d_ruler_item_mousemove(C, ruler_info, event->mval, true);
+ view3d_ruler_item_mousemove(C, ruler_info, event->mval, event->shift != 0, true);
}
copy_v3_v3(ruler_item->co[2], ruler_item->co[0]);
@@ -814,7 +845,8 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* update the new location */
- view3d_ruler_item_mousemove(C, ruler_info, event->mval, event->ctrl != 0);
+ view3d_ruler_item_mousemove(C, ruler_info, event->mval,
+ event->shift != 0, event->ctrl != 0);
do_draw = true;
}
}
@@ -857,7 +889,9 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
case MOUSEMOVE:
{
if (ruler_info->state == RULER_STATE_DRAG) {
- if (view3d_ruler_item_mousemove(C, ruler_info, event->mval, event->ctrl != 0)) {
+ if (view3d_ruler_item_mousemove(C, ruler_info, event->mval,
+ event->shift != 0, event->ctrl != 0))
+ {
do_draw = true;
}
}
diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c
index 603d9a1595c..d30c1699d65 100644
--- a/source/blender/editors/space_view3d/view3d_toolbar.c
+++ b/source/blender/editors/space_view3d/view3d_toolbar.c
@@ -162,7 +162,7 @@ static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), cons
if (BLI_strcasestr(ot->name, str)) {
if (WM_operator_poll((bContext *)C, ot)) {
- if (0 == uiSearchItemAdd(items, ot->name, ot, 0))
+ if (false == uiSearchItemAdd(items, ot->name, ot, 0))
break;
}
}
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 64e49abd761..be296025624 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -112,6 +112,7 @@ static bool transdata_check_local_center(TransInfo *t)
return ((t->around == V3D_LOCAL) && (
(t->flag & (T_OBJECT | T_POSE)) ||
(t->obedit && t->obedit->type == OB_MESH && (t->settings->selectmode & (SCE_SELECT_EDGE | SCE_SELECT_FACE))) ||
+ (t->obedit && t->obedit->type == OB_MBALL) ||
(t->obedit && t->obedit->type == OB_ARMATURE) ||
(t->spacetype == SPACE_IPO))
);
@@ -2757,8 +2758,8 @@ int Warp(TransInfo *t, const int UNUSED(mval[2]))
vec[1] = (vec[1] - cursor[1]);
- co = (float)cos(phi0);
- si = (float)sin(phi0);
+ co = cosf(phi0);
+ si = sinf(phi0);
loc[0] = -si * vec[1] + cursor[0];
loc[1] = co * vec[1] + cursor[1];
loc[2] = vec[2];
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index a551ef5008e..1f08bfda6a6 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -72,7 +72,7 @@ typedef struct TransSnap {
short target;
short modePoint;
short modeSelect;
- short align;
+ bool align;
char project;
char snap_self;
short peel;
@@ -593,7 +593,7 @@ void flushTransGraphData(TransInfo *t);
void remake_graph_transdata(TransInfo *t, struct ListBase *anim_data);
void flushTransUVs(TransInfo *t);
void flushTransParticles(TransInfo *t);
-int clipUVTransform(TransInfo *t, float *vec, int resize);
+bool clipUVTransform(TransInfo *t, float vec[2], const bool resize);
void clipUVData(TransInfo *t);
void flushTransNodes(TransInfo *t);
void flushTransSeq(TransInfo *t);
@@ -628,8 +628,8 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char tex
void constraintNumInput(TransInfo *t, float vec[3]);
-int isLockConstraint(TransInfo *t);
-int getConstraintSpaceDimension(TransInfo *t);
+bool isLockConstraint(TransInfo *t);
+int getConstraintSpaceDimension(TransInfo *t);
char constraintModeToChar(TransInfo *t);
void startConstraint(TransInfo *t);
@@ -652,21 +652,21 @@ typedef enum {
void snapGrid(TransInfo *t, float *val);
void snapGridAction(TransInfo *t, float *val, GearsType action);
-int activeSnap(TransInfo *t);
-int validSnap(TransInfo *t);
+bool activeSnap(TransInfo *t);
+bool validSnap(TransInfo *t);
void initSnapping(struct TransInfo *t, struct wmOperator *op);
void applyProject(TransInfo *t);
void applySnapping(TransInfo *t, float *vec);
void resetSnapping(TransInfo *t);
-int handleSnapping(TransInfo *t, const struct wmEvent *event);
+bool handleSnapping(TransInfo *t, const struct wmEvent *event);
void drawSnapping(const struct bContext *C, TransInfo *t);
-int usingSnappingNormal(TransInfo *t);
-int validSnappingNormal(TransInfo *t);
+bool usingSnappingNormal(TransInfo *t);
+bool validSnappingNormal(TransInfo *t);
void getSnapPoint(TransInfo *t, float vec[3]);
void addSnapPoint(TransInfo *t);
-int updateSelectedSnapPoint(TransInfo *t);
+bool updateSelectedSnapPoint(TransInfo *t);
void removeSnapPoint(TransInfo *t);
/********************** Mouse Input ******************************/
@@ -729,8 +729,8 @@ struct TransformOrientation *createMeshSpace(struct bContext *C, struct ReportLi
struct TransformOrientation *createBoneSpace(struct bContext *C, struct ReportList *reports, char *name, int overwrite);
/* Those two fill in mat and return non-zero on success */
-int createSpaceNormal(float mat[3][3], float normal[3]);
-int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3]);
+bool createSpaceNormal(float mat[3][3], const float normal[3]);
+bool createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3]);
struct TransformOrientation *addMatrixSpace(struct bContext *C, float mat[3][3], char name[], int overwrite);
void applyTransformOrientation(const struct bContext *C, float mat[3][3], char *name);
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index f3026205ea2..7678051fd38 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -557,13 +557,17 @@ void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[])
void setLocalConstraint(TransInfo *t, int mode, const char text[])
{
+ /* edit-mode now allows local transforms too */
+#if 0
if (t->flag & T_EDIT) {
float obmat[3][3];
copy_m3_m4(obmat, t->scene->obedit->obmat);
normalize_m3(obmat);
setConstraint(t, obmat, mode, text);
}
- else {
+ else
+#endif
+ {
if (t->total == 1) {
setConstraint(t, t->data->axismtx, mode, text);
}
@@ -743,37 +747,42 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
static void drawObjectConstraint(TransInfo *t)
{
- int i;
- TransData *td = t->data;
-
/* Draw the first one lighter because that's the one who controls the others.
* Meaning the transformation is projected on that one and just copied on the others
* constraint space.
* In a nutshell, the object with light axis is controlled by the user and the others follow.
* Without drawing the first light, users have little clue what they are doing.
*/
- if (t->con.mode & CON_AXIS0) {
- drawLine(t, td->ob->obmat[3], td->axismtx[0], 'X', DRAWLIGHT);
- }
- if (t->con.mode & CON_AXIS1) {
- drawLine(t, td->ob->obmat[3], td->axismtx[1], 'Y', DRAWLIGHT);
- }
- if (t->con.mode & CON_AXIS2) {
- drawLine(t, td->ob->obmat[3], td->axismtx[2], 'Z', DRAWLIGHT);
- }
+ short options = DRAWLIGHT;
+ TransData *td = t->data;
+ int i;
- td++;
+ for (i = 0; i < t->total; i++, td++) {
+ float co[3];
+
+ if (t->flag & T_OBJECT) {
+ copy_v3_v3(co, td->ob->obmat[3]);
+ }
+ else if (t->flag & T_EDIT) {
+ mul_v3_m4v3(co, t->obedit->obmat, td->center);
+ }
+ else if (t->flag & T_POSE) {
+ mul_v3_m4v3(co, t->poseobj->obmat, td->center);
+ }
+ else {
+ copy_v3_v3(co, td->center);
+ }
- for (i = 1; i < t->total; i++, td++) {
if (t->con.mode & CON_AXIS0) {
- drawLine(t, td->ob->obmat[3], td->axismtx[0], 'X', 0);
+ drawLine(t, td->center, td->axismtx[0], 'X', options);
}
if (t->con.mode & CON_AXIS1) {
- drawLine(t, td->ob->obmat[3], td->axismtx[1], 'Y', 0);
+ drawLine(t, td->center, td->axismtx[1], 'Y', options);
}
if (t->con.mode & CON_AXIS2) {
- drawLine(t, td->ob->obmat[3], td->axismtx[2], 'Z', 0);
+ drawLine(t, td->center, td->axismtx[2], 'Z', options);
}
+ options &= ~DRAWLIGHT;
}
}
@@ -992,20 +1001,20 @@ char constraintModeToChar(TransInfo *t)
}
-int isLockConstraint(TransInfo *t)
+bool isLockConstraint(TransInfo *t)
{
int mode = t->con.mode;
if ((mode & (CON_AXIS0 | CON_AXIS1)) == (CON_AXIS0 | CON_AXIS1))
- return 1;
+ return true;
if ((mode & (CON_AXIS1 | CON_AXIS2)) == (CON_AXIS1 | CON_AXIS2))
- return 1;
+ return true;
if ((mode & (CON_AXIS0 | CON_AXIS2)) == (CON_AXIS0 | CON_AXIS2))
- return 1;
+ return true;
- return 0;
+ return false;
}
/*
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index f84c967711c..661d7055036 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -125,7 +125,7 @@
/* local function prototype - for Object/Bone Constraints */
-static short constraints_list_needinv(TransInfo *t, ListBase *list);
+static bool constraints_list_needinv(TransInfo *t, ListBase *list);
/* ************************** Functions *************************** */
@@ -1236,6 +1236,8 @@ static void createTransMBallVerts(TransInfo *t)
copy_v3_v3(td->iloc, td->loc);
copy_v3_v3(td->center, td->loc);
+ quat_to_mat3(td->axismtx, ml->quat);
+
if (ml->flag & SELECT) td->flag = TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE;
else td->flag = TD_USEQUAT;
@@ -1858,32 +1860,29 @@ static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[3][3],
MEM_freeN(tots);
}
-/* loop-in-a-loop I know, but we need it! (ton) */
-static void get_face_center(float r_cent[3], BMVert *eve)
-
+static BMElem *bm_vert_single_select_face(BMVert *eve)
{
- BMFace *efa;
+ BMElem *ele;
BMIter iter;
- BM_ITER_ELEM (efa, &iter, eve, BM_FACES_OF_VERT) {
- if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
- BM_face_calc_center_mean(efa, r_cent);
- break;
+ BM_ITER_ELEM (ele, &iter, eve, BM_FACES_OF_VERT) {
+ if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
+ return ele;
}
}
+ return NULL;
}
-
-static void get_edge_center(float r_cent[3], BMVert *eve)
+static BMElem *bm_vert_single_select_edge(BMVert *eve)
{
- BMEdge *eed;
+ BMElem *ele;
BMIter iter;
- BM_ITER_ELEM (eed, &iter, eve, BM_EDGES_OF_VERT) {
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
- mid_v3_v3v3(r_cent, eed->v1->co, eed->v2->co);
- break;
+ BM_ITER_ELEM (ele, &iter, eve, BM_EDGES_OF_VERT) {
+ if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
+ return ele;
}
}
+ return NULL;
}
/* way to overwrite what data is edited with transform */
@@ -1895,25 +1894,51 @@ static void VertsToTransData(TransInfo *t, TransData *td, TransDataExtension *tx
// td->loc = key->co;
//else
td->loc = eve->co;
-
+ copy_v3_v3(td->iloc, td->loc);
copy_v3_v3(td->center, td->loc);
if (t->around == V3D_LOCAL) {
- if (em->selectmode & SCE_SELECT_FACE)
- get_face_center(td->center, eve);
- else if (em->selectmode & SCE_SELECT_EDGE)
- get_edge_center(td->center, eve);
+ BMElem *ele;
+ bool is_axismat_set = false;
+
+ if (em->selectmode & (SCE_SELECT_FACE | SCE_SELECT_EDGE) &&
+ (ele = ((em->selectmode & SCE_SELECT_FACE) ?
+ bm_vert_single_select_face(eve) :
+ bm_vert_single_select_edge(eve))))
+ {
+ float normal[3], tangent[3];
+
+ BMEditSelection ese;
+ ese.next = ese.prev = NULL;
+ ese.ele = ele;
+ ese.htype = ele->head.htype;
+
+ BM_editselection_center(&ese, td->center);
+ BM_editselection_normal(&ese, normal);
+ BM_editselection_plane(&ese, tangent);
+
+ if (createSpaceNormalTangent(td->axismtx, normal, tangent)) {
+ is_axismat_set = true;
+ }
+ }
+
+ /* for verts or fallback when createSpaceNormalTangent fails */
+ if (is_axismat_set == false) {
+ axis_dominant_v3_to_m3(td->axismtx, eve->no);
+ invert_m3(td->axismtx);
+ }
+ }
+ else {
+ /* Setting normals */
+ copy_v3_v3(td->axismtx[2], eve->no);
+ td->axismtx[0][0] =
+ td->axismtx[0][1] =
+ td->axismtx[0][2] =
+ td->axismtx[1][0] =
+ td->axismtx[1][1] =
+ td->axismtx[1][2] = 0.0f;
}
- copy_v3_v3(td->iloc, td->loc);
- // Setting normals
- copy_v3_v3(td->axismtx[2], eve->no);
- td->axismtx[0][0] =
- td->axismtx[0][1] =
- td->axismtx[0][2] =
- td->axismtx[1][0] =
- td->axismtx[1][1] =
- td->axismtx[1][2] = 0.0f;
td->ext = NULL;
td->val = NULL;
@@ -2503,7 +2528,7 @@ void flushTransUVs(TransInfo *t)
}
}
-int clipUVTransform(TransInfo *t, float *vec, int resize)
+bool clipUVTransform(TransInfo *t, float vec[2], const bool resize)
{
TransData *td;
int a, clipx = 1, clipy = 1;
@@ -2574,16 +2599,16 @@ void clipUVData(TransInfo *t)
/* ********************* ANIMATION EDITORS (GENERAL) ************************* */
/* This function tests if a point is on the "mouse" side of the cursor/frame-marking */
-static short FrameOnMouseSide(char side, float frame, float cframe)
+static bool FrameOnMouseSide(char side, float frame, float cframe)
{
/* both sides, so it doesn't matter */
- if (side == 'B') return 1;
+ if (side == 'B') return true;
/* only on the named side */
if (side == 'R')
- return (frame >= cframe) ? 1 : 0;
+ return (frame >= cframe);
else
- return (frame <= cframe) ? 1 : 0;
+ return (frame <= cframe);
}
/* ********************* NLA EDITOR ************************* */
@@ -4523,7 +4548,7 @@ static void createTransSeqData(bContext *C, TransInfo *t)
* These particular constraints benefit from this, but others don't, hence
* this semi-hack ;-) - Aligorith
*/
-static short constraints_list_needinv(TransInfo *t, ListBase *list)
+static bool constraints_list_needinv(TransInfo *t, ListBase *list)
{
bConstraint *con;
@@ -4536,26 +4561,30 @@ static short constraints_list_needinv(TransInfo *t, ListBase *list)
if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f)) {
/* (affirmative) returns for specific constraints here... */
/* constraints that require this regardless */
- if (con->type == CONSTRAINT_TYPE_CHILDOF) return 1;
- if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) return 1;
- if (con->type == CONSTRAINT_TYPE_CLAMPTO) return 1;
- if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) return 1;
- if (con->type == CONSTRAINT_TYPE_FOLLOWTRACK) return 1;
-
+ if (ELEM5(con->type,
+ CONSTRAINT_TYPE_CHILDOF,
+ CONSTRAINT_TYPE_FOLLOWPATH,
+ CONSTRAINT_TYPE_CLAMPTO,
+ CONSTRAINT_TYPE_OBJECTSOLVER,
+ CONSTRAINT_TYPE_FOLLOWTRACK))
+ {
+ return true;
+ }
+
/* constraints that require this only under special conditions */
if (con->type == CONSTRAINT_TYPE_ROTLIKE) {
/* CopyRot constraint only does this when rotating, and offset is on */
bRotateLikeConstraint *data = (bRotateLikeConstraint *)con->data;
if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION))
- return 1;
+ return true;
}
}
}
}
/* no appropriate candidates found */
- return 0;
+ return false;
}
/* transcribe given object into TransData for Transforming */
@@ -4563,8 +4592,8 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
{
Scene *scene = t->scene;
float obmtx[3][3];
- short constinv;
- short skip_invert = 0;
+ bool constinv;
+ bool skip_invert = false;
if (t->mode != TFM_DUMMY && ob->rigidbody_object) {
float rot[3][3], scale[3];
@@ -4602,15 +4631,15 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
/* disable constraints inversion for dummy pass */
if (t->mode == TFM_DUMMY)
- skip_invert = 1;
+ skip_invert = true;
- if (skip_invert == 0 && constinv == 0) {
- if (constinv == 0)
+ if (skip_invert == false && constinv == false) {
+ if (constinv == false)
ob->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc_time checks this */
BKE_object_where_is_calc(t->scene, ob);
- if (constinv == 0)
+ if (constinv == false)
ob->transflag &= ~OB_NO_CONSTRAINTS;
}
else
@@ -4762,19 +4791,19 @@ static void set_trans_object_base_flags(TransInfo *t)
}
}
-static int mark_children(Object *ob)
+static bool mark_children(Object *ob)
{
if (ob->flag & (SELECT | BA_TRANSFORM_CHILD))
- return 1;
+ return true;
if (ob->parent) {
if (mark_children(ob->parent)) {
ob->flag |= BA_TRANSFORM_CHILD;
- return 1;
+ return true;
}
}
- return 0;
+ return false;
}
static int count_proportional_objects(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 41a3418ada9..889e4f01fc7 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -719,13 +719,13 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i
side_delta = 2.0f * (float)M_PI / (float)nsides;
theta = (float)M_PI + 0.5f * ring_delta;
- cos_theta = (float)cos(theta);
- sin_theta = (float)sin(theta);
+ cos_theta = cosf(theta);
+ sin_theta = sinf(theta);
for (i = nrings - 1; i >= 0; i--) {
theta1 = theta + ring_delta;
- cos_theta1 = (float)cos(theta1);
- sin_theta1 = (float)sin(theta1);
+ cos_theta1 = cosf(theta1);
+ sin_theta1 = sinf(theta1);
if (do_caps && i == start) { // cap
glBegin(GL_POLYGON);
@@ -766,8 +766,8 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i
float cos_phi, sin_phi, dist;
phi -= side_delta;
- cos_phi = (float)cos(phi);
- sin_phi = (float)sin(phi);
+ cos_phi = cosf(phi);
+ sin_phi = sinf(phi);
dist = radhole + radring * cos_phi;
glVertex3f(cos_theta * dist, -sin_theta * dist, radring * sin_phi);
@@ -841,27 +841,6 @@ static void manipulator_setcolor(View3D *v3d, char axis, int colcode, unsigned c
glColor4ubv(col);
}
-static void axis_sort_v3(const float axis_values[3], int r_axis_order[3])
-{
- float v[3];
- copy_v3_v3(v, axis_values);
-
-#define SWAP_AXIS(a, b) { \
- SWAP(float, v[a], v[b]); \
- SWAP(int, r_axis_order[a], r_axis_order[b]); \
-} (void)0
-
- if (v[0] < v[1]) {
- if (v[2] < v[0]) { SWAP_AXIS(0, 2); }
- }
- else {
- if (v[1] < v[2]) { SWAP_AXIS(0, 1); }
- else { SWAP_AXIS(0, 2); }
- }
- if (v[2] < v[1]) { SWAP_AXIS(1, 2); }
-
-#undef SWAP_AXIS
-}
static void manipulator_axis_order(RegionView3D *rv3d, int r_axis_order[3])
{
float axis_values[3];
@@ -1635,15 +1614,18 @@ void BIF_draw_manipulator(const bContext *C)
switch (v3d->around) {
case V3D_CENTER:
case V3D_ACTIVE:
- rv3d->twmat[3][0] = (scene->twmin[0] + scene->twmax[0]) / 2.0f;
- rv3d->twmat[3][1] = (scene->twmin[1] + scene->twmax[1]) / 2.0f;
- rv3d->twmat[3][2] = (scene->twmin[2] + scene->twmax[2]) / 2.0f;
- if (v3d->around == V3D_ACTIVE && scene->obedit == NULL) {
- Object *ob = OBACT;
- if (ob && !(ob->mode & OB_MODE_POSE))
- copy_v3_v3(rv3d->twmat[3], ob->obmat[3]);
+ {
+ Object *ob;
+ if (((v3d->around == V3D_ACTIVE) && (scene->obedit == NULL)) &&
+ ((ob = OBACT) && !(ob->mode & OB_MODE_POSE)))
+ {
+ copy_v3_v3(rv3d->twmat[3], ob->obmat[3]);
+ }
+ else {
+ mid_v3_v3v3(rv3d->twmat[3], scene->twmin, scene->twmax);
}
break;
+ }
case V3D_LOCAL:
case V3D_CENTROID:
copy_v3_v3(rv3d->twmat[3], scene->twcent);
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 0c1f169935a..023083a98ff 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -213,13 +213,13 @@ TransformOrientation *createMeshSpace(bContext *C, ReportList *reports, char *na
return addMatrixSpace(C, mat, name, overwrite);
}
-int createSpaceNormal(float mat[3][3], float normal[3])
+bool createSpaceNormal(float mat[3][3], const float normal[3])
{
float tangent[3] = {0.0f, 0.0f, 1.0f};
copy_v3_v3(mat[2], normal);
if (normalize_v3(mat[2]) == 0.0f) {
- return 0; /* error return */
+ return false; /* error return */
}
cross_v3_v3v3(mat[0], mat[2], tangent);
@@ -233,14 +233,14 @@ int createSpaceNormal(float mat[3][3], float normal[3])
normalize_m3(mat);
- return 1;
+ return true;
}
-int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3])
+bool createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3])
{
copy_v3_v3(mat[2], normal);
if (normalize_v3(mat[2]) == 0.0f) {
- return 0; /* error return */
+ return false; /* error return */
}
/* preempt zero length tangent from causing trouble */
@@ -250,14 +250,14 @@ int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3])
cross_v3_v3v3(mat[0], mat[2], tangent);
if (normalize_v3(mat[0]) == 0.0f) {
- return 0; /* error return */
+ return false; /* error return */
}
cross_v3_v3v3(mat[1], mat[2], mat[0]);
normalize_m3(mat);
- return 1;
+ return true;
}
TransformOrientation *addMatrixSpace(bContext *C, float mat[3][3], char name[], int overwrite)
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index fdbfdfc8675..c6ab33124ef 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -78,7 +78,11 @@
#include "transform.h"
-#define TRANSFORM_DIST_MAX_PX 1000
+/* this should be passed as an arg for use in snap functions */
+#undef BASACT
+
+#define TRANSFORM_DIST_MAX_PX 1000.0f
+#define TRANSFORM_SNAP_MAX_PX 100.0f
/********************* PROTOTYPES ***********************/
@@ -120,13 +124,13 @@ int BIF_snappingSupported(Object *obedit)
}
#endif
-int validSnap(TransInfo *t)
+bool validSnap(TransInfo *t)
{
return (t->tsnap.status & (POINT_INIT | TARGET_INIT)) == (POINT_INIT | TARGET_INIT) ||
(t->tsnap.status & (MULTI_POINTS | TARGET_INIT)) == (MULTI_POINTS | TARGET_INIT);
}
-int activeSnap(TransInfo *t)
+bool activeSnap(TransInfo *t)
{
return (t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP || (t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT;
}
@@ -260,9 +264,9 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
}
}
-int handleSnapping(TransInfo *t, const wmEvent *event)
+bool handleSnapping(TransInfo *t, const wmEvent *event)
{
- int status = 0;
+ bool status = false;
#if 0 // XXX need a proper selector for all snap mode
if (BIF_snappingSupported(t->obedit) && event->type == TABKEY && event->shift) {
@@ -295,8 +299,8 @@ void applyProject(TransInfo *t)
for (i = 0; i < t->total; i++, td++) {
float iloc[3], loc[3], no[3];
- float mval[2];
- int dist = TRANSFORM_DIST_MAX_PX;
+ float mval_fl[2];
+ float dist_px = TRANSFORM_DIST_MAX_PX;
if (td->flag & TD_NOACTION)
break;
@@ -318,8 +322,8 @@ void applyProject(TransInfo *t)
copy_v3_v3(iloc, td->ob->obmat[3]);
}
- if (ED_view3d_project_float_global(t->ar, iloc, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
- if (snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.modeSelect)) {
+ if (ED_view3d_project_float_global(t->ar, iloc, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
+ if (snapObjectsTransform(t, mval_fl, &dist_px, loc, no, t->tsnap.modeSelect)) {
// if (t->flag & (T_EDIT|T_POSE)) {
// mul_m4_v3(imat, loc);
// }
@@ -368,7 +372,7 @@ void applySnapping(TransInfo *t, float *vec)
void resetSnapping(TransInfo *t)
{
t->tsnap.status = 0;
- t->tsnap.align = 0;
+ t->tsnap.align = false;
t->tsnap.project = 0;
t->tsnap.mode = 0;
t->tsnap.modeSelect = 0;
@@ -383,20 +387,20 @@ void resetSnapping(TransInfo *t)
t->tsnap.snapNodeBorder = 0;
}
-int usingSnappingNormal(TransInfo *t)
+bool usingSnappingNormal(TransInfo *t)
{
return t->tsnap.align;
}
-int validSnappingNormal(TransInfo *t)
+bool validSnappingNormal(TransInfo *t)
{
if (validSnap(t)) {
if (dot_v3v3(t->tsnap.snapNormal, t->tsnap.snapNormal) > 0) {
- return 1;
+ return true;
}
}
- return 0;
+ return false;
}
static void initSnappingMode(TransInfo *t)
@@ -404,6 +408,7 @@ static void initSnappingMode(TransInfo *t)
ToolSettings *ts = t->settings;
Object *obedit = t->obedit;
Scene *scene = t->scene;
+ Base *base_act = scene->basact;
if (t->spacetype == SPACE_NODE) {
/* force project off when not supported */
@@ -444,7 +449,7 @@ static void initSnappingMode(TransInfo *t)
}
/* Particles edit mode*/
else if (t->tsnap.applySnap != NULL && // A snapping function actually exist
- (obedit == NULL && BASACT && BASACT->object && BASACT->object->mode & OB_MODE_PARTICLE_EDIT))
+ (obedit == NULL && base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT))
{
t->tsnap.modeSelect = SNAP_ALL;
}
@@ -598,35 +603,32 @@ void addSnapPoint(TransInfo *t)
}
}
-int updateSelectedSnapPoint(TransInfo *t)
+bool updateSelectedSnapPoint(TransInfo *t)
{
- int status = 0;
+ bool status = false;
if (t->tsnap.status & MULTI_POINTS) {
TransSnapPoint *p, *closest_p = NULL;
- int closest_dist = 0;
- int screen_loc[2];
+ float closest_dist = TRANSFORM_SNAP_MAX_PX;
+ const float mval_fl[2] = {t->mval[0], t->mval[1]};
+ float screen_loc[2];
for (p = t->tsnap.points.first; p; p = p->next) {
- int dx, dy;
- int dist;
+ float dist;
- if (ED_view3d_project_int_global(t->ar, p->co, screen_loc, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) {
+ if (ED_view3d_project_float_global(t->ar, p->co, screen_loc, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) {
continue;
}
- dx = t->mval[0] - screen_loc[0];
- dy = t->mval[1] - screen_loc[1];
-
- dist = dx * dx + dy * dy;
+ dist = len_squared_v2v2(mval_fl, screen_loc);
- if (dist < 100 && (closest_p == NULL || closest_dist > dist)) {
+ if (dist < closest_dist) {
closest_p = p;
closest_dist = dist;
}
}
if (closest_p) {
- status = t->tsnap.selectedPoint == closest_p ? 0 : 1;
+ status = (t->tsnap.selectedPoint != closest_p);
t->tsnap.selectedPoint = closest_p;
}
}
@@ -819,7 +821,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
float no[3];
float mval[2];
bool found = false;
- int dist = SNAP_MIN_DISTANCE; // Use a user defined value here
+ float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here
mval[0] = t->mval[0];
mval[1] = t->mval[1];
@@ -907,7 +909,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
BLI_freelistN(&depth_peels);
}
else {
- found = snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.modeSelect);
+ found = snapObjectsTransform(t, mval, &dist_px, loc, no, t->tsnap.modeSelect);
}
if (found == true) {
@@ -949,10 +951,10 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
}
else if (t->spacetype == SPACE_NODE) {
float loc[2];
- int dist = SNAP_MIN_DISTANCE; // Use a user defined value here
+ float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here
char node_border;
- if (snapNodesTransform(t, t->mval, &dist, loc, &node_border, t->tsnap.modeSelect)) {
+ if (snapNodesTransform(t, t->mval, &dist_px, loc, &node_border, t->tsnap.modeSelect)) {
copy_v2_v2(t->tsnap.snapPoint, loc);
t->tsnap.snapNodeBorder = node_border;
@@ -1145,8 +1147,8 @@ static void TargetSnapClosest(TransInfo *t)
}
static bool snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], short v2no[3], float obmat[4][4], float timat[3][3],
- const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], const float mval[2],
- float r_loc[3], float r_no[3], int *r_dist, float *r_depth)
+ const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], const float mval_fl[2],
+ float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth)
{
float intersect[3] = {0, 0, 0}, ray_end[3], dvec[3];
int result;
@@ -1182,8 +1184,8 @@ static bool snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], s
if (dot_v3v3(ray_normal_local, dvec) > 0) {
float location[3];
float new_depth;
- int screen_loc[2];
- int new_dist;
+ float screen_loc[2];
+ float new_dist;
copy_v3_v3(location, intersect);
@@ -1191,8 +1193,8 @@ static bool snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], s
new_depth = len_v3v3(location, ray_start);
- if (ED_view3d_project_int_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
- new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
+ if (ED_view3d_project_float_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
+ new_dist = len_manhattan_v2v2(mval_fl, screen_loc);
}
else {
new_dist = TRANSFORM_DIST_MAX_PX;
@@ -1202,7 +1204,7 @@ static bool snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], s
* this takes care of series of connected edges a bit slanted w.r.t the viewport
* otherwise, it would stick to the verts of the closest edge and not slide along merrily
* */
- if (new_dist <= *r_dist && new_depth < *r_depth * 1.001f) {
+ if (new_dist <= *r_dist_px && new_depth < *r_depth * 1.001f) {
float n1[3], n2[3];
*r_depth = new_depth;
@@ -1223,7 +1225,7 @@ static bool snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], s
copy_v3_v3(r_loc, location);
- *r_dist = new_dist;
+ *r_dist_px = new_dist;
}
}
}
@@ -1232,8 +1234,8 @@ static bool snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], s
}
static bool snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[4][4], float timat[3][3],
- const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], const float mval[2],
- float r_loc[3], float r_no[3], int *r_dist, float *r_depth)
+ const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], const float mval_fl[2],
+ float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth)
{
bool retval = false;
float dvec[3];
@@ -1243,8 +1245,8 @@ static bool snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[4][4
if (dot_v3v3(ray_normal_local, dvec) > 0) {
float location[3];
float new_depth;
- int screen_loc[2];
- int new_dist;
+ float screen_loc[2];
+ float new_dist;
copy_v3_v3(location, vco);
@@ -1252,15 +1254,15 @@ static bool snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[4][4
new_depth = len_v3v3(location, ray_start);
- if (ED_view3d_project_int_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
- new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
+ if (ED_view3d_project_float_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
+ new_dist = len_manhattan_v2v2(mval_fl, screen_loc);
}
else {
new_dist = TRANSFORM_DIST_MAX_PX;
}
- if (new_dist <= *r_dist && new_depth < *r_depth) {
+ if (new_dist <= *r_dist_px && new_depth < *r_depth) {
*r_depth = new_depth;
retval = true;
@@ -1272,7 +1274,7 @@ static bool snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[4][4
normalize_v3(r_no);
}
- *r_dist = new_dist;
+ *r_dist_px = new_dist;
}
}
@@ -1281,7 +1283,7 @@ static bool snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[4][4
static bool snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm, float obmat[4][4],
const float ray_start[3], const float ray_normal[3], const float mval[2],
- float r_loc[3], float *UNUSED(r_no), int *r_dist, float *r_depth)
+ float r_loc[3], float *UNUSED(r_no), float *r_dist_px, float *r_depth)
{
float imat[4][4];
float ray_start_local[3], ray_normal_local[3];
@@ -1304,11 +1306,11 @@ static bool snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *ar
if ((eBone->flag & (BONE_HIDDEN_A | BONE_ROOTSEL | BONE_TIPSEL)) == 0) {
switch (snap_mode) {
case SCE_SNAP_MODE_VERTEX:
- retval |= snapVertex(ar, eBone->head, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth);
- retval |= snapVertex(ar, eBone->tail, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth);
+ retval |= snapVertex(ar, eBone->head, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
+ retval |= snapVertex(ar, eBone->tail, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
break;
case SCE_SNAP_MODE_EDGE:
- retval |= snapEdge(ar, eBone->head, NULL, eBone->tail, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth);
+ retval |= snapEdge(ar, eBone->head, NULL, eBone->tail, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
break;
}
}
@@ -1328,11 +1330,11 @@ static bool snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *ar
switch (snap_mode) {
case SCE_SNAP_MODE_VERTEX:
- retval |= snapVertex(ar, head_vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth);
- retval |= snapVertex(ar, tail_vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth);
+ retval |= snapVertex(ar, head_vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
+ retval |= snapVertex(ar, tail_vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
break;
case SCE_SNAP_MODE_EDGE:
- retval |= snapEdge(ar, head_vec, NULL, tail_vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth);
+ retval |= snapEdge(ar, head_vec, NULL, tail_vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth);
break;
}
}
@@ -1344,7 +1346,7 @@ static bool snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *ar
static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, BMEditMesh *em, float obmat[4][4],
const float ray_start[3], const float ray_normal[3], const float mval[2],
- float r_loc[3], float r_no[3], int *r_dist, float *r_depth)
+ float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth)
{
bool retval = false;
int totvert = dm->getNumVerts(dm);
@@ -1451,7 +1453,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
if (test) {
- retval |= snapVertex(ar, v->co, v->no, obmat, timat, ray_start, ray_start_local, ray_normal_local, mval, r_loc, r_no, r_dist, r_depth);
+ retval |= snapVertex(ar, v->co, v->no, obmat, timat, ray_start, ray_start_local, ray_normal_local, mval, r_loc, r_no, r_dist_px, r_depth);
}
}
@@ -1501,7 +1503,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
}
if (test) {
- retval |= snapEdge(ar, verts[e->v1].co, verts[e->v1].no, verts[e->v2].co, verts[e->v2].no, obmat, timat, ray_start, ray_start_local, ray_normal_local, mval, r_loc, r_no, r_dist, r_depth);
+ retval |= snapEdge(ar, verts[e->v1].co, verts[e->v1].no, verts[e->v2].co, verts[e->v2].no, obmat, timat, ray_start, ray_start_local, ray_normal_local, mval, r_loc, r_no, r_dist_px, r_depth);
}
}
@@ -1514,11 +1516,10 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
return retval;
}
-static bool snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, float obmat[4][4],
+static bool snapObject(Scene *scene, short snap_mode, ARegion *ar, Object *ob, int editobject, float obmat[4][4],
const float ray_start[3], const float ray_normal[3], const float mval[2],
- float r_loc[3], float r_no[3], int *r_dist, float *r_depth)
+ float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth)
{
- ToolSettings *ts = scene->toolsettings;
bool retval = false;
if (ob->type == OB_MESH) {
@@ -1535,31 +1536,29 @@ static bool snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, fl
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
}
- retval = snapDerivedMesh(ts->snap_mode, ar, ob, dm, em, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, r_depth);
+ retval = snapDerivedMesh(snap_mode, ar, ob, dm, em, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth);
dm->release(dm);
}
else if (ob->type == OB_ARMATURE) {
- retval = snapArmature(ts->snap_mode, ar, ob, ob->data, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, r_depth);
+ retval = snapArmature(snap_mode, ar, ob, ob->data, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth);
}
return retval;
}
-static bool snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, const float mval[2],
- int *r_dist, float r_loc[3], float r_no[3], SnapMode mode)
+static bool snapObjectsRay(Scene *scene, short snap_mode, Base *base_act, View3D *v3d, ARegion *ar, Object *obedit,
+ const float ray_start[3], const float ray_normal[3],
+ const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode)
{
Base *base;
float depth = (FLT_MAX / 2.0f); /* use half of flt-max so we can scale up without an exception */
bool retval = false;
- float ray_start[3], ray_normal[3];
-
- ED_view3d_win_to_ray(ar, v3d, mval, ray_start, ray_normal);
if (mode == SNAP_ALL && obedit) {
Object *ob = obedit;
- retval |= snapObject(scene, ar, ob, 1, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, &depth);
+ retval |= snapObject(scene, snap_mode, ar, ob, 1, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, &depth);
}
/* Need an exception for particle edit because the base is flagged with BA_HAS_RECALC_DATA
@@ -1567,10 +1566,10 @@ static bool snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit,
*
* To solve that problem, we do it first as an exception.
* */
- base = BASACT;
+ base = base_act;
if (base && base->object && base->object->mode & OB_MODE_PARTICLE_EDIT) {
Object *ob = base->object;
- retval |= snapObject(scene, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, &depth);
+ retval |= snapObject(scene, snap_mode, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, &depth);
}
for (base = FIRSTBASE; base != NULL; base = base->next) {
@@ -1578,7 +1577,7 @@ static bool snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit,
(base->flag & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 &&
((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT | BA_WAS_SEL)) == 0) ||
- (ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != BASACT)))
+ (ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != base_act)))
{
Object *ob = base->object;
@@ -1589,30 +1588,58 @@ static bool snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit,
for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) {
Object *dob = dupli_ob->ob;
- retval |= snapObject(scene, ar, dob, 0, dupli_ob->mat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, &depth);
+ retval |= snapObject(scene, snap_mode, ar, dob, 0, dupli_ob->mat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, &depth);
}
free_object_duplilist(lb);
}
- retval |= snapObject(scene, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, &depth);
+ retval |= snapObject(scene, snap_mode, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, &depth);
}
}
return retval;
}
+static bool snapObjects(Scene *scene, short snap_mode, Base *base_act, View3D *v3d, ARegion *ar, Object *obedit,
+ const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode)
+{
+ float ray_start[3], ray_normal[3];
+
+ ED_view3d_win_to_ray(ar, v3d, mval, ray_start, ray_normal);
+
+ return snapObjectsRay(scene, snap_mode, base_act, v3d, ar, obedit,
+ ray_start, ray_normal,
+ mval, r_dist_px, r_loc, r_no, mode);
+}
-bool snapObjectsTransform(TransInfo *t, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode)
+bool snapObjectsTransform(TransInfo *t, const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode)
{
- return snapObjects(t->scene, t->view, t->ar, t->obedit, mval, r_dist, r_loc, r_no, mode);
+ return snapObjects(t->scene, t->scene->toolsettings->snap_mode, t->scene->basact, t->view, t->ar, t->obedit,
+ mval, r_dist_px, r_loc, r_no, mode);
}
-bool snapObjectsContext(bContext *C, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode)
+bool snapObjectsContext(bContext *C, const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode)
{
ScrArea *sa = CTX_wm_area(C);
View3D *v3d = sa->spacedata.first;
+ Scene *scene = CTX_data_scene(C);
- return snapObjects(CTX_data_scene(C), v3d, CTX_wm_region(C), CTX_data_edit_object(C), mval, r_dist, r_loc, r_no, mode);
+ return snapObjects(scene, scene->toolsettings->snap_mode, scene->basact, v3d, CTX_wm_region(C), CTX_data_edit_object(C), mval, r_dist_px, r_loc, r_no, mode);
+}
+
+bool snapObjectsEx(Scene *scene, Base *base_act, View3D *v3d, ARegion *ar, Object *obedit, short snap_mode,
+ const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode)
+{
+ return snapObjects(scene, snap_mode, base_act, v3d, ar, obedit,
+ mval, r_dist_px, r_loc, r_no, mode);
+}
+bool snapObjectsRayEx(Scene *scene, Base *base_act, View3D *v3d, ARegion *ar, Object *obedit, short snap_mode,
+ const float ray_start[3], const float ray_normal[3],
+ const float mval[2], float *r_dist_px, float r_loc[3], float r_no[3], SnapMode mode)
+{
+ return snapObjectsRay(scene, snap_mode, base_act, v3d, ar, obedit,
+ ray_start, ray_normal,
+ mval, r_dist_px, r_loc, r_no, mode);
}
/******************** PEELING *********************************/
@@ -1889,7 +1916,7 @@ static NodeBorder snapNodeBorder(int snap_node_mode)
}
static bool snapNode(ToolSettings *ts, SpaceNode *UNUSED(snode), ARegion *ar, bNode *node, const int mval[2],
- float r_loc[2], int *r_dist, char *r_node_border)
+ float r_loc[2], float *r_dist_px, char *r_node_border)
{
View2D *v2d = &ar->v2d;
NodeBorder border = snapNodeBorder(ts->snap_node_mode);
@@ -1902,9 +1929,9 @@ static bool snapNode(ToolSettings *ts, SpaceNode *UNUSED(snode), ARegion *ar, bN
if (border & NODE_LEFT) {
new_dist = abs(totr.xmin - mval[0]);
- if (new_dist < *r_dist) {
+ if (new_dist < *r_dist_px) {
UI_view2d_region_to_view(v2d, totr.xmin, mval[1], &r_loc[0], &r_loc[1]);
- *r_dist = new_dist;
+ *r_dist_px = new_dist;
*r_node_border = NODE_LEFT;
retval = true;
}
@@ -1912,9 +1939,9 @@ static bool snapNode(ToolSettings *ts, SpaceNode *UNUSED(snode), ARegion *ar, bN
if (border & NODE_RIGHT) {
new_dist = abs(totr.xmax - mval[0]);
- if (new_dist < *r_dist) {
+ if (new_dist < *r_dist_px) {
UI_view2d_region_to_view(v2d, totr.xmax, mval[1], &r_loc[0], &r_loc[1]);
- *r_dist = new_dist;
+ *r_dist_px = new_dist;
*r_node_border = NODE_RIGHT;
retval = true;
}
@@ -1922,9 +1949,9 @@ static bool snapNode(ToolSettings *ts, SpaceNode *UNUSED(snode), ARegion *ar, bN
if (border & NODE_BOTTOM) {
new_dist = abs(totr.ymin - mval[1]);
- if (new_dist < *r_dist) {
+ if (new_dist < *r_dist_px) {
UI_view2d_region_to_view(v2d, mval[0], totr.ymin, &r_loc[0], &r_loc[1]);
- *r_dist = new_dist;
+ *r_dist_px = new_dist;
*r_node_border = NODE_BOTTOM;
retval = true;
}
@@ -1932,9 +1959,9 @@ static bool snapNode(ToolSettings *ts, SpaceNode *UNUSED(snode), ARegion *ar, bN
if (border & NODE_TOP) {
new_dist = abs(totr.ymax - mval[1]);
- if (new_dist < *r_dist) {
+ if (new_dist < *r_dist_px) {
UI_view2d_region_to_view(v2d, mval[0], totr.ymax, &r_loc[0], &r_loc[1]);
- *r_dist = new_dist;
+ *r_dist_px = new_dist;
*r_node_border = NODE_TOP;
retval = true;
}
@@ -1944,7 +1971,7 @@ static bool snapNode(ToolSettings *ts, SpaceNode *UNUSED(snode), ARegion *ar, bN
}
static bool snapNodes(ToolSettings *ts, SpaceNode *snode, ARegion *ar, const int mval[2],
- int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode)
+ float *r_dist_px, float r_loc[2], char *r_node_border, SnapMode mode)
{
bNodeTree *ntree = snode->edittree;
bNode *node;
@@ -1954,21 +1981,21 @@ static bool snapNodes(ToolSettings *ts, SpaceNode *snode, ARegion *ar, const int
for (node = ntree->nodes.first; node; node = node->next) {
if (snapNodeTest(&ar->v2d, node, mode))
- retval |= snapNode(ts, snode, ar, node, mval, r_loc, r_dist, r_node_border);
+ retval |= snapNode(ts, snode, ar, node, mval, r_loc, r_dist_px, r_node_border);
}
return retval;
}
-bool snapNodesTransform(TransInfo *t, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode)
+bool snapNodesTransform(TransInfo *t, const int mval[2], float *r_dist_px, float r_loc[2], char *r_node_border, SnapMode mode)
{
- return snapNodes(t->settings, t->sa->spacedata.first, t->ar, mval, r_dist, r_loc, r_node_border, mode);
+ return snapNodes(t->settings, t->sa->spacedata.first, t->ar, mval, r_dist_px, r_loc, r_node_border, mode);
}
-bool snapNodesContext(bContext *C, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode)
+bool snapNodesContext(bContext *C, const int mval[2], float *r_dist_px, float r_loc[2], char *r_node_border, SnapMode mode)
{
Scene *scene = CTX_data_scene(C);
- return snapNodes(scene->toolsettings, CTX_wm_space_node(C), CTX_wm_region(C), mval, r_dist, r_loc, r_node_border, mode);
+ return snapNodes(scene->toolsettings, CTX_wm_space_node(C), CTX_wm_region(C), mval, r_dist_px, r_loc, r_node_border, mode);
}
/*================================================================*/
diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt
index e0991c48fa6..bcc55c4ea6e 100644
--- a/source/blender/editors/util/CMakeLists.txt
+++ b/source/blender/editors/util/CMakeLists.txt
@@ -32,7 +32,7 @@ set(INC
)
set(INC_SYS
-
+ ${GLEW_INCLUDE_PATH}
)
set(SRC
@@ -90,6 +90,8 @@ set(SRC
../include/UI_view2d.h
)
+add_definitions(-DGLEW_STATIC)
+
if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
diff --git a/source/blender/editors/util/SConscript b/source/blender/editors/util/SConscript
index 1c1a8e46dd7..8460b307f0d 100644
--- a/source/blender/editors/util/SConscript
+++ b/source/blender/editors/util/SConscript
@@ -28,7 +28,7 @@
Import ('env')
sources = env.Glob('*.c')
-defs = []
+defs = [ 'GLEW_STATIC' ]
incs = '../include ../../blenfont ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 73062c57526..35e6c40c36b 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -37,11 +37,15 @@
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
+#include "DNA_screen_types.h"
#include "DNA_scene_types.h"
#include "DNA_packedFile_types.h"
#include "BLI_blenlib.h"
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
#include "BLF_translation.h"
#include "BKE_context.h"
@@ -54,6 +58,7 @@
#include "ED_mesh.h"
#include "ED_object.h"
#include "ED_sculpt.h"
+#include "ED_space_api.h"
#include "ED_util.h"
#include "UI_interface.h"
@@ -157,17 +162,6 @@ void apply_keyb_grid(int shift, int ctrl, float *val, float fac1, float fac2, fl
}
}
-#if 0 /* UNUSED */
-int GetButStringLength(const char *str)
-{
- int rt;
-
- rt = UI_GetStringWidth(str);
-
- return rt + 15;
-}
-#endif
-
void unpack_menu(bContext *C, const char *opname, const char *id_name, const char *abs_name, const char *folder, struct PackedFile *pf)
{
PointerRNA props_ptr;
@@ -255,3 +249,24 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
uiPupMenuEnd(C, pup);
}
+
+/* ********************* generic callbacks for drawcall api *********************** */
+
+/**
+ * Callback that draws a line between the mouse and a position given as the initial argument.
+ */
+void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info)
+{
+ wmWindow *win = CTX_wm_window(C);
+ const int *mval_src = (int *)arg_info;
+ const int mval_dst[2] = {win->eventstate->x - ar->winrct.xmin,
+ win->eventstate->y - ar->winrct.ymin};
+
+ UI_ThemeColor(TH_WIRE);
+ setlinestyle(3);
+ glBegin(GL_LINE_STRIP);
+ glVertex2iv(mval_dst);
+ glVertex2iv(mval_src);
+ glEnd();
+ setlinestyle(0);
+}