Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-09-08 11:35:07 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-09-08 11:35:07 +0400
commit1d0a567023d89b4e397800eeb164512b40336184 (patch)
treef74e408485e26ad12428ab69d7a73621e59583c2 /source/blender/editors/curve
parentfab4bf0816834744664858cdcca96792a6225ca3 (diff)
Curve/Surface Editing
- rename "Nurb" to "Spline" in RNA, eg. bpy.data.curves[0].splines[2].type == 'NURBS' from a user perspective spline is a more generic term while Nurb is misleading when used for beziers and poly lines. - added curve.active_spline property so the python UI can display the last selected curve. - set the active spline when entering editmode (uses first selected spline) - added back Hide Handles as a curve property (removed the global flag), access from the view panel in editmode. - added hide normal option for curve, normal size access for curve and mesh display. - changing orderU/V, endpoints, cyclic, bezierU/V now work in editmode and calls update functions. - entering editmode was crashing with text objects - curve.switch_direction() crashed (own fault from last commit) - Tkey for tilt was overridden by Toolbar, made Tilt Ctrl+T. - OBJECT_OT_mode_set check for compatible modes before running - so curves dont try go into paint mode with V key for eg.
Diffstat (limited to 'source/blender/editors/curve')
-rw-r--r--source/blender/editors/curve/curve_ops.c2
-rw-r--r--source/blender/editors/curve/editcurve.c94
2 files changed, 59 insertions, 37 deletions
diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c
index d3bcdcb69bb..a242e424aa0 100644
--- a/source/blender/editors/curve/curve_ops.c
+++ b/source/blender/editors/curve/curve_ops.c
@@ -233,7 +233,7 @@ void ED_keymap_curve(wmWindowManager *wm)
WM_keymap_add_item(keymap, "CURVE_OT_delete", DELKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "CURVE_OT_tilt_clear", TKEY, KM_PRESS, KM_ALT, 0);
- RNA_enum_set(WM_keymap_add_item(keymap, "TFM_OT_transform", TKEY, KM_PRESS, 0, 0)->ptr, "mode", TFM_TILT);
+ RNA_enum_set(WM_keymap_add_item(keymap, "TFM_OT_transform", TKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", TFM_TILT);
RNA_enum_set(WM_keymap_add_item(keymap, "CURVE_OT_handle_type_set", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", 1);
RNA_enum_set(WM_keymap_add_item(keymap, "CURVE_OT_handle_type_set", HKEY, KM_PRESS, 0, 0)->ptr, "type", 3);
RNA_enum_set(WM_keymap_add_item(keymap, "CURVE_OT_handle_type_set", VKEY, KM_PRESS, 0, 0)->ptr, "type", 2);
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 871f00a585c..e346ccafde3 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -86,9 +86,6 @@
/* still need to eradicate a few :( */
#define callocstructN(x,y,name) (x*)MEM_callocN((y)* sizeof(x),name)
-/* for curve objects in editmode that can have hidden handles */
-#define BEZSELECTED_HIDDENHANDLES(bezt) ((G.f & G_HIDDENHANDLES) ? (bezt)->f2 & SELECT : BEZSELECTED(bezt))
-
float nurbcircle[8][2]= {
{0.0, -1.0}, {-1.0, -1.0}, {-1.0, 0.0}, {-1.0, 1.0},
{0.0, 1.0}, { 1.0, 1.0}, { 1.0, 0.0}, { 1.0, -1.0}
@@ -213,7 +210,7 @@ int isNurbsel(Nurb *nu)
return 0;
}
-int isNurbsel_count(Nurb *nu)
+int isNurbsel_count(Curve *cu, Nurb *nu)
{
BezTriple *bezt;
BPoint *bp;
@@ -223,7 +220,7 @@ int isNurbsel_count(Nurb *nu)
bezt= nu->bezt;
a= nu->pntsu;
while(a--) {
- if (BEZSELECTED_HIDDENHANDLES(bezt)) sel++;
+ if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) sel++;
bezt++;
}
}
@@ -269,6 +266,8 @@ void load_editNurb(Object *obedit)
if(obedit==NULL) return;
+ set_actNurb(obedit, NULL);
+
if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
Curve *cu= obedit->data;
Nurb *nu, *newnu;
@@ -314,11 +313,13 @@ void load_editNurb(Object *obedit)
void make_editNurb(Object *obedit)
{
ListBase *editnurb= curve_get_editcurve(obedit);
- Nurb *nu, *newnu;
+ Nurb *nu, *newnu, *nu_act= NULL;
KeyBlock *actkey;
if(obedit==NULL) return;
+ set_actNurb(obedit, NULL);
+
if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
Curve *cu= obedit->data;
@@ -334,6 +335,12 @@ void make_editNurb(Object *obedit)
newnu= duplicateNurb(nu);
test2DNurb(newnu); // after join, or any other creation of curve
BLI_addtail(editnurb, newnu);
+
+ if (nu_act == NULL && isNurbsel(nu)) {
+ nu_act= newnu;
+ set_actNurb(obedit, newnu);
+ }
+
nu= nu->next;
}
@@ -343,8 +350,6 @@ void make_editNurb(Object *obedit)
key_to_curve(actkey, cu, editnurb);
}
}
-
- set_actNurb(obedit, NULL);
}
void free_editNurb(Object *obedit)
@@ -1609,6 +1614,7 @@ void CURVE_OT_select_all_toggle(wmOperatorType *ot)
static int hide_exec(bContext *C, wmOperator *op)
{
Object *obedit= CTX_data_edit_object(C);
+ Curve *cu= obedit->data;
ListBase *editnurb= curve_get_editcurve(obedit);
Nurb *nu;
BPoint *bp;
@@ -1621,11 +1627,11 @@ static int hide_exec(bContext *C, wmOperator *op)
a= nu->pntsu;
sel= 0;
while(a--) {
- if(invert == 0 && BEZSELECTED_HIDDENHANDLES(bezt)) {
+ if(invert == 0 && BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
select_beztriple(bezt, DESELECT, 1, HIDDEN);
bezt->hide= 1;
}
- else if(invert && !BEZSELECTED_HIDDENHANDLES(bezt)) {
+ else if(invert && !BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
select_beztriple(bezt, DESELECT, 1, HIDDEN);
bezt->hide= 1;
}
@@ -1739,6 +1745,7 @@ void CURVE_OT_reveal(wmOperatorType *ot)
static int select_inverse_exec(bContext *C, wmOperator *op)
{
Object *obedit= CTX_data_edit_object(C);
+ Curve *cu= obedit->data;
ListBase *editnurb= curve_get_editcurve(obedit);
Nurb *nu;
BPoint *bp;
@@ -1752,7 +1759,7 @@ static int select_inverse_exec(bContext *C, wmOperator *op)
while(a--) {
if(bezt->hide==0) {
bezt->f2 ^= SELECT; /* always do the center point */
- if ((G.f & G_HIDDENHANDLES)==0) {
+ if((cu->drawflag & CU_HIDE_HANDLES)==0) {
bezt->f1 ^= SELECT;
bezt->f3 ^= SELECT;
}
@@ -1803,6 +1810,7 @@ void CURVE_OT_select_inverse(wmOperatorType *ot)
static int subdivide_exec(bContext *C, wmOperator *op)
{
Object *obedit= CTX_data_edit_object(C);
+ Curve *cu= obedit->data;
ListBase *editnurb= curve_get_editcurve(obedit);
Nurb *nu;
BezTriple *prevbezt, *bezt, *beztnew, *beztn;
@@ -1832,7 +1840,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
bezt= prevbezt+1;
}
while(a--) {
- if( BEZSELECTED_HIDDENHANDLES(prevbezt) && BEZSELECTED_HIDDENHANDLES(bezt) ) amount++;
+ if( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) amount++;
prevbezt= bezt;
bezt++;
}
@@ -1856,7 +1864,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
memcpy(beztn, prevbezt, sizeof(BezTriple));
beztn++;
- if( BEZSELECTED_HIDDENHANDLES(prevbezt) && BEZSELECTED_HIDDENHANDLES(bezt) ) {
+ if( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
memcpy(beztn, bezt, sizeof(BezTriple));
/* midpoint subdividing */
@@ -2351,14 +2359,14 @@ static int convertspline(short type, Nurb *nu)
}
}
else if(nu->type == CU_BEZIER) { /* Bezier */
- if(type==0 || type==4) { /* to Poly or Nurb */
+ if(type==CU_POLY || type==CU_NURBS) {
nr= 3*nu->pntsu;
nu->bp = MEM_callocN(nr * sizeof(BPoint), "setsplinetype");
a= nu->pntsu;
bezt= nu->bezt;
bp= nu->bp;
while(a--) {
- if(type==0 && bezt->h1==HD_VECT && bezt->h2==HD_VECT) {
+ if(type==CU_POLY && bezt->h1==HD_VECT && bezt->h2==HD_VECT) {
/* vector handle becomes 1 poly vertice */
VECCOPY(bp->vec, bezt->vec[1]);
bp->vec[3]= 1.0;
@@ -2383,15 +2391,15 @@ static int convertspline(short type, Nurb *nu)
bezt++;
}
MEM_freeN(nu->bezt);
- nu->bezt= 0;
+ nu->bezt= NULL;
nu->pntsu= nr;
nu->pntsv= 1;
nu->orderu= 4;
nu->orderv= 1;
- nu->type |= type;
+ nu->type = type;
if(nu->flagu & CU_CYCLIC) c= nu->orderu-1;
else c= 0;
- if(type== 4) {
+ if(type== CU_NURBS) {
nu->flagu &= CU_CYCLIC; /* disable all flags except for cyclic */
nu->flagu += 4;
makeknots(nu, 1);
@@ -2464,7 +2472,15 @@ static int set_spline_type_exec(bContext *C, wmOperator *op)
}
}
- return (changed)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
+ if(changed) {
+ DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
}
void CURVE_OT_spline_type_set(wmOperatorType *ot)
@@ -2472,8 +2488,8 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot)
static EnumPropertyItem type_items[]= {
{CU_POLY, "POLY", 0, "Poly", ""},
{CU_BEZIER, "BEZIER", 0, "Bezier", ""},
- {CU_CARDINAL, "CARDINAL", 0, "Cardinal", ""},
- {CU_BSPLINE, "B_SPLINE", 0, "B-Spline", ""},
+// {CU_CARDINAL, "CARDINAL", 0, "Cardinal", ""},
+// {CU_BSPLINE, "B_SPLINE", 0, "B-Spline", ""},
{CU_NURBS, "NURBS", 0, "NURBS", ""},
{0, NULL, 0, NULL, NULL}};
@@ -2483,6 +2499,7 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot)
/* api callbacks */
ot->exec= set_spline_type_exec;
+ ot->invoke= WM_menu_invoke;
ot->poll= ED_operator_editcurve;
/* flags */
@@ -2866,6 +2883,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
{
/* joins 2 curves */
Object *obedit= CTX_data_edit_object(C);
+ Curve *cu= obedit->data;
ListBase *editnurb= curve_get_editcurve(obedit);
Nurb *nu, *nu1=0, *nu2=0;
BezTriple *bezt;
@@ -2881,8 +2899,8 @@ static int make_segment_exec(bContext *C, wmOperator *op)
if( isNurbsel(nu) ) {
if(nu->pntsu>1 && nu->pntsv>1) break;
- if(isNurbsel_count(nu)>1) break;
- if(isNurbsel_count(nu)==1) {
+ if(isNurbsel_count(cu, nu)>1) break;
+ if(isNurbsel_count(cu, nu)==1) {
/* only 1 selected, not first or last, a little complex, but intuitive */
if(nu->pntsv==1) {
if( (nu->bp->f1 & SELECT) || ((nu->bp+nu->pntsu-1)->f1 & SELECT));
@@ -2902,23 +2920,23 @@ static int make_segment_exec(bContext *C, wmOperator *op)
if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
if(nu1==0) {
- if( BEZSELECTED_HIDDENHANDLES(bezt) ) nu1= nu;
+ if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) nu1= nu;
else {
bezt= bezt+(nu->pntsu-1);
- if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
+ if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
nu1= nu;
switchdirectionNurb(nu);
}
}
}
else if(nu2==0) {
- if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
+ if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
nu2= nu;
switchdirectionNurb(nu);
}
else {
bezt= bezt+(nu->pntsu-1);
- if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
+ if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
nu2= nu;
}
}
@@ -3039,8 +3057,8 @@ void CURVE_OT_make_segment(wmOperatorType *ot)
void mouse_nurb(bContext *C, short mval[2], int extend)
{
Object *obedit= CTX_data_edit_object(C);
- ListBase *editnurb= curve_get_editcurve(obedit);
Curve *cu= obedit->data;
+ ListBase *editnurb= curve_get_editcurve(obedit);
ViewContext vc;
Nurb *nu;
BezTriple *bezt=0;
@@ -3417,12 +3435,13 @@ void CURVE_OT_vertex_add(wmOperatorType *ot)
static int extrude_exec(bContext *C, wmOperator *op)
{
Object *obedit= CTX_data_edit_object(C);
+ Curve *cu= obedit->data;
ListBase *editnurb= curve_get_editcurve(obedit);
Nurb *nu;
/* first test: curve? */
for(nu= editnurb->first; nu; nu= nu->next)
- if(nu->pntsv==1 && isNurbsel_count(nu)==1)
+ if(nu->pntsv==1 && isNurbsel_count(cu, nu)==1)
break;
if(obedit->type==OB_CURVE || nu) {
@@ -3473,6 +3492,7 @@ void CURVE_OT_extrude(wmOperatorType *ot)
static int toggle_cyclic_exec(bContext *C, wmOperator *op)
{
Object *obedit= CTX_data_edit_object(C);
+ Curve *cu= obedit->data;
ListBase *editnurb= curve_get_editcurve(obedit);
Nurb *nu;
BezTriple *bezt;
@@ -3496,7 +3516,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
a= nu->pntsu;
bezt= nu->bezt;
while(a--) {
- if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
+ if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
nu->flagu ^= CU_CYCLIC;
break;
}
@@ -3674,8 +3694,8 @@ void CURVE_OT_select_linked(wmOperatorType *ot)
static int select_row_exec(bContext *C, wmOperator *op)
{
Object *obedit= CTX_data_edit_object(C);
- ListBase *editnurb= curve_get_editcurve(obedit);
Curve *cu= obedit->data;
+ ListBase *editnurb= curve_get_editcurve(obedit);
static BPoint *last=0;
static int direction=0;
Nurb *nu;
@@ -4224,6 +4244,7 @@ void CURVE_OT_duplicate(wmOperatorType *ot)
static int delete_exec(bContext *C, wmOperator *op)
{
Object *obedit= CTX_data_edit_object(C);
+ Curve *cu= obedit->data;
ListBase *editnurb= curve_get_editcurve(obedit);
Nurb *nu, *next, *nu1;
BezTriple *bezt, *bezt1, *bezt2;
@@ -4250,7 +4271,7 @@ static int delete_exec(bContext *C, wmOperator *op)
a= nu->pntsu;
if(a) {
while(a) {
- if( BEZSELECTED_HIDDENHANDLES(bezt) );
+ if( BEZSELECTED_HIDDENHANDLES(cu, bezt) );
else break;
a--;
bezt++;
@@ -4295,7 +4316,7 @@ static int delete_exec(bContext *C, wmOperator *op)
if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
for(a=0;a<nu->pntsu;a++) {
- if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
+ if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
memmove(bezt, bezt+1, (nu->pntsu-a-1)*sizeof(BezTriple));
nu->pntsu--;
a--;
@@ -4355,7 +4376,7 @@ static int delete_exec(bContext *C, wmOperator *op)
if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
for(a=0; a<nu->pntsu-1; a++) {
- if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
+ if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
bezt1= bezt;
bezt2= bezt+1;
if( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) ;
@@ -4706,7 +4727,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname)
cent[2]-= obedit->obmat[3][2];
if(rv3d) {
- if (!(newname) || U.flag & USER_ADD_VIEWALIGNED || !rv3d)
+ if (!(newname) || U.flag & USER_ADD_VIEWALIGNED)
Mat3CpyMat4(imat, rv3d->viewmat);
else
Mat3One(imat);
@@ -5087,6 +5108,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname)
static int clear_tilt_exec(bContext *C, wmOperator *op)
{
Object *obedit= CTX_data_edit_object(C);
+ Curve *cu= obedit->data;
ListBase *editnurb= curve_get_editcurve(obedit);
Nurb *nu;
BezTriple *bezt;
@@ -5098,7 +5120,7 @@ static int clear_tilt_exec(bContext *C, wmOperator *op)
bezt= nu->bezt;
a= nu->pntsu;
while(a--) {
- if(BEZSELECTED_HIDDENHANDLES(bezt)) bezt->alfa= 0.0;
+ if(BEZSELECTED_HIDDENHANDLES(cu, bezt)) bezt->alfa= 0.0;
bezt++;
}
}