[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37601] branches/soc-2011-onion/source/ blender/editors/uvedit: smart welding - do a mockup preview mode that draws a rectangle for proof-of concept .
Ryakiotakis Antonis
kalast at gmail.com
Fri Jun 17 20:04:26 CEST 2011
Revision: 37601
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37601
Author: psy-fi
Date: 2011-06-17 18:04:26 +0000 (Fri, 17 Jun 2011)
Log Message:
-----------
smart welding - do a mockup preview mode that draws a rectangle for proof-of concept. Drawing of result to follow.
Modified Paths:
--------------
branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_draw.c
branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_intern.h
branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
Modified: branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_draw.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_draw.c 2011-06-17 16:10:06 UTC (rev 37600)
+++ branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_draw.c 2011-06-17 18:04:26 UTC (rev 37601)
@@ -434,6 +434,7 @@
float pointsize;
int drawfaces, interpedges;
Image *ima= sima->image;
+ StitchPreviewer *stitch_preview = uv_get_stitch_previewer();
em= BKE_mesh_get_editmesh(me);
activetf= EM_get_active_mtface(em, &efa_act, NULL, 0); /* will be set to NULL if hidden */
@@ -525,6 +526,17 @@
}
+ /* 2.5 draw test :) */
+ if((stitch_preview) && stitch_preview->enabled){
+ glColor4f(1.0, 1.0, 1.0, 1.0);
+ glBegin(GL_QUADS);
+ glVertex2f(-0.5, -0.5);
+ glVertex2f(0.5, -0.5);
+ glVertex2f(0.5, 0.5);
+ glVertex2f(-0.5, 0.5);
+ glEnd();
+ }
+
/* 3. draw active face stippled */
if(activetf) {
Modified: branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_intern.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_intern.h 2011-06-17 16:10:06 UTC (rev 37600)
+++ branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_intern.h 2011-06-17 18:04:26 UTC (rev 37601)
@@ -42,6 +42,14 @@
struct Object;
struct wmOperatorType;
+typedef struct StitchPreviewer {
+ float *previewQuads[4][2];
+ float *previewTris[2][2];
+ unsigned int numOfTris;
+ unsigned int numOfQuads;
+ char enabled;
+} StitchPreviewer;
+
/* id can be from 0 to 3 */
#define TF_PIN_MASK(id) (TF_PIN1 << id)
#define TF_SEL_MASK(id) (TF_SEL1 << id)
@@ -63,5 +71,7 @@
void UV_OT_sphere_project(struct wmOperatorType *ot);
void UV_OT_unwrap(struct wmOperatorType *ot);
+/* tool utilities */
+StitchPreviewer *uv_get_stitch_previewer(void);
#endif /* ED_UVEDIT_INTERN_H */
Modified: branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c 2011-06-17 16:10:06 UTC (rev 37600)
+++ branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c 2011-06-17 18:04:26 UTC (rev 37601)
@@ -1123,6 +1123,7 @@
int count;
} UVVertAverage;
+/* stitch state object */
typedef struct StitchState {
short preview;
int use_limit;
@@ -1133,13 +1134,36 @@
#define VERT_STITCH 1
#define EDGE_STITCH 2
+/* Previewer stuff */
+static StitchPreviewer *_stitch_preview;
+
+static StitchPreviewer * stitch_preview_init()
+{
+ _stitch_preview = MEM_mallocN(sizeof(StitchPreviewer), "stitch_previewer");
+ return _stitch_preview;
+}
+
+static void stitch_preview_delete()
+{
+ if(_stitch_preview)
+ {
+ MEM_freeN(_stitch_preview);
+ _stitch_preview = NULL;
+ }
+}
+
+StitchPreviewer *uv_get_stitch_previewer(void)
+{
+ return _stitch_preview;
+}
+
static void stitch_update_header(StitchState *stitch_state, bContext *C)
{
- static char str[] = "V(ertices): %c E(dges): %c P(review): %c L(imit): %c S(nap): %c Wheel(limit adjust): %f";
+ static char str[] = "%c V(ertices) %c E(dges) %c P(review) %c L(imit) %c S(nap) Wheel(limit adjust): %f";
char msg[256];
ScrArea *sa= CTX_wm_area(C);
if(sa) {
- sprintf(msg, str, ' ', ' ', ' ', stitch_state->use_limit?'*':' ', ' ', stitch_state->limitDist);
+ sprintf(msg, str, ' ', ' ', uv_get_stitch_previewer()->enabled?'*':' ', stitch_state->use_limit?'*':' ', ' ', stitch_state->limitDist);
ED_area_headerprint(sa, msg);
}
}
@@ -1147,7 +1171,9 @@
static int stitch_init(bContext *C, wmOperator *op)
{
StitchState *stitch_state = MEM_mallocN(sizeof(StitchState), "stitch_state");
+ StitchPreviewer *preview = stitch_preview_init();
+ preview->enabled = 1;
op->customdata = stitch_state;
if(!stitch_state)
@@ -1360,7 +1386,7 @@
MEM_freeN(stitch_state);
op->customdata = NULL;
}
-
+ stitch_preview_delete();
}
@@ -1377,6 +1403,10 @@
static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event)
{
StitchState *stitch_state;
+ Object *obedit;
+ StitchPreviewer *preview;
+ obedit= CTX_data_edit_object(C);
+ preview = uv_get_stitch_previewer();
stitch_state = (StitchState *)op->customdata;
@@ -1428,7 +1458,11 @@
/* turn preview on/off */
case PKEY:
- return OPERATOR_RUNNING_MODAL;
+ if(event->val == KM_PRESS){
+ preview->enabled = !preview->enabled;
+ break;
+ } else
+ return OPERATOR_RUNNING_MODAL;
/* snap islands on/off */
case SKEY:
@@ -1440,6 +1474,7 @@
/* if updated settings, renew feedback message */
stitch_update_header(stitch_state, C);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
return OPERATOR_RUNNING_MODAL;
}
More information about the Bf-blender-cvs
mailing list