Add material slot reorder buttons

This commit is contained in:
2015-04-28 07:24:56 +10:00
committed by Campbell Barton
parent 58a2b10a65
commit 4288ab16e5
10 changed files with 196 additions and 2 deletions

View File

@@ -4492,6 +4492,54 @@ int BKE_curve_material_index_validate(Curve *cu)
}
}
void BKE_curve_material_remap(Curve *cu, const unsigned int *remap, unsigned int remap_len)
{
const int curvetype = BKE_curve_type_get(cu);
const short remap_len_short = (short)remap_len;
#define MAT_NR_REMAP(n) \
if (n < remap_len_short) { \
BLI_assert(n >= 0 && remap[n] < remap_len_short); \
n = remap[n]; \
} ((void)0)
if (curvetype == OB_FONT) {
struct CharInfo *strinfo;
int charinfo_len, i;
if (cu->editfont) {
EditFont *ef = cu->editfont;
strinfo = ef->textbufinfo;
charinfo_len = ef->len;
}
else {
strinfo = cu->strinfo;
charinfo_len = cu->len_wchar;
}
for (i = 0; i <= charinfo_len; i++) {
if (strinfo[i].mat_nr > 0) {
strinfo[i].mat_nr -= 1;
MAT_NR_REMAP(strinfo[i].mat_nr);
strinfo[i].mat_nr += 1;
}
}
}
else {
Nurb *nu;
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
if (nurbs) {
for (nu = nurbs->first; nu; nu = nu->next) {
MAT_NR_REMAP(nu->mat_nr);
}
}
}
#undef MAT_NR_REMAP
}
void BKE_curve_rect_from_textbox(const struct Curve *cu, const struct TextBox *tb, struct rctf *r_rect)
{
r_rect->xmin = cu->xof + tb->x;