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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-05-26 03:11:42 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-05-26 03:35:32 +0400
commiteaf815f14a928f7d99db93013c9ad8daae539094 (patch)
tree39dbe47367aa37c83ef0f9455e4ea8f707e1acca /source
parentf574b1ca3cda82b2cffa992bd4288c44e99cc643 (diff)
Fix for curve having invalid active vertex after setting type
also allow passing NULL vertex to BKE_curve_nurb_vert_active_set
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/curve.c18
-rw-r--r--source/blender/editors/curve/editcurve.c18
-rw-r--r--source/blender/makesrna/intern/rna_curve.c9
3 files changed, 36 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index fa5e3dc24c3..a61a15f4566 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -3830,6 +3830,9 @@ bool BKE_nurb_order_clamp_v(struct Nurb *nu)
return changed;
}
+/**
+ * \note caller must ensure active vertex remains valid.
+ */
bool BKE_nurb_type_convert(Nurb *nu, const short type, const bool use_handles)
{
BezTriple *bezt;
@@ -4011,13 +4014,18 @@ void BKE_curve_nurb_vert_active_set(Curve *cu, Nurb *nu, void *vert)
if (nu) {
BKE_curve_nurb_active_set(cu, nu);
- if (nu->type == CU_BEZIER) {
- BLI_assert(ARRAY_HAS_ITEM((BezTriple *)vert, nu->bezt, nu->pntsu));
- cu->actvert = (BezTriple *)vert - nu->bezt;
+ if (vert) {
+ if (nu->type == CU_BEZIER) {
+ BLI_assert(ARRAY_HAS_ITEM((BezTriple *)vert, nu->bezt, nu->pntsu));
+ cu->actvert = (BezTriple *)vert - nu->bezt;
+ }
+ else {
+ BLI_assert(ARRAY_HAS_ITEM((BPoint *)vert, nu->bp, nu->pntsu * nu->pntsv));
+ cu->actvert = (BPoint *)vert - nu->bp;
+ }
}
else {
- BLI_assert(ARRAY_HAS_ITEM((BPoint *)vert, nu->bp, nu->pntsu * nu->pntsv));
- cu->actvert = (BPoint *)vert - nu->bp;
+ cu->actvert = CU_ACT_NONE;
}
}
else {
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 2fdc9ff846b..f5cfc289ab9 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -3916,6 +3916,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op)
ListBase *editnurb = object_editcurve_get(obedit);
Nurb *nu;
bool changed = false;
+ bool changed_size = false;
const bool use_handles = RNA_boolean_get(op->ptr, "use_handles");
const int type = RNA_enum_get(op->ptr, "type");
@@ -3926,10 +3927,16 @@ static int set_spline_type_exec(bContext *C, wmOperator *op)
for (nu = editnurb->first; nu; nu = nu->next) {
if (isNurbsel(nu)) {
- if (BKE_nurb_type_convert(nu, type, use_handles) == false)
- BKE_report(op->reports, RPT_ERROR, "No conversion possible");
- else
+ const int pntsu_prev = nu->pntsu;
+ if (BKE_nurb_type_convert(nu, type, use_handles)) {
changed = true;
+ if (pntsu_prev != nu->pntsu) {
+ changed_size = true;
+ }
+ }
+ else {
+ BKE_report(op->reports, RPT_ERROR, "No conversion possible");
+ }
}
}
@@ -3940,6 +3947,11 @@ static int set_spline_type_exec(bContext *C, wmOperator *op)
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+ if (changed_size) {
+ Curve *cu = obedit->data;
+ cu->actvert = CU_ACT_NONE;
+ }
+
return OPERATOR_FINISHED;
}
else {
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index 79c19c4c246..29f1dd5f29f 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -323,8 +323,15 @@ static int rna_Nurb_length(PointerRNA *ptr)
static void rna_Nurb_type_set(PointerRNA *ptr, int value)
{
+ Curve *cu = (Curve *)ptr->id.data;
Nurb *nu = (Nurb *)ptr->data;
- BKE_nurb_type_convert(nu, value, true);
+ const int pntsu_prev = nu->pntsu;
+
+ if (BKE_nurb_type_convert(nu, value, true)) {
+ if (nu->pntsu != pntsu_prev) {
+ cu->actvert = CU_ACT_NONE;
+ }
+ }
}
static void rna_BPoint_array_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)