Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2018-09-23 20:41:10 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2018-09-25 18:44:57 +0300
commitaf998b40a0d1cd1615ab836c6214523169d4dd42 (patch)
tree1c2a05cf7fa7ccf7b35e8501eba5a99ab5e51071 /source/blender/draw/intern/draw_cache.c
parentbd51cada8db64e45cabca66cd61438c1ae2bdf25 (diff)
Implement correct drawing of advanced Weight display features.
This adds existing behavior from calc_weightpaint_vert_array that was missing from the new rendering code: - No selected Vertex Group displays as a solid pink color. - Zero weight displays as alert color depending on Options. - Multipaint mode correctly displays collective weight. In order to properly implement this variety, a data structure holding all relevant parameters is introduced. Reviewers: fclem, campbellbarton Subscribers: jbakker Differential Revision: https://developer.blender.org/D3722
Diffstat (limited to 'source/blender/draw/intern/draw_cache.c')
-rw-r--r--source/blender/draw/intern/draw_cache.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index c4214b436f1..abc62c7e175 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -37,11 +37,16 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
+#include "BLI_listbase.h"
+
+#include "BKE_object_deform.h"
#include "GPU_batch.h"
#include "GPU_batch_presets.h"
#include "GPU_batch_utils.h"
+#include "MEM_guardedalloc.h"
+
#include "draw_cache.h"
#include "draw_cache_impl.h"
@@ -2950,12 +2955,46 @@ GPUBatch *DRW_cache_mesh_loose_edges_get(Object *ob)
return DRW_mesh_batch_cache_get_loose_edges_with_normals(me);
}
-GPUBatch *DRW_cache_mesh_surface_weights_get(Object *ob)
+GPUBatch *DRW_cache_mesh_surface_weights_get(Object *ob, ToolSettings *ts, bool paint_mode)
{
BLI_assert(ob->type == OB_MESH);
Mesh *me = ob->data;
- return DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(me, ob->actdef - 1);
+
+ /* Extract complete vertex weight group selection state and mode flags. */
+ VertexWeightSelection vwsel;
+ memset(&vwsel, 0, sizeof(vwsel));
+
+ vwsel.defgroup_active = ob->actdef - 1;
+ vwsel.defgroup_tot = BLI_listbase_count(&ob->defbase);
+
+ vwsel.alert_mode = ts->weightuser;
+
+ if (paint_mode && ts->multipaint) {
+ /* Multipaint needs to know all selected bones, not just the active group.
+ * This is actually a relatively expensive operation, but caching would be difficult. */
+ vwsel.defgroup_sel = BKE_object_defgroup_selected_get(ob, vwsel.defgroup_tot, &vwsel.defgroup_sel_tot);
+
+ if (vwsel.defgroup_sel_tot > 1) {
+ vwsel.flags |= VWEIGHT_MULTIPAINT | (ts->auto_normalize ? VWEIGHT_AUTO_NORMALIZE : 0);
+
+ if (me->editflag & ME_EDIT_MIRROR_X) {
+ BKE_object_defgroup_mirror_selection(ob, vwsel.defgroup_tot, vwsel.defgroup_sel, vwsel.defgroup_sel, &vwsel.defgroup_sel_tot);
+ }
+ }
+ /* With only one selected bone Multipaint reverts to regular mode. */
+ else {
+ vwsel.defgroup_sel_tot = 0;
+ MEM_SAFE_FREE(vwsel.defgroup_sel);
+ }
+ }
+
+ /* Generate the weight data using the selection. */
+ GPUBatch *batch = DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(me, &vwsel);
+
+ DRW_vweight_selection_clear(&vwsel);
+
+ return batch;
}
GPUBatch *DRW_cache_mesh_surface_vert_colors_get(Object *ob)