[Bf-blender-cvs] [e724479ca61] sculpt-dev: Sculpt-dev: sculpt colors stuff
Joseph Eagar
noreply at git.blender.org
Wed Nov 17 13:09:23 CET 2021
Commit: e724479ca61921ce4168191accb4fb44bfd0fc88
Author: Joseph Eagar
Date: Wed Nov 17 03:09:37 2021 -0800
Branches: sculpt-dev
https://developer.blender.org/rBe724479ca61921ce4168191accb4fb44bfd0fc88
Sculpt-dev: sculpt colors stuff
* Mask by color now works for dyntopo.
* Attribute and vertex color lists in the UI
now hide temporary CD layers.
* Added a specific op for removing vertex color
attributes.
* Fixed various bugs.
===================================================================
A release/datafiles/icons/ops.sculpt.color_filter.dat
A release/datafiles/icons/ops.sculpt.ipmask_filter.dat
A release/datafiles/icons/ops.sculpt.mask_by_color.dat
M release/scripts/startup/bl_ui/properties_data_mesh.py
M source/blender/blenkernel/BKE_attribute.h
M source/blender/blenkernel/intern/attribute.c
M source/blender/blenkernel/intern/mesh.cc
M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc
M source/blender/editors/datafiles/CMakeLists.txt
M source/blender/editors/geometry/geometry_attributes.c
M source/blender/editors/geometry/geometry_intern.h
M source/blender/editors/geometry/geometry_ops.c
M source/blender/editors/sculpt_paint/sculpt_ops.c
M source/blender/makesrna/intern/rna_attribute.c
===================================================================
diff --git a/release/datafiles/icons/ops.sculpt.color_filter.dat b/release/datafiles/icons/ops.sculpt.color_filter.dat
new file mode 100644
index 00000000000..ec9b280c79c
Binary files /dev/null and b/release/datafiles/icons/ops.sculpt.color_filter.dat differ
diff --git a/release/datafiles/icons/ops.sculpt.ipmask_filter.dat b/release/datafiles/icons/ops.sculpt.ipmask_filter.dat
new file mode 100644
index 00000000000..0d247b9a103
Binary files /dev/null and b/release/datafiles/icons/ops.sculpt.ipmask_filter.dat differ
diff --git a/release/datafiles/icons/ops.sculpt.mask_by_color.dat b/release/datafiles/icons/ops.sculpt.mask_by_color.dat
new file mode 100644
index 00000000000..3fd4b1ec190
Binary files /dev/null and b/release/datafiles/icons/ops.sculpt.mask_by_color.dat differ
diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index c449d097755..5b33618d3e5 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -450,6 +450,7 @@ class MESH_UL_color_attributes(UIList):
for item in attrs:
bad = item.domain not in ["POINT", "CORNER"]
bad = bad or item.data_type not in ["FLOAT_COLOR", "BYTE_COLOR"]
+ bad = bad or item.temporary
#if not bad:
#print(bad, idx, item.name, item.domain, item.data_type)
@@ -501,7 +502,7 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
col = row.column(align=True)
col.operator("geometry.color_attribute_add", icon='ADD', text="")
- col.operator("geometry.attribute_remove", icon='REMOVE', text="")
+ col.operator("geometry.color_attribute_remove", icon='REMOVE', text="")
active = mesh.attributes.active
@@ -616,6 +617,20 @@ class MESH_UL_attributes(UIList):
'CORNER': "Face Corner",
}
+ def filter_items(self, context, data, property):
+ attrs = getattr(data, property)
+ ret = []
+ idxs = []
+ idx = 0
+
+ for item in attrs:
+ ret.append(self.bitflag_filter_item if not item.temporary else 0)
+ idxs.append(idx)
+
+ idx += 1
+
+ return ret, idxs
+
def draw_item(self, _context, layout, _data, attribute, _icon, _active_data, _active_propname, _index):
data_type = attribute.bl_rna.properties['data_type'].enum_items[attribute.data_type]
diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h
index 3cc4fb9c9cf..a47981ca1f5 100644
--- a/source/blender/blenkernel/BKE_attribute.h
+++ b/source/blender/blenkernel/BKE_attribute.h
@@ -99,7 +99,7 @@ void BKE_id_attributes_active_set(struct ID *id, struct CustomDataLayer *layer);
int *BKE_id_attributes_active_index_p(struct ID *id);
CustomData *BKE_id_attributes_iterator_next_domain(struct ID *id, struct CustomDataLayer *layers);
-CustomDataLayer *BKE_id_attribute_from_index(const struct ID *id, int lookup_index);
+CustomDataLayer *BKE_id_attribute_from_index(const struct ID *id, int lookup_index, const AttributeDomainMask domain_mask);
struct AttributeRef *BKE_id_attributes_active_color_ref_p(struct ID *id);
void BKE_id_attributes_active_color_set(struct ID *id, struct CustomDataLayer *active_layer);
diff --git a/source/blender/blenkernel/intern/attribute.c b/source/blender/blenkernel/intern/attribute.c
index 340e1a957bb..9f0373288ca 100644
--- a/source/blender/blenkernel/intern/attribute.c
+++ b/source/blender/blenkernel/intern/attribute.c
@@ -301,7 +301,9 @@ CustomDataLayer *BKE_id_attribute_find(const ID *id,
return NULL;
}
-CustomDataLayer *BKE_id_attribute_from_index(const ID *id, int lookup_index)
+CustomDataLayer *BKE_id_attribute_from_index(const ID *id,
+ int lookup_index,
+ const AttributeDomainMask domain_mask)
{
DomainInfo info[ATTR_DOMAIN_NUM];
get_domains(id, info);
@@ -310,7 +312,7 @@ CustomDataLayer *BKE_id_attribute_from_index(const ID *id, int lookup_index)
for (AttributeDomain domain = 0; domain < ATTR_DOMAIN_NUM; domain++) {
CustomData *customdata = info[domain].customdata;
- if (!customdata) {
+ if (!customdata || !((1 << (int)domain) & domain_mask)) {
continue;
}
@@ -486,7 +488,7 @@ void BKE_id_attributes_active_color_set(ID *id, CustomDataLayer *active_layer)
{
AttributeRef *ref = BKE_id_attributes_active_color_ref_p(id);
- if (!ref) {
+ if (!ref || !ref->type) {
fprintf(stderr, "%s: vertex colors not supported for this type\n", __func__);
return;
}
@@ -535,7 +537,7 @@ CustomDataLayer *BKE_id_attributes_render_color_get(ID *id)
{
AttributeRef *ref = BKE_id_attributes_render_color_ref_p(id);
- if (!ref) {
+ if (!ref || !ref->type) {
fprintf(stderr, "%s: vertex colors not supported for this type\n", __func__);
return NULL;
}
diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc
index f10b4a3f1c5..b6987341acb 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -153,6 +153,9 @@ static void mesh_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int
/* XXX This is not nice, we need to make BKE_id_copy_ex fully re-entrant... */
mesh_dst->key->from = &mesh_dst->id;
}
+
+ mesh_dst->attr_color_active = mesh_src->attr_color_active;
+ mesh_dst->attr_color_render = mesh_src->attr_color_render;
}
static void mesh_free_data(ID *id)
@@ -1016,6 +1019,9 @@ void BKE_mesh_copy_parameters(Mesh *me_dst, const Mesh *me_src)
me_dst->face_sets_color_seed = me_src->face_sets_color_seed;
me_dst->face_sets_color_default = me_src->face_sets_color_default;
+ me_dst->attr_color_active = me_src->attr_color_active;
+ me_dst->attr_color_render = me_src->attr_color_render;
+
/* Copy texture space. */
me_dst->texflag = me_src->texflag;
copy_v3_v3(me_dst->loc, me_src->loc);
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc
index 979f1915273..804771453fa 100644
--- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc
@@ -24,6 +24,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_string.h"
+#include "BKE_object.h"
#include "extract_mesh.h"
@@ -33,7 +34,7 @@ namespace blender::draw {
/** \name Extract VCol
* \{ */
-static void extract_vcol_init(const MeshRenderData *mr,
+ATTR_NO_OPT static void extract_vcol_init(const MeshRenderData *mr,
struct MeshBatchCache *cache,
void *buf,
void *UNUSED(tls_data))
@@ -41,7 +42,7 @@ static void extract_vcol_init(const MeshRenderData *mr,
GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
GPUVertFormat format = {0};
GPU_vertformat_deinterleave(&format);
-
+
CustomData *cd_vdata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->vdata : &mr->me->vdata;
CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata;
diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt
index 31b2e1d7941..db9b49b8cf3 100644
--- a/source/blender/editors/datafiles/CMakeLists.txt
+++ b/source/blender/editors/datafiles/CMakeLists.txt
@@ -742,6 +742,7 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
brush.particle.puff
brush.particle.smooth
brush.particle.weight
+ brush.sculpt.array
brush.sculpt.blob
brush.sculpt.boundary
brush.sculpt.clay
@@ -755,6 +756,7 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
brush.sculpt.draw_face_sets
brush.sculpt.draw_sharp
brush.sculpt.elastic_deform
+ brush.sculpt.fairing
brush.sculpt.fill
brush.sculpt.flatten
brush.sculpt.grab
@@ -763,16 +765,20 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
brush.sculpt.mask
brush.sculpt.multiplane_scrape
brush.sculpt.nudge
+ brush.sculpt.paint
brush.sculpt.pinch
brush.sculpt.pose
brush.sculpt.rotate
+ brush.sculpt.scene_project
brush.sculpt.scrape
brush.sculpt.simplify
+ brush.sculpt.smear
brush.sculpt.smooth
brush.sculpt.snake_hook
brush.sculpt.thumb
brush.sculpt.topology
brush.sculpt.twist
+ brush.sculpt.vcol_boundary
brush.uv_sculpt.grab
brush.uv_sculpt.pinch
brush.uv_sculpt.relax
@@ -864,6 +870,8 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
ops.sculpt.lasso_trim
ops.sculpt.line_mask
ops.sculpt.line_project
+ ops.sculpt.mask_by_color
+ ops.sculpt.mask_select
ops.sculpt.mesh_filter
ops.sequencer.blade
ops.transform.bone_envelope
diff --git a/source/blender/editors/geometry/geometry_attributes.c b/source/blender/editors/geometry/geometry_attributes.c
index ea56d6e1716..558b7ae5573 100644
--- a/source/blender/editors/geometry/geometry_attributes.c
+++ b/source/blender/editors/geometry/geometry_attributes.c
@@ -240,3 +240,58 @@ void GEOMETRY_OT_attribute_remove(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+
+
+static int geometry_color_attribute_remove_exec(bContext *C, wmOperator *op)
+{
+ Object *ob = ED_object_context(C);
+ ID *id = ob->data;
+ CustomDataLayer *layer = BKE_id_attributes_active_color_get(id);
+
+ if (layer == NULL) {
+ return OPERATOR_CANCELLED;
+ }
+
+ if (!BKE_id_attribute_remove(id, layer, op->reports)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ int *active_index = BKE_id_attributes_active_index_p(id);
+ if (*active_index > 0) {
+ *active_index -= 1;
+ }
+
+ DEG_id_tag_update(id, ID_RECALC_GEOMETRY);
+ WM_main_add_notifier(NC_GEOM | ND_DATA, id);
+
+ return OPERATOR_FINISHED;
+}
+
+static bool geometry_color_attributes_remove_poll(bContext *C)
+{
+ if (!geometry_attributes_poll(C)) {
+ return false;
+ }
+
+ Object *ob = ED_object_context(C);
+ ID *data = (ob) ? ob->data : NULL;
+ if (BKE_id_attributes_active_color_get(data) != NULL) {
+ return true;
+ }
+
+ return false;
+}
+void GEOMETRY_OT_co
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list