Curves: Add transform tools to toolbar #104750

Merged
Falk David merged 4 commits from filedescriptor/blender:curves-transform-gizmo-group into main 2023-02-14 18:24:38 +01:00
2 changed files with 27 additions and 1 deletions

View File

@ -2997,7 +2997,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
_defs_edit_curve.curve_vertex_randomize,
],
'EDIT_CURVES': [
*_tools_select,
*_tools_default,
],
'EDIT_SURFACE': [
*_tools_default,

View File

@ -30,7 +30,9 @@
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_context.h"
#include "BKE_crazyspace.hh"
#include "BKE_curve.h"
#include "BKE_curves.hh"
#include "BKE_editmesh.h"
#include "BKE_global.h"
#include "BKE_gpencil.h"
@ -47,6 +49,7 @@
#include "WM_types.h"
#include "ED_armature.h"
#include "ED_curves.h"
#include "ED_gizmo_library.h"
#include "ED_gizmo_utils.h"
#include "ED_gpencil.h"
@ -623,6 +626,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
const TransformCalcParams *params,
TransformBounds *tbounds)
{
using namespace blender;
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
@ -929,6 +933,28 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
}
FOREACH_EDIT_OBJECT_END();
}
else if (obedit->type == OB_CURVES) {
FOREACH_EDIT_OBJECT_BEGIN (ob_iter, use_mat_local) {
const Curves &curves_id = *static_cast<Curves *>(ob_iter->data);
const bke::CurvesGeometry &curves = curves_id.geometry.wrap();
const bke::crazyspace::GeometryDeformation deformation =
Review
        const Curves &curves_id = *static_cast<const Curves *>(ob_iter->data);
        const bke::CurvesGeometry &curves = curves_id.geometry.wrap();
        const bke::crazyspace::GeometryDeformation deformation =
``` const Curves &curves_id = *static_cast<const Curves *>(ob_iter->data); const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); const bke::crazyspace::GeometryDeformation deformation = ```
bke::crazyspace::get_evaluated_curves_deformation(*depsgraph, *ob);
float4x4 mat_local;
if (use_mat_local) {
mat_local = float4x4(obedit->world_to_object) * float4x4(ob_iter->object_to_world);
}
Vector<int64_t> indices;
Review
        const IndexMask selected_points = ed::curves::retrieve_selected_points(curves, indices);
        const Span<float3> positions = deformation.positions;
``` const IndexMask selected_points = ed::curves::retrieve_selected_points(curves, indices); const Span<float3> positions = deformation.positions; ```
const IndexMask selected_points = ed::curves::retrieve_selected_points(curves, indices);
const Span<float3> positions = deformation.positions;
filedescriptor marked this conversation as resolved
Review

Retrieve the positions span once, this does a string lookup in CustomData for every index.

Retrieve the positions span once, this does a string lookup in `CustomData` for every index.
totsel += selected_points.size();
for (const int point_i : selected_points) {
calc_tw_center_with_matrix(tbounds, positions[point_i], use_mat_local, mat_local.ptr());
}
}
FOREACH_EDIT_OBJECT_END();
}
#undef FOREACH_EDIT_OBJECT_BEGIN
#undef FOREACH_EDIT_OBJECT_END