Join curves: compensate for different bevel depths

When joining curves, the resulting curve will inherit the bevel depth of
the active curve, but the radii would stay the same which leads to
changed appearance when joining.

Now compensate for this taking the different bevel depths into account
(if present).

Was a feature request here (and I also think we had reports about this
-- which were usually turned down as not-a-bug):
https://blender.community/c/rightclickselect/bhhbbc/

Differential Revision: https://developer.blender.org/D10752
This commit is contained in:
Philipp Oeser 2021-03-17 09:21:32 +01:00
parent f65a3172a8
commit d5a705873e
1 changed files with 16 additions and 0 deletions

View File

@ -6872,6 +6872,8 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op)
* See #object_join_exec for detailed comment on why the safe version is used. */
invert_m4_m4_safe_ortho(imat, ob_active->obmat);
Curve *cu_active = ob_active->data;
CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) {
if (ob_iter->type == ob_active->type) {
if (ob_iter != ob_active) {
@ -6882,6 +6884,15 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op)
/* watch it: switch order here really goes wrong */
mul_m4_m4m4(cmat, imat, ob_iter->obmat);
/* Compensate for different bevel depth. */
bool do_radius = false;
float compensate_radius = 0.0f;
if (cu->ext2 != 0.0f && cu_active->ext2 != 0.0f) {
float compensate_scale = mat4_to_scale(cmat);
compensate_radius = cu->ext2 / cu_active->ext2 * compensate_scale;
do_radius = true;
}
LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
Nurb *newnu = BKE_nurb_duplicate(nu);
if (ob_active->totcol) { /* TODO, merge material lists */
@ -6895,6 +6906,11 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op)
if ((bezt = newnu->bezt)) {
a = newnu->pntsu;
while (a--) {
/* Compensate for different bevel depth. */
if (do_radius) {
bezt->radius *= compensate_radius;
}
mul_m4_v3(cmat, bezt->vec[0]);
mul_m4_v3(cmat, bezt->vec[1]);
mul_m4_v3(cmat, bezt->vec[2]);