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:
authorCampbell Barton <ideasman42@gmail.com>2017-05-08 05:46:54 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-05-08 06:00:43 +0300
commit1a869fb6b96c5f36d9db8cb7a87b6b01567ecd45 (patch)
treeffd8cc784c03b57f04b077ae8f32c1ac7bc09e19 /source/blender/draw/modes/edit_mesh_mode.c
parent0927748624519608b9caf4b898eaf192c83d3d7b (diff)
DWM: show weights in edit-mode
Engine collection settings aren't currently flushed, once they are this will work as expected.
Diffstat (limited to 'source/blender/draw/modes/edit_mesh_mode.c')
-rw-r--r--source/blender/draw/modes/edit_mesh_mode.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index 120d977c222..83bdd788900 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -55,6 +55,7 @@ extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
/* *********** LISTS *********** */
typedef struct EDIT_MESH_PassList {
+ struct DRWPass *vcolor_faces;
struct DRWPass *depth_hidden_wire;
struct DRWPass *edit_face_overlay;
struct DRWPass *edit_face_occluded;
@@ -87,6 +88,8 @@ typedef struct EDIT_MESH_Data {
/* *********** STATIC *********** */
static struct {
+ /* weight/vert-color */
+ GPUShader *vcolor_face_shader;
GPUShader *overlay_tri_sh;
GPUShader *overlay_tri_fast_sh;
GPUShader *overlay_tri_vcol_sh;
@@ -103,6 +106,8 @@ static struct {
} e_data = {NULL}; /* Engine data */
typedef struct EDIT_MESH_PrivateData {
+ /* weight/vert-color */
+ DRWShadingGroup *fvcolor_shgrp;
DRWShadingGroup *depth_shgrp_hidden_wire;
DRWShadingGroup *fnormals_shgrp;
@@ -140,6 +145,10 @@ static void EDIT_MESH_engine_init(void *vedata)
(int)viewport_size[0], (int)viewport_size[1],
tex, ARRAY_SIZE(tex));
+ if (!e_data.vcolor_face_shader) {
+ e_data.vcolor_face_shader = GPU_shader_get_builtin_shader(GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR_ALPHA);
+ }
+
if (!e_data.overlay_tri_sh) {
e_data.overlay_tri_sh = DRW_shader_create_with_lib(
datatoc_edit_mesh_overlay_vert_glsl,
@@ -302,6 +311,21 @@ static void EDIT_MESH_cache_init(void *vedata)
}
{
+ psl->vcolor_faces = DRW_pass_create(
+ "Vert Color Pass",
+ DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
+
+ stl->g_data->fvcolor_shgrp = DRW_shgroup_create(e_data.vcolor_face_shader, psl->vcolor_faces);
+
+ static float light[3] = {-0.3f, 0.5f, 1.0f};
+ static float alpha = 1.0f;
+ static float world_light = 1.0f; /* XXX, see: paint_vertex_mode.c */
+ DRW_shgroup_uniform_vec3(stl->g_data->fvcolor_shgrp, "light", light, 1);
+ DRW_shgroup_uniform_float(stl->g_data->fvcolor_shgrp, "alpha", &alpha, 1);
+ DRW_shgroup_uniform_float(stl->g_data->fvcolor_shgrp, "global", &world_light, 1);
+ }
+
+ {
/* Complementary Depth Pass */
psl->depth_hidden_wire = DRW_pass_create(
"Depth Pass Hidden Wire",
@@ -402,6 +426,8 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
if (ob == obedit) {
IDProperty *ces_mode_ed = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_EDIT, "");
bool do_occlude_wire = BKE_collection_engine_property_value_get_bool(ces_mode_ed, "show_occlude_wire");
+ bool do_show_weight = BKE_collection_engine_property_value_get_bool(ces_mode_ed, "show_weight");
+
/* Updating uniform */
backwire_opacity = BKE_collection_engine_property_value_get_float(ces_mode_ed, "backwire_opacity");
@@ -413,6 +439,11 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
face_mod = (do_occlude_wire) ? 0.0f : 1.0f;
+ if (do_show_weight) {
+ geom = DRW_cache_mesh_surface_weights_get(ob);
+ DRW_shgroup_call_add(stl->g_data->fvcolor_shgrp, geom, ob->obmat);
+ }
+
if (do_occlude_wire) {
geom = DRW_cache_mesh_surface_get(ob);
DRW_shgroup_call_add(stl->g_data->depth_shgrp_hidden_wire, geom, ob->obmat);
@@ -455,6 +486,8 @@ static void EDIT_MESH_draw_scene(void *vedata)
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+ DRW_draw_pass(psl->vcolor_faces);
+
DRW_draw_pass(psl->depth_hidden_wire);
if (psl->edit_face_occluded) {
@@ -490,6 +523,7 @@ void EDIT_MESH_collection_settings_create(IDProperty *properties)
properties->type == IDP_GROUP &&
properties->subtype == IDP_GROUP_SUB_MODE_EDIT);
BKE_collection_engine_property_add_int(properties, "show_occlude_wire", false);
+ BKE_collection_engine_property_add_int(properties, "show_weight", true);
BKE_collection_engine_property_add_int(properties, "face_normals_show", false);
BKE_collection_engine_property_add_int(properties, "vert_normals_show", false);
BKE_collection_engine_property_add_int(properties, "loop_normals_show", false);