[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21687] branches/blender2.5/blender/source /blender: Store sketch in armature instead of ugly global.
Martin Poirier
theeth at yahoo.com
Sun Jul 19 04:26:01 CEST 2009
Revision: 21687
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21687
Author: theeth
Date: 2009-07-19 04:26:01 +0200 (Sun, 19 Jul 2009)
Log Message:
-----------
Store sketch in armature instead of ugly global.
Like edit data, this isn't saved, just a temp pointer used during work session.
Also bring back sketching panel for 3d view.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/blenkernel/intern/armature.c
branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
branches/blender2.5/blender/source/blender/editors/armature/editarmature_sketch.c
branches/blender2.5/blender/source/blender/editors/include/ED_armature.h
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_buttons.c
branches/blender2.5/blender/source/blender/makesdna/DNA_armature_types.h
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_init_exit.c
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/armature.c 2009-07-19 01:55:21 UTC (rev 21686)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/armature.c 2009-07-19 02:26:01 UTC (rev 21687)
@@ -140,6 +140,12 @@
MEM_freeN(arm->edbo);
arm->edbo= NULL;
}
+
+ /* free sketch */
+ if (arm->sketch) {
+ ED_freeSketch(arm->sketch);
+ arm->sketch = NULL;
+ }
}
}
Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c 2009-07-19 01:55:21 UTC (rev 21686)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c 2009-07-19 02:26:01 UTC (rev 21687)
@@ -2342,6 +2342,7 @@
link_list(fd, &arm->bonebase);
arm->edbo= NULL;
+ arm->sketch = NULL;
bone=arm->bonebase.first;
while (bone) {
Modified: branches/blender2.5/blender/source/blender/editors/armature/editarmature_sketch.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/editarmature_sketch.c 2009-07-19 01:55:21 UTC (rev 21686)
+++ branches/blender2.5/blender/source/blender/editors/armature/editarmature_sketch.c 2009-07-19 02:26:01 UTC (rev 21687)
@@ -186,7 +186,6 @@
GestureApplyFct apply;
} SK_GestureAction;
-SK_Sketch *GLOBAL_sketch = NULL;
SK_Point boneSnap;
int LAST_SNAP_POINT_VALID = 0;
float LAST_SNAP_POINT[3];
@@ -217,6 +216,8 @@
int sk_detectConvertGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
void sk_applyConvertGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
+SK_Sketch* contextSketch(const bContext *c, int create);
+SK_Sketch* viewcontextSketch(ViewContext *vc, int create);
void sk_resetOverdraw(SK_Sketch *sketch);
int sk_hasOverdraw(SK_Sketch *sketch, SK_Stroke *stk);
@@ -381,7 +382,7 @@
char * BIF_nameBoneTemplate(const bContext *C)
{
ToolSettings *ts = CTX_data_tool_settings(C);
- SK_Sketch *stk = GLOBAL_sketch;
+ SK_Sketch *stk = contextSketch(C, 1);
RigGraph *rg;
int index = 0;
@@ -1592,6 +1593,7 @@
float p[3];
float size = 0;
+ BLI_freelistN(&sketch->depth_peels);
sketch->depth_peels.first = sketch->depth_peels.last = NULL;
peelObjectsContext(C, &sketch->depth_peels, dd->mval);
@@ -3023,9 +3025,10 @@
{
if (ValidSketchViewContext(vc))
{
- if (GLOBAL_sketch != NULL)
+ SK_Sketch *sketch = viewcontextSketch(vc, 0);
+ if (sketch)
{
- sk_drawSketch(vc->scene, vc->v3d, GLOBAL_sketch, 1);
+ sk_drawSketch(vc->scene, vc->v3d, sketch, 1);
return 1;
}
}
@@ -3037,18 +3040,20 @@
{
if (ED_operator_sketch_mode(C))
{
- if (GLOBAL_sketch != NULL)
+ SK_Sketch *sketch = contextSketch(C, 0);
+ if (sketch)
{
- sk_drawSketch(CTX_data_scene(C), CTX_wm_view3d(C), GLOBAL_sketch, 0);
+ sk_drawSketch(CTX_data_scene(C), CTX_wm_view3d(C), sketch, 0);
}
}
}
static int sketch_delete(bContext *C, wmOperator *op, wmEvent *event)
{
- if (GLOBAL_sketch != NULL)
+ SK_Sketch *sketch = contextSketch(C, 0);
+ if (sketch)
{
- sk_deleteSelectedStrokes(GLOBAL_sketch);
+ sk_deleteSelectedStrokes(sketch);
// allqueue(REDRAWVIEW3D, 0);
}
return OPERATOR_FINISHED;
@@ -3056,9 +3061,10 @@
void BIF_sk_selectStroke(bContext *C, short mval[2], short extend)
{
- if (GLOBAL_sketch != NULL)
+ SK_Sketch *sketch = contextSketch(C, 0);
+ if (sketch)
{
- sk_selectStroke(C, GLOBAL_sketch, mval, extend);
+ sk_selectStroke(C, sketch, mval, extend);
}
}
@@ -3066,9 +3072,10 @@
{
if (ED_operator_sketch_full_mode(C))
{
- if (GLOBAL_sketch != NULL)
+ SK_Sketch *sketch = contextSketch(C, 0);
+ if (sketch)
{
- sk_convert(C, GLOBAL_sketch);
+ sk_convert(C, sketch);
// BIF_undo_push("Convert Sketch");
// allqueue(REDRAWVIEW3D, 0);
// allqueue(REDRAWBUTSEDIT, 0);
@@ -3080,42 +3087,86 @@
{
if (ED_operator_sketch_full_mode(C))
{
- if (GLOBAL_sketch != NULL)
+ SK_Sketch *sketch = contextSketch(C, 0);
+ if (sketch)
{
- sk_deleteSelectedStrokes(GLOBAL_sketch);
+ sk_deleteSelectedStrokes(sketch);
// BIF_undo_push("Convert Sketch");
// allqueue(REDRAWVIEW3D, 0);
}
}
}
-//void BIF_selectAllSketch(bContext *C, int mode)
-//{
-// if (BIF_validSketchMode(C))
-// {
-// if (GLOBAL_sketch != NULL)
-// {
-// sk_selectAllSketch(GLOBAL_sketch, mode);
-//// XXX
-//// allqueue(REDRAWVIEW3D, 0);
-// }
-// }
-//}
+#if 0
+void BIF_selectAllSketch(bContext *C, int mode)
+{
+ if (BIF_validSketchMode(C))
+ {
+ SK_Sketch *sketch = contextSketch(C, 0);
+ if (sketch)
+ {
+ sk_selectAllSketch(sketch, mode);
+// XXX
+// allqueue(REDRAWVIEW3D, 0);
+ }
+ }
+}
+#endif
-void BIF_freeSketch(bContext *C)
+void ED_freeSketch(SK_Sketch *sketch)
{
- if (GLOBAL_sketch != NULL)
+ sk_freeSketch(sketch);
+}
+
+SK_Sketch* ED_createSketch()
+{
+ return sk_createSketch();
+}
+
+SK_Sketch* contextSketch(const bContext *C, int create)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ SK_Sketch *sketch = NULL;
+
+ if (obedit && obedit->type == OB_ARMATURE)
{
- sk_freeSketch(GLOBAL_sketch);
- GLOBAL_sketch = NULL;
+ bArmature *arm = obedit->data;
+
+ if (arm->sketch == NULL && create)
+ {
+ arm->sketch = sk_createSketch();
+ }
+ sketch = arm->sketch;
}
+
+ return sketch;
}
+SK_Sketch* viewcontextSketch(ViewContext *vc, int create)
+{
+ Object *obedit = vc->obedit;
+ SK_Sketch *sketch = NULL;
+
+ if (obedit && obedit->type == OB_ARMATURE)
+ {
+ bArmature *arm = obedit->data;
+
+ if (arm->sketch == NULL && create)
+ {
+ arm->sketch = sk_createSketch();
+ }
+ sketch = arm->sketch;
+ }
+
+ return sketch;
+}
+
static int sketch_cancel(bContext *C, wmOperator *op, wmEvent *event)
{
- if (GLOBAL_sketch != NULL)
+ SK_Sketch *sketch = contextSketch(C, 0);
+ if (sketch != NULL)
{
- sk_cancelStroke(GLOBAL_sketch);
+ sk_cancelStroke(sketch);
ED_area_tag_redraw(CTX_wm_area(C));
return OPERATOR_FINISHED;
}
@@ -3124,9 +3175,10 @@
static int sketch_finish(bContext *C, wmOperator *op, wmEvent *event)
{
- if (GLOBAL_sketch != NULL)
+ SK_Sketch *sketch = contextSketch(C, 0);
+ if (sketch != NULL)
{
- if (sk_finish_stroke(C, GLOBAL_sketch))
+ if (sk_finish_stroke(C, sketch))
{
ED_area_tag_redraw(CTX_wm_area(C));
return OPERATOR_FINISHED;
@@ -3137,10 +3189,11 @@
static int sketch_select(bContext *C, wmOperator *op, wmEvent *event)
{
- if (GLOBAL_sketch != NULL)
+ SK_Sketch *sketch = contextSketch(C, 0);
+ if (sketch)
{
short extend = 0;
- sk_selectStroke(C, GLOBAL_sketch, event->mval, extend);
+ sk_selectStroke(C, sketch, event->mval, extend);
ED_area_tag_redraw(CTX_wm_area(C));
}
@@ -3149,7 +3202,8 @@
static int sketch_draw_stroke_cancel(bContext *C, wmOperator *op)
{
- sk_cancelStroke(GLOBAL_sketch);
+ SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */
+ sk_cancelStroke(sketch);
MEM_freeN(op->customdata);
return OPERATOR_CANCELLED;
}
@@ -3158,18 +3212,14 @@
{
short snap = RNA_boolean_get(op->ptr, "snap");
SK_DrawData *dd;
+ SK_Sketch *sketch = contextSketch(C, 1);
- if (GLOBAL_sketch == NULL)
- {
- GLOBAL_sketch = sk_createSketch();
- }
-
op->customdata = dd = MEM_callocN(sizeof("SK_DrawData"), "SketchDrawData");
sk_initDrawData(dd, event->mval);
- sk_start_draw_stroke(GLOBAL_sketch);
+ sk_start_draw_stroke(sketch);
- sk_draw_stroke(C, GLOBAL_sketch, GLOBAL_sketch->active_stroke, dd, snap);
+ sk_draw_stroke(C, sketch, sketch->active_stroke, dd, snap);
WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
@@ -3178,7 +3228,8 @@
static int sketch_draw_gesture_cancel(bContext *C, wmOperator *op)
{
- sk_cancelStroke(GLOBAL_sketch);
+ SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */
+ sk_cancelStroke(sketch);
MEM_freeN(op->customdata);
return OPERATOR_CANCELLED;
}
@@ -3187,17 +3238,14 @@
{
short snap = RNA_boolean_get(op->ptr, "snap");
SK_DrawData *dd;
+ SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */
+ sk_cancelStroke(sketch);
- if (GLOBAL_sketch == NULL)
- {
- GLOBAL_sketch = sk_createSketch();
- }
-
op->customdata = dd = MEM_callocN(sizeof("SK_DrawData"), "SketchDrawData");
sk_initDrawData(dd, event->mval);
- sk_start_draw_gesture(GLOBAL_sketch);
- sk_draw_stroke(C, GLOBAL_sketch, GLOBAL_sketch->gesture, dd, snap);
+ sk_start_draw_gesture(sketch);
+ sk_draw_stroke(C, sketch, sketch->gesture, dd, snap);
WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
@@ -3208,6 +3256,7 @@
{
short snap = RNA_boolean_get(op->ptr, "snap");
SK_DrawData *dd = op->customdata;
+ SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */
int retval = OPERATOR_RUNNING_MODAL;
switch (event->type)
@@ -3220,7 +3269,7 @@
case MOUSEMOVE:
dd->mval[0] = event->mval[0];
dd->mval[1] = event->mval[1];
- sk_draw_stroke(C, GLOBAL_sketch, stk, dd, snap);
+ sk_draw_stroke(C, sketch, stk, dd, snap);
ED_area_tag_redraw(CTX_wm_area(C));
break;
case ESCKEY:
@@ -3235,7 +3284,7 @@
{
sk_endContinuousStroke(stk);
sk_filterLastContinuousStroke(stk);
- sk_updateNextPoint(GLOBAL_sketch, stk);
+ sk_updateNextPoint(sketch, stk);
ED_area_tag_redraw(CTX_wm_area(C));
MEM_freeN(op->customdata);
retval = OPERATOR_FINISHED;
@@ -3248,11 +3297,11 @@
if (stk->nb_points > 1)
{
/* apply gesture here */
- sk_applyGesture(C, GLOBAL_sketch);
+ sk_applyGesture(C, sketch);
}
sk_freeStroke(stk);
- GLOBAL_sketch->gesture = NULL;
+ sketch->gesture = NULL;
ED_area_tag_redraw(CTX_wm_area(C));
MEM_freeN(op->customdata);
@@ -3267,21 +3316,23 @@
static int sketch_draw_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
{
- return sketch_draw_modal(C, op, event, 0, GLOBAL_sketch->active_stroke);
+ SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */
+ return sketch_draw_modal(C, op, event, 0, sketch->active_stroke);
}
static int sketch_draw_gesture_modal(bContext *C, wmOperator *op, wmEvent *event)
{
- return sketch_draw_modal(C, op, event, 1, GLOBAL_sketch->gesture);
+ SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */
+ return sketch_draw_modal(C, op, event, 1, sketch->gesture);
}
static int sketch_draw_preview(bContext *C, wmOperator *op, wmEvent *event)
{
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list