[Bf-blender-cvs] [a19f862] custom-manipulators: Bring back stuff removed in temp_manipulators_core
Julian Eisel
noreply at git.blender.org
Fri Oct 7 00:14:09 CEST 2016
Commit: a19f862bd95ef0aeb80e2383f15c51376c6b910a
Author: Julian Eisel
Date: Fri Oct 7 00:11:35 2016 +0200
Branches: custom-manipulators
https://developer.blender.org/rBa19f862bd95ef0aeb80e2383f15c51376c6b910a
Bring back stuff removed in temp_manipulators_core
Was removed for merge into blender2.8, but we still need it in this branch.
===================================================================
M source/blender/CMakeLists.txt
A source/blender/makesdna/DNA_manipulator_types.h
M source/blender/makesdna/DNA_view3d_types.h
M source/blender/makesdna/intern/makesdna.c
M source/blender/makesrna/intern/rna_wm.c
M source/blender/windowmanager/intern/wm_event_system.c
M source/blender/windowmanager/manipulators/WM_manipulator_types.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/intern/wm_manipulatorgroup.c
M source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c
===================================================================
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index d49ceb1..b5cb45f 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -55,6 +55,7 @@ set(SRC_DNA_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lattice_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_linestyle_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_listBase.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_manipulator_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_material_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_mesh_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_meshdata_types.h
diff --git a/source/blender/makesdna/DNA_manipulator_types.h b/source/blender/makesdna/DNA_manipulator_types.h
new file mode 100644
index 0000000..7b75806
--- /dev/null
+++ b/source/blender/makesdna/DNA_manipulator_types.h
@@ -0,0 +1,43 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file DNA_manipulator_types.h
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_MANIPULATOR_TYPES_H__
+#define __DNA_MANIPULATOR_TYPES_H__
+
+typedef struct wmManipulatorGroup {
+ struct wmManipulatorGroup *next, *prev;
+
+ struct wmManipulatorGroupType *type;
+ ListBase manipulators;
+
+ void *py_instance; /* python stores the class instance here */
+ struct ReportList *reports; /* errors and warnings storage */
+
+ void *customdata;
+ void (*customdata_free)(void *); /* for freeing customdata from above */
+ int flag; /* private */
+ int pad;
+} wmManipulatorGroup;
+
+#endif /* __DNA_MANIPULATOR_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 8970af2..1ae07ff 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -369,6 +369,14 @@ enum {
#define V3D_3D_MANIPULATORS (1 << 1)
#define V3D_SHADED_MANIPULATORS (1 << 2)
+typedef enum ManipulatorType{
+ WT_TRANSLATE = 0,
+ WT_ROTATE = 1,
+ WT_SCALE = 2,
+ WT_CUSTOM = 3,
+} ManipulatorType;
+
+
/* BGPic->flag */
/* may want to use 1 for select ? */
enum {
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 0f7ed8c..a646043 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -77,6 +77,7 @@ static const char *includefiles[] = {
"DNA_image_types.h",
"DNA_texture_types.h",
"DNA_lamp_types.h",
+ "DNA_manipulator_types.h",
"DNA_material_types.h",
"DNA_vfont_types.h",
"DNA_meta_types.h",
@@ -1287,6 +1288,7 @@ int main(int argc, char **argv)
#include "DNA_image_types.h"
#include "DNA_texture_types.h"
#include "DNA_lamp_types.h"
+#include "DNA_manipulator_types.h"
#include "DNA_material_types.h"
#include "DNA_vfont_types.h"
#include "DNA_meta_types.h"
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 4bb8a50..9c8ad8d 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -29,6 +29,7 @@
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
+#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_manipulator_types.h"
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index b3cf8bb..b4d80f2 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -36,6 +36,7 @@
#include <string.h>
#include "DNA_listBase.h"
+#include "DNA_manipulator_types.h"
#include "DNA_screen_types.h"
#include "DNA_scene_types.h"
#include "DNA_windowmanager_types.h"
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
index 284a3e9..8de33ca 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
@@ -71,21 +71,6 @@ enum {
/* -------------------------------------------------------------------- */
/* wmManipulatorGroup */
-typedef struct wmManipulatorGroup {
- struct wmManipulatorGroup *next, *prev;
-
- struct wmManipulatorGroupType *type;
- ListBase manipulators;
-
- void *py_instance; /* python stores the class instance here */
- struct ReportList *reports; /* errors and warnings storage */
-
- void *customdata;
- void (*customdata_free)(void *); /* for freeing customdata from above */
- int flag; /* private */
- int pad;
-} wmManipulatorGroup;
-
/* factory class for a manipulator-group type, gets called every time a new area is spawned */
typedef struct wmManipulatorGroupType {
struct wmManipulatorGroupType *next, *prev;
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
index c3e17f9..55ff129 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
@@ -34,6 +34,8 @@
#include "BLI_path_util.h"
#include "BLI_string.h"
+#include "DNA_manipulator_types.h"
+
#include "ED_screen.h"
#include "ED_view3d.h"
@@ -51,6 +53,59 @@
#include "wm_manipulator_intern.h"
+/**
+ * Main draw call for ManipulatorGeometryInfo data
+ */
+void wm_manipulator_geometryinfo_draw(ManipulatorGeometryInfo *info, const bool select)
+{
+ GLuint buf[3];
+
+ const bool use_lighting = !select && ((U.manipulator_flag & V3D_SHADED_MANIPULATORS) != 0);
+
+ if (use_lighting)
+ glGenBuffers(3, buf);
+ else
+ glGenBuffers(2, buf);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glBindBuffer(GL_ARRAY_BUFFER, buf[0]);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * info->nverts, info->verts, GL_STATIC_DRAW);
+ glVertexPointer(3, GL_FLOAT, 0, NULL);
+
+ if (use_lighting) {
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glBindBuffer(GL_ARRAY_BUFFER, buf[2]);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * info->nverts, info->normals, GL_STATIC_DRAW);
+ glNormalPointer(GL_FLOAT, 0, NULL);
+ glShadeModel(GL_SMOOTH);
+ }
+
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buf[1]);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned short) * (3 * info->ntris), info->indices, GL_STATIC_DRAW);
+
+ glEnable(GL_CULL_FACE);
+ glEnable(GL_DEPTH_TEST);
+
+ glDrawElements(GL_TRIANGLES, info->ntris * 3, GL_UNSIGNED_SHORT, NULL);
+
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+
+ if (use_lighting) {
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glShadeModel(GL_FLAT);
+ glDeleteBuffers(3, buf);
+ }
+ else {
+ glDeleteBuffers(2, buf);
+ }
+}
+
/* Still unused */
wmManipulator *WM_manipulator_new(
void (*draw)(const bContext *C, wmManipulator *customdata),
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h b/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
index 1a9693a..386c8bb 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
@@ -226,5 +226,7 @@ typedef struct ManipulatorGeometryInfo {
bool init;
} ManipulatorGeometryInfo;
+void wm_manipulator_geometryinfo_draw(ManipulatorGeometryInfo *info, const bool select);
+
#endif /* __WM_MANIPULATOR_INTERN_H__ */
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c b/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c
index 37a3ca8..c9d1cf7 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c
@@ -41,6 +41,8 @@
#include "BPY_extern.h"
+#include "DNA_manipulator_types.h"
+
#include "ED_screen.h"
#include "MEM_guardedalloc.h"
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c b/source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c
index 20f2df1..d975ca5 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c
@@ -36,6 +36,8 @@
#include "BLI_string.h"
#include "BLI_ghash.h"
+#include "DNA_manipulator_types.h"
+
#include "ED_screen.h"
#include "ED_view3d.h"
@@ -237,6 +239,30 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext
return;
BLI_assert(!BLI_listbase_is_empty(&mmap->manipulator_groups));
+ const bool draw_multisample = (U.ogl_multisamples != USER_MULTISAMPLE_NONE);
+ const bool use_lighting = (U.manipulator_flag & V3D_SHADED_MANIPULATORS) != 0;
+
+ /* enable multisampling */
+ if (draw_multisample) {
+ glEnable(GL_MULTISAMPLE);
+ }
+ if (use_lighting) {
+ const float lightpos[4] = {0.0, 0.0, 1.0, 0.0};
+ const float diffuse[4] = {1.0, 1.0, 1.0, 0.0};
+
+ glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
+
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ glEnable(GL_COLOR_MATERIAL);
+ glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ glPushMatrix();
+ glLoadIdentity();
+ glLightfv(GL_LIGHT0, GL_POSITION, lightpos);
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
+ glPopMatrix();
+ }
+
/* draw_manipulators contains all v
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list