static bool curve_select_similar_weight(ListBase *editnurb, Curve *cu, float compare, float thresh)
{
	Nurb *nu, *act_nu;
	void *act_vert;
	float weight_ref;

	if (!BKE_curve_nurb_vert_active_get(cu, &act_nu, &act_vert))
		return false;

	if (act_nu->type == CU_BEZIER) {
		weight_ref = ((BezTriple *)act_vert)->weight;
	}
	else {
		weight_ref = ((BPoint *)act_vert)->weight;
	}

	for (nu = editnurb->first; nu; nu = nu->next) {
		if (nu->type == CU_BEZIER) {
			curve_select_similar_weight__bezt(nu, weight_ref, compare, thresh);
		}
		else {
			curve_select_similar_weight__bp(nu, weight_ref, compare, thresh);
		}
	}

	return true;
}
static bool curve_select_similar_radius(ListBase *editnurb, Curve *cu, float compare, float thresh)
{
	Nurb *nu, *act_nu;
	void *act_vert;
	float radius_ref;

	if (!BKE_curve_nurb_vert_active_get(cu, &act_nu, &act_vert)) {
		return false;
	}

	if (act_nu->type == CU_BEZIER) {
		radius_ref = ((BezTriple *)act_vert)->radius;
	}
	else {
		radius_ref = ((BPoint *)act_vert)->radius;
	}

	/* make relative */
	thresh *= radius_ref;

	for (nu = editnurb->first; nu; nu = nu->next) {
		if (nu->type == CU_BEZIER) {
			curve_select_similar_radius__bezt(nu, radius_ref, compare, thresh);
		}
		else {
			curve_select_similar_radius__bp(nu, radius_ref, compare, thresh);
		}
	}

	return true;
}
static bool curve_select_similar_direction(ListBase *editnurb, Curve *cu, float thresh)
{
	Nurb *nu, *act_nu;
	void *act_vert;
	float dir[3];
	float angle_cos;

	if (!BKE_curve_nurb_vert_active_get(cu, &act_nu, &act_vert)) {
		return false;
	}

	if (act_nu->type == CU_BEZIER) {
		BKE_nurb_bezt_calc_normal(act_nu, act_vert, dir);
	}
	else {
		BKE_nurb_bpoint_calc_normal(act_nu, act_vert, dir);
	}

	/* map 0-1 to radians, 'cos' for comparison */
	angle_cos = cosf(thresh * (float)M_PI_2);

	for (nu = editnurb->first; nu; nu = nu->next) {
		if (nu->type == CU_BEZIER) {
			curve_select_similar_direction__bezt(nu, dir, angle_cos);
		}
		else {
			curve_select_similar_direction__bp(nu, dir, angle_cos);
		}
	}

	return true;
}
bool ED_curve_select_nth(Curve *cu, int nth, int skip, int offset)
{
	Nurb *nu = NULL;
	void *vert = NULL;

	if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert))
		return false;

	if (nu->bezt) {
		select_nth_bezt(nu, vert, nth, skip, offset);
	}
	else {
		select_nth_bp(nu, vert, nth, skip, offset);
	}

	return true;
}
Example #5
0
static bool ed_curve_select_nth(Curve *cu, const struct CheckerIntervalParams *params)
{
	Nurb *nu = NULL;
	void *vert = NULL;

	if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert))
		return false;

	if (nu->bezt) {
		select_nth_bezt(nu, vert, params);
	}
	else {
		select_nth_bp(nu, vert, params);
	}

	return true;
}
static int select_row_exec(bContext *C, wmOperator *UNUSED(op))
{
	Object *obedit = CTX_data_edit_object(C);
	Curve *cu = obedit->data;
	ListBase *editnurb = object_editcurve_get(obedit);
	static BPoint *last = NULL;
	static int direction = 0;
	Nurb *nu = NULL;
	BPoint *bp = NULL;
	int u = 0, v = 0, a, b;

	if (!BKE_curve_nurb_vert_active_get(cu, &nu, (void *)&bp))
		return OPERATOR_CANCELLED;

	if (last == bp) {
		direction = 1 - direction;
		BKE_nurbList_flag_set(editnurb, 0);
	}
	last = bp;

	u = cu->actvert % nu->pntsu;
	v = cu->actvert / nu->pntsu;
	bp = nu->bp;
	for (a = 0; a < nu->pntsv; a++) {
		for (b = 0; b < nu->pntsu; b++, bp++) {
			if (direction) {
				if (a == v) select_bpoint(bp, SELECT, SELECT, VISIBLE);
			}
			else {
				if (b == u) select_bpoint(bp, SELECT, SELECT, VISIBLE);
			}
		}
	}

	WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);

	return OPERATOR_FINISHED;
}