[Bf-blender-cvs] [691df9f29d7] custom-manipulators: Merge branch 'blender2.8' into custom-manipulators
Campbell Barton
noreply at git.blender.org
Mon Apr 3 05:01:05 CEST 2017
Commit: 691df9f29d7b307d94eb326ade9e81b74084c562
Author: Campbell Barton
Date: Mon Apr 3 12:57:12 2017 +1000
Branches: custom-manipulators
https://developer.blender.org/rB691df9f29d7b307d94eb326ade9e81b74084c562
Merge branch 'blender2.8' into custom-manipulators
Needed to add GLU back for purpose of merging, noted with IMM-FIXME
===================================================================
===================================================================
diff --cc CMakeLists.txt
index 4caedbab6d5,4fe6df2c67b..47fb65daafb
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@@ -1058,11 -1052,6 +1052,11 @@@ endif(
find_package(OpenGL)
blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
- if(WITH_GLU)
++# IMM-FIXME
++if(TRUE)
+ list(APPEND BLENDER_GL_LIBRARIES "${OPENGL_glu_LIBRARY}")
- list(APPEND GL_DEFINITIONS -DWITH_GLU)
+endif()
+
if(WITH_SYSTEM_GLES)
find_package_wrapper(OpenGLES)
endif()
diff --cc source/blender/editors/space_view3d/view3d_draw.c
index badbb1ddefd,808a5f34299..eb9ac304288
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@@ -2240,8 -2218,8 +2219,8 @@@ static void view3d_draw_reference_image
/**
* 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;
@@@ -2326,7 -2319,10 +2326,10 @@@ static void view3d_draw_view(const bCon
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);
+
+ glDisable(GL_DEPTH_TEST);
+
view3d_draw_region_info(C, ar);
#if VIEW3D_DRAW_DEBUG
diff --cc source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c
index 904bea10168,00000000000..34fc5772816
mode 100644,000000..100644
--- a/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c
@@@ -1,578 -1,0 +1,581 @@@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2014 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c
+ * \ingroup wm
+ *
+ * \name Arrow Manipulator
+ *
+ * 3D Manipulator
+ *
+ * \brief Simple arrow manipulator which is dragged into a certain direction.
+ * The arrow head can have varying shapes, e.g. cone, box, etc.
+ */
+
+#include "BIF_gl.h"
+
++// IMM-FIXME
++#include <GL/glu.h>
++
+#include "BKE_context.h"
+
+#include "BLI_math.h"
+
+#include "DNA_manipulator_types.h"
+#include "DNA_view3d_types.h"
+
+#include "ED_view3d.h"
+#include "ED_screen.h"
+
+#include "GPU_select.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+
+#include "WM_types.h"
+#include "WM_api.h"
+
+/* own includes */
+#include "wm_manipulator_wmapi.h"
+#include "wm_manipulator_intern.h"
+#include "manipulator_geometry.h"
+#include "manipulator_library_intern.h"
+
+
+/* to use custom arrows exported to geom_arrow_manipulator.c */
+//#define MANIPULATOR_USE_CUSTOM_ARROWS
+
+#ifdef MANIPULATOR_USE_CUSTOM_ARROWS
+ManipulatorGeometryInfo arrow_head_draw_info = {0};
+#endif
+ManipulatorGeometryInfo cube_draw_info = {0};
+
+/* ArrowManipulator->flag */
+enum {
+ ARROW_UP_VECTOR_SET = (1 << 0),
+ ARROW_CUSTOM_RANGE_SET = (1 << 1),
+};
+
+typedef struct ArrowManipulator {
+ wmManipulator manipulator;
+
+ ManipulatorCommonData data;
+
+ int style;
+ int flag;
+
+ float len; /* arrow line length */
+ float direction[3];
+ float up[3];
+ float aspect[2]; /* cone style only */
+} ArrowManipulator;
+
+
+/* -------------------------------------------------------------------- */
+
+static void manipulator_arrow_get_final_pos(wmManipulator *manipulator, float r_pos[3])
+{
+ ArrowManipulator *arrow = (ArrowManipulator *)manipulator;
+
+ mul_v3_v3fl(r_pos, arrow->direction, arrow->data.offset);
+ add_v3_v3(r_pos, arrow->manipulator.origin);
+}
+
+static void arrow_draw_geom(const ArrowManipulator *arrow, const bool select)
+{
+ if (arrow->style & MANIPULATOR_ARROW_STYLE_CROSS) {
+ glPushAttrib(GL_ENABLE_BIT);
+ glDisable(GL_LIGHTING);
+ glBegin(GL_LINES);
+ glVertex2f(-1.0, 0.f);
+ glVertex2f(1.0, 0.f);
+ glVertex2f(0.f, -1.0);
+ glVertex2f(0.f, 1.0);
+ glEnd();
+
+ glPopAttrib();
+ }
+ else if (arrow->style & MANIPULATOR_ARROW_STYLE_CONE) {
+ const float unitx = arrow->aspect[0];
+ const float unity = arrow->aspect[1];
+ const float vec[4][3] = {
+ {-unitx, -unity, 0},
+ { unitx, -unity, 0},
+ { unitx, unity, 0},
+ {-unitx, unity, 0},
+ };
+
+ glLineWidth(arrow->manipulator.line_width);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(3, GL_FLOAT, 0, vec);
+ glDrawArrays(GL_LINE_LOOP, 0, ARRAY_SIZE(vec));
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glLineWidth(1.0);
+ }
+ else {
+#ifdef MANIPULATOR_USE_CUSTOM_ARROWS
+ wm_manipulator_geometryinfo_draw(&arrow_head_draw_info, select);
+#else
+ const float vec[2][3] = {
+ {0.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, arrow->len},
+ };
+
+ glLineWidth(arrow->manipulator.line_width);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(3, GL_FLOAT, 0, vec);
+ glDrawArrays(GL_LINE_STRIP, 0, ARRAY_SIZE(vec));
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glLineWidth(1.0);
+
+
+ /* *** draw arrow head *** */
+
+ glPushMatrix();
+
+ if (arrow->style & MANIPULATOR_ARROW_STYLE_BOX) {
+ const float size = 0.05f;
+
+ /* translate to line end with some extra offset so box starts exactly where line ends */
+ glTranslatef(0.0f, 0.0f, arrow->len + size);
+ /* scale down to box size */
+ glScalef(size, size, size);
+
+ /* draw cube */
+ wm_manipulator_geometryinfo_draw(&cube_draw_info, select);
+ }
+ else {
+ const float len = 0.25f;
+ const float width = 0.06f;
+ const bool use_lighting = select == false && ((U.manipulator_flag & V3D_SHADED_MANIPULATORS) != 0);
+
+ /* translate to line end */
+ glTranslatef(0.0f, 0.0f, arrow->len);
+
+ if (use_lighting) {
+ glShadeModel(GL_SMOOTH);
+ }
+
+ GLUquadricObj *qobj = gluNewQuadric();
+ gluQuadricDrawStyle(qobj, GLU_FILL);
+ gluQuadricOrientation(qobj, GLU_INSIDE);
+ gluDisk(qobj, 0.0, width, 8, 1);
+ gluQuadricOrientation(qobj, GLU_OUTSIDE);
+ gluCylinder(qobj, width, 0.0, len, 8, 1);
+ gluDeleteQuadric(qobj);
+
+ if (use_lighting) {
+ glShadeModel(GL_FLAT);
+ }
+ }
+
+ glPopMatrix();
+#endif
+ }
+}
+
+static void arrow_draw_intern(ArrowManipulator *arrow, const bool select, const bool highlight)
+{
+ const float up[3] = {0.0f, 0.0f, 1.0f};
+ float col[4];
+ float rot[3][3];
+ float mat[4][4];
+ float final_pos[3];
+
+ manipulator_color_get(&arrow->manipulator, highlight, col);
+ manipulator_arrow_get_final_pos(&arrow->manipulator, final_pos);
+
+ if (arrow->flag & ARROW_UP_VECTOR_SET) {
+ copy_v3_v3(rot[2], arrow->direction);
+ copy_v3_v3(rot[1], arrow->up);
+ cross_v3_v3v3(rot[0], arrow->up, arrow->direction);
+ }
+ else {
+ rotation_between_vecs_to_mat3(rot, up, arrow->direction);
+ }
+ copy_m4_m3(mat, rot);
+ copy_v3_v3(mat[3], final_pos);
+ mul_mat3_m4_fl(mat, arrow->manipulator.scale);
+
+ glPushMatrix();
+ glMultMatrixf(mat);
+
+ glColor4fv(col);
+ glEnable(GL_BLEND);
+ glTranslatef(UNPACK3(arrow->manipulator.offset));
+ arrow_draw_geom(arrow, select);
+ glDisable(GL_BLEND);
+
+ glPopMatrix();
+
+ if (arrow->manipulator.interaction_data) {
+ ManipulatorInteraction *inter = arrow->manipulator.interaction_data;
+
+ copy_m4_m3(mat, rot);
+ copy_v3_v3(mat[3], inter->init_origin);
+ mul_mat3_m4_fl(mat, inter->init_scale);
+
+ glPushMatrix();
+ glMultMatrixf(mat);
+
+ glEnable(GL_BLEND);
+ glColor4f(0.5f, 0.5f, 0.5f, 0.5f);
+ glTranslatef(UNPACK3(arrow->manipulator.offset));
+ arrow_draw_geom(arrow, select);
+ glDisable(GL_BLEND);
+
+ glPopMatrix();
+ }
+}
+
+static void manipulator_arrow_render_3d_intersect(
+ const bContext *UNUSED(C), wmManipulator *manipulator,
+ int selectionbase)
+{
+ GPU_select_load_id(selectionbase);
+ arrow_draw_intern((ArrowManipulator *)manipulator, true, false);
+}
+
+static void manipulator_arrow_draw(const bContext *UNUSED(C), wmManipulator *manipulator)
+{
+ arrow_draw_intern((ArrowManipulator *)manipulator, false, (manipulator->state & WM_MANIPULATOR_HIGHLIGHT) != 0);
+}
+
+/**
+ * Calculate arrow offset independent from prop min value,
+ * meaning the range will not be offset by min value first.
+ */
+#define USE_ABS_HANDLE_RANGE
+
+static int manipulator_arrow_handler(bContext *C, const wmEvent *event, wmManipulator *manipulator, const int flag)
+{
+ ArrowManipulator *arrow = (ArrowManipulator *)manipulator;
+ ManipulatorInteraction *inter = manipulator->interaction_data;
+ ARegion *ar = CTX_wm_region(C);
+ RegionView3D *rv3d = ar->regiondata;
+
+ float orig_origin[4];
+ float viewvec[3], tangent[3], plane[3];
+ float offset[4];
+ float m_diff[2];
+ float dir_2d[2], dir2d_final[2];
+ float facdir = 1.0f;
+ bool use_vertical = false;
+
+
+ copy_v3_v3(orig_origin, inter->init_origin);
+ orig_origin[3] = 1.0f;
+ add_v3_v3v3(offset, orig_origin, arrow->direction);
+ offset[3] = 1.0f;
+
+ /* calculate view vector */
+ if (rv3d->is_persp) {
+ sub_v3_v3v3(viewvec, orig_origin, rv3d->viewinv[3]);
+ }
+ else {
+ copy_v3_v3(viewvec, rv3d->viewinv[2]);
+ }
+ normalize_v3(viewvec);
+
+ /* first determine if view vector is really cl
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list