[Bf-blender-cvs] [20f95de6ba2] blender2.8: Weight painting with draw manager
Luca Rood
noreply at git.blender.org
Wed May 3 19:00:16 CEST 2017
Commit: 20f95de6ba2d32dcff553251ff4de2efd5b76955
Author: Luca Rood
Date: Wed May 3 18:55:40 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB20f95de6ba2d32dcff553251ff4de2efd5b76955
Weight painting with draw manager
This implements weight rendering with the draw manager, with all drawing
options (Shading, wire, face masking, vertex masking).
This is part of T51208
Reviewers: campbellbarton
Subscribers: dfelinto
Differential Revision: https://developer.blender.org/D2654
===================================================================
M release/scripts/startup/bl_ui/properties_collection.py
M source/blender/blenkernel/BKE_mesh.h
M source/blender/blenkernel/intern/deform.c
M source/blender/blenkernel/intern/layer.c
M source/blender/blenkernel/intern/object_deform.c
M source/blender/draw/DRW_engine.h
M source/blender/draw/intern/draw_cache.c
M source/blender/draw/intern/draw_cache.h
M source/blender/draw/intern/draw_cache_impl.h
M source/blender/draw/intern/draw_cache_impl_mesh.c
M source/blender/draw/modes/object_mode.c
M source/blender/draw/modes/paint_weight_mode.c
M source/blender/editors/mesh/editface.c
M source/blender/editors/sculpt_paint/paint_stroke.c
M source/blender/editors/sculpt_paint/paint_vertex.c
M source/blender/gpu/CMakeLists.txt
M source/blender/gpu/GPU_shader.h
M source/blender/gpu/intern/gpu_shader.c
A source/blender/gpu/shaders/gpu_shader_simple_lighting_smooth_color_alpha_frag.glsl
M source/blender/makesdna/DNA_ID.h
M source/blender/makesdna/DNA_layer_types.h
M source/blender/makesrna/intern/rna_mesh.c
M source/blender/makesrna/intern/rna_scene.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py
index c1e2b00966c..0cd0194ff33 100644
--- a/release/scripts/startup/bl_ui/properties_collection.py
+++ b/release/scripts/startup/bl_ui/properties_collection.py
@@ -112,11 +112,30 @@ class COLLECTION_PT_edit_mode_settings(CollectionButtonsPanel, Panel):
col.template_override_property(collection_props, scene_props, "normals_length")
+class COLLECTION_PT_paint_weight_mode_settings(CollectionButtonsPanel, Panel):
+ bl_label = "Weight Paint Mode Settings"
+
+ @classmethod
+ def poll(cls, context):
+ ob = context.object
+ return ob and (ob.mode == 'WEIGHT_PAINT')
+
+ def draw(self, context):
+ layout = self.layout
+ scene_props = context.scene.collection_properties['WeightPaintMode']
+ collection = context.layer_collection
+ collection_props = collection.engine_overrides['WeightPaintMode']
+
+ col = layout.column()
+ col.template_override_property(collection_props, scene_props, "use_shading")
+ col.template_override_property(collection_props, scene_props, "use_wire")
+
classes = (
COLLECTION_PT_context_collection,
COLLECTION_PT_clay_settings,
COLLECTION_PT_object_mode_settings,
COLLECTION_PT_edit_mode_settings,
+ COLLECTION_PT_paint_weight_mode_settings,
)
if __name__ == "__main__": # only for live edit.
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index a24ce490262..db6f40756a4 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -411,6 +411,7 @@ void BKE_mesh_eval_geometry(struct EvaluationContext *eval_ctx,
enum {
BKE_MESH_BATCH_DIRTY_ALL = 0,
BKE_MESH_BATCH_DIRTY_SELECT,
+ BKE_MESH_BATCH_DIRTY_WEIGHT,
};
void BKE_mesh_batch_cache_dirty(struct Mesh *me, int mode);
void BKE_mesh_batch_cache_free(struct Mesh *me);
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 13b1aab5e1c..22ba050e4fb 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -54,6 +54,7 @@
#include "BKE_customdata.h"
#include "BKE_data_transfer.h"
#include "BKE_deform.h" /* own include */
+#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_object_deform.h"
@@ -73,6 +74,8 @@ bDeformGroup *BKE_defgroup_new(Object *ob, const char *name)
BLI_addtail(&ob->defbase, defgroup);
defgroup_unique_name(defgroup, ob);
+ BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_WEIGHT);
+
return defgroup;
}
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index d9398ae83c7..1a920a155b8 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -1088,6 +1088,22 @@ static void layer_collection_create_mode_settings_edit(IDProperty *root, const b
IDP_AddToGroup(root, props);
}
+static void layer_collection_create_mode_settings_paint_weight(IDProperty *root, const bool populate)
+{
+ IDProperty *props;
+ IDPropertyTemplate val = {0};
+
+ props = IDP_New(IDP_GROUP, &val, "WeightPaintMode");
+ props->subtype = IDP_GROUP_SUB_MODE_PAINT_WEIGHT;
+
+ /* properties */
+ if (populate) {
+ PAINT_WEIGHT_collection_settings_create(props);
+ }
+
+ IDP_AddToGroup(root, props);
+}
+
static void collection_create_render_settings(IDProperty *root, const bool populate)
{
CollectionEngineSettingsCB_Type *ces_type;
@@ -1103,6 +1119,7 @@ static void collection_create_mode_settings(IDProperty *root, const bool populat
* and have IDP_AddToGroup outside the callbacks */
layer_collection_create_mode_settings_object(root, populate);
layer_collection_create_mode_settings_edit(root, populate);
+ layer_collection_create_mode_settings_paint_weight(root, populate);
}
static int idproperty_group_subtype(const int mode_type)
@@ -1116,6 +1133,9 @@ static int idproperty_group_subtype(const int mode_type)
case COLLECTION_MODE_EDIT:
idgroup_type = IDP_GROUP_SUB_MODE_EDIT;
break;
+ case COLLECTION_MODE_PAINT_WEIGHT:
+ idgroup_type = IDP_GROUP_SUB_MODE_PAINT_WEIGHT;
+ break;
default:
case COLLECTION_MODE_NONE:
return IDP_GROUP_SUB_ENGINE_RENDER;
diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c
index ccf2aec5c7a..990c96c9576 100644
--- a/source/blender/blenkernel/intern/object_deform.c
+++ b/source/blender/blenkernel/intern/object_deform.c
@@ -51,6 +51,7 @@
#include "BKE_editmesh.h"
#include "BKE_object_deform.h" /* own include */
#include "BKE_object.h"
+#include "BKE_mesh.h"
#include "BKE_modifier.h"
/** \name Misc helpers
@@ -405,6 +406,8 @@ void BKE_object_defgroup_remove(Object *ob, bDeformGroup *defgroup)
object_defgroup_remove_edit_mode(ob, defgroup);
else
object_defgroup_remove_object_mode(ob, defgroup);
+
+ BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_WEIGHT);
}
/**
diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index 125a9d8d992..239919fd826 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -89,5 +89,6 @@ void DRW_pass_free(struct DRWPass *pass);
void OBJECT_collection_settings_create(struct IDProperty *properties);
void EDIT_MESH_collection_settings_create(struct IDProperty *properties);
void EDIT_ARMATURE_collection_settings_create(struct IDProperty *properties);
+void PAINT_WEIGHT_collection_settings_create(struct IDProperty *properties);
#endif /* __DRW_ENGINE_H__ */
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 79ca4209894..9fa79c41265 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -1769,6 +1769,14 @@ Batch *DRW_cache_mesh_surface_get(Object *ob)
return DRW_mesh_batch_cache_get_triangles_with_normals(me);
}
+Batch *DRW_cache_mesh_surface_weights_get(Object *ob)
+{
+ 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);
+}
+
/* Return list of batches */
Batch **DRW_cache_mesh_surface_shaded_get(Object *ob)
{
@@ -1802,6 +1810,30 @@ Batch *DRW_cache_mesh_verts_get(Object *ob)
return DRW_mesh_batch_cache_get_all_verts(me);
}
+Batch *DRW_cache_mesh_edges_weight_overlay_get(Object *ob, bool use_wire, bool use_sel)
+{
+ BLI_assert(ob->type == OB_MESH);
+
+ Mesh *me = ob->data;
+ return DRW_mesh_batch_cache_get_weight_overlay_edges(me, use_wire, use_sel);
+}
+
+Batch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob)
+{
+ BLI_assert(ob->type == OB_MESH);
+
+ Mesh *me = ob->data;
+ return DRW_mesh_batch_cache_get_weight_overlay_faces(me);
+}
+
+Batch *DRW_cache_mesh_verts_weight_overlay_get(Object *ob)
+{
+ BLI_assert(ob->type == OB_MESH);
+
+ Mesh *me = ob->data;
+ return DRW_mesh_batch_cache_get_weight_overlay_verts(me);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index 586ed98fed0..a725eb2c37a 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -94,12 +94,15 @@ void DRW_cache_mesh_wire_overlay_get(
struct Batch *DRW_cache_face_centers_get(struct Object *ob);
struct Batch *DRW_cache_mesh_wire_outline_get(struct Object *ob);
struct Batch *DRW_cache_mesh_surface_get(struct Object *ob);
+struct Batch *DRW_cache_mesh_surface_weights_get(struct Object *ob);
struct Batch *DRW_cache_mesh_surface_verts_get(struct Object *ob);
struct Batch *DRW_cache_mesh_edges_get(struct Object *ob);
struct Batch *DRW_cache_mesh_verts_get(struct Object *ob);
+struct Batch *DRW_cache_mesh_edges_weight_overlay_get(struct Object *ob, bool use_wire, bool use_sel);
+struct Batch *DRW_cache_mesh_faces_weight_overlay_get(struct Object *ob);
+struct Batch *DRW_cache_mesh_verts_weight_overlay_get(struct Object *ob);
struct Batch **DRW_cache_mesh_surface_shaded_get(struct Object *ob);
-
/* Curve */
struct Batch *DRW_cache_curve_surface_get(struct Object *ob);
struct Batch *DRW_cache_curve_surface_verts_get(struct Object *ob);
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index c988a5703dc..d9bc448967c 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -68,9 +68,13 @@ struct Batch *DRW_lattice_batch_cache_get_overlay_verts(struct Lattice *lt);
/* Mesh */
struct Batch **DRW_mesh_batch_cache_get_surface_shaded(struct Mesh *me);
+struct Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel);
+struct Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me);
+struct Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(struct Mesh *me);
struct Batch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me);
struct Batch *DRW_mesh_batch_cache_get_all_triangles(struct Mesh *me);
struct Batch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me);
+struct Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me, int index);
struct Batch *DRW_mesh_batch_cache_get_points_with_normals(struct Mesh *me);
struct Batch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me);
struct Batch *DRW_mesh_batch_cache_get_fancy_edges(struct Mesh *me);
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index fbddcd60d46..5a5d0260699 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -37,11 +37,14 @@
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
#include "BKE_customdata.h"
+#include "BKE_deform.h"
#include "BKE_DerivedMesh.h"
#include "BKE_editmesh.h"
#include "BKE_mesh.h"
+#include "BKE_texture.h"
#include "bmesh.h"
@@ -120,6 +123,7 @@ typedef struct MeshRenderData {
MLoopUV **mloopuv;
MCol
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list