Fix for curve having invalid active vertex after setting type

also allow passing NULL vertex to BKE_curve_nurb_vert_active_set
This commit is contained in:
2014-05-26 09:11:42 +10:00
parent f574b1ca3c
commit eaf815f14a
3 changed files with 36 additions and 9 deletions

View File

@@ -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 {