Sculpt-dev: fix smooth_strength_factor bug
* Fixed bug where BRUSH_MAPPING_INHERIT was being or'd to BrushMapping->flag instead of assigned to ->inherit_mode. * Fixed smooth_strength_factor and smooth_strength_projection. * Also added yet more asan poisoning to mempool * Added a function to build final inherited brush channel, BKE_brush_channel_copy_final_data. Takes BrushMapping->inherit_mode into account.
This commit is contained in:
parent
7f933459a8
commit
9f45edd430
|
@ -39,7 +39,7 @@ extern "C" {
|
|||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 3
|
||||
#define BLENDER_FILE_SUBVERSION 4
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and show a warning if the file
|
||||
|
|
|
@ -249,6 +249,18 @@ void BKE_brush_channelset_merge(BrushChannelSet *dst,
|
|||
BrushChannelSet *child,
|
||||
BrushChannelSet *parent);
|
||||
|
||||
/*takes child and parent channels and builds inherited channel
|
||||
in dst, with channel and brush mapping inheritance flags
|
||||
properly resolved.
|
||||
|
||||
note that child or parent may be NULL, but not both.
|
||||
*/
|
||||
void BKE_brush_channel_copy_final_data(BrushChannel *dst,
|
||||
BrushChannel *src_child,
|
||||
BrushChannel *src_parent,
|
||||
bool keep_mapping,
|
||||
bool keep_idname_and_def);
|
||||
|
||||
void BKE_brush_resolve_channels(struct Brush *brush, struct Sculpt *sd);
|
||||
|
||||
void BKE_brush_channelset_set_final_int(BrushChannelSet *brushset,
|
||||
|
@ -309,10 +321,10 @@ int BKE_brush_channel_get_vector(BrushChannel *ch, float out[4], BrushMappingDat
|
|||
|
||||
/* returns size of vector */
|
||||
int BKE_brush_channelset_get_final_vector(BrushChannelSet *brushset,
|
||||
BrushChannelSet *toolset,
|
||||
const char *idname,
|
||||
float r_vec[4],
|
||||
BrushMappingData *mapdata);
|
||||
BrushChannelSet *toolset,
|
||||
const char *idname,
|
||||
float r_vec[4],
|
||||
BrushMappingData *mapdata);
|
||||
void BKE_brush_channelset_set_final_vector(BrushChannelSet *brushset,
|
||||
BrushChannelSet *toolset,
|
||||
const char *idname,
|
||||
|
|
|
@ -477,7 +477,7 @@ CustomDataLayer *BKE_id_attributes_active_color_get(ID *id)
|
|||
}
|
||||
|
||||
if (!ref->type) {
|
||||
fprintf(stderr, "%s: invalid active color attribute\n", __func__);
|
||||
//fprintf(stderr, "%s: invalid active color attribute\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ void BKE_id_attributes_active_color_set(ID *id, CustomDataLayer *active_layer)
|
|||
if (customdata) {
|
||||
for (int i = 0; i < customdata->totlayer; i++) {
|
||||
CustomDataLayer *layer = &customdata->layers[i];
|
||||
|
||||
|
||||
if (layer == active_layer && ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CORNER)) {
|
||||
ref->type = layer->type;
|
||||
ref->domain = domain;
|
||||
|
@ -548,7 +548,7 @@ CustomDataLayer *BKE_id_attributes_render_color_get(ID *id)
|
|||
}
|
||||
|
||||
if (!ref->type) {
|
||||
fprintf(stderr, "%s: invalid render color attribute\n", __func__);
|
||||
//fprintf(stderr, "%s: invalid render color attribute\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
# pragma warning(error : 4018) /* signed/unsigned mismatch */
|
||||
# pragma warning(error : 4245) /* conversion from 'int' to 'unsigned int' */
|
||||
# pragma warning(error : 4389) /* signed/unsigned mismatch */
|
||||
# pragma warning(error : 4002) /* too many actual parameters for macro 'identifier' */
|
||||
# pragma warning(error : 4002) /* too many actual maeters for macro 'identifier' */
|
||||
# pragma warning(error : 4003) /* not enough actual parameters for macro 'identifier' */
|
||||
# pragma warning( \
|
||||
error : 4022) /* 'function': pointer mismatch for actual parameter 'parameter number' */
|
||||
|
@ -328,6 +328,53 @@ static void copy_channel_data_keep_mappings(BrushChannel *dst,
|
|||
}
|
||||
}
|
||||
|
||||
void BKE_brush_channel_copy_final_data(BrushChannel *dst,
|
||||
BrushChannel *src_child,
|
||||
BrushChannel *src_parent,
|
||||
bool keep_mapping,
|
||||
bool keep_idname_and_def)
|
||||
{
|
||||
if (!src_child || !src_parent) {
|
||||
BKE_brush_channel_copy_data(
|
||||
dst, src_child ? src_child : src_parent, keep_mapping, keep_idname_and_def);
|
||||
return;
|
||||
}
|
||||
|
||||
if (src_child->flag & BRUSH_CHANNEL_INHERIT) {
|
||||
BKE_brush_channel_copy_data(dst, src_parent, keep_mapping, keep_idname_and_def);
|
||||
}
|
||||
else {
|
||||
BKE_brush_channel_copy_data(dst, src_child, keep_mapping, keep_idname_and_def);
|
||||
}
|
||||
|
||||
if (keep_mapping) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < BRUSH_MAPPING_MAX; i++) {
|
||||
BrushMapping *mp = NULL;
|
||||
|
||||
switch (src_child->mappings[i].inherit_mode) {
|
||||
case BRUSH_MAPPING_INHERIT_CHANNEL:
|
||||
mp = src_child->flag & BRUSH_CHANNEL_INHERIT ? src_parent->mappings + i :
|
||||
src_child->mappings + i;
|
||||
break;
|
||||
case BRUSH_MAPPING_INHERIT_ALWAYS:
|
||||
mp = src_parent->mappings + i;
|
||||
break;
|
||||
case BRUSH_MAPPING_INHERIT_NEVER:
|
||||
mp = src_child->mappings + i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (UNLIKELY(!mp)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BKE_brush_mapping_copy_data(dst->mappings + i, mp);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_brush_channel_copy_data(BrushChannel *dst,
|
||||
BrushChannel *src,
|
||||
bool keep_mapping,
|
||||
|
@ -463,7 +510,7 @@ void BKE_brush_channel_init(BrushChannel *ch, BrushChannelType *def)
|
|||
}
|
||||
|
||||
if (mdef->inherit) {
|
||||
mp->flag |= BRUSH_MAPPING_INHERIT_ALWAYS;
|
||||
mp->inherit_mode = BRUSH_MAPPING_INHERIT_ALWAYS;
|
||||
}
|
||||
|
||||
int slope = CURVEMAP_SLOPE_POSITIVE;
|
||||
|
@ -840,10 +887,8 @@ void BKE_brush_channelset_merge(BrushChannelSet *dst,
|
|||
BKE_brush_channel_copy_data(mch, pch, true, false);
|
||||
}
|
||||
|
||||
/*apply mapping inheritance flags, which are respected
|
||||
for non inherited channels. note that absense
|
||||
of BRUSH_MAPPING_FLAG doen't prevent mapping inheritance
|
||||
if BRUSH_CHANNEL_INHERIT in ch->flag *is* set.*/
|
||||
/* apply mapping inheritance flags, which are respected
|
||||
even for non inherited channels.*/
|
||||
for (int i = 0; i < BRUSH_MAPPING_MAX; i++) {
|
||||
if (brush_mapping_inherits(ch, ch->mappings + i)) {
|
||||
BKE_brush_mapping_copy_data(mch->mappings + i, pch->mappings + i);
|
||||
|
|
|
@ -274,6 +274,7 @@ static bool check_builtin_init()
|
|||
|
||||
for (int j = 0; j < BRUSH_MAPPING_MAX; j++) {
|
||||
(&def->mappings.pressure)[j].inherit = true;
|
||||
(&def->mappings.pressure)[j].enabled = i == 0 && j == 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2877,6 +2877,10 @@ static void long_edge_queue_create(EdgeQueueContext *eq_ctx,
|
|||
// deal with non-manifold iffyness
|
||||
destroy_nonmanifold_fins(pbvh, e);
|
||||
push_subentry = true;
|
||||
|
||||
if (bm_elem_is_free((BMElem *)e, BM_EDGE)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
MSculptVert *mv1 = BKE_PBVH_SCULPTVERT(cd_sculpt_vert, e->v1);
|
||||
|
@ -3798,6 +3802,13 @@ static BMVert *pbvh_bmesh_collapse_edge(PBVH *pbvh,
|
|||
}
|
||||
|
||||
do {
|
||||
BMLoop *l2 = l;
|
||||
do {
|
||||
if (BM_ELEM_CD_GET_INT(l2->v, pbvh->cd_vert_node_offset) != DYNTOPO_NODE_NONE) {
|
||||
pbvh_bmesh_vert_remove(pbvh, l2->v);
|
||||
}
|
||||
} while ((l2 = l2->next) != l);
|
||||
|
||||
if (BM_ELEM_CD_GET_INT(l->f, pbvh->cd_face_node_offset) != DYNTOPO_NODE_NONE) {
|
||||
pbvh_bmesh_face_remove(pbvh, l->f, false, false, false);
|
||||
BM_log_face_topo_pre(pbvh->bm_log, l->f);
|
||||
|
|
|
@ -1084,6 +1084,12 @@ bool BKE_paint_ensure(ToolSettings *ts, struct Paint **r_paint)
|
|||
Sculpt *data = MEM_callocN(sizeof(*data), __func__);
|
||||
paint = &data->paint;
|
||||
|
||||
if (!data->channels) {
|
||||
data->channels = BKE_brush_channelset_create(__func__);
|
||||
}
|
||||
|
||||
BKE_brush_check_toolsettings(data);
|
||||
|
||||
/* Turn on X plane mirror symmetry by default */
|
||||
paint->symmetry_flags |= PAINT_SYMM_X;
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ Topology rake:
|
|||
|
||||
#include "bmesh.h"
|
||||
#include "pbvh_intern.h"
|
||||
#include "atomic_ops.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
@ -75,7 +76,7 @@ Topology rake:
|
|||
|
||||
#include <stdarg.h>
|
||||
|
||||
static void _debugprint(const char *fmt, ...)
|
||||
ATTR_NO_OPT static void _debugprint(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
@ -84,7 +85,7 @@ static void _debugprint(const char *fmt, ...)
|
|||
}
|
||||
|
||||
#ifdef PBVH_BMESH_DEBUG
|
||||
void pbvh_bmesh_check_nodes_simple(PBVH *pbvh)
|
||||
ATTR_NO_OPT void pbvh_bmesh_check_nodes_simple(PBVH *pbvh)
|
||||
{
|
||||
for (int i = 0; i < pbvh->totnode; i++) {
|
||||
PBVHNode *node = pbvh->nodes + i;
|
||||
|
@ -108,7 +109,7 @@ void pbvh_bmesh_check_nodes_simple(PBVH *pbvh)
|
|||
}
|
||||
}
|
||||
|
||||
void pbvh_bmesh_check_nodes(PBVH *pbvh)
|
||||
ATTR_NO_OPT void pbvh_bmesh_check_nodes(PBVH *pbvh)
|
||||
{
|
||||
for (int i = 0; i < pbvh->totnode; i++) {
|
||||
PBVHNode *node = pbvh->nodes + i;
|
||||
|
@ -125,12 +126,12 @@ void pbvh_bmesh_check_nodes(PBVH *pbvh)
|
|||
int ni = BM_ELEM_CD_GET_INT(v, pbvh->cd_vert_node_offset);
|
||||
|
||||
if (ni >= 0 && (!v->e || !v->e->l)) {
|
||||
_debugprint("wire vert had node reference\n");
|
||||
BM_ELEM_CD_SET_INT(v, pbvh->cd_vert_node_offset, DYNTOPO_NODE_NONE);
|
||||
_debugprint("wire vert had node reference: %p (type %d)\n", v, v->head.htype);
|
||||
//BM_ELEM_CD_SET_INT(v, pbvh->cd_vert_node_offset, DYNTOPO_NODE_NONE);
|
||||
}
|
||||
|
||||
if (ni < -1 || ni >= pbvh->totnode) {
|
||||
_debugprint("vert node ref was invalid");
|
||||
_debugprint("vert node ref was invalid: %p (type %d)\n", v, v->head.htype);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -229,7 +230,7 @@ void pbvh_bmesh_check_nodes(PBVH *pbvh)
|
|||
}
|
||||
}
|
||||
|
||||
void pbvh_bmesh_pbvh_bmesh_check_nodes(PBVH *pbvh)
|
||||
ATTR_NO_OPT void pbvh_bmesh_pbvh_bmesh_check_nodes(PBVH *pbvh)
|
||||
{
|
||||
pbvh_bmesh_check_nodes(pbvh);
|
||||
}
|
||||
|
@ -1575,9 +1576,14 @@ static void pbvh_bmesh_create_leaf_fast_task_cb(void *__restrict userdata,
|
|||
do {
|
||||
BMVert *v = l_iter->v;
|
||||
|
||||
if (BM_ELEM_CD_GET_INT(v, pbvh->cd_vert_node_offset) == DYNTOPO_NODE_NONE) {
|
||||
int old = BM_ELEM_CD_GET_INT(
|
||||
v, pbvh->cd_vert_node_offset);
|
||||
|
||||
char *ptr = (char *)v;
|
||||
ptr += pbvh->cd_vert_node_offset;
|
||||
|
||||
if (old == DYNTOPO_NODE_NONE && atomic_cas_int32((int32_t*)ptr, DYNTOPO_NODE_NONE, node_index) == DYNTOPO_NODE_NONE) {
|
||||
BLI_table_gset_insert(n->bm_unique_verts, v);
|
||||
BM_ELEM_CD_SET_INT(v, pbvh->cd_vert_node_offset, node_index);
|
||||
}
|
||||
else {
|
||||
BLI_table_gset_add(n->bm_other_verts, v);
|
||||
|
|
|
@ -343,6 +343,8 @@ BLI_INLINE PBVHNode *pbvh_bmesh_node_from_face(PBVH *pbvh, const BMFace *key)
|
|||
|
||||
bool pbvh_bmesh_node_limit_ensure(PBVH *pbvh, int node_index);
|
||||
|
||||
//#define PBVH_BMESH_DEBUG
|
||||
|
||||
#ifdef PBVH_BMESH_DEBUG
|
||||
void pbvh_bmesh_check_nodes(PBVH *pbvh);
|
||||
void pbvh_bmesh_check_nodes_simple(PBVH *pbvh);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2575,6 +2575,64 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 301, 4)) {
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
if (!scene->toolsettings || !scene->toolsettings->sculpt ||
|
||||
!scene->toolsettings->sculpt->channels) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BrushChannelSet *chset = scene->toolsettings->sculpt->channels;
|
||||
|
||||
BrushChannel *ch1 = BRUSHSET_LOOKUP(chset, smooth_strength_factor);
|
||||
BrushChannel *ch2 = BRUSHSET_LOOKUP(chset, smooth_strength_projection);
|
||||
|
||||
for (int i = 0; i < BRUSH_MAPPING_MAX; i++) {
|
||||
if (ch1) {
|
||||
ch1->mappings[i].inherit_mode = BRUSH_MAPPING_INHERIT_ALWAYS;
|
||||
|
||||
if (i == 0) {
|
||||
ch1->mappings[i].flag |= BRUSH_MAPPING_ENABLED;
|
||||
}
|
||||
else {
|
||||
ch1->mappings[i].flag &= ~BRUSH_MAPPING_ENABLED;
|
||||
}
|
||||
}
|
||||
|
||||
if (ch2) {
|
||||
ch2->mappings[i].inherit_mode = BRUSH_MAPPING_INHERIT_ALWAYS;
|
||||
ch2->mappings[i].flag &= ~BRUSH_MAPPING_ENABLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
|
||||
if (!brush->channels) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BrushChannel *ch1 = BRUSHSET_LOOKUP(brush->channels, smooth_strength_factor);
|
||||
BrushChannel *ch2 = BRUSHSET_LOOKUP(brush->channels, smooth_strength_projection);
|
||||
|
||||
for (int i = 0; i < BRUSH_MAPPING_MAX; i++) {
|
||||
if (ch1) {
|
||||
ch1->mappings[i].inherit_mode = BRUSH_MAPPING_INHERIT_ALWAYS;
|
||||
|
||||
if (i == 0) {
|
||||
ch1->mappings[i].flag |= BRUSH_MAPPING_ENABLED;
|
||||
}
|
||||
else {
|
||||
ch1->mappings[i].flag &= ~BRUSH_MAPPING_ENABLED;
|
||||
}
|
||||
}
|
||||
|
||||
if (ch2) {
|
||||
ch2->mappings[i].inherit_mode = BRUSH_MAPPING_INHERIT_ALWAYS;
|
||||
ch2->mappings[i].flag &= ~BRUSH_MAPPING_ENABLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
|
|
|
@ -2259,7 +2259,7 @@ static char *obj_append_line(char *line, char *str, char *fixed, int *size, int
|
|||
return str;
|
||||
}
|
||||
|
||||
static char *bm_save_local_obj_text(
|
||||
ATTR_NO_OPT static char *bm_save_local_obj_text(
|
||||
BMesh *bm, int depth, char buf[LOCAL_OBJ_SIZE], const char *fmt, ...)
|
||||
{
|
||||
va_list vl;
|
||||
|
@ -2512,7 +2512,11 @@ static void trigger_jvke_error(int err, char *obj_text)
|
|||
printf("========= ERROR %s============\n\n%s\n\n", get_err_str(err), obj_text);
|
||||
}
|
||||
|
||||
#if JVKE_DEBUG
|
||||
char *_last_local_obj = NULL;
|
||||
|
||||
//#define JVKE_DEBUG
|
||||
|
||||
#ifdef JVKE_DEBUG
|
||||
# define JVKE_CHECK_ELEMENT(elem) \
|
||||
{ \
|
||||
int err = 0; \
|
||||
|
@ -2531,7 +2535,7 @@ BMVert *bmesh_kernel_join_vert_kill_edge(
|
|||
|
||||
#ifdef JVKE_DEBUG
|
||||
char buf[LOCAL_OBJ_SIZE];
|
||||
char *saved_obj = bm_save_local_obj_text(bm, 2, buf, "e", e);
|
||||
char *saved_obj = _last_local_obj = bm_save_local_obj_text(bm, 2, buf, "e", e);
|
||||
bm_local_obj_free(saved_obj, buf);
|
||||
#endif
|
||||
|
||||
|
@ -2760,6 +2764,7 @@ BMVert *bmesh_kernel_join_vert_kill_edge(
|
|||
|
||||
JVKE_CHECK_ELEMENT(v_conn);
|
||||
|
||||
#ifdef JVKE_DEBUG
|
||||
for (int step = 0; step < 2; step++) {
|
||||
BMVert *v = step ? v_conn : v_del;
|
||||
BMEdge *e1 = v->e;
|
||||
|
@ -2782,6 +2787,7 @@ BMVert *bmesh_kernel_join_vert_kill_edge(
|
|||
} while ((e1 = BM_DISK_EDGE_NEXT(e1, v)) != v->e);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// printf("v_del: %p, v_conn: %p\n", v_del->e, v_conn->e);
|
||||
if (do_del) {
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
/* returns positive nonzero on error */
|
||||
|
||||
#ifdef NDEBUG
|
||||
#if 1//def NDEBUG
|
||||
/* No error checking for release,
|
||||
* it can take most of the CPU time when running some tools. */
|
||||
# define BM_CHECK_ELEMENT(el) (void)(el)
|
||||
|
|
|
@ -5783,6 +5783,28 @@ static void get_nodes_undo(Sculpt *sd,
|
|||
data->totnode = totnode;
|
||||
}
|
||||
|
||||
static void sculpt_apply_alt_smmoth_settings(SculptSession *ss, Sculpt *sd, Brush *brush)
|
||||
{
|
||||
float factor = BRUSHSET_GET_FLOAT(ss->cache->channels_final, smooth_strength_factor, NULL);
|
||||
float projection = BRUSHSET_GET_FLOAT(
|
||||
ss->cache->channels_final, smooth_strength_projection, NULL);
|
||||
|
||||
BRUSHSET_SET_FLOAT(ss->cache->channels_final, strength, factor);
|
||||
BRUSHSET_SET_FLOAT(ss->cache->channels_final, projection, projection);
|
||||
|
||||
BrushChannel *ch = BRUSHSET_LOOKUP(brush->channels, smooth_strength_factor);
|
||||
BrushChannel *parentch = BRUSHSET_LOOKUP(sd->channels, smooth_strength_factor);
|
||||
|
||||
BKE_brush_channel_copy_final_data(
|
||||
BRUSHSET_LOOKUP(ss->cache->channels_final, strength), ch, parentch, false, true);
|
||||
|
||||
ch = BRUSHSET_LOOKUP(brush->channels, smooth_strength_projection);
|
||||
parentch = BRUSHSET_LOOKUP(sd->channels, smooth_strength_projection);
|
||||
|
||||
BKE_brush_channel_copy_final_data(
|
||||
BRUSHSET_LOOKUP(ss->cache->channels_final, projection), ch, parentch, false, true);
|
||||
}
|
||||
|
||||
static void SCULPT_run_command(
|
||||
Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSettings *ups, void *userdata)
|
||||
{
|
||||
|
@ -6072,23 +6094,6 @@ static void SCULPT_run_commandlist(
|
|||
SculptSession *ss = ob->sculpt;
|
||||
Brush *oldbrush = ss->cache->brush;
|
||||
|
||||
if (ss->cache->alt_smooth && SCULPT_get_tool(ss, brush) == SCULPT_TOOL_SMOOTH) {
|
||||
float factor = BRUSHSET_GET_FLOAT(ss->cache->channels_final, smooth_strength_factor, NULL);
|
||||
float projection = BRUSHSET_GET_FLOAT(
|
||||
ss->cache->channels_final, smooth_strength_projection, NULL);
|
||||
|
||||
BRUSHSET_SET_FLOAT(ss->cache->channels_final, strength, factor);
|
||||
BRUSHSET_SET_FLOAT(ss->cache->channels_final, projection, projection);
|
||||
|
||||
BrushChannel *ch = BRUSHSET_LOOKUP(ss->cache->channels_final, smooth_strength_factor);
|
||||
BKE_brush_channel_copy_data(
|
||||
BRUSHSET_LOOKUP(ss->cache->channels_final, strength), ch, false, true);
|
||||
|
||||
ch = BRUSHSET_LOOKUP(ss->cache->channels_final, smooth_strength_projection);
|
||||
BKE_brush_channel_copy_data(
|
||||
BRUSHSET_LOOKUP(ss->cache->channels_final, projection), ch, false, true);
|
||||
}
|
||||
|
||||
int totnode = 0;
|
||||
PBVHNode **nodes = NULL;
|
||||
|
||||
|
@ -6097,6 +6102,10 @@ static void SCULPT_run_commandlist(
|
|||
float radius_scale = 1.0f;
|
||||
float radius_max = 0.0f;
|
||||
|
||||
if (ss->cache && ss->cache->alt_smooth && ss->cache->tool_override == SCULPT_TOOL_SMOOTH) {
|
||||
sculpt_apply_alt_smmoth_settings(ss, sd, brush);
|
||||
}
|
||||
|
||||
BKE_brush_commandlist_start(list, brush, ss->cache->channels_final);
|
||||
|
||||
// this does a more high-level check then SCULPT_TOOL_HAS_DYNTOPO;
|
||||
|
@ -7023,8 +7032,8 @@ static void sculpt_update_cache_invariants(
|
|||
bContext *C, Sculpt *sd, SculptSession *ss, wmOperator *op, const float mouse[2])
|
||||
{
|
||||
StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache");
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
// Main *bmain = CTX_data_main(C);
|
||||
// Scene *scene = CTX_data_scene(C);
|
||||
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
|
||||
Brush *brush = BKE_paint_brush(&sd->paint);
|
||||
ViewContext *vc = paint_stroke_view_context(op->customdata);
|
||||
|
@ -7124,6 +7133,12 @@ static void sculpt_update_cache_invariants(
|
|||
/* Do nothing, this tool has its own smooth mode. */
|
||||
}
|
||||
else {
|
||||
if (!cache->tool_override_channels) {
|
||||
cache->tool_override_channels = sculpt_init_tool_override_channels(
|
||||
sd, ss, SCULPT_TOOL_SMOOTH);
|
||||
cache->tool_override = SCULPT_TOOL_SMOOTH;
|
||||
}
|
||||
#if 0
|
||||
Paint *p = &sd->paint;
|
||||
Brush *br;
|
||||
int size = BKE_brush_size_get(scene, brush, true);
|
||||
|
@ -7140,6 +7155,7 @@ static void sculpt_update_cache_invariants(
|
|||
BKE_brush_size_set(scene, brush, size, paint_use_channels(C));
|
||||
BKE_curvemapping_init(brush->curve);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8401,7 +8417,7 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const f
|
|||
channels = sculpt_init_tool_override_channels(sd, ob->sculpt, tool);
|
||||
}
|
||||
|
||||
//paranoia check to correct corrupted brushes
|
||||
// paranoia check to correct corrupted brushes
|
||||
BKE_brush_builtin_patch(brush, brush->sculpt_tool);
|
||||
|
||||
BKE_brush_channelset_compat_load(sculpt_get_brush_channels(ob->sculpt, brush), brush, false);
|
||||
|
@ -8486,21 +8502,8 @@ void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerR
|
|||
ss->cache->use_plane_trim = BRUSHSET_GET_INT(
|
||||
ss->cache->channels_final, use_plane_trim, &ss->cache->input_mapping);
|
||||
|
||||
if (ss->cache->alt_smooth) {
|
||||
Brush *brush = (Brush *)BKE_libblock_find_name(
|
||||
CTX_data_main(C), ID_BR, ss->cache->saved_active_brush_name);
|
||||
|
||||
if (brush) {
|
||||
// some settings should not be overridden
|
||||
|
||||
bool hard_edge = BRUSHSET_GET_FINAL_INT(
|
||||
brush->channels, sd->channels ? sd->channels : NULL, hard_edge_mode, NULL);
|
||||
float smooth_factor = BRUSHSET_GET_FINAL_FLOAT(
|
||||
brush->channels, sd->channels ? sd->channels : NULL, smooth_strength_factor, NULL);
|
||||
|
||||
BRUSHSET_SET_INT(ss->cache->channels_final, hard_edge_mode, hard_edge);
|
||||
BRUSHSET_SET_FLOAT(ss->cache->channels_final, smooth_strength_factor, smooth_factor);
|
||||
}
|
||||
if (ss->cache->alt_smooth && ss->cache->tool_override == SCULPT_TOOL_SMOOTH) {
|
||||
sculpt_apply_alt_smmoth_settings(ss, sd, brush);
|
||||
}
|
||||
|
||||
// load settings into brush and unified paint settings
|
||||
|
@ -8586,20 +8589,6 @@ void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerR
|
|||
detail_range);
|
||||
}
|
||||
|
||||
if (0 && !ss->cache->commandlist && SCULPT_stroke_is_dynamic_topology(ss, brush)) {
|
||||
float spacing = (float)brush->cached_dyntopo.spacing / 100.0f;
|
||||
|
||||
if (paint_stroke_apply_subspacing(
|
||||
ss->cache->stroke, spacing, PAINT_MODE_SCULPT, &ss->cache->last_dyntopo_t)) {
|
||||
do_symmetrical_brush_actions(sd, ob, sculpt_topology_update, ups, NULL);
|
||||
|
||||
if (SCULPT_get_tool(ss, brush) == SCULPT_TOOL_SNAKE_HOOK) {
|
||||
/* run dyntopo again for snake hook */
|
||||
do_symmetrical_brush_actions(sd, ob, sculpt_topology_update, ups, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool run_commandlist = brush_uses_commandlist(brush, SCULPT_get_tool(ss, brush));
|
||||
|
||||
if (run_commandlist) {
|
||||
|
@ -8616,6 +8605,10 @@ void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerR
|
|||
tool = SCULPT_TOOL_RELAX;
|
||||
}
|
||||
|
||||
if (ss->cache->alt_smooth && ss->cache->tool_override == SCULPT_TOOL_SMOOTH) {
|
||||
sculpt_apply_alt_smmoth_settings(ss, sd, brush);
|
||||
}
|
||||
|
||||
BKE_builtin_commandlist_create(
|
||||
brush, ss->cache->channels_final, list, tool, &ss->cache->input_mapping);
|
||||
}
|
||||
|
@ -8711,9 +8704,7 @@ static void sculpt_brush_exit_tex(Sculpt *sd)
|
|||
|
||||
static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(stroke))
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
|
||||
|
||||
|
@ -8743,11 +8734,12 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
|
|||
/* Do nothing. */
|
||||
}
|
||||
else {
|
||||
/*
|
||||
BKE_brush_size_set(scene, brush, ss->cache->saved_smooth_size, true);
|
||||
brush = (Brush *)BKE_libblock_find_name(bmain, ID_BR, ss->cache->saved_active_brush_name);
|
||||
if (brush) {
|
||||
BKE_paint_brush_set(&sd->paint, brush);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1177,7 +1177,7 @@ double area_tri_v3_db(const double v1[3], const double v2[3], const double v3[3]
|
|||
return len_v3_db(n) * 0.5;
|
||||
}
|
||||
|
||||
ATTR_NO_OPT static UVSmoothTri *uvsolver_ensure_face(UVSolver *solver, BMFace *f)
|
||||
static UVSmoothTri *uvsolver_ensure_face(UVSolver *solver, BMFace *f)
|
||||
{
|
||||
void **entry = NULL;
|
||||
|
||||
|
@ -1405,7 +1405,7 @@ static void uvsolver_solve_begin(UVSolver *solver)
|
|||
}
|
||||
}
|
||||
|
||||
ATTR_NO_OPT static void uvsolver_simple_relax(UVSolver *solver, float strength)
|
||||
static void uvsolver_simple_relax(UVSolver *solver, float strength)
|
||||
{
|
||||
BLI_mempool_iter iter;
|
||||
|
||||
|
@ -1434,7 +1434,7 @@ ATTR_NO_OPT static void uvsolver_simple_relax(UVSolver *solver, float strength)
|
|||
|
||||
bool sign = sv1->neighbor_tris[i]->area2d < 0.0f;
|
||||
|
||||
//try to unfold folded uvs
|
||||
// try to unfold folded uvs
|
||||
if (totneighbor > 0 && sign != lastsign) {
|
||||
strength2 = 1.0;
|
||||
}
|
||||
|
@ -1730,7 +1730,7 @@ void SCULPT_uv_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
|
|||
|
||||
UVSolver *solver = uvsolver_new(cd_uv);
|
||||
solver->cd_sculpt_vert = ss->cd_sculpt_vert;
|
||||
//solver->strength = powf(fabs(ss->cache->bstrength), 0.25) * signf(ss->cache->bstrength);
|
||||
// solver->strength = powf(fabs(ss->cache->bstrength), 0.25) * signf(ss->cache->bstrength);
|
||||
solver->strength = ss->cache->bstrength;
|
||||
|
||||
/* Threaded loop over nodes. */
|
||||
|
|
|
@ -113,9 +113,9 @@ static EnumPropertyItem prop_color_filter_types[] = {
|
|||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
ATTR_NO_OPT static void color_filter_task_cb(void *__restrict userdata,
|
||||
const int n,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
static void color_filter_task_cb(void *__restrict userdata,
|
||||
const int n,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
{
|
||||
SculptThreadedTaskData *data = userdata;
|
||||
SculptSession *ss = data->ob->sculpt;
|
||||
|
|
|
@ -1653,6 +1653,10 @@ void SCULPT_smooth(Sculpt *sd,
|
|||
int iteration, count;
|
||||
float last;
|
||||
|
||||
if (bstrength == 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SCULPT_stroke_is_first_brush_step(ss->cache) &&
|
||||
((ss->cache->brush->flag2 & BRUSH_SMOOTH_USE_AREA_WEIGHT) ||
|
||||
ss->cache->brush->boundary_smooth_factor > 0.0f)) {
|
||||
|
@ -1734,7 +1738,8 @@ void SCULPT_smooth(Sculpt *sd,
|
|||
#else
|
||||
const float strength = last;
|
||||
#endif
|
||||
// turn off velocity smooth for final iteration or two to smooth out ripples
|
||||
|
||||
/* turn off velocity smooth for final iteration or two to smooth out ripples */
|
||||
bool do_vel = do_vel_smooth && iteration != count;
|
||||
|
||||
if (count > 1) {
|
||||
|
|
Loading…
Reference in New Issue