Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/curve/editcurve.c
| Show First 20 Lines • Show All 6,866 Lines • ▼ Show 20 Lines | int ED_curve_join_objects_exec(bContext *C, wmOperator *op) | ||||
| } | } | ||||
| BLI_listbase_clear(&tempbase); | BLI_listbase_clear(&tempbase); | ||||
| /* Inverse transform for all selected curves in this object, | /* Inverse transform for all selected curves in this object, | ||||
| * See #object_join_exec for detailed comment on why the safe version is used. */ | * See #object_join_exec for detailed comment on why the safe version is used. */ | ||||
| invert_m4_m4_safe_ortho(imat, ob_active->obmat); | 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) { | CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { | ||||
| if (ob_iter->type == ob_active->type) { | if (ob_iter->type == ob_active->type) { | ||||
| if (ob_iter != ob_active) { | if (ob_iter != ob_active) { | ||||
| cu = ob_iter->data; | cu = ob_iter->data; | ||||
| if (cu->nurb.first) { | if (cu->nurb.first) { | ||||
| /* watch it: switch order here really goes wrong */ | /* watch it: switch order here really goes wrong */ | ||||
| mul_m4_m4m4(cmat, imat, ob_iter->obmat); | 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) { | LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) { | ||||
| Nurb *newnu = BKE_nurb_duplicate(nu); | Nurb *newnu = BKE_nurb_duplicate(nu); | ||||
| if (ob_active->totcol) { /* TODO, merge material lists */ | if (ob_active->totcol) { /* TODO, merge material lists */ | ||||
| CLAMP(newnu->mat_nr, 0, ob_active->totcol - 1); | CLAMP(newnu->mat_nr, 0, ob_active->totcol - 1); | ||||
| } | } | ||||
| else { | else { | ||||
| newnu->mat_nr = 0; | newnu->mat_nr = 0; | ||||
| } | } | ||||
| BLI_addtail(&tempbase, newnu); | BLI_addtail(&tempbase, newnu); | ||||
| if ((bezt = newnu->bezt)) { | if ((bezt = newnu->bezt)) { | ||||
| a = newnu->pntsu; | a = newnu->pntsu; | ||||
| while (a--) { | 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[0]); | ||||
| mul_m4_v3(cmat, bezt->vec[1]); | mul_m4_v3(cmat, bezt->vec[1]); | ||||
| mul_m4_v3(cmat, bezt->vec[2]); | mul_m4_v3(cmat, bezt->vec[2]); | ||||
| bezt++; | bezt++; | ||||
| } | } | ||||
| BKE_nurb_handles_calc(newnu); | BKE_nurb_handles_calc(newnu); | ||||
| } | } | ||||
| if ((bp = newnu->bp)) { | if ((bp = newnu->bp)) { | ||||
| ▲ Show 20 Lines • Show All 194 Lines • Show Last 20 Lines | |||||