Fix #143630: Pivot to Active Vertex moves 3D cursor to infinity
There are a number of issues with the "Active Vertex" mode for the Set Pivot operator in Sculpt Mode: 1. The menu option did not require the cursor, so moving off of the mesh and using this option would previously pick the last value in the `SculptSession` 2. The active vertex information was not updated when this was called, so even if the user invoked this operator with their mouse on the mesh via the Operator Search popup, it would not use the right position. This also means behavior would differ depending on if a brush tool was being used or the transform tools. To fix these issues, the relevant flags are set for the operator as a whole, and the internal active vert information is updated prior to being requested for this operator. Note that this does add an extra mouse click required for calling the operator via the Operator Search menu, but given that it only worked in specific situations before, this is an acceptable tradeoff. Assigning a shortcut to this operator removes this requirement, as expected. Pull Request: https://projects.blender.org/blender/blender/pulls/143675
This commit is contained in:
@@ -640,7 +640,7 @@ static bool set_pivot_depends_on_cursor(bContext & /*C*/, wmOperatorType & /*ot*
|
||||
return true;
|
||||
}
|
||||
const PivotPositionMode mode = PivotPositionMode(RNA_enum_get(ptr, "mode"));
|
||||
return mode == PivotPositionMode::CursorSurface;
|
||||
return ELEM(mode, PivotPositionMode::CursorSurface, PivotPositionMode::ActiveVert);
|
||||
}
|
||||
|
||||
struct AveragePositionAccumulation {
|
||||
@@ -933,7 +933,11 @@ static wmOperatorStatus set_pivot_position_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
/* Pivot to active vertex. */
|
||||
else if (mode == PivotPositionMode::ActiveVert) {
|
||||
copy_v3_v3(ss.pivot_pos, ss.active_vert_position(*depsgraph, ob));
|
||||
const float2 mval(RNA_float_get(op->ptr, "mouse_x"), RNA_float_get(op->ptr, "mouse_y"));
|
||||
CursorGeometryInfo cgi;
|
||||
if (cursor_geometry_info_update(C, &cgi, mval, false)) {
|
||||
copy_v3_v3(ss.pivot_pos, ss.active_vert_position(*depsgraph, ob));
|
||||
}
|
||||
}
|
||||
/* Pivot to ray-cast surface. */
|
||||
else if (mode == PivotPositionMode::CursorSurface) {
|
||||
@@ -981,7 +985,7 @@ static bool set_pivot_position_poll_property(const bContext * /*C*/,
|
||||
{
|
||||
if (STRPREFIX(RNA_property_identifier(prop), "mouse_")) {
|
||||
const PivotPositionMode mode = PivotPositionMode(RNA_enum_get(op->ptr, "mode"));
|
||||
return mode == PivotPositionMode::CursorSurface;
|
||||
return ELEM(mode, PivotPositionMode::CursorSurface, PivotPositionMode::ActiveVert);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1012,7 +1016,7 @@ void SCULPT_OT_set_pivot_position(wmOperatorType *ot)
|
||||
0.0f,
|
||||
FLT_MAX,
|
||||
"Mouse Position X",
|
||||
"Position of the mouse used for \"Surface\" mode",
|
||||
"Position of the mouse used for \"Surface\" and \"Active Vertex\" mode",
|
||||
0.0f,
|
||||
10000.0f);
|
||||
RNA_def_float(ot->srna,
|
||||
@@ -1021,7 +1025,7 @@ void SCULPT_OT_set_pivot_position(wmOperatorType *ot)
|
||||
0.0f,
|
||||
FLT_MAX,
|
||||
"Mouse Position Y",
|
||||
"Position of the mouse used for \"Surface\" mode",
|
||||
"Position of the mouse used for \"Surface\" and \"Active Vertex\" mode",
|
||||
0.0f,
|
||||
10000.0f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user