Page MenuHome

Multi-Object EditMode: CURVE_OT_select_similar
AbandonedPublic

Authored by Habib Gahbiche (zazizizou) on Oct 28 2018, 9:05 PM.

Details

Summary

I'm trying to base my code on mesh editmode select similar.

Done:

  • SIMCURHAND_TYPE
  • SIMCURHAND_RADIUS
  • SIMCURHAND_WEIGHT
  • SIMCURHAND_DIRECTION

Limits:

  • DIRECTION does not support surfaces, because BKE_nurb_bpoint_calc_normal does not work with Nurbs of type CU_CARDINAL. This also didn't work prior to this patch, so maybe first wait until surfaces are properly supported in EditMode?
  • Threshold default is too large. Not sure if it's better to change the default or scale the threshold in code.

Diff Detail

Repository
rB Blender
Branch
cu_sel_sim (branched from blender2.8)
Build Status
Buildable 2310
Build 2310: arc lint + arc unit

Event Timeline

Campbell Barton (campbellbarton) requested changes to this revision.Oct 30 2018, 4:17 AM

This is just wrapping the logic up in a loop, for select similar we need it to work between objects.

This isn't a simple task, see how mesh editmode select similar now works.

This revision now requires changes to proceed.Oct 30 2018, 4:17 AM
Habib Gahbiche (zazizizou) edited the summary of this revision. (Show Details)

select similar based on type (i.e. bezier or nurbs)

count nurbs correctly

Habib Gahbiche (zazizizou) edited the summary of this revision. (Show Details)

simplify nurb counts

Dalai Felinto (dfelinto) requested changes to this revision.Oct 30 2018, 7:12 PM
Dalai Felinto (dfelinto) added inline comments.
source/blender/editors/curve/editcurve_select.c
220

Why is this not a static function? Are you planning to use this from a different file?

222

Code style, loose this extra line.

1555

Why to implement a _exec_multi? Why not just replace the _exec() function?

1562

Use ELEM instead:
if (ELEM, type, SIMCURHAND_RADIUS, SIMCURHAND_WEIGHT, ...))

1592

It is overkill to use gset here if there is only two options. Use bitflags instead.

1678

No need to actually count the changed ones. Just use a bool, like changed_multi.

This revision now requires changes to proceed.Oct 30 2018, 7:12 PM
source/blender/editors/curve/editcurve_select.c
220

I was following the style of the neighbouring functions, e.g. bool ED_curve_select_check. But maybe all similar functions should be static?

1555

will do with the final patch, just wanted to keep the original for reference

Habib Gahbiche (zazizizou) marked 4 inline comments as done.Oct 30 2018, 8:09 PM
Habib Gahbiche (zazizizou) edited the summary of this revision. (Show Details)
  1. Support for select similar based on RADIUS. Implemented with a KDTree.
  2. Moved mesh_select_similar_compare_float_tree to select_utils.c and renamed to ED_select_similar_compare_float_tree
  3. Moved mesh_select_similar_compare_float to select_utils.c and renamed to ED_select_similar_compare_float
Habib Gahbiche (zazizizou) edited the summary of this revision. (Show Details)

Support for WEIGHT and DIRECTION. All types except TYPE are now in a single function.

source/blender/editors/curve/editcurve_select.c
1436

Comments should start with a capital letter and end with a full stop:
/* Get type of selected control points. */

1443

Do a short break:

if (!ED_curve...()) {
  continue;
}
1544

No need for the parenthesis around changed_multi.

Habib Gahbiche (zazizizou) edited the summary of this revision. (Show Details)

short break - style

Dalai Felinto (dfelinto) requested changes to this revision.Nov 2 2018, 8:22 PM

As discussed on irc, things like direction and radius should be done in the world space, not the local space. @Habib Gahbiche (zazizizou) I only mentioned direction, but radius should always consider scale for instance, so we need it to be in world space.

This revision now requires changes to proceed.Nov 2 2018, 8:22 PM
Habib Gahbiche (zazizizou) edited the summary of this revision. (Show Details)

SIMCURHAND_DIRECTION is now computed in world space.

No changes to RADIUS because I don't think it's affected by scale. I saw the same behavior in 2.79 with particles when using the curve as a curve guide. So I believe it's handled the same way as WEIGHT. But even if it does depend on scale, how should I scale one float? Maybe define a circle with radius to compare, transform it into world coordinates, compute its area and then compare areas instead of radii (this could be a solution for MBALL_OT_select_similar where the radius has a different meaning...

Only return OPERATOR_CANCELLED when no control points are selected.

Thanks for addressing the changes. Committed on 4e9911663a22766f6751d33ae84c1ebcc1fae559 with minor changes.
There is a pending issue as discussed, to be addressed by a future patch if possible. Basically similar direction should take scale into account, for non-uniformly scaled curve objects.