[Bf-blender-cvs] [0079748] wiggly-widgets: Placeholder widget code for spotlamps
Antony Riakiotakis
noreply at git.blender.org
Fri Oct 3 12:16:10 CEST 2014
Commit: 007974899fc415c24e3840dc2d8def9c89f8df15
Author: Antony Riakiotakis
Date: Fri Oct 3 12:15:57 2014 +0200
Branches: wiggly-widgets
https://developer.blender.org/rB007974899fc415c24e3840dc2d8def9c89f8df15
Placeholder widget code for spotlamps
===================================================================
M source/blender/editors/include/ED_transform.h
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/CMakeLists.txt
A source/blender/editors/interface/interface_generic_widgets.c
M source/blender/editors/space_view3d/space_view3d.c
M source/blender/editors/transform/transform_manipulator.c
M source/blender/makesdna/DNA_lamp_types.h
===================================================================
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 6ad3ed4..9a87d77 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -152,10 +152,10 @@ void Transform_Properties(struct wmOperatorType *ot, int flags);
/* view3d manipulators */
-int BIF_manipulator_handler(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget, int active);
-void BIF_manipulator_render_3d_intersect(const struct bContext *C, struct wmWidget *widget, int selectionbase);
-void BIF_draw_manipulator(const struct bContext *C, struct wmWidget *widget);
-bool BIF_manipulator_poll(const struct bContext *C, struct wmWidget *widget);
+int WIDGET_manipulator_handler(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget, int active);
+void WIDGET_manipulator_render_3d_intersect(const struct bContext *C, struct wmWidget *widget, int selectionbase);
+void WIDGET_manipulator_draw(const struct bContext *C, struct wmWidget *widget);
+bool WIDGET_manipulator_poll(const struct bContext *C, struct wmWidget *widget);
/* Snapping */
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index bc794bf..f262e1b 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -996,4 +996,10 @@ void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p);
int uiFloatPrecisionCalc(int prec, double value);
+/* ui_generic_widgets.c */
+int WIDGET_lamp_handler(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget, int active);
+void WIDGET_lamp_render_3d_intersect(const struct bContext *C, struct wmWidget *widget, int selectionbase);
+void WIDGET_lamp_draw(const struct bContext *C, struct wmWidget *widget);
+bool WIDGET_lamp_poll(const struct bContext *C, struct wmWidget *widget);
+
#endif /* __UI_INTERFACE_H__ */
diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt
index e13517a..239d4a4 100644
--- a/source/blender/editors/interface/CMakeLists.txt
+++ b/source/blender/editors/interface/CMakeLists.txt
@@ -51,6 +51,7 @@ set(SRC
interface_templates.c
interface_utils.c
interface_widgets.c
+ interface_generic_widgets.c
resources.c
view2d.c
view2d_ops.c
diff --git a/source/blender/editors/interface/interface_generic_widgets.c b/source/blender/editors/interface/interface_generic_widgets.c
new file mode 100644
index 0000000..f98102f
--- /dev/null
+++ b/source/blender/editors/interface/interface_generic_widgets.c
@@ -0,0 +1,105 @@
+/*
+ * ***** 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) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/interface/interface_generic_widgets.c
+ * \ingroup edinterface
+ */
+
+#include "WM_types.h"
+
+#include "DNA_screen_types.h"
+#include "DNA_lamp_types.h"
+#include "DNA_object_types.h"
+#include "DNA_lamp_types.h"
+#include "DNA_view3d_types.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_math_matrix.h"
+
+#include "BKE_context.h"
+
+#include "ED_view3d.h"
+
+#include "WM_types.h"
+
+#include "GL/glew.h"
+
+#include "UI_interface.h"
+
+int WIDGET_lamp_handler(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget, int active)
+{
+ return 0;
+}
+
+void WIDGET_lamp_render_3d_intersect(const struct bContext *C, struct wmWidget *widget, int selectionbase)
+{
+
+}
+
+void WIDGET_lamp_draw(const struct bContext *C, struct wmWidget *widget)
+{
+ ARegion *ar = CTX_wm_region(C);
+ RegionView3D *rv3d = ar->regiondata;
+
+ Object *ob = CTX_data_active_object(C);
+ Lamp *la = ob->data;
+
+ float widgetmat[4][4];
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+
+ copy_m4_m4(widgetmat, ob->obmat);
+ normalize_m4(widgetmat);
+ mul_mat3_m4_fl(widgetmat, ED_view3d_pixel_size(rv3d, widgetmat[3]) * U.tw_size);
+
+ glMultMatrixf(&widgetmat[0][0]);
+
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+
+ glShadeModel(GL_SMOOTH);
+ glBegin(GL_TRIANGLES);
+ glColor3f(1.0, 0.0, 0.0);
+ glVertex3f(0.0, 0.0, 1.0);
+ glColor3f(0.0, 1.0, 0.0);
+ glVertex3f(-1.0, 0.0, -1.0);
+ glColor3f(0.0, 0.0, 1.0);
+ glVertex3f(1.0, 0.0, -1.0);
+ glEnd();
+
+ glPopMatrix();
+}
+
+bool WIDGET_lamp_poll(const struct bContext *C, struct wmWidget *UNUSED(widget))
+{
+ Object *ob = CTX_data_active_object(C);
+
+ if (ob->type == OB_LAMP) {
+ Lamp *la = ob->data;
+ return (la->type == LA_SPOT);
+ }
+ return false;
+}
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 1244333..7e71230 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -69,6 +69,7 @@
#include "RNA_access.h"
#include "UI_resources.h"
+#include "UI_interface.h"
#ifdef WITH_PYTHON
# include "BPY_extern.h"
@@ -697,19 +698,20 @@ static void view3d_widgets(void)
int *realtimeflags = MEM_mallocN(sizeof(int), "manipulator_display_flags");
*realtimeflags = 0;
- widget = WM_widget_new(BIF_manipulator_poll,
- BIF_draw_manipulator,
- BIF_manipulator_render_3d_intersect,
+ widget = WM_widget_new(WIDGET_manipulator_poll,
+ WIDGET_manipulator_draw,
+ WIDGET_manipulator_render_3d_intersect,
NULL,
- BIF_manipulator_handler, realtimeflags, true);
+ WIDGET_manipulator_handler, realtimeflags, true);
WM_widget_register(wmap, widget);
- widget = WM_widget_new(NULL,
+ realtimeflags = MEM_mallocN(sizeof(int), "manipulator_display_flags");
+ widget = WM_widget_new(WIDGET_lamp_poll,
+ WIDGET_lamp_draw,
+ WIDGET_manipulator_render_3d_intersect,
NULL,
- NULL,
- NULL,
- NULL, NULL, false);
+ WIDGET_lamp_handler, realtimeflags, true);
WM_widget_register(wmap, widget);
}
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index b135ad9..49d9e8b 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -1437,6 +1437,7 @@ static void draw_manipulator_translate(
drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat);
glPopMatrix();
+ glPushMatrix();
/* and now apply matrix, we move to local matrix drawing */
glMultMatrixf(rv3d->twmat);
@@ -1493,7 +1494,7 @@ static void draw_manipulator_translate(
}
gluDeleteQuadric(qobj);
- glLoadMatrixf(rv3d->viewmat);
+ glPopMatrix();
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
@@ -1628,7 +1629,7 @@ static void draw_manipulator_rotate_cyl(
/* main call, does calc centers & orientation too */
static int drawflags = 0xFFFF; // only for the calls below, belongs in scene...?
-void BIF_draw_manipulator(const bContext *C, wmWidget *widget)
+void WIDGET_manipulator_draw(const bContext *C, wmWidget *widget)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
@@ -1710,7 +1711,7 @@ void BIF_draw_manipulator(const bContext *C, wmWidget *widget)
}
}
-bool BIF_manipulator_poll(const struct bContext *C, wmWidget *UNUSED(widget))
+bool WIDGET_manipulator_poll(const struct bContext *C, wmWidget *UNUSED(widget))
{
/* it's a given we only use this in 3D view */
ScrArea *sa = CTX_wm_area(C);
@@ -1719,7 +1720,7 @@ bool BIF_manipulator_poll(const struct bContext *C, wmWidget *UNUSED(widget))
return ((v3d->twflag & V3D_USE_MANIPULATOR) != 0);
}
-void BIF_manipulator_render_3d_intersect(const bContext *C, wmWidget *UNUSED(widget), int selectionbase)
+void WIDGET_manipulator_render_3d_intersect(const bContext *C, wmWidget *UNUSED(widget), int selectionbase)
{
ScrArea *sa = CTX_wm_area(C);
View3D *v3d = sa->spacedata.first;
@@ -1743,7 +1744,7 @@ void BIF_manipulator_render_3d_intersect(const bContext *C, wmWidget *UNUSED(wid
}
/* return 0; nothing happened */
-int BIF_manipulator_handler(bContext *C, const struct wmEvent *event, wmWidget *widget, int active)
+int WIDGET_manipulator_handler(bContext *C, const struct wmEvent *event, wmWidget *widget, int active)
{
ScrArea *sa = CTX_wm_area(C);
View3D *v3d = sa->spacedata.first;
diff --git a/source/blender/makesdna/DNA_lamp_types.h b/source/blender/makesdna/DNA_lamp_types.h
index 727afe0..a920182 100644
--- a/source/blender/makesdna/DNA_lamp_types.h
+++ b/source/blender/makesdna/DNA_lamp_types.h
@@ -151,7 +151,6 @@ typedef struct Lamp {
#define LA_LAYER_SHADOW (1 << 15)
#define LA_SHAD_TEX (1 << 16)
#define LA_SHOW_CONE (1 << 17)
-#define LA_WIDGET (1 << 18)
/* layer_shadow */
#define LA_LAYER_SHADOW_BOTH 0
More information about the Bf-blender-cvs
mailing list