static char *gpu_str_skip_token(char *str, char *token, int max) { int len = 0; /* skip a variable/function name */ while (*str) { if (ELEM7(*str, ' ', '(', ')', ',', '\t', '\n', '\r')) break; else { if (token && len < max-1) { *token= *str; token++; len++; } str++; } } if (token) *token= '\0'; /* skip the next special characters: * note the missing ')' */ while (*str) { if (ELEM6(*str, ' ', '(', ',', '\t', '\n', '\r')) str++; else break; } return str; }
static bool is_noncolor_pass(ScenePassType pass_type) { return ELEM7(pass_type, SCE_PASS_Z, SCE_PASS_NORMAL, SCE_PASS_VECTOR, SCE_PASS_INDEXOB, SCE_PASS_UV, SCE_PASS_RAYHITS, SCE_PASS_INDEXMA); }
/* Maps new_w weights in place, using either one of the predefined functions, or a custom curve. * Return values are in new_w. * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real * vertex index (in case the weight tables do not cover the whole vertices...). * cmap might be NULL, in which case curve mapping mode will return unmodified data. */ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cmap, RNG *rng) { int i; /* Return immediately, if we have nothing to do! */ /* Also security checks... */ if (((falloff_type == MOD_WVG_MAPPING_CURVE) && (cmap == NULL)) || !ELEM7(falloff_type, MOD_WVG_MAPPING_CURVE, MOD_WVG_MAPPING_SHARP, MOD_WVG_MAPPING_SMOOTH, MOD_WVG_MAPPING_ROOT, MOD_WVG_MAPPING_SPHERE, MOD_WVG_MAPPING_RANDOM, MOD_WVG_MAPPING_STEP)) { return; } if (cmap && falloff_type == MOD_WVG_MAPPING_CURVE) { curvemapping_initialize(cmap); } /* Map each weight (vertex) to its new value, accordingly to the chosen mode. */ for (i = 0; i < num; ++i) { float fac = new_w[i]; /* Code borrowed from the warp modifier. */ /* Closely matches PROP_SMOOTH and similar. */ switch (falloff_type) { case MOD_WVG_MAPPING_CURVE: fac = curvemapping_evaluateF(cmap, 0, fac); break; case MOD_WVG_MAPPING_SHARP: fac = fac * fac; break; case MOD_WVG_MAPPING_SMOOTH: fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; break; case MOD_WVG_MAPPING_ROOT: fac = (float)sqrt(fac); break; case MOD_WVG_MAPPING_SPHERE: fac = (float)sqrt(2 * fac - fac * fac); break; case MOD_WVG_MAPPING_RANDOM: fac = BLI_rng_get_float(rng) * fac; break; case MOD_WVG_MAPPING_STEP: fac = (fac >= 0.5f) ? 1.0f : 0.0f; break; } new_w[i] = fac; } }
void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_management) { ImageFormatData *imf = imfptr->data; ID *id = imfptr->id.data; PointerRNA display_settings_ptr; PropertyRNA *prop; const int depth_ok = BKE_imtype_valid_depths(imf->imtype); /* some settings depend on this being a scene thats rendered */ const short is_render_out = (id && GS(id->name) == ID_SCE); uiLayout *col, *row, *split, *sub; int show_preview = FALSE; col = uiLayoutColumn(layout, FALSE); split = uiLayoutSplit(col, 0.5f, FALSE); uiItemR(split, imfptr, "file_format", 0, "", ICON_NONE); sub = uiLayoutRow(split, FALSE); uiItemR(sub, imfptr, "color_mode", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE); /* only display depth setting if multiple depths can be used */ if ((ELEM7(depth_ok, R_IMF_CHAN_DEPTH_1, R_IMF_CHAN_DEPTH_8, R_IMF_CHAN_DEPTH_10, R_IMF_CHAN_DEPTH_12, R_IMF_CHAN_DEPTH_16, R_IMF_CHAN_DEPTH_24, R_IMF_CHAN_DEPTH_32)) == 0) { row = uiLayoutRow(col, FALSE); uiItemL(row, IFACE_("Color Depth:"), ICON_NONE); uiItemR(row, imfptr, "color_depth", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } if (BKE_imtype_supports_quality(imf->imtype)) { uiItemR(col, imfptr, "quality", 0, NULL, ICON_NONE); } if (BKE_imtype_supports_compress(imf->imtype)) { uiItemR(col, imfptr, "compression", 0, NULL, ICON_NONE); } if (ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) { uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE); } row = uiLayoutRow(col, FALSE); if (BKE_imtype_supports_zbuf(imf->imtype)) { uiItemR(row, imfptr, "use_zbuffer", 0, NULL, ICON_NONE); } if (is_render_out && (imf->imtype == R_IMF_IMTYPE_OPENEXR)) { show_preview = TRUE; uiItemR(row, imfptr, "use_preview", 0, NULL, ICON_NONE); } if (imf->imtype == R_IMF_IMTYPE_JP2) { uiItemR(col, imfptr, "jpeg2k_codec", 0, NULL, ICON_NONE); row = uiLayoutRow(col, FALSE); uiItemR(row, imfptr, "use_jpeg2k_cinema_preset", 0, NULL, ICON_NONE); uiItemR(row, imfptr, "use_jpeg2k_cinema_48", 0, NULL, ICON_NONE); uiItemR(col, imfptr, "use_jpeg2k_ycc", 0, NULL, ICON_NONE); } if (imf->imtype == R_IMF_IMTYPE_DPX) { uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE); } if (imf->imtype == R_IMF_IMTYPE_CINEON) { #if 1 uiItemL(col, IFACE_("Hard coded Non-Linear, Gamma:1.7"), ICON_NONE); #else uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE); uiItemR(col, imfptr, "cineon_black", 0, NULL, ICON_NONE); uiItemR(col, imfptr, "cineon_white", 0, NULL, ICON_NONE); uiItemR(col, imfptr, "cineon_gamma", 0, NULL, ICON_NONE); #endif } /* color management */ if (color_management && (!BKE_imtype_requires_linear_float(imf->imtype) || (show_preview && imf->flag & R_IMF_FLAG_PREVIEW_JPG))) { prop = RNA_struct_find_property(imfptr, "display_settings"); display_settings_ptr = RNA_property_pointer_get(imfptr, prop); col = uiLayoutColumn(layout, FALSE); uiItemL(col, IFACE_("Color Management"), ICON_NONE); uiItemR(col, &display_settings_ptr, "display_device", 0, NULL, ICON_NONE); uiTemplateColormanagedViewSettings(col, NULL, imfptr, "view_settings"); } }
/* thresh is threshold for comparing vertices, uvs, vertex colors, * weights, etc.*/ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2, const float thresh) { const float thresh_sq = thresh * thresh; CustomDataLayer *l1, *l2; int i, i1 = 0, i2 = 0, tot, j; for (i = 0; i < c1->totlayer; i++) { if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY, CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) { i1++; } } for (i = 0; i < c2->totlayer; i++) { if (ELEM7(c2->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY, CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) { i2++; } } if (i1 != i2) return MESHCMP_CDLAYERS_MISMATCH; l1 = c1->layers; l2 = c2->layers; tot = i1; i1 = 0; i2 = 0; for (i = 0; i < tot; i++) { while (i1 < c1->totlayer && !ELEM7(l1->type, CD_MVERT, CD_MEDGE, CD_MPOLY, CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) { i1++, l1++; } while (i2 < c2->totlayer && !ELEM7(l2->type, CD_MVERT, CD_MEDGE, CD_MPOLY, CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) { i2++, l2++; } if (l1->type == CD_MVERT) { MVert *v1 = l1->data; MVert *v2 = l2->data; int vtot = m1->totvert; for (j = 0; j < vtot; j++, v1++, v2++) { if (len_v3v3(v1->co, v2->co) > thresh) return MESHCMP_VERTCOMISMATCH; /* I don't care about normals, let's just do coodinates */ } } /*we're order-agnostic for edges here*/ if (l1->type == CD_MEDGE) { MEdge *e1 = l1->data; MEdge *e2 = l2->data; int etot = m1->totedge; EdgeHash *eh = BLI_edgehash_new_ex(__func__, etot); for (j = 0; j < etot; j++, e1++) { BLI_edgehash_insert(eh, e1->v1, e1->v2, e1); } for (j = 0; j < etot; j++, e2++) { if (!BLI_edgehash_lookup(eh, e2->v1, e2->v2)) return MESHCMP_EDGEUNKNOWN; } BLI_edgehash_free(eh, NULL); } if (l1->type == CD_MPOLY) { MPoly *p1 = l1->data; MPoly *p2 = l2->data; int ptot = m1->totpoly; for (j = 0; j < ptot; j++, p1++, p2++) { MLoop *lp1, *lp2; int k; if (p1->totloop != p2->totloop) return MESHCMP_POLYMISMATCH; lp1 = m1->mloop + p1->loopstart; lp2 = m2->mloop + p2->loopstart; for (k = 0; k < p1->totloop; k++, lp1++, lp2++) { if (lp1->v != lp2->v) return MESHCMP_POLYVERTMISMATCH; } } } if (l1->type == CD_MLOOP) { MLoop *lp1 = l1->data; MLoop *lp2 = l2->data; int ltot = m1->totloop; for (j = 0; j < ltot; j++, lp1++, lp2++) { if (lp1->v != lp2->v) return MESHCMP_LOOPMISMATCH; } } if (l1->type == CD_MLOOPUV) { MLoopUV *lp1 = l1->data; MLoopUV *lp2 = l2->data; int ltot = m1->totloop; for (j = 0; j < ltot; j++, lp1++, lp2++) { if (len_squared_v2v2(lp1->uv, lp2->uv) > thresh_sq) return MESHCMP_LOOPUVMISMATCH; } } if (l1->type == CD_MLOOPCOL) { MLoopCol *lp1 = l1->data; MLoopCol *lp2 = l2->data; int ltot = m1->totloop; for (j = 0; j < ltot; j++, lp1++, lp2++) { if (ABS(lp1->r - lp2->r) > thresh || ABS(lp1->g - lp2->g) > thresh || ABS(lp1->b - lp2->b) > thresh || ABS(lp1->a - lp2->a) > thresh) { return MESHCMP_LOOPCOLMISMATCH; } } } if (l1->type == CD_MDEFORMVERT) { MDeformVert *dv1 = l1->data; MDeformVert *dv2 = l2->data; int dvtot = m1->totvert; for (j = 0; j < dvtot; j++, dv1++, dv2++) { int k; MDeformWeight *dw1 = dv1->dw, *dw2 = dv2->dw; if (dv1->totweight != dv2->totweight) return MESHCMP_DVERT_TOTGROUPMISMATCH; for (k = 0; k < dv1->totweight; k++, dw1++, dw2++) { if (dw1->def_nr != dw2->def_nr) return MESHCMP_DVERT_GROUPMISMATCH; if (ABS(dw1->weight - dw2->weight) > thresh) return MESHCMP_DVERT_WEIGHTMISMATCH; } } } } return 0; }