[Bf-blender-cvs] [7a21cc4f70f] sculpt-dev: Sculpt-dev: Fix brush curves being allocated in error.
Joseph Eagar
noreply at git.blender.org
Thu May 12 04:54:30 CEST 2022
Commit: 7a21cc4f70f7e12527a8523066ff86c196d4cb3e
Author: Joseph Eagar
Date: Wed May 11 19:53:45 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rB7a21cc4f70f7e12527a8523066ff86c196d4cb3e
Sculpt-dev: Fix brush curves being allocated in error.
===================================================================
M release/datafiles/startup.blend
M source/blender/blenkernel/intern/brush_engine.c
M source/blender/blenkernel/intern/curvemapping_cache.c
M source/blender/blenkernel/intern/customdata.cc
M source/blender/editors/sculpt_paint/sculpt_brush_types.c
===================================================================
diff --git a/release/datafiles/startup.blend b/release/datafiles/startup.blend
index cc16b16e21a..de64cd00d26 100644
Binary files a/release/datafiles/startup.blend and b/release/datafiles/startup.blend differ
diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index 87ce6db9f75..efd4008a467 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -127,7 +127,7 @@ void BKE_brush_channel_system_exit()
}
/* returns true if curve was duplicated or initialized. */
-ATTR_NO_OPT bool BKE_brush_mapping_ensure_write(BrushMapping *mp)
+bool BKE_brush_mapping_ensure_write(BrushMapping *mp)
{
if (mp->mapping_curve.curve && IS_CACHE_CURVE(mp->mapping_curve.curve)) {
@@ -186,6 +186,10 @@ void BKE_brush_channel_curve_assign(BrushChannel *ch, BrushCurve *curve)
// returns true if curve was duplicated
bool BKE_brush_channel_curve_ensure_write(BrushCurve *curve)
{
+ if (curve->preset != BRUSH_CURVE_CUSTOM) {
+ return false;
+ }
+
BKE_brush_channel_curvemapping_get(curve, true);
if (IS_CACHE_CURVE(curve->curve)) {
@@ -468,9 +472,7 @@ void BKE_brush_channel_copy_data(BrushChannel *dst,
if (src->curve.curve) {
if (!IS_CACHE_CURVE(src->curve.curve)) {
- // dst->curve = GET_CACHE_CURVE(src->curve);
-
- // hrm, let's not modify src->curve, GET_CACHE_CURVE might free it
+ /* Can't use GET_CACHE_CURVE macro since it will free src->curve.curve. */
dst->curve.curve = BKE_curvemapping_cache_get(brush_curve_cache, src->curve.curve, false);
}
else {
@@ -1075,10 +1077,10 @@ static bool channel_has_mappings(BrushChannel *ch)
}
/* idx is used by vector channels */
-ATTR_NO_OPT double BKE_brush_channel_eval_mappings(BrushChannel *ch,
- BrushMappingData *mapdata,
- double f,
- int idx)
+double BKE_brush_channel_eval_mappings(BrushChannel *ch,
+ BrushMappingData *mapdata,
+ double f,
+ int idx)
{
if (idx == 3 && !(ch->flag & BRUSH_CHANNEL_APPLY_MAPPING_TO_ALPHA)) {
@@ -2024,7 +2026,7 @@ void BKE_brush_channelset_foreach_id(void *userdata,
// for now, do nothing; in the future brush textures (might) have ID references
}
-ATTR_NO_OPT void BKE_brush_channelset_read(BlendDataReader *reader, BrushChannelSet *chset)
+void BKE_brush_channelset_read(BlendDataReader *reader, BrushChannelSet *chset)
{
BLO_read_list(reader, &chset->channels);
@@ -2130,7 +2132,7 @@ ATTR_NO_OPT void BKE_brush_channelset_read(BlendDataReader *reader, BrushChannel
}
}
-ATTR_NO_OPT void BKE_brush_channelset_write(BlendWriter *writer, BrushChannelSet *chset)
+void BKE_brush_channelset_write(BlendWriter *writer, BrushChannelSet *chset)
{
/* Instantiate cached curves to ensure they get written
* (and susequently read) seperately.
@@ -2139,7 +2141,7 @@ ATTR_NO_OPT void BKE_brush_channelset_write(BlendWriter *writer, BrushChannelSet
LISTBASE_FOREACH (BrushChannel *, ch, &chset->channels) {
BKE_brush_channel_curve_ensure_write(&ch->curve);
- if (ch->curve.curve) {
+ if (ch->type == BRUSH_CHANNEL_TYPE_CURVE && ch->curve.curve) {
BKE_curvemapping_blend_write(writer, ch->curve.curve);
}
diff --git a/source/blender/blenkernel/intern/curvemapping_cache.c b/source/blender/blenkernel/intern/curvemapping_cache.c
index 675d3e71d7a..82c38d9ba8e 100644
--- a/source/blender/blenkernel/intern/curvemapping_cache.c
+++ b/source/blender/blenkernel/intern/curvemapping_cache.c
@@ -62,7 +62,7 @@ static int curvmapping_curve_count(const CurveMapping *cumap)
return count;
}
-ATTR_NO_OPT bool BKE_curvemapping_equals(const CurveMapping *a, const CurveMapping *b)
+bool BKE_curvemapping_equals(const CurveMapping *a, const CurveMapping *b)
{
int count = curvmapping_curve_count(a);
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index ee52e9cb134..7e849b72522 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -4980,12 +4980,10 @@ void CustomData_blend_write_prepare(CustomData *data,
for (i = 0, j = 0; i < totlayer; i++) {
CustomDataLayer *layer = &data->layers[i];
- printf("layer: %d %s %d\n", layer->type, layer->name ? layer->name : "", layer->flag);
/* Layers with this flag set are not written to file. */
if ((layer->flag & (CD_FLAG_NOCOPY | CD_FLAG_TEMPORARY)) || layer->anonymous_id != nullptr) {
data->totlayer--;
- printf("skipping layer %p (%s)", layer, layer->name);
// CLOG_WARN(&LOG, "skipping layer %p (%s)", layer, layer->name);
}
else {
diff --git a/source/blender/editors/sculpt_paint/sculpt_brush_types.c b/source/blender/editors/sculpt_paint/sculpt_brush_types.c
index db7711c6e9d..24423078258 100644
--- a/source/blender/editors/sculpt_paint/sculpt_brush_types.c
+++ b/source/blender/editors/sculpt_paint/sculpt_brush_types.c
@@ -373,10 +373,6 @@ void SCULPT_do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
mul_v3_v3(offset, ss->cache->scale);
mul_v3_fl(offset, bstrength);
- /* XXX: this shouldn't be necessary, but sculpting crashes in blender2.8 otherwise
- * initialize before threads so they can do curve mapping. */
- BKE_curvemapping_init(brush->curve);
-
/* Threaded loop over nodes. */
SculptThreadedTaskData data = {
.sd = sd,
@@ -2726,7 +2722,7 @@ void SCULPT_do_elastic_deform_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in
/** \name Sculpt Draw Sharp Brush
* \{ */
-ATTR_NO_OPT static void do_draw_sharp_brush_task_cb_ex(void *__restrict userdata,
+static void do_draw_sharp_brush_task_cb_ex(void *__restrict userdata,
const int n,
const TaskParallelTLS *__restrict tls)
{
@@ -2876,10 +2872,6 @@ void SCULPT_do_draw_sharp_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
mul_v3_v3(offset, ss->cache->scale);
mul_v3_fl(offset, bstrength);
- /* XXX: this shouldn't be necessary, but sculpting crashes in blender2.8 otherwise
- * initialize before threads so they can do curve mapping. */
- BKE_curvemapping_init(brush->curve);
-
/* Threaded loop over nodes. */
SculptThreadedTaskData data = {
.sd = sd,
@@ -3690,10 +3682,6 @@ void SCULPT_do_auto_face_set(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
return;
}
- /* XXX: this shouldn't be necessary, but sculpting crashes in blender2.8 otherwise
- * initialize before threads so they can do curve mapping. */
- BKE_curvemapping_init(brush->curve);
-
/* Threaded loop over nodes. */
SculptFaceSetDrawData data = {
.sd = sd,
@@ -4300,7 +4288,7 @@ static void do_displacement_heal_cb(void *__restrict userdata,
float mat[3][3], p[3];
BKE_subdiv_ccg_get_tangent_matrix(ss->subdiv_ccg, &coord, mat, p);
- memcpy((void *)mats[locali], (void*)mat, sizeof(mat));
+ memcpy((void *)mats[locali], (void *)mat, sizeof(mat));
invert_m3(mat);
More information about the Bf-blender-cvs
mailing list