Curves: cage overlay for sculpt mode #104467

Merged
Jacques Lucke merged 44 commits from JacquesLucke/blender:sculpt-edit-overlay into main 2023-02-14 18:10:24 +01:00
1 changed files with 19 additions and 9 deletions
Showing only changes of commit 7e3a76bb3d - Show all commits

View File

@ -336,6 +336,7 @@ void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Ob
curves_id_orig);
}
curves_evaluate_modifiers(depsgraph, scene, object, geometry_set);
Curves *curves_id_eval = const_cast<Curves *>(geometry_set.get_curves_for_read());
/* Create cage curves geometry for drawing. */
if (generate_cage) {
@ -350,22 +351,31 @@ void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Ob
object->runtime.editcurves_eval_cage = curves_id_cage;
const blender::bke::CurvesEditHints *curve_edit_hints =
geometry_set.get_curve_edit_hints_for_read();
if (curve_edit_hints && curve_edit_hints->positions.has_value()) {
curves_cage.positions_for_write().copy_from(*curve_edit_hints->positions);
Span<float3> positions;
if (curve_edit_hints) {
if (curve_edit_hints->positions.has_value()) {
positions = *curve_edit_hints->positions;
}
else if (curves_id_eval && curves_id_eval->geometry.point_num == curves_orig.point_num) {
blender::bke::CurvesGeometry &curves_eval = blender::bke::CurvesGeometry::wrap(
curves_id_eval->geometry);
positions = curves_eval.positions();
}
}
else {
curves_cage.positions_for_write().copy_from(curves_orig.positions());
if (positions.is_empty()) {
positions = curves_orig.positions();
}
JacquesLucke marked this conversation as resolved
Review

Why does this have to create a new Curves at all? Wouldn't it be enough to use the original curves combined with the deformed positions? At the very least this should be strongly motivated by a comment here.

Why does this have to create a new `Curves` at all? Wouldn't it be enough to use the original curves combined with the deformed positions? At the very least this should be strongly motivated by a comment here.
curves_cage.positions_for_write().copy_from(positions);
}
/* Assign evaluated object. */
Curves *curves_eval = const_cast<Curves *>(geometry_set.get_curves_for_read());
if (curves_eval == nullptr) {
curves_eval = blender::bke::curves_new_nomain(0, 0);
BKE_object_eval_assign_data(object, &curves_eval->id, true);
if (curves_id_eval == nullptr) {
curves_id_eval = blender::bke::curves_new_nomain(0, 0);
BKE_object_eval_assign_data(object, &curves_id_eval->id, true);
}
else {
BKE_object_eval_assign_data(object, &curves_eval->id, false);
BKE_object_eval_assign_data(object, &curves_id_eval->id, false);
}
object->runtime.geometry_set_eval = new GeometrySet(std::move(geometry_set));
}