diff options
author | Jonathan deWerd <jjoonathan@gmail.com> | 2014-08-22 12:59:21 +0400 |
---|---|---|
committer | Jonathan deWerd <jjoonathan@gmail.com> | 2014-08-22 12:59:21 +0400 |
commit | 942f5b12df3545ea139fff199b3f32f9872764b5 (patch) | |
tree | 678016e8b1280f1ab05dd48359a14826d95047ee | |
parent | 63dd004afdb58b76a5606344500683bdee09d651 (diff) |
Chrome improvements: shortcuts, trim select/drag, Shift-D, per-trim tessellation resolution, etc.soc-2014-nurbs
-rw-r--r-- | release/scripts/startup/bl_ui/properties_data_curve.py | 1 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_image.py | 47 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_curve.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/curve.cpp | 13 | ||||
-rw-r--r-- | source/blender/editors/include/ED_uvedit.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_api/spacetypes.c | 1 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 7 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_draw.c | 5 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 91 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_curve_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_curve.c | 85 |
11 files changed, 208 insertions, 47 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py index af22c881c04..ecf9e5cab90 100644 --- a/release/scripts/startup/bl_ui/properties_data_curve.py +++ b/release/scripts/startup/bl_ui/properties_data_curve.py @@ -296,7 +296,6 @@ class DATA_PT_active_spline(CurveButtonsPanelActive, Panel): col.prop(act_spline, "radius_interpolation", text="Radius") layout.prop(act_spline, "use_smooth") - layout.prop(act_spline, "resolution_trim") class DATA_PT_font(CurveButtonsPanelText, Panel): diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 2828d6d3ba6..076b5818ebe 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -143,9 +143,15 @@ class IMAGE_MT_trim(Menu): bl_label = "Trim" def draw(self, context): layout = self.layout + layout.operator("uv.nurbsuv_delete_trim", text="Delete Trim") + layout.menu("IMAGE_MT_add") + +class IMAGE_MT_add(Menu): + bl_label = "Add" + def draw(self, context): + layout = self.layout layout.operator("uv.nurbsuv_add_square", text="Square Trim", icon='MESH_PLANE') layout.operator("uv.nurbsuv_add_circle", text="Circular Trim", icon='SURFACE_NCIRCLE') - layout.operator("uv.nurbsuv_delete_trim", text="Delete Trim") class IMAGE_MT_image(Menu): bl_label = "Image" @@ -585,6 +591,34 @@ class IMAGE_PT_game_properties(Panel): col.separator() col.prop(ima, "mapping", expand=True) +class IMAGE_PT_view_nurbs(Panel): + bl_space_type = 'IMAGE_EDITOR' + bl_region_type = 'UI' + bl_label = 'NURBS:' + + @classmethod + def poll(cls, context): + return context.space_data.show_nurbsuv + + def draw(self, context): + layout = self.layout + split = layout.split() + col = split.column() + cu = context.edit_object.data + active_breakpt = cu.active_breakpt + active_trim = cu.active_trim + active_trim_nurb = cu.active_trim_nurb + if active_breakpt: + col.label(text="Active Breakpoint:") + col.prop(active_breakpt, "loc", text="Location") + col.prop(active_breakpt, "multiplicity", text="Multiplicity") + if active_trim: + col.label(text="Active Trim:") + sub = col.column() + sub.row().prop(active_trim, "type", expand=True) + if active_trim_nurb: + col.label(text="Active Trim Geometry:") + col.prop(active_trim_nurb, "resolution_u", text="Resolution:") class IMAGE_PT_view_properties(Panel): bl_space_type = 'IMAGE_EDITOR' @@ -627,17 +661,6 @@ class IMAGE_PT_view_properties(Panel): col.label("Cursor Location:") col.row().prop(sima, "cursor_location", text="") - if show_nurbsuv: - col.separator() - if context.edit_object.data.active_breakpt: - col.label(text="Active Breakpoint:") - col.prop(context.edit_object.data.active_breakpt, "loc", text="Location") - col.prop(context.edit_object.data.active_breakpt, "multiplicity", text="Multiplicity") - if context.edit_object.data.active_trim: - col.label(text="Active Trim:") - sub = col.column() - sub.row().prop(context.edit_object.data.active_trim, "type", expand=True) - if show_uvedit: col.separator() diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 78ef2345615..9a042c5356a 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -175,7 +175,7 @@ void BKE_nurbList_flag_set(ListBase *editnurb, short flag); void BKE_nurbTrim_free(struct NurbTrim *nt); struct NurbTrim *BKE_nurbTrim_duplicate(struct NurbTrim *nt); -int BKE_nurbTrim_tess(struct NurbTrim *nt, int resolution, float (**uv)[2]); // Returns: # verts in uv +int BKE_nurbTrim_tess(struct NurbTrim *nt, float (**uv)[2]); // Returns: # verts in uv void BKE_nurbTrim_update_data(struct NurbTrim *nt); void BKE_nurb_free(struct Nurb *nu); diff --git a/source/blender/blenkernel/intern/curve.cpp b/source/blender/blenkernel/intern/curve.cpp index 699a5943495..3179bc70e20 100644 --- a/source/blender/blenkernel/intern/curve.cpp +++ b/source/blender/blenkernel/intern/curve.cpp @@ -789,18 +789,18 @@ NurbTrim *BKE_nurbTrim_duplicate(NurbTrim *nt) { return ret; } -int BKE_nurbTrim_tess(struct NurbTrim *nt, int resolution, float (**uv_out)[2]) { +int BKE_nurbTrim_tess(struct NurbTrim *nt, float (**uv_out)[2]) { int tot_tess_pts = 0; for (Nurb* nu = (Nurb*)nt->nurb_list.first; nu; nu=nu->next) { - int tess_pts = nu->pntsu * resolution + 1; - if (nu->flagu&CU_NURB_ENDPOINT) tess_pts = (nu->pntsu+2-nu->orderu)*resolution; + int tess_pts = nu->pntsu * nu->resolu + 1; + if (nu->flagu&CU_NURB_ENDPOINT) tess_pts = (nu->pntsu+2-nu->orderu)*nu->resolu; tot_tess_pts += tess_pts; } float (*uv)[2] = (float(*)[2])MEM_mallocN(sizeof(*uv)*tot_tess_pts, "BKE_nurbTrim_tess"); *uv_out = uv; for (Nurb* nu = (Nurb*)nt->nurb_list.first; nu; nu=nu->next) { - int tess_pts = nu->pntsu * resolution + 1; - if (nu->flagu&CU_NURB_ENDPOINT) tess_pts = (nu->pntsu+2-nu->orderu)*resolution; + int tess_pts = nu->pntsu * nu->resolu + 1; + if (nu->flagu&CU_NURB_ENDPOINT) tess_pts = (nu->pntsu+2-nu->orderu)*nu->resolu; float *U = nu->knotsu; int pntsu = nu->pntsu; BPoint *bp = nu->bp; @@ -4248,11 +4248,10 @@ GridMesh *BKE_nurb_compute_trimmed_GridMesh(struct Nurb* nu) { gm->init_grid(totu,totv); // Trim - if (nu->resol_trim<1) nu->resol_trim = 1; // gm->begin_recording(); for (NurbTrim *nt=(NurbTrim*)nu->trims.first; nt; nt=nt->next) { float (*trim_uv_pts)[2]; - int num_trimpts = BKE_nurbTrim_tess(nt, nu->resol_trim, &trim_uv_pts); + int num_trimpts = BKE_nurbTrim_tess(nt, &trim_uv_pts); int trim_poly = gm->poly_new((float*)trim_uv_pts, num_trimpts*2); switch (nt->type) { case CU_TRIM_AND: diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index 6e2adaca004..e11b8883a70 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -49,6 +49,7 @@ struct wmKeyConfig; /* uvedit_ops.c */ void ED_operatortypes_uvedit(void); void ED_keymap_uvedit(struct wmKeyConfig *keyconf); +void ED_operatormacros_uvedit(void); void ED_uvedit_assign_image(struct Main *bmain, struct Scene *scene, struct Object *obedit, struct Image *ima, struct Image *previma); bool ED_uvedit_minmax(struct Scene *scene, struct Image *ima, struct Object *obedit, float min[2], float max[2]); diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 83040a26480..6ae2d2fbdc2 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -143,6 +143,7 @@ void ED_spacetypes_init(void) ED_operatormacros_curve(); ED_operatormacros_mask(); ED_operatormacros_sequencer(); + ED_operatormacros_uvedit(); /* register dropboxes (can use macros) */ spacetypes = BKE_spacetypes_list(); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index aecaa6528fc..73c0aedbf8c 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2591,6 +2591,7 @@ static void createTransUVsNURBS(bContext *C, TransInfo *t) BPoint *pt; int count=0,num_bp,i; float aspx, aspy; + bool trim_selected; /* First see how many trim control points + knots we will be dragging (count) */ for (nu=cu->editnurb->nurbs.first; nu; nu=nu->next) { @@ -2600,10 +2601,11 @@ static void createTransUVsNURBS(bContext *C, TransInfo *t) for (i=0; i<ek->num_breaksv; i++) if (ek->breaksv[i].flag&SELECT) count++; for (nt=nu->trims.first; nt; nt=nt->next) { + trim_selected = nt->flag & SELECT; for (trimnu=nt->nurb_list.first; trimnu; trimnu=trimnu->next) { num_bp = trimnu->pntsu * trimnu->pntsv; for (i=0; i<num_bp; i++) - if (trimnu->bp[i].f1 & SELECT) count++; + if (trimnu->bp[i].f1&SELECT || trim_selected) count++; } } } @@ -2652,11 +2654,12 @@ static void createTransUVsNURBS(bContext *C, TransInfo *t) count += 1; } for (nt=nu->trims.first; nt; nt=nt->next) { + trim_selected = nt->flag & SELECT; for (trimnu=nt->nurb_list.first; trimnu; trimnu=trimnu->next) { num_bp = trimnu->pntsu * trimnu->pntsv; for (i=0; i<num_bp; i++) { pt = &trimnu->bp[i]; - if (pt->f1 & SELECT) { + if (pt->f1&SELECT || trim_selected) { td = &t->data[count]; td2d = &t->data2d[count]; td2d->loc[0] = pt->vec[0]; diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index b9a453eb020..e047f4f5460 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -1096,7 +1096,6 @@ static void draw_nurbuv(const struct bContext *C, ARegion *ar, Object *obedit) glShadeModel(GL_SMOOTH); for (nu=cu->editnurb->nurbs.first; nu; nu=nu->next) { if (!(nu->flag2&CU_SELECTED2)) continue; - resoltrim = nu->resol_trim; for (nt=nu->trims.first; nt; nt=nt->next) { glBegin(GL_LINE_STRIP); UI_ThemeColor(TH_WIRE); @@ -1118,7 +1117,6 @@ static void draw_nurbuv(const struct bContext *C, ARegion *ar, Object *obedit) /******* (Normalized Coordinates) draw trim curves *********/ for (nu=cu->editnurb->nurbs.first; nu; nu=nu->next) { if (!(nu->flag2&CU_SELECTED2)) continue; - resoltrim = nu->resol_trim; for (nt=nu->trims.first; nt; nt=nt->next) { glBegin(GL_LINE_STRIP); UI_ThemeColor(TH_WIRE); @@ -1133,7 +1131,7 @@ static void draw_nurbuv(const struct bContext *C, ARegion *ar, Object *obedit) UI_ThemeColor((nt->flag&SELECT)? TH_NURB_SEL_TRIM_ADD : TH_NURB_TRIM_ADD); break; } - j = BKE_nurbTrim_tess(nt, resoltrim, &trim_uv_pnts); + j = BKE_nurbTrim_tess(nt, &trim_uv_pnts); for (i=0; i<j; i++) { glVertex2f(trim_uv_pnts[i][0], trim_uv_pnts[i][1]); } @@ -1148,7 +1146,6 @@ static void draw_nurbuv(const struct bContext *C, ARegion *ar, Object *obedit) glBegin(GL_POINTS); for (nu=cu->editnurb->nurbs.first; nu; nu=nu->next) { if (!(nu->flag2&CU_SELECTED2)) continue; - resoltrim = nu->resol_trim; for (nt=nu->trims.first; nt; nt=nt->next) { /* if (!(nt->flag & SELECT)) continue; */ for (trimnu=nt->nurb_list.first; trimnu; trimnu=trimnu->next) { diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 0ee2c6fe3bc..1f06cb0a229 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -2518,7 +2518,7 @@ static int nurbsuv_mouse_select(bContext *C, const float co[2], bool extend) { } /* Figure out nearest trim to click co */ for (nt=nu->trims.first; nt; nt=nt->next) { - num_trim_verts = BKE_nurbTrim_tess(nt, nu->resol_trim, &trim_verts); + num_trim_verts = BKE_nurbTrim_tess(nt, &trim_verts); for (i=0; i<num_trim_verts-1; i++) { dist = dist2_pt_lineseg(co, trim_verts[i][0], trim_verts[i][1], trim_verts[i+1][0], trim_verts[i+1][1]); if (dist<trim) { @@ -2610,6 +2610,60 @@ static void UV_OT_select(wmOperatorType *ot) "Location", "Mouse location in normalized coordinates, 0.0 to 1.0 is within the image bounds", -100.0f, 100.0f); } +static int nurbs_trim_duplicate(bContext *C, wmOperator *UNUSED(op)) +{ + Object *obedit = CTX_data_edit_object(C); + Curve *cu = (Curve*)obedit->data; + Nurb *nu, *trimnu; + NurbTrim *nt, *dup_nt, *first_dup_nt; + int i,num_bp; + + BLI_assert(obedit->type == OB_SURF); + for (nu=(Nurb*)cu->editnurb->nurbs.first; nu; nu=nu->next) { + first_dup_nt = NULL; + for (nt=(NurbTrim*)nu->trims.first; nt && nt!=first_dup_nt; nt=nt->next) { + /* First, propagate vertex selections to trim curve selections */ + for (trimnu=(Nurb*)nt->nurb_list.first; trimnu; trimnu=trimnu->next) { + num_bp = trimnu->pntsu * trimnu->pntsv; + for (i=0; i<num_bp; i++) { + if (trimnu->bp[i].f1&SELECT) { + nt->flag |= SELECT; + break; + } + } + if (nt->flag&SELECT) break; + } + /* If this trim curve is selected, duplicate it */ + if (nt->flag&SELECT) { + dup_nt = BKE_nurbTrim_duplicate(nt); + if (!first_dup_nt) first_dup_nt = dup_nt; + BLI_addtail(&nu->trims, dup_nt); + dup_nt->flag |= SELECT; + } + /* Clear the selection on the original, leaving dup to be dragged alone */ + nt->flag &= ~SELECT; + for (trimnu=(Nurb*)nt->nurb_list.first; trimnu; trimnu=trimnu->next) { + num_bp = trimnu->pntsu * trimnu->pntsv; + for (i=0; i<num_bp; i++) trimnu->bp[i].f1 &= ~SELECT; + } + } + } + return OPERATOR_FINISHED; +} + +static void UV_OT_nurbs_trim_duplicate(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Duplicate Trims"; + ot->description = "Duplicate selected NURBS trim curves"; + ot->idname = "UV_OT_nurbs_trim_duplicate"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* api callbacks */ + ot->exec = nurbs_trim_duplicate; + ot->poll = ED_operator_nurbsuv; /* requires space image */; +} + /* ******************** loop select operator **************** */ static int uv_select_loop_exec(bContext *C, wmOperator *op) @@ -4121,6 +4175,10 @@ static int nurbsuv_add_square(bContext *C, wmOperator *UNUSED(op)) BLI_addtail(&nu->trims, new_nt); BKE_nurbs_cached_UV_mesh_clear(nu, true); WM_event_add_notifier(C, NC_GEOM | ND_DATA, cu); + DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); + + nurbsuv_set_selected_all(C, false); + new_nt->flag |= SELECT; return OPERATOR_FINISHED; } @@ -4180,6 +4238,10 @@ static int nurbsuv_add_circle(bContext *C, wmOperator *UNUSED(op)) BLI_addtail(&nu->trims, new_nt); BKE_nurbs_cached_UV_mesh_clear(nu, true); WM_event_add_notifier(C, NC_GEOM | ND_DATA, cu); + DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); + + nurbsuv_set_selected_all(C, false); + new_nt->flag |= SELECT; return OPERATOR_FINISHED; } @@ -4848,9 +4910,6 @@ void ED_operatortypes_uvedit(void) WM_operatortype_append(UV_OT_select_linked_pick); WM_operatortype_append(UV_OT_select_split); WM_operatortype_append(UV_OT_select_pinned); - WM_operatortype_append(UV_OT_nurbsuv_add_square); - WM_operatortype_append(UV_OT_nurbsuv_add_circle); - WM_operatortype_append(UV_OT_nurbsuv_delete_trim); WM_operatortype_append(UV_OT_select_border); WM_operatortype_append(UV_OT_select_lasso); WM_operatortype_append(UV_OT_circle_select); @@ -4885,6 +4944,24 @@ void ED_operatortypes_uvedit(void) WM_operatortype_append(UV_OT_cursor_set); WM_operatortype_append(UV_OT_tile_set); + + WM_operatortype_append(UV_OT_nurbsuv_add_square); + WM_operatortype_append(UV_OT_nurbsuv_add_circle); + WM_operatortype_append(UV_OT_nurbsuv_delete_trim); + WM_operatortype_append(UV_OT_nurbs_trim_duplicate); +} + +void ED_operatormacros_uvedit(void) { + wmOperatorType *ot; + wmOperatorTypeMacro *otmacro; + + ot = WM_operatortype_append_macro("UV_OT_nurbs_trim_duplicate_move", "Duplicate Trims", + "Duplicate selected trims and move them", OPTYPE_UNDO | OPTYPE_REGISTER); + if (ot) { + WM_operatortype_macro_define(ot, "UV_OT_nurbs_trim_duplicate"); + otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); + RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF); + } } void ED_keymap_uvedit(wmKeyConfig *keyconf) @@ -4971,9 +5048,9 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "IMAGE_MT_uvs_select_mode", TABKEY, KM_PRESS, KM_CTRL, 0); /* NURBS UV Editor */ - WM_keymap_add_menu(keymap, "UV_OT_nurbsuv_add_square", AKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_menu(keymap, "UV_OT_nurbsuv_add_circle", AKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_menu(keymap, "UV_OT_nurbsuv_delete_trim", XKEY, KM_PRESS, 0, 0); + WM_keymap_add_menu(keymap, "IMAGE_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "UV_OT_nurbsuv_delete_trim", XKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "UV_OT_nurbs_trim_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); ED_keymap_proportional_cycle(keyconf, keymap); ED_keymap_proportional_editmode(keyconf, keymap, false); diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index 136f0d42c5b..28beee4a16f 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -181,7 +181,7 @@ typedef struct Nurb { int pntsu, pntsv; /* number of points in the U or V directions */ short flag2; /* CU_SELECTED2, CU_...2 */ - short resol_trim; /* tessellation res of trim curve (per pt) */ + short resol_trim; /* deprecated: tessellation res of trim curve (per pt) */ short resolu, resolv; /* tessellation resolution in the U or V directions */ short orderu, orderv; short flagu, flagv; diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 1fffc9758e3..c6d83c93df5 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -823,6 +823,62 @@ static PointerRNA rna_nurbs_active_trim_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, NULL, NULL); } +static PointerRNA rna_nurbs_active_trim_nurb_get(PointerRNA *ptr) +{ + Nurb *nu = (Nurb *)ptr->data, *trimnu; + NurbTrim *nt; + int num_bp,i; + + for (nt=nu->trims.first; nt; nt=nt->next) { + if (nt->flag&SELECT) { + /* This is the active trim! Now search for first selected point to + * see what the active trim nurb is. + */ + for (trimnu=(Nurb*)nt->nurb_list.first; trimnu; trimnu=trimnu->next) { + num_bp = trimnu->pntsu * trimnu->pntsv; + for (i=0; i<num_bp; i++) { + if (trimnu->bp[i].f1&SELECT) { + return rna_pointer_inherit_refine(ptr, &RNA_Spline, trimnu); + } + } + } + /* Otherwise, default to the first trim nurb. */ + return rna_pointer_inherit_refine(ptr, &RNA_Spline, nt->nurb_list.first); + } + } + + return rna_pointer_inherit_refine(ptr, NULL, NULL); +} + +static PointerRNA rna_curve_active_trim_nurb_get(PointerRNA *ptr) +{ + Curve *cu = (Curve*)ptr->data; + Nurb *nu, *trimnu; + NurbTrim *nt; + int num_bp,i; + for (nu=(Nurb*)cu->editnurb->nurbs.first; nu; nu=nu->next) { + for (nt=nu->trims.first; nt; nt=nt->next) { + if (nt->flag&SELECT) { + /* This is the active trim! Now search for first selected point to + * see what the active trim nurb is. + */ + for (trimnu=(Nurb*)nt->nurb_list.first; trimnu; trimnu=trimnu->next) { + num_bp = trimnu->pntsu * trimnu->pntsv; + for (i=0; i<num_bp; i++) { + if (trimnu->bp[i].f1&SELECT) { + return rna_pointer_inherit_refine(ptr, &RNA_Spline, trimnu); + } + } + } + /* Otherwise, default to the first trim nurb. */ + return rna_pointer_inherit_refine(ptr, &RNA_Spline, nt->nurb_list.first); + } + } + } + + return rna_pointer_inherit_refine(ptr, NULL, NULL); +} + static PointerRNA rna_curve_active_breakpt_get(PointerRNA *ptr) { Curve *cu = (Curve *)ptr->data; @@ -1719,6 +1775,12 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Active Trim", "Trim to be edited in the property editor"); + prop = RNA_def_property(srna, "active_trim_nurb", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Spline"); + RNA_def_property_pointer_funcs(prop, "rna_curve_active_trim_nurb_get", NULL, NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Active Trim Nurb", "The first active 2D NURBS curve of the active trim. A trim NURBS curve is active if its parent trim is selected or if any of its control points are selected"); + RNA_api_curve(srna); } @@ -1752,7 +1814,7 @@ static void rna_def_curve_nurb_trim(BlenderRNA *brna) prop = RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); RNA_def_property_ui_text(prop, "Selected", "Has this trim been selected?"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); + RNA_def_property_update(prop, NC_GEOM | ND_DATA, NULL); } static void rna_def_curve_nurb_breakpt(BlenderRNA *brna) @@ -1767,18 +1829,18 @@ static void rna_def_curve_nurb_breakpt(BlenderRNA *brna) prop = RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); RNA_def_property_ui_text(prop, "Selected", "Has this breakpoint been selected?"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); + RNA_def_property_update(prop, NC_GEOM | ND_DATA, NULL); prop = RNA_def_property(srna, "multiplicity", PROP_INT, PROP_UNSIGNED); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/ RNA_def_property_int_sdna(prop, NULL, "multiplicity"); RNA_def_property_ui_text(prop, "Multiplicity", "Number of times the knot %loc% is repeated in the knot array."); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); + RNA_def_property_update(prop, NC_GEOM | ND_DATA, NULL); prop = RNA_def_property(srna, "loc", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "loc"); RNA_def_property_ui_text(prop, "KnotLocation", "The floating-point value of this knot in the knot array."); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); + RNA_def_property_update(prop, NC_GEOM | ND_DATA, NULL); } static void rna_def_curve_nurb_editknot(BlenderRNA *brna) { @@ -1900,14 +1962,7 @@ static void rna_def_curve_nurb(BlenderRNA *brna) RNA_def_property_ui_range(prop, 1, 64, 1, -1); RNA_def_property_ui_text(prop, "Resolution V", "Surface subdivisions per segment"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - - prop = RNA_def_property(srna, "resolution_trim", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "resol_trim"); - RNA_def_property_range(prop, 1, 1024); - RNA_def_property_ui_range(prop, 1, 64, 1, -1); - RNA_def_property_ui_text(prop, "Trim Resolution", "Subdivisions per segment of trim curves"); - RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - + prop = RNA_def_property(srna, "use_cyclic_u", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_NURB_CYCLIC); RNA_def_property_ui_text(prop, "Cyclic U", "Make this curve or surface a closed loop in the U direction"); @@ -1997,6 +2052,12 @@ static void rna_def_curve_nurb(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Active Trim", "Trim to be edited in the property editor"); + prop = RNA_def_property(srna, "active_trim_nurb", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Spline"); + RNA_def_property_pointer_funcs(prop, "rna_nurbs_active_trim_nurb_get", NULL, NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Active Trim Nurb", "The first active 2D NURBS curve of the active trim. A trim NURBS curve is active if its parent trim is selected or if any of its control points are selected"); + prop = RNA_def_property(srna, "trims", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_funcs(prop, "rna_NurbTrim_list_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", NULL, NULL, NULL, NULL); RNA_def_property_struct_type(prop, "NurbTrim"); |