~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/editors/armature/editarmature_sketch.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: editarmature_sketch.c 29870 2010-07-02 11:26:12Z blendix $
3
 
 *
 
1
/*
4
2
 * ***** BEGIN GPL LICENSE BLOCK *****
5
3
 *
6
4
 * This program is free software; you can redistribute it and/or
20
18
 * ***** END GPL LICENSE BLOCK *****
21
19
 */
22
20
 
 
21
/** \file blender/editors/armature/editarmature_sketch.c
 
22
 *  \ingroup edarmature
 
23
 */
 
24
 
 
25
 
23
26
#include <string.h>
24
27
#include <math.h>
25
28
#include <float.h>
26
29
 
27
30
#include "MEM_guardedalloc.h"
28
31
 
 
32
#include "DNA_object_types.h"
29
33
#include "DNA_scene_types.h"
30
34
#include "DNA_armature_types.h"
31
35
 
34
38
 
35
39
#include "BLI_blenlib.h"
36
40
#include "BLI_math.h"
 
41
#include "BLI_utildefines.h"
37
42
#include "BLI_graph.h"
38
43
#include "BLI_ghash.h"
39
44
 
40
 
#include "BKE_utildefines.h"
41
 
#include "BKE_global.h"
42
 
#include "BKE_DerivedMesh.h"
43
 
#include "BKE_object.h"
44
 
#include "BKE_anim.h"
45
45
#include "BKE_context.h"
46
46
#include "BKE_sketch.h"
47
47
 
79
79
        GestureApplyFct         apply;
80
80
} SK_GestureAction;
81
81
 
82
 
SK_Point boneSnap;
83
 
int    LAST_SNAP_POINT_VALID = 0;
84
 
float  LAST_SNAP_POINT[3];
 
82
#if 0 /* UNUSED 2.5 */
 
83
static SK_Point boneSnap;
 
84
#endif
 
85
 
 
86
static int    LAST_SNAP_POINT_VALID = 0;
 
87
static float  LAST_SNAP_POINT[3];
85
88
 
86
89
 
87
90
typedef struct SK_StrokeIterator {
109
112
 
110
113
void initStrokeIterator(BArcIterator *iter, SK_Stroke *stk, int start, int end);
111
114
 
112
 
void sk_deleteSelectedStrokes(SK_Sketch *sketch);
113
 
 
114
 
SK_Point *sk_lastStrokePoint(SK_Stroke *stk);
115
 
 
116
115
int sk_detectCutGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
117
116
void sk_applyCutGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
118
117
int sk_detectTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
136
135
 
137
136
/******************** GESTURE ACTIONS ******************************/
138
137
 
139
 
SK_GestureAction GESTURE_ACTIONS[] =
 
138
static SK_GestureAction GESTURE_ACTIONS[] =
140
139
        {
141
140
                {"Cut", sk_detectCutGesture, sk_applyCutGesture},
142
141
                {"Trim", sk_detectTrimGesture, sk_applyTrimGesture},
150
149
 
151
150
/******************** TEMPLATES UTILS *************************/
152
151
 
153
 
char  *TEMPLATES_MENU = NULL;
154
 
int    TEMPLATES_CURRENT = 0;
155
 
GHash *TEMPLATES_HASH = NULL;
156
 
RigGraph *TEMPLATE_RIGG = NULL;
 
152
static char  *TEMPLATES_MENU = NULL;
 
153
static int    TEMPLATES_CURRENT = 0;
 
154
static GHash *TEMPLATES_HASH = NULL;
 
155
static RigGraph *TEMPLATE_RIGG = NULL;
157
156
 
158
157
void BIF_makeListTemplates(const bContext *C)
159
158
{
188
187
        }
189
188
}
190
189
 
191
 
char *BIF_listTemplates(const bContext *C)
 
190
const char *BIF_listTemplates(const bContext *UNUSED(C))
192
191
{
193
192
        GHashIterator ghi;
194
193
        char menu_header[] = "Template%t|None%x0|";
247
246
        return TEMPLATES_CURRENT;
248
247
}
249
248
 
250
 
RigGraph* sk_makeTemplateGraph(const bContext *C, Object *ob)
 
249
static RigGraph* sk_makeTemplateGraph(const bContext *C, Object *ob)
251
250
{
252
251
        Object *obedit = CTX_data_edit_object(C);
253
252
        if (ob == obedit)
291
290
        }
292
291
}
293
292
 
294
 
char * BIF_nameBoneTemplate(const bContext *C)
 
293
const char * BIF_nameBoneTemplate(const bContext *C)
295
294
{
296
295
        ToolSettings *ts = CTX_data_tool_settings(C);
297
296
        SK_Sketch *stk = contextSketch(C, 1);
313
312
        return RIG_nameBone(rg, 0, index);
314
313
}
315
314
 
316
 
void  BIF_freeTemplates(bContext *C)
 
315
void  BIF_freeTemplates(bContext *UNUSED(C))
317
316
{
318
317
        if (TEMPLATES_MENU != NULL)
319
318
        {
355
354
 
356
355
/*********************** CONVERSION ***************************/
357
356
 
358
 
void sk_autoname(bContext *C, ReebArc *arc)
 
357
static void sk_autoname(bContext *C, ReebArc *arc)
359
358
{
360
359
        ToolSettings *ts = CTX_data_tool_settings(C);
361
360
        if (ts->skgen_retarget_options & SK_RETARGET_AUTONAME)
373
372
                        int valid = 0;
374
373
                        int caps = 0;
375
374
 
376
 
                        if (BLI_streq(side, ""))
 
375
                        if (side[0] == '\0')
377
376
                        {
378
377
                                valid = 1;
379
378
                        }
380
 
                        else if (BLI_streq(side, "R") || BLI_streq(side, "L"))
 
379
                        else if (strcmp(side, "R")==0 || strcmp(side, "L")==0)
381
380
                        {
382
381
                                valid = 1;
383
382
                                caps = 1;
384
383
                        }
385
 
                        else if (BLI_streq(side, "r") || BLI_streq(side, "l"))
 
384
                        else if (strcmp(side, "r")==0 || strcmp(side, "l")==0)
386
385
                        {
387
386
                                valid = 1;
388
387
                                caps = 0;
403
402
        }
404
403
}
405
404
 
406
 
ReebNode *sk_pointToNode(SK_Point *pt, float imat[][4], float tmat[][3])
 
405
static ReebNode *sk_pointToNode(SK_Point *pt, float imat[][4], float tmat[][3])
407
406
{
408
407
        ReebNode *node;
409
408
 
410
409
        node = MEM_callocN(sizeof(ReebNode), "reeb node");
411
 
        VECCOPY(node->p, pt->p);
 
410
        copy_v3_v3(node->p, pt->p);
412
411
        mul_m4_v3(imat, node->p);
413
412
 
414
 
        VECCOPY(node->no, pt->no);
 
413
        copy_v3_v3(node->no, pt->no);
415
414
        mul_m3_v3(tmat, node->no);
416
415
 
417
416
        return node;
418
417
}
419
418
 
420
 
ReebArc *sk_strokeToArc(SK_Stroke *stk, float imat[][4], float tmat[][3])
 
419
static ReebArc *sk_strokeToArc(SK_Stroke *stk, float imat[][4], float tmat[][3])
421
420
{
422
421
        ReebArc *arc;
423
422
        int i;
431
430
 
432
431
        for (i = 0; i < arc->bcount; i++)
433
432
        {
434
 
                VECCOPY(arc->buckets[i].p, stk->points[i + 1].p);
 
433
                copy_v3_v3(arc->buckets[i].p, stk->points[i + 1].p);
435
434
                mul_m4_v3(imat, arc->buckets[i].p);
436
435
 
437
 
                VECCOPY(arc->buckets[i].no, stk->points[i + 1].no);
 
436
                copy_v3_v3(arc->buckets[i].no, stk->points[i + 1].no);
438
437
                mul_m3_v3(tmat, arc->buckets[i].no);
439
438
        }
440
439
 
441
440
        return arc;
442
441
}
443
442
 
444
 
void sk_retargetStroke(bContext *C, SK_Stroke *stk)
 
443
static void sk_retargetStroke(bContext *C, SK_Stroke *stk)
445
444
{
446
445
        ToolSettings *ts = CTX_data_tool_settings(C);
447
446
        Object *obedit = CTX_data_edit_object(C);
472
471
 
473
472
/**************************************************************/
474
473
 
475
 
void sk_cancelStroke(SK_Sketch *sketch)
 
474
static void sk_cancelStroke(SK_Sketch *sketch)
476
475
{
477
476
        if (sketch->active_stroke != NULL)
478
477
        {
482
481
}
483
482
 
484
483
 
485
 
float sk_clampPointSize(SK_Point *pt, float size)
 
484
static float sk_clampPointSize(SK_Point *pt, float size)
486
485
{
487
486
        return MAX2(size * pt->size, size / 2);
488
487
}
489
488
 
490
 
void sk_drawPoint(GLUquadric *quad, SK_Point *pt, float size)
 
489
static void sk_drawPoint(GLUquadric *quad, SK_Point *pt, float size)
491
490
{
492
491
        glTranslatef(pt->p[0], pt->p[1], pt->p[2]);
493
492
        gluSphere(quad, sk_clampPointSize(pt, size), 8, 8);
494
493
}
495
494
 
496
 
void sk_drawEdge(GLUquadric *quad, SK_Point *pt0, SK_Point *pt1, float size)
 
495
static void sk_drawEdge(GLUquadric *quad, SK_Point *pt0, SK_Point *pt1, float size)
497
496
{
498
497
        float vec1[3], vec2[3] = {0, 0, 1}, axis[3];
499
498
        float angle, length;
509
508
 
510
509
        angle = angle_normalized_v3v3(vec2, vec1);
511
510
 
512
 
        glRotatef(angle * 180 / M_PI + 180, axis[0], axis[1], axis[2]);
 
511
        glRotatef(angle * (float)(180.0/M_PI) + 180.0f, axis[0], axis[1], axis[2]);
513
512
 
514
513
        gluCylinder(quad, sk_clampPointSize(pt1, size), sk_clampPointSize(pt0, size), length, 8, 8);
515
514
}
516
515
 
517
 
void sk_drawNormal(GLUquadric *quad, SK_Point *pt, float size, float height)
 
516
static void sk_drawNormal(GLUquadric *quad, SK_Point *pt, float size, float height)
518
517
{
519
518
        float vec2[3] = {0, 0, 1}, axis[3];
520
519
        float angle;
530
529
 
531
530
        angle = angle_normalized_v3v3(vec2, pt->no);
532
531
 
533
 
        glRotatef(angle * 180 / M_PI, axis[0], axis[1], axis[2]);
 
532
        glRotatef(angle * (float)(180.0/M_PI), axis[0], axis[1], axis[2]);
534
533
 
535
534
        glColor3f(0, 1, 1);
536
535
        gluCylinder(quad, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height), 10, 2);
538
537
        glPopMatrix();
539
538
}
540
539
 
541
 
void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end)
 
540
static void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end)
542
541
{
543
542
        float rgb[3];
544
543
        int i;
614
613
        gluDeleteQuadric(quad);
615
614
}
616
615
 
617
 
void drawSubdividedStrokeBy(ToolSettings *toolsettings, BArcIterator *iter, NextSubdivisionFunc next_subdividion)
 
616
static void drawSubdividedStrokeBy(ToolSettings *toolsettings, BArcIterator *iter, NextSubdivisionFunc next_subdividion)
618
617
{
619
618
        SK_Stroke *stk = ((SK_StrokeIterator*)iter)->stroke;
620
619
        float head[3], tail[3];
625
624
        gluQuadricNormals(quad, GLU_SMOOTH);
626
625
 
627
626
        iter->head(iter);
628
 
        VECCOPY(head, iter->p);
 
627
        copy_v3_v3(head, iter->p);
629
628
 
630
629
        index = next_subdividion(toolsettings, iter, bone_start, end, head, tail);
631
630
        while (index != -1)
641
640
 
642
641
                glPopMatrix();
643
642
 
644
 
                VECCOPY(head, tail);
 
643
                copy_v3_v3(head, tail);
645
644
                bone_start = index; // start next bone from current index
646
645
 
647
646
                index = next_subdividion(toolsettings, iter, bone_start, end, head, tail);
650
649
        gluDeleteQuadric(quad);
651
650
}
652
651
 
653
 
void sk_drawStrokeSubdivision(ToolSettings *toolsettings, SK_Stroke *stk)
 
652
static void sk_drawStrokeSubdivision(ToolSettings *toolsettings, SK_Stroke *stk)
654
653
{
655
654
        int head_index = -1;
656
655
        int i;
701
700
        }
702
701
}
703
702
 
704
 
SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, short mval[2], int *dist, int *index, int all_pts)
 
703
static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], int *dist, int *index, int all_pts)
705
704
{
706
705
        ARegion *ar = CTX_wm_region(C);
707
706
        SK_Point *pt = NULL;
734
733
        return pt;
735
734
}
736
735
 
737
 
SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, short mval[2], int *dist)
 
736
#if 0 /* UNUSED 2.5 */
 
737
static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, int mval[2], int *dist)
738
738
{
739
739
        ARegion *ar = CTX_wm_region(C);
740
740
        SK_Point *pt = NULL;
748
748
 
749
749
                if ((bone->flag & BONE_CONNECTED) == 0)
750
750
                {
751
 
                        VECCOPY(vec, bone->head);
 
751
                        copy_v3_v3(vec, bone->head);
752
752
                        mul_m4_v3(ob->obmat, vec);
753
753
                        project_short_noclip(ar, vec, pval);
754
754
 
758
758
                        {
759
759
                                *dist = pdist;
760
760
                                pt = &boneSnap;
761
 
                                VECCOPY(pt->p, vec);
 
761
                                copy_v3_v3(pt->p, vec);
762
762
                                pt->type = PT_EXACT;
763
763
                        }
764
764
                }
765
765
 
766
766
 
767
 
                VECCOPY(vec, bone->tail);
 
767
                copy_v3_v3(vec, bone->tail);
768
768
                mul_m4_v3(ob->obmat, vec);
769
769
                project_short_noclip(ar, vec, pval);
770
770
 
774
774
                {
775
775
                        *dist = pdist;
776
776
                        pt = &boneSnap;
777
 
                        VECCOPY(pt->p, vec);
 
777
                        copy_v3_v3(pt->p, vec);
778
778
                        pt->type = PT_EXACT;
779
779
                }
780
780
        }
781
781
 
782
782
        return pt;
783
783
}
 
784
#endif
784
785
 
785
786
void sk_resetOverdraw(SK_Sketch *sketch)
786
787
{
798
799
                        (sketch->over.start != -1 || sketch->over.end != -1);
799
800
}
800
801
 
801
 
void sk_updateOverdraw(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
 
802
static void sk_updateOverdraw(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
802
803
{
803
804
        if (sketch->over.target == NULL)
804
805
        {
875
876
}
876
877
 
877
878
/* return 1 on reverse needed */
878
 
int sk_adjustIndexes(SK_Sketch *sketch, int *start, int *end)
 
879
static int sk_adjustIndexes(SK_Sketch *sketch, int *start, int *end)
879
880
{
880
881
        int retval = 0;
881
882
 
903
904
        return retval;
904
905
}
905
906
 
906
 
void sk_endOverdraw(SK_Sketch *sketch)
 
907
static void sk_endOverdraw(SK_Sketch *sketch)
907
908
{
908
909
        SK_Stroke *stk = sketch->active_stroke;
909
910
 
932
933
}
933
934
 
934
935
 
935
 
void sk_startStroke(SK_Sketch *sketch)
 
936
static void sk_startStroke(SK_Sketch *sketch)
936
937
{
937
938
        SK_Stroke *stk = sk_createStroke();
938
939
 
942
943
        sk_resetOverdraw(sketch);
943
944
}
944
945
 
945
 
void sk_endStroke(bContext *C, SK_Sketch *sketch)
 
946
static void sk_endStroke(bContext *C, SK_Sketch *sketch)
946
947
{
947
948
        ToolSettings *ts = CTX_data_tool_settings(C);
948
949
        sk_shrinkStrokeBuffer(sketch->active_stroke);
955
956
        sketch->active_stroke = NULL;
956
957
}
957
958
 
958
 
void sk_updateDrawData(SK_DrawData *dd)
 
959
static void sk_updateDrawData(SK_DrawData *dd)
959
960
{
960
961
        dd->type = PT_CONTINUOUS;
961
962
 
963
964
        dd->previous_mval[1] = dd->mval[1];
964
965
}
965
966
 
966
 
float sk_distanceDepth(bContext *C, float p1[3], float p2[3])
 
967
static float sk_distanceDepth(bContext *C, float p1[3], float p2[3])
967
968
{
968
969
        ARegion *ar = CTX_wm_region(C);
969
970
        RegionView3D *rv3d = ar->regiondata;
984
985
        return distance;
985
986
}
986
987
 
987
 
void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end, float length, float distance)
 
988
static void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end, float length, float distance)
988
989
{
989
990
        ARegion *ar = CTX_wm_region(C);
990
991
        ScrArea *sa = CTX_wm_area(C);
1002
1003
                float pval[2];
1003
1004
 
1004
1005
                project_float(ar, stk->points[i].p, pval);
1005
 
                viewray(ar, v3d, pval, ray_start, ray_normal);
 
1006
                ED_view3d_win_to_ray(ar, v3d, pval, ray_start, ray_normal);
1006
1007
 
1007
1008
                mul_v3_fl(ray_normal, distance * progress / length);
1008
1009
                add_v3_v3(stk->points[i].p, ray_normal);
1009
1010
 
1010
 
                progress += delta ;
 
1011
                progress += delta;
1011
1012
        }
1012
1013
}
1013
1014
 
1014
 
void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_DrawData *dd)
 
1015
static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_DrawData *dd)
1015
1016
{
1016
1017
        ARegion *ar = CTX_wm_region(C);
1017
1018
        /* copied from grease pencil, need fixing */
1019
1020
        short cval[2];
1020
1021
        float fp[3] = {0, 0, 0};
1021
1022
        float dvec[3];
 
1023
        float mval_f[2];
1022
1024
 
1023
1025
        if (last != NULL)
1024
1026
        {
1025
 
                VECCOPY(fp, last->p);
 
1027
                copy_v3_v3(fp, last->p);
1026
1028
        }
1027
1029
 
1028
1030
        initgrabz(ar->regiondata, fp[0], fp[1], fp[2]);
1029
1031
 
1030
1032
        /* method taken from editview.c - mouse_cursor() */
1031
1033
        project_short_noclip(ar, fp, cval);
1032
 
        window_to_3d_delta(ar, dvec, cval[0] - dd->mval[0], cval[1] - dd->mval[1]);
 
1034
        VECSUB2D(mval_f, cval, dd->mval);
 
1035
        ED_view3d_win_to_delta(ar, mval_f, dvec);
1033
1036
        sub_v3_v3v3(vec, fp, dvec);
1034
1037
}
1035
1038
 
1036
 
int sk_getStrokeDrawPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
 
1039
static int sk_getStrokeDrawPoint(bContext *C, SK_Point *pt, SK_Sketch *UNUSED(sketch), SK_Stroke *stk, SK_DrawData *dd)
1037
1040
{
1038
1041
        pt->type = dd->type;
1039
1042
        pt->mode = PT_PROJECT;
1042
1045
        return 1;
1043
1046
}
1044
1047
 
1045
 
int sk_addStrokeDrawPoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
 
1048
static int sk_addStrokeDrawPoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
1046
1049
{
1047
1050
        ARegion *ar = CTX_wm_region(C);
1048
1051
        RegionView3D *rv3d = ar->regiondata;
1057
1060
        return 1;
1058
1061
}
1059
1062
 
1060
 
int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
 
1063
static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
1061
1064
{
1062
1065
        ToolSettings *ts = CTX_data_tool_settings(C);
1063
1066
        int point_added = 0;
1076
1079
 
1077
1080
                mvalf[0]= dd->mval[0];
1078
1081
                mvalf[1]= dd->mval[1];
1079
 
                peelObjectsContext(C, &sketch->depth_peels, mvalf);
 
1082
                peelObjectsContext(C, &sketch->depth_peels, mvalf, SNAP_ALL);
1080
1083
 
1081
1084
                if (stk->nb_points > 0 && stk->points[stk->nb_points - 1].type == PT_CONTINUOUS)
1082
1085
                {
1131
1134
                                }
1132
1135
                                else
1133
1136
                                {
1134
 
                                        VECCOPY(vec, p1->p);
 
1137
                                        copy_v3_v3(vec, p1->p);
1135
1138
                                }
1136
1139
 
1137
1140
                                if (last_p == NULL)
1138
1141
                                {
1139
 
                                        VECCOPY(p, vec);
 
1142
                                        copy_v3_v3(p, vec);
1140
1143
                                        size = new_size;
1141
1144
                                        dist = 0;
1142
1145
                                        break;
1146
1149
 
1147
1150
                                if (new_dist < dist)
1148
1151
                                {
1149
 
                                        VECCOPY(p, vec);
 
1152
                                        copy_v3_v3(p, vec);
1150
1153
                                        dist = new_dist;
1151
1154
                                        size = new_size;
1152
1155
                                }
1158
1161
                        pt->type = dd->type;
1159
1162
                        pt->mode = PT_SNAP;
1160
1163
                        pt->size = size / 2;
1161
 
                        VECCOPY(pt->p, p);
 
1164
                        copy_v3_v3(pt->p, p);
1162
1165
 
1163
1166
                        point_added = 1;
1164
1167
                }
1190
1193
 
1191
1194
                        if (spt != NULL)
1192
1195
                        {
1193
 
                                VECCOPY(pt->p, spt->p);
 
1196
                                copy_v3_v3(pt->p, spt->p);
1194
1197
                                point_added = 1;
1195
1198
                        }
1196
1199
                }
1204
1207
                {
1205
1208
                        pt->type = dd->type;
1206
1209
                        pt->mode = PT_SNAP;
1207
 
                        VECCOPY(pt->p, vec);
 
1210
                        copy_v3_v3(pt->p, vec);
1208
1211
 
1209
1212
                        point_added = 1;
1210
1213
                }
1213
1216
        return point_added;
1214
1217
}
1215
1218
 
1216
 
int sk_addStrokeSnapPoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
 
1219
static int sk_addStrokeSnapPoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
1217
1220
{
1218
1221
        int point_added;
1219
1222
        ARegion *ar = CTX_wm_region(C);
1231
1234
                int total;
1232
1235
                int i;
1233
1236
 
1234
 
                VECCOPY(final_p, pt.p);
 
1237
                copy_v3_v3(final_p, pt.p);
1235
1238
 
1236
1239
                sk_projectDrawPoint(C, pt.p, stk, dd);
1237
1240
                sk_appendStrokePoint(stk, &pt);
1256
1259
                        sk_interpolateDepth(C, stk, i + 1, stk->nb_points - 2, length, distance);
1257
1260
                }
1258
1261
 
1259
 
                VECCOPY(stk->points[stk->nb_points - 1].p, final_p);
 
1262
                copy_v3_v3(stk->points[stk->nb_points - 1].p, final_p);
1260
1263
 
1261
1264
                point_added = 1;
1262
1265
        }
1264
1267
        return point_added;
1265
1268
}
1266
1269
 
1267
 
void sk_addStrokePoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd, short snap)
 
1270
static void sk_addStrokePoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd, short snap)
1268
1271
{
1269
1272
        ToolSettings *ts = CTX_data_tool_settings(C);
1270
1273
        int point_added = 0;
1285
1288
        }
1286
1289
}
1287
1290
 
1288
 
void sk_getStrokePoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd, short snap)
 
1291
static void sk_getStrokePoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd, short snap)
1289
1292
{
1290
1293
        int point_added = 0;
1291
1294
 
1293
1296
        {
1294
1297
                point_added = sk_getStrokeSnapPoint(C, pt, sketch, stk, dd);
1295
1298
                LAST_SNAP_POINT_VALID = 1;
1296
 
                VECCOPY(LAST_SNAP_POINT, pt->p);
 
1299
                copy_v3_v3(LAST_SNAP_POINT, pt->p);
1297
1300
        }
1298
1301
        else
1299
1302
        {
1473
1476
        }
1474
1477
}
1475
1478
 
1476
 
void sk_convertStroke(bContext *C, SK_Stroke *stk)
 
1479
static void sk_convertStroke(bContext *C, SK_Stroke *stk)
1477
1480
{
1478
1481
        Object *obedit = CTX_data_edit_object(C);
1479
1482
        ToolSettings *ts = CTX_data_tool_settings(C);
1533
1536
                                {
1534
1537
                                        bone = ED_armature_edit_bone_add(arm, "Bone");
1535
1538
 
1536
 
                                        VECCOPY(bone->head, head->p);
1537
 
                                        VECCOPY(bone->tail, pt->p);
 
1539
                                        copy_v3_v3(bone->head, head->p);
 
1540
                                        copy_v3_v3(bone->tail, pt->p);
1538
1541
 
1539
1542
                                        mul_m4_v3(invmat, bone->head);
1540
1543
                                        mul_m4_v3(invmat, bone->tail);
1565
1568
        }
1566
1569
}
1567
1570
 
1568
 
void sk_convert(bContext *C, SK_Sketch *sketch)
 
1571
static void sk_convert(bContext *C, SK_Sketch *sketch)
1569
1572
{
1570
1573
        ToolSettings *ts = CTX_data_tool_settings(C);
1571
1574
        SK_Stroke *stk;
1591
1594
 
1592
1595
 
1593
1596
/* returns the number of self intersections */
1594
 
int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gesture)
 
1597
static int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gesture)
1595
1598
{
1596
1599
        ARegion *ar = CTX_wm_region(C);
1597
1600
        int added = 0;
1640
1643
        return added;
1641
1644
}
1642
1645
 
1643
 
int cmpIntersections(void *i1, void *i2)
 
1646
static int cmpIntersections(void *i1, void *i2)
1644
1647
{
1645
1648
        SK_Intersection *isect1 = i1, *isect2 = i2;
1646
1649
 
1672
1675
 
1673
1676
 
1674
1677
/* returns the maximum number of intersections per stroke */
1675
 
int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, SK_Stroke *gesture)
 
1678
static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, SK_Stroke *gesture)
1676
1679
{
1677
1680
        ARegion *ar = CTX_wm_region(C);
1678
1681
        ScrArea *sa = CTX_wm_area(C);
1718
1721
 
1719
1722
                                        mval[0] = vi[0];
1720
1723
                                        mval[1] = vi[1];
1721
 
                                        viewline(ar, v3d, mval, ray_start, ray_end);
 
1724
                                        ED_view3d_win_to_segment_clip(ar, v3d, mval, ray_start, ray_end);
1722
1725
 
1723
1726
                                        isect_line_line_v3(     stk->points[s_i].p,
1724
1727
                                                                                stk->points[s_i + 1].p,
1742
1745
        return added;
1743
1746
}
1744
1747
 
1745
 
int sk_getSegments(SK_Stroke *segments, SK_Stroke *gesture)
 
1748
static int sk_getSegments(SK_Stroke *segments, SK_Stroke *gesture)
1746
1749
{
1747
1750
        SK_StrokeIterator sk_iter;
1748
1751
        BArcIterator *iter = (BArcIterator*)&sk_iter;
1777
1780
        return segments->nb_points - 1;
1778
1781
}
1779
1782
 
1780
 
int sk_detectCutGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
 
1783
int sk_detectCutGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
1781
1784
{
1782
1785
        if (gest->nb_segments == 1 && gest->nb_intersections == 1)
1783
1786
        {
1787
1790
        return 0;
1788
1791
}
1789
1792
 
1790
 
void sk_applyCutGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
 
1793
void sk_applyCutGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
1791
1794
{
1792
1795
        SK_Intersection *isect;
1793
1796
 
1796
1799
                SK_Point pt;
1797
1800
 
1798
1801
                pt.type = PT_EXACT;
1799
 
                pt.mode = PT_PROJECT; /* take mode from neighbouring points */
1800
 
                VECCOPY(pt.p, isect->p);
1801
 
                VECCOPY(pt.no, isect->stroke->points[isect->before].no);
 
1802
                pt.mode = PT_PROJECT; /* take mode from neighboring points */
 
1803
                copy_v3_v3(pt.p, isect->p);
 
1804
                copy_v3_v3(pt.no, isect->stroke->points[isect->before].no);
1802
1805
 
1803
1806
                sk_insertStrokePoint(isect->stroke, &pt, isect->after);
1804
1807
        }
1805
1808
}
1806
1809
 
1807
 
int sk_detectTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
 
1810
int sk_detectTrimGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
1808
1811
{
1809
1812
        if (gest->nb_segments == 2 && gest->nb_intersections == 1 && gest->nb_self_intersections == 0)
1810
1813
        {
1814
1817
                sub_v3_v3v3(s1, gest->segments->points[1].p, gest->segments->points[0].p);
1815
1818
                sub_v3_v3v3(s2, gest->segments->points[2].p, gest->segments->points[1].p);
1816
1819
 
1817
 
                angle = RAD2DEG(angle_v2v2(s1, s2));
 
1820
                angle = RAD2DEGF(angle_v2v2(s1, s2));
1818
1821
 
1819
1822
                if (angle > 60 && angle < 120)
1820
1823
                {
1825
1828
        return 0;
1826
1829
}
1827
1830
 
1828
 
void sk_applyTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
 
1831
void sk_applyTrimGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
1829
1832
{
1830
1833
        SK_Intersection *isect;
1831
1834
        float trim_dir[3];
1838
1841
                float stroke_dir[3];
1839
1842
 
1840
1843
                pt.type = PT_EXACT;
1841
 
                pt.mode = PT_PROJECT; /* take mode from neighbouring points */
1842
 
                VECCOPY(pt.p, isect->p);
1843
 
                VECCOPY(pt.no, isect->stroke->points[isect->before].no);
 
1844
                pt.mode = PT_PROJECT; /* take mode from neighboring points */
 
1845
                copy_v3_v3(pt.p, isect->p);
 
1846
                copy_v3_v3(pt.no, isect->stroke->points[isect->before].no);
1844
1847
 
1845
1848
                sub_v3_v3v3(stroke_dir, isect->stroke->points[isect->after].p, isect->stroke->points[isect->before].p);
1846
1849
 
1860
1863
        }
1861
1864
}
1862
1865
 
1863
 
int sk_detectCommandGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
 
1866
int sk_detectCommandGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
1864
1867
{
1865
1868
        if (gest->nb_segments > 2 && gest->nb_intersections == 2 && gest->nb_self_intersections == 1)
1866
1869
        {
1867
1870
                SK_Intersection *isect, *self_isect;
1868
1871
 
1869
1872
                /* get the the last intersection of the first pair */
1870
 
                for( isect = gest->intersections.first; isect; isect = isect->next )
 
1873
                for ( isect = gest->intersections.first; isect; isect = isect->next )
1871
1874
                {
1872
1875
                        if (isect->stroke == isect->next->stroke)
1873
1876
                        {
1887
1890
        return 0;
1888
1891
}
1889
1892
 
1890
 
void sk_applyCommandGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
 
1893
void sk_applyCommandGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
1891
1894
{
1892
1895
        SK_Intersection *isect;
1893
1896
        int command = 1;
1894
1897
 
1895
1898
//      XXX
1896
1899
//      command = pupmenu("Action %t|Flatten %x1|Straighten %x2|Polygonize %x3");
1897
 
        if(command < 1) return;
 
1900
        if (command < 1) return;
1898
1901
 
1899
1902
        for (isect = gest->intersections.first; isect; isect = isect->next)
1900
1903
        {
1922
1925
        }
1923
1926
}
1924
1927
 
1925
 
int sk_detectDeleteGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
 
1928
int sk_detectDeleteGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
1926
1929
{
1927
1930
        if (gest->nb_segments == 2 && gest->nb_intersections == 2)
1928
1931
        {
1932
1935
                sub_v3_v3v3(s1, gest->segments->points[1].p, gest->segments->points[0].p);
1933
1936
                sub_v3_v3v3(s2, gest->segments->points[2].p, gest->segments->points[1].p);
1934
1937
 
1935
 
                angle = RAD2DEG(angle_v2v2(s1, s2));
 
1938
                angle = RAD2DEGF(angle_v2v2(s1, s2));
1936
1939
 
1937
1940
                if (angle > 120)
1938
1941
                {
1943
1946
        return 0;
1944
1947
}
1945
1948
 
1946
 
void sk_applyDeleteGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
 
1949
void sk_applyDeleteGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *sketch)
1947
1950
{
1948
1951
        SK_Intersection *isect;
1949
1952
 
1959
1962
        }
1960
1963
}
1961
1964
 
1962
 
int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
 
1965
int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
1963
1966
{
1964
1967
        ARegion *ar = CTX_wm_region(C);
1965
1968
        if (gest->nb_segments > 2 && gest->nb_intersections == 2)
2007
2010
        return 0;
2008
2011
}
2009
2012
 
2010
 
void sk_applyMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
 
2013
void sk_applyMergeGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
2011
2014
{
2012
2015
        SK_Intersection *isect;
2013
2016
 
2038
2041
        }
2039
2042
}
2040
2043
 
2041
 
int sk_detectReverseGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
 
2044
int sk_detectReverseGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
2042
2045
{
2043
2046
        if (gest->nb_segments > 2 && gest->nb_intersections == 2 && gest->nb_self_intersections == 0)
2044
2047
        {
2064
2067
                                        sub_v3_v3v3(end_v, sk_lastStrokePoint(gest->stk)->p, isect->p);
2065
2068
                                }
2066
2069
 
2067
 
                                angle = RAD2DEG(angle_v2v2(start_v, end_v));
 
2070
                                angle = RAD2DEGF(angle_v2v2(start_v, end_v));
2068
2071
 
2069
2072
                                if (angle > 120)
2070
2073
                                {
2080
2083
        return 0;
2081
2084
}
2082
2085
 
2083
 
void sk_applyReverseGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
 
2086
void sk_applyReverseGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
2084
2087
{
2085
2088
        SK_Intersection *isect;
2086
2089
 
2097
2100
        }
2098
2101
}
2099
2102
 
2100
 
int sk_detectConvertGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
 
2103
int sk_detectConvertGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
2101
2104
{
2102
2105
        if (gest->nb_segments == 3 && gest->nb_self_intersections == 1)
2103
2106
        {
2106
2109
        return 0;
2107
2110
}
2108
2111
 
2109
 
void sk_applyConvertGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
 
2112
void sk_applyConvertGesture(bContext *C, SK_Gesture *UNUSED(gest), SK_Sketch *sketch)
2110
2113
{
2111
2114
        sk_convert(C, sketch);
2112
2115
}
2131
2134
        BLI_freelistN(&gest->self_intersections);
2132
2135
}
2133
2136
 
2134
 
void sk_applyGesture(bContext *C, SK_Sketch *sketch)
 
2137
static void sk_applyGesture(bContext *C, SK_Sketch *sketch)
2135
2138
{
2136
2139
        SK_Gesture gest;
2137
2140
        SK_GestureAction *act;
2154
2157
/********************************************/
2155
2158
 
2156
2159
 
2157
 
int sk_selectStroke(bContext *C, SK_Sketch *sketch, short mval[2], int extend)
 
2160
static int sk_selectStroke(bContext *C, SK_Sketch *sketch, const int mval[2], int extend)
2158
2161
{
2159
2162
        ViewContext vc;
2160
2163
        rcti rect;
2163
2166
 
2164
2167
        view3d_set_viewcontext(C, &vc);
2165
2168
 
2166
 
        rect.xmin= mval[0]-5;
2167
 
        rect.xmax= mval[0]+5;
2168
 
        rect.ymin= mval[1]-5;
2169
 
        rect.ymax= mval[1]+5;
 
2169
        rect.xmin = mval[0]-5;
 
2170
        rect.xmax = mval[0]+5;
 
2171
        rect.ymin = mval[1]-5;
 
2172
        rect.ymax = mval[1]+5;
2170
2173
 
2171
2174
        hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect);
2172
2175
 
2174
2177
        {
2175
2178
                int besthitresult = -1;
2176
2179
 
2177
 
                if(hits == 1) {
 
2180
                if (hits == 1) {
2178
2181
                        besthitresult = buffer[3];
2179
2182
                }
2180
2183
                else {
2205
2208
        return 0;
2206
2209
}
2207
2210
 
2208
 
void sk_queueRedrawSketch(SK_Sketch *sketch)
 
2211
#if 0 /* UNUSED 2.5 */
 
2212
static void sk_queueRedrawSketch(SK_Sketch *sketch)
2209
2213
{
2210
2214
        if (sketch->active_stroke != NULL)
2211
2215
        {
2218
2222
                }
2219
2223
        }
2220
2224
}
 
2225
#endif
2221
2226
 
2222
 
void sk_drawSketch(Scene *scene, View3D *v3d, SK_Sketch *sketch, int with_names)
 
2227
static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch, int with_names)
2223
2228
{
2224
2229
        ToolSettings *ts= scene->toolsettings;
2225
2230
        SK_Stroke *stk;
2347
2352
        }
2348
2353
}
2349
2354
 
2350
 
int sk_finish_stroke(bContext *C, SK_Sketch *sketch)
 
2355
static int sk_finish_stroke(bContext *C, SK_Sketch *sketch)
2351
2356
{
2352
2357
        ToolSettings *ts = CTX_data_tool_settings(C);
2353
2358
 
2382
2387
        return 0;
2383
2388
}
2384
2389
 
2385
 
void sk_start_draw_stroke(SK_Sketch *sketch)
 
2390
static void sk_start_draw_stroke(SK_Sketch *sketch)
2386
2391
{
2387
2392
        if (sketch->active_stroke == NULL)
2388
2393
        {
2393
2398
        }
2394
2399
}
2395
2400
 
2396
 
void sk_start_draw_gesture(SK_Sketch *sketch)
 
2401
static void sk_start_draw_gesture(SK_Sketch *sketch)
2397
2402
{
2398
2403
        sketch->gesture = sk_createStroke();
2399
2404
}
2400
2405
 
2401
 
int sk_draw_stroke(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd, short snap)
 
2406
static int sk_draw_stroke(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd, short snap)
2402
2407
{
2403
2408
        if (sk_stroke_filtermval(dd))
2404
2409
        {
2456
2461
        }
2457
2462
}
2458
2463
 
2459
 
static int sketch_delete(bContext *C, wmOperator *op, wmEvent *event)
 
2464
static int sketch_delete(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
2460
2465
{
2461
2466
        SK_Sketch *sketch = contextSketch(C, 0);
2462
2467
        if (sketch)
2464
2469
                sk_deleteSelectedStrokes(sketch);
2465
2470
//                      allqueue(REDRAWVIEW3D, 0);
2466
2471
        }
 
2472
        WM_event_add_notifier(C, NC_SCREEN|ND_SKETCH|NA_REMOVED, NULL);
2467
2473
        return OPERATOR_FINISHED;
2468
2474
}
2469
2475
 
2470
 
void BIF_sk_selectStroke(bContext *C, short mval[2], short extend)
 
2476
void BIF_sk_selectStroke(bContext *C, const int mval[2], short extend)
2471
2477
{
2472
2478
        ToolSettings *ts = CTX_data_tool_settings(C);
2473
2479
        SK_Sketch *sketch = contextSketch(C, 0);
2562
2568
        return sketch;
2563
2569
}
2564
2570
 
2565
 
static int sketch_convert(bContext *C, wmOperator *op, wmEvent *event)
 
2571
static int sketch_convert(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
2566
2572
{
2567
2573
        SK_Sketch *sketch = contextSketch(C, 0);
2568
2574
        if (sketch != NULL)
2573
2579
        return OPERATOR_FINISHED;
2574
2580
}
2575
2581
 
2576
 
static int sketch_cancel(bContext *C, wmOperator *op, wmEvent *event)
 
2582
static int sketch_cancel(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
2577
2583
{
2578
2584
        SK_Sketch *sketch = contextSketch(C, 0);
2579
2585
        if (sketch != NULL)
2585
2591
        return OPERATOR_PASS_THROUGH;
2586
2592
}
2587
2593
 
2588
 
static int sketch_finish(bContext *C, wmOperator *op, wmEvent *event)
 
2594
static int sketch_finish(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
2589
2595
{
2590
2596
        SK_Sketch *sketch = contextSketch(C, 0);
2591
2597
        if (sketch != NULL)
2599
2605
        return OPERATOR_PASS_THROUGH;
2600
2606
}
2601
2607
 
2602
 
static int sketch_select(bContext *C, wmOperator *op, wmEvent *event)
 
2608
static int sketch_select(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
2603
2609
{
2604
2610
        SK_Sketch *sketch = contextSketch(C, 0);
2605
2611
        if (sketch)
2775
2781
        }
2776
2782
}
2777
2783
 
2778
 
int ED_operator_sketch_mode_gesture(bContext *C)
 
2784
static int ED_operator_sketch_mode_gesture(bContext *C)
2779
2785
{
2780
2786
        ToolSettings *ts = CTX_data_tool_settings(C);
2781
2787
        SK_Sketch *sketch = contextSketch(C, 0);
2833
2839
void SKETCH_OT_delete(wmOperatorType *ot)
2834
2840
{
2835
2841
        /* identifiers */
2836
 
        ot->name= "delete";
2837
 
        ot->idname= "SKETCH_OT_delete";
 
2842
        ot->name = "Delete";
 
2843
        ot->idname = "SKETCH_OT_delete";
2838
2844
 
2839
2845
        /* api callbacks */
2840
 
        ot->invoke= sketch_delete;
 
2846
        ot->invoke = sketch_delete;
2841
2847
 
2842
 
        ot->poll= ED_operator_sketch_full_mode;
 
2848
        ot->poll = ED_operator_sketch_full_mode;
2843
2849
 
2844
2850
        /* flags */
2845
 
//      ot->flag= OPTYPE_UNDO;
 
2851
//      ot->flag = OPTYPE_UNDO;
2846
2852
}
2847
2853
 
2848
2854
void SKETCH_OT_select(wmOperatorType *ot)
2849
2855
{
2850
2856
        /* identifiers */
2851
 
        ot->name= "select";
2852
 
        ot->idname= "SKETCH_OT_select";
 
2857
        ot->name = "Select";
 
2858
        ot->idname = "SKETCH_OT_select";
2853
2859
 
2854
2860
        /* api callbacks */
2855
 
        ot->invoke= sketch_select;
 
2861
        ot->invoke = sketch_select;
2856
2862
 
2857
 
        ot->poll= ED_operator_sketch_full_mode;
 
2863
        ot->poll = ED_operator_sketch_full_mode;
2858
2864
 
2859
2865
        /* flags */
2860
 
//      ot->flag= OPTYPE_UNDO;
 
2866
//      ot->flag = OPTYPE_UNDO;
2861
2867
}
2862
2868
 
2863
2869
void SKETCH_OT_cancel_stroke(wmOperatorType *ot)
2864
2870
{
2865
2871
        /* identifiers */
2866
 
        ot->name= "cancel stroke";
2867
 
        ot->idname= "SKETCH_OT_cancel_stroke";
 
2872
        ot->name = "Cancel Stroke";
 
2873
        ot->idname = "SKETCH_OT_cancel_stroke";
2868
2874
 
2869
2875
        /* api callbacks */
2870
 
        ot->invoke= sketch_cancel;
 
2876
        ot->invoke = sketch_cancel;
2871
2877
 
2872
 
        ot->poll= ED_operator_sketch_mode_active_stroke;
 
2878
        ot->poll = ED_operator_sketch_mode_active_stroke;
2873
2879
 
2874
2880
        /* flags */
2875
 
//      ot->flag= OPTYPE_UNDO;
 
2881
//      ot->flag = OPTYPE_UNDO;
2876
2882
}
2877
2883
 
2878
2884
void SKETCH_OT_convert(wmOperatorType *ot)
2879
2885
{
2880
2886
        /* identifiers */
2881
 
        ot->name= "convert";
2882
 
        ot->idname= "SKETCH_OT_convert";
 
2887
        ot->name = "Convert";
 
2888
        ot->idname = "SKETCH_OT_convert";
2883
2889
 
2884
2890
        /* api callbacks */
2885
 
        ot->invoke= sketch_convert;
 
2891
        ot->invoke = sketch_convert;
2886
2892
 
2887
 
        ot->poll= ED_operator_sketch_full_mode;
 
2893
        ot->poll = ED_operator_sketch_full_mode;
2888
2894
 
2889
2895
        /* flags */
2890
 
        ot->flag= OPTYPE_UNDO;
 
2896
        ot->flag = OPTYPE_UNDO;
2891
2897
}
2892
2898
 
2893
2899
void SKETCH_OT_finish_stroke(wmOperatorType *ot)
2894
2900
{
2895
2901
        /* identifiers */
2896
 
        ot->name= "end stroke";
2897
 
        ot->idname= "SKETCH_OT_finish_stroke";
 
2902
        ot->name = "End Stroke";
 
2903
        ot->idname = "SKETCH_OT_finish_stroke";
2898
2904
 
2899
2905
        /* api callbacks */
2900
 
        ot->invoke= sketch_finish;
 
2906
        ot->invoke = sketch_finish;
2901
2907
 
2902
 
        ot->poll= ED_operator_sketch_mode_active_stroke;
 
2908
        ot->poll = ED_operator_sketch_mode_active_stroke;
2903
2909
 
2904
2910
        /* flags */
2905
 
//      ot->flag= OPTYPE_UNDO;
 
2911
//      ot->flag = OPTYPE_UNDO;
2906
2912
}
2907
2913
 
2908
2914
void SKETCH_OT_draw_preview(wmOperatorType *ot)
2909
2915
{
2910
2916
        /* identifiers */
2911
 
        ot->name= "draw preview";
2912
 
        ot->idname= "SKETCH_OT_draw_preview";
 
2917
        ot->name = "Draw Preview";
 
2918
        ot->idname = "SKETCH_OT_draw_preview";
2913
2919
 
2914
2920
        /* api callbacks */
2915
 
        ot->invoke= sketch_draw_preview;
 
2921
        ot->invoke = sketch_draw_preview;
2916
2922
 
2917
 
        ot->poll= ED_operator_sketch_mode_active_stroke;
 
2923
        ot->poll = ED_operator_sketch_mode_active_stroke;
2918
2924
 
2919
2925
        RNA_def_boolean(ot->srna, "snap", 0, "Snap", "");
2920
2926
 
2921
2927
        /* flags */
2922
 
//      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
2928
//      ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
2923
2929
}
2924
2930
 
2925
2931
void SKETCH_OT_draw_stroke(wmOperatorType *ot)
2926
2932
{
2927
2933
        /* identifiers */
2928
 
        ot->name= "draw stroke";
2929
 
        ot->idname= "SKETCH_OT_draw_stroke";
 
2934
        ot->name = "Draw Stroke";
 
2935
        ot->idname = "SKETCH_OT_draw_stroke";
2930
2936
 
2931
2937
        /* api callbacks */
2932
2938
        ot->invoke = sketch_draw_stroke;
2933
2939
        ot->modal  = sketch_draw_stroke_modal;
2934
2940
        ot->cancel = sketch_draw_stroke_cancel;
2935
2941
 
2936
 
        ot->poll= (int (*)(bContext *))ED_operator_sketch_mode;
 
2942
        ot->poll = (int (*)(bContext *))ED_operator_sketch_mode;
2937
2943
 
2938
2944
        RNA_def_boolean(ot->srna, "snap", 0, "Snap", "");
2939
2945
 
2940
2946
        /* flags */
2941
 
        ot->flag= OPTYPE_BLOCKING; // OPTYPE_REGISTER|OPTYPE_UNDO
 
2947
        ot->flag = OPTYPE_BLOCKING; // OPTYPE_REGISTER|OPTYPE_UNDO
2942
2948
}
2943
2949
 
2944
2950
void SKETCH_OT_gesture(wmOperatorType *ot)
2945
2951
{
2946
2952
        /* identifiers */
2947
 
        ot->name= "gesture";
2948
 
        ot->idname= "SKETCH_OT_gesture";
 
2953
        ot->name = "Gesture";
 
2954
        ot->idname = "SKETCH_OT_gesture";
2949
2955
 
2950
2956
        /* api callbacks */
2951
2957
        ot->invoke = sketch_draw_gesture;
2952
2958
        ot->modal  = sketch_draw_gesture_modal;
2953
2959
        ot->cancel = sketch_draw_gesture_cancel;
2954
2960
 
2955
 
        ot->poll= ED_operator_sketch_mode_gesture;
 
2961
        ot->poll = ED_operator_sketch_mode_gesture;
2956
2962
 
2957
2963
        RNA_def_boolean(ot->srna, "snap", 0, "Snap", "");
2958
2964
 
2959
2965
        /* flags */
2960
 
        ot->flag= OPTYPE_BLOCKING; // OPTYPE_UNDO
 
2966
        ot->flag = OPTYPE_BLOCKING; // OPTYPE_UNDO
2961
2967
}
2962
2968