Пример #1
0
static int lattice_select_mirror_exec(bContext *C, wmOperator *op)
{
	Object *obedit = CTX_data_edit_object(C);
	Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
	const bool extend = RNA_boolean_get(op->ptr, "extend");
	const int axis = RNA_enum_get(op->ptr, "axis");
	bool flip_uvw[3] = {false};
	int tot, i;
	BPoint *bp;
	BLI_bitmap *selpoints;

	tot = lt->pntsu * lt->pntsv * lt->pntsw;

	flip_uvw[axis] = true;

	if (!extend) {
		lt->actbp = LT_ACTBP_NONE;
	}

	/* store "original" selection */
	selpoints = BLI_BITMAP_NEW(tot, __func__);
	BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false);

	/* actual (de)selection */
	for (i = 0; i < tot; i++) {
		const int i_flip = BKE_lattice_index_flip(lt, i, flip_uvw[0], flip_uvw[1], flip_uvw[2]);
		bp = &lt->def[i];
		if (!bp->hide) {
			if (BLI_BITMAP_TEST(selpoints, i_flip)) {
				bp->f1 |= SELECT;
			}
			else {
				if (!extend) {
					bp->f1 &= ~SELECT;
				}
			}
		}
	}


	MEM_freeN(selpoints);

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

	return OPERATOR_FINISHED;
}
Пример #2
0
static int lattice_select_more_less(bContext *C, const bool select)
{
	Object *obedit = CTX_data_edit_object(C);
	Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
	BPoint *bp;
	const int tot = lt->pntsu * lt->pntsv * lt->pntsw;
	int u, v, w;
	BLI_bitmap *selpoints;

	lt->actbp = LT_ACTBP_NONE;

	selpoints = BLI_BITMAP_NEW(tot, __func__);
	BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false);

	bp = lt->def;
	for (w = 0; w < lt->pntsw; w++) {
		for (v = 0; v < lt->pntsv; v++) {
			for (u = 0; u < lt->pntsu; u++) {
				if ((bp->hide == 0) && (((bp->f1 & SELECT) == 0) == select)) {
					if (lattice_test_bitmap_uvw(lt, selpoints, u + 1, v, w, select) ||
					    lattice_test_bitmap_uvw(lt, selpoints, u - 1, v, w, select) ||
					    lattice_test_bitmap_uvw(lt, selpoints, u, v + 1, w, select) ||
					    lattice_test_bitmap_uvw(lt, selpoints, u, v - 1, w, select) ||
					    lattice_test_bitmap_uvw(lt, selpoints, u, v, w + 1, select) ||
					    lattice_test_bitmap_uvw(lt, selpoints, u, v, w - 1, select))
					{
						BKE_BIT_TEST_SET(bp->f1, select, SELECT);
					}
				}
				bp++;
			}
		}
	}

	MEM_freeN(selpoints);

	WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
	return OPERATOR_FINISHED;
}
Пример #3
0
static void ed_lattice_select_mirrored(Lattice *lt, const int axis, const bool extend)
{
	const int tot = lt->pntsu * lt->pntsv * lt->pntsw;
	int i;
	BPoint *bp;
	BLI_bitmap *selpoints;

	bool flip_uvw[3] = {false};
	flip_uvw[axis] = true;

	/* we could flip this too */
	if (!extend) {
		lt->actbp = LT_ACTBP_NONE;
	}

	/* store "original" selection */
	selpoints = BLI_BITMAP_NEW(tot, __func__);
	BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false);

	/* actual (de)selection */
	for (i = 0; i < tot; i++) {
		const int i_flip = BKE_lattice_index_flip(lt, i, flip_uvw[0], flip_uvw[1], flip_uvw[2]);
		bp = &lt->def[i];
		if (!bp->hide) {
			if (BLI_BITMAP_TEST(selpoints, i_flip)) {
				bp->f1 |= SELECT;
			}
			else {
				if (!extend) {
					bp->f1 &= ~SELECT;
				}
			}
		}
	}


	MEM_freeN(selpoints);
}