Editors: move curve directory to C++

Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/110262
This commit is contained in:
Jacques Lucke
2023-07-19 15:28:46 +02:00
parent a79680b4d1
commit 18096bd18a
10 changed files with 749 additions and 711 deletions

View File

@@ -19,16 +19,16 @@ set(INC_SYS
)
set(SRC
curve_ops.c
editcurve.c
editcurve_add.c
editcurve_paint.c
editcurve_pen.c
editcurve_query.c
editcurve_select.c
curve_ops.cc
editcurve.cc
editcurve_add.cc
editcurve_paint.cc
editcurve_pen.cc
editcurve_query.cc
editcurve_select.cc
editcurve_undo.cc
editfont.c
editfont_undo.c
editfont.cc
editfont_undo.cc
curve_intern.h
)

View File

@@ -52,7 +52,9 @@
#include "curve_intern.h"
extern "C" {
#include "curve_fit_nd.h"
}
#include "UI_interface.h"
#include "UI_resources.h"
@@ -74,10 +76,10 @@ static bool curve_delete_vertices(Object *obedit, View3D *v3d);
ListBase *object_editcurve_get(Object *ob)
{
if (ob && ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF)) {
Curve *cu = ob->data;
Curve *cu = static_cast<Curve *>(ob->data);
return &cu->editnurb->nurbs;
}
return NULL;
return nullptr;
}
/** \} */
@@ -121,7 +123,7 @@ void printknots(Object *obedit)
static CVKeyIndex *init_cvKeyIndex(
void *cv, int key_index, int nu_index, int pt_index, int vertex_index)
{
CVKeyIndex *cvIndex = MEM_callocN(sizeof(CVKeyIndex), __func__);
CVKeyIndex *cvIndex = static_cast<CVKeyIndex *>(MEM_callocN(sizeof(CVKeyIndex), __func__));
cvIndex->orig_cv = cv;
cvIndex->key_index = key_index;
@@ -135,8 +137,8 @@ static CVKeyIndex *init_cvKeyIndex(
static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase)
{
Nurb *nu = editnurb->nurbs.first;
Nurb *orignu = origBase->first;
Nurb *nu = static_cast<Nurb *>(editnurb->nurbs.first);
Nurb *orignu = static_cast<Nurb *>(origBase->first);
GHash *gh;
BezTriple *bezt, *origbezt;
BPoint *bp, *origbp;
@@ -160,7 +162,8 @@ static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase)
* it might be replaced and freed while editcurve remain in use
* (in viewport render case e.g.). Note that we could use a pool to avoid
* lots of malloc's here, but... not really a problem for now. */
BezTriple *origbezt_cpy = MEM_mallocN(sizeof(*origbezt), __func__);
BezTriple *origbezt_cpy = static_cast<BezTriple *>(
MEM_mallocN(sizeof(*origbezt), __func__));
*origbezt_cpy = *origbezt;
keyIndex = init_cvKeyIndex(origbezt_cpy, key_index, nu_index, pt_index, vertex_index);
BLI_ghash_insert(gh, bezt, keyIndex);
@@ -181,7 +184,7 @@ static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase)
* it might be replaced and freed while editcurve remain in use
* (in viewport render case e.g.). Note that we could use a pool to avoid
* lots of malloc's here, but... not really a problem for now. */
BPoint *origbp_cpy = MEM_mallocN(sizeof(*origbp_cpy), __func__);
BPoint *origbp_cpy = static_cast<BPoint *>(MEM_mallocN(sizeof(*origbp_cpy), __func__));
*origbp_cpy = *origbp;
keyIndex = init_cvKeyIndex(origbp_cpy, key_index, nu_index, pt_index, vertex_index);
BLI_ghash_insert(gh, bp, keyIndex);
@@ -203,12 +206,12 @@ static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase)
static CVKeyIndex *getCVKeyIndex(EditNurb *editnurb, const void *cv)
{
return BLI_ghash_lookup(editnurb->keyindex, cv);
return static_cast<CVKeyIndex *>(BLI_ghash_lookup(editnurb->keyindex, cv));
}
static CVKeyIndex *popCVKeyIndex(EditNurb *editnurb, const void *cv)
{
return BLI_ghash_popkey(editnurb->keyindex, cv, NULL);
return static_cast<CVKeyIndex *>(BLI_ghash_popkey(editnurb->keyindex, cv, nullptr));
}
static BezTriple *getKeyIndexOrig_bezt(EditNurb *editnurb, const BezTriple *bezt)
@@ -216,7 +219,7 @@ static BezTriple *getKeyIndexOrig_bezt(EditNurb *editnurb, const BezTriple *bezt
CVKeyIndex *index = getCVKeyIndex(editnurb, bezt);
if (!index) {
return NULL;
return nullptr;
}
return (BezTriple *)index->orig_cv;
@@ -227,7 +230,7 @@ static BPoint *getKeyIndexOrig_bp(EditNurb *editnurb, BPoint *bp)
CVKeyIndex *index = getCVKeyIndex(editnurb, bp);
if (!index) {
return NULL;
return nullptr;
}
return (BPoint *)index->orig_cv;
@@ -302,7 +305,7 @@ static void keyIndex_updateCV(EditNurb *editnurb, char *cv, char *newcv, int cou
int i;
CVKeyIndex *index;
if (editnurb->keyindex == NULL) {
if (editnurb->keyindex == nullptr) {
/* No shape keys - updating not needed */
return;
}
@@ -463,7 +466,7 @@ static void switch_keys_direction(Curve *cu, Nurb *actnu)
int a;
LISTBASE_FOREACH (KeyBlock *, currkey, &cu->key->block) {
fp = currkey->data;
fp = static_cast<float *>(currkey->data);
LISTBASE_FOREACH (Nurb *, nu, nubase) {
if (nu->bezt) {
@@ -527,8 +530,9 @@ GHash *ED_curve_keyindex_hash_duplicate(GHash *keyindex)
GHASH_ITER (gh_iter, keyindex) {
void *cv = BLI_ghashIterator_getKey(&gh_iter);
CVKeyIndex *index = BLI_ghashIterator_getValue(&gh_iter);
CVKeyIndex *newIndex = MEM_mallocN(sizeof(CVKeyIndex), "dupli_keyIndexHash index");
CVKeyIndex *index = static_cast<CVKeyIndex *>(BLI_ghashIterator_getValue(&gh_iter));
CVKeyIndex *newIndex = static_cast<CVKeyIndex *>(
MEM_mallocN(sizeof(CVKeyIndex), "dupli_keyIndexHash index"));
memcpy(newIndex, index, sizeof(CVKeyIndex));
newIndex->orig_cv = MEM_dupallocN(index->orig_cv);
@@ -575,8 +579,8 @@ static void calc_keyHandles(ListBase *nurb, float *key)
prevfp = fp + (KEYELEM_FLOAT_LEN_BEZTRIPLE * (a - 1));
}
else {
prevp = NULL;
prevfp = NULL;
prevp = nullptr;
prevfp = nullptr;
}
nextp = bezt + 1;
@@ -592,7 +596,7 @@ static void calc_keyHandles(ListBase *nurb, float *key)
key_to_bezt(prevfp, prevp, &prev);
}
BKE_nurb_handle_calc(&cur, prevp ? &prev : NULL, nextp ? &next : NULL, 0, 0);
BKE_nurb_handle_calc(&cur, prevp ? &prev : nullptr, nextp ? &next : nullptr, 0, 0);
bezt_to_key(&cur, fp);
prevp = bezt;
@@ -603,8 +607,8 @@ static void calc_keyHandles(ListBase *nurb, float *key)
nextfp = startfp;
}
else {
nextp = NULL;
nextfp = NULL;
nextp = nullptr;
nextfp = nullptr;
}
}
else {
@@ -627,20 +631,20 @@ static void calc_shapeKeys(Object *obedit, ListBase *newnurbs)
{
Curve *cu = (Curve *)obedit->data;
if (cu->key == NULL) {
if (cu->key == nullptr) {
return;
}
int a, i, currkey_i;
EditNurb *editnurb = cu->editnurb;
KeyBlock *actkey = BLI_findlink(&cu->key->block, editnurb->shapenr - 1);
KeyBlock *actkey = static_cast<KeyBlock *>(BLI_findlink(&cu->key->block, editnurb->shapenr - 1));
BezTriple *bezt, *oldbezt;
BPoint *bp, *oldbp;
Nurb *newnu;
int totvert = BKE_keyblock_curve_element_count(&editnurb->nurbs);
float(*ofs)[3] = NULL;
bool *dependent = NULL;
float(*ofs)[3] = nullptr;
bool *dependent = nullptr;
float *oldkey, *newkey, *ofp;
/* editing the base key should update others */
@@ -662,7 +666,7 @@ static void calc_shapeKeys(Object *obedit, ListBase *newnurbs)
}
}
ofs = MEM_callocN(sizeof(float[3]) * totvec, "currkey->data");
ofs = static_cast<float(*)[3]>(MEM_callocN(sizeof(float[3]) * totvec, "currkey->data"));
i = 0;
LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
if (nu->bezt) {
@@ -708,14 +712,15 @@ static void calc_shapeKeys(Object *obedit, ListBase *newnurbs)
LISTBASE_FOREACH_INDEX (KeyBlock *, currkey, &cu->key->block, currkey_i) {
const bool apply_offset = (ofs && (currkey != actkey) && dependent[currkey_i]);
float *fp = newkey = MEM_callocN(cu->key->elemsize * totvert, "currkey->data");
ofp = oldkey = currkey->data;
float *fp = newkey = static_cast<float *>(
MEM_callocN(cu->key->elemsize * totvert, "currkey->data"));
ofp = oldkey = static_cast<float *>(currkey->data);
Nurb *nu = editnurb->nurbs.first;
Nurb *nu = static_cast<Nurb *>(editnurb->nurbs.first);
/* We need to restore to original curve into newnurb, *not* editcurve's nurbs.
* Otherwise, in case we update obdata *without* leaving editmode (e.g. viewport render),
* we would invalidate editcurve. */
newnu = newnurbs->first;
newnu = static_cast<Nurb *>(newnurbs->first);
i = 0;
while (nu) {
if (currkey == actkey) {
@@ -901,7 +906,7 @@ static void fcurve_path_rename(AnimData *adt,
spath = nfcu->rna_path;
nfcu->rna_path = BLI_sprintfN("%s%s", rna_path, suffix);
/* BKE_fcurve_copy() sets nfcu->grp to NULL. To maintain the groups, we need to keep the
/* BKE_fcurve_copy() sets nfcu->grp to nullptr. To maintain the groups, we need to keep the
* pointer. As a result, the group's 'channels' pointers will be wrong, which is fixed by
* calling `action_groups_reconstruct(action)` later, after all fcurves have been renamed. */
nfcu->grp = fcu->grp;
@@ -943,7 +948,7 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves)
CVKeyIndex *keyIndex;
char rna_path[64], orig_rna_path[64];
AnimData *adt = BKE_animdata_from_id(&cu->id);
ListBase curves = {NULL, NULL};
ListBase curves = {nullptr, nullptr};
int nu_index = 0;
LISTBASE_FOREACH_INDEX (Nurb *, nu, &editnurb->nurbs, nu_index) {
@@ -1020,7 +1025,7 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves)
nu_index = 0;
LISTBASE_FOREACH_INDEX (Nurb *, nu, &editnurb->nurbs, nu_index) {
keyIndex = NULL;
keyIndex = nullptr;
if (nu->pntsu) {
if (nu->bezt) {
keyIndex = getCVKeyIndex(editnurb, &nu->bezt[0]);
@@ -1049,7 +1054,7 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves)
}
*orig_curves = curves;
if (adt != NULL) {
if (adt != nullptr) {
BKE_action_groups_reconstruct(adt->action);
}
}
@@ -1067,7 +1072,7 @@ int ED_curve_updateAnimPaths(Main *bmain, Curve *cu)
return 0;
}
if (adt->action != NULL) {
if (adt->action != nullptr) {
curve_rename_fcurves(cu, &adt->action->curves);
DEG_id_tag_update(&adt->action->id, ID_RECALC_COPY_ON_WRITE);
}
@@ -1104,7 +1109,8 @@ static int *init_index_map(Object *obedit, int *r_old_totvert)
}
}
old_to_new_map = MEM_mallocN(old_totvert * sizeof(int), "curve old to new index map");
old_to_new_map = static_cast<int *>(
MEM_mallocN(old_totvert * sizeof(int), "curve old to new index map"));
for (int i = 0; i < old_totvert; i++) {
old_to_new_map[i] = -1;
}
@@ -1156,10 +1162,10 @@ static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit)
{
Curve *curve = (Curve *)obedit->data;
EditNurb *editnurb = curve->editnurb;
int *old_to_new_map = NULL;
int *old_to_new_map = nullptr;
int old_totvert;
if (editnurb->keyindex == NULL) {
if (editnurb->keyindex == nullptr) {
/* TODO(sergey): Happens when separating curves, this would lead to
* the wrong indices in the hook modifier, address this together with
* other indices issues.
@@ -1172,7 +1178,7 @@ static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit)
if ((object->parent) && (object->parent->data == curve) &&
ELEM(object->partype, PARVERT1, PARVERT3))
{
if (old_to_new_map == NULL) {
if (old_to_new_map == nullptr) {
old_to_new_map = init_index_map(obedit, &old_totvert);
}
@@ -1201,7 +1207,7 @@ static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit)
HookModifierData *hmd = (HookModifierData *)md;
int i, j;
if (old_to_new_map == NULL) {
if (old_to_new_map == nullptr) {
old_to_new_map = init_index_map(obedit, &old_totvert);
}
@@ -1222,7 +1228,7 @@ static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit)
}
}
}
if (old_to_new_map != NULL) {
if (old_to_new_map != nullptr) {
MEM_freeN(old_to_new_map);
}
}
@@ -1231,13 +1237,13 @@ void ED_curve_editnurb_load(Main *bmain, Object *obedit)
{
ListBase *editnurb = object_editcurve_get(obedit);
if (obedit == NULL) {
if (obedit == nullptr) {
return;
}
if (ELEM(obedit->type, OB_CURVES_LEGACY, OB_SURF)) {
Curve *cu = obedit->data;
ListBase newnurb = {NULL, NULL}, oldnurb = cu->nurb;
Curve *cu = static_cast<Curve *>(obedit->data);
ListBase newnurb = {nullptr, nullptr}, oldnurb = cu->nurb;
remap_hooks_and_vertex_parents(bmain, obedit);
@@ -1258,7 +1264,7 @@ void ED_curve_editnurb_load(Main *bmain, Object *obedit)
cu->nurb = newnurb;
ED_curve_updateAnimPaths(bmain, obedit->data);
ED_curve_updateAnimPaths(bmain, static_cast<Curve *>(obedit->data));
BKE_nurbList_free(&oldnurb);
}
@@ -1274,7 +1280,7 @@ void ED_curve_editnurb_make(Object *obedit)
actkey = BKE_keyblock_from_object(obedit);
if (actkey) {
/* TODO(@ideasman42): undo_system: investigate why this was needed. */
/* TODO(@ideasman42): undo_system: investigate why this was needed. */
#if 0
undo_editmode_clear();
#endif
@@ -1285,7 +1291,7 @@ void ED_curve_editnurb_make(Object *obedit)
BKE_curve_editNurb_keyIndex_free(&editnurb->keyindex);
}
else {
editnurb = MEM_callocN(sizeof(EditNurb), "editnurb");
editnurb = static_cast<EditNurb *>(MEM_callocN(sizeof(EditNurb), "editnurb"));
cu->editnurb = editnurb;
}
@@ -1310,7 +1316,7 @@ void ED_curve_editnurb_make(Object *obedit)
void ED_curve_editnurb_free(Object *obedit)
{
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
BKE_curve_editNurb_free(cu);
}
@@ -1346,10 +1352,10 @@ static int separate_exec(bContext *C, wmOperator *op)
Object *oldob, *newob;
Curve *oldcu, *newcu;
EditNurb *newedit;
ListBase newnurb = {NULL, NULL};
ListBase newnurb = {nullptr, nullptr};
oldob = oldbase->object;
oldcu = oldob->data;
oldcu = static_cast<Curve *>(oldob->data);
if (oldcu->key) {
status.error_vertex_keys++;
@@ -1372,14 +1378,14 @@ static int separate_exec(bContext *C, wmOperator *op)
/* 2. Duplicate the object and data. */
/* Take into account user preferences for duplicating actions. */
const eDupli_ID_Flags dupflag = (U.dupflag & USER_DUP_ACT);
const eDupli_ID_Flags dupflag = eDupli_ID_Flags((U.dupflag & USER_DUP_ACT));
newbase = ED_object_add_duplicate(bmain, scene, view_layer, oldbase, dupflag);
DEG_relations_tag_update(bmain);
newob = newbase->object;
newcu = newob->data = BKE_id_copy(bmain, &oldcu->id);
newcu->editnurb = NULL;
newcu = static_cast<Curve *>(newob->data = BKE_id_copy(bmain, &oldcu->id));
newcu->editnurb = nullptr;
id_us_min(&oldcu->id); /* Because new curve is a copy: reduce user count. */
/* 3. Put new object in editmode, clear it and set separated nurbs. */
@@ -1476,13 +1482,13 @@ static int curve_split_exec(bContext *C, wmOperator *op)
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
if (!ED_curve_select_check(v3d, cu->editnurb)) {
continue;
}
ListBase newnurb = {NULL, NULL};
ListBase newnurb = {nullptr, nullptr};
adduplicateflagNurb(obedit, v3d, &newnurb, SELECT, true);
@@ -1498,13 +1504,13 @@ static int curve_split_exec(bContext *C, wmOperator *op)
cu->actnu -= len_orig - BLI_listbase_count(editnurb);
BLI_movelisttolist(editnurb, &newnurb);
if (ED_curve_updateAnimPaths(bmain, obedit->data)) {
if (ED_curve_updateAnimPaths(bmain, static_cast<Curve *>(obedit->data))) {
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
}
changed = true;
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
MEM_freeN(objects);
@@ -1682,7 +1688,7 @@ static void weightflagNurb(ListBase *editnurb, short flag, float w)
static void ed_surf_delete_selected(Object *obedit)
{
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
ListBase *editnurb = object_editcurve_get(obedit);
BPoint *bp, *bpn, *newbp;
int a, b, newu, newv;
@@ -1711,7 +1717,7 @@ static void ed_surf_delete_selected(Object *obedit)
BLI_remlink(editnurb, nu);
keyIndex_delNurb(cu->editnurb, nu);
BKE_nurb_free(nu);
nu = NULL;
nu = nullptr;
}
else {
if (isNurbselU(nu, &newv, SELECT)) {
@@ -1781,7 +1787,7 @@ static void ed_surf_delete_selected(Object *obedit)
static void ed_curve_delete_selected(Object *obedit, View3D *v3d)
{
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditNurb *editnurb = cu->editnurb;
ListBase *nubase = &editnurb->nurbs;
BezTriple *bezt, *bezt1;
@@ -1812,7 +1818,7 @@ static void ed_curve_delete_selected(Object *obedit, View3D *v3d)
BLI_remlink(nubase, nu);
keyIndex_delNurb(editnurb, nu);
BKE_nurb_free(nu);
nu = NULL;
nu = nullptr;
}
}
}
@@ -1838,15 +1844,15 @@ static void ed_curve_delete_selected(Object *obedit, View3D *v3d)
BLI_remlink(nubase, nu);
keyIndex_delNurb(editnurb, nu);
BKE_nurb_free(nu);
nu = NULL;
nu = nullptr;
}
}
}
/* Never allow the order to exceed the number of points
* NOTE: this is ok but changes unselected nurbs, disable for now. */
/* Never allow the order to exceed the number of points
* NOTE: this is ok but changes unselected nurbs, disable for now. */
#if 0
if ((nu != NULL) && (nu->type == CU_NURBS)) {
if ((nu != nullptr) && (nu->type == CU_NURBS)) {
clamp_nurb_order_u(nu);
}
#endif
@@ -1902,8 +1908,8 @@ static void ed_curve_delete_selected(Object *obedit, View3D *v3d)
MEM_freeN(nu->bp);
nu->bp = bp1;
/* Never allow the order to exceed the number of points
* NOTE: this is ok but changes unselected nurbs, disable for now. */
/* Never allow the order to exceed the number of points
* NOTE: this is ok but changes unselected nurbs, disable for now. */
#if 0
if (nu->type == CU_NURBS) {
clamp_nurb_order_u(nu);
@@ -2012,10 +2018,10 @@ static int sel_to_copy_ints(const BPoint *bp,
return selected_leg_count;
}
typedef struct NurbDim {
struct NurbDim {
int pntsu;
int pntsv;
} NurbDim;
};
static NurbDim editnurb_find_max_points_num(const EditNurb *editnurb)
{
@@ -2036,8 +2042,10 @@ bool ed_editnurb_extrude_flag(EditNurb *editnurb, const uint8_t flag)
const NurbDim max = editnurb_find_max_points_num(editnurb);
/* One point induces at most one interval. Except single point case, it can give + 1.
* Another +1 is for first element of the first interval. */
int *const intvls_u = MEM_malloc_arrayN(max.pntsu + 2, sizeof(int), "extrudeNurb0");
int *const intvls_v = MEM_malloc_arrayN(max.pntsv + 2, sizeof(int), "extrudeNurb1");
int *const intvls_u = static_cast<int *>(
MEM_malloc_arrayN(max.pntsu + 2, sizeof(int), "extrudeNurb0"));
int *const intvls_v = static_cast<int *>(
MEM_malloc_arrayN(max.pntsv + 2, sizeof(int), "extrudeNurb1"));
bool ok = false;
LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
@@ -2295,7 +2303,7 @@ static void adduplicateflagNurb(
if (ED_curve_nurb_select_check(v3d, nu)) {
/* A rectangular area in nurb has to be selected and if splitting
* must be in U or V direction. */
usel = MEM_callocN(nu->pntsu, "adduplicateN3");
usel = static_cast<char *>(MEM_callocN(nu->pntsu, "adduplicateN3"));
bp = nu->bp;
for (a = 0; a < nu->pntsv; a++) {
for (b = 0; b < nu->pntsu; b++, bp++) {
@@ -2551,7 +2559,7 @@ static void adduplicateflagNurb(
/** \name Switch Direction Operator
* \{ */
static int switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
static int switch_direction_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
const Scene *scene = CTX_data_scene(C);
@@ -2563,7 +2571,7 @@ static int switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
if (!ED_curve_select_check(v3d, cu->editnurb)) {
continue;
@@ -2582,11 +2590,11 @@ static int switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
}
}
if (ED_curve_updateAnimPaths(bmain, obedit->data)) {
if (ED_curve_updateAnimPaths(bmain, static_cast<Curve *>(obedit->data))) {
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
}
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
}
MEM_freeN(objects);
@@ -2647,7 +2655,7 @@ static int set_goal_weight_exec(bContext *C, wmOperator *op)
}
}
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
}
@@ -2715,7 +2723,7 @@ static int set_radius_exec(bContext *C, wmOperator *op)
}
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
MEM_freeN(objects);
@@ -2792,7 +2800,7 @@ static void smooth_single_bp(BPoint *bp,
}
}
static int smooth_exec(bContext *C, wmOperator *UNUSED(op))
static int smooth_exec(bContext *C, wmOperator * /*op*/)
{
const float factor = 1.0f / 6.0f;
const Scene *scene = CTX_data_scene(C);
@@ -2811,7 +2819,7 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op))
LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->bezt) {
/* duplicate the curve to use in weight calculation */
const BezTriple *bezt_orig = MEM_dupallocN(nu->bezt);
const BezTriple *bezt_orig = static_cast<const BezTriple *>(MEM_dupallocN(nu->bezt));
BezTriple *bezt;
changed = false;
@@ -2847,7 +2855,7 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op))
}
else if (nu->bp) {
/* Same as above, keep these the same! */
const BPoint *bp_orig = MEM_dupallocN(nu->bp);
const BPoint *bp_orig = static_cast<const BPoint *>(MEM_dupallocN(nu->bp));
BPoint *bp;
if (nu->flagu & CU_NURB_CYCLIC) {
@@ -2875,7 +2883,7 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op))
}
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
MEM_freeN(objects);
@@ -3090,7 +3098,7 @@ static void curve_smooth_value(ListBase *editnurb, const int bezt_offsetof, cons
/** \name Smooth Weight Operator
* \{ */
static int curve_smooth_weight_exec(bContext *C, wmOperator *UNUSED(op))
static int curve_smooth_weight_exec(bContext *C, wmOperator * /*op*/)
{
const Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -3105,7 +3113,7 @@ static int curve_smooth_weight_exec(bContext *C, wmOperator *UNUSED(op))
curve_smooth_value(editnurb, offsetof(BezTriple, weight), offsetof(BPoint, weight));
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
MEM_freeN(objects);
@@ -3134,7 +3142,7 @@ void CURVE_OT_smooth_weight(wmOperatorType *ot)
/** \name Smooth Radius Operator
* \{ */
static int curve_smooth_radius_exec(bContext *C, wmOperator *UNUSED(op))
static int curve_smooth_radius_exec(bContext *C, wmOperator * /*op*/)
{
const Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -3149,7 +3157,7 @@ static int curve_smooth_radius_exec(bContext *C, wmOperator *UNUSED(op))
curve_smooth_value(editnurb, offsetof(BezTriple, radius), offsetof(BPoint, radius));
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
MEM_freeN(objects);
@@ -3178,7 +3186,7 @@ void CURVE_OT_smooth_radius(wmOperatorType *ot)
/** \name Smooth Tilt Operator
* \{ */
static int curve_smooth_tilt_exec(bContext *C, wmOperator *UNUSED(op))
static int curve_smooth_tilt_exec(bContext *C, wmOperator * /*op*/)
{
const Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -3193,7 +3201,7 @@ static int curve_smooth_tilt_exec(bContext *C, wmOperator *UNUSED(op))
curve_smooth_value(editnurb, offsetof(BezTriple, tilt), offsetof(BPoint, tilt));
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
MEM_freeN(objects);
@@ -3235,7 +3243,7 @@ static int hide_exec(bContext *C, wmOperator *op)
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
if (!(invert || ED_curve_select_check(v3d, cu->editnurb))) {
continue;
@@ -3293,9 +3301,9 @@ static int hide_exec(bContext *C, wmOperator *op)
}
}
DEG_id_tag_update(obedit->data, ID_RECALC_GEOMETRY);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
BKE_curve_nurb_vert_active_validate(obedit->data);
BKE_curve_nurb_vert_active_validate(static_cast<Curve *>(obedit->data));
}
MEM_freeN(objects);
return OPERATOR_FINISHED;
@@ -3372,7 +3380,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
}
if (changed) {
DEG_id_tag_update(obedit->data,
DEG_id_tag_update(static_cast<ID *>(obedit->data),
ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
changed_multi = true;
@@ -3412,7 +3420,7 @@ void CURVE_OT_reveal(wmOperatorType *ot)
*/
static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
{
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditNurb *editnurb = cu->editnurb;
BezTriple *bezt, *beztnew, *beztn;
BPoint *bp, *prevbp, *bpnew, *bpn;
@@ -3437,7 +3445,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
bezt = nu->bezt;
while (a--) {
nextbezt = BKE_nurb_bezt_get_next(nu, bezt);
if (nextbezt == NULL) {
if (nextbezt == nullptr) {
break;
}
@@ -3460,7 +3468,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
beztn++;
nextbezt = BKE_nurb_bezt_get_next(nu, bezt);
if (nextbezt == NULL) {
if (nextbezt == nullptr) {
break;
}
@@ -3529,7 +3537,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
bp = nu->bp;
while (a--) {
nextbp = BKE_nurb_bpoint_get_next(nu, bp);
if (nextbp == NULL) {
if (nextbp == nullptr) {
break;
}
@@ -3554,7 +3562,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
bpn++;
nextbp = BKE_nurb_bpoint_get_next(nu, bp);
if (nextbp == NULL) {
if (nextbp == nullptr) {
break;
}
@@ -3624,8 +3632,8 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
* needed.
*/
/* selection-arrays */
usel = MEM_callocN(sizeof(int) * nu->pntsu, "subivideNurb3");
vsel = MEM_callocN(sizeof(int) * nu->pntsv, "subivideNurb3");
usel = static_cast<int *>(MEM_callocN(sizeof(int) * nu->pntsu, "subivideNurb3"));
vsel = static_cast<int *>(MEM_callocN(sizeof(int) * nu->pntsv, "subivideNurb3"));
sel = 0;
/* Count the number of selected points. */
@@ -3651,7 +3659,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
int tot = ((number_cuts + 1) * nu->pntsu - number_cuts) *
((number_cuts + 1) * nu->pntsv - number_cuts);
bpn = bpnew = MEM_mallocN(tot * sizeof(BPoint), "subdivideNurb4");
bpn = bpnew = static_cast<BPoint *>(MEM_mallocN(tot * sizeof(BPoint), "subdivideNurb4"));
bp = nu->bp;
/* first subdivide rows */
for (a = 0; a < nu->pntsv; a++) {
@@ -3711,8 +3719,8 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
}
if (sel) { /* V ! */
bpn = bpnew = MEM_mallocN((sel + nu->pntsv) * nu->pntsu * sizeof(BPoint),
"subdivideNurb4");
bpn = bpnew = static_cast<BPoint *>(
MEM_mallocN((sel + nu->pntsv) * nu->pntsu * sizeof(BPoint), "subdivideNurb4"));
bp = nu->bp;
for (a = 0; a < nu->pntsv; a++) {
for (b = 0; b < nu->pntsu; b++) {
@@ -3761,8 +3769,8 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
if (sel) { /* U ! */
/* Inserting U points is sort of 'default' Flat curves only get
* U points inserted in them. */
bpn = bpnew = MEM_mallocN((sel + nu->pntsu) * nu->pntsv * sizeof(BPoint),
"subdivideNurb4");
bpn = bpnew = static_cast<BPoint *>(
MEM_mallocN((sel + nu->pntsu) * nu->pntsv * sizeof(BPoint), "subdivideNurb4"));
bp = nu->bp;
for (a = 0; a < nu->pntsv; a++) {
for (b = 0; b < nu->pntsu; b++) {
@@ -3816,7 +3824,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
if (!ED_curve_select_check(v3d, cu->editnurb)) {
continue;
@@ -3829,7 +3837,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
}
WM_event_add_notifier(C, NC_GEOM | ND_DATA, cu);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
MEM_freeN(objects);
@@ -3886,7 +3894,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op)
LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (ED_curve_nurb_select_check(v3d, nu)) {
const int pntsu_prev = nu->pntsu;
const char *err_msg = NULL;
const char *err_msg = nullptr;
if (BKE_nurb_type_convert(nu, type, use_handles, &err_msg)) {
changed = true;
if (pntsu_prev != nu->pntsu) {
@@ -3900,15 +3908,15 @@ static int set_spline_type_exec(bContext *C, wmOperator *op)
}
if (changed) {
if (ED_curve_updateAnimPaths(bmain, obedit->data)) {
if (ED_curve_updateAnimPaths(bmain, static_cast<Curve *>(obedit->data))) {
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
}
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
if (changed_size) {
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
cu->actvert = CU_ACT_NONE;
}
@@ -3927,7 +3935,7 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot)
{CU_POLY, "POLY", 0, "Poly", ""},
{CU_BEZIER, "BEZIER", 0, "Bezier", ""},
{CU_NURBS, "NURBS", 0, "NURBS", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
@@ -3970,7 +3978,7 @@ static int set_handle_type_exec(bContext *C, wmOperator *op)
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
if (!ED_curve_select_check(v3d, cu->editnurb)) {
continue;
@@ -3980,7 +3988,7 @@ static int set_handle_type_exec(bContext *C, wmOperator *op)
BKE_nurbList_handles_set(editnurb, handle_type);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
MEM_freeN(objects);
return OPERATOR_FINISHED;
@@ -3995,7 +4003,7 @@ void CURVE_OT_handle_type_set(wmOperatorType *ot)
{5, "ALIGNED", 0, "Aligned", ""},
{6, "FREE_ALIGN", 0, "Free", ""},
{3, "TOGGLE_FREE_ALIGN", 0, "Toggle Free/Align", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
@@ -4034,7 +4042,7 @@ static int curve_normals_make_consistent_exec(bContext *C, wmOperator *op)
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
if (!ED_curve_select_check(v3d, cu->editnurb)) {
continue;
@@ -4044,7 +4052,7 @@ static int curve_normals_make_consistent_exec(bContext *C, wmOperator *op)
BKE_nurbList_handles_recalculate(editnurb, calc_length, SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
MEM_freeN(objects);
return OPERATOR_FINISHED;
@@ -4081,7 +4089,7 @@ static void switchdirection_knots(float *base, int tot)
float *fp1, *fp2, *tempf;
int a;
if (base == NULL || tot == 0) {
if (base == nullptr || tot == 0) {
return;
}
@@ -4100,7 +4108,7 @@ static void switchdirection_knots(float *base, int tot)
/* and make in increasing order again */
a = tot - 1;
fp1 = base;
fp2 = tempf = MEM_mallocN(sizeof(float) * tot, "switchdirect");
fp2 = tempf = static_cast<float *>(MEM_mallocN(sizeof(float) * tot, "switchdirect"));
while (a--) {
fp2[0] = fabsf(fp1[1] - fp1[0]);
fp1++;
@@ -4134,7 +4142,7 @@ static void rotate_direction_nurb(Nurb *nu)
SWAP(float *, nu->knotsu, nu->knotsv);
switchdirection_knots(nu->knotsv, KNOTSV(nu));
temp = MEM_dupallocN(nu->bp);
temp = static_cast<BPoint *>(MEM_dupallocN(nu->bp));
bp1 = nu->bp;
for (v = 0; v < nu->pntsv; v++) {
for (u = 0; u < nu->pntsu; u++, bp1++) {
@@ -4162,15 +4170,15 @@ static bool is_u_selected(Nurb *nu, int u)
return false;
}
typedef struct NurbSort {
struct NurbSort {
struct NurbSort *next, *prev;
Nurb *nu;
float vec[3];
} NurbSort;
};
static void make_selection_list_nurb(View3D *v3d, ListBase *editnurb, ListBase *nsortbase)
{
ListBase nbase = {NULL, NULL};
ListBase nbase = {nullptr, nullptr};
NurbSort *nus, *nustest, *headdo, *taildo;
BPoint *bp;
float dist, headdist, taildist;
@@ -4194,7 +4202,7 @@ static void make_selection_list_nurb(View3D *v3d, ListBase *editnurb, ListBase *
}
/* just add the first one */
nus = nbase.first;
nus = static_cast<NurbSort *>(nbase.first);
BLI_remlink(&nbase, nus);
BLI_addtail(nsortbase, nus);
@@ -4202,9 +4210,9 @@ static void make_selection_list_nurb(View3D *v3d, ListBase *editnurb, ListBase *
while (nbase.first) {
headdist = taildist = 1.0e30;
headdo = taildo = NULL;
headdo = taildo = nullptr;
nustest = nbase.first;
nustest = static_cast<NurbSort *>(nbase.first);
while (nustest) {
dist = len_v3v3(nustest->vec, ((NurbSort *)nsortbase->first)->vec);
@@ -4354,7 +4362,8 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
nu1->orderv++;
}
temp = nu1->bp;
nu1->bp = MEM_mallocN(nu1->pntsu * nu1->pntsv * sizeof(BPoint), "mergeBP");
nu1->bp = static_cast<BPoint *>(
MEM_mallocN(nu1->pntsu * nu1->pntsv * sizeof(BPoint), "mergeBP"));
bp = nu1->bp;
bp1 = temp;
@@ -4400,11 +4409,11 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
static int merge_nurb(View3D *v3d, Object *obedit)
{
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
ListBase *editnurb = object_editcurve_get(obedit);
NurbSort *nus1, *nus2;
bool ok = true;
ListBase nsortbase = {NULL, NULL};
ListBase nsortbase = {nullptr, nullptr};
make_selection_list_nurb(v3d, editnurb, &nsortbase);
@@ -4413,7 +4422,7 @@ static int merge_nurb(View3D *v3d, Object *obedit)
return CURVE_MERGE_ERR_FEW_SELECTION;
}
nus1 = nsortbase.first;
nus1 = static_cast<NurbSort *>(nsortbase.first);
nus2 = nus1->next;
/* resolution match, to avoid uv rotations */
@@ -4456,7 +4465,7 @@ static int merge_nurb(View3D *v3d, Object *obedit)
}
BLI_freelistN(&nsortbase);
BKE_curve_nurb_active_set(obedit->data, NULL);
BKE_curve_nurb_active_set(static_cast<Curve *>(obedit->data), nullptr);
return ok ? CURVE_MERGE_OK : CURVE_MERGE_ERR_RESOLUTION_SOME;
}
@@ -4481,7 +4490,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
if (!ED_curve_select_check(v3d, cu->editnurb)) {
status.unselected++;
@@ -4489,16 +4498,16 @@ static int make_segment_exec(bContext *C, wmOperator *op)
}
ListBase *nubase = object_editcurve_get(obedit);
Nurb *nu, *nu1 = NULL, *nu2 = NULL;
Nurb *nu, *nu1 = nullptr, *nu2 = nullptr;
BPoint *bp;
bool ok = false;
/* first decide if this is a surface merge! */
if (obedit->type == OB_SURF) {
nu = nubase->first;
nu = static_cast<Nurb *>(nubase->first);
}
else {
nu = NULL;
nu = nullptr;
}
while (nu) {
@@ -4545,7 +4554,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
}
/* find both nurbs and points, nu1 will be put behind nu2 */
for (nu = nubase->first; nu; nu = nu->next) {
for (nu = static_cast<Nurb *>(nubase->first); nu; nu = nu->next) {
if (nu->pntsu == 1) {
nu->flagu &= ~CU_NURB_CYCLIC;
}
@@ -4554,10 +4563,10 @@ static int make_segment_exec(bContext *C, wmOperator *op)
if (nu->type == CU_BEZIER) {
if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, &(nu->bezt[nu->pntsu - 1]))) {
/* Last point is selected, preferred for nu2 */
if (nu2 == NULL) {
if (nu2 == nullptr) {
nu2 = nu;
}
else if (nu1 == NULL) {
else if (nu1 == nullptr) {
nu1 = nu;
/* Just in case both of first/last CV are selected check
@@ -4571,10 +4580,10 @@ static int make_segment_exec(bContext *C, wmOperator *op)
}
else if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, nu->bezt)) {
/* First point is selected, preferred for nu1 */
if (nu1 == NULL) {
if (nu1 == nullptr) {
nu1 = nu;
}
else if (nu2 == NULL) {
else if (nu2 == nullptr) {
nu2 = nu;
/* Just in case both of first/last CV are selected check
@@ -4595,10 +4604,10 @@ static int make_segment_exec(bContext *C, wmOperator *op)
bp = nu->bp;
if (bp[nu->pntsu - 1].f1 & SELECT) {
if (nu2 == NULL) {
if (nu2 == nullptr) {
nu2 = nu;
}
else if (nu1 == NULL) {
else if (nu1 == nullptr) {
nu1 = nu;
if ((bp->f1 & SELECT) == 0) {
@@ -4608,10 +4617,10 @@ static int make_segment_exec(bContext *C, wmOperator *op)
}
}
else if (bp->f1 & SELECT) {
if (nu1 == NULL) {
if (nu1 == nullptr) {
nu1 = nu;
}
else if (nu2 == NULL) {
else if (nu2 == nullptr) {
nu2 = nu;
if ((bp[nu->pntsu - 1].f1 & SELECT) == 0) {
@@ -4643,7 +4652,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
BLI_remlink(nubase, nu2);
keyIndex_delNurb(cu->editnurb, nu2);
BKE_nurb_free(nu2);
nu2 = NULL;
nu2 = nullptr;
BKE_nurb_handles_calc(nu1);
}
else {
@@ -4666,7 +4675,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
}
keyIndex_delNurb(cu->editnurb, nu2);
BKE_nurb_free(nu2);
nu2 = NULL;
nu2 = nullptr;
}
BKE_curve_nurb_active_set(cu, nu1); /* for selected */
@@ -4701,7 +4710,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
continue;
}
if (ED_curve_updateAnimPaths(bmain, obedit->data)) {
if (ED_curve_updateAnimPaths(bmain, static_cast<Curve *>(obedit->data))) {
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
}
@@ -4709,7 +4718,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
curve_merge_tag_object:
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
MEM_freeN(objects);
@@ -4781,9 +4790,9 @@ bool ED_curve_editnurb_select_pick(bContext *C,
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewContext vc;
Nurb *nu;
BezTriple *bezt = NULL;
BPoint *bp = NULL;
Base *basact = NULL;
BezTriple *bezt = nullptr;
BPoint *bp = nullptr;
Base *basact = nullptr;
short hand;
bool changed = false;
@@ -4811,7 +4820,8 @@ bool ED_curve_editnurb_select_pick(bContext *C,
ED_curve_deselect_all(((Curve *)ob_iter->data)->editnurb);
DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT | ID_RECALC_COPY_ON_WRITE);
DEG_id_tag_update(static_cast<ID *>(ob_iter->data),
ID_RECALC_SELECT | ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob_iter->data);
}
MEM_freeN(objects);
@@ -4821,7 +4831,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
if (found) {
Object *obedit = basact->object;
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
ListBase *editnurb = object_editcurve_get(obedit);
const void *vert = BKE_curve_vert_active_get(cu);
@@ -4968,7 +4978,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
/* Change active material on object. */
if (nu->mat_nr != obedit->actcol - 1) {
obedit->actcol = nu->mat_nr + 1;
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, NULL);
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, nullptr);
}
BKE_view_layer_synced_ensure(vc.scene, vc.view_layer);
@@ -4976,7 +4986,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
ED_object_base_activate(C, basact);
}
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT | ID_RECALC_COPY_ON_WRITE);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT | ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
changed = true;
@@ -5116,7 +5126,7 @@ static int spin_exec(bContext *C, wmOperator *op)
}
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
MEM_freeN(objects);
@@ -5129,7 +5139,7 @@ static int spin_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int spin_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
Scene *scene = CTX_data_scene(C);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
@@ -5163,7 +5173,7 @@ void CURVE_OT_spin(wmOperatorType *ot)
RNA_def_float_vector_xyz(ot->srna,
"center",
3,
NULL,
nullptr,
-OBJECT_ADD_SIZE_MAXF,
OBJECT_ADD_SIZE_MAXF,
"Center",
@@ -5171,7 +5181,7 @@ void CURVE_OT_spin(wmOperatorType *ot)
-1000.0f,
1000.0f);
RNA_def_float_vector(
ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -1.0f, 1.0f);
ot->srna, "axis", 3, nullptr, -1.0f, 1.0f, "Axis", "Axis in global view space", -1.0f, 1.0f);
}
/** \} */
@@ -5208,7 +5218,7 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d)
bool duplic_first = false;
bool duplic_last = false;
if (nu->type == CU_BEZIER) {
BezTriple *bezt, *bezt_prev = NULL;
BezTriple *bezt, *bezt_prev = nullptr;
BezTriple bezt_stack;
bool is_cyclic = false;
if (pnt_len == 1) {
@@ -5266,13 +5276,13 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d)
is_prev_selected = false;
}
else {
bezt_prev = NULL;
bezt_prev = nullptr;
}
BezTriple *bezt_src, *bezt_dst, *bezt_src_iter, *bezt_dst_iter;
const int new_len = pnt_len + new_points;
bezt_src = nu->bezt;
bezt_dst = MEM_mallocN(new_len * sizeof(BezTriple), __func__);
bezt_dst = static_cast<BezTriple *>(MEM_mallocN(new_len * sizeof(BezTriple), __func__));
bezt_src_iter = &bezt_src[0];
bezt_dst_iter = &bezt_dst[0];
i = 0;
@@ -5321,7 +5331,7 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d)
}
}
else {
BPoint *bp, *bp_prev = NULL;
BPoint *bp, *bp_prev = nullptr;
BPoint bp_stack;
if (pnt_len == 1) {
/* Single point extrusion.
@@ -5369,10 +5379,10 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d)
is_prev_selected = false;
}
else {
bp_prev = NULL;
bp_prev = nullptr;
}
bp_src = nu->bp;
bp_dst = MEM_mallocN(new_len * sizeof(BPoint), __func__);
bp_dst = static_cast<BPoint *>(MEM_mallocN(new_len * sizeof(BPoint), __func__));
bp_src_iter = &bp_src[0];
bp_dst_iter = &bp_dst[0];
i = 0;
@@ -5518,7 +5528,8 @@ int ed_editcurve_addvert(Curve *cu, EditNurb *editnurb, View3D *v3d, const float
Nurb *nurb_new;
if (!nu) {
/* Bezier as default. */
nurb_new = MEM_callocN(sizeof(Nurb), "BLI_editcurve_addvert new_bezt_nurb 2");
nurb_new = static_cast<Nurb *>(
MEM_callocN(sizeof(Nurb), "BLI_editcurve_addvert new_bezt_nurb 2"));
nurb_new->type = CU_BEZIER;
nurb_new->resolu = cu->resolu;
nurb_new->orderu = 4;
@@ -5574,7 +5585,7 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Object *obedit = CTX_data_edit_object(C);
View3D *v3d = CTX_wm_view3d(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditNurb *editnurb = cu->editnurb;
float location[3];
float imat[4][4];
@@ -5585,14 +5596,14 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
mul_m4_v3(imat, location);
if (ed_editcurve_addvert(cu, editnurb, v3d, location)) {
if (ED_curve_updateAnimPaths(bmain, obedit->data)) {
if (ED_curve_updateAnimPaths(bmain, static_cast<Curve *>(obedit->data))) {
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
}
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
return OPERATOR_FINISHED;
}
@@ -5616,7 +5627,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
BezTriple *bezt;
BPoint *bp;
cu = vc.obedit->data;
cu = static_cast<Curve *>(vc.obedit->data);
ED_curve_nurb_vert_selected_find(cu, vc.v3d, &nu, &bezt, &bp);
@@ -5633,27 +5644,26 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ED_view3d_win_to_3d_int(vc.v3d, vc.region, location, event->mval, location);
if (use_proj) {
const float mval[2] = {UNPACK2(event->mval)};
const float mval[2] = {float(event->mval[0]), float(event->mval[1])};
SnapObjectContext *snap_context = ED_transform_snap_object_context_create(vc.scene, 0);
ED_transform_snap_object_project_view3d(
snap_context,
vc.depsgraph,
vc.region,
vc.v3d,
SCE_SNAP_TO_FACE,
&(const struct SnapObjectParams){
.snap_target_select = (vc.obedit != NULL) ? SCE_SNAP_TARGET_NOT_ACTIVE :
SCE_SNAP_TARGET_ALL,
.edit_mode_type = SNAP_GEOM_FINAL,
},
NULL,
mval,
NULL,
NULL,
location,
NULL);
SnapObjectParams params{};
params.snap_target_select = (vc.obedit != nullptr) ? SCE_SNAP_TARGET_NOT_ACTIVE :
SCE_SNAP_TARGET_ALL;
params.edit_mode_type = SNAP_GEOM_FINAL;
ED_transform_snap_object_project_view3d(snap_context,
vc.depsgraph,
vc.region,
vc.v3d,
SCE_SNAP_TO_FACE,
&params,
nullptr,
mval,
nullptr,
nullptr,
location,
nullptr);
ED_transform_snap_object_context_destroy(snap_context);
}
@@ -5714,7 +5724,7 @@ void CURVE_OT_vertex_add(wmOperatorType *ot)
RNA_def_float_vector_xyz(ot->srna,
"location",
3,
NULL,
nullptr,
-OBJECT_ADD_SIZE_MAXF,
OBJECT_ADD_SIZE_MAXF,
"Location",
@@ -5729,7 +5739,7 @@ void CURVE_OT_vertex_add(wmOperatorType *ot)
/** \name Extrude Operator
* \{ */
static int curve_extrude_exec(bContext *C, wmOperator *UNUSED(op))
static int curve_extrude_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
const Scene *scene = CTX_data_scene(C);
@@ -5741,7 +5751,7 @@ static int curve_extrude_exec(bContext *C, wmOperator *UNUSED(op))
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditNurb *editnurb = cu->editnurb;
bool changed = false;
@@ -5757,12 +5767,12 @@ static int curve_extrude_exec(bContext *C, wmOperator *UNUSED(op))
}
if (changed) {
if (ED_curve_updateAnimPaths(bmain, obedit->data)) {
if (ED_curve_updateAnimPaths(bmain, static_cast<Curve *>(obedit->data))) {
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
}
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
}
MEM_freeN(objects);
@@ -5828,7 +5838,7 @@ bool curve_toggle_cyclic(View3D *v3d, ListBase *editnurb, int direction)
BKE_nurb_handles_calc(nu);
}
else if (nu->pntsv == 1 && nu->type == CU_NURBS) {
if (nu->knotsu) { /* if check_valid_nurb_u fails the knotsu can be NULL */
if (nu->knotsu) { /* if check_valid_nurb_u fails the knotsu can be nullptr */
a = nu->pntsu;
bp = nu->bp;
while (a--) {
@@ -5884,7 +5894,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
if (!ED_curve_select_check(v3d, cu->editnurb)) {
continue;
@@ -5894,7 +5904,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
if (curve_toggle_cyclic(v3d, editnurb, direction)) {
changed_multi = true;
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
}
MEM_freeN(objects);
@@ -5902,7 +5912,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
static int toggle_cyclic_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int toggle_cyclic_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
Object *obedit = CTX_data_edit_object(C);
ListBase *editnurb = object_editcurve_get(obedit);
@@ -5931,7 +5941,7 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot)
static const EnumPropertyItem direction_items[] = {
{0, "CYCLIC_U", 0, "Cyclic U", ""},
{1, "CYCLIC_V", 0, "Cyclic V", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
@@ -5976,13 +5986,13 @@ static int duplicate_exec(bContext *C, wmOperator *op)
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
if (!ED_curve_select_check(v3d, cu->editnurb)) {
continue;
}
ListBase newnurb = {NULL, NULL};
ListBase newnurb = {nullptr, nullptr};
adduplicateflagNurb(obedit, v3d, &newnurb, SELECT, false);
if (BLI_listbase_is_empty(&newnurb)) {
@@ -6041,16 +6051,16 @@ static bool curve_delete_vertices(Object *obedit, View3D *v3d)
static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
{
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditNurb *editnurb = cu->editnurb;
ListBase *nubase = &editnurb->nurbs, newnurb = {NULL, NULL};
ListBase *nubase = &editnurb->nurbs, newnurb = {nullptr, nullptr};
Nurb *nu1;
BezTriple *bezt, *bezt1, *bezt2;
BPoint *bp, *bp1, *bp2;
int a, b, starta, enda, cut, cyclicut;
LISTBASE_FOREACH (Nurb *, nu, nubase) {
nu1 = NULL;
nu1 = nullptr;
starta = enda = cut = -1;
cyclicut = 0;
@@ -6140,14 +6150,14 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
nu1 = BKE_nurb_copy(nu, cut, 1);
}
if (nu1 != NULL) {
if (nu1 != nullptr) {
ED_curve_beztcpy(editnurb, nu1->bezt, &nu->bezt[starta], cut);
BLI_addtail(&newnurb, nu1);
if (starta != 0 || enda != nu->pntsu - 1) {
nu1->flagu &= ~CU_NURB_CYCLIC;
}
nu1 = NULL;
nu1 = nullptr;
}
starta = enda = -1;
}
@@ -6267,7 +6277,7 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
nu1 = BKE_nurb_copy(nu, cut, nu->pntsv);
}
if (nu1 != NULL) {
if (nu1 != nullptr) {
for (b = 0; b < nu->pntsv; b++) {
ED_curve_bpcpy(
editnurb, &nu1->bp[b * nu1->pntsu], &nu->bp[b * nu->pntsu + starta], cut);
@@ -6277,7 +6287,7 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
if (starta != 0 || enda != nu->pntsu - 1) {
nu1->flagu &= ~CU_NURB_CYCLIC;
}
nu1 = NULL;
nu1 = nullptr;
}
starta = enda = -1;
}
@@ -6390,14 +6400,14 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
nu1 = BKE_nurb_copy(nu, nu->pntsu, cut);
}
if (nu1 != NULL) {
if (nu1 != nullptr) {
ED_curve_bpcpy(editnurb, nu1->bp, &nu->bp[starta * nu->pntsu], cut * nu->pntsu);
BLI_addtail(&newnurb, nu1);
if (starta != 0 || enda != nu->pntsv - 1) {
nu1->flagv &= ~CU_NURB_CYCLIC;
}
nu1 = NULL;
nu1 = nullptr;
}
starta = enda = -1;
}
@@ -6439,7 +6449,7 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
if (split) {
/* deselect for split operator */
for (b = 0, bezt1 = nu->bezt; b < nu->pntsu; b++, bezt1++) {
select_beztriple(bezt1, false, SELECT, true);
select_beztriple(bezt1, false, SELECT, eVisible_Types(true));
}
}
@@ -6474,7 +6484,7 @@ static int curve_delete_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
View3D *v3d = CTX_wm_view3d(C);
eCurveElem_Types type = RNA_enum_get(op->ptr, "type");
eCurveElem_Types type = eCurveElem_Types(RNA_enum_get(op->ptr, "type"));
const Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
@@ -6506,12 +6516,12 @@ static int curve_delete_exec(bContext *C, wmOperator *op)
changed_multi = true;
cu->actvert = CU_ACT_NONE;
if (ED_curve_updateAnimPaths(bmain, obedit->data)) {
if (ED_curve_updateAnimPaths(bmain, static_cast<Curve *>(obedit->data))) {
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
}
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
}
MEM_freeN(objects);
@@ -6525,15 +6535,15 @@ static int curve_delete_exec(bContext *C, wmOperator *op)
static const EnumPropertyItem curve_delete_type_items[] = {
{CURVE_VERTEX, "VERT", 0, "Vertices", ""},
{CURVE_SEGMENT, "SEGMENT", 0, "Segments", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem *rna_curve_delete_type_itemf(bContext *C,
PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
PointerRNA * /*ptr*/,
PropertyRNA * /*prop*/,
bool *r_free)
{
EnumPropertyItem *item = NULL;
EnumPropertyItem *item = nullptr;
int totitem = 0;
if (!C) { /* needed for docs and i18n tools */
@@ -6581,8 +6591,8 @@ void CURVE_OT_delete(wmOperatorType *ot)
static bool test_bezt_is_sel_any(const void *bezt_v, void *user_data)
{
View3D *v3d = user_data;
const BezTriple *bezt = bezt_v;
View3D *v3d = static_cast<View3D *>(user_data);
const BezTriple *bezt = static_cast<const BezTriple *>(bezt_v);
return BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt);
}
@@ -6597,7 +6607,7 @@ void ed_dissolve_bez_segment(BezTriple *bezt_prev,
const int dims = 3;
const int points_len = ((cu->resolu - 1) * i_span_edge_len) + 1;
float *points = MEM_mallocN(points_len * dims * sizeof(float), __func__);
float *points = static_cast<float *>(MEM_mallocN(points_len * dims * sizeof(float), __func__));
float *points_stride = points;
const int points_stride_len = (cu->resolu - 1);
@@ -6630,7 +6640,7 @@ void ed_dissolve_bez_segment(BezTriple *bezt_prev,
curve_fit_cubic_to_points_single_fl(points,
points_len,
NULL,
nullptr,
dims,
FLT_EPSILON,
tan_l,
@@ -6650,7 +6660,7 @@ void ed_dissolve_bez_segment(BezTriple *bezt_prev,
MEM_freeN(points);
}
static int curve_dissolve_exec(bContext *C, wmOperator *UNUSED(op))
static int curve_dissolve_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
const Scene *scene = CTX_data_scene(C);
@@ -6672,7 +6682,7 @@ static int curve_dissolve_exec(bContext *C, wmOperator *UNUSED(op))
LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if ((nu->type == CU_BEZIER) && (nu->pntsu > 2)) {
uint span_step[2] = {nu->pntsu, nu->pntsu};
uint span_step[2] = {uint(nu->pntsu), uint(nu->pntsu)};
uint span_len;
while (BLI_array_iter_span(nu->bezt,
@@ -6696,12 +6706,12 @@ static int curve_dissolve_exec(bContext *C, wmOperator *UNUSED(op))
cu->actnu = cu->actvert = CU_ACT_NONE;
if (ED_curve_updateAnimPaths(bmain, obedit->data)) {
if (ED_curve_updateAnimPaths(bmain, static_cast<Curve *>(obedit->data))) {
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
}
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
MEM_freeN(objects);
return OPERATOR_FINISHED;
@@ -6785,12 +6795,12 @@ static int curve_decimate_exec(bContext *C, wmOperator *op)
if (changed) {
cu->actnu = cu->actvert = CU_ACT_NONE;
if (ED_curve_updateAnimPaths(bmain, obedit->data)) {
if (ED_curve_updateAnimPaths(bmain, static_cast<Curve *>(obedit->data))) {
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
}
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
}
@@ -6858,7 +6868,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
}
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
ret_value = OPERATOR_FINISHED;
}
@@ -6933,16 +6943,16 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op)
BLI_listbase_clear(&tempbase);
/* 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->object_to_world);
Curve *cu_active = ob_active->data;
Curve *cu_active = static_cast<Curve *>(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) {
cu = ob_iter->data;
cu = static_cast<Curve *>(ob_iter->data);
if (cu->nurb.first) {
/* watch it: switch order here really goes wrong */
@@ -6998,7 +7008,7 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
cu = ob_active->data;
cu = static_cast<Curve *>(ob_active->data);
BLI_movelisttolist(&cu->nurb, &tempbase);
if (ob_active->type == OB_CURVES_LEGACY && CU_IS_2D(cu)) {
@@ -7023,7 +7033,7 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op)
/** \name Clear Tilt Operator
* \{ */
static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op))
static int clear_tilt_exec(bContext *C, wmOperator * /*op*/)
{
const Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -7034,7 +7044,7 @@ static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op))
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
if (!ED_curve_select_check(v3d, cu->editnurb)) {
continue;
@@ -7069,7 +7079,7 @@ static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op))
}
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
MEM_freeN(objects);
return OPERATOR_FINISHED;
@@ -7115,7 +7125,7 @@ static bool match_texture_space_poll(bContext *C)
return object && ELEM(object->type, OB_CURVES_LEGACY, OB_SURF, OB_FONT);
}
static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
static int match_texture_space_exec(bContext *C, wmOperator * /*op*/)
{
/* Need to ensure the dependency graph is fully evaluated, so the display list is at a correct
* state. */
@@ -7128,7 +7138,7 @@ static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
float min[3], max[3], texspace_size[3], texspace_location[3];
int a;
BLI_assert(object_eval->runtime.curve_cache != NULL);
BLI_assert(object_eval->runtime.curve_cache != nullptr);
INIT_MINMAX(min, max);
BKE_displist_minmax(&object_eval->runtime.curve_cache->disp, min, max);

View File

@@ -106,7 +106,7 @@ Nurb *ED_curve_add_nurbs_primitive(
static int xzproj = 0; /* this function calls itself... */
ListBase *editnurb = object_editcurve_get(obedit);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
Nurb *nu = NULL;
Nurb *nu = nullptr;
BezTriple *bezt;
BPoint *bp;
Curve *cu = (Curve *)obedit->data;
@@ -204,7 +204,7 @@ Nurb *ED_curve_add_nurbs_primitive(
}
if (cutype == CU_NURBS) {
nu->knotsu = NULL; /* nurbs_knot_calc_u allocates */
nu->knotsu = nullptr; /* nurbs_knot_calc_u allocates */
BKE_nurb_knot_calc_u(nu);
}
}
@@ -240,7 +240,7 @@ Nurb *ED_curve_add_nurbs_primitive(
}
if (cutype == CU_NURBS) {
nu->knotsu = NULL; /* nurbs_knot_calc_u allocates */
nu->knotsu = nullptr; /* nurbs_knot_calc_u allocates */
BKE_nurb_knot_calc_u(nu);
}
@@ -417,13 +417,13 @@ Nurb *ED_curve_add_nurbs_primitive(
BLI_addtail(editnurb, nu); /* temporal for spin */
if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) {
ed_editnurb_spin(umat, NULL, obedit, tmp_vec, tmp_cent);
ed_editnurb_spin(umat, nullptr, obedit, tmp_vec, tmp_cent);
}
else if (U.flag & USER_ADD_VIEWALIGNED) {
ed_editnurb_spin(viewmat, NULL, obedit, zvec, mat[3]);
ed_editnurb_spin(viewmat, nullptr, obedit, zvec, mat[3]);
}
else {
ed_editnurb_spin(umat, NULL, obedit, tmp_vec, mat[3]);
ed_editnurb_spin(umat, nullptr, obedit, tmp_vec, mat[3]);
}
BKE_nurb_knot_calc_v(nu);
@@ -452,13 +452,13 @@ Nurb *ED_curve_add_nurbs_primitive(
/* same as above */
if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) {
ed_editnurb_spin(umat, NULL, obedit, tmp_vec, tmp_cent);
ed_editnurb_spin(umat, nullptr, obedit, tmp_vec, tmp_cent);
}
else if (U.flag & USER_ADD_VIEWALIGNED) {
ed_editnurb_spin(viewmat, NULL, obedit, zvec, mat[3]);
ed_editnurb_spin(viewmat, nullptr, obedit, zvec, mat[3]);
}
else {
ed_editnurb_spin(umat, NULL, obedit, tmp_vec, mat[3]);
ed_editnurb_spin(umat, nullptr, obedit, tmp_vec, mat[3]);
}
BLI_remlink(editnurb, nu);
@@ -474,10 +474,10 @@ Nurb *ED_curve_add_nurbs_primitive(
default: /* should never happen */
BLI_assert_msg(0, "invalid nurbs type");
return NULL;
return nullptr;
}
BLI_assert(nu != NULL);
BLI_assert(nu != nullptr);
if (nu) { /* should always be set */
nu->flag |= CU_SMOOTH;
@@ -510,13 +510,13 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
WM_operator_view3d_unit_defaults(C, op);
if (!ED_object_add_generic_get_opts(
C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL))
C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr))
{
return OPERATOR_CANCELLED;
}
if (!isSurf) { /* adding curve */
if (obedit == NULL || obedit->type != OB_CURVES_LEGACY) {
if (obedit == nullptr || obedit->type != OB_CURVES_LEGACY) {
const char *name = get_curve_defname(type);
Curve *cu;
@@ -534,7 +534,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
}
}
else { /* adding surface */
if (obedit == NULL || obedit->type != OB_SURF) {
if (obedit == nullptr || obedit->type != OB_SURF) {
const char *name = get_surf_defname(type);
obedit = ED_object_add_type(C, OB_SURF, name, loc, rot, true, local_view_bits);
newob = true;

View File

@@ -50,7 +50,9 @@
#define USE_SPLINE_FIT
#ifdef USE_SPLINE_FIT
extern "C" {
# include "curve_fit_nd.h"
}
#endif
/* Distance between input samples */
@@ -76,6 +78,11 @@ struct StrokeElem {
float pressure;
};
enum CurveDrawState {
CURVE_DRAW_IDLE = 0,
CURVE_DRAW_PAINTING = 1,
};
struct CurveDrawData {
short init_event_type;
short curve_type;
@@ -118,10 +125,7 @@ struct CurveDrawData {
ViewContext vc;
ViewDepths *depths;
enum {
CURVE_DRAW_IDLE = 0,
CURVE_DRAW_PAINTING = 1,
} state;
CurveDrawState state;
/* StrokeElem */
BLI_mempool *stroke_elem_pool;
@@ -132,7 +136,7 @@ struct CurveDrawData {
static float stroke_elem_radius_from_pressure(const struct CurveDrawData *cdd,
const float pressure)
{
const Curve *cu = cdd->vc.obedit->data;
const Curve *cu = static_cast<const Curve *>(cdd->vc.obedit->data);
return ((pressure * cdd->radius.range) + cdd->radius.min) * cu->bevel_radius;
}
@@ -269,7 +273,7 @@ static bool stroke_elem_project_fallback_elem(const struct CurveDrawData *cdd,
const float location_fallback_depth[3],
struct StrokeElem *selem)
{
const int mval_i[2] = {UNPACK2(selem->mval)};
const int mval_i[2] = {int(selem->mval[0]), int(selem->mval[1])};
const float radius = stroke_elem_radius(cdd, selem);
return stroke_elem_project_fallback(cdd,
mval_i,
@@ -301,9 +305,9 @@ static void curve_draw_stroke_to_operator_elem(wmOperator *op, const struct Stro
static void curve_draw_stroke_from_operator_elem(wmOperator *op, PointerRNA *itemptr)
{
struct CurveDrawData *cdd = op->customdata;
struct CurveDrawData *cdd = static_cast<CurveDrawData *>(op->customdata);
struct StrokeElem *selem = BLI_mempool_calloc(cdd->stroke_elem_pool);
struct StrokeElem *selem = static_cast<StrokeElem *>(BLI_mempool_calloc(cdd->stroke_elem_pool));
RNA_float_get_array(itemptr, "mouse", selem->mval);
RNA_float_get_array(itemptr, "location", selem->location_world);
@@ -313,13 +317,15 @@ static void curve_draw_stroke_from_operator_elem(wmOperator *op, PointerRNA *ite
static void curve_draw_stroke_to_operator(wmOperator *op)
{
struct CurveDrawData *cdd = op->customdata;
struct CurveDrawData *cdd = static_cast<CurveDrawData *>(op->customdata);
BLI_mempool_iter iter;
const struct StrokeElem *selem;
BLI_mempool_iternew(cdd->stroke_elem_pool, &iter);
for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) {
for (selem = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter)); selem;
selem = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter)))
{
curve_draw_stroke_to_operator_elem(op, selem);
}
}
@@ -338,10 +344,10 @@ static void curve_draw_stroke_from_operator(wmOperator *op)
/** \name Operator Callbacks & Helpers
* \{ */
static void curve_draw_stroke_3d(const bContext *UNUSED(C), ARegion *UNUSED(region), void *arg)
static void curve_draw_stroke_3d(const bContext * /*C*/, ARegion * /*region*/, void *arg)
{
wmOperator *op = arg;
struct CurveDrawData *cdd = op->customdata;
wmOperator *op = static_cast<wmOperator *>(arg);
struct CurveDrawData *cdd = static_cast<CurveDrawData *>(op->customdata);
const int stroke_len = BLI_mempool_len(cdd->stroke_elem_pool);
@@ -350,7 +356,7 @@ static void curve_draw_stroke_3d(const bContext *UNUSED(C), ARegion *UNUSED(regi
}
Object *obedit = cdd->vc.obedit;
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
if (cu->bevel_radius > 0.0f) {
BLI_mempool_iter iter;
@@ -371,7 +377,9 @@ static void curve_draw_stroke_3d(const bContext *UNUSED(C), ARegion *UNUSED(regi
GPU_matrix_mul(obedit->object_to_world);
BLI_mempool_iternew(cdd->stroke_elem_pool, &iter);
for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) {
for (selem = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter)); selem;
selem = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter)))
{
GPU_matrix_translate_3f(selem->location_local[0] - location_prev[0],
selem->location_local[1] - location_prev[1],
selem->location_local[2] - location_prev[2]);
@@ -390,15 +398,17 @@ static void curve_draw_stroke_3d(const bContext *UNUSED(C), ARegion *UNUSED(regi
}
if (stroke_len > 1) {
float(*coord_array)[3] = MEM_mallocN(sizeof(*coord_array) * stroke_len, __func__);
float(*coord_array)[3] = static_cast<float(*)[3]>(
MEM_mallocN(sizeof(*coord_array) * stroke_len, __func__));
{
BLI_mempool_iter iter;
const struct StrokeElem *selem;
int i;
BLI_mempool_iternew(cdd->stroke_elem_pool, &iter);
for (selem = BLI_mempool_iterstep(&iter), i = 0; selem;
selem = BLI_mempool_iterstep(&iter), i++) {
for (selem = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter)), i = 0; selem;
selem = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter)), i++)
{
copy_v3_v3(coord_array[i], selem->location_world);
}
}
@@ -443,12 +453,12 @@ static void curve_draw_stroke_3d(const bContext *UNUSED(C), ARegion *UNUSED(regi
static void curve_draw_event_add(wmOperator *op, const wmEvent *event)
{
struct CurveDrawData *cdd = op->customdata;
struct CurveDrawData *cdd = static_cast<CurveDrawData *>(op->customdata);
Object *obedit = cdd->vc.obedit;
invert_m4_m4(obedit->world_to_object, obedit->object_to_world);
struct StrokeElem *selem = BLI_mempool_calloc(cdd->stroke_elem_pool);
struct StrokeElem *selem = static_cast<StrokeElem *>(BLI_mempool_calloc(cdd->stroke_elem_pool));
ARRAY_SET_ITEMS(selem->mval, event->mval[0], event->mval[1]);
@@ -485,7 +495,7 @@ static void curve_draw_event_add(wmOperator *op, const wmEvent *event)
}
}
selem_new_last = BLI_mempool_calloc(cdd->stroke_elem_pool);
selem_new_last = static_cast<StrokeElem *>(BLI_mempool_calloc(cdd->stroke_elem_pool));
}
}
selem = selem_new_last;
@@ -499,7 +509,7 @@ static void curve_draw_event_add(wmOperator *op, const wmEvent *event)
static void curve_draw_event_add_first(wmOperator *op, const wmEvent *event)
{
struct CurveDrawData *cdd = op->customdata;
struct CurveDrawData *cdd = static_cast<CurveDrawData *>(op->customdata);
const CurvePaintSettings *cps = &cdd->vc.scene->toolsettings->curve_paint_settings;
/* add first point */
@@ -539,11 +549,12 @@ static void curve_draw_event_add_first(wmOperator *op, const wmEvent *event)
/* Special case for when we only have offset applied on the first-hit,
* the remaining stroke must be offset too. */
if (cdd->project.surface_offset != 0.0f) {
const float mval_fl[2] = {UNPACK2(event->mval)};
const float mval_fl[2] = {float(event->mval[0]), float(event->mval[1])};
float location_no_offset[3];
if (stroke_elem_project(cdd, event->mval, mval_fl, 0.0f, 0.0f, location_no_offset, NULL)) {
if (stroke_elem_project(cdd, event->mval, mval_fl, 0.0f, 0.0f, location_no_offset, nullptr))
{
sub_v3_v3v3(cdd->project.offset, cdd->prev.location_world_valid, location_no_offset);
if (!is_zero_v3(cdd->project.offset)) {
cdd->project.use_offset = true;
@@ -559,14 +570,14 @@ static void curve_draw_event_add_first(wmOperator *op, const wmEvent *event)
static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke)
{
BLI_assert(op->customdata == NULL);
BLI_assert(op->customdata == nullptr);
struct CurveDrawData *cdd = MEM_callocN(sizeof(*cdd), __func__);
struct CurveDrawData *cdd = static_cast<CurveDrawData *>(MEM_callocN(sizeof(*cdd), __func__));
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
if (is_invoke) {
ED_view3d_viewcontext_init(C, &cdd->vc, depsgraph);
if (ELEM(NULL, cdd->vc.region, cdd->vc.rv3d, cdd->vc.v3d, cdd->vc.win, cdd->vc.scene)) {
if (ELEM(nullptr, cdd->vc.region, cdd->vc.rv3d, cdd->vc.v3d, cdd->vc.win, cdd->vc.scene)) {
MEM_freeN(cdd);
BKE_report(op->reports, RPT_ERROR, "Unable to access 3D viewport");
return false;
@@ -609,7 +620,7 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke)
static void curve_draw_exit(wmOperator *op)
{
struct CurveDrawData *cdd = op->customdata;
struct CurveDrawData *cdd = static_cast<CurveDrawData *>(op->customdata);
if (cdd) {
if (cdd->draw_handle_view) {
ED_region_draw_cb_exit(cdd->vc.region->type, cdd->draw_handle_view);
@@ -624,7 +635,7 @@ static void curve_draw_exit(wmOperator *op)
ED_view3d_depths_free(cdd->depths);
}
MEM_freeN(cdd);
op->customdata = NULL;
op->customdata = nullptr;
}
}
@@ -633,7 +644,7 @@ static void curve_draw_exit(wmOperator *op)
*/
static void curve_draw_exec_precalc(wmOperator *op)
{
struct CurveDrawData *cdd = op->customdata;
struct CurveDrawData *cdd = static_cast<CurveDrawData *>(op->customdata);
const CurvePaintSettings *cps = &cdd->vc.scene->toolsettings->curve_paint_settings;
PropertyRNA *prop;
@@ -661,8 +672,10 @@ static void curve_draw_exec_precalc(wmOperator *op)
int i = 0;
BLI_mempool_iternew(cdd->stroke_elem_pool, &iter);
selem_prev = BLI_mempool_iterstep(&iter);
for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter), i++) {
selem_prev = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter));
for (selem = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter)); selem;
selem = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter)), i++)
{
len_3d += len_v3v3(selem->location_local, selem_prev->location_local);
len_2d += len_v2v2(selem->mval, selem_prev->mval);
selem_prev = selem;
@@ -681,8 +694,10 @@ static void curve_draw_exec_precalc(wmOperator *op)
const struct StrokeElem *selem, *selem_first, *selem_last;
BLI_mempool_iternew(cdd->stroke_elem_pool, &iter);
selem_first = selem_last = BLI_mempool_iterstep(&iter);
for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) {
selem_first = selem_last = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter));
for (selem = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter)); selem;
selem = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter)))
{
selem_last = selem;
}
@@ -703,17 +718,20 @@ static void curve_draw_exec_precalc(wmOperator *op)
BLI_mempool_iter iter;
struct StrokeElem *selem, *selem_prev;
float *lengths = MEM_mallocN(sizeof(float) * stroke_len, __func__);
struct StrokeElem **selem_array = MEM_mallocN(sizeof(*selem_array) * stroke_len, __func__);
float *lengths = static_cast<float *>(MEM_mallocN(sizeof(float) * stroke_len, __func__));
struct StrokeElem **selem_array = static_cast<StrokeElem **>(
MEM_mallocN(sizeof(*selem_array) * stroke_len, __func__));
lengths[0] = 0.0f;
float len_3d = 0.0f;
int i = 1;
BLI_mempool_iternew(cdd->stroke_elem_pool, &iter);
selem_prev = BLI_mempool_iterstep(&iter);
selem_prev = static_cast<StrokeElem *>(BLI_mempool_iterstep(&iter));
selem_array[0] = selem_prev;
for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter), i++) {
for (selem = static_cast<StrokeElem *>(BLI_mempool_iterstep(&iter)); selem;
selem = static_cast<StrokeElem *>(BLI_mempool_iterstep(&iter)), i++)
{
const float len_3d_segment = len_v3v3(selem->location_local, selem_prev->location_local);
len_3d += len_3d_segment;
lengths[i] = len_3d;
@@ -746,17 +764,17 @@ static void curve_draw_exec_precalc(wmOperator *op)
static int curve_draw_exec(bContext *C, wmOperator *op)
{
if (op->customdata == NULL) {
if (op->customdata == nullptr) {
if (!curve_draw_init(C, op, false)) {
return OPERATOR_CANCELLED;
}
}
struct CurveDrawData *cdd = op->customdata;
struct CurveDrawData *cdd = static_cast<CurveDrawData *>(op->customdata);
const CurvePaintSettings *cps = &cdd->vc.scene->toolsettings->curve_paint_settings;
Object *obedit = cdd->vc.obedit;
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
ListBase *nurblist = object_editcurve_get(obedit);
int stroke_len = BLI_mempool_len(cdd->stroke_elem_pool);
@@ -776,7 +794,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
const float radius_max = cps->radius_max;
const float radius_range = cps->radius_max - cps->radius_min;
Nurb *nu = MEM_callocN(sizeof(Nurb), __func__);
Nurb *nu = static_cast<Nurb *>(MEM_callocN(sizeof(Nurb), __func__));
nu->pntsv = 0;
nu->resolu = cu->resolu;
nu->resolv = cu->resolv;
@@ -798,9 +816,10 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
} coords_indices;
coords_indices.radius = use_pressure_radius ? dims++ : -1;
float *coords = MEM_mallocN(sizeof(*coords) * stroke_len * dims, __func__);
float *coords = static_cast<float *>(
MEM_mallocN(sizeof(*coords) * stroke_len * dims, __func__));
float *cubic_spline = NULL;
float *cubic_spline = nullptr;
uint cubic_spline_len = 0;
/* error in object local space */
@@ -815,8 +834,9 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
float *co = coords;
BLI_mempool_iternew(cdd->stroke_elem_pool, &iter);
for (selem = BLI_mempool_iterstep(&iter); selem;
selem = BLI_mempool_iterstep(&iter), co += dims) {
for (selem = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter)); selem;
selem = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter)), co += dims)
{
copy_v3_v3(co, selem->location_local);
if (coords_indices.radius != -1) {
co[coords_indices.radius] = selem->pressure;
@@ -830,7 +850,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
}
}
uint *corners = NULL;
uint *corners = nullptr;
uint corners_len = 0;
if ((fit_method == CURVE_PAINT_FIT_METHOD_SPLIT) && (corner_angle < (float)M_PI)) {
@@ -850,7 +870,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
&corners_len);
}
uint *corners_index = NULL;
uint *corners_index = nullptr;
uint corners_index_len = 0;
uint calc_flag = CURVE_FIT_CALC_HIGH_QUALIY;
@@ -865,12 +885,12 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
dims,
error_threshold,
calc_flag,
NULL,
nullptr,
0,
corner_angle,
&cubic_spline,
&cubic_spline_len,
NULL,
nullptr,
&corners_index,
&corners_index_len);
}
@@ -884,7 +904,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
corners_len,
&cubic_spline,
&cubic_spline_len,
NULL,
nullptr,
&corners_index,
&corners_index_len);
}
@@ -896,7 +916,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
if (result == 0) {
nu->pntsu = cubic_spline_len;
nu->bezt = MEM_callocN(sizeof(BezTriple) * nu->pntsu, __func__);
nu->bezt = static_cast<BezTriple *>(MEM_callocN(sizeof(BezTriple) * nu->pntsu, __func__));
float *co = cubic_spline;
BezTriple *bezt = nu->bezt;
@@ -992,7 +1012,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
nu->pntsu = stroke_len;
nu->pntsv = 1;
nu->type = CU_POLY;
nu->bp = MEM_callocN(nu->pntsu * sizeof(BPoint), __func__);
nu->bp = static_cast<BPoint *>(MEM_callocN(nu->pntsu * sizeof(BPoint), __func__));
/* Misc settings. */
nu->resolu = cu->resolu;
@@ -1003,7 +1023,9 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
BPoint *bp = nu->bp;
BLI_mempool_iternew(cdd->stroke_elem_pool, &iter);
for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) {
for (selem = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter)); selem;
selem = static_cast<const StrokeElem *>(BLI_mempool_iterstep(&iter)))
{
copy_v3_v3(bp->vec, selem->location_local);
if (!is_3d) {
bp->vec[2] = 0.0f;
@@ -1030,7 +1052,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
cu->actvert = nu->pntsu - 1;
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
curve_draw_exit(op);
@@ -1047,7 +1069,7 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
}
struct CurveDrawData *cdd = op->customdata;
struct CurveDrawData *cdd = static_cast<CurveDrawData *>(op->customdata);
const CurvePaintSettings *cps = &cdd->vc.scene->toolsettings->curve_paint_settings;
@@ -1055,7 +1077,7 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* Fallback (in case we can't find the depth on first test). */
{
const float mval_fl[2] = {UNPACK2(event->mval)};
const float mval_fl[2] = {float(event->mval[0]), float(event->mval[1])};
float center[3];
negate_v3_v3(center, cdd->vc.rv3d->ofs);
ED_view3d_win_to_3d(cdd->vc.v3d, cdd->vc.region, center, mval_fl, cdd->prev.location_world);
@@ -1070,10 +1092,10 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
View3D *v3d = cdd->vc.v3d;
RegionView3D *rv3d = cdd->vc.rv3d;
Object *obedit = cdd->vc.obedit;
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
const float *plane_no = NULL;
const float *plane_co = NULL;
const float *plane_no = nullptr;
const float *plane_co = nullptr;
if (CU_IS_2D(cu)) {
/* 2D overrides other options */
@@ -1089,11 +1111,11 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ED_view3d_depth_override(cdd->vc.depsgraph,
cdd->vc.region,
cdd->vc.v3d,
NULL,
nullptr,
V3D_DEPTH_NO_GPENCIL,
&cdd->depths);
if (cdd->depths != NULL) {
if (cdd->depths != nullptr) {
cdd->project.use_depth = true;
}
else {
@@ -1130,7 +1152,7 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
static void curve_draw_cancel(bContext *UNUSED(C), wmOperator *op)
static void curve_draw_cancel(bContext * /*C*/, wmOperator *op)
{
curve_draw_exit(op);
}
@@ -1139,7 +1161,7 @@ static void curve_draw_cancel(bContext *UNUSED(C), wmOperator *op)
static int curve_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
int ret = OPERATOR_RUNNING_MODAL;
struct CurveDrawData *cdd = op->customdata;
struct CurveDrawData *cdd = static_cast<CurveDrawData *>(op->customdata);
UNUSED_VARS(C, op);
@@ -1168,7 +1190,7 @@ static int curve_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
else if (ISMOUSE_MOTION(event->type)) {
if (cdd->state == CURVE_DRAW_PAINTING) {
const float mval_fl[2] = {UNPACK2(event->mval)};
const float mval_fl[2] = {float(event->mval[0]), float(event->mval[1])};
if (len_squared_v2v2(mval_fl, cdd->prev.mval) > square_f(STROKE_SAMPLE_DIST_MIN_PX)) {
curve_draw_event_add(op, event);
}

View File

@@ -56,7 +56,7 @@
/**
* Data structure to keep track of details about the cut location
*/
typedef struct CutData {
struct CutData {
/* Index of the last #BezTriple or BPoint before the cut. */
int bezt_index, bp_index;
/* Nurb to which the cut belongs to. */
@@ -71,21 +71,21 @@ typedef struct CutData {
float prev_loc[3], cut_loc[3], next_loc[3];
/* Mouse location in floats. */
float mval[2];
} CutData;
};
/**
* Data required for segment altering functionality.
*/
typedef struct MoveSegmentData {
struct MoveSegmentData {
/* Nurb being altered. */
Nurb *nu;
/* Index of the #BezTriple before the segment. */
int bezt_index;
/* Fraction along the segment at which mouse was pressed. */
float t;
} MoveSegmentData;
};
typedef struct CurvePenData {
struct CurvePenData {
MoveSegmentData *msd;
/* Whether the mouse is clicking and dragging. */
bool dragging;
@@ -119,30 +119,30 @@ typedef struct CurvePenData {
Nurb *nu;
BezTriple *bezt;
BPoint *bp;
} CurvePenData;
};
static const EnumPropertyItem prop_handle_types[] = {
{HD_AUTO, "AUTO", 0, "Auto", ""},
{HD_VECT, "VECTOR", 0, "Vector", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
typedef enum eClose_opt {
enum eClose_opt {
OFF = 0,
ON_PRESS = 1,
ON_CLICK = 2,
} eClose_opt;
};
static const EnumPropertyItem prop_close_spline_method[] = {
{OFF, "OFF", 0, "None", ""},
{ON_PRESS, "ON_PRESS", 0, "On Press", "Move handles after closing the spline"},
{ON_CLICK, "ON_CLICK", 0, "On Click", "Spline closes on release if not dragged"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static void update_location_for_2d_curve(const ViewContext *vc, float location[3])
{
Curve *cu = vc->obedit->data;
Curve *cu = static_cast<Curve *>(vc->obedit->data);
if (CU_IS_2D(cu)) {
const float eps = 1e-6f;
@@ -198,7 +198,7 @@ static void screenspace_to_worldspace_int(const ViewContext *vc,
const float depth[3],
float r_pos_3d[3])
{
const float pos_2d_fl[2] = {UNPACK2(pos_2d)};
const float pos_2d_fl[2] = {float(pos_2d[0]), float(pos_2d[1])};
screenspace_to_worldspace(vc, pos_2d_fl, depth, r_pos_3d);
}
@@ -207,7 +207,7 @@ static bool worldspace_to_screenspace(const ViewContext *vc,
float r_pos_2d[2])
{
return ED_view3d_project_float_object(
vc->region, pos_3d, r_pos_2d, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) ==
vc->region, pos_3d, r_pos_2d, V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) ==
V3D_PROJ_RET_OK;
}
@@ -371,8 +371,8 @@ static void move_all_selected_points(const ViewContext *vc,
ListBase *nurbs,
const bool bezt_only)
{
const float mval[2] = {UNPACK2(event->xy)};
const float prev_mval[2] = {UNPACK2(event->prev_xy)};
const float mval[2] = {float(event->xy[0]), float(event->xy[1])};
const float prev_mval[2] = {float(event->prev_xy[0]), float(event->prev_xy[1])};
float disp_2d[2];
sub_v2_v2v2(disp_2d, mval, prev_mval);
@@ -438,7 +438,7 @@ static void delete_nurb(Curve *cu, Nurb *nu)
ListBase *nurbs = &editnurb->nurbs;
const int nu_index = get_nurb_index(nurbs, nu);
if (cu->actnu == nu_index) {
BKE_curve_nurb_vert_active_set(cu, NULL, NULL);
BKE_curve_nurb_vert_active_set(cu, nullptr, nullptr);
}
BLI_remlink(nurbs, nu);
@@ -475,18 +475,18 @@ static bool get_closest_vertex_to_point_in_nurbs(const ViewContext *vc,
BPoint **r_bp,
int *r_bezt_idx)
{
*r_nu = NULL;
*r_bezt = NULL;
*r_bp = NULL;
*r_nu = nullptr;
*r_bezt = nullptr;
*r_bp = nullptr;
float min_dist_bezt = FLT_MAX;
int closest_handle = 0;
BezTriple *closest_bezt = NULL;
Nurb *closest_bezt_nu = NULL;
BezTriple *closest_bezt = nullptr;
Nurb *closest_bezt_nu = nullptr;
float min_dist_bp = FLT_MAX;
BPoint *closest_bp = NULL;
Nurb *closest_bp_nu = NULL;
BPoint *closest_bp = nullptr;
Nurb *closest_bp_nu = nullptr;
LISTBASE_FOREACH (Nurb *, nu, nurbs) {
if (nu->type == CU_BEZIER) {
@@ -756,7 +756,7 @@ static void update_cut_data_for_nurb(
if (nu->type == CU_BEZIER) {
for (int i = 0; i < end; i++) {
float *points = MEM_mallocN(sizeof(float[3]) * (resolu + 1), __func__);
float *points = static_cast<float *>(MEM_mallocN(sizeof(float[3]) * (resolu + 1), __func__));
const BezTriple *bezt1 = nu->bezt + i;
const BezTriple *bezt2 = nu->bezt + (i + 1) % nu->pntsu;
@@ -832,22 +832,23 @@ static bool update_cut_data_for_all_nurbs(const ViewContext *vc,
static CutData init_cut_data(const wmEvent *event)
{
CutData cd = {.bezt_index = 0,
.bp_index = 0,
.min_dist = FLT_MAX,
.parameter = 0.5f,
.has_prev = false,
.has_next = false,
.mval[0] = event->mval[0],
.mval[1] = event->mval[1]};
CutData cd{};
cd.bezt_index = 0;
cd.bp_index = 0;
cd.min_dist = FLT_MAX;
cd.parameter = 0.5f;
cd.has_prev = false;
cd.has_next = false;
cd.mval[0] = event->mval[0];
cd.mval[1] = event->mval[1];
return cd;
}
static bool insert_point_to_segment(const ViewContext *vc, const wmEvent *event)
{
Curve *cu = vc->obedit->data;
Curve *cu = static_cast<Curve *>(vc->obedit->data);
CutData cd = init_cut_data(event);
const float mval[2] = {UNPACK2(event->mval)};
const float mval[2] = {float(event->mval[0]), float(event->mval[1])};
const float threshold_dist_px = ED_view3d_select_dist_px() * SEL_DIST_FACTOR;
const bool near_spline = update_cut_data_for_all_nurbs(
vc, BKE_curve_editNurbs_get(cu), mval, threshold_dist_px, &cd);
@@ -891,9 +892,9 @@ static void get_first_selected_point(
BPoint *bp;
int a;
*r_nu = NULL;
*r_bezt = NULL;
*r_bp = NULL;
*r_nu = nullptr;
*r_bezt = nullptr;
*r_bp = nullptr;
LISTBASE_FOREACH (Nurb *, nu, nurbs) {
if (nu->type == CU_BEZIER) {
@@ -902,8 +903,8 @@ static void get_first_selected_point(
while (a--) {
if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) {
if (*r_bezt || *r_bp) {
*r_bp = NULL;
*r_bezt = NULL;
*r_bp = nullptr;
*r_bezt = nullptr;
return;
}
*r_bezt = bezt;
@@ -918,8 +919,8 @@ static void get_first_selected_point(
while (a--) {
if (bp->f1 & SELECT) {
if (*r_bezt || *r_bp) {
*r_bp = NULL;
*r_bezt = NULL;
*r_bp = nullptr;
*r_bezt = nullptr;
return;
}
*r_bp = bp;
@@ -1078,7 +1079,7 @@ static void extrude_points_from_selected_vertices(const ViewContext *vc,
const wmEvent *event,
const int extrude_handle)
{
Curve *cu = vc->obedit->data;
Curve *cu = static_cast<Curve *>(vc->obedit->data);
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
float center[3] = {0.0f, 0.0f, 0.0f};
deselect_all_center_vertices(nurbs);
@@ -1104,9 +1105,9 @@ static void extrude_points_from_selected_vertices(const ViewContext *vc,
extrude_vertices_from_selected_endpoints(editnurb, nurbs, cu, disp_3d);
}
else {
Nurb *old_last_nu = editnurb->nurbs.last;
Nurb *old_last_nu = static_cast<Nurb *>(editnurb->nurbs.last);
ed_editcurve_addvert(cu, editnurb, vc->v3d, location);
Nurb *new_last_nu = editnurb->nurbs.last;
Nurb *new_last_nu = static_cast<Nurb *>(editnurb->nurbs.last);
if (old_last_nu != new_last_nu) {
BKE_curve_nurb_vert_active_set(cu,
@@ -1134,18 +1135,19 @@ static bool is_spline_nearby(ViewContext *vc,
const wmEvent *event,
const float sel_dist)
{
Curve *cu = vc->obedit->data;
Curve *cu = static_cast<Curve *>(vc->obedit->data);
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
CutData cd = init_cut_data(event);
const float mval[2] = {UNPACK2(event->mval)};
const float mval[2] = {float(event->mval[0]), float(event->mval[1])};
const bool nearby = update_cut_data_for_all_nurbs(vc, nurbs, mval, sel_dist, &cd);
if (nearby) {
if (cd.nurb && (cd.nurb->type == CU_BEZIER) && RNA_boolean_get(op->ptr, "move_segment")) {
MoveSegmentData *seg_data;
CurvePenData *cpd = (CurvePenData *)(op->customdata);
cpd->msd = seg_data = MEM_callocN(sizeof(MoveSegmentData), __func__);
cpd->msd = seg_data = static_cast<MoveSegmentData *>(
MEM_callocN(sizeof(MoveSegmentData), __func__));
seg_data->bezt_index = cd.bezt_index;
seg_data->nu = cd.nurb;
seg_data->t = cd.parameter;
@@ -1275,17 +1277,17 @@ static void toggle_sel_bezt_free_align_handles(ListBase *nurbs)
*/
static bool delete_point_under_mouse(ViewContext *vc, const wmEvent *event)
{
BezTriple *bezt = NULL;
BPoint *bp = NULL;
Nurb *nu = NULL;
BezTriple *bezt = nullptr;
BPoint *bp = nullptr;
Nurb *nu = nullptr;
int temp = 0;
Curve *cu = vc->obedit->data;
Curve *cu = static_cast<Curve *>(vc->obedit->data);
EditNurb *editnurb = cu->editnurb;
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
const float mouse_point[2] = {UNPACK2(event->mval)};
const float mouse_point[2] = {float(event->mval[0]), float(event->mval[1])};
get_closest_vertex_to_point_in_nurbs(vc, nurbs, mouse_point, &nu, &bezt, &bp, &temp);
const bool found_point = nu != NULL;
const bool found_point = nu != nullptr;
bool deleted = false;
if (found_point) {
@@ -1296,7 +1298,7 @@ static bool delete_point_under_mouse(ViewContext *vc, const wmEvent *event)
BezTriple *prev_bezt = BKE_nurb_bezt_get_prev(nu, bezt);
if (next_bezt && prev_bezt) {
const int bez_index = BKE_curve_nurb_vert_index_get(nu, bezt);
const uint span_step[2] = {bez_index, bez_index};
const uint span_step[2] = {uint(bez_index), uint(bez_index)};
ed_dissolve_bez_segment(prev_bezt, next_bezt, nu, cu, 1, span_step);
}
delete_bezt_from_nurb(bezt, nu, editnurb);
@@ -1307,7 +1309,7 @@ static bool delete_point_under_mouse(ViewContext *vc, const wmEvent *event)
if (nu->pntsu == 0) {
delete_nurb(cu, nu);
nu = NULL;
nu = nullptr;
}
deleted = true;
cu->actvert = CU_ACT_NONE;
@@ -1354,7 +1356,7 @@ static void move_adjacent_handle(ViewContext *vc, const wmEvent *event, ListBase
int displacement[2];
sub_v2_v2v2_int(displacement, event->xy, event->prev_xy);
const float disp_fl[2] = {UNPACK2(displacement)};
const float disp_fl[2] = {float(displacement[0]), float(displacement[1])};
move_bezt_handle_or_vertex_by_displacement(
vc, adj_bezt, bezt_idx, disp_fl, 0.0f, false, false);
BKE_nurb_handles_calc(nu);
@@ -1379,12 +1381,12 @@ static bool make_cyclic_if_endpoints(ViewContext *vc,
return false;
}
Nurb *nu = NULL;
BezTriple *bezt = NULL;
BPoint *bp = NULL;
Curve *cu = vc->obedit->data;
Nurb *nu = nullptr;
BezTriple *bezt = nullptr;
BPoint *bp = nullptr;
Curve *cu = static_cast<Curve *>(vc->obedit->data);
int bezt_idx;
const float mval_fl[2] = {UNPACK2(vc->mval)};
const float mval_fl[2] = {float(vc->mval[0]), float(vc->mval[1])};
get_closest_vertex_to_point_in_nurbs(
vc, &(cu->editnurb->nurbs), mval_fl, &nu, &bezt, &bp, &bezt_idx);
@@ -1530,14 +1532,14 @@ wmKeyMap *curve_pen_modal_keymap(wmKeyConfig *keyconf)
0,
"Lock Angle",
"Move the handle along its current angle"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Curve Pen Modal Map");
/* This function is called for each space-type, only needs to add map once. */
if (keymap && keymap->modal_items) {
return NULL;
return nullptr;
}
keymap = WM_modalkeymap_ensure(keyconf, "Curve Pen Modal Map", modal_items);
@@ -1554,23 +1556,22 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event)
Object *obedit = CTX_data_edit_object(C);
ED_view3d_viewcontext_init(C, &vc, depsgraph);
Curve *cu = vc.obedit->data;
Curve *cu = static_cast<Curve *>(vc.obedit->data);
ListBase *nurbs = &cu->editnurb->nurbs;
const float threshold_dist_px = ED_view3d_select_dist_px() * SEL_DIST_FACTOR;
BezTriple *bezt = NULL;
BPoint *bp = NULL;
Nurb *nu = NULL;
BezTriple *bezt = nullptr;
BPoint *bp = nullptr;
Nurb *nu = nullptr;
const struct SelectPick_Params params = {
.sel_op = SEL_OP_SET,
.deselect_all = false,
};
SelectPick_Params params{};
params.sel_op = SEL_OP_SET;
params.deselect_all = false;
int ret = OPERATOR_RUNNING_MODAL;
/* Distance threshold for mouse clicks to affect the spline or its points */
const float mval_fl[2] = {UNPACK2(event->mval)};
const float mval_fl[2] = {float(event->mval[0]), float(event->mval[1])};
const bool extrude_point = RNA_boolean_get(op->ptr, "extrude_point");
const bool delete_point = RNA_boolean_get(op->ptr, "delete_point");
@@ -1585,8 +1586,9 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event)
const int extrude_handle = RNA_enum_get(op->ptr, "extrude_handle");
CurvePenData *cpd;
if (op->customdata == NULL) {
op->customdata = cpd = MEM_callocN(sizeof(CurvePenData), __func__);
if (op->customdata == nullptr) {
op->customdata = cpd = static_cast<CurvePenData *>(
MEM_callocN(sizeof(CurvePenData), __func__));
}
else {
cpd = (CurvePenData *)(op->customdata);
@@ -1594,7 +1596,7 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
if (event->type == EVT_MODAL_MAP) {
if (cpd->msd == NULL) {
if (cpd->msd == nullptr) {
if (event->val == PEN_MODAL_FREE_ALIGN_TOGGLE) {
toggle_sel_bezt_free_align_handles(nurbs);
cpd->link_handles = false;
@@ -1636,7 +1638,7 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
if (cpd->dragging) {
if (cpd->spline_nearby && move_seg && cpd->msd != NULL) {
if (cpd->spline_nearby && move_seg && cpd->msd != nullptr) {
MoveSegmentData *seg_data = cpd->msd;
move_segment(&vc, seg_data, event);
cpd->acted = true;
@@ -1722,7 +1724,7 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
if (cpd->msd != NULL) {
if (cpd->msd != nullptr) {
MEM_freeN(cpd->msd);
}
MEM_freeN(cpd);
@@ -1732,7 +1734,7 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event)
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
return ret;
}
@@ -1741,18 +1743,18 @@ static int curve_pen_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
ViewContext vc;
ED_view3d_viewcontext_init(C, &vc, CTX_data_ensure_evaluated_depsgraph(C));
Curve *cu = vc.obedit->data;
Curve *cu = static_cast<Curve *>(vc.obedit->data);
ListBase *nurbs = &cu->editnurb->nurbs;
BezTriple *bezt = NULL;
BPoint *bp = NULL;
Nurb *nu = NULL;
BezTriple *bezt = nullptr;
BPoint *bp = nullptr;
Nurb *nu = nullptr;
CurvePenData *cpd;
op->customdata = cpd = MEM_callocN(sizeof(CurvePenData), __func__);
op->customdata = cpd = static_cast<CurvePenData *>(MEM_callocN(sizeof(CurvePenData), __func__));
/* Distance threshold for mouse clicks to affect the spline or its points */
const float mval_fl[2] = {UNPACK2(event->mval)};
const float mval_fl[2] = {float(event->mval[0]), float(event->mval[1])};
const float threshold_dist_px = ED_view3d_select_dist_px() * SEL_DIST_FACTOR;
const bool extrude_point = RNA_boolean_get(op->ptr, "extrude_point");

View File

@@ -30,6 +30,16 @@
/** \name Cursor Picking API
* \{ */
struct PickUserData {
BPoint *bp;
BezTriple *bezt;
Nurb *nurb;
float dist;
int hpoint, select;
float mval_fl[2];
bool is_changed;
};
static void ED_curve_pick_vert__do_closest(void *userData,
Nurb *nu,
BPoint *bp,
@@ -38,15 +48,7 @@ static void ED_curve_pick_vert__do_closest(void *userData,
bool handles_visible,
const float screen_co[2])
{
struct {
BPoint *bp;
BezTriple *bezt;
Nurb *nurb;
float dist;
int hpoint, select;
float mval_fl[2];
bool is_changed;
} *data = userData;
PickUserData *data = static_cast<PickUserData *>(userData);
uint8_t flag;
float dist_test;
@@ -101,15 +103,7 @@ bool ED_curve_pick_vert_ex(ViewContext *vc,
/* (sel == 1): selected gets a disadvantage */
/* in nurb and bezt or bp the nearest is written */
/* return 0 1 2: handlepunt */
struct {
BPoint *bp;
BezTriple *bezt;
Nurb *nurb;
float dist;
int hpoint, select;
float mval_fl[2];
bool is_changed;
} data = {NULL};
PickUserData data{};
data.dist = dist_px;
data.hpoint = 0;
@@ -173,9 +167,9 @@ void ED_curve_nurb_vert_selected_find(
BPoint *bp1;
int a;
*r_nu = NULL;
*r_bezt = NULL;
*r_bp = NULL;
*r_nu = nullptr;
*r_bezt = nullptr;
*r_bp = nullptr;
LISTBASE_FOREACH (Nurb *, nu1, editnurb) {
if (nu1->type == CU_BEZIER) {
@@ -183,16 +177,16 @@ void ED_curve_nurb_vert_selected_find(
a = nu1->pntsu;
while (a--) {
if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt1)) {
if (!ELEM(*r_nu, NULL, nu1)) {
*r_nu = NULL;
*r_bp = NULL;
*r_bezt = NULL;
if (!ELEM(*r_nu, nullptr, nu1)) {
*r_nu = nullptr;
*r_bp = nullptr;
*r_bezt = nullptr;
return;
}
if (*r_bezt || *r_bp) {
*r_bp = NULL;
*r_bezt = NULL;
*r_bp = nullptr;
*r_bezt = nullptr;
}
else {
*r_bezt = bezt1;
@@ -207,16 +201,16 @@ void ED_curve_nurb_vert_selected_find(
a = nu1->pntsu * nu1->pntsv;
while (a--) {
if (bp1->f1 & SELECT) {
if (!ELEM(*r_nu, NULL, nu1)) {
*r_bp = NULL;
*r_bezt = NULL;
*r_nu = NULL;
if (!ELEM(*r_nu, nullptr, nu1)) {
*r_bp = nullptr;
*r_bezt = nullptr;
*r_nu = nullptr;
return;
}
if (*r_bezt || *r_bp) {
*r_bp = NULL;
*r_bezt = NULL;
*r_bp = nullptr;
*r_bezt = nullptr;
}
else {
*r_bp = bp1;
@@ -231,8 +225,8 @@ void ED_curve_nurb_vert_selected_find(
bool ED_curve_active_center(Curve *cu, float center[3])
{
Nurb *nu = NULL;
void *vert = NULL;
Nurb *nu = nullptr;
void *vert = nullptr;
if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert)) {
return false;

View File

@@ -214,7 +214,7 @@ int ED_curve_select_count(const View3D *v3d, const EditNurb *editnurb)
int sel = 0;
Nurb *nu;
for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
for (nu = static_cast<Nurb *>(editnurb->nurbs.first); nu; nu = nu->next) {
sel += ED_curve_nurb_select_count(v3d, nu);
}
@@ -246,7 +246,7 @@ bool ED_curve_deselect_all_multi_ex(Base **bases, int bases_len)
bool changed_multi = false;
for (uint base_index = 0; base_index < bases_len; base_index++) {
Object *obedit = bases[base_index]->object;
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
changed_multi |= ED_curve_deselect_all(cu->editnurb);
DEG_id_tag_update(&cu->id, ID_RECALC_SELECT);
}
@@ -404,7 +404,7 @@ static void selectend_nurb(Object *obedit, eEndPoint_Types selfirst, bool doswap
Curve *cu;
int a;
if (obedit == NULL) {
if (obedit == nullptr) {
return;
}
@@ -467,7 +467,7 @@ static void selectend_nurb(Object *obedit, eEndPoint_Types selfirst, bool doswap
}
}
static int de_select_first_exec(bContext *C, wmOperator *UNUSED(op))
static int de_select_first_exec(bContext *C, wmOperator * /*op*/)
{
const Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -478,9 +478,9 @@ static int de_select_first_exec(bContext *C, wmOperator *UNUSED(op))
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
selectend_nurb(obedit, FIRST, true, false);
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
BKE_curve_nurb_vert_active_validate(obedit->data);
BKE_curve_nurb_vert_active_validate(static_cast<Curve *>(obedit->data));
}
MEM_freeN(objects);
return OPERATOR_FINISHED;
@@ -501,7 +501,7 @@ void CURVE_OT_de_select_first(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int de_select_last_exec(bContext *C, wmOperator *UNUSED(op))
static int de_select_last_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -512,9 +512,9 @@ static int de_select_last_exec(bContext *C, wmOperator *UNUSED(op))
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
selectend_nurb(obedit, LAST, true, false);
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
BKE_curve_nurb_vert_active_validate(obedit->data);
BKE_curve_nurb_vert_active_validate(static_cast<Curve *>(obedit->data));
}
MEM_freeN(objects);
@@ -556,7 +556,7 @@ static int de_select_all_exec(bContext *C, wmOperator *op)
action = SEL_SELECT;
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
if (ED_curve_select_check(v3d, cu->editnurb)) {
action = SEL_DESELECT;
@@ -567,7 +567,7 @@ static int de_select_all_exec(bContext *C, wmOperator *op)
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
bool changed = false;
switch (action) {
@@ -584,7 +584,7 @@ static int de_select_all_exec(bContext *C, wmOperator *op)
}
if (changed) {
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
BKE_curve_nurb_vert_active_validate(cu);
}
@@ -618,7 +618,7 @@ void CURVE_OT_select_all(wmOperatorType *ot)
/** \name Select Linked Operator
* \{ */
static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
static int select_linked_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -629,7 +629,7 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditNurb *editnurb = cu->editnurb;
ListBase *nurbs = &editnurb->nurbs;
bool changed = false;
@@ -641,7 +641,7 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
}
if (changed) {
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
}
@@ -650,7 +650,7 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
static int select_linked_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int select_linked_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
return select_linked_exec(C, op);
}
@@ -688,13 +688,13 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent
BPoint *bp;
int a;
const bool select = !RNA_boolean_get(op->ptr, "deselect");
Base *basact = NULL;
Base *basact = nullptr;
view3d_operator_needs_opengl(C);
ED_view3d_viewcontext_init(C, &vc, depsgraph);
copy_v2_v2_int(vc.mval, event->mval);
if (!ED_curve_pick_vert(&vc, 1, &nu, &bezt, &bp, NULL, &basact)) {
if (!ED_curve_pick_vert(&vc, 1, &nu, &bezt, &bp, nullptr, &basact)) {
return OPERATOR_CANCELLED;
}
@@ -717,11 +717,11 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent
Object *obedit = basact->object;
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
if (!select) {
BKE_curve_nurb_vert_active_validate(obedit->data);
BKE_curve_nurb_vert_active_validate(static_cast<Curve *>(obedit->data));
}
return OPERATOR_FINISHED;
@@ -755,18 +755,18 @@ void CURVE_OT_select_linked_pick(wmOperatorType *ot)
/** \name Select Row Operator
* \{ */
static int select_row_exec(bContext *C, wmOperator *UNUSED(op))
static int select_row_exec(bContext *C, wmOperator * /*op*/)
{
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
ListBase *editnurb = object_editcurve_get(obedit);
static BPoint *last = NULL;
static BPoint *last = nullptr;
static int direction = 0;
Nurb *nu = NULL;
BPoint *bp = NULL;
Nurb *nu = nullptr;
BPoint *bp = nullptr;
int u = 0, v = 0, a, b;
if (!BKE_curve_nurb_vert_active_get(cu, &nu, (void *)&bp)) {
if (!BKE_curve_nurb_vert_active_get(cu, &nu, static_cast<void **>((void *)&bp))) {
return OPERATOR_CANCELLED;
}
@@ -794,7 +794,7 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op))
}
}
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
@@ -821,7 +821,7 @@ void CURVE_OT_select_row(wmOperatorType *ot)
/** \name Select Next Operator
* \{ */
static int select_next_exec(bContext *C, wmOperator *UNUSED(op))
static int select_next_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -835,7 +835,7 @@ static int select_next_exec(bContext *C, wmOperator *UNUSED(op))
ListBase *editnurb = object_editcurve_get(obedit);
select_adjacent_cp(editnurb, 1, 0, SELECT);
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -863,7 +863,7 @@ void CURVE_OT_select_next(wmOperatorType *ot)
/** \name Select Previous Operator
* \{ */
static int select_previous_exec(bContext *C, wmOperator *UNUSED(op))
static int select_previous_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -877,7 +877,7 @@ static int select_previous_exec(bContext *C, wmOperator *UNUSED(op))
ListBase *editnurb = object_editcurve_get(obedit);
select_adjacent_cp(editnurb, -1, 0, SELECT);
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -980,7 +980,7 @@ static void curve_select_more(Object *obedit)
}
}
static int curve_select_more_exec(bContext *C, wmOperator *UNUSED(op))
static int curve_select_more_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -990,7 +990,7 @@ static int curve_select_more_exec(bContext *C, wmOperator *UNUSED(op))
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
curve_select_more(obedit);
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -1199,7 +1199,7 @@ static void curve_select_less(Object *obedit)
}
}
static int curve_select_less_exec(bContext *C, wmOperator *UNUSED(op))
static int curve_select_less_exec(bContext *C, wmOperator * /*op*/)
{
const Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -1209,7 +1209,7 @@ static int curve_select_less_exec(bContext *C, wmOperator *UNUSED(op))
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
curve_select_less(obedit);
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -1323,8 +1323,8 @@ static int curve_select_random_exec(bContext *C, wmOperator *op)
}
MEM_freeN(verts_selection_mask);
BKE_curve_nurb_vert_active_validate(obedit->data);
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
BKE_curve_nurb_vert_active_validate(static_cast<Curve *>(obedit->data));
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
@@ -1405,18 +1405,18 @@ static void select_nth_bp(Nurb *nu, BPoint *bp, const struct CheckerIntervalPara
static bool ed_curve_select_nth(Curve *cu, const struct CheckerIntervalParams *params)
{
Nurb *nu = NULL;
void *vert = NULL;
Nurb *nu = nullptr;
void *vert = nullptr;
if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert)) {
return false;
}
if (nu->bezt) {
select_nth_bezt(nu, vert, params);
select_nth_bezt(nu, static_cast<BezTriple *>(vert), params);
}
else {
select_nth_bp(nu, vert, params);
select_nth_bp(nu, static_cast<BPoint *>(vert), params);
}
return true;
@@ -1438,16 +1438,16 @@ static int select_nth_exec(bContext *C, wmOperator *op)
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
if (!ED_curve_select_check(v3d, cu->editnurb)) {
continue;
}
if (ed_curve_select_nth(obedit->data, &op_params) == true) {
if (ed_curve_select_nth(static_cast<Curve *>(obedit->data), &op_params) == true) {
changed = true;
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
}
@@ -1493,7 +1493,7 @@ static const EnumPropertyItem curve_prop_similar_compare_types[] = {
{SIM_CMP_GT, "GREATER", 0, "Greater", ""},
{SIM_CMP_LT, "LESS", 0, "Less", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
enum {
@@ -1508,7 +1508,7 @@ static const EnumPropertyItem curve_prop_similar_types[] = {
{SIMCURHAND_RADIUS, "RADIUS", 0, "Radius", ""},
{SIMCURHAND_WEIGHT, "WEIGHT", 0, "Weight", ""},
{SIMCURHAND_DIRECTION, "DIRECTION", 0, "Direction", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static void nurb_bezt_direction_worldspace_get(Object *ob,
@@ -1626,14 +1626,16 @@ static bool curve_nurb_select_similar_type(Object *ob,
switch (type) {
case SIMCURHAND_RADIUS: {
float radius_ref = bezt->radius;
if (ED_select_similar_compare_float_tree(tree_1d, radius_ref, thresh, compare)) {
if (ED_select_similar_compare_float_tree(
tree_1d, radius_ref, thresh, eSimilarCmp(compare))) {
select = true;
}
break;
}
case SIMCURHAND_WEIGHT: {
float weight_ref = bezt->weight;
if (ED_select_similar_compare_float_tree(tree_1d, weight_ref, thresh, compare)) {
if (ED_select_similar_compare_float_tree(
tree_1d, weight_ref, thresh, eSimilarCmp(compare))) {
select = true;
}
break;
@@ -1645,7 +1647,7 @@ static bool curve_nurb_select_similar_type(Object *ob,
if (BLI_kdtree_3d_find_nearest(tree_3d, dir, &nearest) != -1) {
float orient = angle_normalized_v3v3(dir, nearest.co);
float delta = thresh_cos - fabsf(cosf(orient));
if (ED_select_similar_compare_float(delta, thresh, compare)) {
if (ED_select_similar_compare_float(delta, thresh, eSimilarCmp(compare))) {
select = true;
}
}
@@ -1671,14 +1673,16 @@ static bool curve_nurb_select_similar_type(Object *ob,
switch (type) {
case SIMCURHAND_RADIUS: {
float radius_ref = bp->radius;
if (ED_select_similar_compare_float_tree(tree_1d, radius_ref, thresh, compare)) {
if (ED_select_similar_compare_float_tree(
tree_1d, radius_ref, thresh, eSimilarCmp(compare))) {
select = true;
}
break;
}
case SIMCURHAND_WEIGHT: {
float weight_ref = bp->weight;
if (ED_select_similar_compare_float_tree(tree_1d, weight_ref, thresh, compare)) {
if (ED_select_similar_compare_float_tree(
tree_1d, weight_ref, thresh, eSimilarCmp(compare))) {
select = true;
}
break;
@@ -1690,7 +1694,7 @@ static bool curve_nurb_select_similar_type(Object *ob,
if (BLI_kdtree_3d_find_nearest(tree_3d, dir, &nearest) != -1) {
float orient = angle_normalized_v3v3(dir, nearest.co);
float delta = fabsf(cosf(orient)) - thresh_cos;
if (ED_select_similar_compare_float(delta, thresh, compare)) {
if (ED_select_similar_compare_float(delta, thresh, eSimilarCmp(compare))) {
select = true;
}
}
@@ -1725,7 +1729,7 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
tot_nurbs_selected_all += ED_curve_select_count(v3d, cu->editnurb);
}
@@ -1735,8 +1739,8 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
KDTree_1d *tree_1d = NULL;
KDTree_3d *tree_3d = NULL;
KDTree_1d *tree_1d = nullptr;
KDTree_3d *tree_3d = nullptr;
short type_ref = 0;
switch (optype) {
@@ -1752,7 +1756,7 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
/* Get type of selected control points. */
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditNurb *editnurb = cu->editnurb;
LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
@@ -1773,11 +1777,11 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
}
}
if (tree_1d != NULL) {
if (tree_1d != nullptr) {
BLI_kdtree_1d_deduplicate(tree_1d);
BLI_kdtree_1d_balance(tree_1d);
}
if (tree_3d != NULL) {
if (tree_3d != nullptr) {
BLI_kdtree_3d_deduplicate(tree_3d);
BLI_kdtree_3d_balance(tree_3d);
}
@@ -1785,7 +1789,7 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
/* Select control points with desired type. */
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditNurb *editnurb = cu->editnurb;
bool changed = false;
@@ -1807,17 +1811,17 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
}
if (changed) {
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
}
MEM_freeN(objects);
if (tree_1d != NULL) {
if (tree_1d != nullptr) {
BLI_kdtree_1d_free(tree_1d);
}
if (tree_3d != NULL) {
if (tree_3d != nullptr) {
BLI_kdtree_3d_free(tree_3d);
}
return OPERATOR_FINISHED;
@@ -1934,7 +1938,7 @@ static void curve_select_shortest_path_surf(Nurb *nu, int vert_src, int vert_dst
} * data;
/* init connectivity data */
data = MEM_mallocN(sizeof(*data) * vert_num, __func__);
data = static_cast<PointAdj *>(MEM_mallocN(sizeof(*data) * vert_num, __func__));
for (int i = 0; i < vert_num; i++) {
data[i].vert = i;
data[i].vert_prev = -1;
@@ -1983,7 +1987,7 @@ static void curve_select_shortest_path_surf(Nurb *nu, int vert_src, int vert_dst
}
}
BLI_heapsimple_free(heap, NULL);
BLI_heapsimple_free(heap, nullptr);
if (vert_curr == vert_dst) {
int i = 0;
@@ -2010,19 +2014,19 @@ static int edcu_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE
BPoint *bp_dst;
int vert_dst;
void *vert_dst_p;
Base *basact = NULL;
Base *basact = nullptr;
view3d_operator_needs_opengl(C);
ED_view3d_viewcontext_init(C, &vc, depsgraph);
copy_v2_v2_int(vc.mval, event->mval);
if (!ED_curve_pick_vert(&vc, 1, &nu_dst, &bezt_dst, &bp_dst, NULL, &basact)) {
if (!ED_curve_pick_vert(&vc, 1, &nu_dst, &bezt_dst, &bp_dst, nullptr, &basact)) {
return OPERATOR_PASS_THROUGH;
}
ED_view3d_viewcontext_init_object(&vc, basact->object);
Object *obedit = basact->object;
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
Nurb *nu_src = BKE_curve_nurb_active_get(cu);
int vert_src = cu->actvert;
@@ -2055,7 +2059,7 @@ static int edcu_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE
ED_object_base_activate(C, basact);
}
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT | ID_RECALC_COPY_ON_WRITE);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT | ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}

View File

@@ -68,307 +68,307 @@ static char *font_select_to_buffer(Object *obedit);
static char32_t findaccent(char32_t char1, const char code)
{
char32_t new = 0;
char32_t new_char = 0;
if (char1 == 'a') {
if (code == '`') {
new = 224;
new_char = 224;
}
else if (code == 39) {
new = 225;
new_char = 225;
}
else if (code == '^') {
new = 226;
new_char = 226;
}
else if (code == '~') {
new = 227;
new_char = 227;
}
else if (code == '"') {
new = 228;
new_char = 228;
}
else if (code == 'o') {
new = 229;
new_char = 229;
}
else if (code == 'e') {
new = 230;
new_char = 230;
}
else if (code == '-') {
new = 170;
new_char = 170;
}
}
else if (char1 == 'c') {
if (code == ',') {
new = 231;
new_char = 231;
}
else if (code == '|') {
new = 162;
new_char = 162;
}
else if (code == 'o') {
new = 169;
new_char = 169;
}
}
else if (char1 == 'e') {
if (code == '`') {
new = 232;
new_char = 232;
}
else if (code == 39) {
new = 233;
new_char = 233;
}
else if (code == '^') {
new = 234;
new_char = 234;
}
else if (code == '"') {
new = 235;
new_char = 235;
}
}
else if (char1 == 'i') {
if (code == '`') {
new = 236;
new_char = 236;
}
else if (code == 39) {
new = 237;
new_char = 237;
}
else if (code == '^') {
new = 238;
new_char = 238;
}
else if (code == '"') {
new = 239;
new_char = 239;
}
}
else if (char1 == 'n') {
if (code == '~') {
new = 241;
new_char = 241;
}
}
else if (char1 == 'o') {
if (code == '`') {
new = 242;
new_char = 242;
}
else if (code == 39) {
new = 243;
new_char = 243;
}
else if (code == '^') {
new = 244;
new_char = 244;
}
else if (code == '~') {
new = 245;
new_char = 245;
}
else if (code == '"') {
new = 246;
new_char = 246;
}
else if (code == '/') {
new = 248;
new_char = 248;
}
else if (code == '-') {
new = 186;
new_char = 186;
}
else if (code == 'e') {
new = 339;
new_char = 339;
}
else if (code == 'c') {
new = 169;
new_char = 169;
}
else if (code == 'r') {
new = 174;
new_char = 174;
}
}
else if (char1 == 'r') {
if (code == 'o') {
new = 174;
new_char = 174;
}
}
else if (char1 == 's') {
if (code == 's') {
new = 167;
new_char = 167;
}
}
else if (char1 == 't') {
if (code == 'm') {
new = 8482;
new_char = 8482;
}
}
else if (char1 == 'u') {
if (code == '`') {
new = 249;
new_char = 249;
}
else if (code == 39) {
new = 250;
new_char = 250;
}
else if (code == '^') {
new = 251;
new_char = 251;
}
else if (code == '"') {
new = 252;
new_char = 252;
}
}
else if (char1 == 'y') {
if (code == 39) {
new = 253;
new_char = 253;
}
else if (code == '"') {
new = 255;
new_char = 255;
}
}
else if (char1 == 'A') {
if (code == '`') {
new = 192;
new_char = 192;
}
else if (code == 39) {
new = 193;
new_char = 193;
}
else if (code == '^') {
new = 194;
new_char = 194;
}
else if (code == '~') {
new = 195;
new_char = 195;
}
else if (code == '"') {
new = 196;
new_char = 196;
}
else if (code == 'o') {
new = 197;
new_char = 197;
}
else if (code == 'e') {
new = 198;
new_char = 198;
}
}
else if (char1 == 'C') {
if (code == ',') {
new = 199;
new_char = 199;
}
}
else if (char1 == 'E') {
if (code == '`') {
new = 200;
new_char = 200;
}
else if (code == 39) {
new = 201;
new_char = 201;
}
else if (code == '^') {
new = 202;
new_char = 202;
}
else if (code == '"') {
new = 203;
new_char = 203;
}
}
else if (char1 == 'I') {
if (code == '`') {
new = 204;
new_char = 204;
}
else if (code == 39) {
new = 205;
new_char = 205;
}
else if (code == '^') {
new = 206;
new_char = 206;
}
else if (code == '"') {
new = 207;
new_char = 207;
}
}
else if (char1 == 'N') {
if (code == '~') {
new = 209;
new_char = 209;
}
}
else if (char1 == 'O') {
if (code == '`') {
new = 210;
new_char = 210;
}
else if (code == 39) {
new = 211;
new_char = 211;
}
else if (code == '^') {
new = 212;
new_char = 212;
}
else if (code == '~') {
new = 213;
new_char = 213;
}
else if (code == '"') {
new = 214;
new_char = 214;
}
else if (code == '/') {
new = 216;
new_char = 216;
}
else if (code == 'e') {
new = 141;
new_char = 141;
}
}
else if (char1 == 'U') {
if (code == '`') {
new = 217;
new_char = 217;
}
else if (code == 39) {
new = 218;
new_char = 218;
}
else if (code == '^') {
new = 219;
new_char = 219;
}
else if (code == '"') {
new = 220;
new_char = 220;
}
}
else if (char1 == 'Y') {
if (code == 39) {
new = 221;
new_char = 221;
}
}
else if (char1 == '1') {
if (code == '4') {
new = 188;
new_char = 188;
}
if (code == '2') {
new = 189;
new_char = 189;
}
}
else if (char1 == '3') {
if (code == '4') {
new = 190;
new_char = 190;
}
}
else if (char1 == ':') {
if (code == '-') {
new = 247;
new_char = 247;
}
}
else if (char1 == '-') {
if (code == ':') {
new = 247;
new_char = 247;
}
if (code == '|') {
new = 8224;
new_char = 8224;
}
if (code == '+') {
new = 177;
new_char = 177;
}
}
else if (char1 == '|') {
if (code == '-') {
new = 8224;
new_char = 8224;
}
if (code == '=') {
new = 8225;
new_char = 8225;
}
}
else if (char1 == '=') {
if (code == '|') {
new = 8225;
new_char = 8225;
}
}
else if (char1 == '+') {
if (code == '-') {
new = 177;
new_char = 177;
}
}
if (new) {
return new;
if (new_char) {
return new_char;
}
return char1;
}
static int insert_into_textbuf(Object *obedit, uintptr_t c)
{
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
if (ef->len < MAXTEXT - 1) {
@@ -396,7 +396,7 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
static void text_update_edited(bContext *C, Object *obedit, const eEditFontMode mode)
{
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
BLI_assert(ef->len >= 0);
@@ -404,7 +404,7 @@ static void text_update_edited(bContext *C, Object *obedit, const eEditFontMode
/* run update first since it can move the cursor */
if (mode == FO_EDIT) {
/* re-tesselllate */
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
}
else {
/* depsgraph runs above, but since we're not tagging for update, call direct */
@@ -425,13 +425,13 @@ static void text_update_edited(bContext *C, Object *obedit, const eEditFontMode
}
}
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
}
static int kill_selection(Object *obedit, int ins) /* ins == new character len */
{
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
int selend, selstart, direction;
int getfrom;
@@ -463,7 +463,7 @@ static void font_select_update_primary_clipboard(Object *obedit)
return;
}
char *buf = font_select_to_buffer(obedit);
if (buf == NULL) {
if (buf == nullptr) {
return;
}
WM_clipboard_text_set(buf, true);
@@ -483,7 +483,7 @@ static bool font_paste_wchar(Object *obedit,
/* optional */
CharInfo *str_info)
{
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
int selend, selstart;
@@ -529,11 +529,11 @@ static bool font_paste_utf8(bContext *C, const char *str, const size_t str_len)
int tmplen;
char32_t *mem = MEM_mallocN((sizeof(*mem) * (str_len + 1)), __func__);
char32_t *mem = static_cast<char32_t *>(MEM_mallocN((sizeof(*mem) * (str_len + 1)), __func__));
tmplen = BLI_str_utf8_as_utf32(mem, str, str_len + 1);
retval = font_paste_wchar(obedit, mem, tmplen, NULL);
retval = font_paste_wchar(obedit, mem, tmplen, nullptr);
MEM_freeN(mem);
@@ -550,15 +550,15 @@ static char *font_select_to_buffer(Object *obedit)
{
int selstart, selend;
if (!BKE_vfont_select_get(obedit, &selstart, &selend)) {
return NULL;
return nullptr;
}
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
char32_t *text_buf = ef->textbuf + selstart;
const size_t text_buf_len = selend - selstart;
const size_t len_utf8 = BLI_str_utf32_as_utf8_len_ex(text_buf, text_buf_len + 1);
char *buf = MEM_mallocN(len_utf8 + 1, __func__);
char *buf = static_cast<char *>(MEM_mallocN(len_utf8 + 1, __func__));
BLI_str_utf32_as_utf8(buf, text_buf, len_utf8);
return buf;
}
@@ -576,8 +576,8 @@ static int paste_from_file(bContext *C, ReportList *reports, const char *filepat
size_t filelen;
int retval;
strp = BLI_file_read_text_as_mem(filepath, 1, &filelen);
if (strp == NULL) {
strp = static_cast<char *>(BLI_file_read_text_as_mem(filepath, 1, &filelen));
if (strp == nullptr) {
BKE_reportf(reports, RPT_ERROR, "Failed to open file '%s'", filepath);
return OPERATOR_CANCELLED;
}
@@ -602,14 +602,14 @@ static int paste_from_file_exec(bContext *C, wmOperator *op)
char *filepath;
int retval;
filepath = RNA_string_get_alloc(op->ptr, "filepath", NULL, 0, NULL);
filepath = RNA_string_get_alloc(op->ptr, "filepath", nullptr, 0, nullptr);
retval = paste_from_file(C, op->reports, filepath);
MEM_freeN(filepath);
return retval;
}
static int paste_from_file_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int paste_from_file_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return paste_from_file_exec(C, op);
@@ -669,18 +669,18 @@ static void txt_add_object(bContext *C,
int a;
const float rot[3] = {0.0f, 0.0f, 0.0f};
obedit = BKE_object_add(bmain, scene, view_layer, OB_FONT, NULL);
obedit = BKE_object_add(bmain, scene, view_layer, OB_FONT, nullptr);
BKE_view_layer_synced_ensure(scene, view_layer);
object = BKE_view_layer_active_object_get(view_layer);
/* seems to assume view align ? TODO: look into this, could be an operator option. */
ED_object_base_init_transform_on_add(object, NULL, rot);
ED_object_base_init_transform_on_add(object, nullptr, rot);
BKE_object_where_is_calc(depsgraph, scene, obedit);
add_v3_v3(obedit->loc, offset);
cu = obedit->data;
cu = static_cast<Curve *>(obedit->data);
cu->vfont = BKE_vfont_builtin_get();
id_us_plus(&cu->vfont->id);
@@ -698,8 +698,8 @@ static void txt_add_object(bContext *C,
MEM_freeN(cu->strinfo);
}
cu->str = MEM_mallocN(nbytes + 4, "str");
cu->strinfo = MEM_callocN((nchars + 4) * sizeof(CharInfo), "strinfo");
cu->str = static_cast<char *>(MEM_mallocN(nbytes + 4, "str"));
cu->strinfo = static_cast<CharInfo *>(MEM_callocN((nchars + 4) * sizeof(CharInfo), "strinfo"));
cu->len = 0;
cu->len_char32 = nchars - 1;
@@ -742,7 +742,7 @@ void ED_text_to_object(bContext *C, const Text *text, const bool split_lines)
}
if (split_lines) {
for (line = text->lines.first; line; line = line->next) {
for (line = static_cast<const TextLine *>(text->lines.first); line; line = line->next) {
/* skip lines with no text, but still make space for them */
if (line->line[0] == '\0') {
linenum++;
@@ -768,7 +768,10 @@ void ED_text_to_object(bContext *C, const Text *text, const bool split_lines)
offset[1] = 0.0f;
offset[2] = 0.0f;
txt_add_object(C, text->lines.first, BLI_listbase_count(&text->lines), offset);
txt_add_object(C,
static_cast<const TextLine *>(text->lines.first),
BLI_listbase_count(&text->lines),
offset);
}
DEG_relations_tag_update(bmain);
@@ -786,13 +789,13 @@ static const EnumPropertyItem style_items[] = {
{CU_CHINFO_ITALIC, "ITALIC", 0, "Italic", ""},
{CU_CHINFO_UNDERLINE, "UNDERLINE", 0, "Underline", ""},
{CU_CHINFO_SMALLCAPS, "SMALL_CAPS", 0, "Small Caps", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static int set_style(bContext *C, const int style, const bool clear)
{
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
int i, selstart, selend;
@@ -809,7 +812,7 @@ static int set_style(bContext *C, const int style, const bool clear)
}
}
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
@@ -852,7 +855,7 @@ void FONT_OT_style_set(wmOperatorType *ot)
static int toggle_style_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
int style, clear, selstart, selend;
style = RNA_enum_get(op->ptr, "style");
@@ -889,10 +892,10 @@ void FONT_OT_style_toggle(wmOperatorType *ot)
/** \name Select All Operator
* \{ */
static int font_select_all_exec(bContext *C, wmOperator *UNUSED(op))
static int font_select_all_exec(bContext *C, wmOperator * /*op*/)
{
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
if (ef->len) {
@@ -934,19 +937,19 @@ static void copy_selection(Object *obedit)
int selstart, selend;
if (BKE_vfont_select_get(obedit, &selstart, &selend)) {
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
char *buf = NULL;
char *buf = nullptr;
char32_t *text_buf;
size_t len_utf8;
/* internal clipboard (for style) */
BKE_vfont_clipboard_set(
ef->textbuf + selstart, ef->textbufinfo + selstart, selend - selstart + 1);
BKE_vfont_clipboard_get(&text_buf, NULL, &len_utf8, NULL);
BKE_vfont_clipboard_get(&text_buf, nullptr, &len_utf8, nullptr);
/* system clipboard */
buf = MEM_mallocN(len_utf8 + 1, __func__);
buf = static_cast<char *>(MEM_mallocN(len_utf8 + 1, __func__));
if (buf) {
BLI_str_utf32_as_utf8(buf, text_buf, len_utf8 + 1);
WM_clipboard_text_set(buf, false);
@@ -955,7 +958,7 @@ static void copy_selection(Object *obedit)
}
}
static int copy_text_exec(bContext *C, wmOperator *UNUSED(op))
static int copy_text_exec(bContext *C, wmOperator * /*op*/)
{
Object *obedit = CTX_data_edit_object(C);
@@ -982,7 +985,7 @@ void FONT_OT_text_copy(wmOperatorType *ot)
/** \name Cut Text Operator
* \{ */
static int cut_text_exec(bContext *C, wmOperator *UNUSED(op))
static int cut_text_exec(bContext *C, wmOperator * /*op*/)
{
Object *obedit = CTX_data_edit_object(C);
int selstart, selend;
@@ -1026,7 +1029,7 @@ static bool paste_selection(Object *obedit, ReportList *reports)
CharInfo *info_buf;
size_t len;
BKE_vfont_clipboard_get(&text_buf, &info_buf, NULL, &len);
BKE_vfont_clipboard_get(&text_buf, &info_buf, nullptr, &len);
if (font_paste_wchar(obedit, text_buf, len, info_buf)) {
return true;
@@ -1050,21 +1053,21 @@ static int paste_text_exec(bContext *C, wmOperator *op)
struct {
char *buf;
int len;
} clipboard_system = {NULL}, clipboard_vfont = {NULL};
} clipboard_system = {nullptr}, clipboard_vfont = {nullptr};
/* No need for UTF8 validation as the conversion handles invalid sequences gracefully. */
clipboard_system.buf = WM_clipboard_text_get(selection, false, &clipboard_system.len);
if (clipboard_system.buf == NULL) {
if (clipboard_system.buf == nullptr) {
return OPERATOR_CANCELLED;
}
BKE_vfont_clipboard_get(&text_buf, NULL, &len_utf8, NULL);
BKE_vfont_clipboard_get(&text_buf, nullptr, &len_utf8, nullptr);
if (text_buf) {
clipboard_vfont.buf = MEM_mallocN(len_utf8 + 1, __func__);
clipboard_vfont.buf = static_cast<char *>(MEM_mallocN(len_utf8 + 1, __func__));
if (clipboard_vfont.buf == NULL) {
if (clipboard_vfont.buf == nullptr) {
MEM_freeN(clipboard_system.buf);
return OPERATOR_CANCELLED;
}
@@ -1148,14 +1151,14 @@ static const EnumPropertyItem move_type_items[] = {
{NEXT_LINE, "NEXT_LINE", 0, "Next Line", ""},
{PREV_PAGE, "PREVIOUS_PAGE", 0, "Previous Page", ""},
{NEXT_PAGE, "NEXT_PAGE", 0, "Next Page", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static int move_cursor(bContext *C, int type, const bool select)
{
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
int cursmove = -1;
@@ -1265,7 +1268,7 @@ static int move_cursor(bContext *C, int type, const bool select)
/* apply vertical cursor motion to position immediately
* otherwise the selection will lag behind */
if (FO_CURS_IS_MOTION(cursmove)) {
BKE_vfont_to_curve(DEG_get_evaluated_object(depsgraph, obedit), cursmove);
BKE_vfont_to_curve(DEG_get_evaluated_object(depsgraph, obedit), eEditFontMode(cursmove));
cursmove = FO_CURS;
}
@@ -1281,7 +1284,7 @@ static int move_cursor(bContext *C, int type, const bool select)
font_select_update_primary_clipboard(obedit);
}
text_update_edited(C, obedit, cursmove);
text_update_edited(C, obedit, eEditFontMode(cursmove));
return OPERATOR_FINISHED;
}
@@ -1356,7 +1359,7 @@ void FONT_OT_move_select(wmOperatorType *ot)
static int change_spacing_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
float kern, delta = RNA_float_get(op->ptr, "delta");
int selstart, selend;
@@ -1423,7 +1426,7 @@ void FONT_OT_change_spacing(wmOperatorType *ot)
static int change_character_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
int character, delta = RNA_int_get(op->ptr, "delta");
@@ -1478,10 +1481,10 @@ void FONT_OT_change_character(wmOperatorType *ot)
/** \name Line Break Operator
* \{ */
static int line_break_exec(bContext *C, wmOperator *UNUSED(op))
static int line_break_exec(bContext *C, wmOperator * /*op*/)
{
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
insert_into_textbuf(obedit, '\n');
@@ -1522,13 +1525,13 @@ static const EnumPropertyItem delete_type_items[] = {
{DEL_SELECTION, "SELECTION", 0, "Selection", ""},
{DEL_NEXT_SEL, "NEXT_OR_SELECTION", 0, "Next or Selection", ""},
{DEL_PREV_SEL, "PREVIOUS_OR_SELECTION", 0, "Previous or Selection", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static int delete_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
int selstart, selend, type = RNA_enum_get(op->ptr, "type");
int range[2] = {0, 0};
@@ -1679,10 +1682,11 @@ static int insert_text_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
inserted_utf8 = RNA_string_get_alloc(op->ptr, "text", NULL, 0, NULL);
inserted_utf8 = RNA_string_get_alloc(op->ptr, "text", nullptr, 0, nullptr);
len = BLI_strlen_utf8(inserted_utf8);
inserted_text = MEM_callocN(sizeof(char32_t) * (len + 1), "FONT_insert_text");
inserted_text = static_cast<char32_t *>(
MEM_callocN(sizeof(char32_t) * (len + 1), "FONT_insert_text"));
len = BLI_str_utf8_as_utf32(inserted_text, inserted_utf8, MAXTEXT);
for (a = 0; a < len; a++) {
@@ -1701,7 +1705,7 @@ static int insert_text_exec(bContext *C, wmOperator *op)
static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
static bool accentcode = false;
const bool alt = event->modifier & KM_ALT;
@@ -1797,7 +1801,7 @@ void FONT_OT_text_insert(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
RNA_def_string(ot->srna, "text", NULL, 0, "Text", "Text to insert at the cursor position");
RNA_def_string(ot->srna, "text", nullptr, 0, "Text", "Text to insert at the cursor position");
RNA_def_boolean(
ot->srna,
"accent",
@@ -1834,7 +1838,7 @@ static void font_cursor_set_apply(bContext *C, const wmEvent *event)
{
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob = DEG_get_evaluated_object(depsgraph, CTX_data_active_object(C));
Curve *cu = ob->data;
Curve *cu = static_cast<Curve *>(ob->data);
EditFont *ef = cu->editfont;
BLI_assert(ef->len >= 0);
@@ -1864,14 +1868,14 @@ static void font_cursor_set_apply(bContext *C, const wmEvent *event)
ef->selend = string_offset;
ef->pos = string_offset;
DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
DEG_id_tag_update(static_cast<ID *>(ob->data), ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
}
static int font_selection_set_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Object *obedit = CTX_data_active_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
font_cursor_set_apply(C, event);
@@ -1882,7 +1886,7 @@ static int font_selection_set_invoke(bContext *C, wmOperator *op, const wmEvent
return OPERATOR_RUNNING_MODAL;
}
static int font_selection_set_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static int font_selection_set_modal(bContext *C, wmOperator * /*op*/, const wmEvent *event)
{
switch (event->type) {
case LEFTMOUSE:
@@ -1920,10 +1924,10 @@ void FONT_OT_selection_set(wmOperatorType *ot)
/** \name Select Word Operator
* \{ */
static int font_select_word_exec(bContext *C, wmOperator *UNUSED(op))
static int font_select_word_exec(bContext *C, wmOperator * /*op*/)
{
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
BLI_str_cursor_step_bounds_utf32(ef->textbuf, ef->len, ef->pos, &ef->selstart, &ef->selend);
@@ -1956,10 +1960,10 @@ void FONT_OT_select_word(wmOperatorType *ot)
/** \name Text-Box Add Operator
* \{ */
static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op))
static int textbox_add_exec(bContext *C, wmOperator * /*op*/)
{
Object *obedit = CTX_data_active_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
int i;
if (cu->totbox < 256) {
@@ -1971,7 +1975,7 @@ static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op))
cu->totbox++;
}
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -2000,7 +2004,7 @@ void FONT_OT_textbox_add(wmOperatorType *ot)
static int textbox_remove_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_active_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
int i;
int index = RNA_int_get(op->ptr, "index");
@@ -2014,7 +2018,7 @@ static int textbox_remove_exec(bContext *C, wmOperator *op)
}
}
DEG_id_tag_update(obedit->data, 0);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
@@ -2045,15 +2049,17 @@ void FONT_OT_textbox_remove(wmOperatorType *ot)
void ED_curve_editfont_make(Object *obedit)
{
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
int len_char32;
if (ef == NULL) {
ef = cu->editfont = MEM_callocN(sizeof(EditFont), "editfont");
if (ef == nullptr) {
ef = cu->editfont = static_cast<EditFont *>(MEM_callocN(sizeof(EditFont), "editfont"));
ef->textbuf = MEM_callocN((MAXTEXT + 4) * sizeof(*ef->textbuf), "texteditbuf");
ef->textbufinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditbufinfo");
ef->textbuf = static_cast<char32_t *>(
MEM_callocN((MAXTEXT + 4) * sizeof(*ef->textbuf), "texteditbuf"));
ef->textbufinfo = static_cast<CharInfo *>(
MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditbufinfo"));
}
/* Convert the original text to chat32_t. */
@@ -2081,7 +2087,7 @@ void ED_curve_editfont_make(Object *obedit)
void ED_curve_editfont_load(Object *obedit)
{
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
/* Free the old curve string */
@@ -2092,7 +2098,7 @@ void ED_curve_editfont_load(Object *obedit)
cu->len = BLI_str_utf32_as_utf8_len(ef->textbuf);
/* Alloc memory for UTF-8 variable char length string */
cu->str = MEM_mallocN(cu->len + sizeof(char32_t), "str");
cu->str = static_cast<char *>(MEM_mallocN(cu->len + sizeof(char32_t), "str"));
/* Copy the wchar to UTF-8 */
BLI_str_utf32_as_utf8(cu->str, ef->textbuf, cu->len + 1);
@@ -2100,7 +2106,8 @@ void ED_curve_editfont_load(Object *obedit)
if (cu->strinfo) {
MEM_freeN(cu->strinfo);
}
cu->strinfo = MEM_callocN((cu->len_char32 + 4) * sizeof(CharInfo), "texteditinfo");
cu->strinfo = static_cast<CharInfo *>(
MEM_callocN((cu->len_char32 + 4) * sizeof(CharInfo), "texteditinfo"));
memcpy(cu->strinfo, ef->textbufinfo, cu->len_char32 * sizeof(CharInfo));
/* Other vars */
@@ -2123,7 +2130,7 @@ void ED_curve_editfont_free(Object *obedit)
static const EnumPropertyItem case_items[] = {
{CASE_LOWER, "LOWER", 0, "Lower", ""},
{CASE_UPPER, "UPPER", 0, "Upper", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static int set_case(bContext *C, int ccase)
@@ -2179,10 +2186,10 @@ void FONT_OT_case_set(wmOperatorType *ot)
/** \name Toggle Case Operator
* \{ */
static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op))
static int toggle_case_exec(bContext *C, wmOperator * /*op*/)
{
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
char32_t *str;
int ccase = CASE_UPPER;
@@ -2221,14 +2228,15 @@ static void font_ui_template_init(bContext *C, wmOperator *op)
{
PropertyPointerRNA *pprop;
op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA");
op->customdata = pprop = static_cast<PropertyPointerRNA *>(
MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"));
UI_context_active_but_prop_get_templateID(C, &pprop->ptr, &pprop->prop);
}
static void font_open_cancel(bContext *UNUSED(C), wmOperator *op)
static void font_open_cancel(bContext * /*C*/, wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
op->customdata = nullptr;
}
static int font_open_exec(bContext *C, wmOperator *op)
@@ -2254,7 +2262,7 @@ static int font_open_exec(bContext *C, wmOperator *op)
}
/* hook into UI */
pprop = op->customdata;
pprop = static_cast<PropertyPointerRNA *>(op->customdata);
if (pprop->prop) {
/* when creating new ID blocks, use is already 1, but RNA
@@ -2262,7 +2270,7 @@ static int font_open_exec(bContext *C, wmOperator *op)
id_us_min(&font->id);
RNA_id_pointer_create(&font->id, &idptr);
RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr, NULL);
RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr, nullptr);
RNA_property_update(C, &pprop->ptr, pprop->prop);
}
@@ -2271,9 +2279,9 @@ static int font_open_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int open_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
VFont *vfont = NULL;
VFont *vfont = nullptr;
char filepath[FILE_MAX];
PointerRNA idptr;
@@ -2282,7 +2290,7 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
font_ui_template_init(C, op);
/* hook into UI */
pprop = op->customdata;
pprop = static_cast<PropertyPointerRNA *>(op->customdata);
if (pprop->prop) {
idptr = RNA_property_pointer_get((PointerRNA *)pprop, pprop->prop);
@@ -2349,7 +2357,7 @@ static int font_unlink_exec(bContext *C, wmOperator *op)
UI_context_active_but_prop_get_templateID(C, &pprop.ptr, &pprop.prop);
if (pprop.prop == NULL) {
if (pprop.prop == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Incorrect context for running font unlink");
return OPERATOR_CANCELLED;
}
@@ -2357,7 +2365,7 @@ static int font_unlink_exec(bContext *C, wmOperator *op)
builtin_font = BKE_vfont_builtin_get();
RNA_id_pointer_create(&builtin_font->id, &idptr);
RNA_property_pointer_set(&pprop.ptr, pprop.prop, idptr, NULL);
RNA_property_pointer_set(&pprop.ptr, pprop.prop, idptr, nullptr);
RNA_property_update(C, &pprop.ptr, pprop.prop);
return OPERATOR_FINISHED;
@@ -2382,11 +2390,11 @@ bool ED_curve_editfont_select_pick(
{
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
ViewContext vc;
/* bias against the active, in pixels, allows cycling */
const float active_bias_px = 4.0f;
const float mval_fl[2] = {UNPACK2(mval)};
const float mval_fl[2] = {float(mval[0]), float(mval[1])};
const int i_actbox = max_ii(0, cu->actbox - 1);
int i_iter, actbox_select = -1;
const float dist = ED_view3d_select_dist_px();
@@ -2451,7 +2459,7 @@ bool ED_curve_editfont_select_pick(
cu->actbox = actbox_select;
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
/* TODO: support #ID_RECALC_SELECT. */
DEG_id_tag_update(obedit->data, ID_RECALC_COPY_ON_WRITE);
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_COPY_ON_WRITE);
}
return true;
}

View File

@@ -52,7 +52,7 @@ static CLG_LogRef LOG = {"ed.undo.font"};
/** \name Undo Conversion
* \{ */
typedef struct UndoFont {
struct UndoFont {
char32_t *textbuf;
CharInfo *textbufinfo;
@@ -66,7 +66,7 @@ typedef struct UndoFont {
#endif
size_t undo_size;
} UndoFont;
};
#ifdef USE_ARRAY_STORE
@@ -81,7 +81,7 @@ static struct {
/* We could have the undo API pass in the previous state, for now store a local list */
ListBase local_links;
} uf_arraystore = {{NULL}};
} uf_arraystore = {{nullptr}};
/**
* \param create: When false, only free the arrays.
@@ -92,9 +92,9 @@ static void uf_arraystore_compact_ex(UndoFont *uf, const UndoFont *uf_ref, bool
{
# define STATE_COMPACT(uf, id, len) \
if ((uf)->id) { \
BLI_assert(create == ((uf)->store.id == NULL)); \
BLI_assert(create == ((uf)->store.id == nullptr)); \
if (create) { \
BArrayState *state_reference = uf_ref ? uf_ref->store.id : NULL; \
BArrayState *state_reference = uf_ref ? uf_ref->store.id : nullptr; \
const size_t stride = sizeof(*(uf)->id); \
BArrayStore *bs = BLI_array_store_at_size_ensure( \
&uf_arraystore.bs_stride, stride, ARRAY_CHUNK_SIZE); \
@@ -103,7 +103,7 @@ static void uf_arraystore_compact_ex(UndoFont *uf, const UndoFont *uf_ref, bool
} \
/* keep uf->len for validation */ \
MEM_freeN((uf)->id); \
(uf)->id = NULL; \
(uf)->id = nullptr; \
} \
((void)0)
@@ -163,7 +163,7 @@ static void uf_arraystore_compact_with_info(UndoFont *um, const UndoFont *uf_ref
*/
static void uf_arraystore_expand_clear(UndoFont *um)
{
uf_arraystore_compact_ex(um, NULL, false);
uf_arraystore_compact_ex(um, nullptr, false);
}
static void uf_arraystore_expand(UndoFont *uf)
@@ -173,7 +173,7 @@ static void uf_arraystore_expand(UndoFont *uf)
const size_t stride = sizeof(*(uf)->id); \
BArrayState *state = (uf)->store.id; \
size_t state_len; \
(uf)->id = BLI_array_store_state_data_get_alloc(state, &state_len); \
*(void **)&(uf)->id = BLI_array_store_state_data_get_alloc(state, &state_len); \
BLI_assert((len) == (state_len / stride)); \
UNUSED_VARS_NDEBUG(stride); \
} \
@@ -193,7 +193,7 @@ static void uf_arraystore_free(UndoFont *uf)
BArrayStore *bs = BLI_array_store_at_size_get(&uf_arraystore.bs_stride, stride); \
BArrayState *state = (uf)->store.id; \
BLI_array_store_state_remove(bs, state); \
(uf)->store.id = NULL; \
(uf)->store.id = nullptr; \
} \
((void)0)
@@ -257,11 +257,11 @@ static void *undofont_from_editfont(UndoFont *uf, Curve *cu)
BLI_assert(sizeof(*uf->textbuf) == sizeof(*ef->textbuf));
final_size = sizeof(*uf->textbuf) * (ef->len + 1);
uf->textbuf = MEM_mallocN(final_size, __func__);
uf->textbuf = static_cast<char32_t *>(MEM_mallocN(final_size, __func__));
memcpy(uf->textbuf, ef->textbuf, final_size);
final_size = sizeof(CharInfo) * (ef->len + 1);
uf->textbufinfo = MEM_mallocN(final_size, __func__);
uf->textbufinfo = static_cast<CharInfo *>(MEM_mallocN(final_size, __func__));
memcpy(uf->textbufinfo, ef->textbufinfo, final_size);
uf->pos = ef->pos;
@@ -271,9 +271,9 @@ static void *undofont_from_editfont(UndoFont *uf, Curve *cu)
#ifdef USE_ARRAY_STORE
{
const UndoFont *uf_ref = uf_arraystore.local_links.last ?
((LinkData *)uf_arraystore.local_links.last)->data :
NULL;
const UndoFont *uf_ref = static_cast<const UndoFont *>(
uf_arraystore.local_links.last ? ((LinkData *)uf_arraystore.local_links.last)->data :
nullptr);
/* Add ourselves. */
BLI_addtail(&uf_arraystore.local_links, BLI_genericNodeN(uf));
@@ -293,7 +293,8 @@ static void undofont_free_data(UndoFont *uf)
{
#ifdef USE_ARRAY_STORE
{
LinkData *link = BLI_findptr(&uf_arraystore.local_links, uf, offsetof(LinkData, data));
LinkData *link = static_cast<LinkData *>(
BLI_findptr(&uf_arraystore.local_links, uf, offsetof(LinkData, data)));
BLI_remlink(&uf_arraystore.local_links, link);
MEM_freeN(link);
}
@@ -315,13 +316,13 @@ static Object *editfont_object_from_context(bContext *C)
BKE_view_layer_synced_ensure(scene, view_layer);
Object *obedit = BKE_view_layer_edit_object_get(view_layer);
if (obedit && obedit->type == OB_FONT) {
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
EditFont *ef = cu->editfont;
if (ef != NULL) {
if (ef != nullptr) {
return obedit;
}
}
return NULL;
return nullptr;
}
/** \} */
@@ -330,23 +331,23 @@ static Object *editfont_object_from_context(bContext *C)
/** \name Implements ED Undo System
* \{ */
typedef struct FontUndoStep {
struct FontUndoStep {
UndoStep step;
/* NOTE: will split out into list for multi-object-editmode. */
UndoRefID_Object obedit_ref;
UndoFont data;
} FontUndoStep;
};
static bool font_undosys_poll(bContext *C)
{
return editfont_object_from_context(C) != NULL;
return editfont_object_from_context(C) != nullptr;
}
static bool font_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p)
{
FontUndoStep *us = (FontUndoStep *)us_p;
us->obedit_ref.ptr = editfont_object_from_context(C);
Curve *cu = us->obedit_ref.ptr->data;
Curve *cu = static_cast<Curve *>(us->obedit_ref.ptr->data);
undofont_from_editfont(&us->data, cu);
us->step.data_size = us->data.undo_size;
cu->editfont->needs_flush_to_id = 1;
@@ -355,11 +356,8 @@ static bool font_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p)
return true;
}
static void font_undosys_step_decode(bContext *C,
Main *bmain,
UndoStep *us_p,
const eUndoStepDir UNUSED(dir),
bool UNUSED(is_final))
static void font_undosys_step_decode(
bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir /*dir*/, bool /*is_final*/)
{
FontUndoStep *us = (FontUndoStep *)us_p;
@@ -368,7 +366,7 @@ static void font_undosys_step_decode(bContext *C,
/* Pass in an array of 1 (typically used for multi-object edit-mode). */
ED_undo_object_editmode_restore_helper(C, &obedit, 1, sizeof(Object *));
Curve *cu = obedit->data;
Curve *cu = static_cast<Curve *>(obedit->data);
undofont_to_editfont(&us->data, cu);
DEG_id_tag_update(&cu->id, ID_RECALC_GEOMETRY);
@@ -379,7 +377,7 @@ static void font_undosys_step_decode(bContext *C,
cu->editfont->needs_flush_to_id = 1;
bmain->is_memfile_undo_flush_needed = true;
WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, nullptr);
}
static void font_undosys_step_free(UndoStep *us_p)