Fix: Grease Pencil: Bézier handles not effected by Snap To Grid
This makes it so that bézier handles will be snapped to the grid, same as the control points. Pull Request: https://projects.blender.org/blender/blender/pulls/144517
This commit is contained in:
committed by
Falk David
parent
baaa180ba1
commit
fd7bb7f9c3
@@ -3444,19 +3444,29 @@ static wmOperatorStatus grease_pencil_snap_to_grid_exec(bContext *C, wmOperator
|
||||
continue;
|
||||
}
|
||||
|
||||
IndexMaskMemory memory;
|
||||
const IndexMask selected_points = ed::curves::retrieve_selected_points(curves, memory);
|
||||
for (const StringRef selection_name : ed::curves::get_curves_selection_attribute_names(curves))
|
||||
{
|
||||
IndexMaskMemory memory;
|
||||
const IndexMask selected_points = ed::curves::retrieve_selected_points(
|
||||
curves, selection_name, memory);
|
||||
|
||||
const Layer &layer = grease_pencil.layer(drawing_info.layer_index);
|
||||
const float4x4 layer_to_world = layer.to_world_space(object);
|
||||
const float4x4 world_to_layer = math::invert(layer_to_world);
|
||||
const Layer &layer = grease_pencil.layer(drawing_info.layer_index);
|
||||
const float4x4 layer_to_world = layer.to_world_space(object);
|
||||
const float4x4 world_to_layer = math::invert(layer_to_world);
|
||||
|
||||
MutableSpan<float3> positions = curves.positions_for_write();
|
||||
selected_points.foreach_index(GrainSize(4096), [&](const int point_i) {
|
||||
const float3 pos_world = math::transform_point(layer_to_world, positions[point_i]);
|
||||
const float3 pos_snapped = grid_size * math::floor(pos_world / grid_size + 0.5f);
|
||||
positions[point_i] = math::transform_point(world_to_layer, pos_snapped);
|
||||
});
|
||||
MutableSpan<float3> positions = curves.positions_for_write();
|
||||
if (selection_name == ".selection_handle_left") {
|
||||
positions = curves.handle_positions_left_for_write();
|
||||
}
|
||||
else if (selection_name == ".selection_handle_right") {
|
||||
positions = curves.handle_positions_right_for_write();
|
||||
}
|
||||
selected_points.foreach_index(GrainSize(4096), [&](const int point_i) {
|
||||
const float3 pos_world = math::transform_point(layer_to_world, positions[point_i]);
|
||||
const float3 pos_snapped = grid_size * math::floor(pos_world / grid_size + 0.5f);
|
||||
positions[point_i] = math::transform_point(world_to_layer, pos_snapped);
|
||||
});
|
||||
}
|
||||
|
||||
drawing_info.drawing.tag_positions_changed();
|
||||
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
|
||||
|
||||
Reference in New Issue
Block a user