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>2017-08-06 12:47:25 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-08-06 12:50:09 +0300
commit459365443f62d2f8e8718c1d1b0fbaafd6d765de (patch)
tree2a2235cacdf240b99135aa3f6b1831cec4d5c2bc /source/blender/editors/space_view3d
parent48adef4444a8276ce1d89b122346ae0426493574 (diff)
Manipulator: experimental lamp positioning tool
- New manipulator tracks lamps to position under cursor. - Works with multiple lamps, keeping relative offsets. - Holding Ctrl moves the lamp. - Access via manipulator or Shift-T. Code could be improved, but like to get feedback from users.
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h1
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_lamp.c72
3 files changed, 70 insertions, 4 deletions
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index f67684295a6..74103c4873d 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -737,6 +737,7 @@ static void view3d_widgets(void)
WM_manipulatorgrouptype_append_and_link(mmap_type, TRANSFORM_WGT_manipulator);
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_spot);
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_area);
+ WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_target);
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_force_field);
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera);
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera_view);
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index c9f48e137f5..bc600f3e58e 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -321,6 +321,7 @@ extern const char *view3d_context_dir[]; /* doc access */
/* view3d_widgets.c */
void VIEW3D_WGT_lamp_spot (struct wmManipulatorGroupType *wgt);
void VIEW3D_WGT_lamp_area (struct wmManipulatorGroupType *wgt);
+void VIEW3D_WGT_lamp_target (struct wmManipulatorGroupType *wgt);
void VIEW3D_WGT_camera (struct wmManipulatorGroupType *wgt);
void VIEW3D_WGT_camera_view (struct wmManipulatorGroupType *wgt);
void VIEW3D_WGT_force_field (struct wmManipulatorGroupType *wgt);
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
index 451addaaeae..4b550fd0b2e 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
@@ -50,8 +50,6 @@
/** \name Spot Lamp Manipulators
* \{ */
-/* Spot Lamp */
-
static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
{
Object *ob = CTX_data_active_object(C);
@@ -122,8 +120,6 @@ void VIEW3D_WGT_lamp_spot(wmManipulatorGroupType *wgt)
/** \name Area Lamp Manipulators
* \{ */
-/* Area Lamp */
-
/* translate callbacks */
static void manipulator_area_lamp_prop_size_get(
const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
@@ -231,3 +227,71 @@ void VIEW3D_WGT_lamp_area(wmManipulatorGroupType *wgt)
}
/** \} */
+
+
+/* -------------------------------------------------------------------- */
+
+/** \name Lamp Target Manipulator
+ * \{ */
+
+static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
+{
+ Object *ob = CTX_data_active_object(C);
+
+ if (ob != NULL) {
+ if (ob->type == OB_LAMP) {
+ Lamp *la = ob->data;
+ return (ELEM(la->type, LA_SUN, LA_SPOT, LA_HEMI, LA_AREA));
+ }
+ else if (ob->type == OB_CAMERA) {
+ return true;
+ }
+ }
+ return false;
+}
+
+static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+{
+ const float color[4] = {1.0f, 1.0f, 0.5f, 1.0f};
+ const float color_hi[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+
+ wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__);
+ wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_grab_3d", mgroup, NULL);
+ wmManipulator *mpr = wwrapper->manipulator;
+
+ mgroup->customdata = wwrapper;
+
+ WM_manipulator_set_color(mpr, color);
+ WM_manipulator_set_color_highlight(mpr, color_hi);
+
+ mpr->scale_basis = 0.05f;
+
+ wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_transform_axis_target", true);
+ WM_manipulator_set_operator(mpr, ot, NULL);
+}
+
+static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ wmManipulatorWrapper *wwrapper = mgroup->customdata;
+ Object *ob = CTX_data_active_object(C);
+ wmManipulator *mpr = wwrapper->manipulator;
+
+ copy_m4_m4(mpr->matrix_basis, ob->obmat);
+ unit_m4(mpr->matrix_offset);
+ mpr->matrix_offset[3][2] = -2.4f / mpr->scale_basis;
+}
+
+void VIEW3D_WGT_lamp_target(wmManipulatorGroupType *wgt)
+{
+ wgt->name = "Target Lamp Widgets";
+ wgt->idname = "VIEW3D_WGT_lamp_target";
+
+ wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
+ WM_MANIPULATORGROUPTYPE_3D);
+
+ wgt->poll = WIDGETGROUP_lamp_target_poll;
+ wgt->setup = WIDGETGROUP_lamp_target_setup;
+ wgt->draw_prepare = WIDGETGROUP_lamp_target_draw_prepare;
+}
+
+/** \} */ \ No newline at end of file