[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60342] branches/soc-2013-viewport_fx/ source/blender: Finished work adding selection mode hooks.
Jason Wilkins
Jason.A.Wilkins at gmail.com
Mon Sep 23 21:33:51 CEST 2013
Revision: 60342
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60342
Author: jwilkins
Date: 2013-09-23 19:33:51 +0000 (Mon, 23 Sep 2013)
Log Message:
-----------
Finished work adding selection mode hooks. Selection mode uses an alternative set of aspect functions and most aspects can share a default or leave them unimplemented. This keeps each aspect shader from having to implement its own selection mode shader.
Modified Paths:
--------------
branches/soc-2013-viewport_fx/source/blender/editors/space_view3d/view3d_view.c
branches/soc-2013-viewport_fx/source/blender/editors/transform/transform_manipulator.c
branches/soc-2013-viewport_fx/source/blender/gpu/GPU_aspect.h
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspect.c
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspect_intern.h
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_blender_aspect.c
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_select.c
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_select_intern.h
Modified: branches/soc-2013-viewport_fx/source/blender/editors/space_view3d/view3d_view.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/editors/space_view3d/view3d_view.c 2013-09-23 19:20:24 UTC (rev 60341)
+++ branches/soc-2013-viewport_fx/source/blender/editors/space_view3d/view3d_view.c 2013-09-23 19:33:51 UTC (rev 60342)
@@ -926,13 +926,17 @@
if (vc->rv3d->rflag & RV3D_CLIPPING)
ED_view3d_clipping_set(vc->rv3d);
-
+
+ GPU_aspect_end(); /* have to end current aspect before initializing selection mode */
+
GPU_select_buffer(bufsize, buffer);
GPU_select_begin();
GPU_select_clear();
GPU_select_push(-1);
code = 1;
-
+
+ GPU_aspect_begin(GPU_ASPECT_BASIC, NULL); /* restart aspect in selection mode (assuming was in basic aspect before) */
+
if (vc->obedit && vc->obedit->type == OB_MBALL) {
draw_object(scene, ar, v3d, BASACT, DRAW_PICKING | DRAW_CONSTCOLOR);
}
@@ -991,8 +995,13 @@
}
GPU_select_pop(); /* see above (pushname) */
+
+ GPU_aspect_end(); /* must end aspect before ending selection mode */
+
hits = GPU_select_end();
-
+
+ GPU_aspect_begin(GPU_ASPECT_BASIC, NULL); /* restarting in render mode (assuming was basic aspect before) */
+
G.f &= ~G_PICKSEL;
setwinmatrixview3d(ar, v3d, NULL);
mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat);
Modified: branches/soc-2013-viewport_fx/source/blender/editors/transform/transform_manipulator.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/editors/transform/transform_manipulator.c 2013-09-23 19:20:24 UTC (rev 60341)
+++ branches/soc-2013-viewport_fx/source/blender/editors/transform/transform_manipulator.c 2013-09-23 19:33:51 UTC (rev 60342)
@@ -67,6 +67,7 @@
#include "BKE_editmesh.h"
#include "BKE_lattice.h"
+#include "GPU_blender_aspect.h"
#include "GPU_primitives.h"
#include "GPU_matrix.h"
#include "GPU_select.h"
@@ -1665,11 +1666,15 @@
setwinmatrixview3d(ar, v3d, &rect);
mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
+ GPU_aspect_end(); /* have to end current aspect before initializing selection mode */
+
GPU_select_buffer(64, buffer);
GPU_select_begin();
GPU_select_clear();
GPU_select_push(-2);
+ GPU_aspect_begin(GPU_ASPECT_BASIC, NULL); /* restart aspect in selection mode (assuming was in basic aspect before) */
+
/* do the drawing */
if (v3d->twtype & V3D_MANIP_ROTATE) {
draw_manipulator_rotate(v3d, rv3d, 0, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype);
@@ -1680,8 +1685,13 @@
draw_manipulator_translate(v3d, rv3d, 0, MAN_TRANS_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB);
GPU_select_pop();
+
+ GPU_aspect_end(); /* must end aspect before ending selection mode */
+
hits = GPU_select_end();
+ GPU_aspect_begin(GPU_ASPECT_BASIC, NULL); /* restarting in render mode (assuming was basic aspect before) */
+
G.f &= ~G_PICKSEL;
setwinmatrixview3d(ar, v3d, NULL);
mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
Modified: branches/soc-2013-viewport_fx/source/blender/gpu/GPU_aspect.h
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/gpu/GPU_aspect.h 2013-09-23 19:20:24 UTC (rev 60341)
+++ branches/soc-2013-viewport_fx/source/blender/gpu/GPU_aspect.h 2013-09-23 19:33:51 UTC (rev 60342)
@@ -44,14 +44,14 @@
void GPU_delete_aspects(size_t count, const uint32_t* aspects);
typedef struct GPUaspectimpl {
- bool (*begin )(void* param, const void* object);
- bool (*end )(void* param, const void* object);
- void (*commit )(void* param);
- void (*enable )(void* param, uint32_t options);
- void (*disable )(void* param, uint32_t options);
- void (*select_begin )(void* param, const void* object);
- void (*select_commit)(void* param);
- void (*select_end )(void* param, const void* object);
+ bool (*render_begin )(void* param, const void* object);
+ bool (*render_end )(void* param, const void* object);
+ bool (*render_commit)(void* param);
+ bool (*select_begin )(void* param, const void* object);
+ bool (*select_end )(void* param, const void* object);
+ bool (*select_commit)(void* param);
+ void (*enable )(void* param, uint32_t options);
+ void (*disable )(void* param, uint32_t options);
void* param;
} GPUaspectimpl;
Modified: branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspect.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspect.c 2013-09-23 19:20:24 UTC (rev 60341)
+++ branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspect.c 2013-09-23 19:33:51 UTC (rev 60342)
@@ -32,8 +32,8 @@
/* my interface */
#include "intern/gpu_aspect_intern.h"
-/* my library */
-#include "GPU_safety.h"
+/* internal */
+#include "intern/gpu_select_intern.h"
/* external */
#include "MEM_guardedalloc.h"
@@ -55,6 +55,15 @@
+#if GPU_SAFETY
+bool gpu_aspect_active(void)
+{
+ return current_aspect != -1;
+}
+#endif
+
+
+
void gpu_aspect_init(void)
{
const size_t count = 100;
@@ -84,24 +93,18 @@
bool GPU_commit_aspect(void)
{
- GPUaspectimpl* aspectImpl = GPU_ASPECT_FUNCS[current_aspect];
+ GPUaspectimpl* aspectImpl;
- GPU_ASSERT(current_aspect != -1);
- GPU_ASSERT(in_select_mode == GPU_is_select_mode());
+ GPU_ASSERT(gpu_aspect_active());
+ GPU_ASSERT(in_select_mode == gpu_is_select_mode()); /* not allowed to change select/render mode while an aspect is active */
+ aspectImpl = GPU_ASPECT_FUNCS[current_aspect];
+
if (aspectImpl != NULL) {
- if (in_select_mode) {
- if (aspectImpl->select != NULL ) {
- aspectImpl->select(aspectImpl->param);
- return true;
- }
- }
- else {
- if (aspectImpl->commit != NULL ) {
- aspectImpl->commit(aspectImpl->param);
- return true;
- }
- }
+ if (in_select_mode)
+ return (aspectImpl->select_commit != NULL) ? aspectImpl->select_commit(aspectImpl->param) : false;
+ else
+ return (aspectImpl->render_commit != NULL) ? aspectImpl->render_commit(aspectImpl->param) : false;
}
return false;
@@ -167,19 +170,19 @@
{
GPUaspectimpl* aspectImpl;
- GPU_ASSERT(current_aspect == -1);
+ GPU_ASSERT(!gpu_aspect_active());
current_aspect = aspect;
current_object = object;
- in_select_mode = GPU_is_select_mode();
+ in_select_mode = gpu_is_select_mode();
aspectImpl = GPU_ASPECT_FUNCS[aspect];
if (in_select_mode)
- return (aspectImpl != NULL && aspectImpl->select != NULL) ? aspectImpl->select(aspectImpl->param, object) : true;
+ return (aspectImpl != NULL && aspectImpl->select_begin != NULL) ? aspectImpl->select_begin(aspectImpl->param, object) : true;
else
- return (aspectImpl != NULL && aspectImpl->begin != NULL) ? aspectImpl->begin (aspectImpl->param, object) : true;
+ return (aspectImpl != NULL && aspectImpl->render_begin != NULL) ? aspectImpl->render_begin(aspectImpl->param, object) : true;
}
@@ -189,18 +192,17 @@
GPUaspectimpl* aspectImpl = GPU_ASPECT_FUNCS[current_aspect];
const void* object = current_object;
- GPU_ASSERT(current_aspect != -1);
+ GPU_ASSERT(gpu_aspect_active());
+ GPU_ASSERT(in_select_mode == gpu_is_select_mode()); /* not allowed to change select/render mode while an aspect is active */
current_aspect = -1;
current_object = NULL;
if (in_select_mode) {
- in_select_mode = false;
-
- return (aspectImpl != NULL && aspectImpl->unselect != NULL) ? aspectImpl->unselect(aspectImpl->param, object) : true;
+ return (aspectImpl != NULL && aspectImpl->select_end != NULL) ? aspectImpl->select_end(aspectImpl->param, object) : true;
}
else {
- return (aspectImpl != NULL && aspectImpl->end != NULL) ? aspectImpl->end (aspectImpl->param, object) : true;
+ return (aspectImpl != NULL && aspectImpl->render_end != NULL) ? aspectImpl->render_end(aspectImpl->param, object) : true;
}
}
Modified: branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspect_intern.h
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspect_intern.h 2013-09-23 19:20:24 UTC (rev 60341)
+++ branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspect_intern.h 2013-09-23 19:33:51 UTC (rev 60342)
@@ -34,6 +34,8 @@
#include "GPU_aspect.h"
+#include "GPU_safety.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -41,6 +43,10 @@
void gpu_aspect_init(void);
void gpu_aspect_exit(void);
+#if GPU_SAFETY
+bool gpu_aspect_active(void);
+#endif
+
#ifdef __cplusplus
}
#endif
Modified: branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_blender_aspect.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_blender_aspect.c 2013-09-23 19:20:24 UTC (rev 60341)
+++ branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_blender_aspect.c 2013-09-23 19:33:51 UTC (rev 60342)
@@ -60,19 +60,22 @@
return true;
}
-static void font_commit(void* UNUSED(param))
+static bool font_commit(void* UNUSED(param))
{
gpu_font_bind();
+
+ return true;
}
GPUaspectimpl GPU_ASPECTIMPL_FONT = {
- NULL, /* begin */
- font_end, /* end */
- font_commit, /* commit */
- NULL, /* select */
- NULL, /* unselect */
- NULL, /* enable */
- NULL, /* disable */
+ NULL, /* render_begin */
+ font_end, /* render_end */
+ font_commit, /* render_commit */
+ NULL, /* select_begin */
+ NULL, /* select_end */
+ NULL, /* select_commit */
+ NULL, /* enable */
+ NULL, /* disable */
};
@@ -84,19 +87,22 @@
return true;
}
-static void pixels_commit(void* UNUSED(param))
+static bool pixels_commit(void* UNUSED(param))
{
gpu_pixels_bind();
+
+ return true;
}
GPUaspectimpl GPU_ASPECTIMPL_PIXELS = {
- NULL, /* begin */
- pixels_end, /* end */
- pixels_commit, /* commit */
- NULL, /* select */
- NULL, /* unselect */
- NULL, /* enable */
- NULL, /* disable */
+ NULL, /* render_begin */
+ pixels_end, /* render_end */
+ pixels_commit, /* render_commit */
+ NULL, /* select_begin */
+ NULL, /* select_end */
+ NULL, /* select_commit */
+ NULL, /* enable */
+ NULL, /* disable */
};
@@ -108,9 +114,11 @@
return true;
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list