Cleanup: Rename curve struct fields

These existing names were unhelpful at best, actively confusing at
worst. This patch renames them to be consistent with the terms
used to refer to the values in the UI.
 - `width` -> `offset`
 - `ext1` -> `extrude`
 - `ext2` -> `bevel_radius`

Differential Revision: https://developer.blender.org/D9627
This commit is contained in:
Hans Goudey 2021-12-01 22:01:35 -05:00
parent ca9cdba2df
commit 218360a892
Notes: blender-bot 2023-02-14 06:17:14 +01:00
Referenced by commit 0de1d2e84e, Cleanup: FIx build with USD after recent refactor
11 changed files with 43 additions and 40 deletions

View File

@ -75,8 +75,8 @@ typedef struct CVKeyIndex {
#define SEGMENTSV(nu) (((nu)->flagv & CU_NURB_CYCLIC) ? (nu)->pntsv : (nu)->pntsv - 1)
#define CU_DO_RADIUS(cu, nu) \
((((cu)->flag & (CU_PATH_RADIUS | CU_3D)) || (cu)->bevobj || (cu)->ext1 != 0.0f || \
(cu)->ext2 != 0.0f) ? \
((((cu)->flag & (CU_PATH_RADIUS | CU_3D)) || (cu)->bevobj || (cu)->extrude != 0.0f || \
(cu)->bevel_radius != 0.0f) ? \
1 : \
0)

View File

@ -64,8 +64,8 @@ static void bevel_quarter_fill(const Curve *curve,
float angle = 0.0f;
const float dangle = (float)M_PI_2 / (curve->bevresol + 1);
for (int i = 0; i < curve->bevresol + 1; i++) {
quarter_coords_x[i] = (float)(cosf(angle) * (curve->ext2));
quarter_coords_y[i] = (float)(sinf(angle) * (curve->ext2));
quarter_coords_x[i] = (float)(cosf(angle) * (curve->bevel_radius));
quarter_coords_y[i] = (float)(sinf(angle) * (curve->bevel_radius));
angle += dangle;
}
}
@ -76,11 +76,11 @@ static void bevel_quarter_fill(const Curve *curve,
/* If there aren't enough samples, the curveprofile won't
* sample the start vertex, so set it manually instead. */
quarter_coords_x[0] = curve->ext2;
quarter_coords_x[0] = curve->bevel_radius;
quarter_coords_y[0] = 0.0f;
for (int i = 1; i < curve->bevresol + 1; i++) {
quarter_coords_x[i] = (float)(curve->bevel_profile->segments[i].x * (curve->ext2));
quarter_coords_y[i] = (float)(curve->bevel_profile->segments[i].y * (curve->ext2));
quarter_coords_x[i] = (float)(curve->bevel_profile->segments[i].x * (curve->bevel_radius));
quarter_coords_y[i] = (float)(curve->bevel_profile->segments[i].y * (curve->bevel_radius));
}
}
}
@ -133,13 +133,13 @@ static void curve_bevel_make_extrude_and_fill(const Curve *cu,
/* Add the bottom vertex. */
fp[0] = 0.0f;
fp[1] = 0.0f;
fp[2] = -cu->ext1 - cu->ext2;
fp[2] = -cu->extrude - cu->bevel_radius;
fp += 3;
for (int i = cu->bevresol; i >= 0; i--) {
fp[0] = 0.0f;
fp[1] = quarter_coords_x[i];
fp[2] = -quarter_coords_y[i] - cu->ext1;
fp[2] = -quarter_coords_y[i] - cu->extrude;
fp += 3;
}
}
@ -147,8 +147,8 @@ static void curve_bevel_make_extrude_and_fill(const Curve *cu,
/* Add the extrusion if we're only building either the back or the front. */
if (use_extrude && ELEM(fill_type, FRONT, BACK)) {
fp[0] = 0.0f;
fp[1] = cu->ext2;
fp[2] = (fill_type == FRONT) ? -cu->ext1 : cu->ext1;
fp[1] = cu->bevel_radius;
fp[2] = (fill_type == FRONT) ? -cu->extrude : cu->extrude;
fp += 3;
}
@ -159,13 +159,13 @@ static void curve_bevel_make_extrude_and_fill(const Curve *cu,
for (int i = front_start; i < cu->bevresol + 1; i++) {
fp[0] = 0.0f;
fp[1] = quarter_coords_x[i];
fp[2] = quarter_coords_y[i] + cu->ext1;
fp[2] = quarter_coords_y[i] + cu->extrude;
fp += 3;
}
/* Add the top vertex. */
fp[0] = 0.0f;
fp[1] = 0.0f;
fp[2] = cu->ext1 + cu->ext2;
fp[2] = cu->extrude + cu->bevel_radius;
fp += 3;
}
@ -174,22 +174,22 @@ static void curve_bevel_make_extrude_and_fill(const Curve *cu,
for (int i = cu->bevresol; i > 0; i--) {
fp[0] = 0.0f;
fp[1] = -quarter_coords_x[i];
fp[2] = quarter_coords_y[i] + cu->ext1;
fp[2] = quarter_coords_y[i] + cu->extrude;
fp += 3;
}
if (use_extrude) {
/* Add the extrusion. */
fp[0] = 0.0f;
fp[1] = -cu->ext2;
fp[2] = cu->ext1;
fp[1] = -cu->bevel_radius;
fp[2] = cu->extrude;
fp += 3;
}
for (int i = 0; i < cu->bevresol + 1; i++) {
fp[0] = 0.0f;
fp[1] = -quarter_coords_x[i];
fp[2] = -quarter_coords_y[i] - cu->ext1;
fp[2] = -quarter_coords_y[i] - cu->extrude;
fp += 3;
}
}
@ -213,8 +213,8 @@ static void curve_bevel_make_full_circle(const Curve *cu, ListBase *disp)
for (int i = 0; i < nr; i++) {
fp[0] = 0.0;
fp[1] = (cosf(angle) * (cu->ext2));
fp[2] = (sinf(angle) * (cu->ext2)) - cu->ext1;
fp[1] = (cosf(angle) * (cu->bevel_radius));
fp[2] = (sinf(angle) * (cu->bevel_radius)) - cu->extrude;
angle += dangle;
fp += 3;
}
@ -232,9 +232,9 @@ static void curve_bevel_make_only_extrude(const Curve *cu, ListBase *disp)
float *fp = dl->verts;
fp[0] = fp[1] = 0.0;
fp[2] = -cu->ext1;
fp[2] = -cu->extrude;
fp[3] = fp[4] = 0.0;
fp[5] = cu->ext1;
fp[5] = cu->extrude;
}
static void curve_bevel_make_from_object(const Curve *cu, ListBase *disp)
@ -247,7 +247,7 @@ static void curve_bevel_make_from_object(const Curve *cu, ListBase *disp)
}
Curve *bevcu = cu->bevobj->data;
if (bevcu->ext1 == 0.0f && bevcu->ext2 == 0.0f) {
if (bevcu->extrude == 0.0f && bevcu->bevel_radius == 0.0f) {
ListBase bevdisp = {NULL, NULL};
float facx = cu->bevobj->scale[0];
float facy = cu->bevobj->scale[1];
@ -299,8 +299,8 @@ ListBase BKE_curve_bevel_make(const Curve *curve)
}
}
else {
const bool use_extrude = curve->ext1 != 0.0f;
const bool use_bevel = curve->ext2 != 0.0f;
const bool use_extrude = curve->extrude != 0.0f;
const bool use_bevel = curve->bevel_radius != 0.0f;
/* Pass. */
if (use_extrude && !use_bevel) {
curve_bevel_make_only_extrude(curve, &bevel_shape);

View File

@ -830,7 +830,7 @@ static bool do_curve_implicit_mesh_conversion(const Curve *curve,
}
/* Curve objects with implicit "tube" meshes should convert implicitly to a mesh. */
if (curve->ext1 != 0.0f || curve->ext2 != 0.0f) {
if (curve->extrude != 0.0f || curve->bevel_radius != 0.0f) {
return true;
}
@ -1310,11 +1310,11 @@ static GeometrySet evaluate_curve_type_object(Depsgraph *depsgraph,
ListBase dlbev = BKE_curve_bevel_make(cu);
/* no bevel or extrude, and no width correction? */
if (BLI_listbase_is_empty(&dlbev) && cu->width == 1.0f) {
if (BLI_listbase_is_empty(&dlbev) && cu->offset == 1.0f) {
curve_to_displist(cu, deformed_nurbs, for_render, r_dispbase);
}
else {
const float widfac = cu->width - 1.0f;
const float widfac = cu->offset - 1.0f;
const BevList *bl = (BevList *)ob->runtime.curve_cache->bev.first;
const Nurb *nu = (Nurb *)deformed_nurbs->first;

View File

@ -1892,7 +1892,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (cu = bmain->curves.first; cu; cu = cu->id.next) {
if (cu->flag & (CU_FRONT | CU_BACK)) {
if (cu->ext1 != 0.0f || cu->ext2 != 0.0f) {
if (cu->extrude != 0.0f || cu->bevel_radius != 0.0f) {
Nurb *nu;
for (nu = cu->nurb.first; nu; nu = nu->next) {

View File

@ -6856,9 +6856,9 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op)
/* Compensate for different bevel depth. */
bool do_radius = false;
float compensate_radius = 0.0f;
if (cu->ext2 != 0.0f && cu_active->ext2 != 0.0f) {
if (cu->bevel_radius != 0.0f && cu_active->bevel_radius != 0.0f) {
float compensate_scale = mat4_to_scale(cmat);
compensate_radius = cu->ext2 / cu_active->ext2 * compensate_scale;
compensate_radius = cu->bevel_radius / cu_active->bevel_radius * compensate_scale;
do_radius = true;
}

View File

@ -144,7 +144,7 @@ static float stroke_elem_radius_from_pressure(const struct CurveDrawData *cdd,
const float pressure)
{
const Curve *cu = cdd->vc.obedit->data;
return ((pressure * cdd->radius.range) + cdd->radius.min) * cu->ext2;
return ((pressure * cdd->radius.range) + cdd->radius.min) * cu->bevel_radius;
}
static float stroke_elem_radius(const struct CurveDrawData *cdd, const struct StrokeElem *selem)
@ -364,7 +364,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C),
Object *obedit = cdd->vc.obedit;
Curve *cu = obedit->data;
if (cu->ext2 > 0.0f) {
if (cu->bevel_radius > 0.0f) {
BLI_mempool_iter iter;
const struct StrokeElem *selem;

View File

@ -1324,7 +1324,7 @@ static void gpencil_layer_to_curve(bContext *C,
cu->flag |= CU_3D;
cu->bevresol = gtd->bevel_resolution;
cu->ext2 = gtd->bevel_depth;
cu->bevel_radius = gtd->bevel_depth;
gtd->inittime = ((bGPDstroke *)gpf->strokes.first)->inittime;

View File

@ -34,7 +34,7 @@
.pathlen = 100, \
.resolu = 12, \
.resolv = 12, \
.width = 1.0, \
.offset = 1.0, \
.wordspace = 1.0, \
.spacing = 1.0f, \
.linedist = 1.0, \

View File

@ -237,7 +237,7 @@ typedef struct Curve {
int pathlen;
short bevresol, totcol;
int flag;
float width, ext1, ext2;
float offset, extrude, bevel_radius;
/* default */
short resolu, resolv;

View File

@ -145,3 +145,6 @@ DNA_STRUCT_RENAME_ELEM(LineartGpencilModifierData, transparency_flags, mask_swit
DNA_STRUCT_RENAME_ELEM(LineartGpencilModifierData, transparency_mask, material_mask_bits)
DNA_STRUCT_RENAME_ELEM(SurfaceDeformModifierData, numverts, num_bind_verts)
DNA_STRUCT_RENAME_ELEM(MaterialLineArt, transparency_mask, material_mask_bits)
DNA_STRUCT_RENAME_ELEM(Curve, width, offset)
DNA_STRUCT_RENAME_ELEM(Curve, ext1, extrude)
DNA_STRUCT_RENAME_ELEM(Curve, ext2, bevel_radius)

View File

@ -569,13 +569,13 @@ static void rna_Curve_resolution_v_update_data(Main *bmain, Scene *scene, Pointe
static float rna_Curve_offset_get(PointerRNA *ptr)
{
Curve *cu = (Curve *)ptr->owner_id;
return cu->width - 1.0f;
return cu->offset - 1.0f;
}
static void rna_Curve_offset_set(PointerRNA *ptr, float value)
{
Curve *cu = (Curve *)ptr->owner_id;
cu->width = 1.0f + value;
cu->offset = 1.0f + value;
}
static int rna_Curve_body_length(PointerRNA *ptr);
@ -1656,14 +1656,14 @@ static void rna_def_curve(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Curve_bevel_resolution_update");
prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
RNA_def_property_float_sdna(prop, NULL, "width");
RNA_def_property_float_sdna(prop, NULL, "offset");
RNA_def_property_ui_range(prop, -1.0, 1.0, 0.1, 3);
RNA_def_property_float_funcs(prop, "rna_Curve_offset_get", "rna_Curve_offset_set", NULL);
RNA_def_property_ui_text(prop, "Offset", "Distance to move the curve parallel to its normals");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop = RNA_def_property(srna, "extrude", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
RNA_def_property_float_sdna(prop, NULL, "ext1");
RNA_def_property_float_sdna(prop, NULL, "extrude");
RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 3);
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_text(prop,
@ -1673,7 +1673,7 @@ static void rna_def_curve(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop = RNA_def_property(srna, "bevel_depth", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
RNA_def_property_float_sdna(prop, NULL, "ext2");
RNA_def_property_float_sdna(prop, NULL, "bevel_radius");
RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 3);
RNA_def_property_ui_text(
prop, "Bevel Depth", "Radius of the bevel geometry, not including extrusion");