Commit: 91fc0c4f2a8dcd71b3ad1f96ac7718ab2e222962
Author: Julian Eisel
Date:   Wed Oct 19 00:10:49 2016 +0200
Branches: transform-manipulators
https://developer.blender.org/rB91fc0c4f2a8dcd71b3ad1f96ac7718ab2e222962

Initial implementation of a new transform manipulator

This commit adds the basic framework for the new transform manipulators and 
also includes working manipulators for translation.

Wasn't really happy with the new transform manipulators code in the 
custom-manipulators (used to be wiggly-widgets) branch, especially since it 
reused quite some code of the old manipulator which is messy as hell. I decided 
to refactor this code by rewriting it from scratch. I'm doing this in an own 
branch so it can easily be merged into blender 2.8 when ready.

The new transform manipulators are part of the space_view3d module, IMHO they 
fit better into this than into transform module.

===================================================================

M       source/blender/editors/include/ED_transform.h
M       source/blender/editors/space_view3d/CMakeLists.txt
M       source/blender/editors/space_view3d/space_view3d.c
M       source/blender/editors/space_view3d/view3d_draw.c
M       source/blender/editors/space_view3d/view3d_draw_legacy.c
M       source/blender/editors/space_view3d/view3d_edit.c
M       source/blender/editors/space_view3d/view3d_intern.h
M       source/blender/editors/space_view3d/view3d_ops.c
A       source/blender/editors/space_view3d/view3d_transform_manipulators.c
M       source/blender/editors/transform/transform.h
M       source/blender/editors/transform/transform_manipulator.c
M       source/blender/editors/transform/transform_orientations.c
M       source/blender/makesdna/DNA_view3d_types.h
M       source/blender/windowmanager/CMakeLists.txt
M       source/blender/windowmanager/WM_api.h
A       source/blender/windowmanager/manipulators/WM_manipulator_library.h
M       source/blender/windowmanager/manipulators/WM_manipulator_types.h
A       
source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c
M       
source/blender/windowmanager/manipulators/intern/manipulator_library/manipulator_library_intern.h
M       source/blender/windowmanager/manipulators/intern/wm_manipulator.c
M       source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
M       source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h

===================================================================

diff --git a/source/blender/editors/include/ED_transform.h 
b/source/blender/editors/include/ED_transform.h
index ebd2a3d..a77d9ab 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -130,7 +130,10 @@ void BIF_createTransformOrientation(struct bContext *C, 
struct ReportList *repor
 void BIF_selectTransformOrientation(struct bContext *C, struct 
TransformOrientation *ts);
 void BIF_selectTransformOrientationValue(struct bContext *C, int orientation);
 
-void ED_getTransformOrientationMatrix(const struct bContext *C, float 
orientation_mat[3][3], const short around);
+void ED_getLocalTransformOrientationMatrix(const struct bContext *C, float 
orientation_mat[3][3], const short around);
+void ED_getTransformOrientationMatrix(
+        const struct bContext *C, const char orientation_type, const short 
around,
+        float r_orientation_mat[3][3]);
 
 int BIF_countTransformOrientation(const struct bContext *C);
 
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt 
b/source/blender/editors/space_view3d/CMakeLists.txt
index 8fca2ed..e73d0cf 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -64,6 +64,7 @@ set(SRC
        view3d_select.c
        view3d_snap.c
        view3d_toolbar.c
+       view3d_transform_manipulators.c
        view3d_view.c
 
        view3d_intern.h
diff --git a/source/blender/editors/space_view3d/space_view3d.c 
b/source/blender/editors/space_view3d/space_view3d.c
index 4526d12..f5e28df 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -488,6 +488,12 @@ static void view3d_main_region_init(wmWindowManager *wm, 
ARegion *ar)
        ListBase *lb;
        wmKeyMap *keymap;
 
+       if (!ar->manipulator_map) {
+               ar->manipulator_map = WM_manipulatormap_new_from_type(&(const 
struct wmManipulatorMapType_Params) {
+                       "View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW});
+       }
+       WM_manipulatormap_add_handlers(ar, ar->manipulator_map);
+
        /* object ops. */
        
        /* important to be before Pose keymap since they can both be enabled at 
once */
@@ -813,7 +819,8 @@ static void view3d_main_region_listener(bScreen *sc, 
ScrArea *sa, ARegion *ar, w
 {
        Scene *scene = sc->scene;
        View3D *v3d = sa->spacedata.first;
-       
+       wmManipulatorMap *mmap = ar->manipulator_map;
+
        /* context changes */
        switch (wmn->category) {
                case NC_ANIMATION:
@@ -839,6 +846,7 @@ static void view3d_main_region_listener(bScreen *sc, 
ScrArea *sa, ARegion *ar, w
                                        if (wmn->reference)
                                                view3d_recalc_used_layers(ar, 
wmn, wmn->reference);
                                        ED_region_tag_redraw(ar);
+                                       WM_manipulatormap_tag_refresh(mmap);
                                        break;
                                case ND_FRAME:
                                case ND_TRANSFORM:
@@ -850,6 +858,7 @@ static void view3d_main_region_listener(bScreen *sc, 
ScrArea *sa, ARegion *ar, w
                                case ND_MARKERS:
                                case ND_MODE:
                                        ED_region_tag_redraw(ar);
+                                       WM_manipulatormap_tag_refresh(mmap);
                                        break;
                                case ND_WORLD:
                                        /* handled by space_view3d_listener() 
for v3d access */
@@ -880,6 +889,7 @@ static void view3d_main_region_listener(bScreen *sc, 
ScrArea *sa, ARegion *ar, w
                                case ND_KEYS:
                                case ND_LOD:
                                        ED_region_tag_redraw(ar);
+                                       WM_manipulatormap_tag_refresh(mmap);
                                        break;
                        }
                        switch (wmn->action) {
@@ -893,6 +903,7 @@ static void view3d_main_region_listener(bScreen *sc, 
ScrArea *sa, ARegion *ar, w
                                case ND_DATA:
                                case ND_VERTEX_GROUP:
                                case ND_SELECT:
+                                       WM_manipulatormap_tag_refresh(mmap);
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
@@ -999,6 +1010,7 @@ static void view3d_main_region_listener(bScreen *sc, 
ScrArea *sa, ARegion *ar, w
                                        rv3d->rflag |= RV3D_GPULIGHT_UPDATE;
                                }
                                ED_region_tag_redraw(ar);
+                               WM_manipulatormap_tag_refresh(mmap);
                        }
                        break;
                case NC_ID:
@@ -1472,6 +1484,14 @@ static void view3d_id_remap(ScrArea *sa, SpaceLink 
*slink, ID *old_id, ID *new_i
        }
 }
 
+static void view3d_manipulators(void)
+{
+       wmManipulatorMapType *mmaptype = WM_manipulatormaptype_ensure(&(const 
struct wmManipulatorMapType_Params) {
+               "View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW});
+
+       WM_manipulatorgrouptype_append(mmaptype, 
VIEW3D_MGT_transform_manipulators);
+}
+
 /* only called once, from space/spacetypes.c */
 void ED_spacetype_view3d(void)
 {
@@ -1491,6 +1511,7 @@ void ED_spacetype_view3d(void)
        st->dropboxes = view3d_dropboxes;
        st->context = view3d_context;
        st->id_remap = view3d_id_remap;
+       st->manipulators = view3d_manipulators;
 
        /* regions: main window */
        art = MEM_callocN(sizeof(ARegionType), "spacetype view3d main region");
diff --git a/source/blender/editors/space_view3d/view3d_draw.c 
b/source/blender/editors/space_view3d/view3d_draw.c
index 5b35254..37d57b7 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -62,6 +62,7 @@
 #include "RE_engine.h"
 
 #include "WM_api.h"
+#include "WM_types.h"
 
 #include "view3d_intern.h"  /* own include */
 
@@ -1546,11 +1547,14 @@ static void view3d_draw_reference_images(const bContext 
*C)
 /**
 * 3D manipulators
 */
-static void view3d_draw_manipulator(const bContext *C)
+static void view3d_draw_manipulators(const bContext *C, const ARegion *ar)
 {
-       View3D *v3d = CTX_wm_view3d(C);
-       v3d->zbuf = false;
-       BIF_draw_manipulator(C);
+       /* TODO, only draws 3D manipulators right now, need to see how 2D 
drawing will work in new viewport */
+
+       /* draw depth culled manipulators - manipulators need to be updated 
*after* view matrix was set up */
+       /* TODO depth culling manipulators is not yet supported, just drawing 
_3D here, should
+        * later become _IN_SCENE (and draw _3D separate) */
+       WM_manipulatormap_draw(ar->manipulator_map, C, 
WM_MANIPULATORMAP_DRAWSTEP_3D);
 }
 
 /**
@@ -1592,7 +1596,7 @@ static void view3d_draw_view(const bContext *C, ARegion 
*ar, DrawData *draw_data
        view3d_draw_other_elements(C, ar);
        view3d_draw_tool_ui(C);
        view3d_draw_reference_images(C);
-       view3d_draw_manipulator(C);
+       view3d_draw_manipulators(C, ar);
        view3d_draw_region_info(C, ar);
 }
 
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c 
b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 2e40113..a33ef5e 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -79,6 +79,7 @@
 #include "BIF_glutil.h"
 
 #include "WM_api.h"
+#include "WM_types.h"
 
 #include "BLF_api.h"
 #include "BLT_translation.h"
@@ -2177,10 +2178,6 @@ static void view3d_draw_objects(
                view3d_draw_bgpic_test(scene, ar, v3d, true, do_camera_frame);
        }
 
-       if (!draw_offscreen) {
-               BIF_draw_manipulator(C);
-       }
-
        /* cleanup */
        if (v3d->zbuf) {
                v3d->zbuf = false;
@@ -2965,6 +2962,11 @@ static void view3d_main_region_draw_objects(const 
bContext *C, Scene *scene, Vie
        /* main drawing call */
        view3d_draw_objects(C, scene, v3d, ar, grid_unit, true, false, 
do_compositing ? rv3d->compositor : NULL);
 
+       /* draw depth culled manipulators - manipulators need to be updated 
*after* view matrix was set up */
+       /* TODO depth culling manipulators is not yet supported, just drawing 
_3D here, should
+        * later become _IN_SCENE (and draw _3D separate) */
+       WM_manipulatormap_draw(ar->manipulator_map, C, 
WM_MANIPULATORMAP_DRAWSTEP_3D);
+
        /* post process */
        if (do_compositing) {
                GPU_fx_do_composite_pass(rv3d->compositor, rv3d->winmat, 
rv3d->is_persp, scene, NULL);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c 
b/source/blender/editors/space_view3d/view3d_edit.c
index 2c4b04e..2178b44 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -3797,7 +3797,7 @@ static void axis_set_view(bContext *C, View3D *v3d, 
ARegion *ar,
                        float twmat[3][3];
 
                        /* same as transform manipulator when normal is set */
-                       ED_getTransformOrientationMatrix(C, twmat, 
V3D_AROUND_ACTIVE);
+                       ED_getLocalTransformOrientationMatrix(C, twmat, 
V3D_AROUND_ACTIVE);
 
                        mat3_to_quat(obact_quat, twmat);
                        invert_qt_normalized(obact_quat);
@@ -4769,43 +4769,6 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot)
 
 /* ***************** manipulator op ******************* */
 
-
-static int manipulator_invoke(bContext *C, wmOperator *op, const wmEvent 
*event)
-{
-       View3D *v3d = CTX_wm_view3d(C);
-
-       if (!(v3d->twflag & V3D_USE_MANIPULATOR)) return OPERATOR_PASS_THROUGH;
-       if (!(v3d->twflag & V3D_DRAW_MANIPULATOR)) return OPERATOR_PASS_THROUGH;
-
-       /* only no modifier or shift */
-       if (event->keymodifier != 0 && event->keymodifier != KM_SHIFT) return 
OPERATOR_PASS_THROUGH;
-
-       /* note; otherwise opengl won't work */
-       view3d_operator_needs_opengl(C);
-
-       if (0 == BIF_do_manipulator(C, event, op))
-               return OPERATOR_PASS_THROUGH;
-
-       return OPERATOR_FINISHED;
-}
-
-void VIEW3D_OT_manipulator(wmOperatorType *ot)
-{
-
-       /* identifiers */
-       ot->name = "3D Manipulator";
-       ot->description = "Manipulate selected item by axis";
-       ot->idname = "VIEW3D_OT_manipulator";
-
-       /* api callbacks */
-       ot->invoke = manipulator_invoke;
-
-       ot->poll = ED_operator_view3d_active;
-
-       /* properties to pass to transform */
-       Transform_Properties(ot, P_CONSTRAINT);
-}
-
 static int enable_manipulator_invoke(bContext *C, wmOperator *op, const 
wmEvent *UNUSED(event))
 {
        View3D *v3d = CTX_wm_view3d(C);
diff --git a/source/blender/editors/space_view3d/view3d_intern.h 
b/source/blender/editors/space_view3d/view3d_intern.h
index a114743..4a3581e 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -46,6 +46,7 @@ struct bContext;
 struct bMotionPath;
 struct bPoseChannel;
 struct Mesh;
+struct wmManipulatorGroupType;
 struct wmOperatorType;
 struct wmWindowManager;
 struct wmKeyConfig;
@@ -99,7 +100,6 @@ void VIEW3D_OT_view_orbit(struct wmOperatorType *ot);
 void VIEW3D_OT_view_roll(struct wmOperatorType *ot);
 void VIEW3D_OT_clip_border(struct wmOperatorType *ot);
 void VIEW3D_OT_cursor3d(struct wmOperatorType *ot);
-void VIEW3D_OT_manipulator(struct wmOperatorType *ot);
 void VIEW3D_OT_enable_manipulator(struct wmOperatorType *ot);
 void VIEW3D_OT_render_border(struct wmOpera

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to