Fix #29253: 3D Manipulator: "Active Element" not supported for curves
This funcitonality simply wasn't implemented for curves yet, implemented it now.
This commit is contained in:
@@ -5468,6 +5468,24 @@ static int point_on_nurb(Nurb *nu, void *point)
|
||||
}
|
||||
}
|
||||
|
||||
static Nurb *get_lastsel_nurb(Curve *cu)
|
||||
{
|
||||
ListBase *nubase= curve_editnurbs(cu);
|
||||
Nurb *nu= nubase->first;
|
||||
|
||||
if(!cu->lastsel)
|
||||
return NULL;
|
||||
|
||||
while (nu) {
|
||||
if (point_on_nurb(nu, cu->lastsel))
|
||||
return nu;
|
||||
|
||||
nu= nu->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void select_nth_bezt(Nurb *nu, BezTriple *bezt, int nth)
|
||||
{
|
||||
int a, start;
|
||||
@@ -5517,21 +5535,11 @@ static void select_nth_bp(Nurb *nu, BPoint *bp, int nth)
|
||||
int CU_select_nth(Object *obedit, int nth)
|
||||
{
|
||||
Curve *cu= (Curve*)obedit->data;
|
||||
ListBase *nubase= curve_editnurbs(cu);
|
||||
Nurb *nu;
|
||||
int ok=0;
|
||||
|
||||
/* Search nurb to which selected point belongs to */
|
||||
nu= nubase->first;
|
||||
while (nu) {
|
||||
if (point_on_nurb(nu, cu->lastsel)) {
|
||||
ok= 1;
|
||||
break;
|
||||
}
|
||||
nu= nu->next;
|
||||
}
|
||||
|
||||
if (!ok) return 0;
|
||||
nu= get_lastsel_nurb(cu);
|
||||
if (!nu)
|
||||
return 0;
|
||||
|
||||
if (nu->bezt) {
|
||||
select_nth_bezt(nu, cu->lastsel, nth);
|
||||
@@ -7070,3 +7078,24 @@ void ED_curve_bpcpy(EditNurb *editnurb, BPoint *dst, BPoint *src, int count)
|
||||
memcpy(dst, src, count*sizeof(BPoint));
|
||||
keyIndex_updateBP(editnurb, src, dst, count);
|
||||
}
|
||||
|
||||
int ED_curve_actSelection(Curve *cu, float center[3])
|
||||
{
|
||||
Nurb *nu= get_lastsel_nurb(cu);
|
||||
|
||||
if(!nu)
|
||||
return 0;
|
||||
|
||||
if(nu->bezt) {
|
||||
BezTriple *bezt= cu->lastsel;
|
||||
|
||||
copy_v3_v3(center, bezt->vec[1]);
|
||||
}
|
||||
else {
|
||||
BPoint *bp= cu->lastsel;
|
||||
|
||||
copy_v3_v3(center, bp->vec);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,8 @@ void ED_curve_bpcpy(struct EditNurb *editnurb, struct BPoint *dst, struct BPoint
|
||||
|
||||
int ED_curve_updateAnimPaths(struct Object *obedit);
|
||||
|
||||
int ED_curve_actSelection(struct Curve *cu, float center[3]);
|
||||
|
||||
/* debug only */
|
||||
void printknots(struct Object *obedit);
|
||||
|
||||
|
||||
@@ -1548,14 +1548,26 @@ void calculateCenter(TransInfo *t)
|
||||
|
||||
/* EDIT MODE ACTIVE EDITMODE ELEMENT */
|
||||
|
||||
if (t->obedit && t->obedit->type == OB_MESH) {
|
||||
EditSelection ese;
|
||||
EditMesh *em = BKE_mesh_get_editmesh(t->obedit->data);
|
||||
if (t->obedit) {
|
||||
if(t->obedit->type == OB_MESH) {
|
||||
EditSelection ese;
|
||||
EditMesh *em = BKE_mesh_get_editmesh(t->obedit->data);
|
||||
|
||||
if (EM_get_actSelection(em, &ese)) {
|
||||
EM_editselection_center(t->center, &ese);
|
||||
calculateCenter2D(t);
|
||||
break;
|
||||
if (EM_get_actSelection(em, &ese)) {
|
||||
EM_editselection_center(t->center, &ese);
|
||||
calculateCenter2D(t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ELEM(t->obedit->type, OB_CURVE, OB_SURF)) {
|
||||
float center[3];
|
||||
Curve *cu= (Curve *)t->obedit->data;
|
||||
|
||||
if (ED_curve_actSelection(cu, center)) {
|
||||
copy_v3_v3(t->center, center);
|
||||
calculateCenter2D(t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} /* END EDIT MODE ACTIVE ELEMENT */
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "ED_armature.h"
|
||||
#include "ED_curve.h"
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_particle.h"
|
||||
#include "ED_view3d.h"
|
||||
@@ -390,56 +391,64 @@ int calc_manipulator_stats(const bContext *C)
|
||||
}
|
||||
else if ELEM(obedit->type, OB_CURVE, OB_SURF) {
|
||||
Curve *cu= obedit->data;
|
||||
Nurb *nu;
|
||||
BezTriple *bezt;
|
||||
BPoint *bp;
|
||||
ListBase *nurbs= curve_editnurbs(cu);
|
||||
float center[3];
|
||||
|
||||
nu= nurbs->first;
|
||||
while(nu) {
|
||||
if(nu->type == CU_BEZIER) {
|
||||
bezt= nu->bezt;
|
||||
a= nu->pntsu;
|
||||
while(a--) {
|
||||
/* exceptions
|
||||
* if handles are hidden then only check the center points.
|
||||
* If the center knot is selected then only use this as the center point.
|
||||
*/
|
||||
if (cu->drawflag & CU_HIDE_HANDLES) {
|
||||
if (bezt->f2 & SELECT) {
|
||||
if (v3d->around==V3D_ACTIVE && ED_curve_actSelection(cu, center)) {
|
||||
calc_tw_center(scene, center);
|
||||
totsel++;
|
||||
}
|
||||
else {
|
||||
Nurb *nu;
|
||||
BezTriple *bezt;
|
||||
BPoint *bp;
|
||||
ListBase *nurbs= curve_editnurbs(cu);
|
||||
|
||||
nu= nurbs->first;
|
||||
while(nu) {
|
||||
if(nu->type == CU_BEZIER) {
|
||||
bezt= nu->bezt;
|
||||
a= nu->pntsu;
|
||||
while(a--) {
|
||||
/* exceptions
|
||||
* if handles are hidden then only check the center points.
|
||||
* If the center knot is selected then only use this as the center point.
|
||||
*/
|
||||
if (cu->drawflag & CU_HIDE_HANDLES) {
|
||||
if (bezt->f2 & SELECT) {
|
||||
calc_tw_center(scene, bezt->vec[1]);
|
||||
totsel++;
|
||||
}
|
||||
}
|
||||
else if (bezt->f2 & SELECT) {
|
||||
calc_tw_center(scene, bezt->vec[1]);
|
||||
totsel++;
|
||||
}
|
||||
else {
|
||||
if(bezt->f1) {
|
||||
calc_tw_center(scene, bezt->vec[0]);
|
||||
totsel++;
|
||||
}
|
||||
if(bezt->f3) {
|
||||
calc_tw_center(scene, bezt->vec[2]);
|
||||
totsel++;
|
||||
}
|
||||
}
|
||||
bezt++;
|
||||
}
|
||||
else if (bezt->f2 & SELECT) {
|
||||
calc_tw_center(scene, bezt->vec[1]);
|
||||
totsel++;
|
||||
}
|
||||
else {
|
||||
if(bezt->f1) {
|
||||
calc_tw_center(scene, bezt->vec[0]);
|
||||
totsel++;
|
||||
}
|
||||
if(bezt->f3) {
|
||||
calc_tw_center(scene, bezt->vec[2]);
|
||||
}
|
||||
else {
|
||||
bp= nu->bp;
|
||||
a= nu->pntsu*nu->pntsv;
|
||||
while(a--) {
|
||||
if(bp->f1 & SELECT) {
|
||||
calc_tw_center(scene, bp->vec);
|
||||
totsel++;
|
||||
}
|
||||
bp++;
|
||||
}
|
||||
bezt++;
|
||||
}
|
||||
nu= nu->next;
|
||||
}
|
||||
else {
|
||||
bp= nu->bp;
|
||||
a= nu->pntsu*nu->pntsv;
|
||||
while(a--) {
|
||||
if(bp->f1 & SELECT) {
|
||||
calc_tw_center(scene, bp->vec);
|
||||
totsel++;
|
||||
}
|
||||
bp++;
|
||||
}
|
||||
}
|
||||
nu= nu->next;
|
||||
}
|
||||
}
|
||||
else if(obedit->type==OB_MBALL) {
|
||||
|
||||
Reference in New Issue
Block a user