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:
authorPablo Dobarro <pablodp606>2021-02-07 20:57:14 +0300
committerPablo Dobarro <pablodp606@gmail.com>2021-02-07 21:12:37 +0300
commitec8d1b4eaeb855dd79a28ace0e697548b4f56d66 (patch)
tree8afb5864dbb05e9edccaf4f89d95da9058eaa67d /source/blender/editors/sculpt_paint/paint_mask.c
parent6f63417b500d0893e89fef1ecddb9ff345322e96 (diff)
Sculpt: Location option for lasso trim and depth info
This adds a location option to the trim lasso tool to position the shape in the middle of the volume of the object instead of in the surface under the cursor. {F9349724} In order to make this work, the SCULPT_cursor_geometry_info_update can now also get the depth of the geometry from the raycast. The depth is calculated as the second further intersecting triangle in the raycast over the entire mesh. This information will also be used to improve and create new tools. Differential Revision: https://developer.blender.org/D9622
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_mask.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 17d13041f28..b3e5687a6e5 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -949,6 +949,24 @@ static EnumPropertyItem prop_trim_orientation_types[] = {
{0, NULL, 0, NULL, NULL},
};
+typedef enum eSculptTrimLocationType {
+ SCULPT_GESTURE_TRIM_LOCATION_DEPTH_SURFACE,
+ SCULPT_GESTURE_TRIM_LOCATION_DEPTH_VOLUME,
+} eSculptTrimLocationType;
+static EnumPropertyItem prop_trim_location_types[] = {
+ {SCULPT_GESTURE_TRIM_LOCATION_DEPTH_SURFACE,
+ "DEPTH_SURFACE",
+ 0,
+ "Surface",
+ "Use the surface under the cursor to locate the trimming shape"},
+ {SCULPT_GESTURE_TRIM_LOCATION_DEPTH_VOLUME,
+ "DEPTH_VOLUME",
+ 0,
+ "Volume",
+ "Use the volume of the mesh to locate the trimming shape in the center of the volume"},
+ {0, NULL, 0, NULL, NULL},
+};
+
typedef struct SculptGestureTrimOperation {
SculptGestureOperation op;
@@ -962,6 +980,7 @@ typedef struct SculptGestureTrimOperation {
eSculptTrimOperationType mode;
eSculptTrimOrientationType orientation;
+ eSculptTrimLocationType location;
} SculptGestureTrimOperation;
static void sculpt_gesture_trim_normals_update(SculptGestureContext *sgcontext)
@@ -1053,8 +1072,19 @@ static void sculpt_gesture_trim_calculate_depth(bContext *C, SculptGestureContex
if (trim_operation->use_cursor_depth) {
float world_space_gesture_initial_location[3];
- mul_v3_m4v3(
- world_space_gesture_initial_location, vc->obact->obmat, ss->gesture_initial_location);
+
+ switch (trim_operation->location) {
+ case SCULPT_GESTURE_TRIM_LOCATION_DEPTH_SURFACE: {
+ mul_v3_m4v3(
+ world_space_gesture_initial_location, vc->obact->obmat, ss->gesture_initial_location);
+
+ } break;
+ case SCULPT_GESTURE_TRIM_LOCATION_DEPTH_VOLUME: {
+ float center_co[3];
+ mid_v3_v3v3(center_co, ss->gesture_initial_location, ss->gesture_initial_back_location);
+ mul_v3_m4v3(world_space_gesture_initial_location, vc->obact->obmat, center_co);
+ } break;
+ }
float mid_point_depth;
if (trim_operation->orientation == SCULPT_GESTURE_TRIM_ORIENTATION_VIEW) {
@@ -1362,6 +1392,7 @@ static void sculpt_gesture_init_trim_properties(SculptGestureContext *sgcontext,
trim_operation->mode = RNA_enum_get(op->ptr, "trim_mode");
trim_operation->use_cursor_depth = RNA_boolean_get(op->ptr, "use_cursor_depth");
trim_operation->orientation = RNA_enum_get(op->ptr, "trim_orientation");
+ trim_operation->location = RNA_enum_get(op->ptr, "trim_location");
/* If the cursor was not over the mesh, force the orientation to view. */
if (!sgcontext->ss->gesture_initial_hit) {
@@ -1389,6 +1420,13 @@ static void sculpt_trim_gesture_operator_properties(wmOperatorType *ot)
SCULPT_GESTURE_TRIM_ORIENTATION_VIEW,
"Shape Orientation",
NULL);
+
+ RNA_def_enum(ot->srna,
+ "trim_location",
+ prop_trim_location_types,
+ SCULPT_GESTURE_TRIM_LOCATION_DEPTH_SURFACE,
+ "Shape Location",
+ NULL);
}
/* Project Gesture Operation. */
@@ -1582,7 +1620,7 @@ static int sculpt_trim_gesture_box_invoke(bContext *C, wmOperator *op, const wmE
SculptCursorGeometryInfo sgi;
float mouse[2] = {event->mval[0], event->mval[1]};
SCULPT_vertex_random_access_ensure(ss);
- ss->gesture_initial_hit = SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
+ ss->gesture_initial_hit = SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false, false);
if (ss->gesture_initial_hit) {
copy_v3_v3(ss->gesture_initial_location, sgi.location);
copy_v3_v3(ss->gesture_initial_normal, sgi.normal);
@@ -1623,9 +1661,10 @@ static int sculpt_trim_gesture_lasso_invoke(bContext *C, wmOperator *op, const w
SculptCursorGeometryInfo sgi;
float mouse[2] = {event->mval[0], event->mval[1]};
SCULPT_vertex_random_access_ensure(ss);
- ss->gesture_initial_hit = SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
+ ss->gesture_initial_hit = SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false, true);
if (ss->gesture_initial_hit) {
copy_v3_v3(ss->gesture_initial_location, sgi.location);
+ copy_v3_v3(ss->gesture_initial_back_location, sgi.back_location);
copy_v3_v3(ss->gesture_initial_normal, sgi.normal);
}