Пример #1
0
void paintvert_select_ungrouped(Object *ob, bool extend, bool flush_flags)
{
  Mesh *me = BKE_mesh_from_object(ob);
  MVert *mv;
  MDeformVert *dv;
  int a, tot;

  if (me == NULL || me->dvert == NULL) {
    return;
  }

  if (!extend) {
    paintvert_deselect_all_visible(ob, SEL_DESELECT, false);
  }

  dv = me->dvert;
  tot = me->totvert;

  for (a = 0, mv = me->mvert; a < tot; a++, mv++, dv++) {
    if ((mv->flag & ME_HIDE) == 0) {
      if (dv->dw == NULL) {
        /* if null weight then not grouped */
        mv->flag |= SELECT;
      }
    }
  }

  if (flush_flags) {
    paintvert_flush_flags(ob);
  }
}
Пример #2
0
/*  note: if the caller passes FALSE to flush_flags, then they will need to run paintvert_flush_flags(ob) themselves */
void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags)
{
	Mesh *me;
	MVert *mvert;
	int a;

	me= get_mesh(ob);
	if(me==NULL) return;
	
	if(action == SEL_INVERT) {
		mvert= me->mvert;
		a= me->totvert;
		while(a--) {
			if((mvert->flag & ME_HIDE) == 0) {
				mvert->flag ^= SELECT;
			}
			mvert++;
		}
	}
	else {
		if (action == SEL_TOGGLE) {
			action = SEL_SELECT;

			mvert= me->mvert;
			a= me->totvert;
			while(a--) {
				if((mvert->flag & ME_HIDE) == 0 && mvert->flag & SELECT) {
					action = SEL_DESELECT;
					break;
				}
				mvert++;
			}
		}

		mvert= me->mvert;
		a= me->totvert;
		while(a--) {
			if((mvert->flag & ME_HIDE) == 0) {
				switch (action) {
				case SEL_SELECT:
					mvert->flag |= SELECT;
					break;
				case SEL_DESELECT:
					mvert->flag &= ~SELECT;
					break;
				case SEL_INVERT:
					mvert->flag ^= SELECT;
					break;
				}
			}
			mvert++;
		}
	}

	if(flush_flags) {
		paintvert_flush_flags(ob);
	}
}
Пример #3
0
/*  note: if the caller passes false to flush_flags, then they will need to run paintvert_flush_flags(ob) themselves */
void paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
{
	Mesh *me;
	MVert *mvert;
	int a;

	me = BKE_mesh_from_object(ob);
	if (me == NULL) return;
	
	if (action == SEL_TOGGLE) {
		action = SEL_SELECT;

		mvert = me->mvert;
		a = me->totvert;
		while (a--) {
			if ((mvert->flag & ME_HIDE) == 0 && mvert->flag & SELECT) {
				action = SEL_DESELECT;
				break;
			}
			mvert++;
		}
	}

	mvert = me->mvert;
	a = me->totvert;
	while (a--) {
		if ((mvert->flag & ME_HIDE) == 0) {
			switch (action) {
				case SEL_SELECT:
					mvert->flag |= SELECT;
					break;
				case SEL_DESELECT:
					mvert->flag &= ~SELECT;
					break;
				case SEL_INVERT:
					mvert->flag ^= SELECT;
					break;
			}
		}
		mvert++;
	}

	/* handle mselect */
	if (action == SEL_SELECT) {
		/* pass */
	}
	else if (ELEM(action, SEL_DESELECT, SEL_INVERT)) {
		BKE_mesh_mselect_clear(me);
	}
	else {
		BKE_mesh_mselect_validate(me);
	}

	if (flush_flags) {
		paintvert_flush_flags(ob);
	}
}