Commit: 53874b413e7364c99b10bcd04616e3973fc7307e
Author: Pablo Dobarro
Date: Wed Feb 17 00:17:49 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rB53874b413e7364c99b10bcd04616e3973fc7307e
Sculpt Expand: More comments
===================================================================
M source/blender/editors/sculpt_paint/sculpt_expand.c
M source/blender/editors/sculpt_paint/sculpt_geodesic.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
===================================================================
diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c
b/source/blender/editors/sculpt_paint/sculpt_expand.c
index d8076b40e8c..4d8aa3b3189 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@ -98,10 +98,16 @@
*/
#define SCULPT_EXPAND_VERTEX_NONE -1
+/* Used for defining an unitialized active component index for an unused
symmetry pass. */
+
+#define EXPAND_ACTIVE_COMPOMENT_NONE -1
/* Defines how much each time the texture distortion is increased/decreased
when using the modal
* keymap. */
#define SCULPT_EXPAND_TEXTURE_DISTORTION_STEP 0.01f
+/* This threshold offsets the required falloff value to start a new loop. This
is needed because in
+ * some situations, vertices which have the same falloff value as max_falloff
will start a new
+ * loop, which is undesired. */
#define SCULPT_EXPAND_LOOP_THRESHOLD 0.00001f
/* Expand Modal Keymap. */
@@ -378,9 +384,7 @@ static BLI_bitmap
*sculpt_expand_boundary_from_enabled(SculptSession *ss,
return boundary_vertices;
}
-
-
-/* Functions implementing differnt algorithms for initializing the falloff
values. */
+/* Functions implementing different algorithms for initializing falloff
values. */
/* Geodesic: Initializes the falloff with geodesic distances from the given
active vertex, taking
* symmetry into account. */
@@ -772,9 +776,11 @@ static void
sculpt_expand_mesh_face_falloff_from_vertex_falloff(SculptSession *s
}
}
-/* Recursions. These functions will generate new falloff values based on the
state of the vertices from the current ExpandCache options and falloff values.
*/
+/* Recursions. These functions will generate new falloff values based on the
state of the vertices
+ * from the current ExpandCache options and falloff values. */
-/* Geodesic recursion: Initializes falloff values using geodesic distances
from the boundary of the current vertices state. */
+/* Geodesic recursion: Initializes falloff values using geodesic distances
from the boundary of the
+ * current vertices state. */
static void sculpt_expand_geodesics_from_state_boundary(Object *ob,
ExpandCache
*expand_cache,
BLI_bitmap
*enabled_vertices)
@@ -800,7 +806,8 @@ static void
sculpt_expand_geodesics_from_state_boundary(Object *ob,
BLI_gset_free(initial_vertices, NULL);
}
-/* Geodesic recursion: Initializes falloff values using topology steps from
the boundary of the current vertices state, increasing the value by 1 each time
a new vertex is visited. */
+/* Geodesic recursion: Initializes falloff values using topology steps from
the boundary of the
+ * current vertices state, increasing the value by 1 each time a new vertex is
visited. */
static void sculpt_expand_topology_from_state_boundary(Object *ob,
ExpandCache
*expand_cache,
BLI_bitmap
*enabled_vertices)
@@ -844,7 +851,9 @@ static void sculpt_expand_resursion_step_add(Object *ob,
BLI_bitmap *enabled_vertices = sculpt_expand_bitmap_from_enabled(ss,
expand_cache);
- /* Each time a new recursion step is created, reset the distortion strength.
This is the expedted result from the recursion, as otherwise the new falloff
will render with undesired distortion from the beginning */
+ /* Each time a new recursion step is created, reset the distortion strength.
This is the expedted
+ * result from the recursion, as otherwise the new falloff will render with
undesired distortion
+ * from the beginning */
expand_cache->texture_distortion_strength = 0.0f;
switch (recursion_type) {
@@ -923,8 +932,8 @@ static void
sculpt_expand_initialize_from_face_set_boundary(Object *ob,
}
}
-
-/* Main function to initialize new falloff values in a ExpandCache given an
initial vertex and a falloff type. */
+/* Main function to initialize new falloff values in a ExpandCache given an
initial vertex and a
+ * falloff type. */
static void sculpt_expand_falloff_factors_from_vertex_and_symm_create(
ExpandCache *expand_cache,
Sculpt *sd,
@@ -979,8 +988,9 @@ static void
sculpt_expand_falloff_factors_from_vertex_and_symm_create(
}
}
-
-/* Adds to the snapping Face Set gset all Face Sets which contain all enabled
vertices for the current ExpandCache state. This improves the usability of
snapping, as already enabled elements won't switch their state when toggling
snapping with the modal keymap.*/
+/* Adds to the snapping Face Set gset all Face Sets which contain all enabled
vertices for the
+ * current ExpandCache state. This improves the usability of snapping, as
already enabled elements
+ * won't switch their state when toggling snapping with the modal keymap.*/
static void sculpt_expand_snap_initialize_from_enabled(SculptSession *ss,
ExpandCache
*expand_cache)
{
@@ -988,7 +998,8 @@ static void
sculpt_expand_snap_initialize_from_enabled(SculptSession *ss,
return;
}
- /* Make sure this code runs with snapping and invert disabled. This
simplifies the code and prevents using this function with snapping already
enabled. */
+ /* Make sure this code runs with snapping and invert disabled. This
simplifies the code and
+ * prevents using this function with snapping already enabled. */
const bool prev_snap_state = expand_cache->snap;
const bool prev_invert_state = expand_cache->invert;
expand_cache->snap = false;
@@ -1024,7 +1035,6 @@ static void
sculpt_expand_snap_initialize_from_enabled(SculptSession *ss,
expand_cache->invert = prev_invert_state;
}
-
/* Functions to free a ExpandCache */
static void sculpt_expand_cache_data_free(ExpandCache *expand_cache)
{
@@ -1035,20 +1045,20 @@ static void sculpt_expand_cache_data_free(ExpandCache
*expand_cache)
MEM_SAFE_FREE(expand_cache->falloff);
MEM_SAFE_FREE(expand_cache->face_falloff);
MEM_SAFE_FREE(expand_cache->original_mask);
- MEM_SAFE_FREE(expand_cache->origin_face_sets);
+ MEM_SAFE_FREE(expand_cache->original_face_sets);
MEM_SAFE_FREE(expand_cache->initial_face_sets);
- MEM_SAFE_FREE(expand_cache->original_color);
+ MEM_SAFE_FREE(expand_cache->original_colors);
MEM_SAFE_FREE(expand_cache);
}
static void sculpt_expand_cache_free(SculptSession *ss)
{
sculpt_expand_cache_data_free(ss->expand_cache);
- /* Needs to be set to NULL as the paint cursor relies on checking this
pointer detecting if an expand operation is running. */
+ /* Needs to be set to NULL as the paint cursor relies on checking this
pointer detecting if an
+ * expand operation is running. */
ss->expand_cache = NULL;
}
-
/* Functions to restore the original state from the ExpandCache when canceling
the operator. */
static void sculpt_expand_restore_face_set_data(SculptSession *ss, ExpandCache
*expand_cache)
{
@@ -1061,7 +1071,7 @@ static void
sculpt_expand_restore_face_set_data(SculptSession *ss, ExpandCache *
}
MEM_freeN(nodes);
for (int i = 0; i < ss->totfaces; i++) {
- ss->face_sets[i] = expand_cache->origin_face_sets[i];
+ ss->face_sets[i] = expand_cache->original_face_sets[i];
}
}
@@ -1075,7 +1085,7 @@ static void
sculpt_expand_restore_color_data(SculptSession *ss, ExpandCache *exp
PBVHVertexIter vd;
BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
{
- copy_v4_v4(vd.col, expand_cache->original_color[vd.index]);
+ copy_v4_v4(vd.col, expand_cache->original_colors[vd.index]);
}
BKE_pbvh_vertex_iter_end;
BKE_pbvh_node_mark_redraw(node);
@@ -1101,7 +1111,8 @@ static void sculpt_expand_restore_mask_data(SculptSession
*ss, ExpandCache *expa
MEM_freeN(nodes);
}
-/* Main function to restore the original state of the data to how it was
before starting the expand operation. */
+/* Main function to restore the original state of the data to how it was
before starting the expand
+ * operation. */
static void sculpt_expand_restore_original_state(bContext *C,
Object *ob,
ExpandCache *expand_cache)
@@ -1129,6 +1140,7 @@ static void sculpt_expand_restore_original_state(bContext
*C,
}
}
+/* Cancel operator callback. */
static void sculpt_expand_cancel(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_active_object(C);
@@ -1140,6 +1152,9 @@ static void sculpt_expand_cancel(bContext *C, wmOperator
*UNUSED(op))
sculpt_expand_cache_free(ss);
}
+/* Functions to update the sculpt mesh data. */
+
+/* Callback to update mask data per PBVH node. */
static void sculpt_expand_mask_update_task_cb(void *__restrict userdata,
const int i,
const TaskParallelTLS
*__restrict UNUSED(tls))
@@ -1186,6 +1201,7 @@ static void sculpt_expand_mask_update_task_cb(void
*__restrict userdata,
}
}
+/* Update Face Set data. Not multithreaded per node as nodes don't contain
face arrays. */
static void sculpt_expand_face_sets_update(SculptSession *ss, ExpandCache
*expand_cache)
{
const int totface = ss->totfaces;
@@ -1203,10 +1219,11 @@ static void
sculpt_expand_face_sets_update(SculptSession *ss, ExpandCache *expan
}
for (int i = 0; i < expand_cache->totnode; i++) {
- BKE_pbvh_node_mark_update_mask(expand_cache->nodes[i]);
+ BKE_pbvh_node_mark_redraw(ss->expand_cache->nodes[i]);
}
}
+/* Callback to update vertex colors per PBVH node. */
static void sculpt_expand_colors_update_task_cb(void *__restrict userdata,
const int i,
const TaskParallelTLS
*__restrict UNUSED(tls))
@@ -1241,7 +1258,7 @@ static void sculpt_expand_colors_update_task_cb(void
*__restrict userdata,
float final_fill_color[4];
mul_v4_v4fl(final_fill_color, expand_cache->fill_color, fade);
IMB_blend_color_float(final_color,
- expand_cache->original_color[vd.index],
+ expand_cache->original_color
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs