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:
authorJoseph Eagar <joeedh@gmail.com>2022-03-31 13:54:44 +0300
committerJoseph Eagar <joeedh@gmail.com>2022-03-31 13:54:44 +0300
commit2c29a94531225fe4f8d77171647016e37261de31 (patch)
tree225467fe2c53184f5c00ed0f3dd55a0d67c9cbc0 /source/blender
parentf55c46ca65155366d9f63b431c81236c9541cc69 (diff)
temp-sculpt-colors: make requested changes
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_attribute.h16
-rw-r--r--source/blender/blenkernel/BKE_paint.h6
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h12
-rw-r--r--source/blender/blenkernel/intern/attribute.c26
-rw-r--r--source/blender/blenkernel/intern/brush.c3
-rw-r--r--source/blender/blenkernel/intern/data_transfer.c1
-rw-r--r--source/blender/blenkernel/intern/pbvh.c8
-rw-r--r--source/blender/blenkernel/intern/pbvh.cc62
-rw-r--r--source/blender/blenkernel/intern/pbvh_intern.h2
-rw-r--r--source/blender/blenloader/intern/versioning_300.c98
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh_render_data.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c122
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc22
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c3
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c3
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_filter_mesh.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_ops.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c7
19 files changed, 211 insertions, 188 deletions
diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h
index 1bf2d7ca18e..b47e7e572cf 100644
--- a/source/blender/blenkernel/BKE_attribute.h
+++ b/source/blender/blenkernel/BKE_attribute.h
@@ -92,7 +92,7 @@ int BKE_id_attribute_to_index(const struct ID *id,
AttributeDomainMask domain_mask,
CustomDataMask layer_mask);
-struct CustomDataLayer *BKE_id_attribute_subset_active_get(struct ID *id,
+struct CustomDataLayer *BKE_id_attribute_subset_active_get(const struct ID *id,
int active_flag,
AttributeDomainMask domain_mask,
CustomDataMask mask);
@@ -102,11 +102,11 @@ void BKE_id_attribute_subset_active_set(struct ID *id,
AttributeDomainMask domain_mask,
CustomDataMask mask);
-/** Copies CustomData instances into a (usually stack-allocated) ID. This is a shallow copy, the
- * purpose is to create a bride for using the C attribute API on arbitrary sets of CustomData
- * domains.
+/**
+ * Copies CustomData instances into a (usually stack-allocated) ID. This is a shallow copy, the
+ * purpose is to create a bride for using the C attribute API on arbitrary sets of CustomData
+ * domains.
*/
-
void BKE_id_attribute_copy_domains_temp(struct ID *temp_id,
const struct CustomData *vdata,
const struct CustomData *edata,
@@ -114,12 +114,12 @@ void BKE_id_attribute_copy_domains_temp(struct ID *temp_id,
const struct CustomData *pdata,
const struct CustomData *cdata);
-struct CustomDataLayer *BKE_id_attributes_active_color_get(struct ID *id);
+struct CustomDataLayer *BKE_id_attributes_active_color_get(const struct ID *id);
void BKE_id_attributes_active_color_set(struct ID *id, struct CustomDataLayer *active_layer);
-struct CustomDataLayer *BKE_id_attributes_render_color_get(struct ID *id);
+struct CustomDataLayer *BKE_id_attributes_render_color_get(const struct ID *id);
void BKE_id_attributes_render_color_set(struct ID *id, struct CustomDataLayer *active_layer);
-bool BKE_id_attribute_find_unique_name(struct ID *id, const char *name, char *outname);
+bool BKE_id_attribute_calc_unique_name(struct ID *id, const char *name, char *outname);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 5c83cbe6e63..5633c476dc1 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -12,6 +12,8 @@
#include "DNA_brush_enums.h"
#include "DNA_object_enums.h"
+#include "BKE_attribute.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -495,8 +497,8 @@ typedef struct SculptSession {
struct MPropCol *vcol;
struct MLoopCol *mcol;
- int vcol_domain;
- int vcol_type;
+ AttributeDomain vcol_domain;
+ CustomDataType vcol_type;
float *vmask;
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index acbc4778555..c6c8e1dffa7 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -528,19 +528,19 @@ const float (*BKE_pbvh_get_vert_normals(const PBVH *pbvh))[3];
PBVHColorBufferNode *BKE_pbvh_node_color_buffer_get(PBVHNode *node);
void BKE_pbvh_node_color_buffer_free(PBVH *pbvh);
bool BKE_pbvh_get_color_layer(const struct Mesh *me,
- CustomDataLayer **cl_out,
- AttributeDomain *attr_out);
+ CustomDataLayer **r_layer,
+ AttributeDomain *r_attr);
/* Swaps colors at each element in indices (of domain pbvh->vcol_domain)
* with values in colors. */
-void BKE_pbvh_swap_colors(PBVH *pbvh, float (*colors)[4], int *indices, int totelem);
+void BKE_pbvh_swap_colors(PBVH *pbvh, float (*colors)[4], int *indices, int elem_num);
/* Stores colors from the elements in indices (of domain pbvh->vcol_domain)
* into colors. */
-void BKE_pbvh_store_colors(PBVH *pbvh, float (*colors)[4], int *indices, int totelem);
+void BKE_pbvh_store_colors(PBVH *pbvh, float (*colors)[4], int *indices, int elem_num);
/* Like BKE_pbvh_store_colors but handles loop->vert conversion */
-void BKE_pbvh_store_colors_vertex(PBVH *pbvh, float (*colors)[4], int *indices, int totelem);
+void BKE_pbvh_store_colors_vertex(PBVH *pbvh, float (*colors)[4], int *indices, int elem_num);
bool BKE_pbvh_is_drawing(const PBVH *pbvh);
void BKE_pbvh_is_drawing_set(PBVH *pbvh, bool val);
@@ -554,7 +554,7 @@ void BKE_pbvh_pmap_set(PBVH *pbvh, const struct MeshElemMap *pmap);
void BKE_pbvh_vertex_color_set(PBVH *pbvh, int vertex, const float color[4]);
void BKE_pbvh_vertex_color_get(PBVH *pbvh, int vertex, float r_color[4]);
-void BKE_pbvh_ensure_node_loops(PBVH *pbvh, const struct Mesh *me);
+void BKE_pbvh_ensure_node_loops(PBVH *pbvh);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/intern/attribute.c b/source/blender/blenkernel/intern/attribute.c
index 60457ec5367..ad7fea4b78e 100644
--- a/source/blender/blenkernel/intern/attribute.c
+++ b/source/blender/blenkernel/intern/attribute.c
@@ -162,7 +162,7 @@ static bool unique_name_cb(void *arg, const char *name)
return false;
}
-bool BKE_id_attribute_find_unique_name(ID *id, const char *name, char *outname)
+bool BKE_id_attribute_calc_unique_name(ID *id, const char *name, char *outname)
{
AttrUniqueData data = {.id = id};
@@ -184,7 +184,7 @@ CustomDataLayer *BKE_id_attribute_new(
}
char uniquename[MAX_CUSTOMDATA_LAYER_NAME];
- BKE_id_attribute_find_unique_name(id, name, uniquename);
+ BKE_id_attribute_calc_unique_name(id, name, uniquename);
switch (GS(id->name)) {
case ID_ME: {
@@ -500,14 +500,14 @@ int BKE_id_attribute_to_index(const struct ID *id,
CustomData *cdata = info[domains[i]].customdata;
for (int j = 0; j < cdata->totlayer; j++) {
- CustomDataLayer *layer2 = cdata->layers + j;
+ CustomDataLayer *layer_iter = cdata->layers + j;
- if (!(CD_TYPE_AS_MASK(layer2->type) & layer_mask) ||
- (CD_TYPE_AS_MASK(layer2->type) & CD_FLAG_TEMPORARY)) {
+ if (!(CD_TYPE_AS_MASK(layer_iter->type) & layer_mask) ||
+ (CD_TYPE_AS_MASK(layer_iter->type) & CD_FLAG_TEMPORARY)) {
continue;
}
- if (layer == layer2) {
+ if (layer == layer_iter) {
return index;
}
@@ -518,7 +518,7 @@ int BKE_id_attribute_to_index(const struct ID *id,
return -1;
}
-CustomDataLayer *BKE_id_attribute_subset_active_get(ID *id,
+CustomDataLayer *BKE_id_attribute_subset_active_get(const ID *id,
int active_flag,
AttributeDomainMask domain_mask,
CustomDataMask mask)
@@ -578,21 +578,21 @@ void BKE_id_attribute_subset_active_set(ID *id,
CustomData *cdata = info[domains[i]].customdata;
for (int j = 0; j < cdata->totlayer; j++) {
- CustomDataLayer *layer2 = cdata->layers + j;
+ CustomDataLayer *layer_iter = cdata->layers + j;
- if (!(CD_TYPE_AS_MASK(layer2->type) & mask) ||
- (CD_TYPE_AS_MASK(layer2->type) & CD_FLAG_TEMPORARY)) {
+ if (!(CD_TYPE_AS_MASK(layer_iter->type) & mask) ||
+ (CD_TYPE_AS_MASK(layer_iter->type) & CD_FLAG_TEMPORARY)) {
continue;
}
- layer2->flag &= ~active_flag;
+ layer_iter->flag &= ~active_flag;
}
}
layer->flag |= active_flag;
}
-CustomDataLayer *BKE_id_attributes_active_color_get(ID *id)
+CustomDataLayer *BKE_id_attributes_active_color_get(const ID *id)
{
return BKE_id_attribute_subset_active_get(
id, CD_FLAG_COLOR_ACTIVE, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL);
@@ -604,7 +604,7 @@ void BKE_id_attributes_active_color_set(ID *id, CustomDataLayer *active_layer)
id, active_layer, CD_FLAG_COLOR_ACTIVE, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL);
}
-CustomDataLayer *BKE_id_attributes_render_color_get(ID *id)
+CustomDataLayer *BKE_id_attributes_render_color_get(const ID *id)
{
return BKE_id_attribute_subset_active_get(
id, CD_FLAG_COLOR_RENDER, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL);
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index fa52051a2ea..8acb6092697 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -1833,8 +1833,7 @@ void BKE_brush_sculpt_reset(Brush *br)
br->tip_roundness = 1.0f;
br->density = 1.0f;
br->flag &= ~BRUSH_SPACE_ATTEN;
- zero_v3(br->rgb);
- add_v3_fl(br->rgb, 1.0f);
+ copy_v3_fl(br->rgb, 1.0f);
zero_v3(br->secondary_rgb);
break;
case SCULPT_TOOL_SMEAR:
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index ef002edb861..b7ec3a38817 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -49,7 +49,6 @@ void BKE_object_data_transfer_dttypes_to_cdmask(const int dtdata_types,
}
cddata_type = BKE_object_data_transfer_dttype_to_cdtype(dtdata_type);
-
if (!(cddata_type & CD_FAKE)) {
if (DT_DATATYPE_IS_VERT(dtdata_type)) {
r_data_masks->vmask |= 1LL << cddata_type;
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 613476e6401..2109652481c 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -3142,7 +3142,7 @@ void BKE_pbvh_node_num_loops(PBVH *pbvh, PBVHNode *node, int *r_totloop)
BLI_assert(BKE_pbvh_type(pbvh) == PBVH_FACES);
if (r_totloop) {
- *r_totloop = node->face_loops;
+ *r_totloop = node->indices_num;
}
}
@@ -3156,7 +3156,7 @@ void BKE_pbvh_pmap_set(PBVH *pbvh, const MeshElemMap *pmap)
pbvh->pmap = pmap;
}
-void BKE_pbvh_ensure_node_loops(PBVH *pbvh, const Mesh *me)
+void BKE_pbvh_ensure_node_loops(PBVH *pbvh)
{
BLI_assert(BKE_pbvh_type(pbvh) == PBVH_FACES);
@@ -3188,14 +3188,14 @@ void BKE_pbvh_ensure_node_loops(PBVH *pbvh, const Mesh *me)
}
node->loop_indices = MEM_malloc_arrayN(node->totprim * 3, sizeof(int), __func__);
- node->face_loops = 0;
+ node->indices_num = 0;
for (int j = 0; j < node->totprim; j++) {
const MLoopTri *mlt = pbvh->looptri + node->prim_indices[j];
for (int k = 0; k < 3; k++) {
if (!BLI_BITMAP_TEST(visit, mlt->tri[k])) {
- node->loop_indices[node->face_loops++] = mlt->tri[k];
+ node->loop_indices[node->indices_num++] = mlt->tri[k];
BLI_BITMAP_ENABLE(visit, mlt->tri[k]);
}
}
diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc
index 122307f0117..223f2055cdc 100644
--- a/source/blender/blenkernel/intern/pbvh.cc
+++ b/source/blender/blenkernel/intern/pbvh.cc
@@ -43,13 +43,13 @@ using IndexRange = blender::IndexRange;
struct MLoopColHelper {
using ColType = MLoopCol;
- static void toFloat(MLoopCol *col, float r_color[4])
+ static void to_float(MLoopCol *col, float r_color[4])
{
rgba_uchar_to_float(r_color, reinterpret_cast<const unsigned char *>(col));
srgb_to_linearrgb_v3_v3(r_color, r_color);
}
- static void fromFloat(MLoopCol *col, const float color[4])
+ static void from_float(MLoopCol *col, const float color[4])
{
float temp[4];
@@ -63,12 +63,12 @@ struct MLoopColHelper {
struct MPropColHelper {
using ColType = MPropCol;
- static void toFloat(MPropCol *col, float r_color[4])
+ static void to_float(MPropCol *col, float r_color[4])
{
copy_v4_v4(r_color, col->color);
}
- static void fromFloat(MPropCol *col, const float color[4])
+ static void from_float(MPropCol *col, const float color[4])
{
copy_v4_v4(col->color, color);
}
@@ -82,9 +82,9 @@ template<typename Helper> struct ColorSetter {
*dst = *src;
}
- static void setFloat(ColType *dst, const float src[4])
+ static void set_float(ColType *dst, const float src[4])
{
- Helper::fromFloat(dst, src);
+ Helper::from_float(dst, src);
}
};
@@ -99,12 +99,12 @@ template<typename Helper> struct ColorSwapper {
*src = tmp;
}
- static void setFloat(ColType *dst, float src[4])
+ static void set_float(ColType *dst, float src[4])
{
ColType temp = *dst;
- Helper::fromFloat(dst, src);
- Helper::toFloat(&temp, src);
+ Helper::from_float(dst, src);
+ Helper::to_float(&temp, src);
}
};
@@ -117,9 +117,9 @@ template<typename Helper> struct ColorStorer {
*src = *dst;
}
- static void setFloat(ColType *dst, float src[4])
+ static void set_float(ColType *dst, float src[4])
{
- Helper::toFloat(dst, src);
+ Helper::to_float(dst, src);
}
};
@@ -128,7 +128,7 @@ static void pbvh_vertex_color_get(PBVH *pbvh, int vertex, float r_color[4])
{
if (pbvh->vcol_domain == ATTR_DOMAIN_CORNER) {
const MeshElemMap *melem = pbvh->pmap + vertex;
- int tot = 0;
+ int count = 0;
zero_v4(r_color);
@@ -142,22 +142,22 @@ static void pbvh_vertex_color_get(PBVH *pbvh, int vertex, float r_color[4])
for (int j = 0; j < mp->totloop; j++, col++, ml++) {
if (ml->v == vertex) {
float temp[4];
- Helper::toFloat(col, temp);
+ Helper::to_float(col, temp);
add_v4_v4(r_color, temp);
- tot++;
+ count++;
}
}
}
- if (tot) {
- mul_v4_fl(r_color, 1.0f / (float)tot);
+ if (count) {
+ mul_v4_fl(r_color, 1.0f / (float)count);
}
}
else {
typename Helper::ColType *col = static_cast<typename Helper::ColType *>(pbvh->vcol->data) +
vertex;
- Helper::toFloat(col, r_color);
+ Helper::to_float(col, r_color);
}
}
@@ -186,7 +186,7 @@ static void pbvh_vertex_color_set(PBVH *pbvh, int vertex, const float color[4])
for (int j = 0; j < mp->totloop; j++, col++, ml++) {
if (ml->v == vertex) {
- Setter::setFloat(col, color);
+ Setter::set_float(col, color);
}
}
}
@@ -194,7 +194,7 @@ static void pbvh_vertex_color_set(PBVH *pbvh, int vertex, const float color[4])
else {
typename Helper::ColType *col = static_cast<typename Helper::ColType *>(pbvh->vcol->data) +
vertex;
- Setter::setFloat(col, color);
+ Setter::set_float(col, color);
}
}
@@ -210,46 +210,46 @@ void BKE_pbvh_vertex_color_set(PBVH *pbvh, int vertex, const float color[4])
template<typename Helper, typename Setter = ColorSetter<Helper>>
static void pbvh_set_colors(
- PBVH *UNUSED(pbvh), void *color_attr, float (*colors)[4], int *indices, int totelem)
+ PBVH *UNUSED(pbvh), void *color_attr, float (*colors)[4], int *indices, int indices_num)
{
typename Helper::ColType *col = reinterpret_cast<typename Helper::ColType *>(color_attr);
- for (int i : IndexRange(totelem)) {
- Setter::setFloat(col + indices[i], colors[i]);
+ for (int i : IndexRange(indices_num)) {
+ Setter::set_float(col + indices[i], colors[i]);
}
}
-void BKE_pbvh_swap_colors(PBVH *pbvh, float (*colors)[4], int *indices, int totelem)
+void BKE_pbvh_swap_colors(PBVH *pbvh, float (*colors)[4], int *indices, int indices_num)
{
if (pbvh->vcol->type == CD_PROP_COLOR) {
pbvh_set_colors<MPropColHelper, ColorSwapper<MPropColHelper>>(
- pbvh, pbvh->vcol->data, colors, indices, totelem);
+ pbvh, pbvh->vcol->data, colors, indices, indices_num);
}
else {
pbvh_set_colors<MLoopColHelper, ColorSwapper<MLoopColHelper>>(
- pbvh, pbvh->vcol->data, colors, indices, totelem);
+ pbvh, pbvh->vcol->data, colors, indices, indices_num);
}
}
-void BKE_pbvh_store_colors(PBVH *pbvh, float (*colors)[4], int *indices, int totelem)
+void BKE_pbvh_store_colors(PBVH *pbvh, float (*colors)[4], int *indices, int indices_num)
{
if (pbvh->vcol->type == CD_PROP_COLOR) {
pbvh_set_colors<MPropColHelper, ColorStorer<MPropColHelper>>(
- pbvh, pbvh->vcol->data, colors, indices, totelem);
+ pbvh, pbvh->vcol->data, colors, indices, indices_num);
}
else {
pbvh_set_colors<MLoopColHelper, ColorStorer<MLoopColHelper>>(
- pbvh, pbvh->vcol->data, colors, indices, totelem);
+ pbvh, pbvh->vcol->data, colors, indices, indices_num);
}
}
-void BKE_pbvh_store_colors_vertex(PBVH *pbvh, float (*colors)[4], int *indices, int totelem)
+void BKE_pbvh_store_colors_vertex(PBVH *pbvh, float (*colors)[4], int *indices, int indices_num)
{
if (pbvh->vcol_domain == ATTR_DOMAIN_POINT) {
- BKE_pbvh_store_colors(pbvh, colors, indices, totelem);
+ BKE_pbvh_store_colors(pbvh, colors, indices, indices_num);
}
else {
- for (int i = 0; i < totelem; i++) {
+ for (int i = 0; i < indices_num; i++) {
BKE_pbvh_vertex_color_get(pbvh, indices[i], colors[i]);
}
}
diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h
index 0a3a04cec6f..910bece6a35 100644
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@ -67,7 +67,7 @@ struct PBVHNode {
* are loops unique to this node, see comment for
* vert_indices for more details.*/
int *loop_indices;
- unsigned int face_loops;
+ unsigned int indices_num;
/* An array mapping face corners into the vert_indices
* array. The array is sized to match 'totprim', and each of
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 5923f0eabf9..c675bc97d82 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -2437,54 +2437,6 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- /* Rebuild active/render color attribute references. */
- if (!MAIN_VERSION_ATLEAST(bmain, 302, 6)) {
- LISTBASE_FOREACH (Brush *, br, &bmain->brushes) {
- /* buggy code in wm_toolsystem broke smear in old files,
- reset to defaults */
- if (br->sculpt_tool == SCULPT_TOOL_SMEAR) {
- br->alpha = 1.0f;
- br->spacing = 5;
- br->flag &= ~BRUSH_ALPHA_PRESSURE;
- br->flag &= ~BRUSH_SPACE_ATTEN;
- br->curve_preset = BRUSH_CURVE_SPHERE;
- }
- }
-
- LISTBASE_FOREACH (Mesh *, me, &bmain->meshes) {
- for (int step = 0; step < 2; step++) {
- CustomDataLayer *actlayer = NULL;
-
- int vact1, vact2;
-
- if (step) {
- vact1 = CustomData_get_render_layer_index(&me->vdata, CD_PROP_COLOR);
- vact2 = CustomData_get_render_layer_index(&me->ldata, CD_MLOOPCOL);
- }
- else {
- vact1 = CustomData_get_active_layer_index(&me->vdata, CD_PROP_COLOR);
- vact2 = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPCOL);
- }
-
- if (vact1 != -1) {
- actlayer = me->vdata.layers + vact1;
- }
- else if (vact2 != -1) {
- actlayer = me->ldata.layers + vact2;
- }
-
- if (actlayer) {
- if (step) {
- BKE_id_attributes_render_color_set(&me->id, actlayer);
- }
- else {
- BKE_id_attributes_active_color_set(&me->id, actlayer);
- }
- }
- }
- }
- }
-
if (!MAIN_VERSION_ATLEAST(bmain, 302, 7)) {
/* Generate 'system' liboverrides IDs.
* NOTE: This is a fairly rough process, based on very basic heuristics. Should be enough for a
@@ -2537,6 +2489,56 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+
+ /* Rebuild active/render color attribute references. */
+ if (!MAIN_VERSION_ATLEAST(bmain, 302, 8)) {
+ LISTBASE_FOREACH (Brush *, br, &bmain->brushes) {
+ /* While vertex-colors were experimental the smear tool became corrupt due
+ * to bugs in the wm_toolsystem API (auto-creation of sculpt brushes
+ * was broken) so its values must be reset. */
+ if (br->sculpt_tool == SCULPT_TOOL_SMEAR) {
+ br->alpha = 1.0f;
+ br->spacing = 5;
+ br->flag &= ~BRUSH_ALPHA_PRESSURE;
+ br->flag &= ~BRUSH_SPACE_ATTEN;
+ br->curve_preset = BRUSH_CURVE_SPHERE;
+ }
+ }
+
+ LISTBASE_FOREACH (Mesh *, me, &bmain->meshes) {
+ for (int step = 0; step < 2; step++) {
+ CustomDataLayer *actlayer = NULL;
+
+ int vact1, vact2;
+
+ if (step) {
+ vact1 = CustomData_get_render_layer_index(&me->vdata, CD_PROP_COLOR);
+ vact2 = CustomData_get_render_layer_index(&me->ldata, CD_MLOOPCOL);
+ }
+ else {
+ vact1 = CustomData_get_active_layer_index(&me->vdata, CD_PROP_COLOR);
+ vact2 = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPCOL);
+ }
+
+ if (vact1 != -1) {
+ actlayer = me->vdata.layers + vact1;
+ }
+ else if (vact2 != -1) {
+ actlayer = me->ldata.layers + vact2;
+ }
+
+ if (actlayer) {
+ if (step) {
+ BKE_id_attributes_render_color_set(&me->id, actlayer);
+ }
+ else {
+ BKE_id_attributes_active_color_set(&me->id, actlayer);
+ }
+ }
+ }
+ }
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c
index 3a996920222..0a93f346b37 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c
@@ -445,9 +445,7 @@ MeshRenderData *mesh_render_data_create(Object *object,
BLI_assert(editmesh_eval_cage && editmesh_eval_final);
mr->bm = me->edit_mesh->bm;
mr->edit_bmesh = me->edit_mesh;
-
mr->me = (do_final) ? editmesh_eval_final : editmesh_eval_cage;
-
mr->edit_data = is_mode_active ? mr->me->runtime.edit_data : NULL;
if (mr->edit_data) {
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 778411b21b4..2a61e0a2857 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -459,16 +459,19 @@ static void mesh_cd_calc_active_mloopcol_layer(const Object *object,
DRW_MeshCDMask *cd_used)
{
const Mesh *me_final = editmesh_final_or_this(object, me);
- Mesh query_mesh = *me_final;
+ Mesh me_query = {0};
+
+ /* Copy name so ID type switch statement in BKE_id_attribute_copy_domains_temp works. */
+ BLI_strncpy(me_query.id.name, me_final->id.name, sizeof(me_final->id.name));
const CustomData *cd_vdata = mesh_cd_vdata_get_from_mesh(me_final);
const CustomData *cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
- BKE_id_attribute_copy_domains_temp(&query_mesh.id, cd_vdata, NULL, cd_ldata, NULL, NULL);
+ BKE_id_attribute_copy_domains_temp(&me_query.id, cd_vdata, NULL, cd_ldata, NULL, NULL);
- CustomDataLayer *layer = BKE_id_attributes_active_color_get(&query_mesh.id);
+ CustomDataLayer *layer = BKE_id_attributes_active_color_get(&me_query.id);
int layer_i = BKE_id_attribute_to_index(
- &query_mesh.id, layer, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL);
+ &me_query.id, layer, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL);
if (layer_i != -1) {
cd_used->vcol |= (1UL << (uint)layer_i);
@@ -505,6 +508,51 @@ static bool custom_data_match_attribute(const CustomData *custom_data,
return false;
}
+static uint mesh_cd_calc_gpu_layers_vcol_used(const Mesh *me_query,
+ const CustomData *cd_vdata,
+ const CustomData *cd_ldata,
+ const char name[])
+{
+ CustomDataLayer *layer = NULL;
+ AttributeDomain domain;
+
+ if (name[0]) {
+ int layer_i = 0;
+
+ domain = ATTR_DOMAIN_POINT;
+ layer_i = CustomData_get_named_layer_index(cd_vdata, CD_PROP_COLOR, name);
+ layer_i = layer_i == -1 ? CustomData_get_named_layer_index(cd_vdata, CD_MLOOPCOL, name) :
+ layer_i;
+
+ if (layer_i == -1) {
+ domain = ATTR_DOMAIN_CORNER;
+ layer_i = layer_i == -1 ? CustomData_get_named_layer_index(cd_ldata, CD_PROP_COLOR, name) :
+ layer_i;
+ layer_i = layer_i == -1 ? CustomData_get_named_layer_index(cd_ldata, CD_MLOOPCOL, name) :
+ layer_i;
+ }
+
+ /* Note: this is not the same as the layer_i below. */
+ if (layer_i != -1) {
+ layer = (domain == ATTR_DOMAIN_POINT ? cd_vdata : cd_ldata)->layers + layer_i;
+ }
+ }
+ else {
+ layer = BKE_id_attributes_render_color_get(&me_query->id);
+ }
+
+ if (!layer) {
+ return -1;
+ }
+
+ /* Note: this is the logical index into the color attribute list,
+ not the customdata index. */
+ int vcol_i = BKE_id_attribute_to_index(
+ (ID *)me_query, layer, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL);
+
+ return vcol_i;
+}
+
static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
const Mesh *me,
struct GPUMaterial **gpumat_array,
@@ -517,10 +565,14 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
const CustomData *cd_vdata = mesh_cd_vdata_get_from_mesh(me_final);
const CustomData *cd_edata = mesh_cd_edata_get_from_mesh(me_final);
- /* Create a local copy of mesh with final customdata domains
+ /* Create a mesh with final customdata domains
we can query. */
- Mesh query_mesh = *me;
- BKE_id_attribute_copy_domains_temp(&query_mesh.id, cd_vdata, cd_edata, cd_ldata, cd_pdata, NULL);
+ Mesh me_query = {0};
+
+ /* Copy name so ID type switch statement in BKE_id_attribute_copy_domains_temp works. */
+ BLI_strncpy(me_query.id.name, me_final->id.name, sizeof(me_final->id.name));
+
+ BKE_id_attribute_copy_domains_temp(&me_query.id, cd_vdata, cd_edata, cd_ldata, cd_pdata, NULL);
/* See: DM_vertex_attributes_from_gpu for similar logic */
DRW_MeshCDMask cd_used;
@@ -659,44 +711,7 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
case CD_MCOL:
case CD_MLOOPCOL:
case CD_PROP_COLOR: {
- CustomDataLayer *layer2 = NULL;
-
- if (name[0]) {
- int layer_i = 0;
-
- domain = ATTR_DOMAIN_POINT;
- layer_i = CustomData_get_named_layer_index(cd_vdata, CD_PROP_COLOR, name);
- layer_i = layer_i == -1 ?
- CustomData_get_named_layer_index(cd_vdata, CD_MLOOPCOL, name) :
- layer_i;
-
- if (layer_i == -1) {
- domain = ATTR_DOMAIN_CORNER;
- layer_i = layer_i == -1 ?
- CustomData_get_named_layer_index(cd_ldata, CD_PROP_COLOR, name) :
- layer_i;
- layer_i = layer_i == -1 ?
- CustomData_get_named_layer_index(cd_ldata, CD_MLOOPCOL, name) :
- layer_i;
- }
-
- /* Note: this is not the same as the layer_i below. */
- if (layer_i != -1) {
- layer2 = (domain == ATTR_DOMAIN_POINT ? cd_vdata : cd_ldata)->layers + layer_i;
- }
- }
- else {
- layer2 = BKE_id_attributes_render_color_get(&query_mesh.id);
- }
-
- if (!layer2) {
- break;
- }
-
- /* Note: this is the logical index into the color attribute list,
- not the customdata index. */
- int layer_i = BKE_id_attribute_to_index(
- (ID *)&query_mesh, layer2, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL);
+ int layer_i = mesh_cd_calc_gpu_layers_vcol_used(&me_query, cd_vdata, cd_ldata, name);
if (layer_i != -1) {
cd_used.vcol |= 1UL << (uint)layer_i;
@@ -704,7 +719,6 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
break;
}
-
case CD_PROP_FLOAT3:
case CD_PROP_BOOL:
case CD_PROP_INT8:
@@ -1203,16 +1217,20 @@ static void sculpt_request_active_vcol(MeshBatchCache *cache, Object *object, Me
const CustomData *cd_vdata = mesh_cd_vdata_get_from_mesh(me_final);
const CustomData *cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
- Mesh query_mesh = *me_final;
- BKE_id_attribute_copy_domains_temp(&query_mesh.id, cd_vdata, NULL, cd_ldata, NULL, NULL);
+ Mesh me_query = {0};
+
+ /* Copy name so ID type switch statement in BKE_id_attribute_copy_domains_temp works. */
+ BLI_strncpy(me_query.id.name, me_final->id.name, sizeof(me_final->id.name));
+
+ BKE_id_attribute_copy_domains_temp(&me_query.id, cd_vdata, NULL, cd_ldata, NULL, NULL);
- CustomDataLayer *active = BKE_id_attributes_active_color_get(&query_mesh.id);
- CustomDataLayer *render = BKE_id_attributes_render_color_get(&query_mesh.id);
+ CustomDataLayer *active = BKE_id_attributes_active_color_get(&me_query.id);
+ CustomDataLayer *render = BKE_id_attributes_render_color_get(&me_query.id);
int active_i = BKE_id_attribute_to_index(
- &query_mesh.id, active, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL);
+ &me_query.id, active, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL);
int render_i = BKE_id_attribute_to_index(
- &query_mesh.id, render, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL);
+ &me_query.id, render, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL);
if (active_i >= 0) {
cache->cd_used.vcol |= 1UL << (uint)active_i;
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 bf235c23243..35d106f5a6a 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
@@ -143,12 +143,15 @@ static void extract_vcol_init(const MeshRenderData *mr,
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;
- Mesh query_mesh = *mr->me;
- BKE_id_attribute_copy_domains_temp(
- &query_mesh.id, cd_vdata, nullptr, cd_ldata, nullptr, nullptr);
+ Mesh me_query = {0};
- CustomDataLayer *active_color = BKE_id_attributes_active_color_get(&query_mesh.id);
- CustomDataLayer *render_color = BKE_id_attributes_render_color_get(&query_mesh.id);
+ /* Copy name so ID type switch statement in BKE_id_attribute_copy_domains_temp works. */
+ BLI_strncpy(me_query.id.name, mr->me->id.name, sizeof(mr->me->id.name));
+
+ BKE_id_attribute_copy_domains_temp(&me_query.id, cd_vdata, nullptr, cd_ldata, nullptr, nullptr);
+
+ CustomDataLayer *active_color = BKE_id_attributes_active_color_get(&me_query.id);
+ CustomDataLayer *render_color = BKE_id_attributes_render_color_get(&me_query.id);
const uint32_t vcol_layers = cache->cd_used.vcol;
init_vcol_format(&format, cache, cd_vdata, cd_ldata, active_color, render_color);
@@ -255,12 +258,11 @@ static void extract_vcol_init_subdiv(const DRWSubdivCache *subdiv_cache,
const CustomData *cd_ldata = extract_bmesh ? &coarse_mesh->edit_mesh->bm->ldata :
&coarse_mesh->ldata;
- Mesh query_mesh = *coarse_mesh;
- BKE_id_attribute_copy_domains_temp(
- reinterpret_cast<ID *>(&query_mesh), cd_vdata, nullptr, cd_ldata, nullptr, nullptr);
+ Mesh me_query = *coarse_mesh;
+ BKE_id_attribute_copy_domains_temp(&me_query.id, cd_vdata, nullptr, cd_ldata, nullptr, nullptr);
- CustomDataLayer *active_color = BKE_id_attributes_active_color_get(&query_mesh.id);
- CustomDataLayer *render_color = BKE_id_attributes_render_color_get(&query_mesh.id);
+ CustomDataLayer *active_color = BKE_id_attributes_active_color_get(&me_query.id);
+ CustomDataLayer *render_color = BKE_id_attributes_render_color_get(&me_query.id);
GPUVertFormat format = {0};
init_vcol_format(
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 36dac998303..5929aa75b45 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -707,7 +707,8 @@ static void sculpt_gesture_apply(bContext *C, SculptGestureContext *sgcontext)
operation->sculpt_gesture_end(C, sgcontext);
- SCULPT_undo_push_end(CTX_data_active_object(C));
+ Object *ob = CTX_data_active_object(C);
+ SCULPT_undo_push_end(ob);
SCULPT_tag_update_overlays(C);
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index e3d632b72f5..092f3e33302 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -195,7 +195,6 @@ bool vertex_paint_mode_poll(bContext *C)
return false;
}
- return true;
CustomDataLayer *layer = BKE_id_attributes_active_color_get((ID *)ob->data);
AttributeDomain domain = BKE_id_attribute_domain((ID *)ob->data, layer);
@@ -3568,7 +3567,7 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot)
/* identifiers */
ot->name = "Vertex Paint";
ot->idname = "PAINT_OT_vertex_paint";
- ot->description = "Paint a stroke in the active vertex color layer";
+ ot->description = "Paint a stroke in the active color attribute layer";
/* api callbacks */
ot->invoke = vpaint_invoke;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 177e1e3a923..dbdf5acf505 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3183,7 +3183,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
return;
}
- BKE_pbvh_ensure_node_loops(ss->pbvh, BKE_object_get_original_mesh(ob));
+ BKE_pbvh_ensure_node_loops(ss->pbvh);
}
/* Build a list of all nodes that are potentially within the brush's area of influence */
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
index 248c03aaf80..4b832256dae 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
@@ -111,7 +111,7 @@ void SCULPT_filter_cache_init(bContext *C, Object *ob, Sculpt *sd, const int und
ss->filter_cache->random_seed = rand();
if (undo_type == SCULPT_UNDO_COLOR) {
- BKE_pbvh_ensure_node_loops(ss->pbvh, BKE_object_get_original_mesh(ob));
+ BKE_pbvh_ensure_node_loops(ss->pbvh);
}
const float center[3] = {0.0f};
diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c
index 5fed80f5913..f84852d1d0e 100644
--- a/source/blender/editors/sculpt_paint/sculpt_ops.c
+++ b/source/blender/editors/sculpt_paint/sculpt_ops.c
@@ -1035,7 +1035,7 @@ static int sculpt_mask_by_color_invoke(bContext *C, wmOperator *op, const wmEven
}
if (SCULPT_has_loop_colors(ob)) {
- BKE_pbvh_ensure_node_loops(ss->pbvh, BKE_object_get_original_mesh(ob));
+ BKE_pbvh_ensure_node_loops(ss->pbvh);
}
SCULPT_vertex_random_access_ensure(ss);
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index f3026b36e70..fb6805b0dc5 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -1408,9 +1408,12 @@ SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
if (unode->loop_index) {
BKE_pbvh_node_num_loops(ss->pbvh, unode->node, &allloop);
BKE_pbvh_node_get_loops(ss->pbvh, unode->node, &loop_indices, NULL);
- memcpy(unode->loop_index, loop_indices, sizeof(int) * allloop);
- unode->maxloop = BKE_object_get_original_mesh(ob)->totloop;
+ if (allloop) {
+ memcpy(unode->loop_index, loop_indices, sizeof(int) * allloop);
+
+ unode->maxloop = BKE_object_get_original_mesh(ob)->totloop;
+ }
}
}