Ejemplo n.º 1
0
bool paintface_mouse_select(
    struct bContext *C, Object *ob, const int mval[2], bool extend, bool deselect, bool toggle)
{
  Mesh *me;
  MPoly *mpoly_sel;
  uint index;

  /* Get the face under the cursor */
  me = BKE_mesh_from_object(ob);

  if (!ED_mesh_pick_face(C, ob, mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) {
    return false;
  }

  if (index >= me->totpoly) {
    return false;
  }

  mpoly_sel = me->mpoly + index;
  if (mpoly_sel->flag & ME_HIDE) {
    return false;
  }

  /* clear flags */
  if (!extend && !deselect && !toggle) {
    paintface_deselect_all_visible(C, ob, SEL_DESELECT, false);
  }

  me->act_face = (int)index;

  if (extend) {
    mpoly_sel->flag |= ME_FACE_SEL;
  }
  else if (deselect) {
    mpoly_sel->flag &= ~ME_FACE_SEL;
  }
  else if (toggle) {
    if (mpoly_sel->flag & ME_FACE_SEL) {
      mpoly_sel->flag &= ~ME_FACE_SEL;
    }
    else {
      mpoly_sel->flag |= ME_FACE_SEL;
    }
  }
  else {
    mpoly_sel->flag |= ME_FACE_SEL;
  }

  /* image window redraw */

  paintface_flush_flags(C, ob, SELECT);
  ED_region_tag_redraw(CTX_wm_region(C));  // XXX - should redraw all 3D views
  return true;
}
Ejemplo n.º 2
0
bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], bool extend, bool deselect, bool toggle)
{
	Mesh *me;
	MPoly *mpoly, *mpoly_sel;
	unsigned int a, index;
	
	/* Get the face under the cursor */
	me = BKE_mesh_from_object(ob);

	if (!ED_mesh_pick_face(C, ob, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE))
		return false;
	
	if (index >= me->totpoly)
		return false;

	mpoly_sel = me->mpoly + index;
	if (mpoly_sel->flag & ME_HIDE) return false;
	
	/* clear flags */
	mpoly = me->mpoly;
	a = me->totpoly;
	if (!extend && !deselect && !toggle) {
		while (a--) {
			mpoly->flag &= ~ME_FACE_SEL;
			mpoly++;
		}
	}
	
	me->act_face = (int)index;

	if (extend) {
		mpoly_sel->flag |= ME_FACE_SEL;
	}
	else if (deselect) {
		mpoly_sel->flag &= ~ME_FACE_SEL;
	}
	else if (toggle) {
		if (mpoly_sel->flag & ME_FACE_SEL)
			mpoly_sel->flag &= ~ME_FACE_SEL;
		else
			mpoly_sel->flag |= ME_FACE_SEL;
	}
	else {
		mpoly_sel->flag |= ME_FACE_SEL;
	}
	
	/* image window redraw */
	
	paintface_flush_flags(ob, SELECT);
	WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
	ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views
	return true;
}
Ejemplo n.º 3
0
void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const bool select)
{
	Mesh *me;
	unsigned int index = (unsigned int)-1;

	me = BKE_mesh_from_object(ob);
	if (me == NULL || me->totpoly == 0) return;

	if (mval) {
		if (!ED_mesh_pick_face(C, ob, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) {
			return;
		}
	}

	select_linked_tfaces_with_seams(me, index, select);

	paintface_flush_flags(ob, SELECT);
}