Sculpt: move dyntopo command to top of command list.

* Dyntopo is now run before other commands in the
  brush command lists.
* Fixed nasty command subspacing bug.
* Added a missing RNA library override flag.
This commit is contained in:
Joseph Eagar 2021-10-17 15:02:49 -07:00
parent c14fa10d56
commit f7bf7bec99
4 changed files with 24 additions and 15 deletions

View File

@ -1585,6 +1585,9 @@ static void bke_builtin_commandlist_create_paint(Brush *brush,
autosmooth_spacing = BRUSHSET_GET_FLOAT(chset, spacing, NULL);
}
bool hard_edge_mode = BRUSHSET_GET_INT(chset, hard_edge_mode, NULL);
commandlist_add_dyntopo(chset, cl, brush, tool, hard_edge_mode, radius);
float autosmooth = BRUSHSET_GET_FLOAT(chset, autosmooth, NULL);
if (autosmooth > 0.0f) {
cmd = BKE_brush_command_init(BKE_brush_commandlist_add(cl, chset, true), SCULPT_TOOL_SMOOTH);
@ -1625,9 +1628,6 @@ static void bke_builtin_commandlist_create_paint(Brush *brush,
#undef GETF
bool hard_edge_mode = BRUSHSET_GET_INT(chset, hard_edge_mode, NULL);
commandlist_add_dyntopo(chset, cl, brush, tool, hard_edge_mode, radius);
// float
}
@ -1679,13 +1679,17 @@ void BKE_builtin_commandlist_create(Brush *brush,
return;
}
float radius = BKE_brush_channelset_get_float(chset, "radius", NULL);
/* build dyntopo command */
commandlist_add_dyntopo(chset, cl, brush, tool, hard_edge_mode, radius);
/* build main brush command */
cmd = BKE_brush_commandlist_add(cl, chset, true);
BKE_brush_command_init(cmd, tool);
BKE_builtin_apply_hard_edge_mode(cmd->params, hard_edge_mode);
BKE_brush_commandset_inherit_all_mappings(cmd->params);
float radius = BKE_brush_channelset_get_float(chset, "radius", NULL);
bool no_autosmooth = ELEM(tool, SCULPT_TOOL_BOUNDARY, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_MASK);
bool no_rake = ELEM(tool, SCULPT_TOOL_BOUNDARY, SCULPT_TOOL_MASK);
;
@ -1787,9 +1791,6 @@ void BKE_builtin_commandlist_create(Brush *brush,
BKE_brush_commandset_inherit_all_mappings(cmd->params);
}
/* build dyntopo command */
commandlist_add_dyntopo(chset, cl, brush, tool, hard_edge_mode, radius);
}
void BKE_brush_channelset_read_lib(BlendLibReader *reader, ID *id, BrushChannelSet *chset)

View File

@ -582,8 +582,6 @@ BLI_INLINE void surface_smooth_v_safe(PBVH *pbvh, BMVert *v, float fac)
copy_v3_v3(origno1, dot_v3v3(mv1->origno, mv1->origno) == 0.0f ? v->no : mv1->origno);
}
// BKE_pbvh_bmesh_check_origdata(pbvh, v, pbvh->stroke_id);
zero_v3(co);
zero_v3(origco);
@ -2132,6 +2130,7 @@ static void long_edge_queue_task_cb(void *__restrict userdata,
const TaskParallelTLS *__restrict tls)
{
EdgeQueueThreadData *tdata = ((EdgeQueueThreadData *)userdata) + n;
PBVH *pbvh = tdata->pbvh;
PBVHNode *node = tdata->node;
EdgeQueueContext *eq_ctx = tdata->eq_ctx;
RNG *rng = BLI_rng_new(_long_edge_queue_task_cb_seed++); // I don't care if seed becomes mangled
@ -2144,7 +2143,8 @@ static void long_edge_queue_task_cb(void *__restrict userdata,
BLI_array_declare(faces);
bool do_smooth = eq_ctx->surface_smooth_fac > 0.0f;
BKE_pbvh_bmesh_check_tris(tdata->pbvh, node);
BKE_pbvh_bmesh_check_tris(pbvh, node);
int ni = node - pbvh->nodes;
const char facetag = BM_ELEM_TAG_ALT;
@ -2211,6 +2211,11 @@ static void long_edge_queue_task_cb(void *__restrict userdata,
do {
MSculptVert *mv = BKE_PBVH_SCULPTVERT(eq_ctx->cd_sculpt_vert, l_iter->v);
/* are we owned by this node? if so, make sure origdata is up to date */
if (BM_ELEM_CD_GET_INT(l_iter->v, pbvh->cd_vert_node_offset) == ni) {
BKE_pbvh_bmesh_check_origdata(pbvh, l_iter->v, pbvh->stroke_id);
}
/*
If valence is not up to date, just add it to the list;
long_edge_queue_create will check and de-duplicate this for us.

View File

@ -10125,7 +10125,7 @@ static void SCULPT_run_commandlist(
&cmd->last_spacing_t[SCULPT_get_symmetry_pass(ss)]);
if (!noskip) {
return;
continue;
}
BrushRunCommandData data = {
@ -11427,8 +11427,8 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po
float delta_mouse[2];
sub_v3_v3v3(delta_mouse, cache->mouse, cache->mouse_event);
float speed = len_v3(delta_mouse) / (800000.0f); /*get a reasonably usable value*/
sub_v2_v2v2(delta_mouse, cache->mouse, cache->mouse_event);
float speed = len_v2(delta_mouse) / (800000.0f); /*get a reasonably usable value*/
speed /= PIL_check_seconds_timer() - cache->last_speed_time;
cache->input_mapping.speed = sculpt_update_speed_average(ss, speed);

View File

@ -799,13 +799,15 @@ void RNA_def_brush_curve(BlenderRNA *brna)
prop = RNA_def_property(srna, "curve_preset", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, "BrushCurve", "preset");
RNA_def_property_enum_items(prop, brush_curve_preset_items);
RNA_def_property_ui_text(prop, "Curve Preset", "");
RNA_def_property_ui_text(prop, "Curve Pre set", "");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "CurveMapping");
RNA_def_property_ui_text(prop, "Curve Sensitivity", "Curve used for the sensitivity");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_pointer_funcs(prop, "rna_BrushCurve_curve_get", NULL, NULL, NULL);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
}
void RNA_def_brush_channel(BlenderRNA *brna)
@ -832,6 +834,7 @@ void RNA_def_brush_channel(BlenderRNA *brna)
"rna_BrushChannel_category_set");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, "BrushChannel", "name");