[Bf-blender-cvs] [534009098ea] blender2.8: Remove obsolete weight paint color computation code.
Alexander Gavrilov
noreply at git.blender.org
Mon Oct 1 10:20:34 CEST 2018
Commit: 534009098ea094aa1f3b5298101e5d9e0a3cb1dc
Author: Alexander Gavrilov
Date: Sun Sep 30 18:07:38 2018 +0300
Branches: blender2.8
https://developer.blender.org/rB534009098ea094aa1f3b5298101e5d9e0a3cb1dc
Remove obsolete weight paint color computation code.
The new weight paint drawing code converts weight to color
directly in the shader, so the old CD_PREVIEW_MLOOPCOL based
code is not needed anymore.
===================================================================
M source/blender/blenkernel/BKE_DerivedMesh.h
M source/blender/blenkernel/BKE_mesh_runtime.h
M source/blender/blenkernel/intern/DerivedMesh.c
M source/blender/editors/interface/resources.c
M source/blender/makesrna/intern/rna_userdef.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index cdf0d683779..0b0030ec101 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -559,17 +559,6 @@ void makeDerivedMesh(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
CustomDataMask dataMask, const bool build_shapekey_layers);
-/** Update the weight MCOL preview layer.
- * If weights are NULL, use object's active vgroup(s).
- * Else, weights must be an array of weight float values.
- * If indices is NULL, it must be of numVerts length.
- * Else, it must be of num length, as indices, which contains vertices' idx to apply weights to.
- * (other vertices are assumed zero weight).
- */
-void DM_update_weight_mcol(
- struct Object *ob, struct DerivedMesh *dm, int const draw_flag,
- float *weights, int num, const int *indices);
-
/** convert layers requested by a GLSL material to actually available layers in
* the DerivedMesh, with both a pointer for arrays and an offset for editmesh */
typedef struct DMVertexAttribs {
diff --git a/source/blender/blenkernel/BKE_mesh_runtime.h b/source/blender/blenkernel/BKE_mesh_runtime.h
index 9d29299cacd..9132c3dae64 100644
--- a/source/blender/blenkernel/BKE_mesh_runtime.h
+++ b/source/blender/blenkernel/BKE_mesh_runtime.h
@@ -107,9 +107,6 @@ struct Mesh *mesh_create_eval_final_view(
void BKE_mesh_runtime_eval_to_meshkey(struct Mesh *me_deformed, struct Mesh *me, struct KeyBlock *kb);
-/* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */
-void BKE_mesh_runtime_color_band_store(const struct ColorBand *coba, const char alert_color[4]);
-
#ifndef NDEBUG
char *BKE_mesh_runtime_debug_info(struct Mesh *me_eval);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 6382fd91d0d..4c55591db31 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1326,439 +1326,6 @@ static void add_orco_mesh(
}
}
-/* weight paint colors */
-
-/* Something of a hack, at the moment deal with weightpaint
- * by tucking into colors during modifier eval, only in
- * wpaint mode. Works ok but need to make sure recalc
- * happens on enter/exit wpaint.
- */
-
-/* draw_flag's for calc_weightpaint_vert_color */
-enum {
- /* only one of these should be set, keep first (for easy bit-shifting) */
- CALC_WP_GROUP_USER_ACTIVE = (1 << 1),
- CALC_WP_GROUP_USER_ALL = (1 << 2),
-
- CALC_WP_MULTIPAINT = (1 << 3),
- CALC_WP_AUTO_NORMALIZE = (1 << 4),
- CALC_WP_MIRROR_X = (1 << 5),
-};
-
-typedef struct MERuntimeWeightColorInfo {
- const ColorBand *coba;
- const char *alert_color;
-} MERuntimeWeightColorInfo;
-
-
-static int dm_drawflag_calc(const ToolSettings *ts, const Mesh *me)
-{
- return ((ts->multipaint ? CALC_WP_MULTIPAINT : 0) |
- /* CALC_WP_GROUP_USER_ACTIVE or CALC_WP_GROUP_USER_ALL */
- (1 << ts->weightuser) |
- (ts->auto_normalize ? CALC_WP_AUTO_NORMALIZE : 0) |
- ((me->editflag & ME_EDIT_MIRROR_X) ? CALC_WP_MIRROR_X : 0));
-}
-
-static void weightpaint_color(unsigned char r_col[4], MERuntimeWeightColorInfo *dm_wcinfo, const float input)
-{
- float colf[4];
-
- if (dm_wcinfo && dm_wcinfo->coba) {
- BKE_colorband_evaluate(dm_wcinfo->coba, input, colf);
- }
- else {
- BKE_defvert_weight_to_rgb(colf, input);
- }
-
- /* don't use rgb_float_to_uchar() here because
- * the resulting float doesn't need 0-1 clamp check */
- r_col[0] = (unsigned char)(colf[0] * 255.0f);
- r_col[1] = (unsigned char)(colf[1] * 255.0f);
- r_col[2] = (unsigned char)(colf[2] * 255.0f);
- r_col[3] = 255;
-}
-
-
-static void calc_weightpaint_vert_color(
- unsigned char r_col[4],
- const MDeformVert *dv,
- MERuntimeWeightColorInfo *dm_wcinfo,
- const int defbase_tot, const int defbase_act,
- const bool *defbase_sel, const int defbase_sel_tot,
- const int draw_flag)
-{
- float input = 0.0f;
-
- bool show_alert_color = false;
-
- if ((defbase_sel_tot > 1) && (draw_flag & CALC_WP_MULTIPAINT)) {
- /* Multi-Paint feature */
- input = BKE_defvert_multipaint_collective_weight(
- dv, defbase_tot, defbase_sel, defbase_sel_tot, (draw_flag & CALC_WP_AUTO_NORMALIZE) != 0);
-
- /* make it black if the selected groups have no weight on a vertex */
- if (input == 0.0f) {
- show_alert_color = true;
- }
- }
- else {
- /* default, non tricky behavior */
- input = defvert_find_weight(dv, defbase_act);
-
- if (draw_flag & CALC_WP_GROUP_USER_ACTIVE) {
- if (input == 0.0f) {
- show_alert_color = true;
- }
- }
- else if (draw_flag & CALC_WP_GROUP_USER_ALL) {
- if (input == 0.0f) {
- show_alert_color = defvert_is_weight_zero(dv, defbase_tot);
- }
- }
- }
-
- if (show_alert_color == false) {
- CLAMP(input, 0.0f, 1.0f);
- weightpaint_color(r_col, dm_wcinfo, input);
- }
- else {
- copy_v3_v3_char((char *)r_col, dm_wcinfo->alert_color);
- r_col[3] = 255;
- }
-}
-
-static MERuntimeWeightColorInfo G_me_runtime_wcinfo;
-
-void BKE_mesh_runtime_color_band_store(const ColorBand *coba, const char alert_color[4])
-{
- G_me_runtime_wcinfo.coba = coba;
- G_me_runtime_wcinfo.alert_color = alert_color;
-}
-
-/**
- * return an array of vertex weight colors, caller must free.
- *
- * \note that we could save some memory and allocate RGB only but then we'd need to
- * re-arrange the colors when copying to the face since MCol has odd ordering,
- * so leave this as is - campbell
- */
-static void calc_weightpaint_vert_array(
- Object *ob, DerivedMesh *dm, int const draw_flag, MERuntimeWeightColorInfo *dm_wcinfo,
- unsigned char (*r_wtcol_v)[4])
-{
- BMEditMesh *em = (dm->type == DM_TYPE_EDITBMESH) ? BKE_editmesh_from_object(ob) : NULL;
- const int numVerts = dm->getNumVerts(dm);
-
- if ((ob->actdef != 0) &&
- (CustomData_has_layer(em ? &em->bm->vdata : &dm->vertData, CD_MDEFORMVERT)))
- {
- unsigned char (*wc)[4] = r_wtcol_v;
- unsigned int i;
-
- /* variables for multipaint */
- const int defbase_tot = BLI_listbase_count(&ob->defbase);
- const int defbase_act = ob->actdef - 1;
-
- int defbase_sel_tot = 0;
- bool *defbase_sel = NULL;
-
- if (draw_flag & CALC_WP_MULTIPAINT) {
- defbase_sel = BKE_object_defgroup_selected_get(ob, defbase_tot, &defbase_sel_tot);
-
- if (defbase_sel_tot > 1 && (draw_flag & CALC_WP_MIRROR_X)) {
- BKE_object_defgroup_mirror_selection(ob, defbase_tot, defbase_sel, defbase_sel, &defbase_sel_tot);
- }
- }
-
- /* editmesh won't have deform verts unless modifiers require it,
- * avoid having to create an array of deform-verts only for drawing
- * by reading from the bmesh directly. */
- if (em) {
- BMIter iter;
- BMVert *eve;
- const int cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
- BLI_assert(cd_dvert_offset != -1);
-
- BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) {
- const MDeformVert *dv = BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset);
- calc_weightpaint_vert_color(
- (unsigned char *)wc, dv, dm_wcinfo,
- defbase_tot, defbase_act, defbase_sel, defbase_sel_tot, draw_flag);
- wc++;
- }
- }
- else {
- const MDeformVert *dv = DM_get_vert_data_layer(dm, CD_MDEFORMVERT);
- for (i = numVerts; i != 0; i--, wc++, dv++) {
- calc_weightpaint_vert_color(
- (unsigned char *)wc, dv, dm_wcinfo,
- defbase_tot, defbase_act, defbase_sel, defbase_sel_tot, draw_flag);
- }
- }
-
- if (defbase_sel) {
- MEM_freeN(defbase_sel);
- }
- }
- else {
- unsigned char col[4];
- if ((ob->actdef == 0) && !BLI_listbase_is_empty(&ob->defbase)) {
- /* color-code for missing data (full brightness isn't easy on the eye). */
- ARRAY_SET_ITEMS(col, 0xa0, 0, 0xa0, 0xff);
- }
- else if (draw_flag & (CALC_WP_GROUP_USER_ACTIVE | CALC_WP_GROUP_USER_ALL)) {
- copy_v3_v3_char((char *)col, dm_wcinfo->alert_color);
- col[3] = 255;
- }
- else {
- weightpaint_color(col, dm_wcinfo, 0.0f);
- }
- copy_vn_i((int *)r_wtcol_v, numVerts, *((int *)col));
- }
-}
-
-static void calc_weightpaint_vert_array_mesh(
- Object *ob, Mesh *mesh, int const draw_flag, MERuntimeWeightColorInfo *dm_wcinfo,
- unsigned char (*r_wtcol_v)[4])
-{
- BMEditMesh *em = BKE_editmesh_from_object(ob);
- const int numVerts = mesh->totvert;
-
- if ((ob->actdef != 0) &&
- (CustomData_has_layer(em ? &em->bm->vdata : &mesh->vdata, CD_MDEFORMVERT)))
- {
- unsigned char (*wc)[4] = r_wtcol_v;
- unsigned int i;
-
- /* variables for multipaint */
- const int defbase_tot = BLI_listbase_count(&ob->defbase);
- const int defbase_act = ob->actdef - 1;
-
- int defbase_sel_tot = 0;
- bool *defbase_sel = NULL;
-
- if (draw_flag & CALC_WP_MULTIPAINT) {
- defbase_sel = BKE_object_defgroup_selected_get(ob, defbase_tot, &defbase_sel_tot);
-
- if (defbase_sel_tot > 1 && (draw_flag & CALC_WP_MIRROR_X)) {
- BKE_object_defgroup_mirror_selection(ob, defbase_tot, defbase_sel, defbase_sel, &defbase_sel_tot);
- }
- }
-
- /* editmesh won't have deform verts unless modifiers require it,
- * avoid having to create an array of deform-verts only for drawing
- * by reading from the bmesh directly. */
- if (em) {
- BMIter iter;
- BMVert *eve;
- const int cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
- BLI_assert(cd_dvert_offset != -1);
-
- BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) {
- const MDeformVert *dv = BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset);
- calc_weightpaint_vert_color(
- (unsigned char *)wc, dv, dm_wcinfo,
- defbase_tot, defbase_act, defbase_sel, defbase_sel_tot, draw_flag);
- wc++;
- }
- }
- else {
- const MDeformVert *dv = CustomData_get_layer(&mesh->vdata, CD_MDEFORMVERT);
- for (i = numVerts; i != 0; i--, wc++, dv++) {
- calc_weightpaint_vert_color(
- (unsigned char *)wc, dv, dm_wcinfo,
- defbase_tot, defbase_act, defbase_sel, defbase_sel_tot, draw_flag);
- }
- }
-
- if (defbase_sel)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list