Cleanup: move more editors code to c++

This moves the remaining `.c` files in the following `editors` folders to C++:
`physics`, `screen`, `sound`, `space_buttons`, `space_file`, `space_graph` and `space_image`.

One exception is `fsmenu.c` which has platform specific issues on macos and
windows. E.g. the `Carbon/Carbon.h` include also declares a `Collection` type that collides
with ours.

Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/109918
This commit is contained in:
Jacques Lucke
2023-07-12 13:43:00 +02:00
parent 38cecf9f89
commit 19d4cafb12
62 changed files with 2758 additions and 2460 deletions

View File

@@ -271,11 +271,12 @@ ScrArea *ED_screen_areas_iter_next(const bScreen *screen, const ScrArea *area);
area_name = ED_screen_areas_iter_next(screen, area_name))
#define ED_screen_verts_iter(win, screen, vert_name) \
for (ScrVert *vert_name = (win)->global_areas.vertbase.first ? \
(win)->global_areas.vertbase.first : \
(screen)->vertbase.first; \
(ScrVert *)(win)->global_areas.vertbase.first : \
(ScrVert *)(screen)->vertbase.first; \
vert_name != NULL; \
vert_name = (vert_name == (win)->global_areas.vertbase.last) ? (screen)->vertbase.first : \
vert_name->next)
vert_name = (vert_name == (win)->global_areas.vertbase.last) ? \
(ScrVert *)(screen)->vertbase.first : \
vert_name->next)
/* screens */

View File

@@ -511,7 +511,7 @@ static MenuSearch_Data *menu_items_from_ui_create(
PropertyRNA *prop_ui_type = nullptr;
{
/* This must be a valid pointer, with only it's type checked. */
ScrArea area_dummy = {nullptr};
ScrArea area_dummy{};
/* Anything besides #SPACE_EMPTY is fine,
* as this value is only included in the enum when set. */
area_dummy.spacetype = SPACE_TOPBAR;

View File

@@ -19,17 +19,17 @@ set(INC_SYS
)
set(SRC
dynamicpaint_ops.c
particle_boids.c
particle_edit.c
particle_edit_undo.c
particle_object.c
physics_fluid.c
physics_ops.c
physics_pointcache.c
rigidbody_constraint.c
rigidbody_object.c
rigidbody_world.c
dynamicpaint_ops.cc
particle_boids.cc
particle_edit.cc
particle_edit_undo.cc
particle_object.cc
physics_fluid.cc
physics_ops.cc
physics_pointcache.cc
rigidbody_constraint.cc
rigidbody_object.cc
rigidbody_world.cc
particle_edit_utildefines.h
physics_intern.h

View File

@@ -53,9 +53,9 @@
#include "physics_intern.h" /* own include */
static int surface_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
static int surface_slot_add_exec(bContext *C, wmOperator * /*op*/)
{
DynamicPaintModifierData *pmd = NULL;
DynamicPaintModifierData *pmd = nullptr;
Object *cObject = ED_object_context(C);
DynamicPaintCanvasSettings *canvas;
DynamicPaintSurface *surface;
@@ -96,9 +96,9 @@ void DPAINT_OT_surface_slot_add(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op))
static int surface_slot_remove_exec(bContext *C, wmOperator * /*op*/)
{
DynamicPaintModifierData *pmd = NULL;
DynamicPaintModifierData *pmd = nullptr;
Object *obj_ctx = ED_object_context(C);
DynamicPaintCanvasSettings *canvas;
DynamicPaintSurface *surface;
@@ -111,7 +111,7 @@ static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op))
}
canvas = pmd->canvas;
surface = canvas->surfaces.first;
surface = static_cast<DynamicPaintSurface *>(canvas->surfaces.first);
/* find active surface and remove it */
for (; surface; surface = surface->next) {
@@ -234,10 +234,10 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
/* Vertex Color Layer */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
if (!exists) {
ED_mesh_color_add(ob->data, name, true, true, op->reports);
ED_mesh_color_add(static_cast<Mesh *>(ob->data), name, true, true, op->reports);
}
else {
BKE_id_attribute_remove(ob->data, name, NULL);
BKE_id_attribute_remove(static_cast<ID *>(ob->data), name, nullptr);
}
}
/* Vertex Weight Layer */
@@ -264,7 +264,7 @@ void DPAINT_OT_output_toggle(wmOperatorType *ot)
static const EnumPropertyItem prop_output_toggle_types[] = {
{0, "A", 0, "Output A", ""},
{1, "B", 0, "Output B", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
@@ -285,7 +285,7 @@ void DPAINT_OT_output_toggle(wmOperatorType *ot)
/***************************** Image Sequence Baking ******************************/
typedef struct DynamicPaintBakeJob {
struct DynamicPaintBakeJob {
/* from wmJob */
void *owner;
bool *stop, *do_update;
@@ -301,17 +301,17 @@ typedef struct DynamicPaintBakeJob {
int success;
double start;
} DynamicPaintBakeJob;
};
static void dpaint_bake_free(void *customdata)
{
DynamicPaintBakeJob *job = customdata;
DynamicPaintBakeJob *job = static_cast<DynamicPaintBakeJob *>(customdata);
MEM_freeN(job);
}
static void dpaint_bake_endjob(void *customdata)
{
DynamicPaintBakeJob *job = customdata;
DynamicPaintBakeJob *job = static_cast<DynamicPaintBakeJob *>(customdata);
DynamicPaintCanvasSettings *canvas = job->canvas;
canvas->flags &= ~MOD_DPAINT_BAKING;
@@ -321,7 +321,7 @@ static void dpaint_bake_endjob(void *customdata)
G.is_rendering = false;
BKE_spacedata_draw_locks(false);
WM_set_locked_interface(G_MAIN->wm.first, false);
WM_set_locked_interface(static_cast<wmWindowManager *>(G_MAIN->wm.first), false);
/* Bake was successful:
* Report for ended bake and how long it took */
@@ -434,7 +434,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
static void dpaint_bake_startjob(void *customdata, bool *stop, bool *do_update, float *progress)
{
DynamicPaintBakeJob *job = customdata;
DynamicPaintBakeJob *job = static_cast<DynamicPaintBakeJob *>(customdata);
job->stop = stop;
job->do_update = do_update;
@@ -473,14 +473,14 @@ static int dynamicpaint_bake_exec(bContext *C, wmOperator *op)
*/
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)BKE_modifiers_findby_type(
object_eval, eModifierType_DynamicPaint);
if (pmd == NULL) {
if (pmd == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Bake failed: no Dynamic Paint modifier found");
return OPERATOR_CANCELLED;
}
/* Make sure we're dealing with a canvas */
DynamicPaintCanvasSettings *canvas = pmd->canvas;
if (canvas == NULL) {
if (canvas == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Bake failed: invalid canvas");
return OPERATOR_CANCELLED;
}
@@ -490,7 +490,8 @@ static int dynamicpaint_bake_exec(bContext *C, wmOperator *op)
canvas->error[0] = '\0';
canvas->flags |= MOD_DPAINT_BAKING;
DynamicPaintBakeJob *job = MEM_mallocN(sizeof(DynamicPaintBakeJob), "DynamicPaintBakeJob");
DynamicPaintBakeJob *job = static_cast<DynamicPaintBakeJob *>(
MEM_mallocN(sizeof(DynamicPaintBakeJob), "DynamicPaintBakeJob"));
job->bmain = CTX_data_main(C);
job->scene = scene_eval;
job->depsgraph = depsgraph;
@@ -507,7 +508,7 @@ static int dynamicpaint_bake_exec(bContext *C, wmOperator *op)
WM_jobs_customdata_set(wm_job, job, dpaint_bake_free);
WM_jobs_timer(wm_job, 0.1, NC_OBJECT | ND_MODIFIER, NC_OBJECT | ND_MODIFIER);
WM_jobs_callbacks(wm_job, dpaint_bake_startjob, NULL, NULL, dpaint_bake_endjob);
WM_jobs_callbacks(wm_job, dpaint_bake_startjob, nullptr, nullptr, dpaint_bake_endjob);
WM_set_locked_interface(CTX_wm_manager(C), true);

View File

@@ -36,7 +36,7 @@
static int rule_add_exec(bContext *C, wmOperator *op)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
ParticleSettings *part = ptr.data;
ParticleSettings *part = static_cast<ParticleSettings *>(ptr.data);
int type = RNA_enum_get(op->ptr, "type");
BoidRule *rule;
@@ -48,7 +48,7 @@ static int rule_add_exec(bContext *C, wmOperator *op)
state = boid_get_current_state(part->boids);
for (rule = state->rules.first; rule; rule = rule->next) {
for (rule = static_cast<BoidRule *>(state->rules.first); rule; rule = rule->next) {
rule->flag &= ~BOIDRULE_CURRENT;
}
@@ -78,11 +78,11 @@ void BOID_OT_rule_add(wmOperatorType *ot)
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_boidrule_type_items, 0, "Type", "");
}
static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
static int rule_del_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
ParticleSettings *part = ptr.data;
ParticleSettings *part = static_cast<ParticleSettings *>(ptr.data);
BoidRule *rule;
BoidState *state;
@@ -92,14 +92,14 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
state = boid_get_current_state(part->boids);
for (rule = state->rules.first; rule; rule = rule->next) {
for (rule = static_cast<BoidRule *>(state->rules.first); rule; rule = rule->next) {
if (rule->flag & BOIDRULE_CURRENT) {
BLI_remlink(&state->rules, rule);
MEM_freeN(rule);
break;
}
}
rule = state->rules.first;
rule = static_cast<BoidRule *>(state->rules.first);
if (rule) {
rule->flag |= BOIDRULE_CURRENT;
@@ -126,10 +126,10 @@ void BOID_OT_rule_del(wmOperatorType *ot)
}
/************************ move up/down boid rule operators *********************/
static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op))
static int rule_move_up_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
ParticleSettings *part = ptr.data;
ParticleSettings *part = static_cast<ParticleSettings *>(ptr.data);
BoidRule *rule;
BoidState *state;
@@ -138,7 +138,7 @@ static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op))
}
state = boid_get_current_state(part->boids);
for (rule = state->rules.first; rule; rule = rule->next) {
for (rule = static_cast<BoidRule *>(state->rules.first); rule; rule = rule->next) {
if (rule->flag & BOIDRULE_CURRENT && rule->prev) {
BLI_remlink(&state->rules, rule);
BLI_insertlinkbefore(&state->rules, rule->prev, rule);
@@ -163,10 +163,10 @@ void BOID_OT_rule_move_up(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op))
static int rule_move_down_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
ParticleSettings *part = ptr.data;
ParticleSettings *part = static_cast<ParticleSettings *>(ptr.data);
BoidRule *rule;
BoidState *state;
@@ -175,7 +175,7 @@ static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op))
}
state = boid_get_current_state(part->boids);
for (rule = state->rules.first; rule; rule = rule->next) {
for (rule = static_cast<BoidRule *>(state->rules.first); rule; rule = rule->next) {
if (rule->flag & BOIDRULE_CURRENT && rule->next) {
BLI_remlink(&state->rules, rule);
BLI_insertlinkafter(&state->rules, rule->next, rule);
@@ -201,17 +201,17 @@ void BOID_OT_rule_move_down(wmOperatorType *ot)
}
/************************ add/del boid state operators *********************/
static int state_add_exec(bContext *C, wmOperator *UNUSED(op))
static int state_add_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
ParticleSettings *part = ptr.data;
ParticleSettings *part = static_cast<ParticleSettings *>(ptr.data);
BoidState *state;
if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
}
for (state = part->boids->states.first; state; state = state->next) {
for (state = static_cast<BoidState *>(part->boids->states.first); state; state = state->next) {
state->flag &= ~BOIDSTATE_CURRENT;
}
@@ -236,18 +236,18 @@ void BOID_OT_state_add(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
static int state_del_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
ParticleSettings *part = ptr.data;
ParticleSettings *part = static_cast<ParticleSettings *>(ptr.data);
BoidState *state;
if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
}
for (state = part->boids->states.first; state; state = state->next) {
for (state = static_cast<BoidState *>(part->boids->states.first); state; state = state->next) {
if (state->flag & BOIDSTATE_CURRENT) {
BLI_remlink(&part->boids->states, state);
MEM_freeN(state);
@@ -261,7 +261,7 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
BLI_addtail(&part->boids->states, state);
}
else {
state = part->boids->states.first;
state = static_cast<BoidState *>(part->boids->states.first);
}
state->flag |= BOIDSTATE_CURRENT;
@@ -287,10 +287,10 @@ void BOID_OT_state_del(wmOperatorType *ot)
}
/************************ move up/down boid state operators *********************/
static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op))
static int state_move_up_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
ParticleSettings *part = ptr.data;
ParticleSettings *part = static_cast<ParticleSettings *>(ptr.data);
BoidSettings *boids;
BoidState *state;
@@ -300,7 +300,7 @@ static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op))
boids = part->boids;
for (state = boids->states.first; state; state = state->next) {
for (state = static_cast<BoidState *>(boids->states.first); state; state = state->next) {
if (state->flag & BOIDSTATE_CURRENT && state->prev) {
BLI_remlink(&boids->states, state);
BLI_insertlinkbefore(&boids->states, state->prev, state);
@@ -323,10 +323,10 @@ void BOID_OT_state_move_up(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op))
static int state_move_down_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
ParticleSettings *part = ptr.data;
ParticleSettings *part = static_cast<ParticleSettings *>(ptr.data);
BoidSettings *boids;
BoidState *state;
@@ -336,7 +336,7 @@ static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op))
boids = part->boids;
for (state = boids->states.first; state; state = state->next) {
for (state = static_cast<BoidState *>(boids->states.first); state; state = state->next) {
if (state->flag & BOIDSTATE_CURRENT && state->next) {
BLI_remlink(&boids->states, state);
BLI_insertlinkafter(&boids->states, state->next, state);

View File

@@ -90,10 +90,10 @@ bool PE_poll(bContext *C)
}
PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
if (edit == NULL) {
if (edit == nullptr) {
return false;
}
if (edit->psmd_eval == NULL || edit->psmd_eval->mesh_final == NULL) {
if (edit->psmd_eval == nullptr || edit->psmd_eval->mesh_final == nullptr) {
return false;
}
@@ -111,10 +111,10 @@ bool PE_hair_poll(bContext *C)
}
PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
if (edit == NULL || edit->psys == NULL) {
if (edit == nullptr || edit->psys == nullptr) {
return false;
}
if (edit->psmd_eval == NULL || edit->psmd_eval->mesh_final == NULL) {
if (edit->psmd_eval == nullptr || edit->psmd_eval->mesh_final == nullptr) {
return false;
}
@@ -174,7 +174,7 @@ int PE_minmax(
Object *ob = BKE_view_layer_active_object_get(view_layer);
PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
ParticleSystem *psys;
ParticleSystemModifierData *psmd_eval = NULL;
ParticleSystemModifierData *psmd_eval = nullptr;
POINT_P;
KEY_K;
float co[3], mat[4][4];
@@ -234,14 +234,14 @@ int PE_start_edit(PTCacheEdit *edit)
ParticleEditSettings *PE_settings(Scene *scene)
{
return scene->toolsettings ? &scene->toolsettings->particle : NULL;
return scene->toolsettings ? &scene->toolsettings->particle : nullptr;
}
static float pe_brush_size_get(const Scene *UNUSED(scene), ParticleBrushData *brush)
static float pe_brush_size_get(const Scene * /*scene*/, ParticleBrushData *brush)
{
#if 0 /* TODO: Here we can enable unified brush size, needs more work. */
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
float size = (ups->flag & UNIFIED_PAINT_SIZE) ? ups->size : brush->size;
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
float size = (ups->flag & UNIFIED_PAINT_SIZE) ? ups->size : brush->size;
#endif
return brush->size;
@@ -258,7 +258,7 @@ PTCacheEdit *PE_get_current_from_psys(ParticleSystem *psys)
if (psys->pointcache->flag & PTCACHE_BAKED) {
return psys->pointcache->edit;
}
return NULL;
return nullptr;
}
/* NOTE: Similar to creation of edit, but only updates pointers in the
@@ -293,22 +293,22 @@ static void pe_update_hair_particle_edit_pointers(PTCacheEdit *edit)
static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *ob, bool create)
{
ParticleEditSettings *pset = PE_settings(scene);
PTCacheEdit *edit = NULL;
PTCacheEdit *edit = nullptr;
ListBase pidlist;
PTCacheID *pid;
if (pset == NULL || ob == NULL) {
return NULL;
if (pset == nullptr || ob == nullptr) {
return nullptr;
}
pset->scene = scene;
pset->object = ob;
BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
BKE_ptcache_ids_from_object(&pidlist, ob, nullptr, 0);
/* in the case of only one editable thing, set pset->edittype accordingly */
if (BLI_listbase_is_single(&pidlist)) {
pid = pidlist.first;
pid = static_cast<PTCacheID *>(pidlist.first);
switch (pid->type) {
case PTCACHE_TYPE_PARTICLES:
pset->edittype = PE_TYPE_PARTICLES;
@@ -322,22 +322,22 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
}
}
for (pid = pidlist.first; pid; pid = pid->next) {
for (pid = static_cast<PTCacheID *>(pidlist.first); pid; pid = pid->next) {
if (pset->edittype == PE_TYPE_PARTICLES && pid->type == PTCACHE_TYPE_PARTICLES) {
ParticleSystem *psys = pid->calldata;
ParticleSystem *psys = static_cast<ParticleSystem *>(pid->calldata);
if (psys->flag & PSYS_CURRENT) {
if (psys->part && psys->part->type == PART_HAIR) {
if (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) {
if (create && !psys->pointcache->edit) {
PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL);
PE_create_particle_edit(depsgraph, scene, ob, pid->cache, nullptr);
}
edit = pid->cache->edit;
}
else {
if (create && !psys->edit) {
if (psys->flag & PSYS_HAIR_DONE) {
PE_create_particle_edit(depsgraph, scene, ob, NULL, psys);
PE_create_particle_edit(depsgraph, scene, ob, nullptr, psys);
}
}
edit = psys->edit;
@@ -357,7 +357,7 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) {
pset->flag |= PE_FADE_TIME;
/* Nice to have but doesn't work: `pset->brushtype = PE_BRUSH_COMB;`. */
PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL);
PE_create_particle_edit(depsgraph, scene, ob, pid->cache, nullptr);
}
edit = pid->cache->edit;
break;
@@ -366,7 +366,7 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) {
pset->flag |= PE_FADE_TIME;
/* Nice to have but doesn't work: `pset->brushtype = PE_BRUSH_COMB;`. */
PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL);
PE_create_particle_edit(depsgraph, scene, ob, pid->cache, nullptr);
}
edit = pid->cache->edit;
break;
@@ -379,7 +379,7 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
if (edit && DEG_is_active(depsgraph)) {
edit->pid = *pid;
if (edit->flags & PT_CACHE_EDIT_UPDATE_PARTICLE_FROM_EVAL) {
if (edit->psys != NULL && edit->psys_eval != NULL) {
if (edit->psys != nullptr && edit->psys_eval != nullptr) {
psys_copy_particles(edit->psys, edit->psys_eval);
pe_update_hair_particle_edit_pointers(edit);
}
@@ -452,7 +452,7 @@ static int pe_x_mirror(Object *ob)
/** \name Common Struct Passed to Callbacks
* \{ */
typedef struct PEData {
struct PEData {
ViewContext vc;
ViewDepths *depths;
@@ -493,7 +493,7 @@ typedef struct PEData {
bool is_changed;
void *user_data;
} PEData;
};
static void PE_set_data(bContext *C, PEData *data)
{
@@ -535,7 +535,7 @@ static bool PE_create_shape_tree(PEData *data, Object *shapeob)
return false;
}
return (BKE_bvhtree_from_mesh_get(&data->shape_bvh, mesh, BVHTREE_FROM_LOOPTRI, 4) != NULL);
return (BKE_bvhtree_from_mesh_get(&data->shape_bvh, mesh, BVHTREE_FROM_LOOPTRI, 4) != nullptr);
}
static void PE_free_shape_tree(PEData *data)
@@ -553,9 +553,9 @@ static void PE_create_random_generator(PEData *data)
static void PE_free_random_generator(PEData *data)
{
if (data->rng != NULL) {
if (data->rng != nullptr) {
BLI_rng_free(data->rng);
data->rng = NULL;
data->rng = nullptr;
}
}
@@ -565,7 +565,7 @@ static void PE_data_free(PEData *data)
PE_free_shape_tree(data);
if (data->depths) {
ED_view3d_depths_free(data->depths);
data->depths = NULL;
data->depths = nullptr;
}
}
@@ -586,15 +586,12 @@ static bool key_test_depth(const PEData *data, const float co[3], const int scre
return true;
}
/* used to calculate here but all callers have the screen_co already, so pass as arg */
/* used to calculate here but all callers have the screen_co already, so pass as arg */
#if 0
if (ED_view3d_project_int_global(data->vc.region,
co,
screen_co,
V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN |
V3D_PROJ_TEST_CLIP_NEAR) != V3D_PROJ_RET_OK) {
return 0;
}
if (ED_view3d_project_int_global(data->vc.region, co, screen_co, V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN |
V3D_PROJ_TEST_CLIP_NEAR) != V3D_PROJ_RET_OK) {
return 0;
}
#endif
/* check if screen_co is within bounds because brush_cut uses out of screen coords */
@@ -669,7 +666,7 @@ static bool key_inside_rect(PEData *data, const float co[3])
static bool key_inside_test(PEData *data, const float co[3])
{
if (data->mval) {
return key_inside_circle(data, data->rad, co, NULL);
return key_inside_circle(data, data->rad, co, nullptr);
}
return key_inside_rect(data, co);
}
@@ -824,16 +821,16 @@ static void foreach_mouse_hit_point(PEData *data, ForHitPointFunc func, int sele
}
}
typedef struct KeyIterData {
struct KeyIterData {
PEData *data;
PTCacheEdit *edit;
int selected;
ForHitKeyMatFunc func;
} KeyIterData;
};
static void foreach_mouse_hit_key_iter(void *__restrict iter_data_v,
const int iter,
const TaskParallelTLS *__restrict UNUSED(tls))
const TaskParallelTLS *__restrict /*tls*/)
{
KeyIterData *iter_data = (KeyIterData *)iter_data_v;
PEData *data = iter_data->data;
@@ -1007,7 +1004,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
/* lookup particles and set in mirror cache */
if (!edit->mirror_cache) {
edit->mirror_cache = MEM_callocN(sizeof(int) * totpart, "PE mirror cache");
edit->mirror_cache = static_cast<int *>(MEM_callocN(sizeof(int) * totpart, "PE mirror cache"));
}
LOOP_PARTICLES
@@ -1088,9 +1085,9 @@ static void PE_mirror_particle(
MEM_freeN(mpoint->keys);
}
mpa->hair = MEM_dupallocN(pa->hair);
mpa->hair = static_cast<HairKey *>(MEM_dupallocN(pa->hair));
mpa->totkey = pa->totkey;
mpoint->keys = MEM_dupallocN(point->keys);
mpoint->keys = static_cast<PTCacheEditKey *>(MEM_dupallocN(point->keys));
mpoint->totkey = point->totkey;
mhkey = mpa->hair;
@@ -1145,7 +1142,7 @@ static void PE_apply_mirror(Object *ob, ParticleSystem *psys)
edit = psys->edit;
psmd_eval = edit->psmd_eval;
if (psmd_eval == NULL || psmd_eval->mesh_final == NULL) {
if (psmd_eval == nullptr || psmd_eval->mesh_final == nullptr) {
return;
}
@@ -1161,7 +1158,7 @@ static void PE_apply_mirror(Object *ob, ParticleSystem *psys)
* to avoid doing mirror twice */
LOOP_POINTS {
if (point->flag & PEP_EDIT_RECALC) {
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, NULL);
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, nullptr);
if (edit->mirror_cache[p] != -1) {
edit->points[edit->mirror_cache[p]].flag &= ~PEP_EDIT_RECALC;
@@ -1184,17 +1181,17 @@ static void PE_apply_mirror(Object *ob, ParticleSystem *psys)
/** \name Edit Calculation
* \{ */
typedef struct DeflectEmitterIter {
struct DeflectEmitterIter {
Object *object;
ParticleSystem *psys;
PTCacheEdit *edit;
float dist;
float emitterdist;
} DeflectEmitterIter;
};
static void deflect_emitter_iter(void *__restrict iter_data_v,
const int iter,
const TaskParallelTLS *__restrict UNUSED(tls))
const TaskParallelTLS *__restrict /*tls*/)
{
DeflectEmitterIter *iter_data = (DeflectEmitterIter *)iter_data_v;
PTCacheEdit *edit = iter_data->edit;
@@ -1225,7 +1222,7 @@ static void deflect_emitter_iter(void *__restrict iter_data_v,
dist_1st *= dist * emitterdist;
}
else {
index = BLI_kdtree_3d_find_nearest(edit->emitter_field, key->co, NULL);
index = BLI_kdtree_3d_find_nearest(edit->emitter_field, key->co, nullptr);
vec = edit->emitter_cosnos + index * 6;
nor = vec + 3;
@@ -1267,7 +1264,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
ParticleSystem *psys;
const float dist = ED_view3d_select_dist_px() * 0.01f;
if (edit == NULL || edit->psys == NULL || (pset->flag & PE_DEFLECT_EMITTER) == 0 ||
if (edit == nullptr || edit->psys == nullptr || (pset->flag & PE_DEFLECT_EMITTER) == 0 ||
(edit->psys->flag & PSYS_GLOBAL_HAIR))
{
return;
@@ -1275,7 +1272,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
psys = edit->psys;
if (edit->psmd_eval == NULL || edit->psmd_eval->mesh_final == NULL) {
if (edit->psmd_eval == nullptr || edit->psmd_eval->mesh_final == nullptr) {
return;
}
@@ -1291,13 +1288,13 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
BLI_task_parallel_range(0, edit->totpoint, &iter_data, deflect_emitter_iter, &settings);
}
typedef struct ApplyLengthsIterData {
struct ApplyLengthsIterData {
PTCacheEdit *edit;
} ApplyLengthsIterData;
};
static void apply_lengths_iter(void *__restrict iter_data_v,
const int iter,
const TaskParallelTLS *__restrict UNUSED(tls))
const TaskParallelTLS *__restrict /*tls*/)
{
ApplyLengthsIterData *iter_data = (ApplyLengthsIterData *)iter_data_v;
PTCacheEdit *edit = iter_data->edit;
@@ -1339,14 +1336,14 @@ static void PE_apply_lengths(Scene *scene, PTCacheEdit *edit)
BLI_task_parallel_range(0, edit->totpoint, &iter_data, apply_lengths_iter, &settings);
}
typedef struct IterateLengthsIterData {
struct IterateLengthsIterData {
PTCacheEdit *edit;
ParticleEditSettings *pset;
} IterateLengthsIterData;
};
static void iterate_lengths_iter(void *__restrict iter_data_v,
const int iter,
const TaskParallelTLS *__restrict UNUSED(tls))
const TaskParallelTLS *__restrict /*tls*/)
{
IterateLengthsIterData *iter_data = (IterateLengthsIterData *)iter_data_v;
PTCacheEdit *edit = iter_data->edit;
@@ -1430,7 +1427,7 @@ void recalc_lengths(PTCacheEdit *edit)
}
}
void recalc_emitter_field(Depsgraph *UNUSED(depsgraph), Object *UNUSED(ob), ParticleSystem *psys)
void recalc_emitter_field(Depsgraph * /*depsgraph*/, Object * /*ob*/, ParticleSystem *psys)
{
PTCacheEdit *edit = psys->edit;
Mesh *mesh = edit->psmd_eval->mesh_final;
@@ -1450,7 +1447,8 @@ void recalc_emitter_field(Depsgraph *UNUSED(depsgraph), Object *UNUSED(ob), Part
totface = mesh->totface;
// int totvert = dm->getNumVerts(dm); /* UNUSED */
edit->emitter_cosnos = MEM_callocN(sizeof(float[6]) * totface, "emitter cosnos");
edit->emitter_cosnos = static_cast<float *>(
MEM_callocN(sizeof(float[6]) * totface, "emitter cosnos"));
edit->emitter_field = BLI_kdtree_3d_new(totface);
@@ -1534,7 +1532,7 @@ void update_world_cos(Object *ob, PTCacheEdit *edit)
KEY_K;
float hairmat[4][4];
if (psys == 0 || psys->edit == 0 || psmd_eval == NULL || psmd_eval->mesh_final == NULL) {
if (psys == 0 || psys->edit == 0 || psmd_eval == nullptr || psmd_eval->mesh_final == nullptr) {
return;
}
@@ -1675,7 +1673,7 @@ void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int usefla
/*-----selection callbacks-----*/
static void select_key(PEData *data, int point_index, int key_index, bool UNUSED(is_inside))
static void select_key(PEData *data, int point_index, int key_index, bool /*is_inside*/)
{
PTCacheEdit *edit = data->edit;
PTCacheEditPoint *point = edit->points + point_index;
@@ -1706,10 +1704,7 @@ static void select_key_op(PEData *data, int point_index, int key_index, bool is_
}
}
static void select_keys(PEData *data,
int point_index,
int UNUSED(key_index),
bool UNUSED(is_inside))
static void select_keys(PEData *data, int point_index, int /*key_index*/, bool /*is_inside*/)
{
PTCacheEdit *edit = data->edit;
PTCacheEditPoint *point = edit->points + point_index;
@@ -1833,13 +1828,13 @@ struct NearestParticleData {
PTCacheEditKey *key;
};
static void nearest_key_fn(PEData *data, int point_index, int key_index, bool UNUSED(is_inside))
static void nearest_key_fn(PEData *data, int point_index, int key_index, bool /*is_inside*/)
{
PTCacheEdit *edit = data->edit;
PTCacheEditPoint *point = edit->points + point_index;
PTCacheEditKey *key = point->keys + key_index;
struct NearestParticleData *user_data = data->user_data;
struct NearestParticleData *user_data = static_cast<NearestParticleData *>(data->user_data);
user_data->point = point;
user_data->key = key;
data->is_changed = true;
@@ -1850,7 +1845,7 @@ static bool pe_nearest_point_and_key(bContext *C,
PTCacheEditPoint **r_point,
PTCacheEditKey **r_key)
{
struct NearestParticleData user_data = {NULL};
struct NearestParticleData user_data = {nullptr};
PEData data;
PE_set_view3d_data(C, &data);
@@ -2095,7 +2090,7 @@ enum { RAN_HAIR, RAN_POINTS };
static const EnumPropertyItem select_random_type_items[] = {
{RAN_HAIR, "HAIR", 0, "Hair", ""},
{RAN_POINTS, "POINTS", 0, "Points", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static int select_random_exec(bContext *C, wmOperator *op)
@@ -2181,7 +2176,7 @@ void PARTICLE_OT_select_random(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*/)
{
PEData data;
PE_set_data(C, &data);
@@ -2259,7 +2254,7 @@ void PARTICLE_OT_select_linked_pick(wmOperatorType *ot)
/* properties */
RNA_def_boolean(
ot->srna, "deselect", 0, "Deselect", "Deselect linked keys rather than selecting them");
RNA_def_int_vector(ot->srna, "location", 2, NULL, 0, INT_MAX, "Location", "", 0, 16384);
RNA_def_int_vector(ot->srna, "location", 2, nullptr, 0, INT_MAX, "Location", "", 0, 16384);
}
/** \} */
@@ -2312,7 +2307,7 @@ bool PE_box_select(bContext *C, const rcti *rect, const int sel_op)
PE_set_view3d_data(C, &data);
data.rect = rect;
data.sel_op = sel_op;
data.sel_op = eSelectOp(sel_op);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
data.is_changed = PE_deselect_all_visible_ex(edit);
@@ -2343,13 +2338,13 @@ bool PE_box_select(bContext *C, const rcti *rect, const int sel_op)
static void pe_select_cache_free_generic_userdata(void *data)
{
PE_data_free(data);
PE_data_free(static_cast<PEData *>(data));
MEM_freeN(data);
}
static void pe_select_cache_init_with_generic_userdata(bContext *C, wmGenericUserData *wm_userdata)
{
PEData *data = MEM_callocN(sizeof(*data), __func__);
PEData *data = static_cast<PEData *>(MEM_callocN(sizeof(*data), __func__));
wm_userdata->data = data;
wm_userdata->free_fn = pe_select_cache_free_generic_userdata;
wm_userdata->use_free = true;
@@ -2369,11 +2364,11 @@ bool PE_circle_select(
return false;
}
if (wm_userdata->data == NULL) {
if (wm_userdata->data == nullptr) {
pe_select_cache_init_with_generic_userdata(C, wm_userdata);
}
PEData *data = wm_userdata->data;
PEData *data = static_cast<PEData *>(wm_userdata->data);
data->mval = mval;
data->rad = rad;
data->select = (sel_op != SEL_OP_SUB);
@@ -2381,7 +2376,7 @@ bool PE_circle_select(
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
data->is_changed = PE_deselect_all_visible_ex(edit);
}
for_mouse_hit_keys(data, select_key, 0);
for_mouse_hit_keys(data, select_key, eParticleSelectFlag(0));
if (data->is_changed) {
PE_update_selection(depsgraph, scene, ob, 1);
@@ -2443,7 +2438,8 @@ int PE_lasso_select(bContext *C, const int mcoords[][2], const int mcoords_len,
BLI_lasso_is_point_inside(
mcoords, mcoords_len, screen_co[0], screen_co[1], IS_CLIPPED) &&
key_test_depth(&data, co, screen_co));
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
const int sel_op_result = ED_select_op_action_deselected(
eSelectOp(sel_op), is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(key->flag, sel_op_result, PEK_SELECT);
point->flag |= PEP_EDIT_RECALC;
@@ -2463,7 +2459,8 @@ int PE_lasso_select(bContext *C, const int mcoords[][2], const int mcoords_len,
BLI_lasso_is_point_inside(
mcoords, mcoords_len, screen_co[0], screen_co[1], IS_CLIPPED) &&
key_test_depth(&data, co, screen_co));
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
const int sel_op_result = ED_select_op_action_deselected(
eSelectOp(sel_op), is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(key->flag, sel_op_result, PEK_SELECT);
point->flag |= PEP_EDIT_RECALC;
@@ -2635,7 +2632,7 @@ static void select_less_keys(PEData *data, int point_index)
}
}
static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
static int select_less_exec(bContext *C, wmOperator * /*op*/)
{
PEData data;
@@ -2707,7 +2704,7 @@ static void select_more_keys(PEData *data, int point_index)
}
}
static int select_more_exec(bContext *C, wmOperator *UNUSED(op))
static int select_more_exec(bContext *C, wmOperator * /*op*/)
{
PEData data;
@@ -2761,7 +2758,8 @@ static void rekey_particle(PEData *data, int pa_index)
pa->flag |= PARS_REKEY;
key = new_keys = MEM_callocN(data->totrekey * sizeof(HairKey), "Hair re-key keys");
key = new_keys = static_cast<HairKey *>(
MEM_callocN(data->totrekey * sizeof(HairKey), "Hair re-key keys"));
okey = pa->hair;
/* root and tip stay the same */
@@ -2791,7 +2789,8 @@ static void rekey_particle(PEData *data, int pa_index)
if (point->keys) {
MEM_freeN(point->keys);
}
ekey = point->keys = MEM_callocN(pa->totkey * sizeof(PTCacheEditKey), "Hair re-key edit keys");
ekey = point->keys = static_cast<PTCacheEditKey *>(
MEM_callocN(pa->totkey * sizeof(PTCacheEditKey), "Hair re-key edit keys"));
for (k = 0, key = pa->hair; k < pa->totkey; k++, key++, ekey++) {
ekey->co = key->co;
@@ -2871,7 +2870,7 @@ static void rekey_particle_to_time(
pa->flag |= PARS_REKEY;
key = new_keys = MEM_dupallocN(pa->hair);
key = new_keys = static_cast<HairKey *>(MEM_dupallocN(pa->hair));
/* interpolate new keys from old ones (roots stay the same) */
for (k = 1, key++; k < pa->totkey; k++, key++) {
@@ -2916,7 +2915,7 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror)
psmd_eval = edit->psmd_eval;
LOOP_TAGGED_POINTS {
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, NULL);
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, nullptr);
}
}
@@ -2927,11 +2926,12 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror)
if (new_totpart != psys->totpart) {
if (new_totpart) {
npa = new_pars = MEM_callocN(new_totpart * sizeof(ParticleData), "ParticleData array");
npoint = new_points = MEM_callocN(new_totpart * sizeof(PTCacheEditPoint),
"PTCacheEditKey array");
npa = new_pars = static_cast<ParticleData *>(
MEM_callocN(new_totpart * sizeof(ParticleData), "ParticleData array"));
npoint = new_points = static_cast<PTCacheEditPoint *>(
MEM_callocN(new_totpart * sizeof(PTCacheEditPoint), "PTCacheEditKey array"));
if (ELEM(NULL, new_pars, new_points)) {
if (ELEM(nullptr, new_pars, new_points)) {
/* allocation error! */
if (new_pars) {
MEM_freeN(new_pars);
@@ -2976,7 +2976,7 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror)
if (psys->child) {
MEM_freeN(psys->child);
psys->child = NULL;
psys->child = nullptr;
psys->totchild = 0;
}
@@ -3004,7 +3004,7 @@ static void remove_tagged_keys(Depsgraph *depsgraph, Object *ob, ParticleSystem
LOOP_POINTS {
LOOP_TAGGED_KEYS {
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, NULL);
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, nullptr);
break;
}
}
@@ -3031,8 +3031,10 @@ static void remove_tagged_keys(Depsgraph *depsgraph, Object *ob, ParticleSystem
}
if (new_totkey != pa->totkey) {
nhkey = new_hkeys = MEM_callocN(new_totkey * sizeof(HairKey), "HairKeys");
nkey = new_keys = MEM_callocN(new_totkey * sizeof(PTCacheEditKey), "particle edit keys");
nhkey = new_hkeys = static_cast<HairKey *>(
MEM_callocN(new_totkey * sizeof(HairKey), "HairKeys"));
nkey = new_keys = static_cast<PTCacheEditKey *>(
MEM_callocN(new_totkey * sizeof(PTCacheEditKey), "particle edit keys"));
hkey = pa->hair;
LOOP_KEYS {
@@ -3118,9 +3120,10 @@ static void subdivide_particle(PEData *data, int pa_index)
pa->flag |= PARS_REKEY;
nkey = new_keys = MEM_callocN((pa->totkey + totnewkey) * sizeof(HairKey), "Hair subdivide keys");
nekey = new_ekeys = MEM_callocN((pa->totkey + totnewkey) * sizeof(PTCacheEditKey),
"Hair subdivide edit keys");
nkey = new_keys = static_cast<HairKey *>(
MEM_callocN((pa->totkey + totnewkey) * sizeof(HairKey), "Hair subdivide keys"));
nekey = new_ekeys = static_cast<PTCacheEditKey *>(
MEM_callocN((pa->totkey + totnewkey) * sizeof(PTCacheEditKey), "Hair subdivide edit keys"));
key = pa->hair;
endtime = key[pa->totkey - 1].time;
@@ -3175,7 +3178,7 @@ static void subdivide_particle(PEData *data, int pa_index)
pa->flag &= ~PARS_REKEY;
}
static int subdivide_exec(bContext *C, wmOperator *UNUSED(op))
static int subdivide_exec(bContext *C, wmOperator * /*op*/)
{
PEData data;
@@ -3379,7 +3382,7 @@ void PARTICLE_OT_weight_set(wmOperatorType *ot)
/** \name Cursor Drawing
* \{ */
static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata))
static void brush_drawcursor(bContext *C, int x, int y, void * /*customdata*/)
{
Scene *scene = CTX_data_scene(C);
ParticleEditSettings *pset = PE_settings(scene);
@@ -3414,12 +3417,12 @@ static void toggle_particle_cursor(Scene *scene, bool enable)
ParticleEditSettings *pset = PE_settings(scene);
if (pset->paintcursor && !enable) {
WM_paint_cursor_end(pset->paintcursor);
pset->paintcursor = NULL;
WM_paint_cursor_end(static_cast<wmPaintCursor *>(pset->paintcursor));
pset->paintcursor = nullptr;
}
else if (enable) {
pset->paintcursor = WM_paint_cursor_activate(
SPACE_VIEW3D, RGN_TYPE_WINDOW, PE_poll_view3d, brush_drawcursor, NULL);
SPACE_VIEW3D, RGN_TYPE_WINDOW, PE_poll_view3d, brush_drawcursor, nullptr);
}
}
@@ -3434,7 +3437,7 @@ enum { DEL_PARTICLE, DEL_KEY };
static const EnumPropertyItem delete_type_items[] = {
{DEL_PARTICLE, "PARTICLE", 0, "Particle", ""},
{DEL_KEY, "KEY", 0, "Key", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static void set_delete_particle(PEData *data, int pa_index)
@@ -3444,10 +3447,7 @@ static void set_delete_particle(PEData *data, int pa_index)
edit->points[pa_index].flag |= PEP_TAG;
}
static void set_delete_particle_key(PEData *data,
int pa_index,
int key_index,
bool UNUSED(is_inside))
static void set_delete_particle_key(PEData *data, int pa_index, int key_index, bool /*is_inside*/)
{
PTCacheEdit *edit = data->edit;
@@ -3520,7 +3520,7 @@ static void PE_mirror_x(Depsgraph *depsgraph, Scene *scene, Object *ob, int tagg
POINT_P;
KEY_K;
HairKey *hkey;
int *mirrorfaces = NULL;
int *mirrorfaces = nullptr;
int rotation, totpart, newtotpart;
if (psys->flag & PSYS_GLOBAL_HAIR) {
@@ -3541,7 +3541,7 @@ static void PE_mirror_x(Depsgraph *depsgraph, Scene *scene, Object *ob, int tagg
/* NOTE: In case psys uses Mesh tessface indices, we mirror final Mesh itself, not orig mesh.
* Avoids an (impossible) mesh -> orig -> mesh tessface indices conversion. */
mirrorfaces = mesh_get_x_mirror_faces(
ob, NULL, use_dm_final_indices ? psmd_eval->mesh_final : NULL);
ob, nullptr, use_dm_final_indices ? psmd_eval->mesh_final : nullptr);
if (!edit->mirror_cache) {
PE_update_mirror_cache(ob, psys);
@@ -3556,7 +3556,7 @@ static void PE_mirror_x(Depsgraph *depsgraph, Scene *scene, Object *ob, int tagg
if (point_is_selected(point)) {
if (edit->mirror_cache[p] != -1) {
/* already has a mirror, don't need to duplicate */
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, pa, NULL);
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, pa, nullptr);
continue;
}
point->flag |= PEP_TAG;
@@ -3575,8 +3575,10 @@ static void PE_mirror_x(Depsgraph *depsgraph, Scene *scene, Object *ob, int tagg
(const MFace *)CustomData_get_layer(&me->fdata, CD_MFACE);
/* allocate new arrays and copy existing */
new_pars = MEM_callocN(newtotpart * sizeof(ParticleData), "ParticleData new");
new_points = MEM_callocN(newtotpart * sizeof(PTCacheEditPoint), "PTCacheEditPoint new");
new_pars = static_cast<ParticleData *>(
MEM_callocN(newtotpart * sizeof(ParticleData), "ParticleData new"));
new_points = static_cast<PTCacheEditPoint *>(
MEM_callocN(newtotpart * sizeof(PTCacheEditPoint), "PTCacheEditPoint new"));
if (psys->particles) {
memcpy(new_pars, psys->particles, totpart * sizeof(ParticleData));
@@ -3614,10 +3616,10 @@ static void PE_mirror_x(Depsgraph *depsgraph, Scene *scene, Object *ob, int tagg
*newpa = *pa;
*newpoint = *point;
if (pa->hair) {
newpa->hair = MEM_dupallocN(pa->hair);
newpa->hair = static_cast<HairKey *>(MEM_dupallocN(pa->hair));
}
if (point->keys) {
newpoint->keys = MEM_dupallocN(point->keys);
newpoint->keys = static_cast<PTCacheEditKey *>(MEM_dupallocN(point->keys));
}
/* rotate weights according to vertex index rotation */
@@ -3645,7 +3647,7 @@ static void PE_mirror_x(Depsgraph *depsgraph, Scene *scene, Object *ob, int tagg
}
else {
newpa->num_dmcache = psys_particle_dm_face_lookup(
psmd_eval->mesh_final, psmd_eval->mesh_original, newpa->num, newpa->fuv, NULL);
psmd_eval->mesh_final, psmd_eval->mesh_original, newpa->num, newpa->fuv, nullptr);
}
/* update edit key pointers */
@@ -3670,7 +3672,7 @@ static void PE_mirror_x(Depsgraph *depsgraph, Scene *scene, Object *ob, int tagg
MEM_freeN(mirrorfaces);
}
static int mirror_exec(bContext *C, wmOperator *UNUSED(op))
static int mirror_exec(bContext *C, wmOperator * /*op*/)
{
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Scene *scene = CTX_data_scene(C);
@@ -3680,7 +3682,7 @@ static int mirror_exec(bContext *C, wmOperator *UNUSED(op))
PE_mirror_x(depsgraph, scene, ob, 0);
update_world_cos(ob, edit);
psys_free_path_cache(NULL, edit);
psys_free_path_cache(nullptr, edit);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob);
BKE_particle_batch_cache_dirty_tag(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
@@ -3726,7 +3728,7 @@ void PARTICLE_OT_mirror(wmOperatorType *ot)
* \{ */
static void brush_comb(PEData *data,
float UNUSED(mat[4][4]),
float[4][4] /*mat*/,
float imat[4][4],
int point_index,
int key_index,
@@ -3762,7 +3764,7 @@ static void brush_cut(PEData *data, int pa_index)
int k, cut, keys = (int)pow(2.0, (double)pset->draw_step);
int screen_co[2];
BLI_assert(data->rng != NULL);
BLI_assert(data->rng != nullptr);
/* blunt scissors */
if (BLI_rng_get_float(data->rng) > data->cutfac) {
return;
@@ -3858,7 +3860,7 @@ static void brush_cut(PEData *data, int pa_index)
}
}
static void brush_length(PEData *data, int point_index, float UNUSED(mouse_distance))
static void brush_length(PEData *data, int point_index, float /*mouse_distance*/)
{
PTCacheEdit *edit = data->edit;
PTCacheEditPoint *point = edit->points + point_index;
@@ -3926,7 +3928,7 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
* `ob->world_to_object` is set before calling. */
mul_v3_m4v3(kco, data->ob->world_to_object, co);
point_index = BLI_kdtree_3d_find_nearest(edit->emitter_field, kco, NULL);
point_index = BLI_kdtree_3d_find_nearest(edit->emitter_field, kco, nullptr);
if (point_index == -1) {
return;
}
@@ -3984,27 +3986,57 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
if (puff_volume) {
#if 0
/* this is simple but looks bad, adds annoying kinks */
add_v3_v3(key->co, ofs);
/* this is simple but looks bad, adds annoying kinks */
add_v3_v3(key->co, ofs);
#else
/* Translate (not rotate) the rest of the hair if its not selected. */
{
/* NOLINTNEXTLINE: readability-redundant-preprocessor */
# if 0 /* Kind of works but looks worse than what's below. */
/* Move the unselected point on a vector based on the
* hair direction and the offset */
float c1[3], c2[3];
sub_v3_v3v3(dco, lastco, co);
mul_mat3_m4_v3(imat, dco); /* into particle space */
/* move the point along a vector perpendicular to the
* hairs direction, reduces odd kinks, */
cross_v3_v3v3(c1, ofs, dco);
cross_v3_v3v3(c2, c1, dco);
normalize_v3(c2);
mul_v3_fl(c2, len_v3(ofs));
add_v3_v3(key->co, c2);
/* Move the unselected point on a vector based on the
* hair direction and the offset */
float c1[3], c2[3];
sub_v3_v3v3(dco, lastco, co);
mul_mat3_m4_v3(imat, dco); /* into particle space */
/* move the point along a vector perpendicular to the
* hairs direction, reduces odd kinks, */
cross_v3_v3v3(c1, ofs, dco);
cross_v3_v3v3(c2, c1, dco);
normalize_v3(c2);
mul_v3_fl(c2, len_v3(ofs));
add_v3_v3(key->co, c2);
# else
/* Move the unselected point on a vector based on the
* the normal of the closest geometry */
@@ -4016,7 +4048,7 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
* `ob->world_to_object` is set before calling. */
mul_v3_m4v3(kco, data->ob->world_to_object, oco);
point_index = BLI_kdtree_3d_find_nearest(edit->emitter_field, kco, NULL);
point_index = BLI_kdtree_3d_find_nearest(edit->emitter_field, kco, nullptr);
if (point_index != -1) {
copy_v3_v3(onor, &edit->emitter_cosnos[point_index * 6 + 3]);
mul_mat3_m4_v3(data->ob->object_to_world, onor); /* Normal into world-space. */
@@ -4048,12 +4080,12 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
}
static void BKE_brush_weight_get(PEData *data,
float UNUSED(mat[4][4]),
float UNUSED(imat[4][4]),
float[4][4] /*mat*/,
float[4][4] /*imat*/,
int point_index,
int key_index,
PTCacheEditKey *UNUSED(key),
float UNUSED(mouse_distance))
PTCacheEditKey * /*key*/,
float /*mouse_distance*/)
{
/* roots have full weight always */
if (key_index) {
@@ -4069,11 +4101,11 @@ static void BKE_brush_weight_get(PEData *data,
static void brush_smooth_get(PEData *data,
float mat[4][4],
float UNUSED(imat[4][4]),
int UNUSED(point_index),
float[4][4] /*imat*/,
int /*point_index*/,
int key_index,
PTCacheEditKey *key,
float UNUSED(mouse_distance))
float /*mouse_distance*/)
{
if (key_index) {
float dvec[3];
@@ -4086,12 +4118,12 @@ static void brush_smooth_get(PEData *data,
}
static void brush_smooth_do(PEData *data,
float UNUSED(mat[4][4]),
float[4][4] /*mat*/,
float imat[4][4],
int point_index,
int key_index,
PTCacheEditKey *key,
float UNUSED(mouse_distance))
float /*mouse_distance*/)
{
float vec[3], dvec[3];
@@ -4130,7 +4162,7 @@ static void intersect_dm_quad_weights(
/** Check intersection with an evaluated mesh. */
static int particle_intersect_mesh(Depsgraph *depsgraph,
Scene *UNUSED(scene),
Scene * /*scene*/,
Object *ob,
Mesh *mesh,
float *vert_cos,
@@ -4144,23 +4176,23 @@ static int particle_intersect_mesh(Depsgraph *depsgraph,
float radius,
float *ipoint)
{
const MFace *mface = NULL;
const MFace *mface = nullptr;
int i, totface, intersect = 0;
float cur_d, cur_uv[2], v1[3], v2[3], v3[3], v4[3], min[3], max[3], p_min[3], p_max[3];
float cur_ipoint[3];
if (mesh == NULL) {
if (mesh == nullptr) {
psys_disable_all(ob);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
mesh = (Mesh *)BKE_object_get_evaluated_mesh(ob_eval);
if (mesh == NULL) {
if (mesh == nullptr) {
return 0;
}
psys_enable_all(ob);
if (mesh == NULL) {
if (mesh == nullptr) {
return 0;
}
}
@@ -4275,7 +4307,7 @@ static int particle_intersect_mesh(Depsgraph *depsgraph,
return intersect;
}
typedef struct BrushAddCountIterData {
struct BrushAddCountIterData {
Depsgraph *depsgraph;
Scene *scene;
Object *object;
@@ -4285,12 +4317,12 @@ typedef struct BrushAddCountIterData {
short size;
float imat[4][4];
ParticleData *add_pars;
} BrushAddCountIterData;
};
typedef struct BrushAddCountIterTLSData {
struct BrushAddCountIterTLSData {
RNG *rng;
int num_added;
} BrushAddCountIterTLSData;
};
static void brush_add_count_iter(void *__restrict iter_data_v,
const int iter,
@@ -4303,7 +4335,7 @@ static void brush_add_count_iter(void *__restrict iter_data_v,
ParticleSystem *psys = edit->psys;
ParticleSystemModifierData *psmd_eval = edit->psmd_eval;
ParticleData *add_pars = iter_data->add_pars;
BrushAddCountIterTLSData *tls = tls_v->userdata_chunk;
BrushAddCountIterTLSData *tls = static_cast<BrushAddCountIterTLSData *>(tls_v->userdata_chunk);
const int number = iter_data->number;
const short size = iter_data->size;
const int size2 = size * size;
@@ -4311,7 +4343,7 @@ static void brush_add_count_iter(void *__restrict iter_data_v,
if (number > 1) {
dmx = size;
dmy = size;
if (tls->rng == NULL) {
if (tls->rng == nullptr) {
tls->rng = BLI_rng_new_srandom(psys->seed + data->mval[0] + data->mval[1] +
BLI_task_parallel_thread_id(tls_v));
}
@@ -4338,7 +4370,7 @@ static void brush_add_count_iter(void *__restrict iter_data_v,
float min_d = 2.0;
/* warning, returns the derived mesh face */
BLI_assert(iter_data->mesh != NULL);
BLI_assert(iter_data->mesh != nullptr);
if (particle_intersect_mesh(depsgraph,
iter_data->scene,
iter_data->object,
@@ -4366,7 +4398,7 @@ static void brush_add_count_iter(void *__restrict iter_data_v,
psmd_eval->mesh_original,
add_pars[iter].num,
add_pars[iter].fuv,
NULL);
nullptr);
}
else {
add_pars[iter].num = add_pars[iter].num_dmcache;
@@ -4377,7 +4409,7 @@ static void brush_add_count_iter(void *__restrict iter_data_v,
}
}
static void brush_add_count_iter_reduce(const void *__restrict UNUSED(userdata),
static void brush_add_count_iter_reduce(const void *__restrict /*userdata*/,
void *__restrict join_v,
void *__restrict chunk_v)
{
@@ -4386,11 +4418,11 @@ static void brush_add_count_iter_reduce(const void *__restrict UNUSED(userdata),
join->num_added += tls->num_added;
}
static void brush_add_count_iter_free(const void *__restrict UNUSED(userdata_v),
static void brush_add_count_iter_free(const void *__restrict /*userdata_v*/,
void *__restrict chunk_v)
{
BrushAddCountIterTLSData *tls = (BrushAddCountIterTLSData *)chunk_v;
if (tls->rng != NULL) {
if (tls->rng != nullptr) {
BLI_rng_free(tls->rng);
}
}
@@ -4419,7 +4451,8 @@ static int brush_add(const bContext *C, PEData *data, short number)
return 0;
}
add_pars = MEM_callocN(number * sizeof(ParticleData), "ParticleData add");
add_pars = static_cast<ParticleData *>(
MEM_callocN(number * sizeof(ParticleData), "ParticleData add"));
rng = BLI_rng_new_srandom(psys->seed + data->mval[0] + data->mval[1]);
@@ -4455,7 +4488,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
iter_data.add_pars = add_pars;
copy_m4_m4(iter_data.imat, imat);
BrushAddCountIterTLSData tls = {NULL};
BrushAddCountIterTLSData tls = {nullptr};
TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
@@ -4486,10 +4519,11 @@ static int brush_add(const bContext *C, PEData *data, short number)
int newtotpart = totpart + n;
float hairmat[4][4], cur_co[3];
KDTree_3d *tree = 0;
ParticleData *pa,
*new_pars = MEM_callocN(newtotpart * sizeof(ParticleData), "ParticleData new");
PTCacheEditPoint *point, *new_points = MEM_callocN(newtotpart * sizeof(PTCacheEditPoint),
"PTCacheEditPoint array new");
ParticleData *pa, *new_pars = static_cast<ParticleData *>(
MEM_callocN(newtotpart * sizeof(ParticleData), "ParticleData new"));
PTCacheEditPoint *point,
*new_points = static_cast<PTCacheEditPoint *>(
MEM_callocN(newtotpart * sizeof(PTCacheEditPoint), "PTCacheEditPoint array new"));
PTCacheEditKey *key;
HairKey *hkey;
@@ -4540,9 +4574,10 @@ static int brush_add(const bContext *C, PEData *data, short number)
for (i = totpart; i < newtotpart; i++, pa++, point++) {
memcpy(pa, add_pars + i - totpart, sizeof(ParticleData));
pa->hair = MEM_callocN(pset->totaddkey * sizeof(HairKey), "BakeKey key add");
key = point->keys = MEM_callocN(pset->totaddkey * sizeof(PTCacheEditKey),
"PTCacheEditKey add");
pa->hair = static_cast<HairKey *>(
MEM_callocN(pset->totaddkey * sizeof(HairKey), "BakeKey key add"));
key = point->keys = static_cast<PTCacheEditKey *>(
MEM_callocN(pset->totaddkey * sizeof(PTCacheEditKey), "PTCacheEditKey add"));
point->totkey = pa->totkey = pset->totaddkey;
for (k = 0, hkey = pa->hair; k < pa->totkey; k++, hkey++, key++) {
@@ -4674,7 +4709,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
/** \name Brush Edit Operator
* \{ */
typedef struct BrushEdit {
struct BrushEdit {
Scene *scene;
ViewLayer *view_layer;
Object *ob;
@@ -4686,7 +4721,7 @@ typedef struct BrushEdit {
/** Optional cached view settings to avoid setting on every mouse-move. */
PEData data;
} BrushEdit;
};
static int brush_edit_init(bContext *C, wmOperator *op)
{
@@ -4704,7 +4739,7 @@ static int brush_edit_init(bContext *C, wmOperator *op)
PE_minmax(depsgraph, scene, view_layer, min, max);
mid_v3_v3v3(min, min, max);
bedit = MEM_callocN(sizeof(BrushEdit), "BrushEdit");
bedit = static_cast<BrushEdit *>(MEM_callocN(sizeof(BrushEdit), "BrushEdit"));
bedit->first = 1;
op->customdata = bedit;
@@ -4713,7 +4748,7 @@ static int brush_edit_init(bContext *C, wmOperator *op)
bedit->ob = ob;
bedit->edit = edit;
bedit->zfac = ED_view3d_calc_zfac(region->regiondata, min);
bedit->zfac = ED_view3d_calc_zfac(static_cast<const RegionView3D *>(region->regiondata), min);
/* cache view depths and settings for re-use */
PE_set_view3d_data(C, &bedit->data);
@@ -4724,7 +4759,7 @@ static int brush_edit_init(bContext *C, wmOperator *op)
static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
{
BrushEdit *bedit = op->customdata;
BrushEdit *bedit = static_cast<BrushEdit *>(op->customdata);
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Scene *scene = bedit->scene;
Object *ob = bedit->ob;
@@ -4932,7 +4967,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
}
update_world_cos(ob, edit);
psys_free_path_cache(NULL, edit);
psys_free_path_cache(nullptr, edit);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
else {
@@ -4960,7 +4995,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
static void brush_edit_exit(wmOperator *op)
{
BrushEdit *bedit = op->customdata;
BrushEdit *bedit = static_cast<BrushEdit *>(op->customdata);
PE_data_free(&bedit->data);
MEM_freeN(bedit);
@@ -5031,7 +5066,7 @@ static int brush_edit_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
static void brush_edit_cancel(bContext *UNUSED(C), wmOperator *op)
static void brush_edit_cancel(bContext * /*C*/, wmOperator *op)
{
brush_edit_exit(op);
}
@@ -5084,17 +5119,17 @@ static bool shape_cut_poll(bContext *C)
return false;
}
typedef struct PointInsideBVH {
struct PointInsideBVH {
BVHTreeFromMesh bvhdata;
int num_hits;
} PointInsideBVH;
};
static void point_inside_bvh_cb(void *userdata,
int index,
const BVHTreeRay *ray,
BVHTreeRayHit *hit)
{
PointInsideBVH *data = userdata;
PointInsideBVH *data = static_cast<PointInsideBVH *>(userdata);
data->bvhdata.raycast_callback(&data->bvhdata, index, ray, hit);
@@ -5192,7 +5227,7 @@ static void shape_cut(PEData *data, int pa_index)
}
}
static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
static int shape_cut_exec(bContext *C, wmOperator * /*op*/)
{
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
@@ -5234,7 +5269,7 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
if (removed) {
update_world_cos(ob, edit);
psys_free_path_cache(NULL, edit);
psys_free_path_cache(nullptr, edit);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
else {
@@ -5285,15 +5320,15 @@ void PE_create_particle_edit(
{
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
PTCacheEdit *edit;
ParticleSystemModifierData *psmd = (psys) ? psys_get_modifier(ob, psys) : NULL;
ParticleSystemModifierData *psmd_eval = NULL;
ParticleSystemModifierData *psmd = (psys) ? psys_get_modifier(ob, psys) : nullptr;
ParticleSystemModifierData *psmd_eval = nullptr;
POINT_P;
KEY_K;
ParticleData *pa = NULL;
ParticleData *pa = nullptr;
HairKey *hkey;
int totpoint;
if (psmd != NULL) {
if (psmd != nullptr) {
psmd_eval = (ParticleSystemModifierData *)BKE_modifiers_findby_name(ob_eval,
psmd->modifier.name);
}
@@ -5307,14 +5342,14 @@ void PE_create_particle_edit(
return;
}
if (psys == NULL && (cache && BLI_listbase_is_empty(&cache->mem_cache))) {
if (psys == nullptr && (cache && BLI_listbase_is_empty(&cache->mem_cache))) {
return;
}
edit = (psys) ? psys->edit : cache->edit;
if (!edit) {
ParticleSystem *psys_eval = NULL;
ParticleSystem *psys_eval = nullptr;
if (psys) {
psys_eval = psys_eval_get(depsgraph, ob, psys);
psys_copy_particles(psys, psys_eval);
@@ -5322,8 +5357,9 @@ void PE_create_particle_edit(
totpoint = psys ? psys->totpart : (int)((PTCacheMem *)cache->mem_cache.first)->totpoint;
edit = MEM_callocN(sizeof(PTCacheEdit), "PE_create_particle_edit");
edit->points = MEM_callocN(totpoint * sizeof(PTCacheEditPoint), "PTCacheEditPoints");
edit = static_cast<PTCacheEdit *>(MEM_callocN(sizeof(PTCacheEdit), "PE_create_particle_edit"));
edit->points = static_cast<PTCacheEditPoint *>(
MEM_callocN(totpoint * sizeof(PTCacheEditPoint), "PTCacheEditPoints"));
edit->totpoint = totpoint;
if (psys && !cache) {
@@ -5335,13 +5371,14 @@ void PE_create_particle_edit(
psys->free_edit = PE_free_ptcache_edit;
edit->pathcache = NULL;
edit->pathcache = nullptr;
BLI_listbase_clear(&edit->pathcachebufs);
pa = psys->particles;
LOOP_POINTS {
point->totkey = pa->totkey;
point->keys = MEM_callocN(point->totkey * sizeof(PTCacheEditKey), "ParticleEditKeys");
point->keys = static_cast<PTCacheEditKey *>(
MEM_callocN(point->totkey * sizeof(PTCacheEditKey), "ParticleEditKeys"));
point->flag |= PEP_EDIT_RECALC;
hkey = pa->hair;
@@ -5366,13 +5403,13 @@ void PE_create_particle_edit(
cache->edit = edit;
cache->free_edit = PE_free_ptcache_edit;
edit->psys = NULL;
edit->psys = nullptr;
for (pm = cache->mem_cache.first; pm; pm = pm->next) {
for (pm = static_cast<PTCacheMem *>(cache->mem_cache.first); pm; pm = pm->next) {
totframe++;
}
for (pm = cache->mem_cache.first; pm; pm = pm->next) {
for (pm = static_cast<PTCacheMem *>(cache->mem_cache.first); pm; pm = pm->next) {
LOOP_POINTS {
void *cur[BPHYS_TOT_DATA];
if (BKE_ptcache_mem_pointers_seek(p, pm, cur) == 0) {
@@ -5380,16 +5417,17 @@ void PE_create_particle_edit(
}
if (!point->totkey) {
key = point->keys = MEM_callocN(totframe * sizeof(PTCacheEditKey), "ParticleEditKeys");
key = point->keys = static_cast<PTCacheEditKey *>(
MEM_callocN(totframe * sizeof(PTCacheEditKey), "ParticleEditKeys"));
point->flag |= PEP_EDIT_RECALC;
}
else {
key = point->keys + point->totkey;
}
key->co = cur[BPHYS_DATA_LOCATION];
key->vel = cur[BPHYS_DATA_VELOCITY];
key->rot = cur[BPHYS_DATA_ROTATION];
key->co = static_cast<float *>(cur[BPHYS_DATA_LOCATION]);
key->vel = static_cast<float *>(cur[BPHYS_DATA_VELOCITY]);
key->rot = static_cast<float *>(cur[BPHYS_DATA_ROTATION]);
key->ftime = (float)pm->frame;
key->time = &key->ftime;
BKE_ptcache_mem_pointers_incr(cur);
@@ -5397,7 +5435,7 @@ void PE_create_particle_edit(
point->totkey++;
}
}
psys = NULL;
psys = nullptr;
}
recalc_lengths(edit);
@@ -5413,7 +5451,7 @@ static bool particle_edit_toggle_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
if (ob == NULL || ob->type != OB_MESH) {
if (ob == nullptr || ob->type != OB_MESH) {
return false;
}
if (!ob->data || ID_IS_LINKED(ob->data) || ID_IS_OVERRIDE_LIBRARY(ob->data)) {
@@ -5425,12 +5463,15 @@ static bool particle_edit_toggle_poll(bContext *C)
static void free_all_psys_edit(Object *object)
{
for (ParticleSystem *psys = object->particlesystem.first; psys != NULL; psys = psys->next) {
if (psys->edit != NULL) {
BLI_assert(psys->free_edit != NULL);
for (ParticleSystem *psys = static_cast<ParticleSystem *>(object->particlesystem.first);
psys != nullptr;
psys = psys->next)
{
if (psys->edit != nullptr) {
BLI_assert(psys->free_edit != nullptr);
psys->free_edit(psys->edit);
psys->free_edit = NULL;
psys->edit = NULL;
psys->free_edit = nullptr;
psys->edit = nullptr;
}
}
}
@@ -5467,7 +5508,7 @@ void ED_object_particle_edit_mode_enter_ex(Depsgraph *depsgraph, Scene *scene, O
toggle_particle_cursor(scene, true);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_PARTICLE, NULL);
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_PARTICLE, nullptr);
}
void ED_object_particle_edit_mode_enter(bContext *C)
@@ -5485,7 +5526,7 @@ void ED_object_particle_edit_mode_exit_ex(Scene *scene, Object *ob)
free_all_psys_edit(ob);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_OBJECT, nullptr);
}
void ED_object_particle_edit_mode_exit(bContext *C)
@@ -5504,7 +5545,7 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
const bool is_mode_set = (ob->mode & mode_flag) != 0;
if (!is_mode_set) {
if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
if (!ED_object_mode_compat_set(C, ob, eObjectMode(mode_flag), op->reports)) {
return OPERATOR_CANCELLED;
}
}
@@ -5545,17 +5586,17 @@ void PARTICLE_OT_particle_edit_toggle(wmOperatorType *ot)
/** \name Set Editable Operator
* \{ */
static int clear_edited_exec(bContext *C, wmOperator *UNUSED(op))
static int clear_edited_exec(bContext *C, wmOperator * /*op*/)
{
Object *ob = CTX_data_active_object(C);
ParticleSystem *psys = psys_get_current(ob);
if (psys->edit) {
if (psys->edit->edited || 1) {
if (/*psys->edit->edited ||*/ 1) {
PE_free_ptcache_edit(psys->edit);
psys->edit = NULL;
psys->free_edit = NULL;
psys->edit = nullptr;
psys->free_edit = nullptr;
psys->recalc |= ID_RECALC_PSYS_RESET;
psys->flag &= ~PSYS_GLOBAL_HAIR;
@@ -5669,7 +5710,7 @@ static void scale_points_to_length(PTCacheEdit *edit, float length)
recalc_lengths(edit);
}
static int unify_length_exec(bContext *C, wmOperator *UNUSED(op))
static int unify_length_exec(bContext *C, wmOperator * /*op*/)
{
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);

View File

@@ -56,10 +56,10 @@ static void undoptcache_from_editcache(PTCacheUndo *undo, PTCacheEdit *edit)
if (edit->psys) {
ParticleData *pa;
pa = undo->particles = MEM_dupallocN(edit->psys->particles);
pa = undo->particles = static_cast<ParticleData *>(MEM_dupallocN(edit->psys->particles));
for (int i = 0; i < edit->totpoint; i++, pa++) {
pa->hair = MEM_dupallocN(pa->hair);
pa->hair = static_cast<HairKey *>(MEM_dupallocN(pa->hair));
}
undo->psys_flag = edit->psys->flag;
@@ -68,7 +68,7 @@ static void undoptcache_from_editcache(PTCacheUndo *undo, PTCacheEdit *edit)
PTCacheMem *pm;
BLI_duplicatelist(&undo->mem_cache, &edit->pid.cache->mem_cache);
pm = undo->mem_cache.first;
pm = static_cast<PTCacheMem *>(undo->mem_cache.first);
for (; pm; pm = pm->next) {
for (int i = 0; i < BPHYS_TOT_DATA; i++) {
@@ -77,11 +77,11 @@ static void undoptcache_from_editcache(PTCacheUndo *undo, PTCacheEdit *edit)
}
}
point = undo->points = MEM_dupallocN(edit->points);
point = undo->points = static_cast<PTCacheEditPoint *>(MEM_dupallocN(edit->points));
undo->totpoint = edit->totpoint;
for (int i = 0; i < edit->totpoint; i++, point++) {
point->keys = MEM_dupallocN(point->keys);
point->keys = static_cast<PTCacheEditKey *>(MEM_dupallocN(point->keys));
/* no need to update edit key->co & key->time pointers here */
}
@@ -116,21 +116,21 @@ static void undoptcache_to_editcache(PTCacheUndo *undo, PTCacheEdit *edit)
}
MEM_SAFE_FREE(edit->mirror_cache);
edit->points = MEM_dupallocN(undo->points);
edit->points = static_cast<PTCacheEditPoint *>(MEM_dupallocN(undo->points));
edit->totpoint = undo->totpoint;
LOOP_POINTS {
point->keys = MEM_dupallocN(point->keys);
point->keys = static_cast<PTCacheEditKey *>(MEM_dupallocN(point->keys));
}
if (psys) {
psys->particles = MEM_dupallocN(undo->particles);
psys->particles = static_cast<ParticleData *>(MEM_dupallocN(undo->particles));
psys->totpart = undo->totpoint;
LOOP_POINTS {
pa = psys->particles + p;
hkey = pa->hair = MEM_dupallocN(pa->hair);
hkey = pa->hair = static_cast<HairKey *>(MEM_dupallocN(pa->hair));
LOOP_KEYS {
key->co = hkey->co;
@@ -149,7 +149,7 @@ static void undoptcache_to_editcache(PTCacheUndo *undo, PTCacheEdit *edit)
BLI_duplicatelist(&edit->pid.cache->mem_cache, &undo->mem_cache);
pm = edit->pid.cache->mem_cache.first;
pm = static_cast<PTCacheMem *>(edit->pid.cache->mem_cache.first);
for (; pm; pm = pm->next) {
for (i = 0; i < BPHYS_TOT_DATA; i++) {
@@ -161,9 +161,9 @@ static void undoptcache_to_editcache(PTCacheUndo *undo, PTCacheEdit *edit)
LOOP_POINTS {
LOOP_KEYS {
if ((int)key->ftime == (int)pm->frame) {
key->co = cur[BPHYS_DATA_LOCATION];
key->vel = cur[BPHYS_DATA_VELOCITY];
key->rot = cur[BPHYS_DATA_ROTATION];
key->co = static_cast<float *>(cur[BPHYS_DATA_LOCATION]);
key->vel = static_cast<float *>(cur[BPHYS_DATA_VELOCITY]);
key->rot = static_cast<float *>(cur[BPHYS_DATA_ROTATION]);
key->time = &key->ftime;
}
}
@@ -201,12 +201,12 @@ static void undoptcache_free_data(PTCacheUndo *undo)
/** \name Implements ED Undo System
* \{ */
typedef struct ParticleUndoStep {
struct ParticleUndoStep {
UndoStep step;
UndoRefID_Scene scene_ref;
UndoRefID_Object object_ref;
PTCacheUndo data;
} ParticleUndoStep;
};
static bool particle_undosys_poll(bContext *C)
{
@@ -217,10 +217,10 @@ static bool particle_undosys_poll(bContext *C)
Object *ob = BKE_view_layer_active_object_get(view_layer);
PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
return (edit != NULL);
return (edit != nullptr);
}
static bool particle_undosys_step_encode(bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p)
static bool particle_undosys_step_encode(bContext *C, struct Main * /*bmain*/, UndoStep *us_p)
{
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
ParticleUndoStep *us = (ParticleUndoStep *)us_p;
@@ -234,10 +234,10 @@ static bool particle_undosys_step_encode(bContext *C, struct Main *UNUSED(bmain)
}
static void particle_undosys_step_decode(bContext *C,
struct Main *UNUSED(bmain),
struct Main * /*bmain*/,
UndoStep *us_p,
const eUndoStepDir UNUSED(dir),
bool UNUSED(is_final))
const eUndoStepDir /*dir*/,
bool /*is_final*/)
{
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
@@ -251,7 +251,7 @@ static void particle_undosys_step_decode(bContext *C,
/* While this shouldn't happen, entering particle edit-mode uses a more complex
* setup compared to most other modes which we can't ensure succeeds. */
if (UNLIKELY(edit == NULL)) {
if (UNLIKELY(edit == nullptr)) {
BLI_assert(0);
return;
}
@@ -259,7 +259,7 @@ static void particle_undosys_step_decode(bContext *C,
undoptcache_to_editcache(&us->data, edit);
ParticleEditSettings *pset = &scene->toolsettings->particle;
if ((pset->flag & PE_DRAW_PART) != 0) {
psys_free_path_cache(NULL, edit);
psys_free_path_cache(nullptr, edit);
BKE_particle_batch_cache_dirty_tag(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
}
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);

View File

@@ -66,7 +66,7 @@ static float I[4][4] = {
/********************** particle system slot operators *********************/
static int particle_system_add_exec(bContext *C, wmOperator *UNUSED(op))
static int particle_system_add_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
Object *ob = ED_object_context(C);
@@ -76,7 +76,7 @@ static int particle_system_add_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
object_add_particle_system(bmain, scene, ob, NULL);
object_add_particle_system(bmain, scene, ob, nullptr);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, ob);
WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, ob);
@@ -99,7 +99,7 @@ void OBJECT_OT_particle_system_add(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op))
static int particle_system_remove_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
Object *ob = ED_object_context(C);
@@ -122,7 +122,7 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op))
if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) {
BKE_view_layer_synced_ensure(scene, view_layer);
if (BKE_view_layer_active_object_get(view_layer) == ob) {
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, nullptr);
}
}
}
@@ -153,20 +153,20 @@ void OBJECT_OT_particle_system_remove(wmOperatorType *ot)
static bool psys_poll(bContext *C)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
return (ptr.data != NULL);
return (ptr.data != nullptr);
}
static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op))
static int new_particle_settings_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
ParticleSystem *psys;
ParticleSettings *part = NULL;
ParticleSettings *part = nullptr;
Object *ob;
PointerRNA ptr;
ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
psys = ptr.data;
psys = static_cast<ParticleSystem *>(ptr.data);
/* add or copy particle setting */
if (psys->part) {
@@ -211,11 +211,11 @@ void PARTICLE_OT_new(wmOperatorType *ot)
/********************** keyed particle target operators *********************/
static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
static int new_particle_target_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys = ptr.data;
ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
Object *ob = (Object *)ptr.owner_id;
ParticleTarget *pt;
@@ -224,12 +224,12 @@ static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
pt = psys->targets.first;
pt = static_cast<ParticleTarget *>(psys->targets.first);
for (; pt; pt = pt->next) {
pt->flag &= ~PTARGET_CURRENT;
}
pt = MEM_callocN(sizeof(ParticleTarget), "keyed particle target");
pt = static_cast<ParticleTarget *>(MEM_callocN(sizeof(ParticleTarget), "keyed particle target"));
pt->flag |= PTARGET_CURRENT;
pt->psys = 1;
@@ -258,11 +258,11 @@ void PARTICLE_OT_new_target(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
static int remove_particle_target_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys = ptr.data;
ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
Object *ob = (Object *)ptr.owner_id;
ParticleTarget *pt;
@@ -271,7 +271,7 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
pt = psys->targets.first;
pt = static_cast<ParticleTarget *>(psys->targets.first);
for (; pt; pt = pt->next) {
if (pt->flag & PTARGET_CURRENT) {
BLI_remlink(&psys->targets, pt);
@@ -279,7 +279,7 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
pt = psys->targets.last;
pt = static_cast<ParticleTarget *>(psys->targets.last);
if (pt) {
pt->flag |= PTARGET_CURRENT;
@@ -309,10 +309,10 @@ void PARTICLE_OT_target_remove(wmOperatorType *ot)
/************************ move up particle target operator *********************/
static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op))
static int target_move_up_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys = ptr.data;
ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
Object *ob = (Object *)ptr.owner_id;
ParticleTarget *pt;
@@ -320,7 +320,7 @@ static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
pt = psys->targets.first;
pt = static_cast<ParticleTarget *>(psys->targets.first);
for (; pt; pt = pt->next) {
if (pt->flag & PTARGET_CURRENT && pt->prev) {
BLI_remlink(&psys->targets, pt);
@@ -349,17 +349,17 @@ void PARTICLE_OT_target_move_up(wmOperatorType *ot)
/************************ move down particle target operator *********************/
static int target_move_down_exec(bContext *C, wmOperator *UNUSED(op))
static int target_move_down_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys = ptr.data;
ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
Object *ob = (Object *)ptr.owner_id;
ParticleTarget *pt;
if (!psys) {
return OPERATOR_CANCELLED;
}
pt = psys->targets.first;
pt = static_cast<ParticleTarget *>(psys->targets.first);
for (; pt; pt = pt->next) {
if (pt->flag & PTARGET_CURRENT && pt->next) {
BLI_remlink(&psys->targets, pt);
@@ -388,10 +388,10 @@ void PARTICLE_OT_target_move_down(wmOperatorType *ot)
/************************ refresh dupli objects *********************/
static int dupliob_refresh_exec(bContext *C, wmOperator *UNUSED(op))
static int dupliob_refresh_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys = ptr.data;
ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
if (!psys) {
return OPERATOR_CANCELLED;
@@ -399,7 +399,7 @@ static int dupliob_refresh_exec(bContext *C, wmOperator *UNUSED(op))
psys_check_group_weights(psys->part);
DEG_id_tag_update(&psys->part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, nullptr);
return OPERATOR_FINISHED;
}
@@ -418,10 +418,10 @@ void PARTICLE_OT_dupliob_refresh(wmOperatorType *ot)
/************************ move up particle dupli-weight operator *********************/
static int dupliob_move_up_exec(bContext *C, wmOperator *UNUSED(op))
static int dupliob_move_up_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys = ptr.data;
ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
ParticleSettings *part;
ParticleDupliWeight *dw;
@@ -430,13 +430,13 @@ static int dupliob_move_up_exec(bContext *C, wmOperator *UNUSED(op))
}
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
for (dw = static_cast<ParticleDupliWeight *>(part->instance_weights.first); dw; dw = dw->next) {
if (dw->flag & PART_DUPLIW_CURRENT && dw->prev) {
BLI_remlink(&part->instance_weights, dw);
BLI_insertlinkbefore(&part->instance_weights, dw->prev, dw);
DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, nullptr);
break;
}
}
@@ -458,10 +458,10 @@ void PARTICLE_OT_dupliob_move_up(wmOperatorType *ot)
/********************** particle dupliweight operators *********************/
static int copy_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
static int copy_particle_dupliob_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys = ptr.data;
ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
ParticleSettings *part;
ParticleDupliWeight *dw;
@@ -469,15 +469,15 @@ static int copy_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
for (dw = static_cast<ParticleDupliWeight *>(part->instance_weights.first); dw; dw = dw->next) {
if (dw->flag & PART_DUPLIW_CURRENT) {
dw->flag &= ~PART_DUPLIW_CURRENT;
dw = MEM_dupallocN(dw);
dw = static_cast<ParticleDupliWeight *>(MEM_dupallocN(dw));
dw->flag |= PART_DUPLIW_CURRENT;
BLI_addhead(&part->instance_weights, dw);
DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, nullptr);
break;
}
}
@@ -499,10 +499,10 @@ void PARTICLE_OT_dupliob_copy(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
static int remove_particle_dupliob_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys = ptr.data;
ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
ParticleSettings *part;
ParticleDupliWeight *dw;
@@ -511,21 +511,21 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
}
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
for (dw = static_cast<ParticleDupliWeight *>(part->instance_weights.first); dw; dw = dw->next) {
if (dw->flag & PART_DUPLIW_CURRENT) {
BLI_remlink(&part->instance_weights, dw);
MEM_freeN(dw);
break;
}
}
dw = part->instance_weights.last;
dw = static_cast<ParticleDupliWeight *>(part->instance_weights.last);
if (dw) {
dw->flag |= PART_DUPLIW_CURRENT;
}
DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, nullptr);
return OPERATOR_FINISHED;
}
@@ -546,10 +546,10 @@ void PARTICLE_OT_dupliob_remove(wmOperatorType *ot)
/************************ move down particle dupliweight operator *********************/
static int dupliob_move_down_exec(bContext *C, wmOperator *UNUSED(op))
static int dupliob_move_down_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys = ptr.data;
ParticleSystem *psys = static_cast<ParticleSystem *>(ptr.data);
ParticleSettings *part;
ParticleDupliWeight *dw;
@@ -558,13 +558,13 @@ static int dupliob_move_down_exec(bContext *C, wmOperator *UNUSED(op))
}
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
for (dw = static_cast<ParticleDupliWeight *>(part->instance_weights.first); dw; dw = dw->next) {
if (dw->flag & PART_DUPLIW_CURRENT && dw->next) {
BLI_remlink(&part->instance_weights, dw);
BLI_insertlinkafter(&part->instance_weights, dw->next, dw);
DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, nullptr);
break;
}
}
@@ -595,7 +595,7 @@ static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Part
ParticleData *pa;
PTCacheEdit *edit;
PTCacheEditPoint *point;
PTCacheEditKey *ekey = NULL;
PTCacheEditKey *ekey = nullptr;
HairKey *key;
int i, k;
float hairmat[4][4];
@@ -609,7 +609,7 @@ static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Part
}
edit = psys->edit;
point = edit ? edit->points : NULL;
point = edit ? edit->points : nullptr;
for (i = 0, pa = psys->particles; i < psys->totpart; i++, pa++) {
if (point) {
@@ -645,7 +645,7 @@ static int disconnect_hair_exec(bContext *C, wmOperator *op)
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_context(C);
ParticleSystem *psys = NULL;
ParticleSystem *psys = nullptr;
const bool all = RNA_boolean_get(op->ptr, "all");
if (!ob) {
@@ -653,7 +653,7 @@ static int disconnect_hair_exec(bContext *C, wmOperator *op)
}
if (all) {
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
for (psys = static_cast<ParticleSystem *>(ob->particlesystem.first); psys; psys = psys->next) {
disconnect_hair(depsgraph, scene, ob, psys);
}
}
@@ -705,9 +705,9 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
ParticleData *pa, *tpa;
PTCacheEditPoint *edit_point;
PTCacheEditKey *ekey;
BVHTreeFromMesh bvhtree = {NULL};
const MFace *mface = NULL, *mf;
const vec2i *edges = NULL, *edge;
BVHTreeFromMesh bvhtree = {nullptr};
const MFace *mface = nullptr, *mf;
const vec2i *edges = nullptr, *edge;
Mesh *mesh, *target_mesh;
int numverts;
int k;
@@ -724,7 +724,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
return false;
}
edit_point = target_edit ? target_edit->points : NULL;
edit_point = target_edit ? target_edit->points : nullptr;
invert_m4_m4(from_ob_imat, ob->object_to_world);
invert_m4_m4(to_ob_imat, target_ob->object_to_world);
@@ -741,12 +741,12 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
mesh = target_psmd->mesh_original;
}
target_mesh = target_psmd->mesh_final;
if (mesh == NULL) {
if (mesh == nullptr) {
return false;
}
/* don't modify the original vertices */
/* we don't want to mess up target_psmd->dm when converting to global coordinates below */
mesh = (Mesh *)BKE_id_copy_ex(NULL, &mesh->id, NULL, LIB_ID_COPY_LOCALIZE);
mesh = (Mesh *)BKE_id_copy_ex(nullptr, &mesh->id, nullptr, LIB_ID_COPY_LOCALIZE);
/* BMESH_ONLY, deform dm may not have tessface */
BKE_mesh_tessface_ensure(mesh);
@@ -760,15 +760,16 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
}
if (mesh->totface != 0) {
mface = CustomData_get_layer(&mesh->fdata, CD_MFACE);
mface = static_cast<const MFace *>(CustomData_get_layer(&mesh->fdata, CD_MFACE));
BKE_bvhtree_from_mesh_get(&bvhtree, mesh, BVHTREE_FROM_FACES, 2);
}
else if (mesh->totedge != 0) {
edges = CustomData_get_layer_named(&mesh->edata, CD_PROP_INT32_2D, ".edge_verts");
edges = static_cast<const vec2i *>(
CustomData_get_layer_named(&mesh->edata, CD_PROP_INT32_2D, ".edge_verts"));
BKE_bvhtree_from_mesh_get(&bvhtree, mesh, BVHTREE_FROM_EDGES, 2);
}
else {
BKE_id_free(NULL, mesh);
BKE_id_free(nullptr, mesh);
return false;
}
@@ -822,7 +823,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
}
else {
tpa->num_dmcache = psys_particle_dm_face_lookup(
target_psmd->mesh_final, target_psmd->mesh_original, tpa->num, tpa->fuv, NULL);
target_psmd->mesh_final, target_psmd->mesh_original, tpa->num, tpa->fuv, nullptr);
}
}
else {
@@ -901,7 +902,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
}
free_bvhtree_from_mesh(&bvhtree);
BKE_id_free(NULL, mesh);
BKE_id_free(nullptr, mesh);
psys_free_path_cache(target_psys, target_edit);
@@ -941,7 +942,7 @@ static int connect_hair_exec(bContext *C, wmOperator *op)
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_context(C);
ParticleSystem *psys = NULL;
ParticleSystem *psys = nullptr;
const bool all = RNA_boolean_get(op->ptr, "all");
bool any_connected = false;
@@ -950,7 +951,7 @@ static int connect_hair_exec(bContext *C, wmOperator *op)
}
if (all) {
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
for (psys = static_cast<ParticleSystem *>(ob->particlesystem.first); psys; psys = psys->next) {
any_connected |= connect_hair(depsgraph, scene, ob, psys);
}
}
@@ -1009,22 +1010,22 @@ static void copy_particle_edit(Depsgraph *depsgraph,
return;
}
edit = MEM_dupallocN(edit_from);
edit = static_cast<PTCacheEdit *>(MEM_dupallocN(edit_from));
edit->psys = psys;
psys->edit = edit;
edit->pathcache = NULL;
edit->pathcache = nullptr;
BLI_listbase_clear(&edit->pathcachebufs);
edit->emitter_field = NULL;
edit->emitter_cosnos = NULL;
edit->emitter_field = nullptr;
edit->emitter_cosnos = nullptr;
edit->points = MEM_dupallocN(edit_from->points);
edit->points = static_cast<PTCacheEditPoint *>(MEM_dupallocN(edit_from->points));
pa = psys->particles;
LOOP_POINTS {
HairKey *hkey = pa->hair;
point->keys = MEM_dupallocN(point->keys);
point->keys = static_cast<PTCacheEditKey *>(MEM_dupallocN(point->keys));
LOOP_KEYS {
key->co = hkey->co;
key->time = &hkey->time;
@@ -1057,7 +1058,7 @@ static void remove_particle_systems_from_object(Object *ob_to)
return;
}
for (md = ob_to->modifiers.first; md; md = md_next) {
for (md = static_cast<ModifierData *>(ob_to->modifiers.first); md; md = md_next) {
md_next = md->next;
/* remove all particle system modifiers as well,
@@ -1075,7 +1076,7 @@ static void remove_particle_systems_from_object(Object *ob_to)
BKE_object_free_particlesystems(ob_to);
}
/* single_psys_from is optional, if NULL all psys of ob_from are copied */
/* single_psys_from is optional, if nullptr all psys of ob_from are copied */
static bool copy_particle_systems_to_object(const bContext *C,
Scene *scene,
Object *ob_from,
@@ -1087,7 +1088,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ModifierData *md;
ParticleSystem *psys_start = NULL, *psys, *psys_from;
ParticleSystem *psys_start = nullptr, *psys, *psys_from;
ParticleSystem **tmp_psys;
CustomData_MeshMasks cdmask = {0};
int i, totpsys;
@@ -1095,7 +1096,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
if (ob_to->type != OB_MESH) {
return false;
}
if (!ob_to->data || !BKE_id_is_editable(bmain, ob_to->data)) {
if (!ob_to->data || !BKE_id_is_editable(bmain, static_cast<const ID *>(ob_to->data))) {
return false;
}
@@ -1109,17 +1110,20 @@ static bool copy_particle_systems_to_object(const bContext *C,
* (to collect required customdata masks),
* then create the DM, then add them to the object and make the psys modifiers.
*/
#define PSYS_FROM_FIRST (single_psys_from ? single_psys_from : ob_from->particlesystem.first)
#define PSYS_FROM_NEXT(cur) (single_psys_from ? NULL : (cur)->next)
#define PSYS_FROM_FIRST \
static_cast<ParticleSystem *>( \
(single_psys_from ? single_psys_from : ob_from->particlesystem.first))
#define PSYS_FROM_NEXT(cur) (single_psys_from ? nullptr : (cur)->next)
totpsys = single_psys_from ? 1 : BLI_listbase_count(&ob_from->particlesystem);
tmp_psys = MEM_mallocN(sizeof(ParticleSystem *) * totpsys, "temporary particle system array");
tmp_psys = static_cast<ParticleSystem **>(
MEM_mallocN(sizeof(ParticleSystem *) * totpsys, "temporary particle system array"));
for (psys_from = PSYS_FROM_FIRST, i = 0; psys_from; psys_from = PSYS_FROM_NEXT(psys_from), i++) {
psys = BKE_object_copy_particlesystem(psys_from, 0);
tmp_psys[i] = psys;
if (psys_start == NULL) {
if (psys_start == nullptr) {
psys_start = psys;
}
@@ -1128,7 +1132,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
/* to iterate source and target psys in sync,
* we need to know where the newly added psys start
*/
psys_start = totpsys > 0 ? tmp_psys[0] : NULL;
psys_start = totpsys > 0 ? tmp_psys[0] : nullptr;
/* now append psys to the object and make modifiers */
for (i = 0, psys_from = PSYS_FROM_FIRST; i < totpsys; ++i, psys_from = PSYS_FROM_NEXT(psys_from))
@@ -1182,7 +1186,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
break;
default:
/* should not happen */
from_mat = to_mat = NULL;
from_mat = to_mat = nullptr;
BLI_assert(false);
break;
}
@@ -1236,10 +1240,11 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *ob_from = ED_object_active_context(C);
ParticleSystem *psys_from = NULL;
ParticleSystem *psys_from = nullptr;
if (use_active) {
psys_from = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
if (psys_from == NULL) {
psys_from = static_cast<ParticleSystem *>(
CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data);
if (psys_from == nullptr) {
/* Particle System context pointer is only valid in the Properties Editor. */
psys_from = psys_get_current(ob_from);
}
@@ -1289,7 +1294,7 @@ void PARTICLE_OT_copy_particle_systems(wmOperatorType *ot)
static const EnumPropertyItem space_items[] = {
{PAR_COPY_SPACE_OBJECT, "OBJECT", 0, "Object", "Copy inside each object's local space"},
{PAR_COPY_SPACE_WORLD, "WORLD", 0, "World", "Copy in world space"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
ot->name = "Copy Particle Systems";
@@ -1338,8 +1343,9 @@ static int duplicate_particle_systems_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
/* Context pointer is only valid in the Properties Editor. */
ParticleSystem *psys = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
if (psys == NULL) {
ParticleSystem *psys = static_cast<ParticleSystem *>(
CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data);
if (psys == nullptr) {
psys = psys_get_current(ob);
}

View File

@@ -59,7 +59,7 @@
#define FLUID_JOB_FREE_GUIDES "FLUID_OT_free_guides"
#define FLUID_JOB_BAKE_PAUSE "FLUID_OT_pause_bake"
typedef struct FluidJob {
struct FluidJob {
/* from wmJob */
void *owner;
bool *stop, *do_update;
@@ -78,7 +78,7 @@ typedef struct FluidJob {
double start;
int *pause_frame;
} FluidJob;
};
static inline bool fluid_is_bake_all(FluidJob *job)
{
@@ -132,7 +132,7 @@ static inline bool fluid_is_free_guiding(FluidJob *job)
static bool fluid_initjob(
bContext *C, FluidJob *job, wmOperator *op, char *error_msg, int error_size)
{
FluidModifierData *fmd = NULL;
FluidModifierData *fmd = nullptr;
FluidDomainSettings *fds;
Object *ob = ED_object_active_context(C);
@@ -224,7 +224,7 @@ static bool fluid_validatepaths(FluidJob *job, ReportList *reports)
static void fluid_bake_free(void *customdata)
{
FluidJob *job = customdata;
FluidJob *job = static_cast<FluidJob *>(customdata);
MEM_freeN(job);
}
@@ -234,7 +234,7 @@ static void fluid_bake_sequence(FluidJob *job)
Scene *scene = job->scene;
int frame = 1, orig_frame;
int frames;
int *pause_frame = NULL;
int *pause_frame = nullptr;
bool is_first_frame;
frames = fds->cache_frame_end - fds->cache_frame_start + 1;
@@ -299,7 +299,7 @@ static void fluid_bake_sequence(FluidJob *job)
static void fluid_bake_endjob(void *customdata)
{
FluidJob *job = customdata;
FluidJob *job = static_cast<FluidJob *>(customdata);
FluidDomainSettings *fds = job->fmd->domain;
if (fluid_is_bake_noise(job) || fluid_is_bake_all(job)) {
@@ -331,7 +331,7 @@ static void fluid_bake_endjob(void *customdata)
G.is_rendering = false;
BKE_spacedata_draw_locks(false);
WM_set_locked_interface(G_MAIN->wm.first, false);
WM_set_locked_interface(static_cast<wmWindowManager *>(G_MAIN->wm.first), false);
/* Bake was successful:
* Report for ended bake and how long it took. */
@@ -352,7 +352,7 @@ static void fluid_bake_endjob(void *customdata)
static void fluid_bake_startjob(void *customdata, bool *stop, bool *do_update, float *progress)
{
FluidJob *job = customdata;
FluidJob *job = static_cast<FluidJob *>(customdata);
FluidDomainSettings *fds = job->fmd->domain;
char temp_dir[FILE_MAX];
@@ -435,12 +435,12 @@ static void fluid_bake_startjob(void *customdata, bool *stop, bool *do_update, f
static void fluid_free_endjob(void *customdata)
{
FluidJob *job = customdata;
FluidJob *job = static_cast<FluidJob *>(customdata);
FluidDomainSettings *fds = job->fmd->domain;
G.is_rendering = false;
BKE_spacedata_draw_locks(false);
WM_set_locked_interface(G_MAIN->wm.first, false);
WM_set_locked_interface(static_cast<wmWindowManager *>(G_MAIN->wm.first), false);
/* Reflect the now empty cache in the viewport too. */
DEG_id_tag_update(&job->ob->id, ID_RECALC_GEOMETRY);
@@ -464,7 +464,7 @@ static void fluid_free_endjob(void *customdata)
static void fluid_free_startjob(void *customdata, bool *stop, bool *do_update, float *progress)
{
FluidJob *job = customdata;
FluidJob *job = static_cast<FluidJob *>(customdata);
FluidDomainSettings *fds = job->fmd->domain;
job->stop = stop;
@@ -515,7 +515,7 @@ static void fluid_free_startjob(void *customdata, bool *stop, bool *do_update, f
static int fluid_bake_exec(bContext *C, wmOperator *op)
{
FluidJob *job = MEM_mallocN(sizeof(FluidJob), "FluidJob");
FluidJob *job = static_cast<FluidJob *>(MEM_mallocN(sizeof(FluidJob), "FluidJob"));
char error_msg[256] = "\0";
if (!fluid_initjob(C, job, op, error_msg, sizeof(error_msg))) {
@@ -531,17 +531,17 @@ static int fluid_bake_exec(bContext *C, wmOperator *op)
}
WM_report_banners_cancel(job->bmain);
fluid_bake_startjob(job, NULL, NULL, NULL);
fluid_bake_startjob(job, nullptr, nullptr, nullptr);
fluid_bake_endjob(job);
fluid_bake_free(job);
return OPERATOR_FINISHED;
}
static int fluid_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(_event))
static int fluid_bake_invoke(bContext *C, wmOperator *op, const wmEvent * /*_event*/)
{
Scene *scene = CTX_data_scene(C);
FluidJob *job = MEM_mallocN(sizeof(FluidJob), "FluidJob");
FluidJob *job = static_cast<FluidJob *>(MEM_mallocN(sizeof(FluidJob), "FluidJob"));
char error_msg[256] = "\0";
if (!fluid_initjob(C, job, op, error_msg, sizeof(error_msg))) {
@@ -569,7 +569,7 @@ static int fluid_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
WM_jobs_customdata_set(wm_job, job, fluid_bake_free);
WM_jobs_timer(wm_job, 0.01, NC_OBJECT | ND_MODIFIER, NC_OBJECT | ND_MODIFIER);
WM_jobs_callbacks(wm_job, fluid_bake_startjob, NULL, NULL, fluid_bake_endjob);
WM_jobs_callbacks(wm_job, fluid_bake_startjob, nullptr, nullptr, fluid_bake_endjob);
WM_set_locked_interface(CTX_wm_manager(C), true);
@@ -579,7 +579,7 @@ static int fluid_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
return OPERATOR_RUNNING_MODAL;
}
static int fluid_bake_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static int fluid_bake_modal(bContext *C, wmOperator * /*op*/, const wmEvent *event)
{
/* no running blender, remove handler and pass through */
if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_SIM_FLUID)) {
@@ -595,7 +595,7 @@ static int fluid_bake_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *
static int fluid_free_exec(bContext *C, wmOperator *op)
{
FluidModifierData *fmd = NULL;
FluidModifierData *fmd = nullptr;
FluidDomainSettings *fds;
Object *ob = ED_object_active_context(C);
Scene *scene = CTX_data_scene(C);
@@ -622,7 +622,7 @@ static int fluid_free_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
FluidJob *job = MEM_mallocN(sizeof(FluidJob), "FluidJob");
FluidJob *job = static_cast<FluidJob *>(MEM_mallocN(sizeof(FluidJob), "FluidJob"));
job->bmain = CTX_data_main(C);
job->scene = scene;
job->depsgraph = CTX_data_depsgraph_pointer(C);
@@ -648,7 +648,7 @@ static int fluid_free_exec(bContext *C, wmOperator *op)
WM_jobs_customdata_set(wm_job, job, fluid_bake_free);
WM_jobs_timer(wm_job, 0.01, NC_OBJECT | ND_MODIFIER, NC_OBJECT | ND_MODIFIER);
WM_jobs_callbacks(wm_job, fluid_free_startjob, NULL, NULL, fluid_free_endjob);
WM_jobs_callbacks(wm_job, fluid_free_startjob, nullptr, nullptr, fluid_free_endjob);
WM_set_locked_interface(CTX_wm_manager(C), true);
@@ -660,7 +660,7 @@ static int fluid_free_exec(bContext *C, wmOperator *op)
static int fluid_pause_exec(bContext *C, wmOperator *op)
{
FluidModifierData *fmd = NULL;
FluidModifierData *fmd = nullptr;
FluidDomainSettings *fds;
Object *ob = ED_object_active_context(C);

View File

@@ -16,6 +16,10 @@ struct PointCache;
struct Scene;
struct wmOperatorType;
#ifdef __cplusplus
extern "C" {
#endif
/* particle_edit.c */
void PARTICLE_OT_select_all(struct wmOperatorType *ot);
@@ -160,3 +164,7 @@ void RIGIDBODY_OT_constraint_remove(struct wmOperatorType *ot);
void RIGIDBODY_OT_world_add(struct wmOperatorType *ot);
void RIGIDBODY_OT_world_remove(struct wmOperatorType *ot);
void RIGIDBODY_OT_world_export(struct wmOperatorType *ot);
#ifdef __cplusplus
}
#endif

View File

@@ -36,7 +36,7 @@
static bool ptcache_bake_all_poll(bContext *C)
{
return CTX_data_scene(C) != NULL;
return CTX_data_scene(C) != nullptr;
}
static bool ptcache_poll(bContext *C)
@@ -44,9 +44,9 @@ static bool ptcache_poll(bContext *C)
PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
ID *id = ptr.owner_id;
PointCache *point_cache = ptr.data;
PointCache *point_cache = static_cast<PointCache *>(ptr.data);
if (id == NULL || point_cache == NULL) {
if (id == nullptr || point_cache == nullptr) {
return false;
}
@@ -69,9 +69,9 @@ static bool ptcache_add_remove_poll(bContext *C)
PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
ID *id = ptr.owner_id;
PointCache *point_cache = ptr.data;
PointCache *point_cache = static_cast<PointCache *>(ptr.data);
if (id == NULL || point_cache == NULL) {
if (id == nullptr || point_cache == nullptr) {
return false;
}
@@ -84,25 +84,25 @@ static bool ptcache_add_remove_poll(bContext *C)
return true;
}
typedef struct PointCacheJob {
struct PointCacheJob {
wmWindowManager *wm;
void *owner;
bool *stop, *do_update;
float *progress;
PTCacheBaker *baker;
} PointCacheJob;
};
static void ptcache_job_free(void *customdata)
{
PointCacheJob *job = customdata;
PointCacheJob *job = static_cast<PointCacheJob *>(customdata);
MEM_freeN(job->baker);
MEM_freeN(job);
}
static int ptcache_job_break(void *customdata)
{
PointCacheJob *job = customdata;
PointCacheJob *job = static_cast<PointCacheJob *>(customdata);
if (G.is_break) {
return 1;
@@ -117,7 +117,7 @@ static int ptcache_job_break(void *customdata)
static void ptcache_job_update(void *customdata, float progress, int *cancel)
{
PointCacheJob *job = customdata;
PointCacheJob *job = static_cast<PointCacheJob *>(customdata);
if (ptcache_job_break(job)) {
*cancel = 1;
@@ -129,7 +129,7 @@ static void ptcache_job_update(void *customdata, float progress, int *cancel)
static void ptcache_job_startjob(void *customdata, bool *stop, bool *do_update, float *progress)
{
PointCacheJob *job = customdata;
PointCacheJob *job = static_cast<PointCacheJob *>(customdata);
job->stop = stop;
job->do_update = do_update;
@@ -150,7 +150,7 @@ static void ptcache_job_startjob(void *customdata, bool *stop, bool *do_update,
static void ptcache_job_endjob(void *customdata)
{
PointCacheJob *job = customdata;
PointCacheJob *job = static_cast<PointCacheJob *>(customdata);
Scene *scene = job->baker->scene;
WM_set_locked_interface(job->wm, false);
@@ -164,7 +164,7 @@ static void ptcache_free_bake(PointCache *cache)
if (cache->edit) {
if (!cache->edit->edited || 1) { // XXX okee("Lose changes done in particle mode?")) {
PE_free_ptcache_edit(cache->edit);
cache->edit = NULL;
cache->edit = nullptr;
cache->flag &= ~PTCACHE_BAKED;
}
}
@@ -175,7 +175,8 @@ static void ptcache_free_bake(PointCache *cache)
static PTCacheBaker *ptcache_baker_create(bContext *C, wmOperator *op, bool all)
{
PTCacheBaker *baker = MEM_callocN(sizeof(PTCacheBaker), "PTCacheBaker");
PTCacheBaker *baker = static_cast<PTCacheBaker *>(
MEM_callocN(sizeof(PTCacheBaker), "PTCacheBaker"));
baker->bmain = CTX_data_main(C);
baker->scene = CTX_data_scene(C);
@@ -190,8 +191,8 @@ static PTCacheBaker *ptcache_baker_create(bContext *C, wmOperator *op, bool all)
if (!all) {
PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
ID *id = ptr.owner_id;
Object *ob = (GS(id->name) == ID_OB) ? (Object *)id : NULL;
PointCache *cache = ptr.data;
Object *ob = (GS(id->name) == ID_OB) ? (Object *)id : nullptr;
PointCache *cache = static_cast<PointCache *>(ptr.data);
baker->pid = BKE_ptcache_id_find(ob, baker->scene, cache);
}
@@ -209,11 +210,12 @@ static int ptcache_bake_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int ptcache_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int ptcache_bake_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
bool all = STREQ(op->type->idname, "PTCACHE_OT_bake_all");
PointCacheJob *job = MEM_mallocN(sizeof(PointCacheJob), "PointCacheJob");
PointCacheJob *job = static_cast<PointCacheJob *>(
MEM_mallocN(sizeof(PointCacheJob), "PointCacheJob"));
job->wm = CTX_wm_manager(C);
job->baker = ptcache_baker_create(C, op, all);
job->baker->bake_job = job;
@@ -228,7 +230,7 @@ static int ptcache_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
WM_jobs_customdata_set(wm_job, job, ptcache_job_free);
WM_jobs_timer(wm_job, 0.1, NC_OBJECT | ND_POINTCACHE, NC_OBJECT | ND_POINTCACHE);
WM_jobs_callbacks(wm_job, ptcache_job_startjob, NULL, NULL, ptcache_job_endjob);
WM_jobs_callbacks(wm_job, ptcache_job_startjob, nullptr, nullptr, ptcache_job_endjob);
WM_set_locked_interface(CTX_wm_manager(C), true);
@@ -242,7 +244,7 @@ static int ptcache_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
return OPERATOR_RUNNING_MODAL;
}
static int ptcache_bake_modal(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int ptcache_bake_modal(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
Scene *scene = (Scene *)op->customdata;
@@ -263,7 +265,7 @@ static void ptcache_bake_cancel(bContext *C, wmOperator *op)
WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_POINTCACHE);
}
static int ptcache_free_bake_all_exec(bContext *C, wmOperator *UNUSED(op))
static int ptcache_free_bake_all_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
PTCacheID *pid;
@@ -272,7 +274,7 @@ static int ptcache_free_bake_all_exec(bContext *C, wmOperator *UNUSED(op))
FOREACH_SCENE_OBJECT_BEGIN (scene, ob) {
BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
for (pid = pidlist.first; pid; pid = pid->next) {
for (pid = static_cast<PTCacheID *>(pidlist.first); pid; pid = pid->next) {
ptcache_free_bake(pid->cache);
}
@@ -321,10 +323,10 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int ptcache_free_bake_exec(bContext *C, wmOperator *UNUSED(op))
static int ptcache_free_bake_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
PointCache *cache = ptr.data;
PointCache *cache = static_cast<PointCache *>(ptr.data);
Object *ob = (Object *)ptr.owner_id;
ptcache_free_bake(cache);
@@ -333,10 +335,10 @@ static int ptcache_free_bake_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
static int ptcache_bake_from_cache_exec(bContext *C, wmOperator *UNUSED(op))
static int ptcache_bake_from_cache_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
PointCache *cache = ptr.data;
PointCache *cache = static_cast<PointCache *>(ptr.data);
Object *ob = (Object *)ptr.owner_id;
cache->flag |= PTCACHE_BAKED;
@@ -393,12 +395,12 @@ void PTCACHE_OT_bake_from_cache(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int ptcache_add_new_exec(bContext *C, wmOperator *UNUSED(op))
static int ptcache_add_new_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
Object *ob = (Object *)ptr.owner_id;
PointCache *cache = ptr.data;
PointCache *cache = static_cast<PointCache *>(ptr.data);
PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
if (pid.cache) {
@@ -413,19 +415,19 @@ static int ptcache_add_new_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
static int ptcache_remove_exec(bContext *C, wmOperator *UNUSED(op))
static int ptcache_remove_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
Scene *scene = CTX_data_scene(C);
Object *ob = (Object *)ptr.owner_id;
PointCache *cache = ptr.data;
PointCache *cache = static_cast<PointCache *>(ptr.data);
PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
/* don't delete last cache */
if (pid.cache && pid.ptcaches->first != pid.ptcaches->last) {
BLI_remlink(pid.ptcaches, pid.cache);
BKE_ptcache_free(pid.cache);
*(pid.cache_ptr) = pid.ptcaches->first;
*(pid.cache_ptr) = static_cast<PointCache *>(pid.ptcaches->first);
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, ob);

View File

@@ -44,8 +44,8 @@
static bool operator_rigidbody_constraints_editable_poll(Scene *scene)
{
if (scene == NULL || ID_IS_LINKED(scene) || ID_IS_OVERRIDE_LIBRARY(scene) ||
(scene->rigidbody_world != NULL && scene->rigidbody_world->constraints != NULL &&
if (scene == nullptr || ID_IS_LINKED(scene) || ID_IS_OVERRIDE_LIBRARY(scene) ||
(scene->rigidbody_world != nullptr && scene->rigidbody_world->constraints != nullptr &&
(ID_IS_LINKED(scene->rigidbody_world->constraints) ||
ID_IS_OVERRIDE_LIBRARY(scene->rigidbody_world->constraints))))
{
@@ -89,8 +89,8 @@ bool ED_rigidbody_constraint_add(
return false;
}
/* create constraint group if it doesn't already exits */
if (rbw->constraints == NULL) {
rbw->constraints = BKE_collection_add(bmain, NULL, "RigidBodyConstraints");
if (rbw->constraints == nullptr) {
rbw->constraints = BKE_collection_add(bmain, nullptr, "RigidBodyConstraints");
id_us_plus(&rbw->constraints->id);
}
/* make rigidbody constraint settings */
@@ -131,7 +131,7 @@ static int rigidbody_con_add_exec(bContext *C, wmOperator *op)
bool changed;
/* sanity checks */
if (ELEM(NULL, scene, rbw)) {
if (ELEM(nullptr, scene, rbw)) {
BKE_report(op->reports, RPT_ERROR, "No Rigid Body World to add Rigid Body Constraint to");
return OPERATOR_CANCELLED;
}
@@ -140,7 +140,7 @@ static int rigidbody_con_add_exec(bContext *C, wmOperator *op)
if (changed) {
/* send updates */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -182,14 +182,14 @@ static int rigidbody_con_remove_exec(bContext *C, wmOperator *op)
Object *ob = BKE_view_layer_active_object_get(view_layer);
/* apply to active object */
if (ELEM(NULL, ob, ob->rigidbody_constraint)) {
if (ELEM(nullptr, ob, ob->rigidbody_constraint)) {
BKE_report(op->reports, RPT_ERROR, "Object has no Rigid Body Constraint to remove");
return OPERATOR_CANCELLED;
}
ED_rigidbody_constraint_remove(bmain, scene, ob);
/* send updates */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, nullptr);
/* done */
return OPERATOR_FINISHED;

View File

@@ -47,8 +47,8 @@
static bool operator_rigidbody_editable_poll(Scene *scene)
{
if (scene == NULL || ID_IS_LINKED(scene) || ID_IS_OVERRIDE_LIBRARY(scene) ||
(scene->rigidbody_world != NULL && scene->rigidbody_world->group != NULL &&
if (scene == nullptr || ID_IS_LINKED(scene) || ID_IS_OVERRIDE_LIBRARY(scene) ||
(scene->rigidbody_world != nullptr && scene->rigidbody_world->group != nullptr &&
(ID_IS_LINKED(scene->rigidbody_world->group) ||
ID_IS_OVERRIDE_LIBRARY(scene->rigidbody_world->group))))
{
@@ -120,8 +120,8 @@ static int rigidbody_object_add_exec(bContext *C, wmOperator *op)
if (changed) {
/* send updates */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, nullptr);
WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -162,15 +162,15 @@ static int rigidbody_object_remove_exec(bContext *C, wmOperator *op)
bool changed = false;
/* apply to active object */
if (!ELEM(NULL, ob, ob->rigidbody_object)) {
if (!ELEM(nullptr, ob, ob->rigidbody_object)) {
ED_rigidbody_object_remove(bmain, scene, ob);
changed = true;
}
if (changed) {
/* send updates */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, nullptr);
WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -215,8 +215,8 @@ static int rigidbody_objects_add_exec(bContext *C, wmOperator *op)
if (changed) {
/* send updates */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, nullptr);
WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -249,7 +249,7 @@ void RIGIDBODY_OT_objects_add(wmOperatorType *ot)
/* ************ Remove Rigid Bodies ************** */
static int rigidbody_objects_remove_exec(bContext *C, wmOperator *UNUSED(op))
static int rigidbody_objects_remove_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
@@ -266,8 +266,8 @@ static int rigidbody_objects_remove_exec(bContext *C, wmOperator *UNUSED(op))
if (changed) {
/* send updates */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, nullptr);
WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -318,8 +318,8 @@ static int rigidbody_objects_shape_change_exec(bContext *C, wmOperator *op)
if (changed) {
/* send updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, nullptr);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -354,10 +354,10 @@ void RIGIDBODY_OT_shape_change(wmOperatorType *ot)
/* ************ Calculate Mass ************** */
/* Entry in material density table */
typedef struct rbMaterialDensityItem {
struct rbMaterialDensityItem {
const char *name; /* Name of material */
float density; /* Density (kg/m^3) */
} rbMaterialDensityItem;
};
/* Preset density values for materials (kg/m^3)
* Selected values obtained from:
@@ -379,10 +379,8 @@ static rbMaterialDensityItem RB_MATERIAL_DENSITY_TABLE[] = {
{N_("Bronze"), 8860.0f},
{N_("Carbon (Solid)"), 2146.0f},
{N_("Cardboard"), 689.0f},
{N_("Cast Iron"), 7150.0f},
/* {N_("Cement"), 1442.0f}, */
{N_("Chalk (Solid)"), 2499.0f},
/* {N_("Coffee (Fresh/Roast)"), ~500}, */
{N_("Cast Iron"), 7150.0f}, /* {N_("Cement"), 1442.0f}, */
{N_("Chalk (Solid)"), 2499.0f}, /* {N_("Coffee (Fresh/Roast)"), ~500}, */
{N_("Concrete"), 2320.0f},
{N_("Charcoal"), 208.0f},
{N_("Cork"), 240.0f},
@@ -422,13 +420,13 @@ static const int NUM_RB_MATERIAL_PRESETS = sizeof(RB_MATERIAL_DENSITY_TABLE) /
* - Although there is a runtime cost, this has a lower maintenance cost
* in the long run than other two-list solutions...
*/
static const EnumPropertyItem *rigidbody_materials_itemf(bContext *UNUSED(C),
PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
static const EnumPropertyItem *rigidbody_materials_itemf(bContext * /*C*/,
PointerRNA * /*ptr*/,
PropertyRNA * /*prop*/,
bool *r_free)
{
EnumPropertyItem item_tmp = {0};
EnumPropertyItem *item = NULL;
EnumPropertyItem *item = nullptr;
int totitem = 0;
int i = 0;
@@ -508,7 +506,7 @@ static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op)
if (changed) {
/* send updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, nullptr);
/* done */
return OPERATOR_FINISHED;
@@ -516,7 +514,7 @@ static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
static bool mass_calculate_poll_property(const bContext *UNUSED(C),
static bool mass_calculate_poll_property(const bContext * /*C*/,
wmOperator *op,
const PropertyRNA *prop)
{

View File

@@ -47,7 +47,7 @@ static bool ED_rigidbody_world_active_poll(bContext *C)
static bool ED_rigidbody_world_add_poll(bContext *C)
{
Scene *scene = CTX_data_scene(C);
return (scene && scene->rigidbody_world == NULL);
return (scene && scene->rigidbody_world == nullptr);
}
/* ********************************************** */
@@ -55,7 +55,7 @@ static bool ED_rigidbody_world_add_poll(bContext *C)
/* ********** Add RigidBody World **************** */
static int rigidbody_world_add_exec(bContext *C, wmOperator *UNUSED(op))
static int rigidbody_world_add_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
@@ -96,7 +96,7 @@ static int rigidbody_world_remove_exec(bContext *C, wmOperator *op)
RigidBodyWorld *rbw = scene->rigidbody_world;
/* sanity checks */
if (ELEM(NULL, scene, rbw)) {
if (ELEM(nullptr, scene, rbw)) {
BKE_report(op->reports, RPT_ERROR, "No Rigid Body World to remove");
return OPERATOR_CANCELLED;
}
@@ -138,11 +138,11 @@ static int rigidbody_world_export_exec(bContext *C, wmOperator *op)
char filepath[FILE_MAX];
/* sanity checks */
if (ELEM(NULL, scene, rbw)) {
if (ELEM(nullptr, scene, rbw)) {
BKE_report(op->reports, RPT_ERROR, "No Rigid Body World to export");
return OPERATOR_CANCELLED;
}
if (rbw->shared->physics_world == NULL) {
if (rbw->shared->physics_world == nullptr) {
BKE_report(
op->reports, RPT_ERROR, "Rigid Body World has no associated physics data to export");
return OPERATOR_CANCELLED;
@@ -150,12 +150,12 @@ static int rigidbody_world_export_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", filepath);
#ifdef WITH_BULLET
RB_dworld_export(rbw->shared->physics_world, filepath);
RB_dworld_export(static_cast<rbDynamicsWorld *>(rbw->shared->physics_world), filepath);
#endif
return OPERATOR_FINISHED;
}
static int rigidbody_world_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int rigidbody_world_export_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (!RNA_struct_property_is_set(op->ptr, "relative_path")) {
RNA_boolean_set(op->ptr, "relative_path", (U.flag & USER_RELPATHS) != 0);

View File

@@ -23,18 +23,18 @@ set(INC_SYS
set(SRC
area.cc
area_query.c
area_utils.c
glutil.c
screen_context.c
screen_draw.c
screen_edit.c
screen_geometry.c
screen_ops.c
screen_user_menu.c
screendump.c
workspace_edit.c
workspace_layout_edit.c
area_query.cc
area_utils.cc
glutil.cc
screen_context.cc
screen_draw.cc
screen_edit.cc
screen_geometry.cc
screen_ops.cc
screen_user_menu.cc
screendump.cc
workspace_edit.cc
workspace_layout_edit.cc
workspace_listen.cc
screen_intern.h

View File

@@ -2022,7 +2022,7 @@ static void area_offscreen_init(ScrArea *area)
ScrArea *ED_area_offscreen_create(wmWindow *win, eSpace_Type space_type)
{
ScrArea *area = MEM_cnew<ScrArea>(__func__);
ScrArea *area = static_cast<ScrArea *>(MEM_callocN(sizeof(ScrArea), __func__));
area->spacetype = space_type;
screen_area_spacelink_add(WM_window_get_active_scene(win), area, space_type);
@@ -2434,7 +2434,7 @@ static void region_align_info_to_area(
void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2)
{
ScrArea *tmp = MEM_cnew<ScrArea>(__func__);
ScrArea *tmp = static_cast<ScrArea *>(MEM_callocN(sizeof(ScrArea), __func__));
wmWindow *win = CTX_wm_window(C);
ED_area_exit(C, sa1);

View File

@@ -140,7 +140,7 @@ bool ED_region_contains_xy(const ARegion *region, const int event_xy[2])
/* Header. */
rcti rect;
BLI_rcti_init_pt_radius(&rect, event_xy, overlap_margin);
if (UI_region_but_find_rect_over(region, &rect) == NULL) {
if (UI_region_but_find_rect_over(region, &rect) == nullptr) {
return false;
}
}
@@ -182,7 +182,7 @@ ARegion *ED_area_find_region_xy_visual(const ScrArea *area,
const int event_xy[2])
{
if (!area) {
return NULL;
return nullptr;
}
/* Check overlapped regions first. */
@@ -208,5 +208,5 @@ ARegion *ED_area_find_region_xy_visual(const ScrArea *area,
}
}
return NULL;
return nullptr;
}

View File

@@ -34,11 +34,10 @@ void ED_region_generic_tools_region_message_subscribe(const wmRegionMessageSubsc
struct wmMsgBus *mbus = params->message_bus;
ARegion *region = params->region;
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
.user_data = region,
.notify = ED_region_do_msg_notify_tag_redraw,
};
wmMsgSubscribeValue msg_sub_value_region_tag_redraw{};
msg_sub_value_region_tag_redraw.owner = region;
msg_sub_value_region_tag_redraw.user_data = region;
msg_sub_value_region_tag_redraw.notify = ED_region_do_msg_notify_tag_redraw;
WM_msg_subscribe_rna_anon_prop(mbus, WorkSpace, tools, &msg_sub_value_region_tag_redraw);
}

View File

@@ -48,10 +48,10 @@ IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin)
IMMDrawPixelsTexState state;
immDrawPixelsTexSetupAttributes(&state);
state.shader = GPU_shader_get_builtin_shader(builtin);
state.shader = GPU_shader_get_builtin_shader(eGPUBuiltinShader(builtin));
/* Shader will be unbind by immUnbindProgram in a `immDrawPixelsTex` function. */
immBindBuiltinProgram(builtin);
immBindBuiltinProgram(eGPUBuiltinShader(builtin));
immUniform1i("image", 0);
state.do_shader_unbind = true;
@@ -82,7 +82,7 @@ void immDrawPixelsTexScaledFullSize(const IMMDrawPixelsTexState *state,
const int mip_len = use_mipmap ? 9999 : 1;
GPUTexture *tex = GPU_texture_create_2d(
"immDrawPixels", img_w, img_h, mip_len, gpu_format, GPU_TEXTURE_USAGE_SHADER_READ, NULL);
"immDrawPixels", img_w, img_h, mip_len, gpu_format, GPU_TEXTURE_USAGE_SHADER_READ, nullptr);
const bool use_float_data = ELEM(gpu_format, GPU_RGBA16F, GPU_RGB16F, GPU_R16F);
eGPUDataFormat gpu_data_format = (use_float_data) ? GPU_DATA_FLOAT : GPU_DATA_UBYTE;
@@ -101,7 +101,7 @@ void immDrawPixelsTexScaledFullSize(const IMMDrawPixelsTexState *state,
/* NOTE: Shader could be null for GLSL OCIO drawing, it is fine, since
* it does not need color.
*/
if (state->shader != NULL && GPU_shader_get_uniform(state->shader, "color") != -1) {
if (state->shader != nullptr && GPU_shader_get_uniform(state->shader, "color") != -1) {
immUniformColor4fv((color) ? color : white);
}
@@ -183,7 +183,7 @@ void immDrawPixelsTexTiled_scaling_clipping(IMMDrawPixelsTexState *state,
size_t stride = components * ((use_float_data) ? sizeof(float) : sizeof(uchar));
GPUTexture *tex = GPU_texture_create_2d(
"immDrawPixels", tex_w, tex_h, 1, gpu_format, GPU_TEXTURE_USAGE_SHADER_READ, NULL);
"immDrawPixels", tex_w, tex_h, 1, gpu_format, GPU_TEXTURE_USAGE_SHADER_READ, nullptr);
GPU_texture_filter_mode(tex, use_filter);
GPU_texture_extend_mode(tex, GPU_SAMPLER_EXTEND_MODE_EXTEND);
@@ -203,7 +203,7 @@ void immDrawPixelsTexTiled_scaling_clipping(IMMDrawPixelsTexState *state,
/* NOTE: Shader could be null for GLSL OCIO drawing, it is fine, since
* it does not need color.
*/
if (state->shader != NULL && GPU_shader_get_uniform(state->shader, "color") != -1) {
if (state->shader != nullptr && GPU_shader_get_uniform(state->shader, "color") != -1) {
immUniformColor4fv((color) ? color : white);
}
@@ -290,10 +290,10 @@ void immDrawPixelsTexTiled_scaling_clipping(IMMDrawPixelsTexState *state,
immVertex2f(pos, rast_x + offset_left * xzoom, rast_y + top * yzoom * scaleY);
immEnd();
/* NOTE: Weirdly enough this is only required on macOS. Without this there is some sort of
* bleeding of data is happening from tiles which are drawn later on.
* This doesn't seem to be too slow,
* but still would be nice to have fast and nice solution. */
/* NOTE: Weirdly enough this is only required on macOS. Without this there is some sort of
* bleeding of data is happening from tiles which are drawn later on.
* This doesn't seem to be too slow,
* but still would be nice to have fast and nice solution. */
#ifdef __APPLE__
if (GPU_type_matches_ex(GPU_DEVICE_ANY, GPU_OS_MAC, GPU_DRIVER_ANY, GPU_BACKEND_OPENGL)) {
GPU_flush();
@@ -431,7 +431,7 @@ void ED_draw_imbuf_clipping(ImBuf *ibuf,
bool need_fallback = true;
/* Early out */
if (ibuf->byte_buffer.data == NULL && ibuf->float_buffer.data == NULL) {
if (ibuf->byte_buffer.data == nullptr && ibuf->float_buffer.data == nullptr) {
return;
}
@@ -475,7 +475,7 @@ void ED_draw_imbuf_clipping(ImBuf *ibuf,
if (ok) {
if (ibuf->float_buffer.data) {
eGPUTextureFormat format = 0;
eGPUTextureFormat format = eGPUTextureFormat(0);
if (ibuf->channels == 3) {
format = GPU_RGB16F;
@@ -502,7 +502,7 @@ void ED_draw_imbuf_clipping(ImBuf *ibuf,
clip_max_y,
zoom_x,
zoom_y,
NULL);
nullptr);
}
}
else if (ibuf->byte_buffer.data) {
@@ -521,7 +521,7 @@ void ED_draw_imbuf_clipping(ImBuf *ibuf,
clip_max_y,
zoom_x,
zoom_y,
NULL);
nullptr);
}
IMB_colormanagement_finish_glsl_draw();
@@ -554,7 +554,7 @@ void ED_draw_imbuf_clipping(ImBuf *ibuf,
clip_max_y,
zoom_x,
zoom_y,
NULL);
nullptr);
}
IMB_display_buffer_release(cache_handle);

View File

@@ -113,7 +113,7 @@ const char *screen_context_dir[] = {
"ui_list",
"property",
"asset_library_ref",
NULL,
nullptr,
};
/* Each function `screen_ctx_XXX()` will be called when the screen context "XXX" is requested.
@@ -130,7 +130,7 @@ static eContextResult screen_ctx_scene(const bContext *C, bContextDataResult *re
static eContextResult screen_ctx_visible_objects(const bContext *C, bContextDataResult *result)
{
wmWindow *win = CTX_wm_window(C);
View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
BKE_view_layer_synced_ensure(scene, view_layer);
@@ -146,7 +146,7 @@ static eContextResult screen_ctx_visible_objects(const bContext *C, bContextData
static eContextResult screen_ctx_selectable_objects(const bContext *C, bContextDataResult *result)
{
wmWindow *win = CTX_wm_window(C);
View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
BKE_view_layer_synced_ensure(scene, view_layer);
@@ -162,7 +162,7 @@ static eContextResult screen_ctx_selectable_objects(const bContext *C, bContextD
static eContextResult screen_ctx_selected_objects(const bContext *C, bContextDataResult *result)
{
wmWindow *win = CTX_wm_window(C);
View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
BKE_view_layer_synced_ensure(scene, view_layer);
@@ -179,7 +179,7 @@ static eContextResult screen_ctx_selected_editable_objects(const bContext *C,
bContextDataResult *result)
{
wmWindow *win = CTX_wm_window(C);
View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
BKE_view_layer_synced_ensure(scene, view_layer);
@@ -195,7 +195,7 @@ static eContextResult screen_ctx_selected_editable_objects(const bContext *C,
static eContextResult screen_ctx_editable_objects(const bContext *C, bContextDataResult *result)
{
wmWindow *win = CTX_wm_window(C);
View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
BKE_view_layer_synced_ensure(scene, view_layer);
@@ -212,7 +212,7 @@ static eContextResult screen_ctx_editable_objects(const bContext *C, bContextDat
static eContextResult screen_ctx_objects_in_mode(const bContext *C, bContextDataResult *result)
{
wmWindow *win = CTX_wm_window(C);
View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
const Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
BKE_view_layer_synced_ensure(scene, view_layer);
@@ -231,7 +231,7 @@ static eContextResult screen_ctx_objects_in_mode_unique_data(const bContext *C,
bContextDataResult *result)
{
wmWindow *win = CTX_wm_window(C);
View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
const Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
BKE_view_layer_synced_ensure(scene, view_layer);
@@ -263,8 +263,9 @@ static eContextResult screen_ctx_visible_or_editable_bones_(const bContext *C,
BKE_view_layer_synced_ensure(scene, view_layer);
Object *obedit = BKE_view_layer_edit_object_get(view_layer);
bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL;
EditBone *flipbone = NULL;
bArmature *arm = static_cast<bArmature *>(
(obedit && obedit->type == OB_ARMATURE) ? obedit->data : nullptr);
EditBone *flipbone = nullptr;
if (arm && arm->edbo) {
uint objects_len;
@@ -272,7 +273,7 @@ static eContextResult screen_ctx_visible_or_editable_bones_(const bContext *C,
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint i = 0; i < objects_len; i++) {
Object *ob = objects[i];
arm = ob->data;
arm = static_cast<bArmature *>(ob->data);
/* Attention: X-Axis Mirroring is also handled here... */
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
@@ -335,8 +336,9 @@ static eContextResult screen_ctx_selected_bones_(const bContext *C,
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
BKE_view_layer_synced_ensure(scene, view_layer);
Object *obedit = BKE_view_layer_edit_object_get(view_layer);
bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL;
EditBone *flipbone = NULL;
bArmature *arm = static_cast<bArmature *>(
(obedit && obedit->type == OB_ARMATURE) ? obedit->data : nullptr);
EditBone *flipbone = nullptr;
if (arm && arm->edbo) {
uint objects_len;
@@ -344,7 +346,7 @@ static eContextResult screen_ctx_selected_bones_(const bContext *C,
scene, view_layer, CTX_wm_view3d(C), &objects_len);
for (uint i = 0; i < objects_len; i++) {
Object *ob = objects[i];
arm = ob->data;
arm = static_cast<bArmature *>(ob->data);
/* Attention: X-Axis Mirroring is also handled here... */
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
@@ -402,7 +404,7 @@ static eContextResult screen_ctx_selected_editable_bones(const bContext *C,
static eContextResult screen_ctx_visible_pose_bones(const bContext *C, bContextDataResult *result)
{
wmWindow *win = CTX_wm_window(C);
View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
const Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
BKE_view_layer_synced_ensure(scene, view_layer);
@@ -432,7 +434,7 @@ static eContextResult screen_ctx_visible_pose_bones(const bContext *C, bContextD
static eContextResult screen_ctx_selected_pose_bones(const bContext *C, bContextDataResult *result)
{
wmWindow *win = CTX_wm_window(C);
View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
const Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
Object *obact = BKE_view_layer_active_object_get(view_layer);
@@ -493,7 +495,7 @@ static eContextResult screen_ctx_active_bone(const bContext *C, bContextDataResu
BKE_view_layer_synced_ensure(scene, view_layer);
Object *obact = BKE_view_layer_active_object_get(view_layer);
if (obact && obact->type == OB_ARMATURE) {
bArmature *arm = obact->data;
bArmature *arm = static_cast<bArmature *>(obact->data);
if (arm->edbo) {
if (arm->act_edbone) {
CTX_data_pointer_set(result, &arm->id, &RNA_EditBone, arm->act_edbone);
@@ -718,7 +720,7 @@ static eContextResult screen_ctx_selected_editable_sequences(const bContext *C,
wmWindow *win = CTX_wm_window(C);
Scene *scene = WM_window_get_active_scene(win);
Editing *ed = SEQ_editing_get(scene);
if (ed == NULL) {
if (ed == nullptr) {
return CTX_RESULT_NO_DATA;
}
@@ -754,9 +756,10 @@ static eContextResult screen_ctx_selected_nla_strips(const bContext *C, bContext
{
bAnimContext ac;
if (ANIM_animdata_get_context(C, &ac) != 0) {
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
ANIM_animdata_filter(&ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac.data, eAnimCont_Types(ac.datatype));
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ale->datatype != ALE_NLASTRIP) {
continue;
@@ -779,11 +782,11 @@ static eContextResult screen_ctx_selected_movieclip_tracks(const bContext *C,
bContextDataResult *result)
{
SpaceClip *space_clip = CTX_wm_space_clip(C);
if (space_clip == NULL) {
if (space_clip == nullptr) {
return CTX_RESULT_NO_DATA;
}
MovieClip *clip = ED_space_clip_get_clip(space_clip);
if (clip == NULL) {
if (clip == nullptr) {
return CTX_RESULT_NO_DATA;
}
@@ -806,7 +809,7 @@ static eContextResult screen_ctx_gpencil_data(const bContext *C, bContextDataRes
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
BKE_view_layer_synced_ensure(scene, view_layer);
Object *obact = BKE_view_layer_active_object_get(view_layer);
/* FIXME: for some reason, CTX_data_active_object(C) returns NULL when called from these
/* FIXME: for some reason, CTX_data_active_object(C) returns nullptr when called from these
* situations (as outlined above - see Campbell's #ifdefs).
* That causes the get_active function to fail when called from context.
* For that reason, we end up using an alternative where we pass everything in!
@@ -989,7 +992,7 @@ static eContextResult screen_ctx_editable_gpencil_strokes(const bContext *C,
bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
if (gpd == NULL) {
if (gpd == nullptr) {
return CTX_RESULT_NO_DATA;
}
@@ -998,7 +1001,7 @@ static eContextResult screen_ctx_editable_gpencil_strokes(const bContext *C,
bGPDframe *gpf;
bGPDframe *init_gpf = gpl->actframe;
if (is_multiedit) {
init_gpf = gpl->frames.first;
init_gpf = static_cast<bGPDframe *>(gpl->frames.first);
}
for (gpf = init_gpf; gpf; gpf = gpf->next) {
@@ -1026,7 +1029,7 @@ static eContextResult screen_ctx_editable_gpencil_strokes(const bContext *C,
}
static eContextResult screen_ctx_active_operator(const bContext *C, bContextDataResult *result)
{
wmOperator *op = NULL;
wmOperator *op = nullptr;
SpaceFile *sfile = CTX_wm_space_file(C);
if (sfile) {
@@ -1043,7 +1046,7 @@ static eContextResult screen_ctx_active_operator(const bContext *C, bContextData
/* TODO: get the operator from popup's. */
if (op && op->ptr) {
CTX_data_pointer_set(result, NULL, &RNA_Operator, op);
CTX_data_pointer_set(result, nullptr, &RNA_Operator, op);
return CTX_RESULT_OK;
}
return CTX_RESULT_NO_DATA;
@@ -1076,7 +1079,7 @@ static eContextResult screen_ctx_sel_actions_impl(const bContext *C,
}
/* Search for selected animation data items. */
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
int filter = ANIMFILTER_DATA_VISIBLE;
bool check_selected = false;
@@ -1093,9 +1096,10 @@ static eContextResult screen_ctx_sel_actions_impl(const bContext *C,
break;
}
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
GSet *seen_set = active_only ? NULL : BLI_gset_ptr_new("seen actions");
GSet *seen_set = active_only ? nullptr : BLI_gset_ptr_new("seen actions");
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
/* In dopesheet check selection status of individual items, skipping
@@ -1126,7 +1130,7 @@ static eContextResult screen_ctx_sel_actions_impl(const bContext *C,
ANIM_animdata_freelist(&anim_data);
if (!active_only) {
BLI_gset_free(seen_set, NULL);
BLI_gset_free(seen_set, nullptr);
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
}
@@ -1155,7 +1159,7 @@ static eContextResult screen_ctx_sel_edit_fcurves_(const bContext *C,
{
bAnimContext ac;
if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, SPACE_GRAPH)) {
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS) |
(ac.spacetype == SPACE_GRAPH ?
@@ -1163,7 +1167,8 @@ static eContextResult screen_ctx_sel_edit_fcurves_(const bContext *C,
ANIMFILTER_LIST_VISIBLE) |
extra_filter;
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
@@ -1201,12 +1206,13 @@ static eContextResult screen_ctx_active_editable_fcurve(const bContext *C,
{
bAnimContext ac;
if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_GRAPH)) {
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY | ANIMFILTER_CURVE_VISIBLE);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
@@ -1225,7 +1231,7 @@ static eContextResult screen_ctx_selected_editable_keyframes(const bContext *C,
{
bAnimContext ac;
if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, SPACE_GRAPH)) {
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
/* Use keyframes from editable selected FCurves. */
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS | ANIMFILTER_FOREDIT |
@@ -1234,7 +1240,8 @@ static eContextResult screen_ctx_selected_editable_keyframes(const bContext *C,
(ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY) :
ANIMFILTER_LIST_VISIBLE);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
int i;
FCurve *fcurve;
@@ -1245,7 +1252,7 @@ static eContextResult screen_ctx_selected_editable_keyframes(const bContext *C,
}
fcurve = (FCurve *)ale->data;
if (fcurve->bezt == NULL) {
if (fcurve->bezt == nullptr) {
/* Skip baked FCurves. */
continue;
}
@@ -1282,7 +1289,7 @@ static eContextResult screen_ctx_ui_list(const bContext *C, bContextDataResult *
if (region) {
uiList *list = UI_list_find_mouse_over(region, win->eventstate);
if (list) {
CTX_data_pointer_set(result, NULL, &RNA_UIList, list);
CTX_data_pointer_set(result, nullptr, &RNA_UIList, list);
return CTX_RESULT_OK;
}
}
@@ -1292,20 +1299,21 @@ static eContextResult screen_ctx_ui_list(const bContext *C, bContextDataResult *
/* Registry of context callback functions. */
typedef eContextResult (*context_callback)(const bContext *C, bContextDataResult *result);
static GHash *ed_screen_context_functions = NULL;
static GHash *ed_screen_context_functions = nullptr;
static void free_context_function_ghash(void *UNUSED(user_data))
static void free_context_function_ghash(void * /*user_data*/)
{
BLI_ghash_free(ed_screen_context_functions, NULL, NULL);
BLI_ghash_free(ed_screen_context_functions, nullptr, nullptr);
}
static inline void register_context_function(const char *member, context_callback function)
{
BLI_ghash_insert(ed_screen_context_functions, (void *)member, function);
BLI_ghash_insert(
ed_screen_context_functions, (void *)member, reinterpret_cast<void *>(function));
}
static void ensure_ed_screen_context_functions(void)
{
if (ed_screen_context_functions != NULL) {
if (ed_screen_context_functions != nullptr) {
return;
}
@@ -1313,7 +1321,7 @@ static void ensure_ed_screen_context_functions(void)
ed_screen_context_functions = BLI_ghash_new(
BLI_ghashutil_strhash_p_murmur, BLI_ghashutil_strcmp, __func__);
BKE_blender_atexit_register(free_context_function_ghash, NULL);
BKE_blender_atexit_register(free_context_function_ghash, nullptr);
register_context_function("scene", screen_ctx_scene);
register_context_function("visible_objects", screen_ctx_visible_objects);
@@ -1383,8 +1391,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
ensure_ed_screen_context_functions();
context_callback callback = BLI_ghash_lookup(ed_screen_context_functions, member);
if (callback == NULL) {
context_callback callback = reinterpret_cast<context_callback>(
BLI_ghash_lookup(ed_screen_context_functions, member));
if (callback == nullptr) {
return CTX_RESULT_MEMBER_NOT_FOUND;
}

View File

@@ -17,6 +17,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_math_vector.hh"
#include "BLI_rect.h"
#include "WM_api.h"
@@ -52,20 +53,20 @@ static void do_vert_pair(GPUVertBuf *vbo, uint pos, uint *vidx, int corner, int
switch (corner) {
case 0:
add_v2_v2(inter, (float[2]){-1.0f, -1.0f});
add_v2_v2(exter, (float[2]){-1.0f, -1.0f});
add_v2_v2(inter, blender::float2{-1.0f, -1.0f});
add_v2_v2(exter, blender::float2{-1.0f, -1.0f});
break;
case 1:
add_v2_v2(inter, (float[2]){1.0f, -1.0f});
add_v2_v2(exter, (float[2]){1.0f, -1.0f});
add_v2_v2(inter, blender::float2{1.0f, -1.0f});
add_v2_v2(exter, blender::float2{1.0f, -1.0f});
break;
case 2:
add_v2_v2(inter, (float[2]){1.0f, 1.0f});
add_v2_v2(exter, (float[2]){1.0f, 1.0f});
add_v2_v2(inter, blender::float2{1.0f, 1.0f});
add_v2_v2(exter, blender::float2{1.0f, 1.0f});
break;
case 3:
add_v2_v2(inter, (float[2]){-1.0f, 1.0f});
add_v2_v2(exter, (float[2]){-1.0f, 1.0f});
add_v2_v2(inter, blender::float2{-1.0f, 1.0f});
add_v2_v2(exter, blender::float2{-1.0f, 1.0f});
break;
}
@@ -75,9 +76,9 @@ static void do_vert_pair(GPUVertBuf *vbo, uint pos, uint *vidx, int corner, int
static GPUBatch *batch_screen_edges_get(int *corner_len)
{
static GPUBatch *screen_edges_batch = NULL;
static GPUBatch *screen_edges_batch = nullptr;
if (screen_edges_batch == NULL) {
if (screen_edges_batch == nullptr) {
GPUVertFormat format = {0};
uint pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -93,7 +94,7 @@ static GPUBatch *batch_screen_edges_get(int *corner_len)
/* close the loop */
do_vert_pair(vbo, pos, &vidx, 0, 0);
screen_edges_batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
screen_edges_batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, nullptr, GPU_BATCH_OWNS_VBO);
gpu_batch_presets_register(screen_edges_batch);
}
@@ -131,7 +132,7 @@ static void drawscredge_area_draw(
rect.ymin -= edge_thickness * 0.5f;
}
GPUBatch *batch = batch_screen_edges_get(NULL);
GPUBatch *batch = batch_screen_edges_get(nullptr);
GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_AREA_BORDERS);
GPU_batch_uniform_4fv(batch, "rect", (float *)&rect);
GPU_batch_draw(batch);
@@ -171,8 +172,8 @@ void ED_screen_draw_edges(wmWindow *win)
rcti scissor_rect;
BLI_rcti_init_minmax(&scissor_rect);
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
BLI_rcti_do_minmax_v(&scissor_rect, (int[2]){area->v1->vec.x, area->v1->vec.y});
BLI_rcti_do_minmax_v(&scissor_rect, (int[2]){area->v3->vec.x, area->v3->vec.y});
BLI_rcti_do_minmax_v(&scissor_rect, blender::int2{area->v1->vec.x, area->v1->vec.y});
BLI_rcti_do_minmax_v(&scissor_rect, blender::int2{area->v3->vec.x, area->v3->vec.y});
}
if (GPU_type_matches_ex(GPU_DEVICE_INTEL_UHD, GPU_OS_UNIX, GPU_DRIVER_ANY, GPU_BACKEND_OPENGL)) {
@@ -225,16 +226,15 @@ void screen_draw_join_highlight(ScrArea *sa1, ScrArea *sa2)
/* Rect of the combined areas. */
const bool vertical = SCREEN_DIR_IS_VERTICAL(dir);
const rctf combined = {
.xmin = vertical ? MAX2(sa1->totrct.xmin, sa2->totrct.xmin) :
MIN2(sa1->totrct.xmin, sa2->totrct.xmin),
.xmax = vertical ? MIN2(sa1->totrct.xmax, sa2->totrct.xmax) :
MAX2(sa1->totrct.xmax, sa2->totrct.xmax),
.ymin = vertical ? MIN2(sa1->totrct.ymin, sa2->totrct.ymin) :
MAX2(sa1->totrct.ymin, sa2->totrct.ymin),
.ymax = vertical ? MAX2(sa1->totrct.ymax, sa2->totrct.ymax) :
MIN2(sa1->totrct.ymax, sa2->totrct.ymax),
};
rctf combined{};
combined.xmin = vertical ? MAX2(sa1->totrct.xmin, sa2->totrct.xmin) :
MIN2(sa1->totrct.xmin, sa2->totrct.xmin);
combined.xmax = vertical ? MIN2(sa1->totrct.xmax, sa2->totrct.xmax) :
MAX2(sa1->totrct.xmax, sa2->totrct.xmax);
combined.ymin = vertical ? MIN2(sa1->totrct.ymin, sa2->totrct.ymin) :
MAX2(sa1->totrct.ymin, sa2->totrct.ymin);
combined.ymax = vertical ? MAX2(sa1->totrct.ymax, sa2->totrct.ymax) :
MIN2(sa1->totrct.ymax, sa2->totrct.ymax);
uint pos_id = GPU_vertformat_attr_add(
immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -242,7 +242,7 @@ void screen_draw_join_highlight(ScrArea *sa1, ScrArea *sa2)
GPU_blend(GPU_BLEND_ALPHA);
/* Highlight source (sa1) within combined area. */
immUniformColor4fv((const float[4]){1.0f, 1.0f, 1.0f, 0.10f});
immUniformColor4fv(blender::float4{1.0f, 1.0f, 1.0f, 0.10f});
immRectf(pos_id,
MAX2(sa1->totrct.xmin, combined.xmin),
MAX2(sa1->totrct.ymin, combined.ymin),
@@ -250,7 +250,7 @@ void screen_draw_join_highlight(ScrArea *sa1, ScrArea *sa2)
MIN2(sa1->totrct.ymax, combined.ymax));
/* Highlight destination (sa2) within combined area. */
immUniformColor4fv((const float[4]){0.0f, 0.0f, 0.0f, 0.25f});
immUniformColor4fv(blender::float4{0.0f, 0.0f, 0.0f, 0.25f});
immRectf(pos_id,
MAX2(sa2->totrct.xmin, combined.xmin),
MAX2(sa2->totrct.ymin, combined.ymin),
@@ -262,7 +262,7 @@ void screen_draw_join_highlight(ScrArea *sa1, ScrArea *sa2)
area_getoffsets(sa1, sa2, dir, &offset1, &offset2);
if (offset1 < 0 || offset2 > 0) {
/* Show partial areas that will be closed. */
immUniformColor4fv((const float[4]){0.0f, 0.0f, 0.0f, 0.8f});
immUniformColor4fv(blender::float4{0.0f, 0.0f, 0.0f, 0.8f});
if (vertical) {
if (sa1->totrct.xmin < combined.xmin) {
immRectf(pos_id, sa1->totrct.xmin, sa1->totrct.ymin, combined.xmin, sa1->totrct.ymax);
@@ -298,7 +298,7 @@ void screen_draw_join_highlight(ScrArea *sa1, ScrArea *sa2)
/* Outline the combined area. */
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_draw_roundbox_4fv(&combined, false, 7 * U.pixelsize, (float[4]){1.0f, 1.0f, 1.0f, 0.8f});
UI_draw_roundbox_4fv(&combined, false, 7 * U.pixelsize, blender::float4{1.0f, 1.0f, 1.0f, 0.8f});
}
void screen_draw_split_preview(ScrArea *area, const eScreenAxis dir_axis, const float fac)
@@ -386,12 +386,11 @@ static void screen_preview_draw_areas(const bScreen *screen,
immUniformColor4fv(col);
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
rctf rect = {
.xmin = area->totrct.xmin * scale[0] + ofs_h,
.xmax = area->totrct.xmax * scale[0] - ofs_h,
.ymin = area->totrct.ymin * scale[1] + ofs_h,
.ymax = area->totrct.ymax * scale[1] - ofs_h,
};
rctf rect{};
rect.xmin = area->totrct.xmin * scale[0] + ofs_h;
rect.xmax = area->totrct.xmax * scale[0] - ofs_h;
rect.ymin = area->totrct.ymin * scale[1] + ofs_h;
rect.ymax = area->totrct.ymax * scale[1] - ofs_h;
immBegin(GPU_PRIM_TRI_FAN, 4);
immVertex2f(pos, rect.xmin, rect.ymin);

View File

@@ -56,7 +56,7 @@ static ScrArea *screen_addarea_ex(ScrAreaMap *area_map,
ScrVert *bottom_right,
const eSpace_Type space_type)
{
ScrArea *area = MEM_callocN(sizeof(ScrArea), "addscrarea");
ScrArea *area = static_cast<ScrArea *>(MEM_callocN(sizeof(ScrArea), "addscrarea"));
area->v1 = bottom_left;
area->v2 = top_left;
@@ -97,10 +97,10 @@ ScrArea *area_split(const wmWindow *win,
const float fac,
const bool merge)
{
ScrArea *newa = NULL;
ScrArea *newa = nullptr;
if (area == NULL) {
return NULL;
if (area == nullptr) {
return nullptr;
}
rcti window_rect;
@@ -108,7 +108,7 @@ ScrArea *area_split(const wmWindow *win,
short split = screen_geom_find_area_split_point(area, &window_rect, dir_axis, fac);
if (split == 0) {
return NULL;
return nullptr;
}
/* NOTE(@ideasman42): regarding (fac > 0.5f) checks below.
@@ -129,7 +129,7 @@ ScrArea *area_split(const wmWindow *win,
if (fac > 0.5f) {
/* new areas: top */
newa = screen_addarea(screen, sv1, area->v2, area->v3, sv2, area->spacetype);
newa = screen_addarea(screen, sv1, area->v2, area->v3, sv2, eSpace_Type(area->spacetype));
/* area below */
area->v2 = sv1;
@@ -137,7 +137,7 @@ ScrArea *area_split(const wmWindow *win,
}
else {
/* new areas: bottom */
newa = screen_addarea(screen, area->v1, sv1, sv2, area->v4, area->spacetype);
newa = screen_addarea(screen, area->v1, sv1, sv2, area->v4, eSpace_Type(area->spacetype));
/* area above */
area->v1 = sv1;
@@ -160,7 +160,7 @@ ScrArea *area_split(const wmWindow *win,
if (fac > 0.5f) {
/* new areas: right */
newa = screen_addarea(screen, sv1, sv2, area->v3, area->v4, area->spacetype);
newa = screen_addarea(screen, sv1, sv2, area->v3, area->v4, eSpace_Type(area->spacetype));
/* area left */
area->v3 = sv2;
@@ -168,7 +168,7 @@ ScrArea *area_split(const wmWindow *win,
}
else {
/* new areas: left */
newa = screen_addarea(screen, area->v1, area->v2, sv2, sv1, area->spacetype);
newa = screen_addarea(screen, area->v1, area->v2, sv2, sv1, eSpace_Type(area->spacetype));
/* area right */
area->v1 = sv1;
@@ -190,7 +190,7 @@ ScrArea *area_split(const wmWindow *win,
bScreen *screen_add(Main *bmain, const char *name, const rcti *rect)
{
bScreen *screen = BKE_libblock_alloc(bmain, ID_SCR, name, 0);
bScreen *screen = static_cast<bScreen *>(BKE_libblock_alloc(bmain, ID_SCR, name, 0));
screen->do_refresh = true;
screen->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN;
@@ -222,8 +222,9 @@ void screen_data_copy(bScreen *to, bScreen *from)
BLI_duplicatelist(&to->areabase, &from->areabase);
BLI_listbase_clear(&to->regionbase);
ScrVert *s2 = to->vertbase.first;
for (ScrVert *s1 = from->vertbase.first; s1; s1 = s1->next, s2 = s2->next) {
ScrVert *s2 = static_cast<ScrVert *>(to->vertbase.first);
for (ScrVert *s1 = static_cast<ScrVert *>(from->vertbase.first); s1;
s1 = s1->next, s2 = s2->next) {
s1->newv = s2;
}
@@ -233,7 +234,7 @@ void screen_data_copy(bScreen *to, bScreen *from)
BKE_screen_sort_scrvert(&(se->v1), &(se->v2));
}
ScrArea *from_area = from->areabase.first;
ScrArea *from_area = static_cast<ScrArea *>(from->areabase.first);
LISTBASE_FOREACH (ScrArea *, area, &to->areabase) {
area->v1 = area->v1->newv;
area->v2 = area->v2->newv;
@@ -252,7 +253,7 @@ void screen_data_copy(bScreen *to, bScreen *from)
/* put at zero (needed?) */
LISTBASE_FOREACH (ScrVert *, s1, &from->vertbase) {
s1->newv = NULL;
s1->newv = nullptr;
}
}
@@ -265,7 +266,7 @@ void screen_new_activate_prepare(const wmWindow *win, bScreen *screen_new)
eScreenDir area_getorientation(ScrArea *sa_a, ScrArea *sa_b)
{
if (sa_a == NULL || sa_b == NULL || sa_a == sa_b) {
if (sa_a == nullptr || sa_b == nullptr || sa_a == sa_b) {
return SCREEN_DIR_NONE;
}
@@ -288,25 +289,25 @@ eScreenDir area_getorientation(ScrArea *sa_a, ScrArea *sa_b)
const short miny = MIN3(AREAJOINTOLERANCEY, top_a - bottom_a, top_b - bottom_b);
if (top_a == bottom_b && overlapx >= minx) {
return 1; /* sa_a to bottom of sa_b = N */
return eScreenDir(1); /* sa_a to bottom of sa_b = N */
}
if (bottom_a == top_b && overlapx >= minx) {
return 3; /* sa_a on top of sa_b = S */
return eScreenDir(3); /* sa_a on top of sa_b = S */
}
if (left_a == right_b && overlapy >= miny) {
return 0; /* sa_a to right of sa_b = W */
return eScreenDir(0); /* sa_a to right of sa_b = W */
}
if (right_a == left_b && overlapy >= miny) {
return 2; /* sa_a to left of sa_b = E */
return eScreenDir(2); /* sa_a to left of sa_b = E */
}
return -1;
return eScreenDir(-1);
}
void area_getoffsets(
ScrArea *sa_a, ScrArea *sa_b, const eScreenDir dir, int *r_offset1, int *r_offset2)
{
if (sa_a == NULL || sa_b == NULL) {
if (sa_a == nullptr || sa_b == nullptr) {
*r_offset1 = INT_MAX;
*r_offset2 = INT_MAX;
}
@@ -503,7 +504,7 @@ static ScrArea *screen_area_trim(
{
const bool vertical = SCREEN_DIR_IS_VERTICAL(dir);
if (abs(size) < (vertical ? AREAJOINTOLERANCEX : AREAJOINTOLERANCEY)) {
return NULL;
return nullptr;
}
/* Measurement with ScrVerts because winx and winy might not be correct at this time. */
@@ -562,17 +563,17 @@ int screen_area_join(bContext *C, bScreen *screen, ScrArea *sa1, ScrArea *sa2)
bool screen_area_close(bContext *C, bScreen *screen, ScrArea *area)
{
if (area == NULL) {
if (area == nullptr) {
return false;
}
ScrArea *sa2 = NULL;
ScrArea *sa2 = nullptr;
float best_alignment = 0.0f;
LISTBASE_FOREACH (ScrArea *, neighbor, &screen->areabase) {
const eScreenDir dir = area_getorientation(area, neighbor);
/* Must at least partially share an edge and not be a global area. */
if ((dir != SCREEN_DIR_NONE) && (neighbor->global == NULL)) {
if ((dir != SCREEN_DIR_NONE) && (neighbor->global == nullptr)) {
/* Winx/Winy might not be updated yet, so get lengths from verts. */
const bool vertical = SCREEN_DIR_IS_VERTICAL(dir);
const int area_length = vertical ? (area->v3->vec.x - area->v1->vec.x) :
@@ -693,19 +694,20 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
/* prevent multiwin errors */
screen->winid = win->winid;
screen->context = ed_screen_context;
screen->context = reinterpret_cast<void *>(ed_screen_context);
}
void ED_screens_init(Main *bmain, wmWindowManager *wm)
{
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (BKE_workspace_active_get(win->workspace_hook) == NULL) {
BKE_workspace_active_set(win->workspace_hook, bmain->workspaces.first);
if (BKE_workspace_active_get(win->workspace_hook) == nullptr) {
BKE_workspace_active_set(win->workspace_hook,
static_cast<WorkSpace *>(bmain->workspaces.first));
}
ED_screen_refresh(wm, win);
if (win->eventstate) {
ED_screen_set_active_region(NULL, win, win->eventstate->xy);
ED_screen_set_active_region(nullptr, win, win->eventstate->xy);
}
}
@@ -802,14 +804,14 @@ void ED_region_exit(bContext *C, ARegion *region)
CTX_wm_region_set(C, region);
WM_event_remove_handlers(C, &region->handlers);
WM_event_modal_handler_region_replace(win, region, NULL);
WM_event_modal_handler_region_replace(win, region, nullptr);
WM_draw_region_free(region, true);
MEM_SAFE_FREE(region->headerstr);
if (region->regiontimer) {
WM_event_timer_remove(wm, win, region->regiontimer);
region->regiontimer = NULL;
region->regiontimer = nullptr;
}
WM_msgbus_clear_by_owner(wm->message_bus, region);
@@ -834,7 +836,7 @@ void ED_area_exit(bContext *C, ScrArea *area)
}
WM_event_remove_handlers(C, &area->handlers);
WM_event_modal_handler_area_replace(win, area, NULL);
WM_event_modal_handler_area_replace(win, area, nullptr);
CTX_wm_area_set(C, prevsa);
}
@@ -854,10 +856,10 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
Scene *scene_eval = (Scene *)DEG_get_evaluated_id(depsgraph, &scene->id);
BKE_sound_stop_scene(scene_eval);
}
screen->animtimer = NULL;
screen->animtimer = nullptr;
screen->scrubbing = false;
screen->active_region = NULL;
screen->active_region = nullptr;
LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
ED_region_exit(C, region);
@@ -879,7 +881,7 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
}
else {
/* none otherwise */
CTX_wm_window_set(C, NULL);
CTX_wm_window_set(C, nullptr);
}
}
@@ -889,8 +891,8 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
static void screen_cursor_set(wmWindow *win, const int xy[2])
{
const bScreen *screen = WM_window_get_active_screen(win);
AZone *az = NULL;
ScrArea *area = NULL;
AZone *az = nullptr;
ScrArea *area = nullptr;
LISTBASE_FOREACH (ScrArea *, area_iter, &screen->areabase) {
if ((az = ED_area_actionzone_find_xy(area_iter, xy))) {
@@ -932,11 +934,11 @@ static void screen_cursor_set(wmWindow *win, const int xy[2])
void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
{
bScreen *screen = WM_window_get_active_screen(win);
if (screen == NULL) {
if (screen == nullptr) {
return;
}
ScrArea *area = NULL;
ScrArea *area = nullptr;
ARegion *region_prev = screen->active_region;
ED_screen_areas_iter (win, screen, area_iter) {
@@ -946,7 +948,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
if (xy[1] > (area_iter->totrct.ymin + BORDERPADDING) &&
xy[1] < (area_iter->totrct.ymax - BORDERPADDING))
{
if (ED_area_azones_update(area_iter, xy) == NULL) {
if (ED_area_azones_update(area_iter, xy) == nullptr) {
area = area_iter;
break;
}
@@ -963,7 +965,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
}
}
else {
screen->active_region = NULL;
screen->active_region = nullptr;
}
/* Check for redraw headers. */
@@ -981,7 +983,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
if (region == region_prev && region != screen->active_region) {
wmGizmoMap *gzmap = region_prev->gizmo_map;
if (gzmap) {
if (WM_gizmo_highlight_set(gzmap, NULL)) {
if (WM_gizmo_highlight_set(gzmap, nullptr)) {
ED_region_tag_redraw_no_rebuild(region_prev);
}
}
@@ -1002,13 +1004,14 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
}
/* Ensure test-motion values are never shared between regions. */
const bool use_cycle = !WM_cursor_test_motion_and_update((const int[2]){-1, -1});
const int mval[2] = {-1, -1};
const bool use_cycle = !WM_cursor_test_motion_and_update(mval);
UNUSED_VARS(use_cycle);
}
/* Cursors, for time being set always on edges,
* otherwise the active region doesn't switch. */
if (screen->active_region == NULL) {
if (screen->active_region == nullptr) {
screen_cursor_set(win, xy);
}
else {
@@ -1095,7 +1098,7 @@ static void screen_global_area_refresh(wmWindow *win,
return;
}
ScrArea *area = NULL;
ScrArea *area = nullptr;
LISTBASE_FOREACH (ScrArea *, area_iter, &win->global_areas.areabase) {
if (area_iter->spacetype == space_type) {
area = area_iter;
@@ -1111,7 +1114,7 @@ static void screen_global_area_refresh(wmWindow *win,
screen_area_spacelink_add(WM_window_get_active_scene(win), area, space_type);
/* Data specific to global areas. */
area->global = MEM_callocN(sizeof(*area->global), __func__);
area->global = static_cast<ScrGlobalAreaData *>(MEM_callocN(sizeof(*area->global), __func__));
area->global->size_max = height_max;
area->global->size_min = height_min;
area->global->align = align;
@@ -1176,7 +1179,7 @@ void ED_screen_global_areas_refresh(wmWindow *win)
{
/* Don't create global area for child and temporary windows. */
bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
if ((win->parent != NULL) || screen->temp) {
if ((win->parent != nullptr) || screen->temp) {
if (win->global_areas.areabase.first) {
screen->do_refresh = true;
BKE_screen_area_map_free(&win->global_areas);
@@ -1206,7 +1209,7 @@ void screen_change_prepare(
}
/* we put timer to sleep, so screen_exit has to think there's no timer */
screen_old->animtimer = NULL;
screen_old->animtimer = nullptr;
if (wt) {
WM_event_timer_sleep(CTX_wm_manager(C), win, wt, true);
}
@@ -1230,7 +1233,7 @@ void screen_change_update(bContext *C, wmWindow *win, bScreen *screen)
ED_screen_refresh(CTX_wm_manager(C), win);
BKE_screen_view3d_scene_sync(screen, scene); /* sync new screen with scene data */
WM_event_add_notifier(C, NC_WINDOW, NULL);
WM_event_add_notifier(C, NC_WINDOW, nullptr);
WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTSET, layout);
/* Makes button highlights work. */
@@ -1288,7 +1291,7 @@ static void screen_set_3dview_camera(Scene *scene,
LISTBASE_FOREACH (ARegion *, region, regionbase) {
if (region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
if (rv3d->persp == RV3D_CAMOB) {
rv3d->persp = RV3D_PERSP;
}
@@ -1304,7 +1307,7 @@ void ED_screen_scene_change(bContext *C,
const bool refresh_toolsystem)
{
#if 0
ViewLayer *view_layer_old = WM_window_get_active_view_layer(win);
ViewLayer *view_layer_old = WM_window_get_active_view_layer(win);
#endif
/* Switch scene. */
@@ -1347,13 +1350,13 @@ void ED_screen_scene_change(bContext *C,
ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *area, int type)
{
bScreen *newscreen = NULL;
ScrArea *newsa = NULL;
bScreen *newscreen = nullptr;
ScrArea *newsa = nullptr;
SpaceLink *newsl;
if (!area || area->full == NULL) {
if (!area || area->full == nullptr) {
newscreen = ED_screen_state_maximized_create(C);
newsa = newscreen->areabase.first;
newsa = static_cast<ScrArea *>(newscreen->areabase.first);
BLI_assert(newsa->spacetype == SPACE_EMPTY);
}
@@ -1362,7 +1365,7 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *area, int type)
}
BLI_assert(newsa);
newsl = newsa->spacedata.first;
newsl = static_cast<SpaceLink *>(newsa->spacedata.first);
/* Tag the active space before changing, so we can identify it when user wants to go back. */
if (newsl && (newsl->link_flag & SPACE_FLAG_TYPE_TEMPORARY) == 0) {
@@ -1393,7 +1396,7 @@ void ED_screen_full_prevspace(bContext *C, ScrArea *area)
void ED_screen_restore_temp_type(bContext *C, ScrArea *area)
{
SpaceLink *sl = area->spacedata.first;
SpaceLink *sl = static_cast<SpaceLink *>(area->spacedata.first);
/* In case nether functions below run. */
ED_area_tag_redraw(area);
@@ -1410,7 +1413,7 @@ void ED_screen_restore_temp_type(bContext *C, ScrArea *area)
void ED_screen_full_restore(bContext *C, ScrArea *area)
{
wmWindow *win = CTX_wm_window(C);
SpaceLink *sl = area->spacedata.first;
SpaceLink *sl = static_cast<SpaceLink *>(area->spacedata.first);
bScreen *screen = CTX_wm_screen(C);
short state = (screen ? screen->state : SCREENMAXIMIZED);
@@ -1471,7 +1474,7 @@ static bScreen *screen_state_to_nonnormal(bContext *C,
/* timer */
screen->animtimer = oldscreen->animtimer;
oldscreen->animtimer = NULL;
oldscreen->animtimer = nullptr;
newa = (ScrArea *)screen->areabase.first;
@@ -1516,7 +1519,7 @@ static bScreen *screen_state_to_nonnormal(bContext *C,
bScreen *ED_screen_state_maximized_create(bContext *C)
{
return screen_state_to_nonnormal(C, CTX_wm_window(C), NULL, SCREENMAXIMIZED);
return screen_state_to_nonnormal(C, CTX_wm_window(C), nullptr, SCREENMAXIMIZED);
}
ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const short state)
@@ -1531,14 +1534,14 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
UI_blocklist_free(C, region);
if (region->regiontimer) {
WM_event_timer_remove(wm, NULL, region->regiontimer);
region->regiontimer = NULL;
WM_event_timer_remove(wm, nullptr, region->regiontimer);
region->regiontimer = nullptr;
}
}
/* prevent hanging status prints */
ED_area_status_text(area, NULL);
ED_workspace_status_text(C, NULL);
ED_area_status_text(area, nullptr);
ED_workspace_status_text(C, nullptr);
}
bScreen *screen;
if (area && area->full) {
@@ -1554,7 +1557,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
screen->flag = oldscreen->flag;
/* Find old area we may have swapped dummy space data to. It's swapped back here. */
ScrArea *fullsa = NULL;
ScrArea *fullsa = nullptr;
LISTBASE_FOREACH (ScrArea *, old, &screen->areabase) {
/* area to restore from is always first */
if (old->full && !fullsa) {
@@ -1562,10 +1565,10 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
}
/* clear full screen state */
old->full = NULL;
old->full = nullptr;
}
area->full = NULL;
area->full = nullptr;
if (state == SCREENFULL) {
/* unhide global areas */
@@ -1585,7 +1588,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
/* animtimer back */
screen->animtimer = oldscreen->animtimer;
oldscreen->animtimer = NULL;
oldscreen->animtimer = nullptr;
ED_screen_change(C, screen);
@@ -1604,7 +1607,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
* mouse is outside of the window and we open a file browser */
if (!toggle_area || toggle_area->global) {
bScreen *oldscreen = WM_window_get_active_screen(win);
toggle_area = oldscreen->areabase.first;
toggle_area = static_cast<ScrArea *>(oldscreen->areabase.first);
}
screen = screen_state_to_nonnormal(C, win, toggle_area, state);
@@ -1613,7 +1616,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
}
BLI_assert(CTX_wm_screen(C) == screen);
BLI_assert(CTX_wm_area(C) == NULL); /* May have been freed. */
BLI_assert(CTX_wm_area(C) == nullptr); /* May have been freed. */
/* Setting the area is only needed for Python scripts that call
* operators in succession before returning to the main event loop.
@@ -1621,9 +1624,9 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
* an area after toggling full-screen for example (see: #89526).
* NOTE: an old comment stated this was "bad code",
* however it doesn't cause problems so leave as-is. */
CTX_wm_area_set(C, screen->areabase.first);
CTX_wm_area_set(C, static_cast<ScrArea *>(screen->areabase.first));
return screen->areabase.first;
return static_cast<ScrArea *>(screen->areabase.first);
}
ScrArea *ED_screen_temp_space_open(bContext *C,
@@ -1636,7 +1639,7 @@ ScrArea *ED_screen_temp_space_open(bContext *C,
int display_type,
bool dialog)
{
ScrArea *area = NULL;
ScrArea *area = nullptr;
switch (display_type) {
case USER_TEMP_SPACE_DISPLAY_WINDOW:
@@ -1658,7 +1661,7 @@ ScrArea *ED_screen_temp_space_open(bContext *C,
case USER_TEMP_SPACE_DISPLAY_FULLSCREEN: {
ScrArea *ctx_area = CTX_wm_area(C);
if (ctx_area != NULL && ctx_area->full) {
if (ctx_area != nullptr && ctx_area->full) {
area = ctx_area;
ED_area_newspace(C, ctx_area, space_type, true);
area->flag |= AREA_FLAG_STACKED_FULLSCREEN;
@@ -1682,12 +1685,13 @@ void ED_refresh_viewport_fps(bContext *C)
/* is anim playback running? */
if (animtimer && (U.uiflag & USER_SHOW_FPS)) {
ScreenFrameRateInfo *fpsi = scene->fps_info;
ScreenFrameRateInfo *fpsi = static_cast<ScreenFrameRateInfo *>(scene->fps_info);
/* if there isn't any info, init it first */
if (fpsi == NULL) {
fpsi = scene->fps_info = MEM_callocN(sizeof(ScreenFrameRateInfo),
"refresh_viewport_fps fps_info");
if (fpsi == nullptr) {
fpsi = static_cast<ScreenFrameRateInfo *>(
scene->fps_info = MEM_callocN(sizeof(ScreenFrameRateInfo),
"refresh_viewport_fps fps_info"));
}
/* update the values */
@@ -1710,11 +1714,12 @@ void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable)
if (stopscreen) {
WM_event_timer_remove(wm, win, stopscreen->animtimer);
stopscreen->animtimer = NULL;
stopscreen->animtimer = nullptr;
}
if (enable) {
ScreenAnimData *sad = MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData");
ScreenAnimData *sad = static_cast<ScreenAnimData *>(
MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData"));
screen->animtimer = WM_event_timer_add(wm, win, TIMER0, (1.0 / FPS));
@@ -1760,13 +1765,13 @@ void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable)
}
/* Notifier caught by top header, for button. */
WM_event_add_notifier(C, NC_SCREEN | ND_ANIMPLAY, NULL);
WM_event_add_notifier(C, NC_SCREEN | ND_ANIMPLAY, nullptr);
}
/* helper for screen_animation_play() - only to be used for TimeLine */
static ARegion *time_top_left_3dwindow(bScreen *screen)
{
ARegion *region_top_left = NULL;
ARegion *region_top_left = nullptr;
int min = 10000;
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
@@ -1789,10 +1794,10 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws)
{
if (screen && screen->animtimer) {
wmTimer *wt = screen->animtimer;
ScreenAnimData *sad = wt->customdata;
ScreenAnimData *sad = static_cast<ScreenAnimData *>(wt->customdata);
sad->redraws = redraws;
sad->region = NULL;
sad->region = nullptr;
if (redraws & TIME_REGION) {
sad->region = time_top_left_3dwindow(screen);
}
@@ -1808,7 +1813,7 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph)
#ifdef DURIAN_CAMERA_SWITCH
void *camera = BKE_scene_camera_switch_find(scene);
if (camera && scene->camera != camera) {
scene->camera = camera;
scene->camera = static_cast<Object *>(camera);
/* are there cameras in the views that are not in the scene? */
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
BKE_screen_view3d_scene_sync(screen, scene);
@@ -1836,11 +1841,11 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
continue;
}
v3d = area->spacedata.first;
v3d = static_cast<View3D *>(area->spacedata.first);
if (v3d->camera && v3d->stereo3d_camera == STEREO_3D_ID) {
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiondata && region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
if (rv3d->persp == RV3D_CAMOB) {
return true;
}
@@ -1854,7 +1859,7 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
/* images should always show in stereo, even if
* the file doesn't have views enabled */
sima = area->spacedata.first;
sima = static_cast<SpaceImage *>(area->spacedata.first);
if (sima->image && BKE_image_is_stereo(sima->image) &&
(sima->iuser.flag & IMA_SHOW_STEREO)) {
return true;
@@ -1868,7 +1873,7 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
continue;
}
snode = area->spacedata.first;
snode = static_cast<SpaceNode *>(area->spacedata.first);
if ((snode->flag & SNODE_BACKDRAW) && ED_node_is_compositor(snode)) {
return true;
}
@@ -1881,7 +1886,7 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
continue;
}
sseq = area->spacedata.first;
sseq = static_cast<SpaceSeq *>(area->spacedata.first);
if (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW)) {
return true;
}
@@ -1911,8 +1916,8 @@ Scene *ED_screen_scene_find_with_window(const bScreen *screen,
}
}
/* Can by NULL when accessing a screen that isn't active. */
return NULL;
/* Can by nullptr when accessing a screen that isn't active. */
return nullptr;
}
ScrArea *ED_screen_area_find_with_spacedata(const bScreen *screen,
@@ -1933,12 +1938,12 @@ ScrArea *ED_screen_area_find_with_spacedata(const bScreen *screen,
}
}
}
return NULL;
return nullptr;
}
Scene *ED_screen_scene_find(const bScreen *screen, const wmWindowManager *wm)
{
return ED_screen_scene_find_with_window(screen, wm, NULL);
return ED_screen_scene_find_with_window(screen, wm, nullptr);
}
wmWindow *ED_screen_window_find(const bScreen *screen, const wmWindowManager *wm)
@@ -1948,5 +1953,5 @@ wmWindow *ED_screen_window_find(const bScreen *screen, const wmWindowManager *wm
return win;
}
}
return NULL;
return nullptr;
}

View File

@@ -38,7 +38,7 @@ int screen_geom_area_width(const ScrArea *area)
ScrVert *screen_geom_vertex_add_ex(ScrAreaMap *area_map, short x, short y)
{
ScrVert *sv = MEM_callocN(sizeof(ScrVert), "addscrvert");
ScrVert *sv = static_cast<ScrVert *>(MEM_callocN(sizeof(ScrVert), "addscrvert"));
sv->vec.x = x;
sv->vec.y = y;
@@ -52,7 +52,7 @@ ScrVert *screen_geom_vertex_add(bScreen *screen, short x, short y)
ScrEdge *screen_geom_edge_add_ex(ScrAreaMap *area_map, ScrVert *v1, ScrVert *v2)
{
ScrEdge *se = MEM_callocN(sizeof(ScrEdge), "addscredge");
ScrEdge *se = static_cast<ScrEdge *>(MEM_callocN(sizeof(ScrEdge), "addscredge"));
BKE_screen_sort_scrvert(&v1, &v2);
se->v1 = v1;
@@ -105,7 +105,7 @@ ScrEdge *screen_geom_area_map_find_active_scredge(const ScrAreaMap *area_map,
}
}
return NULL;
return nullptr;
}
ScrEdge *screen_geom_find_active_scredge(const wmWindow *win,
@@ -114,7 +114,7 @@ ScrEdge *screen_geom_find_active_scredge(const wmWindow *win,
const int my)
{
if (U.app_flag & USER_APP_LOCK_EDGE_RESIZE) {
return NULL;
return nullptr;
}
/* Use layout size (screen excluding global areas) for screen-layout area edges */

View File

@@ -92,13 +92,13 @@
bool ED_operator_regionactive(bContext *C)
{
if (CTX_wm_window(C) == NULL) {
if (CTX_wm_window(C) == nullptr) {
return false;
}
if (CTX_wm_screen(C) == NULL) {
if (CTX_wm_screen(C) == nullptr) {
return false;
}
if (CTX_wm_region(C) == NULL) {
if (CTX_wm_region(C) == nullptr) {
return false;
}
return true;
@@ -106,13 +106,13 @@ bool ED_operator_regionactive(bContext *C)
bool ED_operator_areaactive(bContext *C)
{
if (CTX_wm_window(C) == NULL) {
if (CTX_wm_window(C) == nullptr) {
return false;
}
if (CTX_wm_screen(C) == NULL) {
if (CTX_wm_screen(C) == nullptr) {
return false;
}
if (CTX_wm_area(C) == NULL) {
if (CTX_wm_area(C) == nullptr) {
return false;
}
return true;
@@ -120,10 +120,10 @@ bool ED_operator_areaactive(bContext *C)
bool ED_operator_screenactive(bContext *C)
{
if (CTX_wm_window(C) == NULL) {
if (CTX_wm_window(C) == nullptr) {
return false;
}
if (CTX_wm_screen(C) == NULL) {
if (CTX_wm_screen(C) == nullptr) {
return false;
}
return true;
@@ -143,10 +143,10 @@ static bool ED_operator_screenactive_norender(bContext *C)
if (G.is_rendering) {
return false;
}
if (CTX_wm_window(C) == NULL) {
if (CTX_wm_window(C) == nullptr) {
return false;
}
if (CTX_wm_screen(C) == NULL) {
if (CTX_wm_screen(C) == nullptr) {
return false;
}
return true;
@@ -154,14 +154,14 @@ static bool ED_operator_screenactive_norender(bContext *C)
bool ED_operator_screen_mainwinactive(bContext *C)
{
if (CTX_wm_window(C) == NULL) {
if (CTX_wm_window(C) == nullptr) {
return false;
}
bScreen *screen = CTX_wm_screen(C);
if (screen == NULL) {
if (screen == nullptr) {
return false;
}
if (screen->active_region != NULL) {
if (screen->active_region != nullptr) {
return false;
}
return true;
@@ -179,7 +179,7 @@ bool ED_operator_scene(bContext *C)
bool ED_operator_scene_editable(bContext *C)
{
Scene *scene = CTX_data_scene(C);
if (scene == NULL || !BKE_id_is_editable(CTX_data_main(C), &scene->id)) {
if (scene == nullptr || !BKE_id_is_editable(CTX_data_main(C), &scene->id)) {
return false;
}
return true;
@@ -190,7 +190,7 @@ bool ED_operator_objectmode(bContext *C)
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
if (scene == NULL || ID_IS_LINKED(scene)) {
if (scene == nullptr || ID_IS_LINKED(scene)) {
return false;
}
if (CTX_data_edit_object(C)) {
@@ -253,11 +253,11 @@ bool ED_operator_region_view3d_active(bContext *C)
bool ED_operator_region_gizmo_active(bContext *C)
{
ARegion *region = CTX_wm_region(C);
if (region == NULL) {
if (region == nullptr) {
return false;
}
wmGizmoMap *gzmap = region->gizmo_map;
if (gzmap == NULL) {
if (gzmap == nullptr) {
return false;
}
return true;
@@ -396,12 +396,12 @@ static bool ed_object_hidden(const Object *ob)
bool ED_operator_object_active(bContext *C)
{
Object *ob = ED_object_active_context(C);
return ((ob != NULL) && !ed_object_hidden(ob));
return ((ob != nullptr) && !ed_object_hidden(ob));
}
bool ED_operator_object_active_editable_ex(bContext *C, const Object *ob)
{
if (ob == NULL) {
if (ob == nullptr) {
CTX_wm_operator_poll_msg_set(C, "Context missing active object");
return false;
}
@@ -439,28 +439,28 @@ bool ED_operator_object_active_local_editable(bContext *C)
bool ED_operator_object_active_editable_mesh(bContext *C)
{
Object *ob = ED_object_active_context(C);
return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob) && (ob->type == OB_MESH) &&
return ((ob != nullptr) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob) && (ob->type == OB_MESH) &&
!ID_IS_LINKED(ob->data) && !ID_IS_OVERRIDE_LIBRARY(ob->data));
}
bool ED_operator_object_active_editable_font(bContext *C)
{
Object *ob = ED_object_active_context(C);
return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob) && (ob->type == OB_FONT) &&
return ((ob != nullptr) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob) && (ob->type == OB_FONT) &&
!ID_IS_LINKED(ob->data) && !ID_IS_OVERRIDE_LIBRARY(ob->data));
}
bool ED_operator_editable_mesh(bContext *C)
{
Mesh *mesh = ED_mesh_context(C);
return (mesh != NULL) && !ID_IS_LINKED(mesh) && !ID_IS_OVERRIDE_LIBRARY(mesh);
return (mesh != nullptr) && !ID_IS_LINKED(mesh) && !ID_IS_OVERRIDE_LIBRARY(mesh);
}
bool ED_operator_editmesh(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
if (obedit && obedit->type == OB_MESH) {
return NULL != BKE_editmesh_from_object(obedit);
return nullptr != BKE_editmesh_from_object(obedit);
}
return false;
}
@@ -484,7 +484,7 @@ bool ED_operator_editmesh_auto_smooth(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
if (obedit && obedit->type == OB_MESH && (((Mesh *)(obedit->data))->flag & ME_AUTOSMOOTH)) {
return NULL != BKE_editmesh_from_object(obedit);
return nullptr != BKE_editmesh_from_object(obedit);
}
return false;
}
@@ -493,7 +493,7 @@ bool ED_operator_editarmature(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
if (obedit && obedit->type == OB_ARMATURE) {
return NULL != ((bArmature *)obedit->data)->edbo;
return nullptr != ((bArmature *)obedit->data)->edbo;
}
return false;
}
@@ -507,7 +507,7 @@ bool ED_operator_editarmature(bContext *C)
*/
static bool ed_operator_posemode_exclusive_ex(bContext *C, Object *obact)
{
if (obact != NULL && !(obact->mode & OB_MODE_EDIT)) {
if (obact != nullptr && !(obact->mode & OB_MODE_EDIT)) {
if (obact == BKE_object_pose_armature_get(obact)) {
return true;
}
@@ -559,7 +559,7 @@ bool ED_operator_posemode(bContext *C)
if (obact && !(obact->mode & OB_MODE_EDIT)) {
Object *obpose = BKE_object_pose_armature_get(obact);
if (obpose != NULL) {
if (obpose != nullptr) {
if ((obact == obpose) || (obact->mode & OB_MODE_ALL_WEIGHT_PAINT)) {
return true;
}
@@ -574,7 +574,7 @@ bool ED_operator_posemode_local(bContext *C)
if (ED_operator_posemode(C)) {
Main *bmain = CTX_data_main(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
bArmature *arm = ob->data;
bArmature *arm = static_cast<bArmature *>(ob->data);
return (BKE_id_is_editable(bmain, &ob->id) && BKE_id_is_editable(bmain, &arm->id));
}
return false;
@@ -597,7 +597,7 @@ bool ED_operator_uvedit_space_image(bContext *C)
bool ED_operator_uvmap(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = NULL;
BMEditMesh *em = nullptr;
if (obedit && obedit->type == OB_MESH) {
em = BKE_editmesh_from_object(obedit);
@@ -614,7 +614,7 @@ bool ED_operator_editsurfcurve(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
if (obedit && ELEM(obedit->type, OB_CURVES_LEGACY, OB_SURF)) {
return NULL != ((Curve *)obedit->data)->editnurb;
return nullptr != ((Curve *)obedit->data)->editnurb;
}
return false;
}
@@ -633,7 +633,7 @@ bool ED_operator_editcurve(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
if (obedit && obedit->type == OB_CURVES_LEGACY) {
return NULL != ((Curve *)obedit->data)->editnurb;
return nullptr != ((Curve *)obedit->data)->editnurb;
}
return false;
}
@@ -644,7 +644,7 @@ bool ED_operator_editcurve_3d(bContext *C)
if (obedit && obedit->type == OB_CURVES_LEGACY) {
Curve *cu = (Curve *)obedit->data;
return (cu->flag & CU_3D) && (NULL != cu->editnurb);
return (cu->flag & CU_3D) && (nullptr != cu->editnurb);
}
return false;
}
@@ -653,7 +653,7 @@ bool ED_operator_editsurf(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
if (obedit && obedit->type == OB_SURF) {
return NULL != ((Curve *)obedit->data)->editnurb;
return nullptr != ((Curve *)obedit->data)->editnurb;
}
return false;
}
@@ -662,7 +662,7 @@ bool ED_operator_editfont(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
if (obedit && obedit->type == OB_FONT) {
return NULL != ((Curve *)obedit->data)->editfont;
return nullptr != ((Curve *)obedit->data)->editfont;
}
return false;
}
@@ -671,7 +671,7 @@ bool ED_operator_editlattice(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
if (obedit && obedit->type == OB_LATTICE) {
return NULL != ((Lattice *)obedit->data)->editlatt;
return nullptr != ((Lattice *)obedit->data)->editlatt;
}
return false;
}
@@ -680,15 +680,16 @@ bool ED_operator_editmball(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
if (obedit && obedit->type == OB_MBALL) {
return NULL != ((MetaBall *)obedit->data)->editelems;
return nullptr != ((MetaBall *)obedit->data)->editelems;
}
return false;
}
bool ED_operator_camera_poll(bContext *C)
{
struct Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data;
return (cam != NULL && !ID_IS_LINKED(cam));
struct Camera *cam = static_cast<Camera *>(
CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data);
return (cam != nullptr && !ID_IS_LINKED(cam));
}
/** \} */
@@ -737,13 +738,13 @@ static bool screen_active_editable(bContext *C)
* call exit() and remove handler when LMB confirm
*/
typedef struct sActionzoneData {
struct sActionzoneData {
ScrArea *sa1, *sa2;
AZone *az;
int x, y;
eScreenDir gesture_dir;
int modifier;
} sActionzoneData;
};
/* quick poll to save operators to be created and handled */
static bool actionzone_area_poll(bContext *C)
@@ -768,7 +769,7 @@ static bool actionzone_area_poll(bContext *C)
/* the debug drawing of the click_rect is in area_draw_azone_fullscreen, keep both in sync */
static void fullscreen_click_rcti_init(
rcti *rect, const short UNUSED(x1), const short UNUSED(y1), const short x2, const short y2)
rcti *rect, const short /*x1*/, const short /*y1*/, const short x2, const short y2)
{
BLI_rcti_init(rect, x2 - U.widget_unit, x2, y2 - U.widget_unit, y2);
}
@@ -842,9 +843,9 @@ static void area_actionzone_get_rect(AZone *az, rcti *rect)
static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const bool test_only)
{
AZone *az = NULL;
AZone *az = nullptr;
for (az = area->actionzones.first; az; az = az->next) {
for (az = static_cast<AZone *>(area->actionzones.first); az; az = az->next) {
rcti az_rect;
area_actionzone_get_rect(az, &az_rect);
if (BLI_rcti_isect_pt_v(&az_rect, xy)) {
@@ -889,7 +890,7 @@ static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const b
}
/* fade in/out but no click */
az = NULL;
az = nullptr;
}
/* XXX force redraw to show/hide the action zone */
@@ -992,11 +993,11 @@ static AZone *screen_actionzone_find_xy(bScreen *screen, const int xy[2])
{
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
AZone *az = area_actionzone_refresh_xy(area, xy, true);
if (az != NULL) {
if (az != nullptr) {
return az;
}
}
return NULL;
return nullptr;
}
/* Returns the area that the azone belongs to */
@@ -1009,7 +1010,7 @@ static ScrArea *screen_actionzone_area(bScreen *screen, const AZone *az)
}
}
}
return NULL;
return nullptr;
}
AZone *ED_area_actionzone_find_xy(ScrArea *area, const int xy[2])
@@ -1048,10 +1049,10 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type)
}
event.val = KM_NOTHING;
event.flag = 0;
event.flag = eWM_EventFlag(0);
event.customdata = op->customdata;
event.customdata_free = true;
op->customdata = NULL;
op->customdata = nullptr;
wm_event_add(win, &event);
}
@@ -1063,12 +1064,13 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* Quick escape - Scroll azones only hide/unhide the scroll-bars,
* they have their own handling. */
if (az == NULL || ELEM(az->type, AZONE_REGION_SCROLL)) {
if (az == nullptr || ELEM(az->type, AZONE_REGION_SCROLL)) {
return OPERATOR_PASS_THROUGH;
}
/* ok we do the action-zone */
sActionzoneData *sad = op->customdata = MEM_callocN(sizeof(sActionzoneData), "sActionzoneData");
sActionzoneData *sad = static_cast<sActionzoneData *>(
op->customdata = MEM_callocN(sizeof(sActionzoneData), "sActionzoneData"));
sad->sa1 = screen_actionzone_area(screen, az);
sad->az = az;
sad->x = event->xy[0];
@@ -1093,7 +1095,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
bScreen *screen = CTX_wm_screen(C);
sActionzoneData *sad = op->customdata;
sActionzoneData *sad = static_cast<sActionzoneData *>(op->customdata);
switch (event->type) {
case MOUSEMOVE: {
@@ -1132,7 +1134,8 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* Have we dragged off the zone and are not on an edge? */
if ((ED_area_actionzone_find_xy(sad->sa1, event->xy) != sad->az) &&
(screen_geom_area_map_find_active_scredge(
AREAMAP_FROM_SCREEN(screen), &screen_rect, event->xy[0], event->xy[1]) == NULL))
AREAMAP_FROM_SCREEN(screen), &screen_rect, event->xy[0], event->xy[1]) ==
nullptr))
{
/* What area are we now in? */
@@ -1210,7 +1213,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
static void actionzone_cancel(bContext *UNUSED(C), wmOperator *op)
static void actionzone_cancel(bContext * /*C*/, wmOperator *op)
{
actionzone_exit(op);
}
@@ -1250,24 +1253,24 @@ static ScrEdge *screen_area_edge_from_cursor(const bContext *C,
WM_window_rect_calc(win, &window_rect);
ScrEdge *actedge = screen_geom_area_map_find_active_scredge(
AREAMAP_FROM_SCREEN(screen), &window_rect, cursor[0], cursor[1]);
*r_sa1 = NULL;
*r_sa2 = NULL;
if (actedge == NULL) {
return NULL;
*r_sa1 = nullptr;
*r_sa2 = nullptr;
if (actedge == nullptr) {
return nullptr;
}
int borderwidth = (4 * UI_SCALE_FAC);
ScrArea *sa1, *sa2;
if (screen_geom_edge_is_horizontal(actedge)) {
sa1 = BKE_screen_find_area_xy(
screen, SPACE_TYPE_ANY, (const int[2]){cursor[0], cursor[1] + borderwidth});
screen, SPACE_TYPE_ANY, blender::int2{cursor[0], cursor[1] + borderwidth});
sa2 = BKE_screen_find_area_xy(
screen, SPACE_TYPE_ANY, (const int[2]){cursor[0], cursor[1] - borderwidth});
screen, SPACE_TYPE_ANY, blender::int2{cursor[0], cursor[1] - borderwidth});
}
else {
sa1 = BKE_screen_find_area_xy(
screen, SPACE_TYPE_ANY, (const int[2]){cursor[0] + borderwidth, cursor[1]});
screen, SPACE_TYPE_ANY, blender::int2{cursor[0] + borderwidth, cursor[1]});
sa2 = BKE_screen_find_area_xy(
screen, SPACE_TYPE_ANY, (const int[2]){cursor[0] - borderwidth, cursor[1]});
screen, SPACE_TYPE_ANY, blender::int2{cursor[0] - borderwidth, cursor[1]});
}
bool isGlobal = ((sa1 && ED_area_is_global(sa1)) || (sa2 && ED_area_is_global(sa2)));
if (!isGlobal) {
@@ -1304,19 +1307,20 @@ static ScrEdge *screen_area_edge_from_cursor(const bContext *C,
* modal() accept modal events while doing it
*/
typedef struct sAreaSwapData {
struct sAreaSwapData {
ScrArea *sa1, *sa2;
} sAreaSwapData;
};
static bool area_swap_init(wmOperator *op, const wmEvent *event)
{
sActionzoneData *sad = event->customdata;
sActionzoneData *sad = static_cast<sActionzoneData *>(event->customdata);
if (sad == NULL || sad->sa1 == NULL) {
if (sad == nullptr || sad->sa1 == nullptr) {
return false;
}
sAreaSwapData *sd = MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData");
sAreaSwapData *sd = static_cast<sAreaSwapData *>(
MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData"));
sd->sa1 = sad->sa1;
sd->sa2 = sad->sa2;
op->customdata = sd;
@@ -1350,7 +1354,7 @@ static int area_swap_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int area_swap_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
sActionzoneData *sad = op->customdata;
sActionzoneData *sad = static_cast<sActionzoneData *>(op->customdata);
switch (event->type) {
case MOUSEMOVE:
@@ -1372,7 +1376,7 @@ static int area_swap_modal(bContext *C, wmOperator *op, const wmEvent *event)
area_swap_exit(C, op);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1391,7 +1395,7 @@ static int area_swap_exec(bContext *C, wmOperator *op)
int cursor[2];
RNA_int_get_array(op->ptr, "cursor", cursor);
screen_area_edge_from_cursor(C, cursor, &sa1, &sa2);
if (sa1 == NULL || sa2 == NULL) {
if (sa1 == nullptr || sa2 == nullptr) {
return OPERATOR_CANCELLED;
}
ED_area_swapspace(C, sa1, sa2);
@@ -1414,7 +1418,7 @@ static void SCREEN_OT_area_swap(wmOperatorType *ot)
/* rna */
RNA_def_int_vector(
ot->srna, "cursor", 2, NULL, INT_MIN, INT_MAX, "Cursor", "", INT_MIN, INT_MAX);
ot->srna, "cursor", 2, nullptr, INT_MIN, INT_MAX, "Cursor", "", INT_MIN, INT_MAX);
}
/** \} */
@@ -1431,8 +1435,8 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ScrArea *area = CTX_wm_area(C);
if (event && event->customdata) {
sActionzoneData *sad = event->customdata;
if (sad == NULL) {
sActionzoneData *sad = static_cast<sActionzoneData *>(event->customdata);
if (sad == nullptr) {
return OPERATOR_PASS_THROUGH;
}
area = sad->sa1;
@@ -1458,7 +1462,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ED_area_tag_redraw((ScrArea *)newsc->areabase.first);
/* screen, areas init */
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
}
else {
BKE_report(op->reports, RPT_ERROR, "Failed to open window!");
@@ -1517,9 +1521,9 @@ static int area_close_exec(bContext *C, wmOperator *op)
* This causes execution from the Python console fail to return to the prompt as it should.
* This glitch could be solved in the event loop handling as other operators may also
* destructively manipulate windowing data. */
CTX_wm_window_set(C, NULL);
CTX_wm_window_set(C, nullptr);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1591,22 +1595,21 @@ static void SCREEN_OT_area_close(wmOperatorType *ot)
* call exit() and remove handler
*/
typedef struct sAreaMoveData {
enum AreaMoveSnapType {
/* Snapping disabled */
SNAP_NONE = 0, /* Snap to an invisible grid with a unit defined in AREAGRID */
SNAP_AREAGRID, /* Snap to fraction (half, third.. etc) and adjacent edges. */
SNAP_FRACTION_AND_ADJACENT, /* Snap to either bigger or smaller, nothing in-between (used for
* global areas). This has priority over other snap types, if it is
* used, toggling SNAP_FRACTION_AND_ADJACENT doesn't work. */
SNAP_BIGGER_SMALLER_ONLY,
};
struct sAreaMoveData {
int bigger, smaller, origval, step;
eScreenAxis dir_axis;
enum AreaMoveSnapType {
/* Snapping disabled */
SNAP_NONE = 0,
/* Snap to an invisible grid with a unit defined in AREAGRID */
SNAP_AREAGRID,
/* Snap to fraction (half, third.. etc) and adjacent edges. */
SNAP_FRACTION_AND_ADJACENT,
/* Snap to either bigger or smaller, nothing in-between (used for
* global areas). This has priority over other snap types, if it is
* used, toggling SNAP_FRACTION_AND_ADJACENT doesn't work. */
SNAP_BIGGER_SMALLER_ONLY,
} snap_type;
} sAreaMoveData;
AreaMoveSnapType snap_type;
};
/* helper call to move area-edge, sets limits
* need window bounds in order to get correct limits */
@@ -1620,7 +1623,7 @@ static void area_move_set_limits(wmWindow *win,
/* we check all areas and test for free space with MINSIZE */
*bigger = *smaller = 100000;
if (use_bigger_smaller_snap != NULL) {
if (use_bigger_smaller_snap != nullptr) {
*use_bigger_smaller_snap = false;
LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
int size_min = ED_area_global_min_size_y(area) - 1;
@@ -1721,11 +1724,12 @@ static bool area_move_init(bContext *C, wmOperator *op)
/* setup */
ScrEdge *actedge = screen_geom_find_active_scredge(win, screen, x, y);
if (actedge == NULL) {
if (actedge == nullptr) {
return false;
}
sAreaMoveData *md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
sAreaMoveData *md = static_cast<sAreaMoveData *>(
MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData"));
op->customdata = md;
md->dir_axis = screen_geom_edge_is_horizontal(actedge) ? SCREEN_AXIS_H : SCREEN_AXIS_V;
@@ -1917,7 +1921,7 @@ static void area_move_apply_do(const bContext *C,
ED_screen_global_areas_sync(win);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* redraw everything */
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr); /* redraw everything */
/* Update preview thumbnail */
BKE_icon_changed(screen->id.icon_id);
}
@@ -1925,7 +1929,7 @@ static void area_move_apply_do(const bContext *C,
static void area_move_apply(bContext *C, wmOperator *op)
{
sAreaMoveData *md = op->customdata;
sAreaMoveData *md = static_cast<sAreaMoveData *>(op->customdata);
int delta = RNA_int_get(op->ptr, "delta");
area_move_apply_do(C, delta, md->origval, md->dir_axis, md->bigger, md->smaller, md->snap_type);
@@ -1982,7 +1986,7 @@ static void area_move_cancel(bContext *C, wmOperator *op)
/* modal callback for while moving edges */
static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
sAreaMoveData *md = op->customdata;
sAreaMoveData *md = static_cast<sAreaMoveData *>(op->customdata);
/* execute the events */
switch (event->type) {
@@ -2087,7 +2091,7 @@ static void SCREEN_OT_area_move(wmOperatorType *ot)
* call exit() or cancel() and remove handler
*/
typedef struct sAreaSplitData {
struct sAreaSplitData {
int origval; /* for move areas */
int bigger, smaller; /* constraints for moving new edge */
int delta; /* delta move edge */
@@ -2099,8 +2103,7 @@ typedef struct sAreaSplitData {
ScrEdge *nedge; /* new edge */
ScrArea *sarea; /* start area */
ScrArea *narea; /* new area */
} sAreaSplitData;
};
static bool area_split_allowed(const ScrArea *area, const eScreenAxis dir_axis)
{
@@ -2119,12 +2122,12 @@ static bool area_split_allowed(const ScrArea *area, const eScreenAxis dir_axis)
return true;
}
static void area_split_draw_cb(const wmWindow *UNUSED(win), void *userdata)
static void area_split_draw_cb(const wmWindow * /*win*/, void *userdata)
{
const wmOperator *op = userdata;
const wmOperator *op = static_cast<const wmOperator *>(userdata);
sAreaSplitData *sd = op->customdata;
const eScreenAxis dir_axis = RNA_enum_get(op->ptr, "direction");
sAreaSplitData *sd = static_cast<sAreaSplitData *>(op->customdata);
const eScreenAxis dir_axis = eScreenAxis(RNA_enum_get(op->ptr, "direction"));
if (area_split_allowed(sd->sarea, dir_axis)) {
float fac = RNA_float_get(op->ptr, "factor");
@@ -2150,12 +2153,12 @@ static bool area_split_init(bContext *C, wmOperator *op)
ScrArea *area = CTX_wm_area(C);
/* required context */
if (area == NULL) {
if (area == nullptr) {
return false;
}
/* required properties */
const eScreenAxis dir_axis = RNA_enum_get(op->ptr, "direction");
const eScreenAxis dir_axis = eScreenAxis(RNA_enum_get(op->ptr, "direction"));
/* custom data */
sAreaSplitData *sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split");
@@ -2200,7 +2203,7 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *area, ScrArea *sb)
return BKE_screen_find_edge(screen, sav1, sav4);
}
return NULL;
return nullptr;
}
/* do the split, return success */
@@ -2211,7 +2214,7 @@ static bool area_split_apply(bContext *C, wmOperator *op)
sAreaSplitData *sd = (sAreaSplitData *)op->customdata;
float fac = RNA_float_get(op->ptr, "factor");
const eScreenAxis dir_axis = RNA_enum_get(op->ptr, "direction");
const eScreenAxis dir_axis = eScreenAxis(RNA_enum_get(op->ptr, "direction"));
if (!area_split_allowed(sd->sarea, dir_axis)) {
return false;
@@ -2219,7 +2222,7 @@ static bool area_split_apply(bContext *C, wmOperator *op)
sd->narea = area_split(win, screen, sd->sarea, dir_axis, fac, false); /* false = no merge */
if (sd->narea == NULL) {
if (sd->narea == nullptr) {
return false;
}
@@ -2244,7 +2247,7 @@ static bool area_split_apply(bContext *C, wmOperator *op)
ED_area_tag_redraw(sd->sarea);
ED_area_tag_redraw(sd->narea);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
/* Update preview thumbnail */
BKE_icon_changed(screen->id.icon_id);
@@ -2267,11 +2270,11 @@ static void area_split_exit(bContext *C, wmOperator *op)
}
MEM_freeN(op->customdata);
op->customdata = NULL;
op->customdata = nullptr;
}
WM_cursor_modal_restore(CTX_wm_window(C));
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
/* this makes sure aligned edges will result in aligned grabbing */
BKE_screen_remove_double_scrverts(CTX_wm_screen(C));
@@ -2283,7 +2286,7 @@ static void area_split_exit(bContext *C, wmOperator *op)
static void area_split_preview_update_cursor(bContext *C, wmOperator *op)
{
sAreaSplitData *sd = (sAreaSplitData *)op->customdata;
const eScreenAxis dir_axis = RNA_enum_get(op->ptr, "direction");
const eScreenAxis dir_axis = eScreenAxis(RNA_enum_get(op->ptr, "direction"));
if (area_split_allowed(sd->sarea, dir_axis)) {
WM_cursor_set(CTX_wm_window(C),
(dir_axis == SCREEN_AXIS_H) ? WM_CURSOR_H_SPLIT : WM_CURSOR_V_SPLIT);
@@ -2308,14 +2311,14 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
eScreenAxis dir_axis;
if (event->type == EVT_ACTIONZONE_AREA) {
sActionzoneData *sad = event->customdata;
sActionzoneData *sad = static_cast<sActionzoneData *>(event->customdata);
if (sad == NULL || sad->modifier > 0) {
if (sad == nullptr || sad->modifier > 0) {
return OPERATOR_PASS_THROUGH;
}
/* verify *sad itself */
if (sad->sa1 == NULL || sad->az == NULL) {
if (sad->sa1 == nullptr || sad->az == nullptr) {
return OPERATOR_PASS_THROUGH;
}
@@ -2358,10 +2361,10 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
else if (RNA_property_is_set(op->ptr, prop_dir)) {
ScrArea *area = CTX_wm_area(C);
if (area == NULL) {
if (area == nullptr) {
return OPERATOR_CANCELLED;
}
dir_axis = RNA_property_enum_get(op->ptr, prop_dir);
dir_axis = eScreenAxis(RNA_property_enum_get(op->ptr, prop_dir));
if (dir_axis == SCREEN_AXIS_H) {
RNA_property_float_set(
op->ptr, prop_factor, (float)(event->xy[0] - area->v1->vec.x) / (float)area->winx);
@@ -2391,7 +2394,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ScrEdge *actedge = screen_geom_area_map_find_active_scredge(
AREAMAP_FROM_SCREEN(screen), &window_rect, event_co[0], event_co[1]);
if (actedge == NULL) {
if (actedge == nullptr) {
return OPERATOR_CANCELLED;
}
@@ -2410,7 +2413,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (event->type == EVT_ACTIONZONE_AREA) {
/* do the split */
if (area_split_apply(C, op)) {
area_move_set_limits(win, screen, dir_axis, &sd->bigger, &sd->smaller, NULL);
area_move_set_limits(win, screen, dir_axis, &sd->bigger, &sd->smaller, nullptr);
/* add temp handler for edge move or cancel */
G.moving |= G_TRANSFORM_WM;
@@ -2455,10 +2458,10 @@ static void area_split_cancel(bContext *C, wmOperator *op)
else {
if (screen_area_join(C, CTX_wm_screen(C), sd->sarea, sd->narea)) {
if (CTX_wm_area(C) == sd->narea) {
CTX_wm_area_set(C, NULL);
CTX_wm_region_set(C, NULL);
CTX_wm_area_set(C, nullptr);
CTX_wm_region_set(C, nullptr);
}
sd->narea = NULL;
sd->narea = nullptr;
}
}
area_split_exit(C, op);
@@ -2498,7 +2501,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
else {
if (event->val == KM_PRESS) {
if (sd->sarea) {
const eScreenAxis dir_axis = RNA_property_enum_get(op->ptr, prop_dir);
const eScreenAxis dir_axis = eScreenAxis(RNA_property_enum_get(op->ptr, prop_dir));
RNA_property_enum_set(
op->ptr, prop_dir, (dir_axis == SCREEN_AXIS_V) ? SCREEN_AXIS_H : SCREEN_AXIS_V);
area_split_preview_update_cursor(C, op);
@@ -2522,7 +2525,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
if (update_factor) {
const eScreenAxis dir_axis = RNA_property_enum_get(op->ptr, prop_dir);
const eScreenAxis dir_axis = eScreenAxis(RNA_property_enum_get(op->ptr, prop_dir));
sd->delta = (dir_axis == SCREEN_AXIS_V) ? event->xy[0] - sd->origval :
event->xy[1] - sd->origval;
@@ -2592,7 +2595,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
static const EnumPropertyItem prop_direction_items[] = {
{SCREEN_AXIS_H, "HORIZONTAL", 0, "Horizontal", ""},
{SCREEN_AXIS_V, "VERTICAL", 0, "Vertical", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static void SCREEN_OT_area_split(wmOperatorType *ot)
@@ -2615,7 +2618,7 @@ static void SCREEN_OT_area_split(wmOperatorType *ot)
RNA_def_enum(ot->srna, "direction", prop_direction_items, SCREEN_AXIS_H, "Direction", "");
RNA_def_float(ot->srna, "factor", 0.5f, 0.0, 1.0, "Factor", "", 0.0, 1.0);
RNA_def_int_vector(
ot->srna, "cursor", 2, NULL, INT_MIN, INT_MAX, "Cursor", "", INT_MIN, INT_MAX);
ot->srna, "cursor", 2, nullptr, INT_MIN, INT_MAX, "Cursor", "", INT_MIN, INT_MAX);
}
/** \} */
@@ -2624,7 +2627,7 @@ static void SCREEN_OT_area_split(wmOperatorType *ot)
/** \name Scale Region Edge Operator
* \{ */
typedef struct RegionMoveData {
struct RegionMoveData {
AZone *az;
ARegion *region;
ScrArea *area;
@@ -2632,8 +2635,7 @@ typedef struct RegionMoveData {
int orig_xy[2];
int maxsize;
AZEdge edge;
} RegionMoveData;
};
static int area_max_regionsize(ScrArea *area, ARegion *scale_region, AZEdge edge)
{
@@ -2703,14 +2705,14 @@ static bool is_split_edge(const int alignment, const AZEdge edge)
static void region_scale_exit(wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
op->customdata = nullptr;
G.moving &= ~G_TRANSFORM_WM;
}
static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
sActionzoneData *sad = event->customdata;
sActionzoneData *sad = static_cast<sActionzoneData *>(event->customdata);
if (event->type != EVT_ACTIONZONE_REGION) {
BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone");
@@ -2720,7 +2722,8 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event
AZone *az = sad->az;
if (az->region) {
RegionMoveData *rmd = MEM_callocN(sizeof(RegionMoveData), "RegionMoveData");
RegionMoveData *rmd = static_cast<RegionMoveData *>(
MEM_callocN(sizeof(RegionMoveData), "RegionMoveData"));
op->customdata = rmd;
@@ -2803,7 +2806,7 @@ static void region_scale_toggle_hidden(bContext *C, RegionMoveData *rmd)
if ((rmd->region->flag & RGN_FLAG_HIDDEN) == 0) {
if (rmd->region->regiontype == RGN_TYPE_HEADER) {
ARegion *region_tool_header = BKE_area_find_region_type(rmd->area, RGN_TYPE_TOOL_HEADER);
if (region_tool_header != NULL) {
if (region_tool_header != nullptr) {
if ((region_tool_header->flag & RGN_FLAG_HIDDEN_BY_USER) == 0 &&
(region_tool_header->flag & RGN_FLAG_HIDDEN) != 0)
{
@@ -2816,7 +2819,7 @@ static void region_scale_toggle_hidden(bContext *C, RegionMoveData *rmd)
static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
RegionMoveData *rmd = op->customdata;
RegionMoveData *rmd = static_cast<RegionMoveData *>(op->customdata);
int delta;
/* execute the events */
@@ -2907,7 +2910,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
ED_area_tag_redraw(rmd->area);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
break;
}
@@ -2922,7 +2925,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
ED_area_tag_redraw(rmd->area);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
}
region_scale_exit(op);
@@ -2938,7 +2941,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
static void region_scale_cancel(bContext *UNUSED(C), wmOperator *op)
static void region_scale_cancel(bContext * /*C*/, wmOperator *op)
{
region_scale_exit(op);
}
@@ -3066,7 +3069,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
* simulations aren't reset properly).
*/
if (animtimer) {
ScreenAnimData *sad = animtimer->customdata;
ScreenAnimData *sad = static_cast<ScreenAnimData *>(animtimer->customdata);
sad->flag |= ANIMPLAY_FLAG_USE_NEXT_FRAME;
@@ -3122,12 +3125,12 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
bDopeSheet ads = {NULL};
bDopeSheet ads = {nullptr};
const bool next = RNA_boolean_get(op->ptr, "next");
bool done = false;
/* sanity checks */
if (scene == NULL) {
if (scene == nullptr) {
return OPERATOR_CANCELLED;
}
@@ -3150,7 +3153,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
if (ob->type == OB_GPENCIL_LEGACY) {
const bool active = !(scene->flag & SCE_KEYS_NO_SELONLY);
gpencil_to_keylist(&ads, ob->data, keylist, active);
gpencil_to_keylist(&ads, static_cast<bGPdata *>(ob->data), keylist, active);
}
}
@@ -3168,7 +3171,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
if (next) {
ak = ED_keylist_find_next(keylist, cfra);
while ((ak != NULL) && (done == false)) {
while ((ak != nullptr) && (done == false)) {
if (cfra < ak->cfra) {
BKE_scene_frame_set(scene, ak->cfra);
done = true;
@@ -3181,7 +3184,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
else {
ak = ED_keylist_find_prev(keylist, cfra);
while ((ak != NULL) && (done == false)) {
while ((ak != nullptr) && (done == false)) {
if (cfra > ak->cfra) {
BKE_scene_frame_set(scene, ak->cfra);
done = true;
@@ -3339,7 +3342,7 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot)
static int screen_maximize_area_exec(bContext *C, wmOperator *op)
{
bScreen *screen = CTX_wm_screen(C);
ScrArea *area = NULL;
ScrArea *area = nullptr;
const bool hide_panels = RNA_boolean_get(op->ptr, "use_hide_panels");
BLI_assert(!screen->temp);
@@ -3353,7 +3356,7 @@ static int screen_maximize_area_exec(bContext *C, wmOperator *op)
}
}
if (area == NULL) {
if (area == nullptr) {
area = CTX_wm_area(C);
}
@@ -3437,19 +3440,18 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
* call exit() and remove handler when LMB confirm
*/
typedef struct sAreaJoinData {
struct sAreaJoinData {
ScrArea *sa1; /* Potential source area (kept). */
ScrArea *sa2; /* Potential target area (removed or reduced). */
eScreenDir dir; /* Direction of potential join. */
void *draw_callback; /* call #screen_draw_join_highlight */
};
} sAreaJoinData;
static void area_join_draw_cb(const wmWindow *UNUSED(win), void *userdata)
static void area_join_draw_cb(const wmWindow * /*win*/, void *userdata)
{
const wmOperator *op = userdata;
const wmOperator *op = static_cast<const wmOperator *>(userdata);
sAreaJoinData *sd = op->customdata;
sAreaJoinData *sd = static_cast<sAreaJoinData *>(op->customdata);
if (sd->sa1 && sd->sa2 && (sd->dir != SCREEN_DIR_NONE)) {
screen_draw_join_highlight(sd->sa1, sd->sa2);
}
@@ -3459,17 +3461,18 @@ static void area_join_draw_cb(const wmWindow *UNUSED(win), void *userdata)
/* return false: init failed */
static bool area_join_init(bContext *C, wmOperator *op, ScrArea *sa1, ScrArea *sa2)
{
if (sa1 == NULL || sa2 == NULL) {
if (sa1 == nullptr || sa2 == nullptr) {
/* Get areas from cursor location if not specified. */
int cursor[2];
RNA_int_get_array(op->ptr, "cursor", cursor);
screen_area_edge_from_cursor(C, cursor, &sa1, &sa2);
}
if (sa1 == NULL || sa2 == NULL) {
if (sa1 == nullptr || sa2 == nullptr) {
return false;
}
sAreaJoinData *jd = MEM_callocN(sizeof(sAreaJoinData), "op_area_join");
sAreaJoinData *jd = static_cast<sAreaJoinData *>(
MEM_callocN(sizeof(sAreaJoinData), "op_area_join"));
jd->sa1 = sa1;
jd->sa2 = sa2;
@@ -3494,8 +3497,8 @@ static bool area_join_apply(bContext *C, wmOperator *op)
return false;
}
if (CTX_wm_area(C) == jd->sa2) {
CTX_wm_area_set(C, NULL);
CTX_wm_region_set(C, NULL);
CTX_wm_area_set(C, nullptr);
CTX_wm_region_set(C, nullptr);
}
return true;
@@ -3512,7 +3515,7 @@ static void area_join_exit(bContext *C, wmOperator *op)
}
MEM_freeN(jd);
op->customdata = NULL;
op->customdata = nullptr;
}
/* this makes sure aligned edges will result in aligned grabbing */
@@ -3523,7 +3526,7 @@ static void area_join_exit(bContext *C, wmOperator *op)
static int area_join_exec(bContext *C, wmOperator *op)
{
if (!area_join_init(C, op, NULL, NULL)) {
if (!area_join_init(C, op, nullptr, nullptr)) {
return OPERATOR_CANCELLED;
}
@@ -3537,14 +3540,14 @@ static int area_join_exec(bContext *C, wmOperator *op)
static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
if (event->type == EVT_ACTIONZONE_AREA) {
sActionzoneData *sad = event->customdata;
sActionzoneData *sad = static_cast<sActionzoneData *>(event->customdata);
if (sad == NULL || sad->modifier > 0) {
if (sad == nullptr || sad->modifier > 0) {
return OPERATOR_PASS_THROUGH;
}
/* verify *sad itself */
if (sad->sa1 == NULL || sad->sa2 == NULL) {
if (sad->sa1 == nullptr || sad->sa2 == nullptr) {
return OPERATOR_PASS_THROUGH;
}
@@ -3565,7 +3568,7 @@ static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void area_join_cancel(bContext *C, wmOperator *op)
{
WM_event_add_notifier(C, NC_WINDOW, NULL);
WM_event_add_notifier(C, NC_WINDOW, nullptr);
area_join_exit(C, op);
}
@@ -3576,8 +3579,8 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
bScreen *screen = CTX_wm_screen(C);
wmWindow *win = CTX_wm_window(C);
if (op->customdata == NULL) {
if (!area_join_init(C, op, NULL, NULL)) {
if (op->customdata == nullptr) {
if (!area_join_init(C, op, nullptr, nullptr)) {
return OPERATOR_CANCELLED;
}
}
@@ -3600,7 +3603,7 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
jd->dir = SCREEN_DIR_NONE;
}
WM_event_add_notifier(C, NC_WINDOW, NULL);
WM_event_add_notifier(C, NC_WINDOW, nullptr);
if (jd->dir == SCREEN_DIR_N) {
WM_cursor_set(win, WM_CURSOR_N_ARROW);
@@ -3630,7 +3633,7 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
ED_area_tag_redraw(jd->sa2);
area_join_apply(C, op);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
area_join_exit(C, op);
return OPERATOR_FINISHED;
}
@@ -3665,7 +3668,7 @@ static void SCREEN_OT_area_join(wmOperatorType *ot)
/* rna */
RNA_def_int_vector(
ot->srna, "cursor", 2, NULL, INT_MIN, INT_MAX, "Cursor", "", INT_MIN, INT_MAX);
ot->srna, "cursor", 2, nullptr, INT_MIN, INT_MAX, "Cursor", "", INT_MIN, INT_MAX);
}
/** \} */
@@ -3677,7 +3680,7 @@ static void SCREEN_OT_area_join(wmOperatorType *ot)
static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
ScrArea *sa1, *sa2;
if (screen_area_edge_from_cursor(C, event->xy, &sa1, &sa2) == NULL) {
if (screen_area_edge_from_cursor(C, event->xy, &sa1, &sa2) == nullptr) {
return OPERATOR_CANCELLED;
}
@@ -3690,7 +3693,7 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
"SCREEN_OT_area_split",
IFACE_("Vertical Split"),
ICON_NONE,
NULL,
nullptr,
WM_OP_INVOKE_DEFAULT,
0,
&ptr);
@@ -3703,7 +3706,7 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
"SCREEN_OT_area_split",
IFACE_("Horizontal Split"),
ICON_NONE,
NULL,
nullptr,
WM_OP_INVOKE_DEFAULT,
0,
&ptr);
@@ -3721,7 +3724,7 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
"SCREEN_OT_area_join",
IFACE_("Join Areas"),
ICON_NONE,
NULL,
nullptr,
WM_OP_INVOKE_DEFAULT,
0,
&ptr);
@@ -3734,7 +3737,7 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
"SCREEN_OT_area_swap",
IFACE_("Swap Areas"),
ICON_NONE,
NULL,
nullptr,
WM_OP_EXEC_DEFAULT,
0,
&ptr);
@@ -3776,7 +3779,7 @@ static int spacedata_cleanup_exec(bContext *C, wmOperator *op)
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (area->spacedata.first != area->spacedata.last) {
SpaceLink *sl = area->spacedata.first;
SpaceLink *sl = static_cast<SpaceLink *>(area->spacedata.first);
BLI_remlink(&area->spacedata, sl);
tot += BLI_listbase_count(&area->spacedata);
@@ -3817,10 +3820,10 @@ static bool repeat_history_poll(bContext *C)
return !BLI_listbase_is_empty(&wm->operators);
}
static int repeat_last_exec(bContext *C, wmOperator *UNUSED(op))
static int repeat_last_exec(bContext *C, wmOperator * /*op*/)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmOperator *lastop = wm->operators.last;
wmOperator *lastop = static_cast<wmOperator *>(wm->operators.last);
/* Seek last registered operator */
while (lastop) {
@@ -3857,7 +3860,7 @@ static void SCREEN_OT_repeat_last(wmOperatorType *ot)
/** \name Repeat History Operator
* \{ */
static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
wmWindowManager *wm = CTX_wm_manager(C);
@@ -3871,7 +3874,9 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNU
wmOperator *lastop;
int i;
for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--) {
for (i = items - 1, lastop = static_cast<wmOperator *>(wm->operators.last); lastop;
lastop = lastop->prev, i--)
{
if ((lastop->type->flag & OPTYPE_REGISTER) && WM_operator_repeat_check(C, lastop)) {
uiItemIntO(layout,
WM_operatortype_name(lastop->type, lastop->ptr),
@@ -3891,7 +3896,7 @@ static int repeat_history_exec(bContext *C, wmOperator *op)
{
wmWindowManager *wm = CTX_wm_manager(C);
op = BLI_findlink(&wm->operators, RNA_int_get(op->ptr, "index"));
op = static_cast<wmOperator *>(BLI_findlink(&wm->operators, RNA_int_get(op->ptr, "index")));
if (op) {
/* let's put it as last operator in list */
BLI_remlink(&wm->operators, op);
@@ -3924,7 +3929,7 @@ static void SCREEN_OT_repeat_history(wmOperatorType *ot)
/** \name Redo Operator
* \{ */
static int redo_last_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
static int redo_last_invoke(bContext *C, wmOperator * /*op*/, const wmEvent * /*event*/)
{
wmOperator *lastop = WM_operator_last_redo(C);
@@ -3965,7 +3970,7 @@ static void view3d_localview_update_rv3d(RegionView3D *rv3d)
static void region_quadview_init_rv3d(
ScrArea *area, ARegion *region, const char viewlock, const char view, const char persp)
{
RegionView3D *rv3d = region->regiondata;
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
if (persp == RV3D_CAMOB) {
ED_view3d_lastview_store(rv3d);
@@ -4001,7 +4006,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
region->alignment = 0;
if (area->spacetype == SPACE_VIEW3D) {
RegionView3D *rv3d = region->regiondata;
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
/* if this is a locked view, use settings from 'User' view */
if (rv3d->viewlock) {
@@ -4011,7 +4016,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
if (ED_view3d_context_user_region(C, &v3d_user, &region_user)) {
if (region != region_user) {
SWAP(void *, region->regiondata, region_user->regiondata);
rv3d = region->regiondata;
rv3d = static_cast<RegionView3D *>(region->regiondata);
}
}
}
@@ -4026,7 +4031,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
/* Accumulate locks, in case they're mixed. */
LISTBASE_FOREACH (ARegion *, region_iter, &area->regionbase) {
if (region_iter->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d_iter = region_iter->regiondata;
RegionView3D *rv3d_iter = static_cast<RegionView3D *>(region_iter->regiondata);
rv3d->viewlock_quad |= rv3d_iter->viewlock;
}
}
@@ -4038,7 +4043,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
}
}
ED_area_tag_redraw(area);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
}
else if (region->next) {
BKE_report(op->reports, RPT_ERROR, "Only last region can be 4-split");
@@ -4056,7 +4061,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
/* lock views and set them */
if (area->spacetype == SPACE_VIEW3D) {
View3D *v3d = area->spacedata.first;
View3D *v3d = static_cast<View3D *>(area->spacedata.first);
int index_qsplit = 0;
/* run ED_view3d_lock() so the correct 'rv3d->viewquat' is set,
@@ -4065,7 +4070,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
*
* We could avoid manipulating rv3d->localvd here if exiting
* localview with a 4-split would assign these view locks */
RegionView3D *rv3d = region->regiondata;
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
const char viewlock = (rv3d->viewlock_quad & RV3D_VIEWLOCK_INIT) ?
(rv3d->viewlock_quad & ~RV3D_VIEWLOCK_INIT) :
RV3D_LOCK_ROTATION;
@@ -4082,7 +4087,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
viewlock,
ED_view3d_lock_view_from_index(index_qsplit++),
RV3D_ORTHO);
/* forcing camera is distracting */
/* forcing camera is distracting */
#if 0
if (v3d->camera) {
region_quadview_init_rv3d(area, (region = region->next), 0, RV3D_VIEW_CAMERA, RV3D_CAMOB);
@@ -4095,7 +4100,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
#endif
}
ED_area_tag_redraw(area);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
}
return OPERATOR_FINISHED;
@@ -4180,7 +4185,7 @@ static void SCREEN_OT_region_toggle(wmOperatorType *ot)
* \{ */
/* flip a region alignment */
static int region_flip_exec(bContext *C, wmOperator *UNUSED(op))
static int region_flip_exec(bContext *C, wmOperator * /*op*/)
{
ARegion *region = CTX_wm_region(C);
@@ -4203,7 +4208,7 @@ static int region_flip_exec(bContext *C, wmOperator *UNUSED(op))
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_mousemove(CTX_wm_window(C));
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -4241,14 +4246,14 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot)
* \{ */
/* show/hide header text menus */
static int header_toggle_menus_exec(bContext *C, wmOperator *UNUSED(op))
static int header_toggle_menus_exec(bContext *C, wmOperator * /*op*/)
{
ScrArea *area = CTX_wm_area(C);
area->flag = area->flag ^ HEADER_NO_PULLDOWN;
ED_area_tag_redraw(area);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -4288,7 +4293,7 @@ static void screen_area_menu_items(ScrArea *area, uiLayout *layout)
"SCREEN_OT_area_split",
IFACE_("Vertical Split"),
ICON_NONE,
NULL,
nullptr,
WM_OP_INVOKE_DEFAULT,
0,
&ptr);
@@ -4301,7 +4306,7 @@ static void screen_area_menu_items(ScrArea *area, uiLayout *layout)
"SCREEN_OT_area_split",
IFACE_("Horizontal Split"),
ICON_NONE,
NULL,
nullptr,
WM_OP_INVOKE_DEFAULT,
0,
&ptr);
@@ -4322,7 +4327,7 @@ static void screen_area_menu_items(ScrArea *area, uiLayout *layout)
"SCREEN_OT_screen_full_area",
IFACE_("Full Screen Area"),
ICON_NONE,
NULL,
nullptr,
WM_OP_INVOKE_DEFAULT,
0,
&ptr);
@@ -4330,12 +4335,12 @@ static void screen_area_menu_items(ScrArea *area, uiLayout *layout)
}
}
uiItemO(layout, NULL, ICON_NONE, "SCREEN_OT_area_dupli");
uiItemO(layout, nullptr, ICON_NONE, "SCREEN_OT_area_dupli");
uiItemS(layout);
uiItemO(layout, NULL, ICON_NONE, "SCREEN_OT_area_close");
uiItemO(layout, nullptr, ICON_NONE, "SCREEN_OT_area_close");
}
void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void * /*arg*/)
{
ScrArea *area = CTX_wm_area(C);
{
@@ -4361,13 +4366,13 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN
if (!ELEM(area->spacetype, SPACE_TOPBAR)) {
uiItemS(layout);
ED_screens_region_flip_menu_create(C, layout, NULL);
ED_screens_region_flip_menu_create(C, layout, nullptr);
uiItemS(layout);
screen_area_menu_items(area, layout);
}
}
void ED_screens_footer_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
void ED_screens_footer_tools_menu_create(bContext *C, uiLayout *layout, void * /*arg*/)
{
ScrArea *area = CTX_wm_area(C);
@@ -4377,12 +4382,12 @@ void ED_screens_footer_tools_menu_create(bContext *C, uiLayout *layout, void *UN
uiItemR(layout, &ptr, "show_region_footer", 0, IFACE_("Show Footer"), ICON_NONE);
}
ED_screens_region_flip_menu_create(C, layout, NULL);
ED_screens_region_flip_menu_create(C, layout, nullptr);
uiItemS(layout);
screen_area_menu_items(area, layout);
}
void ED_screens_region_flip_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
void ED_screens_region_flip_menu_create(bContext *C, uiLayout *layout, void * /*arg*/)
{
const ARegion *region = CTX_wm_region(C);
const short region_alignment = RGN_ALIGN_ENUM_FROM_MASK(region->alignment);
@@ -4397,11 +4402,11 @@ void ED_screens_region_flip_menu_create(bContext *C, uiLayout *layout, void *UNU
uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip");
}
static void ed_screens_statusbar_menu_create(uiLayout *layout, void *UNUSED(arg))
static void ed_screens_statusbar_menu_create(uiLayout *layout, void * /*arg*/)
{
PointerRNA ptr;
RNA_pointer_create(NULL, &RNA_PreferencesView, &U, &ptr);
RNA_pointer_create(nullptr, &RNA_PreferencesView, &U, &ptr);
uiItemR(layout, &ptr, "show_statusbar_stats", 0, IFACE_("Scene Statistics"), ICON_NONE);
uiItemR(layout, &ptr, "show_statusbar_scene_duration", 0, IFACE_("Scene Duration"), ICON_NONE);
uiItemR(layout, &ptr, "show_statusbar_memory", 0, IFACE_("System Memory"), ICON_NONE);
@@ -4411,9 +4416,7 @@ static void ed_screens_statusbar_menu_create(uiLayout *layout, void *UNUSED(arg)
uiItemR(layout, &ptr, "show_statusbar_version", 0, IFACE_("Blender Version"), ICON_NONE);
}
static int screen_context_menu_invoke(bContext *C,
wmOperator *UNUSED(op),
const wmEvent *UNUSED(event))
static int screen_context_menu_invoke(bContext *C, wmOperator * /*op*/, const wmEvent * /*event*/)
{
const ScrArea *area = CTX_wm_area(C);
const ARegion *region = CTX_wm_region(C);
@@ -4421,26 +4424,26 @@ static int screen_context_menu_invoke(bContext *C,
if (area && area->spacetype == SPACE_STATUSBAR) {
uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Status Bar"), ICON_NONE);
uiLayout *layout = UI_popup_menu_layout(pup);
ed_screens_statusbar_menu_create(layout, NULL);
ed_screens_statusbar_menu_create(layout, nullptr);
UI_popup_menu_end(C, pup);
}
else if (region) {
if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Header"), ICON_NONE);
uiLayout *layout = UI_popup_menu_layout(pup);
ED_screens_header_tools_menu_create(C, layout, NULL);
ED_screens_header_tools_menu_create(C, layout, nullptr);
UI_popup_menu_end(C, pup);
}
else if (region->regiontype == RGN_TYPE_FOOTER) {
uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Footer"), ICON_NONE);
uiLayout *layout = UI_popup_menu_layout(pup);
ED_screens_footer_tools_menu_create(C, layout, NULL);
ED_screens_footer_tools_menu_create(C, layout, nullptr);
UI_popup_menu_end(C, pup);
}
else if (region->regiontype == RGN_TYPE_NAV_BAR) {
uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Navigation Bar"), ICON_NONE);
uiLayout *layout = UI_popup_menu_layout(pup);
ED_screens_region_flip_menu_create(C, layout, NULL);
ED_screens_region_flip_menu_create(C, layout, nullptr);
UI_popup_menu_end(C, pup);
}
}
@@ -4480,7 +4483,7 @@ static bool match_region_with_redraws(const ScrArea *area,
eScreen_Redraws_Flag redraws,
bool from_anim_edit)
{
const eSpace_Type spacetype = area->spacetype;
const eSpace_Type spacetype = eSpace_Type(area->spacetype);
if (regiontype == RGN_TYPE_WINDOW) {
switch (spacetype) {
@@ -4579,7 +4582,8 @@ static void screen_animation_region_tag_redraw(
{
/* Do follow time here if editor type supports it */
if ((redraws & TIME_FOLLOW) &&
screen_animation_region_supports_time_follow(area->spacetype, region->regiontype))
screen_animation_region_supports_time_follow(eSpace_Type(area->spacetype),
eRegion_Type(region->regiontype)))
{
float w = BLI_rctf_size_x(&region->v2d.cur);
if (scene->r.cfra < region->v2d.cur.xmin) {
@@ -4610,7 +4614,7 @@ static void screen_animation_region_tag_redraw(
* which has significant overhead which needs to be avoided in the overlay which is redrawn on
* every UI interaction. */
if (area->spacetype == SPACE_GRAPH) {
const SpaceGraph *sipo = area->spacedata.first;
const SpaceGraph *sipo = static_cast<const SpaceGraph *>(area->spacedata.first);
if (sipo->mode != SIPO_MODE_DRIVERS) {
return;
}
@@ -4624,7 +4628,7 @@ static void screen_animation_region_tag_redraw(
}
if (area->spacetype == SPACE_SEQ) {
const SpaceSeq *sseq = area->spacedata.first;
const SpaceSeq *sseq = static_cast<const SpaceSeq *>(area->spacedata.first);
if (!ED_space_sequencer_has_playback_animation(sseq, scene)) {
return;
}
@@ -4635,7 +4639,7 @@ static void screen_animation_region_tag_redraw(
//#define PROFILE_AUDIO_SYNCH
static int screen_animation_step_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static int screen_animation_step_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
{
bScreen *screen = CTX_wm_screen(C);
wmTimer *wt = screen->animtimer;
@@ -4655,8 +4659,8 @@ static int screen_animation_step_invoke(bContext *C, wmOperator *UNUSED(op), con
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer);
Scene *scene_eval = (depsgraph != NULL) ? DEG_get_evaluated_scene(depsgraph) : NULL;
ScreenAnimData *sad = wt->customdata;
Scene *scene_eval = (depsgraph != nullptr) ? DEG_get_evaluated_scene(depsgraph) : nullptr;
ScreenAnimData *sad = static_cast<ScreenAnimData *>(wt->customdata);
wmWindowManager *wm = CTX_wm_manager(C);
int sync;
double time;
@@ -4672,7 +4676,7 @@ static int screen_animation_step_invoke(bContext *C, wmOperator *UNUSED(op), con
sync = (scene->flag & SCE_FRAME_DROP);
}
if (scene_eval == NULL) {
if (scene_eval == nullptr) {
/* Happens when undo/redo system is used during playback, nothing meaningful we can do here. */
}
else if (scene_eval->id.recalc & ID_RECALC_FRAME_CHANGE) {
@@ -4798,7 +4802,7 @@ static int screen_animation_step_invoke(bContext *C, wmOperator *UNUSED(op), con
}
/* Since we follow draw-flags, we can't send notifier but tag regions ourselves. */
if (depsgraph != NULL) {
if (depsgraph != nullptr) {
ED_update_for_newframe(bmain, depsgraph);
}
@@ -4811,13 +4815,17 @@ static int screen_animation_step_invoke(bContext *C, wmOperator *UNUSED(op), con
if (region == sad->region) {
redraw = true;
}
else if (match_region_with_redraws(
area, region->regiontype, sad->redraws, sad->from_anim_edit)) {
else if (match_region_with_redraws(area,
eRegion_Type(region->regiontype),
eScreen_Redraws_Flag(sad->redraws),
sad->from_anim_edit))
{
redraw = true;
}
if (redraw) {
screen_animation_region_tag_redraw(C, area, region, scene, sad->redraws);
screen_animation_region_tag_redraw(
C, area, region, scene, eScreen_Redraws_Flag(sad->redraws));
}
}
}
@@ -4870,7 +4878,7 @@ bScreen *ED_screen_animation_playing(const wmWindowManager *wm)
}
}
return NULL;
return nullptr;
}
bScreen *ED_screen_animation_no_scrub(const wmWindowManager *wm)
@@ -4883,7 +4891,7 @@ bScreen *ED_screen_animation_no_scrub(const wmWindowManager *wm)
}
}
return NULL;
return nullptr;
}
int ED_screen_animation_play(bContext *C, int sync, int mode)
@@ -4919,7 +4927,7 @@ int ED_screen_animation_play(bContext *C, int sync, int mode)
if (screen->animtimer) {
wmTimer *wt = screen->animtimer;
ScreenAnimData *sad = wt->customdata;
ScreenAnimData *sad = static_cast<ScreenAnimData *>(wt->customdata);
sad->region = CTX_wm_region(C);
}
@@ -4973,7 +4981,7 @@ static int screen_animation_cancel_exec(bContext *C, wmOperator *op)
if (screen) {
if (RNA_boolean_get(op->ptr, "restore_frame") && screen->animtimer) {
ScreenAnimData *sad = screen->animtimer->customdata;
ScreenAnimData *sad = static_cast<ScreenAnimData *>(screen->animtimer->customdata);
Scene *scene = CTX_data_scene(C);
/* reset current frame before stopping, and just send a notifier to deal with the rest
@@ -5083,7 +5091,7 @@ static void SCREEN_OT_box_select(wmOperatorType *ot)
static int fullscreen_back_exec(bContext *C, wmOperator *op)
{
bScreen *screen = CTX_wm_screen(C);
ScrArea *area = NULL;
ScrArea *area = nullptr;
/* search current screen for 'fullscreen' areas */
LISTBASE_FOREACH (ScrArea *, area_iter, &screen->areabase) {
@@ -5133,7 +5141,7 @@ static int userpref_show_exec(bContext *C, wmOperator *op)
/* Set active section via RNA, so it can fail properly. */
PointerRNA pref_ptr;
RNA_pointer_create(NULL, &RNA_Preferences, &U, &pref_ptr);
RNA_pointer_create(nullptr, &RNA_Preferences, &U, &pref_ptr);
PropertyRNA *active_section_prop = RNA_struct_find_property(&pref_ptr, "active_section");
RNA_property_enum_set(&pref_ptr, active_section_prop, RNA_property_enum_get(op->ptr, prop));
@@ -5151,7 +5159,7 @@ static int userpref_show_exec(bContext *C, wmOperator *op)
false,
false,
true,
WIN_ALIGN_LOCATION_CENTER) != NULL)
WIN_ALIGN_LOCATION_CENTER) != nullptr)
{
/* The header only contains the editor switcher and looks empty.
* So hiding in the temp window makes sense. */
@@ -5224,7 +5232,7 @@ static int drivers_editor_show_exec(bContext *C, wmOperator *op)
false,
false,
true,
WIN_ALIGN_LOCATION_CENTER) != NULL)
WIN_ALIGN_LOCATION_CENTER) != nullptr)
{
ED_drivers_editor_init(C, CTX_wm_area(C));
@@ -5232,7 +5240,7 @@ static int drivers_editor_show_exec(bContext *C, wmOperator *op)
if (but) {
bool driven, special;
FCurve *fcu = BKE_fcurve_find_by_rna_context_ui(
C, &ptr, prop, index, NULL, NULL, &driven, &special);
C, &ptr, prop, index, nullptr, nullptr, &driven, &special);
if (fcu) {
/* Isolate this F-Curve... */
@@ -5240,7 +5248,12 @@ static int drivers_editor_show_exec(bContext *C, wmOperator *op)
if (ANIM_animdata_get_context(C, &ac)) {
int filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS;
ANIM_anim_channels_select_set(&ac, ACHANNEL_SETFLAG_CLEAR);
ANIM_set_active_channel(&ac, ac.data, ac.datatype, filter, fcu, ANIMTYPE_FCURVE);
ANIM_set_active_channel(&ac,
ac.data,
eAnimCont_Types(ac.datatype),
eAnimFilter_Flags(filter),
fcu,
ANIMTYPE_FCURVE);
}
else {
/* Just blindly isolate...
@@ -5294,7 +5307,7 @@ static int info_log_show_exec(bContext *C, wmOperator *op)
false,
false,
true,
WIN_ALIGN_LOCATION_CENTER) != NULL)
WIN_ALIGN_LOCATION_CENTER) != nullptr)
{
return OPERATOR_FINISHED;
}
@@ -5320,7 +5333,7 @@ static void SCREEN_OT_info_log_show(wmOperatorType *ot)
/** \name New Screen Operator
* \{ */
static int screen_new_exec(bContext *C, wmOperator *UNUSED(op))
static int screen_new_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
wmWindow *win = CTX_wm_window(C);
@@ -5352,7 +5365,7 @@ static void SCREEN_OT_new(wmOperatorType *ot)
/** \name Delete Screen Operator
* \{ */
static int screen_delete_exec(bContext *C, wmOperator *UNUSED(op))
static int screen_delete_exec(bContext *C, wmOperator * /*op*/)
{
bScreen *screen = CTX_wm_screen(C);
WorkSpace *workspace = CTX_wm_workspace(C);
@@ -5385,11 +5398,11 @@ static void SCREEN_OT_delete(wmOperatorType *ot)
*
* \{ */
typedef struct RegionAlphaInfo {
struct RegionAlphaInfo {
ScrArea *area;
ARegion *region, *child_region; /* other region */
int hidden;
} RegionAlphaInfo;
};
#define TIMEOUT 0.1f
#define TIMESTEP (1.0f / 60.0f)
@@ -5397,12 +5410,12 @@ typedef struct RegionAlphaInfo {
float ED_region_blend_alpha(ARegion *region)
{
/* check parent too */
if (region->regiontimer == NULL && (region->alignment & RGN_SPLIT_PREV) && region->prev) {
if (region->regiontimer == nullptr && (region->alignment & RGN_SPLIT_PREV) && region->prev) {
region = region->prev;
}
if (region->regiontimer) {
RegionAlphaInfo *rgi = region->regiontimer->customdata;
RegionAlphaInfo *rgi = static_cast<RegionAlphaInfo *>(region->regiontimer->customdata);
float alpha;
alpha = (float)region->regiontimer->duration / TIMEOUT;
@@ -5420,7 +5433,7 @@ float ED_region_blend_alpha(ARegion *region)
/* assumes region has running region-blend timer */
static void region_blend_end(bContext *C, ARegion *region, const bool is_running)
{
RegionAlphaInfo *rgi = region->regiontimer->customdata;
RegionAlphaInfo *rgi = static_cast<RegionAlphaInfo *>(region->regiontimer->customdata);
/* always send redraw */
ED_region_tag_redraw(region);
@@ -5442,8 +5455,8 @@ static void region_blend_end(bContext *C, ARegion *region, const bool is_running
/* area decoration needs redraw in end */
ED_area_tag_redraw(rgi->area);
}
WM_event_timer_remove(CTX_wm_manager(C), NULL, region->regiontimer); /* frees rgi */
region->regiontimer = NULL;
WM_event_timer_remove(CTX_wm_manager(C), nullptr, region->regiontimer); /* frees rgi */
region->regiontimer = nullptr;
}
void ED_region_visibility_change_update_animated(bContext *C, ScrArea *area, ARegion *region)
{
@@ -5455,7 +5468,8 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *area, ARe
region_blend_end(C, region, true);
}
RegionAlphaInfo *rgi = MEM_callocN(sizeof(RegionAlphaInfo), "RegionAlphaInfo");
RegionAlphaInfo *rgi = static_cast<RegionAlphaInfo *>(
MEM_callocN(sizeof(RegionAlphaInfo), "RegionAlphaInfo"));
rgi->hidden = region->flag & RGN_FLAG_HIDDEN;
rgi->area = area;
@@ -5482,16 +5496,16 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *area, ARe
}
/* timer runs in win->handlers, so it cannot use context to find area/region */
static int region_blend_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static int region_blend_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
{
wmTimer *timer = event->customdata;
wmTimer *timer = static_cast<wmTimer *>(event->customdata);
/* event type is TIMERREGION, but we better check */
if (event->type != TIMERREGION || timer == NULL) {
if (event->type != TIMERREGION || timer == nullptr) {
return OPERATOR_PASS_THROUGH;
}
RegionAlphaInfo *rgi = timer->customdata;
RegionAlphaInfo *rgi = static_cast<RegionAlphaInfo *>(timer->customdata);
/* always send redraws */
ED_region_tag_redraw(rgi->region);
@@ -5600,13 +5614,13 @@ static void SCREEN_OT_space_type_set_or_cycle(wmOperatorType *ot)
static const EnumPropertyItem space_context_cycle_direction[] = {
{SPACE_CONTEXT_CYCLE_PREV, "PREV", 0, "Previous", ""},
{SPACE_CONTEXT_CYCLE_NEXT, "NEXT", 0, "Next", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static bool space_context_cycle_poll(bContext *C)
{
ScrArea *area = CTX_wm_area(C);
/* area might be NULL if called out of window bounds */
/* area might be nullptr if called out of window bounds */
return (area && ELEM(area->spacetype, SPACE_PROPERTIES, SPACE_USERPREF));
}
@@ -5627,7 +5641,7 @@ static void context_cycle_prop_get(bScreen *screen,
propname = "context";
break;
case SPACE_USERPREF:
RNA_pointer_create(NULL, &RNA_Preferences, &U, r_ptr);
RNA_pointer_create(nullptr, &RNA_Preferences, &U, r_ptr);
propname = "active_section";
break;
default:
@@ -5638,9 +5652,9 @@ static void context_cycle_prop_get(bScreen *screen,
*r_prop = RNA_struct_find_property(r_ptr, propname);
}
static int space_context_cycle_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int space_context_cycle_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
const eScreenCycle direction = RNA_enum_get(op->ptr, "direction");
const eScreenCycle direction = eScreenCycle(RNA_enum_get(op->ptr, "direction"));
PointerRNA ptr;
PropertyRNA *prop;
@@ -5681,7 +5695,7 @@ static void SCREEN_OT_space_context_cycle(wmOperatorType *ot)
/** \name Workspace Cycle Operator
* \{ */
static int space_workspace_cycle_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int space_workspace_cycle_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
wmWindow *win = CTX_wm_window(C);
if (WM_window_is_temp_screen(win)) {
@@ -5689,9 +5703,9 @@ static int space_workspace_cycle_invoke(bContext *C, wmOperator *op, const wmEve
}
Main *bmain = CTX_data_main(C);
const eScreenCycle direction = RNA_enum_get(op->ptr, "direction");
const eScreenCycle direction = eScreenCycle(RNA_enum_get(op->ptr, "direction"));
WorkSpace *workspace_src = WM_window_get_active_workspace(win);
WorkSpace *workspace_dst = NULL;
WorkSpace *workspace_dst = nullptr;
ListBase ordered;
BKE_id_ordered_list(&ordered, &bmain->workspaces);
@@ -5699,17 +5713,18 @@ static int space_workspace_cycle_invoke(bContext *C, wmOperator *op, const wmEve
LISTBASE_FOREACH (LinkData *, link, &ordered) {
if (link->data == workspace_src) {
if (direction == SPACE_CONTEXT_CYCLE_PREV) {
workspace_dst = (link->prev) ? link->prev->data : NULL;
workspace_dst = static_cast<WorkSpace *>((link->prev) ? link->prev->data : nullptr);
}
else {
workspace_dst = (link->next) ? link->next->data : NULL;
workspace_dst = static_cast<WorkSpace *>((link->next) ? link->next->data : nullptr);
}
}
}
if (workspace_dst == NULL) {
LinkData *link = (direction == SPACE_CONTEXT_CYCLE_PREV) ? ordered.last : ordered.first;
workspace_dst = link->data;
if (workspace_dst == nullptr) {
LinkData *link = static_cast<LinkData *>(
(direction == SPACE_CONTEXT_CYCLE_PREV) ? ordered.last : ordered.first);
workspace_dst = static_cast<WorkSpace *>(link->data);
}
BLI_freelistN(&ordered);
@@ -5720,7 +5735,7 @@ static int space_workspace_cycle_invoke(bContext *C, wmOperator *op, const wmEve
win->workspace_hook->temp_workspace_store = workspace_dst;
WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_SET, workspace_dst);
win->workspace_hook->temp_workspace_store = NULL;
win->workspace_hook->temp_workspace_store = nullptr;
return OPERATOR_FINISHED;
}
@@ -5816,7 +5831,7 @@ static void keymap_modal_set(wmKeyConfig *keyconf)
{KM_MODAL_APPLY, "APPLY", 0, "Apply", ""},
{KM_MODAL_SNAP_ON, "SNAP", 0, "Snap On", ""},
{KM_MODAL_SNAP_OFF, "SNAP_OFF", 0, "Snap Off", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* Standard Modal keymap ------------------------------------------------ */
@@ -5825,10 +5840,10 @@ static void keymap_modal_set(wmKeyConfig *keyconf)
WM_modalkeymap_assign(keymap, "SCREEN_OT_area_move");
}
static bool blend_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event))
static bool blend_file_drop_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/)
{
if (drag->type == WM_DRAG_PATH) {
const eFileSel_File_Types file_type = WM_drag_get_path_file_type(drag);
const eFileSel_File_Types file_type = eFileSel_File_Types(WM_drag_get_path_file_type(drag));
if (ELEM(file_type, FILE_TYPE_BLENDER, FILE_TYPE_BLENDER_BACKUP)) {
return true;
}
@@ -5836,7 +5851,7 @@ static bool blend_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEven
return false;
}
static void blend_file_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop)
static void blend_file_drop_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
{
/* copy drag path to properties */
RNA_string_set(drop->ptr, "filepath", WM_drag_get_path(drag));
@@ -5856,8 +5871,8 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
/* dropbox for entire window */
ListBase *lb = WM_dropboxmap_find("Window", 0, 0);
WM_dropbox_add(
lb, "WM_OT_drop_blend_file", blend_file_drop_poll, blend_file_drop_copy, NULL, NULL);
WM_dropbox_add(lb, "UI_OT_drop_color", UI_drop_color_poll, UI_drop_color_copy, NULL, NULL);
lb, "WM_OT_drop_blend_file", blend_file_drop_poll, blend_file_drop_copy, nullptr, nullptr);
WM_dropbox_add(lb, "UI_OT_drop_color", UI_drop_color_poll, UI_drop_color_copy, nullptr, nullptr);
keymap_modal_set(keyconf);
}

View File

@@ -61,22 +61,23 @@ bUserMenu **ED_screen_user_menus_find(const bContext *C, uint *r_len)
{
SpaceLink *sl = CTX_wm_space_data(C);
if (sl == NULL) {
if (sl == nullptr) {
*r_len = 0;
return NULL;
return nullptr;
}
const char *context_mode = CTX_data_mode_string(C);
const char *context = screen_menu_context_string(C, sl);
uint array_len = 3;
bUserMenu **um_array = MEM_calloc_arrayN(array_len, sizeof(*um_array), __func__);
bUserMenu **um_array = static_cast<bUserMenu **>(
MEM_calloc_arrayN(array_len, sizeof(*um_array), __func__));
um_array[0] = BKE_blender_user_menu_find(&U.user_menus, sl->spacetype, context);
um_array[1] = (sl->spacetype != SPACE_TOPBAR) ?
BKE_blender_user_menu_find(&U.user_menus, SPACE_TOPBAR, context_mode) :
NULL;
nullptr;
um_array[2] = (sl->spacetype == SPACE_VIEW3D) ?
BKE_blender_user_menu_find(&U.user_menus, SPACE_PROPERTIES, context_mode) :
NULL;
nullptr;
*r_len = array_len;
return um_array;
@@ -115,7 +116,7 @@ bUserMenuItem_Op *ED_screen_user_menu_item_find_operator(ListBase *lb,
}
}
}
return NULL;
return nullptr;
}
bUserMenuItem_Menu *ED_screen_user_menu_item_find_menu(ListBase *lb, const MenuType *mt)
@@ -128,7 +129,7 @@ bUserMenuItem_Menu *ED_screen_user_menu_item_find_menu(ListBase *lb, const MenuT
}
}
}
return NULL;
return nullptr;
}
bUserMenuItem_Prop *ED_screen_user_menu_item_find_prop(ListBase *lb,
@@ -146,7 +147,7 @@ bUserMenuItem_Prop *ED_screen_user_menu_item_find_prop(ListBase *lb,
}
}
}
return NULL;
return nullptr;
}
void ED_screen_user_menu_item_add_operator(ListBase *lb,
@@ -164,7 +165,7 @@ void ED_screen_user_menu_item_add_operator(ListBase *lb,
}
STRNCPY(umi_op->op_idname, ot->idname);
STRNCPY(umi_op->op_prop_enum, op_prop_enum);
umi_op->prop = prop ? IDP_CopyProperty(prop) : NULL;
umi_op->prop = prop ? IDP_CopyProperty(prop) : nullptr;
}
void ED_screen_user_menu_item_add_menu(ListBase *lb, const char *ui_name, const MenuType *mt)
@@ -214,25 +215,25 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu)
bool is_empty = true;
for (int um_index = 0; um_index < um_array_len; um_index++) {
bUserMenu *um = um_array[um_index];
if (um == NULL) {
if (um == nullptr) {
continue;
}
LISTBASE_FOREACH (bUserMenuItem *, umi, &um->items) {
const char *ui_name = umi->ui_name[0] ? umi->ui_name : NULL;
const char *ui_name = umi->ui_name[0] ? umi->ui_name : nullptr;
if (umi->type == USER_MENU_TYPE_OPERATOR) {
bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi;
wmOperatorType *ot = WM_operatortype_find(umi_op->op_idname, false);
if (ot != NULL) {
if (ot != nullptr) {
if (umi_op->op_prop_enum[0] == '\0') {
IDProperty *prop = umi_op->prop ? IDP_CopyProperty(umi_op->prop) : NULL;
IDProperty *prop = umi_op->prop ? IDP_CopyProperty(umi_op->prop) : nullptr;
uiItemFullO_ptr(menu->layout,
ot,
CTX_IFACE_(ot->translation_context, ui_name),
ICON_NONE,
prop,
umi_op->opcontext,
wmOperatorCallContext(umi_op->opcontext),
0,
NULL);
nullptr);
}
else {
/* umi_op->prop could be used to set other properties but it's currently unsupported.
@@ -243,7 +244,7 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu)
umi_op->op_prop_enum,
CTX_IFACE_(ot->translation_context, ui_name),
ICON_NONE,
NULL);
nullptr);
}
is_empty = false;
}
@@ -257,7 +258,7 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu)
else if (umi->type == USER_MENU_TYPE_MENU) {
bUserMenuItem_Menu *umi_mt = (bUserMenuItem_Menu *)umi;
MenuType *mt = WM_menutype_find(umi_mt->mt_idname, false);
if (mt != NULL) {
if (mt != nullptr) {
uiItemM_ptr(menu->layout, mt, ui_name, ICON_NONE);
is_empty = false;
}
@@ -276,11 +277,12 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu)
*data_path = '\0';
}
PointerRNA ptr = CTX_data_pointer_get(C, umi_pr->context_data_path);
if (ptr.type == NULL) {
if (ptr.type == nullptr) {
PointerRNA ctx_ptr;
RNA_pointer_create(NULL, &RNA_Context, (void *)C, &ctx_ptr);
if (!RNA_path_resolve_full(&ctx_ptr, umi_pr->context_data_path, &ptr, NULL, NULL)) {
ptr.type = NULL;
RNA_pointer_create(nullptr, &RNA_Context, (void *)C, &ctx_ptr);
if (!RNA_path_resolve_full(&ctx_ptr, umi_pr->context_data_path, &ptr, nullptr, nullptr))
{
ptr.type = nullptr;
}
}
if (data_path) {
@@ -289,11 +291,11 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu)
}
bool ok = false;
if (ptr.type != NULL) {
PropertyRNA *prop = NULL;
if (ptr.type != nullptr) {
PropertyRNA *prop = nullptr;
PointerRNA prop_ptr = ptr;
if ((data_path == NULL) || RNA_path_resolve_full(&ptr, data_path, &prop_ptr, NULL, NULL))
{
if ((data_path == nullptr) ||
RNA_path_resolve_full(&ptr, data_path, &prop_ptr, nullptr, nullptr)) {
prop = RNA_struct_find_property(&prop_ptr, umi_pr->prop_id);
if (prop) {
ok = true;
@@ -327,7 +329,7 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu)
void ED_screen_user_menu_register(void)
{
MenuType *mt = MEM_callocN(sizeof(MenuType), __func__);
MenuType *mt = static_cast<MenuType *>(MEM_callocN(sizeof(MenuType), __func__));
STRNCPY(mt->idname, "SCREEN_MT_user_menu");
STRNCPY(mt->label, N_("Quick Favorites"));
STRNCPY(mt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);

View File

@@ -43,14 +43,14 @@
#include "screen_intern.h"
typedef struct ScreenshotData {
struct ScreenshotData {
uint8_t *dumprect;
int dumpsx, dumpsy;
rcti crop;
bool use_crop;
ImageFormatData im_format;
} ScreenshotData;
};
/* call from both exec and invoke */
static int screenshot_data_create(bContext *C, wmOperator *op, ScrArea *area)
@@ -65,7 +65,8 @@ static int screenshot_data_create(bContext *C, wmOperator *op, ScrArea *area)
uint8_t *dumprect = WM_window_pixels_read(C, win, dumprect_size);
if (dumprect) {
ScreenshotData *scd = MEM_callocN(sizeof(ScreenshotData), "screenshot");
ScreenshotData *scd = static_cast<ScreenshotData *>(
MEM_callocN(sizeof(ScreenshotData), "screenshot"));
scd->dumpsx = dumprect_size[0];
scd->dumpsy = dumprect_size[1];
@@ -80,33 +81,33 @@ static int screenshot_data_create(bContext *C, wmOperator *op, ScrArea *area)
return true;
}
op->customdata = NULL;
op->customdata = nullptr;
return false;
}
static void screenshot_data_free(wmOperator *op)
{
ScreenshotData *scd = op->customdata;
ScreenshotData *scd = static_cast<ScreenshotData *>(op->customdata);
if (scd) {
if (scd->dumprect) {
MEM_freeN(scd->dumprect);
}
MEM_freeN(scd);
op->customdata = NULL;
op->customdata = nullptr;
}
}
static int screenshot_exec(bContext *C, wmOperator *op)
{
const bool use_crop = STREQ(op->idname, "SCREEN_OT_screenshot_area");
ScreenshotData *scd = op->customdata;
ScreenshotData *scd = static_cast<ScreenshotData *>(op->customdata);
bool ok = false;
if (scd == NULL) {
if (scd == nullptr) {
/* when running exec directly */
screenshot_data_create(C, op, use_crop ? CTX_wm_area(C) : NULL);
scd = op->customdata;
screenshot_data_create(C, op, use_crop ? CTX_wm_area(C) : nullptr);
scd = static_cast<ScreenshotData *>(op->customdata);
}
if (scd) {
@@ -152,12 +153,12 @@ static int screenshot_exec(bContext *C, wmOperator *op)
static int screenshot_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
const bool use_crop = STREQ(op->idname, "SCREEN_OT_screenshot_area");
ScrArea *area = NULL;
ScrArea *area = nullptr;
if (use_crop) {
area = CTX_wm_area(C);
bScreen *screen = CTX_wm_screen(C);
ScrArea *area_test = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->xy);
if (area_test != NULL) {
if (area_test != nullptr) {
area = area_test;
}
}
@@ -187,42 +188,47 @@ static int screenshot_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
}
static bool screenshot_check(bContext *UNUSED(C), wmOperator *op)
static bool screenshot_check(bContext * /*C*/, wmOperator *op)
{
ScreenshotData *scd = op->customdata;
ScreenshotData *scd = static_cast<ScreenshotData *>(op->customdata);
return WM_operator_filesel_ensure_ext_imtype(op, &scd->im_format);
}
static void screenshot_cancel(bContext *UNUSED(C), wmOperator *op)
static void screenshot_cancel(bContext * /*C*/, wmOperator *op)
{
screenshot_data_free(op);
}
static bool screenshot_draw_check_prop(PointerRNA *UNUSED(ptr),
static bool screenshot_draw_check_prop(PointerRNA * /*ptr*/,
PropertyRNA *prop,
void *UNUSED(user_data))
void * /*user_data*/)
{
const char *prop_id = RNA_property_identifier(prop);
return !STREQ(prop_id, "filepath");
}
static void screenshot_draw(bContext *UNUSED(C), wmOperator *op)
static void screenshot_draw(bContext * /*C*/, wmOperator *op)
{
uiLayout *layout = op->layout;
ScreenshotData *scd = op->customdata;
ScreenshotData *scd = static_cast<ScreenshotData *>(op->customdata);
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
/* image template */
PointerRNA ptr;
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &scd->im_format, &ptr);
RNA_pointer_create(nullptr, &RNA_ImageFormatSettings, &scd->im_format, &ptr);
uiTemplateImageSettings(layout, &ptr, false);
/* main draw call */
uiDefAutoButsRNA(
layout, op->ptr, screenshot_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
uiDefAutoButsRNA(layout,
op->ptr,
screenshot_draw_check_prop,
nullptr,
nullptr,
UI_BUT_LABEL_ALIGN_NONE,
false);
}
static bool screenshot_poll(bContext *C)

View File

@@ -100,7 +100,7 @@ static void workspace_scene_pinning_update(WorkSpace *workspace_new,
if (is_new_pinned) {
if (workspace_new->pin_scene && (workspace_new->pin_scene != active_scene)) {
WM_window_set_active_scene(bmain, C, win, workspace_new->pin_scene);
workspace_new->pin_scene = NULL;
workspace_new->pin_scene = nullptr;
}
}
/* State change 3 - Changing from workspace with pinned scene to unpinned scene. */
@@ -137,13 +137,15 @@ static void workspace_change_update(WorkSpace *workspace_new,
workspace_scene_pinning_update(workspace_new, workspace_old, C);
/* needs to be done before changing mode! (to ensure right context) */
UNUSED_VARS(wm);
#if 0
Object *ob_act = CTX_data_active_object(C) eObjectMode mode_old = workspace_old->object_mode;
eObjectMode mode_new = workspace_new->object_mode;
#if 0
Object *ob_act = CTX_data_active_object(C);
eObjectMode mode_old = workspace_old->object_mode;
eObjectMode mode_new = workspace_new->object_mode;
if (mode_old != mode_new) {
ED_object_mode_set(C, mode_new);
}
if (mode_old != mode_new) {
ED_object_mode_set(C, mode_new);
}
#endif
}
@@ -162,7 +164,7 @@ static WorkSpaceLayout *workspace_change_get_new_layout(Main *bmain,
else {
layout_new = BKE_workspace_active_layout_for_workspace_get(win->workspace_hook, workspace_new);
if (!layout_new) {
layout_new = workspace_new->layouts.first;
layout_new = static_cast<WorkSpaceLayout *>(workspace_new->layouts.first);
}
}
@@ -178,7 +180,7 @@ bool ED_workspace_change(WorkSpace *workspace_new, bContext *C, wmWindowManager
bScreen *screen_new = BKE_workspace_layout_screen_get(layout_new);
bScreen *screen_old = BKE_workspace_active_screen_get(win->workspace_hook);
win->workspace_hook->temp_layout_store = NULL;
win->workspace_hook->temp_layout_store = nullptr;
if (workspace_old == workspace_new) {
/* Could also return true, everything that needs to be done was done (nothing :P),
* but nothing changed */
@@ -189,7 +191,7 @@ bool ED_workspace_change(WorkSpace *workspace_new, bContext *C, wmWindowManager
screen_change_prepare(screen_old, screen_new, bmain, C, win);
if (screen_new == NULL) {
if (screen_new == nullptr) {
return false;
}
@@ -205,7 +207,7 @@ bool ED_workspace_change(WorkSpace *workspace_new, bContext *C, wmWindowManager
/* Automatic mode switching. */
if (workspace_new->object_mode != workspace_old->object_mode) {
ED_object_mode_set(C, workspace_new->object_mode);
ED_object_mode_set(C, eObjectMode(workspace_new->object_mode));
}
return true;
@@ -243,21 +245,21 @@ bool ED_workspace_delete(WorkSpace *workspace, Main *bmain, bContext *C, wmWindo
ListBase ordered;
BKE_id_ordered_list(&ordered, &bmain->workspaces);
WorkSpace *prev = NULL, *next = NULL;
WorkSpace *prev = nullptr, *next = nullptr;
LISTBASE_FOREACH (LinkData *, link, &ordered) {
if (link->data == workspace) {
prev = link->prev ? link->prev->data : NULL;
next = link->next ? link->next->data : NULL;
prev = static_cast<WorkSpace *>(link->prev ? link->prev->data : nullptr);
next = static_cast<WorkSpace *>(link->next ? link->next->data : nullptr);
break;
}
}
BLI_freelistN(&ordered);
BLI_assert((prev != NULL) || (next != NULL));
BLI_assert((prev != nullptr) || (next != nullptr));
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
WorkSpace *workspace_active = WM_window_get_active_workspace(win);
if (workspace_active == workspace) {
ED_workspace_change((prev != NULL) ? prev : next, C, wm, win);
ED_workspace_change((prev != nullptr) ? prev : next, C, wm, win);
}
}
@@ -289,10 +291,10 @@ static WorkSpace *workspace_context_get(bContext *C)
static bool workspace_context_poll(bContext *C)
{
return workspace_context_get(C) != NULL;
return workspace_context_get(C) != nullptr;
}
static int workspace_new_exec(bContext *C, wmOperator *UNUSED(op))
static int workspace_new_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
wmWindow *win = CTX_wm_window(C);
@@ -317,11 +319,11 @@ static void WORKSPACE_OT_duplicate(wmOperatorType *ot)
ot->exec = workspace_new_exec;
}
static int workspace_delete_exec(bContext *C, wmOperator *UNUSED(op))
static int workspace_delete_exec(bContext *C, wmOperator * /*op*/)
{
WorkSpace *workspace = workspace_context_get(C);
WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_DELETE, workspace);
WM_event_add_notifier(C, NC_WINDOW, NULL);
WM_event_add_notifier(C, NC_WINDOW, nullptr);
return OPERATOR_FINISHED;
}
@@ -369,10 +371,10 @@ static int workspace_append_activate_exec(bContext *C, wmOperator *op)
}
/* Set defaults. */
BLO_update_defaults_workspace(appended_workspace, NULL);
BLO_update_defaults_workspace(appended_workspace, nullptr);
/* Reorder to last position. */
BKE_id_reorder(&bmain->workspaces, &appended_workspace->id, NULL, true);
BKE_id_reorder(&bmain->workspaces, &appended_workspace->id, nullptr, true);
/* Changing workspace changes context. Do delayed! */
WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_SET, appended_workspace);
@@ -395,11 +397,11 @@ static void WORKSPACE_OT_append_activate(wmOperatorType *ot)
RNA_def_string(ot->srna,
"idname",
NULL,
nullptr,
MAX_ID_NAME - 2,
"Identifier",
"Name of the workspace to append and activate");
RNA_def_string(ot->srna, "filepath", NULL, FILE_MAX, "Filepath", "Path to the library");
RNA_def_string(ot->srna, "filepath", nullptr, FILE_MAX, "Filepath", "Path to the library");
}
static WorkspaceConfigFileData *workspace_config_file_read(const char *app_template)
@@ -412,26 +414,28 @@ static WorkspaceConfigFileData *workspace_config_file_read(const char *app_templ
}
bool has_path = BLI_exists(startup_file_path);
return (has_path) ? BKE_blendfile_workspace_config_read(startup_file_path, NULL, 0, NULL) : NULL;
return (has_path) ? BKE_blendfile_workspace_config_read(startup_file_path, nullptr, 0, nullptr) :
nullptr;
}
static WorkspaceConfigFileData *workspace_system_file_read(const char *app_template)
{
if (app_template == NULL) {
if (app_template == nullptr) {
return BKE_blendfile_workspace_config_read(
NULL, datatoc_startup_blend, datatoc_startup_blend_size, NULL);
nullptr, datatoc_startup_blend, datatoc_startup_blend_size, nullptr);
}
char template_dir[FILE_MAX];
if (!BKE_appdir_app_template_id_search(app_template, template_dir, sizeof(template_dir))) {
return NULL;
return nullptr;
}
char startup_file_path[FILE_MAX];
BLI_path_join(startup_file_path, sizeof(startup_file_path), template_dir, BLENDER_STARTUP_FILE);
bool has_path = BLI_exists(startup_file_path);
return (has_path) ? BKE_blendfile_workspace_config_read(startup_file_path, NULL, 0, NULL) : NULL;
return (has_path) ? BKE_blendfile_workspace_config_read(startup_file_path, nullptr, 0, nullptr) :
nullptr;
}
static void workspace_append_button(uiLayout *layout,
@@ -453,7 +457,7 @@ static void workspace_append_button(uiLayout *layout,
ot_append,
CTX_DATA_(BLT_I18NCONTEXT_ID_WORKSPACE, workspace->id.name + 2),
ICON_NONE,
NULL,
nullptr,
WM_OP_EXEC_DEFAULT,
0,
&opptr);
@@ -461,9 +465,9 @@ static void workspace_append_button(uiLayout *layout,
RNA_string_set(&opptr, "filepath", filepath);
}
static void workspace_add_menu(bContext *UNUSED(C), uiLayout *layout, void *template_v)
static void workspace_add_menu(bContext * /*C*/, uiLayout *layout, void *template_v)
{
const char *app_template = template_v;
const char *app_template = static_cast<const char *>(template_v);
bool has_startup_items = false;
wmOperatorType *ot_append = WM_operatortype_find("WORKSPACE_OT_append_activate", true);
@@ -508,25 +512,25 @@ static void workspace_add_menu(bContext *UNUSED(C), uiLayout *layout, void *temp
}
}
static int workspace_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int workspace_add_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
uiPopupMenu *pup = UI_popup_menu_begin(
C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, op->type->name), ICON_ADD);
uiLayout *layout = UI_popup_menu_layout(pup);
uiItemMenuF(layout, IFACE_("General"), ICON_NONE, workspace_add_menu, NULL);
uiItemMenuF(layout, IFACE_("General"), ICON_NONE, workspace_add_menu, nullptr);
ListBase templates;
BKE_appdir_app_templates(&templates);
LISTBASE_FOREACH (LinkData *, link, &templates) {
char *template = link->data;
char *app_template = static_cast<char *>(link->data);
char display_name[FILE_MAX];
BLI_path_to_display_name(display_name, sizeof(display_name), IFACE_(template));
BLI_path_to_display_name(display_name, sizeof(display_name), IFACE_(app_template));
/* Steals ownership of link data string. */
uiItemMenuFN(layout, display_name, ICON_NONE, workspace_add_menu, template);
uiItemMenuFN(layout, display_name, ICON_NONE, workspace_add_menu, app_template);
}
BLI_freelistN(&templates);
@@ -555,13 +559,13 @@ static void WORKSPACE_OT_add(wmOperatorType *ot)
ot->invoke = workspace_add_invoke;
}
static int workspace_reorder_to_back_exec(bContext *C, wmOperator *UNUSED(op))
static int workspace_reorder_to_back_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
WorkSpace *workspace = workspace_context_get(C);
BKE_id_reorder(&bmain->workspaces, &workspace->id, NULL, true);
WM_event_add_notifier(C, NC_WINDOW, NULL);
BKE_id_reorder(&bmain->workspaces, &workspace->id, nullptr, true);
WM_event_add_notifier(C, NC_WINDOW, nullptr);
return OPERATOR_INTERFACE;
}
@@ -578,13 +582,13 @@ static void WORKSPACE_OT_reorder_to_back(wmOperatorType *ot)
ot->exec = workspace_reorder_to_back_exec;
}
static int workspace_reorder_to_front_exec(bContext *C, wmOperator *UNUSED(op))
static int workspace_reorder_to_front_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
WorkSpace *workspace = workspace_context_get(C);
BKE_id_reorder(&bmain->workspaces, &workspace->id, NULL, false);
WM_event_add_notifier(C, NC_WINDOW, NULL);
BKE_id_reorder(&bmain->workspaces, &workspace->id, nullptr, false);
WM_event_add_notifier(C, NC_WINDOW, nullptr);
return OPERATOR_INTERFACE;
}
@@ -601,7 +605,7 @@ static void WORKSPACE_OT_reorder_to_front(wmOperatorType *ot)
ot->exec = workspace_reorder_to_front_exec;
}
static int workspace_scene_pin_toggle(bContext *C, wmOperator *UNUSED(op))
static int workspace_scene_pin_toggle(bContext *C, wmOperator * /*op*/)
{
WorkSpace *workspace = workspace_context_get(C);
@@ -609,7 +613,7 @@ static int workspace_scene_pin_toggle(bContext *C, wmOperator *UNUSED(op))
* requires an operator. */
workspace->flags ^= WORKSPACE_USE_PIN_SCENE;
WM_event_add_notifier(C, NC_WORKSPACE, NULL);
WM_event_add_notifier(C, NC_WORKSPACE, nullptr);
return OPERATOR_FINISHED;
}

View File

@@ -111,7 +111,7 @@ static WorkSpaceLayout *workspace_layout_delete_find_new(const WorkSpaceLayout *
}
}
return NULL;
return nullptr;
}
bool ED_workspace_layout_delete(WorkSpace *workspace, WorkSpaceLayout *layout_old, bContext *C)
@@ -139,7 +139,7 @@ bool ED_workspace_layout_delete(WorkSpace *workspace, WorkSpaceLayout *layout_ol
return false;
}
static bool workspace_change_find_new_layout_cb(const WorkSpaceLayout *layout, void *UNUSED(arg))
static bool workspace_change_find_new_layout_cb(const WorkSpaceLayout *layout, void * /*arg*/)
{
/* return false to stop the iterator if we've found a layout that can be activated */
return workspace_layout_set_poll(layout) ? false : true;
@@ -149,7 +149,7 @@ static bScreen *screen_fullscreen_find_associated_normal_screen(const Main *bmai
{
LISTBASE_FOREACH (bScreen *, screen_iter, &bmain->screens) {
if ((screen_iter != screen) && ELEM(screen_iter->state, SCREENMAXIMIZED, SCREENFULL)) {
ScrArea *area = screen_iter->areabase.first;
ScrArea *area = static_cast<ScrArea *>(screen_iter->areabase.first);
if (area && area->full == screen) {
return screen_iter;
}
@@ -180,8 +180,8 @@ WorkSpaceLayout *ED_workspace_screen_change_ensure_unused_layout(
if (screen_is_used_by_other_window(win, screen_temp)) {
/* Screen is already used, try to find a free one. */
layout_temp = BKE_workspace_layout_iter_circular(
workspace, layout_new, workspace_change_find_new_layout_cb, NULL, false);
screen_temp = layout_temp ? BKE_workspace_layout_screen_get(layout_temp) : NULL;
workspace, layout_new, workspace_change_find_new_layout_cb, nullptr, false);
screen_temp = layout_temp ? BKE_workspace_layout_screen_get(layout_temp) : nullptr;
if (!layout_temp || screen_is_used_by_other_window(win, screen_temp)) {
/* Fallback solution: duplicate layout. */
@@ -192,7 +192,7 @@ WorkSpaceLayout *ED_workspace_screen_change_ensure_unused_layout(
return layout_temp;
}
static bool workspace_layout_cycle_iter_cb(const WorkSpaceLayout *layout, void *UNUSED(arg))
static bool workspace_layout_cycle_iter_cb(const WorkSpaceLayout *layout, void * /*arg*/)
{
/* return false to stop iterator when we have found a layout to activate */
return !workspace_layout_set_poll(layout);
@@ -213,7 +213,7 @@ bool ED_workspace_layout_cycle(WorkSpace *workspace, const short direction, bCon
WorkSpaceLayout *new_layout = BKE_workspace_layout_iter_circular(workspace,
old_layout,
workspace_layout_cycle_iter_cb,
NULL,
nullptr,
(direction == -1) ? true :
false);

View File

@@ -17,7 +17,7 @@ set(INC_SYS
)
set(SRC
sound_ops.c
sound_ops.cc
sound_intern.h
)

View File

@@ -56,17 +56,18 @@
/******************** open sound operator ********************/
static void sound_open_cancel(bContext *UNUSED(C), wmOperator *op)
static void sound_open_cancel(bContext * /*C*/, wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
op->customdata = nullptr;
}
static void sound_open_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);
}
@@ -95,7 +96,7 @@ static int sound_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
@@ -103,7 +104,7 @@ static int sound_open_exec(bContext *C, wmOperator *op)
id_us_min(&sound->id);
RNA_id_pointer_create(&sound->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);
}
@@ -115,7 +116,7 @@ static int sound_open_exec(bContext *C, wmOperator *op)
#else /* WITH_AUDASPACE */
static int sound_open_exec(bContext *UNUSED(C), wmOperator *op)
static int sound_open_exec(bContext * /*C*/, wmOperator *op)
{
BKE_report(op->reports, RPT_ERROR, "Compiled without sound support");
@@ -243,7 +244,7 @@ static void sound_update_animation_flags(Scene *scene)
}
scene->id.tag |= LIB_TAG_DOIT;
if (scene->ed != NULL) {
if (scene->ed != nullptr) {
SEQ_for_each_callback(&scene->ed->seqbase, sound_update_animation_flags_fn, scene);
}
@@ -256,7 +257,7 @@ static void sound_update_animation_flags(Scene *scene)
}
}
static int sound_update_animation_flags_exec(bContext *C, wmOperator *UNUSED(op))
static int sound_update_animation_flags_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
@@ -289,7 +290,7 @@ static void SOUND_OT_update_animation_flags(wmOperatorType *ot)
/* ******************************************************* */
static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op))
static int sound_bake_animation_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
/* NOTE: We will be forcefully evaluating dependency graph at every frame, so no need to ensure
@@ -298,7 +299,7 @@ static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op))
int oldfra = scene->r.cfra;
int cfra;
sound_update_animation_flags_exec(C, NULL);
sound_update_animation_flags_exec(C, nullptr);
for (cfra = (scene->r.sfra > 0) ? (scene->r.sfra - 1) : 0; cfra <= scene->r.efra + 1; cfra++) {
scene->r.cfra = cfra;
@@ -348,11 +349,11 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", filepath);
bitrate = RNA_int_get(op->ptr, "bitrate") * 1000;
accuracy = RNA_int_get(op->ptr, "accuracy");
specs.format = RNA_enum_get(op->ptr, "format");
container = RNA_enum_get(op->ptr, "container");
codec = RNA_enum_get(op->ptr, "codec");
specs.format = AUD_SampleFormat(RNA_enum_get(op->ptr, "format"));
container = AUD_Container(RNA_enum_get(op->ptr, "container"));
codec = AUD_Codec(RNA_enum_get(op->ptr, "codec"));
split = RNA_boolean_get(op->ptr, "split_channels");
specs.channels = scene_eval->r.ffcodecdata.audio_channels;
specs.channels = AUD_Channels(scene_eval->r.ffcodecdata.audio_channels);
specs.rate = scene_eval->r.ffcodecdata.audio_mixrate;
BLI_path_abs(filepath, BKE_main_blendfile_path(bmain));
@@ -371,8 +372,8 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
container,
codec,
bitrate,
NULL,
NULL,
nullptr,
nullptr,
error_message,
sizeof(error_message));
}
@@ -386,8 +387,8 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
container,
codec,
bitrate,
NULL,
NULL,
nullptr,
nullptr,
error_message,
sizeof(error_message));
}
@@ -418,7 +419,7 @@ static const EnumPropertyItem container_items[] = {
# endif
{AUD_CONTAINER_OGG, "OGG", 0, "ogg", "Xiph.Org Ogg Container"},
{AUD_CONTAINER_WAV, "WAV", 0, "wav", "Waveform Audio File Format"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static const char *snd_ext_sound[] = {
@@ -429,20 +430,20 @@ static const char *snd_ext_sound[] = {
".mp3",
".ogg",
".wav",
NULL,
nullptr,
};
static bool sound_mixdown_check(bContext *UNUSED(C), wmOperator *op)
static bool sound_mixdown_check(bContext * /*C*/, wmOperator *op)
{
AUD_Container container = RNA_enum_get(op->ptr, "container");
AUD_Container container = AUD_Container(RNA_enum_get(op->ptr, "container"));
const char *extension = NULL;
const char *extension = nullptr;
const EnumPropertyItem *item = container_items;
while (item->identifier != NULL) {
while (item->identifier != nullptr) {
if (item->value == container) {
const char **ext = snd_ext_sound;
while (*ext != NULL) {
while (*ext != nullptr) {
if (STREQ(*ext + 1, item->name)) {
extension = *ext;
break;
@@ -494,9 +495,9 @@ static int sound_mixdown_invoke(bContext *C, wmOperator *op, const wmEvent *even
#ifdef WITH_AUDASPACE
static bool sound_mixdown_draw_check_prop(PointerRNA *UNUSED(ptr),
static bool sound_mixdown_draw_check_prop(PointerRNA * /*ptr*/,
PropertyRNA *prop,
void *UNUSED(user_data))
void * /*user_data*/)
{
const char *prop_id = RNA_property_identifier(prop);
return !STR_ELEM(prop_id, "filepath", "directory", "filename");
@@ -513,20 +514,20 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op)
{AUD_FORMAT_S32, "S32", 0, "S32", "32-bit signed"},
{AUD_FORMAT_FLOAT32, "F32", 0, "F32", "32-bit floating-point"},
{AUD_FORMAT_FLOAT64, "F64", 0, "F64", "64-bit floating-point"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem mp3_format_items[] = {
{AUD_FORMAT_S16, "S16", 0, "S16", "16-bit signed"},
{AUD_FORMAT_S32, "S32", 0, "S32", "32-bit signed"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
# ifdef WITH_SNDFILE
static const EnumPropertyItem flac_format_items[] = {
{AUD_FORMAT_S16, "S16", 0, "S16", "16-bit signed"},
{AUD_FORMAT_S24, "S24", 0, "S24", "24-bit signed"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
# endif
@@ -538,13 +539,13 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op)
{AUD_CODEC_MP3, "MP3", 0, "MP3", "MPEG-2 Audio Layer III"},
{AUD_CODEC_PCM, "PCM", 0, "PCM", "Pulse Code Modulation (RAW)"},
{AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem ogg_codec_items[] = {
{AUD_CODEC_FLAC, "FLAC", 0, "FLAC", "Free Lossless Audio Codec"},
{AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
uiLayout *layout = op->layout;
@@ -557,8 +558,8 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op)
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
AUD_Container container = RNA_enum_get(op->ptr, "container");
AUD_Codec codec = RNA_enum_get(op->ptr, "codec");
AUD_Container container = AUD_Container(RNA_enum_get(op->ptr, "container"));
AUD_Codec codec = AUD_Codec(RNA_enum_get(op->ptr, "codec"));
prop_format = RNA_struct_find_property(op->ptr, "format");
prop_codec = RNA_struct_find_property(op->ptr, "codec");
@@ -650,8 +651,13 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* main draw call */
uiDefAutoButsRNA(
layout, &ptr, sound_mixdown_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
uiDefAutoButsRNA(layout,
&ptr,
sound_mixdown_draw_check_prop,
nullptr,
nullptr,
UI_BUT_LABEL_ALIGN_NONE,
false);
}
#endif /* WITH_AUDASPACE */
@@ -665,7 +671,7 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
{AUD_FORMAT_S32, "S32", 0, "S32", "32-bit signed"},
{AUD_FORMAT_FLOAT32, "F32", 0, "F32", "32-bit floating-point"},
{AUD_FORMAT_FLOAT64, "F64", 0, "F64", "64-bit floating-point"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem codec_items[] = {
@@ -680,7 +686,7 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
# endif
{AUD_CODEC_PCM, "PCM", 0, "PCM", "Pulse Code Modulation (RAW)"},
{AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
#endif /* WITH_AUDASPACE */
@@ -792,13 +798,13 @@ static int sound_unpack_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
int method = RNA_enum_get(op->ptr, "method");
bSound *sound = NULL;
bSound *sound = nullptr;
/* find the supplied image by name */
if (RNA_struct_property_is_set(op->ptr, "id")) {
char sndname[MAX_ID_NAME - 2];
RNA_string_get(op->ptr, "id", sndname);
sound = BLI_findstring(&bmain->sounds, sndname, offsetof(ID, name) + 2);
sound = static_cast<bSound *>(BLI_findstring(&bmain->sounds, sndname, offsetof(ID, name) + 2));
}
if (!sound || !sound->packedfile) {
@@ -811,12 +817,12 @@ static int sound_unpack_exec(bContext *C, wmOperator *op)
"AutoPack is enabled, so image will be packed again on file save");
}
BKE_packedfile_unpack_sound(bmain, op->reports, sound, method);
BKE_packedfile_unpack_sound(bmain, op->reports, sound, ePF_FileStatus(method));
return OPERATOR_FINISHED;
}
static int sound_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int sound_unpack_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
Editing *ed = CTX_data_scene(C)->ed;
bSound *sound;
@@ -867,7 +873,7 @@ static void SOUND_OT_unpack(wmOperatorType *ot)
ot->srna, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "Method", "How to unpack");
/* XXX: weak!, will fail with library, name collisions */
RNA_def_string(
ot->srna, "id", NULL, MAX_ID_NAME - 2, "Sound Name", "Sound data-block name to unpack");
ot->srna, "id", nullptr, MAX_ID_NAME - 2, "Sound Name", "Sound data-block name to unpack");
}
/* ******************************************************* */

View File

@@ -19,10 +19,10 @@ set(INC_SYS
)
set(SRC
buttons_context.c
buttons_ops.c
buttons_context.cc
buttons_ops.cc
buttons_texture.cc
space_buttons.c
space_buttons.cc
buttons_intern.h
)

View File

@@ -77,7 +77,7 @@ static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type)
}
}
return NULL;
return nullptr;
}
/************************* Creating the Path ************************/
@@ -101,7 +101,7 @@ static bool buttons_context_path_view_layer(ButsContextPath *path, wmWindow *win
}
if (buttons_context_path_scene(path)) {
Scene *scene = path->ptr[path->len - 1].data;
Scene *scene = static_cast<Scene *>(path->ptr[path->len - 1].data);
ViewLayer *view_layer = (win->scene == scene) ? WM_window_get_active_view_layer(win) :
BKE_view_layer_default_view(scene);
@@ -125,7 +125,7 @@ static bool buttons_context_path_world(ButsContextPath *path)
}
/* if we have a scene, use the scene's world */
if (buttons_context_path_scene(path)) {
Scene *scene = path->ptr[path->len - 1].data;
Scene *scene = static_cast<Scene *>(path->ptr[path->len - 1].data);
World *world = scene->world;
if (world) {
@@ -156,7 +156,7 @@ static bool buttons_context_path_collection(const bContext *C,
/* if we have a view layer, use the view layer's active collection */
if (buttons_context_path_view_layer(path, window)) {
ViewLayer *view_layer = path->ptr[path->len - 1].data;
ViewLayer *view_layer = static_cast<ViewLayer *>(path->ptr[path->len - 1].data);
BKE_view_layer_synced_ensure(scene, view_layer);
Collection *c = BKE_view_layer_active_collection_get(view_layer)->collection;
@@ -186,7 +186,7 @@ static bool buttons_context_path_linestyle(ButsContextPath *path, wmWindow *wind
}
/* if we have a view layer, use the lineset's linestyle */
if (buttons_context_path_view_layer(path, window)) {
ViewLayer *view_layer = path->ptr[path->len - 1].data;
ViewLayer *view_layer = static_cast<ViewLayer *>(path->ptr[path->len - 1].data);
FreestyleLineStyle *linestyle = BKE_linestyle_active_from_view_layer(view_layer);
if (linestyle) {
RNA_id_pointer_create(&linestyle->id, &path->ptr[path->len]);
@@ -211,7 +211,7 @@ static bool buttons_context_path_object(ButsContextPath *path)
return false;
}
ViewLayer *view_layer = ptr->data;
ViewLayer *view_layer = static_cast<ViewLayer *>(ptr->data);
Object *ob = BKE_view_layer_active_object_get(view_layer);
if (ob) {
@@ -278,10 +278,10 @@ static bool buttons_context_path_data(ButsContextPath *path, int type)
}
/* try to get an object in the path, no pinning supported here */
if (buttons_context_path_object(path)) {
Object *ob = path->ptr[path->len - 1].data;
Object *ob = static_cast<Object *>(path->ptr[path->len - 1].data);
if (ob && ELEM(type, -1, ob->type)) {
RNA_id_pointer_create(ob->data, &path->ptr[path->len]);
RNA_id_pointer_create(static_cast<ID *>(ob->data), &path->ptr[path->len]);
path->len++;
return true;
@@ -295,7 +295,7 @@ static bool buttons_context_path_data(ButsContextPath *path, int type)
static bool buttons_context_path_modifier(ButsContextPath *path)
{
if (buttons_context_path_object(path)) {
Object *ob = path->ptr[path->len - 1].data;
Object *ob = static_cast<Object *>(path->ptr[path->len - 1].data);
if (ELEM(ob->type,
OB_MESH,
@@ -310,7 +310,7 @@ static bool buttons_context_path_modifier(ButsContextPath *path)
OB_VOLUME))
{
ModifierData *md = BKE_object_active_modifier(ob);
if (md != NULL) {
if (md != nullptr) {
RNA_pointer_create(&ob->id, &RNA_Modifier, md, &path->ptr[path->len]);
path->len++;
}
@@ -325,7 +325,7 @@ static bool buttons_context_path_modifier(ButsContextPath *path)
static bool buttons_context_path_shaderfx(ButsContextPath *path)
{
if (buttons_context_path_object(path)) {
Object *ob = path->ptr[path->len - 1].data;
Object *ob = static_cast<Object *>(path->ptr[path->len - 1].data);
if (ob && ELEM(ob->type, OB_GPENCIL_LEGACY)) {
return true;
@@ -345,11 +345,11 @@ static bool buttons_context_path_material(ButsContextPath *path)
}
/* if we have an object, use the object material slot */
if (buttons_context_path_object(path)) {
Object *ob = path->ptr[path->len - 1].data;
Object *ob = static_cast<Object *>(path->ptr[path->len - 1].data);
if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type)) {
Material *ma = BKE_object_material_get(ob, ob->actcol);
if (ma != NULL) {
if (ma != nullptr) {
RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
path->len++;
}
@@ -365,7 +365,7 @@ static bool buttons_context_path_bone(ButsContextPath *path)
{
/* if we have an armature, get the active bone */
if (buttons_context_path_data(path, OB_ARMATURE)) {
bArmature *arm = path->ptr[path->len - 1].data;
bArmature *arm = static_cast<bArmature *>(path->ptr[path->len - 1].data);
if (arm->edbo) {
if (arm->act_edbone) {
@@ -399,8 +399,9 @@ static bool buttons_context_path_pose_bone(ButsContextPath *path)
/* if we have an armature, get the active bone */
if (buttons_context_path_object(path)) {
Object *ob = path->ptr[path->len - 1].data;
bArmature *arm = ob->data; /* path->ptr[path->len-1].data - works too */
Object *ob = static_cast<Object *>(path->ptr[path->len - 1].data);
bArmature *arm = static_cast<bArmature *>(
ob->data); /* path->ptr[path->len-1].data - works too */
if (ob->type != OB_ARMATURE || arm->edbo) {
return false;
@@ -430,7 +431,7 @@ static bool buttons_context_path_particle(ButsContextPath *path)
}
/* if we have an object, get the active particle system */
if (buttons_context_path_object(path)) {
Object *ob = path->ptr[path->len - 1].data;
Object *ob = static_cast<Object *>(path->ptr[path->len - 1].data);
if (ob && ob->type == OB_MESH) {
ParticleSystem *psys = psys_get_current(ob);
@@ -455,9 +456,9 @@ static bool buttons_context_path_brush(const bContext *C, ButsContextPath *path)
}
/* if we have a scene, use the toolsettings brushes */
if (buttons_context_path_scene(path)) {
Scene *scene = path->ptr[path->len - 1].data;
Scene *scene = static_cast<Scene *>(path->ptr[path->len - 1].data);
Brush *br = NULL;
Brush *br = nullptr;
if (scene) {
wmWindow *window = CTX_wm_window(C);
ViewLayer *view_layer = WM_window_get_active_view_layer(window);
@@ -575,7 +576,7 @@ static bool buttons_context_path(
BCONTEXT_VIEW_LAYER,
BCONTEXT_WORLD))
{
RNA_pointer_create(NULL, &RNA_ViewLayer, view_layer, &path->ptr[path->len]);
RNA_pointer_create(nullptr, &RNA_ViewLayer, view_layer, &path->ptr[path->len]);
path->len++;
}
}
@@ -630,7 +631,8 @@ static bool buttons_context_path(
found = buttons_context_path_material(path);
break;
case BCONTEXT_TEXTURE:
found = buttons_context_path_texture(C, path, sbuts->texuser);
found = buttons_context_path_texture(
C, path, static_cast<ButsContextTexture *>(sbuts->texuser));
break;
case BCONTEXT_BONE:
found = buttons_context_path_bone(path);
@@ -694,7 +696,7 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts)
sbuts->path = MEM_callocN(sizeof(ButsContextPath), "ButsContextPath");
}
ButsContextPath *path = sbuts->path;
ButsContextPath *path = static_cast<ButsContextPath *>(sbuts->path);
int pflag = 0;
int flag = 0;
@@ -848,7 +850,7 @@ const char *buttons_context_dir[] = {
"pointcloud",
#endif
"volume",
NULL,
nullptr,
};
int /*eContextResult*/ buttons_context(const bContext *C,
@@ -856,12 +858,12 @@ int /*eContextResult*/ buttons_context(const bContext *C,
bContextDataResult *result)
{
SpaceProperties *sbuts = CTX_wm_space_properties(C);
if (sbuts && sbuts->path == NULL) {
if (sbuts && sbuts->path == nullptr) {
/* path is cleared for SCREEN_OT_redo_last, when global undo does a file-read which clears the
* path (see lib_link_workspace_layout_restore). */
buttons_context_compute(C, sbuts);
}
ButsContextPath *path = sbuts ? sbuts->path : NULL;
ButsContextPath *path = static_cast<ButsContextPath *>(sbuts ? sbuts->path : nullptr);
if (!path) {
return CTX_RESULT_MEMBER_NOT_FOUND;
@@ -956,10 +958,10 @@ int /*eContextResult*/ buttons_context(const bContext *C,
return CTX_RESULT_OK;
}
if (CTX_data_equals(member, "texture")) {
ButsContextTexture *ct = sbuts->texuser;
ButsContextTexture *ct = static_cast<ButsContextTexture *>(sbuts->texuser);
if (ct) {
if (ct->texture == NULL) {
if (ct->texture == nullptr) {
return CTX_RESULT_NO_DATA;
}
@@ -972,7 +974,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
if (ptr) {
Object *ob = ptr->data;
Object *ob = static_cast<Object *>(ptr->data);
if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type) && ob->totcol) {
/* a valid actcol isn't ensured #27526. */
@@ -989,7 +991,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
return CTX_RESULT_OK;
}
if (CTX_data_equals(member, "texture_user")) {
ButsContextTexture *ct = sbuts->texuser;
ButsContextTexture *ct = static_cast<ButsContextTexture *>(sbuts->texuser);
if (!ct) {
return CTX_RESULT_NO_DATA;
@@ -1003,7 +1005,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
return CTX_RESULT_OK;
}
if (CTX_data_equals(member, "texture_user_property")) {
ButsContextTexture *ct = sbuts->texuser;
ButsContextTexture *ct = static_cast<ButsContextTexture *>(sbuts->texuser);
if (!ct) {
return CTX_RESULT_NO_DATA;
@@ -1011,13 +1013,13 @@ int /*eContextResult*/ buttons_context(const bContext *C,
if (ct->user && ct->user->ptr.data) {
ButsTextureUser *user = ct->user;
CTX_data_pointer_set(result, NULL, &RNA_Property, user->prop);
CTX_data_pointer_set(result, nullptr, &RNA_Property, user->prop);
}
return CTX_RESULT_OK;
}
if (CTX_data_equals(member, "texture_node")) {
ButsContextTexture *ct = sbuts->texuser;
ButsContextTexture *ct = static_cast<ButsContextTexture *>(sbuts->texuser);
if (ct) {
/* new shading system */
@@ -1030,7 +1032,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
return CTX_RESULT_NO_DATA;
}
if (CTX_data_equals(member, "texture_slot")) {
ButsContextTexture *ct = sbuts->texuser;
ButsContextTexture *ct = static_cast<ButsContextTexture *>(sbuts->texuser);
PointerRNA *ptr;
/* Particles slots are used in both old and new textures handling. */
@@ -1046,7 +1048,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
return CTX_RESULT_MEMBER_NOT_FOUND; /* new shading system */
}
else if ((ptr = get_pointer_type(path, &RNA_FreestyleLineStyle))) {
FreestyleLineStyle *ls = ptr->data;
FreestyleLineStyle *ls = static_cast<FreestyleLineStyle *>(ptr->data);
if (ls) {
CTX_data_pointer_set(
@@ -1077,7 +1079,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
set_pointer_type(path, result, &RNA_ParticleSystem);
}
else {
CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL);
CTX_data_pointer_set(result, nullptr, &RNA_ParticleSystem, nullptr);
}
return CTX_RESULT_OK;
}
@@ -1106,7 +1108,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
if (ptr && ptr->data) {
Object *ob = ptr->data;
Object *ob = static_cast<Object *>(ptr->data);
ModifierData *md = BKE_modifiers_findby_type(ob, eModifierType_Cloth);
CTX_data_pointer_set(result, &ob->id, &RNA_ClothModifier, md);
return CTX_RESULT_OK;
@@ -1117,7 +1119,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
if (ptr && ptr->data) {
Object *ob = ptr->data;
Object *ob = static_cast<Object *>(ptr->data);
ModifierData *md = BKE_modifiers_findby_type(ob, eModifierType_Softbody);
CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodyModifier, md);
return CTX_RESULT_OK;
@@ -1129,7 +1131,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
if (ptr && ptr->data) {
Object *ob = ptr->data;
Object *ob = static_cast<Object *>(ptr->data);
ModifierData *md = BKE_modifiers_findby_type(ob, eModifierType_Fluid);
CTX_data_pointer_set(result, &ob->id, &RNA_FluidModifier, md);
return CTX_RESULT_OK;
@@ -1140,7 +1142,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
if (ptr && ptr->data) {
Object *ob = ptr->data;
Object *ob = static_cast<Object *>(ptr->data);
ModifierData *md = BKE_modifiers_findby_type(ob, eModifierType_Collision);
CTX_data_pointer_set(result, &ob->id, &RNA_CollisionModifier, md);
return CTX_RESULT_OK;
@@ -1155,7 +1157,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
if (ptr && ptr->data) {
Object *ob = ptr->data;
Object *ob = static_cast<Object *>(ptr->data);
ModifierData *md = BKE_modifiers_findby_type(ob, eModifierType_DynamicPaint);
CTX_data_pointer_set(result, &ob->id, &RNA_DynamicPaintModifier, md);
return CTX_RESULT_OK;
@@ -1179,7 +1181,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
/************************* Drawing the Path ************************/
static bool buttons_panel_context_poll(const bContext *C, PanelType *UNUSED(pt))
static bool buttons_panel_context_poll(const bContext *C, PanelType * /*pt*/)
{
SpaceProperties *sbuts = CTX_wm_space_properties(C);
return sbuts->mainb != BCONTEXT_TOOL;
@@ -1188,7 +1190,7 @@ static bool buttons_panel_context_poll(const bContext *C, PanelType *UNUSED(pt))
static void buttons_panel_context_draw(const bContext *C, Panel *panel)
{
SpaceProperties *sbuts = CTX_wm_space_properties(C);
ButsContextPath *path = sbuts->path;
ButsContextPath *path = static_cast<ButsContextPath *>(sbuts->path);
if (!path) {
return;
@@ -1228,14 +1230,14 @@ static void buttons_panel_context_draw(const bContext *C, Panel *panel)
uiItemL(row, "", ICON_RIGHTARROW);
}
if (ptr->data == NULL) {
if (ptr->data == nullptr) {
continue;
}
/* Add icon and name. */
int icon = RNA_struct_ui_icon(ptr->type);
char namebuf[128];
char *name = RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL);
char *name = RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), nullptr);
if (name) {
uiItemLDrag(row, ptr, name, icon);
@@ -1263,7 +1265,8 @@ static void buttons_panel_context_draw(const bContext *C, Panel *panel)
void buttons_context_register(ARegionType *art)
{
PanelType *pt = MEM_callocN(sizeof(PanelType), "spacetype buttons panel context");
PanelType *pt = static_cast<PanelType *>(
MEM_callocN(sizeof(PanelType), "spacetype buttons panel context"));
STRNCPY(pt->idname, "PROPERTIES_PT_context");
STRNCPY(pt->label, N_("Context")); /* XXX C panels unavailable through RNA bpy.types! */
STRNCPY(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
@@ -1276,10 +1279,10 @@ void buttons_context_register(ARegionType *art)
ID *buttons_context_id_path(const bContext *C)
{
SpaceProperties *sbuts = CTX_wm_space_properties(C);
ButsContextPath *path = sbuts->path;
ButsContextPath *path = static_cast<ButsContextPath *>(sbuts->path);
if (path->len == 0) {
return NULL;
return nullptr;
}
for (int i = path->len - 1; i >= 0; i--) {
@@ -1288,7 +1291,7 @@ ID *buttons_context_id_path(const bContext *C)
/* Pin particle settings instead of system, since only settings are an idblock. */
if (sbuts->mainb == BCONTEXT_PARTICLE && sbuts->flag & SB_PIN_CONTEXT) {
if (ptr->type == &RNA_ParticleSystem && ptr->data) {
ParticleSystem *psys = ptr->data;
ParticleSystem *psys = static_cast<ParticleSystem *>(ptr->data);
return &psys->part->id;
}
}
@@ -1305,5 +1308,5 @@ ID *buttons_context_id_path(const bContext *C)
}
}
return NULL;
return nullptr;
}

View File

@@ -45,7 +45,7 @@
* \note Almost a duplicate of the file browser operator #FILE_OT_start_filter.
* \{ */
static int buttons_start_filter_exec(bContext *C, wmOperator *UNUSED(op))
static int buttons_start_filter_exec(bContext *C, wmOperator * /*op*/)
{
SpaceProperties *space = CTX_wm_space_properties(C);
ScrArea *area = CTX_wm_area(C);
@@ -68,7 +68,7 @@ void BUTTONS_OT_start_filter(wmOperatorType *ot)
ot->poll = ED_operator_buttons_active;
}
static int buttons_clear_filter_exec(bContext *C, wmOperator *UNUSED(op))
static int buttons_clear_filter_exec(bContext *C, wmOperator * /*op*/)
{
SpaceProperties *space = CTX_wm_space_properties(C);
@@ -99,7 +99,7 @@ void BUTTONS_OT_clear_filter(wmOperatorType *ot)
/** \name Pin ID Operator
* \{ */
static int toggle_pin_exec(bContext *C, wmOperator *UNUSED(op))
static int toggle_pin_exec(bContext *C, wmOperator * /*op*/)
{
SpaceProperties *sbuts = CTX_wm_space_properties(C);
@@ -112,7 +112,7 @@ static int toggle_pin_exec(bContext *C, wmOperator *UNUSED(op))
/* Create the new ID pointer and set the pin ID with RNA
* so we can use the property's RNA update functionality. */
ID *new_id = (sbuts->flag & SB_PIN_CONTEXT) ? buttons_context_id_path(C) : NULL;
ID *new_id = (sbuts->flag & SB_PIN_CONTEXT) ? buttons_context_id_path(C) : nullptr;
PointerRNA new_id_ptr;
RNA_id_pointer_create(new_id, &new_id_ptr);
RNA_pointer_set(&sbuts_ptr, "pin_id", new_id_ptr);
@@ -140,12 +140,12 @@ void BUTTONS_OT_toggle_pin(wmOperatorType *ot)
/** \name Context Menu Operator
* \{ */
static int context_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
static int context_menu_invoke(bContext *C, wmOperator * /*op*/, const wmEvent * /*event*/)
{
uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Context Menu"), ICON_NONE);
uiLayout *layout = UI_popup_menu_layout(pup);
uiItemM(layout, "INFO_MT_area", NULL, ICON_NONE);
uiItemM(layout, "INFO_MT_area", nullptr, ICON_NONE);
UI_popup_menu_end(C, pup);
return OPERATOR_INTERFACE;
@@ -169,28 +169,28 @@ void BUTTONS_OT_context_menu(wmOperatorType *ot)
/** \name File Browse Operator
* \{ */
typedef struct FileBrowseOp {
struct FileBrowseOp {
PointerRNA ptr;
PropertyRNA *prop;
bool is_undo;
bool is_userdef;
} FileBrowseOp;
};
static int file_browse_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
FileBrowseOp *fbo = op->customdata;
FileBrowseOp *fbo = static_cast<FileBrowseOp *>(op->customdata);
ID *id;
char *path;
int path_len;
const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" :
"filepath";
if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == NULL) {
if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == nullptr) {
return OPERATOR_CANCELLED;
}
path = RNA_string_get_alloc(op->ptr, path_prop, NULL, 0, &path_len);
path = RNA_string_get_alloc(op->ptr, path_prop, nullptr, 0, &path_len);
/* Add slash for directories, important for some properties. */
if (RNA_property_subtype(fbo->prop) == PROP_DIRPATH) {
@@ -207,11 +207,11 @@ static int file_browse_exec(bContext *C, wmOperator *op)
if (is_relative) {
BLI_path_rel(path_buf, BKE_main_blendfile_path(bmain));
path_len = strlen(path_buf);
path = MEM_reallocN(path, path_len + 1);
path = static_cast<char *>(MEM_reallocN(path, path_len + 1));
memcpy(path, path_buf, path_len + 1);
}
else {
path = MEM_reallocN(path, path_len + 1);
path = static_cast<char *>(MEM_reallocN(path, path_len + 1));
}
}
else {
@@ -251,10 +251,10 @@ static int file_browse_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static void file_browse_cancel(bContext *UNUSED(C), wmOperator *op)
static void file_browse_cancel(bContext * /*C*/, wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
op->customdata = nullptr;
}
static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -278,7 +278,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
}
path = RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL);
path = RNA_property_string_get_alloc(&ptr, prop, nullptr, 0, nullptr);
/* Useful yet irritating feature, Shift+Click to open the file
* Alt+Click to browse a folder in the OS's browser. */
@@ -295,7 +295,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
WM_operator_properties_create_ptr(&props_ptr, ot);
RNA_string_set(&props_ptr, "filepath", path);
WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &props_ptr, NULL);
WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &props_ptr, nullptr);
WM_operator_properties_free(&props_ptr);
MEM_freeN(path);
@@ -305,7 +305,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
PropertyRNA *prop_relpath;
const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" :
"filepath";
fbo = MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp");
fbo = static_cast<FileBrowseOp *>(MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp"));
fbo->ptr = ptr;
fbo->prop = prop;
fbo->is_undo = is_undo;

View File

@@ -46,25 +46,25 @@
/** \name Default Callbacks for Properties Space
* \{ */
static SpaceLink *buttons_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *buttons_create(const ScrArea * /*area*/, const Scene * /*scene*/)
{
ARegion *region;
SpaceProperties *sbuts;
sbuts = MEM_callocN(sizeof(SpaceProperties), "initbuts");
sbuts = static_cast<SpaceProperties *>(MEM_callocN(sizeof(SpaceProperties), "initbuts"));
sbuts->spacetype = SPACE_PROPERTIES;
sbuts->mainb = sbuts->mainbuser = BCONTEXT_OBJECT;
/* header */
region = MEM_callocN(sizeof(ARegion), "header for buts");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "header for buts"));
BLI_addtail(&sbuts->regionbase, region);
region->regiontype = RGN_TYPE_HEADER;
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
/* navigation bar */
region = MEM_callocN(sizeof(ARegion), "navigation bar for buts");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "navigation bar for buts"));
BLI_addtail(&sbuts->regionbase, region);
region->regiontype = RGN_TYPE_NAV_BAR;
@@ -79,7 +79,7 @@ static SpaceLink *buttons_create(const ScrArea *UNUSED(area), const Scene *UNUSE
#endif
/* main region */
region = MEM_callocN(sizeof(ARegion), "main region for buts");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "main region for buts"));
BLI_addtail(&sbuts->regionbase, region);
region->regiontype = RGN_TYPE_WINDOW;
@@ -97,24 +97,25 @@ static void buttons_free(SpaceLink *sl)
}
if (sbuts->texuser) {
ButsContextTexture *ct = sbuts->texuser;
ButsContextTexture *ct = static_cast<ButsContextTexture *>(sbuts->texuser);
BLI_freelistN(&ct->users);
MEM_freeN(ct);
}
if (sbuts->runtime != NULL) {
if (sbuts->runtime != nullptr) {
MEM_SAFE_FREE(sbuts->runtime->tab_search_results);
MEM_freeN(sbuts->runtime);
}
}
/* spacetype; init callback */
static void buttons_init(wmWindowManager *UNUSED(wm), ScrArea *area)
static void buttons_init(wmWindowManager * /*wm*/, ScrArea *area)
{
SpaceProperties *sbuts = (SpaceProperties *)area->spacedata.first;
if (sbuts->runtime == NULL) {
sbuts->runtime = MEM_mallocN(sizeof(SpaceProperties_Runtime), __func__);
if (sbuts->runtime == nullptr) {
sbuts->runtime = static_cast<SpaceProperties_Runtime *>(
MEM_mallocN(sizeof(SpaceProperties_Runtime), __func__));
sbuts->runtime->search_string[0] = '\0';
sbuts->runtime->tab_search_results = BLI_BITMAP_NEW(BCONTEXT_TOT * 2, __func__);
}
@@ -123,13 +124,13 @@ static void buttons_init(wmWindowManager *UNUSED(wm), ScrArea *area)
static SpaceLink *buttons_duplicate(SpaceLink *sl)
{
SpaceProperties *sfile_old = (SpaceProperties *)sl;
SpaceProperties *sbutsn = MEM_dupallocN(sl);
SpaceProperties *sbutsn = static_cast<SpaceProperties *>(MEM_dupallocN(sl));
/* clear or remove stuff from old */
sbutsn->path = NULL;
sbutsn->texuser = NULL;
if (sfile_old->runtime != NULL) {
sbutsn->runtime = MEM_dupallocN(sfile_old->runtime);
sbutsn->path = nullptr;
sbutsn->texuser = nullptr;
if (sfile_old->runtime != nullptr) {
sbutsn->runtime = static_cast<SpaceProperties_Runtime *>(MEM_dupallocN(sfile_old->runtime));
sbutsn->runtime->search_string[0] = '\0';
sbutsn->runtime->tab_search_results = BLI_BITMAP_NEW(BCONTEXT_TOT, __func__);
}
@@ -301,9 +302,9 @@ static void buttons_main_region_layout_properties(const bContext *C,
{
buttons_context_compute(C, sbuts);
const char *contexts[2] = {buttons_main_region_context_string(sbuts->mainb), NULL};
const char *contexts[2] = {buttons_main_region_context_string(sbuts->mainb), nullptr};
ED_region_panels_layout_ex(C, region, &region->type->paneltypes, contexts, NULL);
ED_region_panels_layout_ex(C, region, &region->type->paneltypes, contexts, nullptr);
}
/** \} */
@@ -340,14 +341,14 @@ bool ED_buttons_tab_has_search_result(SpaceProperties *sbuts, const int index)
static bool property_search_for_context(const bContext *C, ARegion *region, SpaceProperties *sbuts)
{
const char *contexts[2] = {buttons_main_region_context_string(sbuts->mainb), NULL};
const char *contexts[2] = {buttons_main_region_context_string(sbuts->mainb), nullptr};
if (sbuts->mainb == BCONTEXT_TOOL) {
return false;
}
buttons_context_compute(C, sbuts);
return ED_region_property_search(C, region, &region->type->paneltypes, contexts, NULL);
return ED_region_property_search(C, region, &region->type->paneltypes, contexts, nullptr);
}
static void property_search_move_to_next_tab_with_results(SpaceProperties *sbuts,
@@ -393,7 +394,7 @@ static void property_search_all_tabs(const bContext *C,
/* Use local copies of the area and duplicate the region as a mainly-paranoid protection
* against changing any of the space / region data while running the search. */
ScrArea *area_original = CTX_wm_area(C);
ScrArea area_copy = *area_original;
ScrArea area_copy = blender::dna::shallow_copy(*area_original);
ARegion *region_copy = BKE_area_region_copy(area_copy.type, region_original);
/* Set the region visible field. Otherwise some layout code thinks we're drawing in a popup.
* This likely isn't necessary, but it's nice to emulate a "real" region where possible. */
@@ -401,11 +402,11 @@ static void property_search_all_tabs(const bContext *C,
CTX_wm_area_set((bContext *)C, &area_copy);
CTX_wm_region_set((bContext *)C, region_copy);
SpaceProperties sbuts_copy = *sbuts;
sbuts_copy.path = NULL;
sbuts_copy.texuser = NULL;
sbuts_copy.runtime = MEM_dupallocN(sbuts->runtime);
sbuts_copy.runtime->tab_search_results = NULL;
SpaceProperties sbuts_copy = blender::dna::shallow_copy(*sbuts);
sbuts_copy.path = nullptr;
sbuts_copy.texuser = nullptr;
sbuts_copy.runtime = static_cast<SpaceProperties_Runtime *>(MEM_dupallocN(sbuts->runtime));
sbuts_copy.runtime->tab_search_results = nullptr;
BLI_listbase_clear(&area_copy.spacedata);
BLI_addtail(&area_copy.spacedata, &sbuts_copy);
@@ -544,7 +545,7 @@ static void buttons_keymap(wmKeyConfig *keyconf)
* \{ */
/* add handlers, stuff you only do once or on area/region changes */
static void buttons_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
static void buttons_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
{
ED_region_header_init(region);
}
@@ -564,13 +565,12 @@ static void buttons_header_region_message_subscribe(const wmRegionMessageSubscri
struct wmMsgBus *mbus = params->message_bus;
ScrArea *area = params->area;
ARegion *region = params->region;
SpaceProperties *sbuts = area->spacedata.first;
SpaceProperties *sbuts = static_cast<SpaceProperties *>(area->spacedata.first);
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
.user_data = region,
.notify = ED_region_do_msg_notify_tag_redraw,
};
wmMsgSubscribeValue msg_sub_value_region_tag_redraw{};
msg_sub_value_region_tag_redraw.owner = region;
msg_sub_value_region_tag_redraw.user_data = region;
msg_sub_value_region_tag_redraw.notify = ED_region_do_msg_notify_tag_redraw;
/* Don't check for SpaceProperties.mainb here, we may toggle between view-layers
* where one has no active object, so that available contexts changes. */
@@ -617,11 +617,10 @@ static void buttons_navigation_bar_region_message_subscribe(
struct wmMsgBus *mbus = params->message_bus;
ARegion *region = params->region;
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
.user_data = region,
.notify = ED_region_do_msg_notify_tag_redraw,
};
wmMsgSubscribeValue msg_sub_value_region_tag_redraw{};
msg_sub_value_region_tag_redraw.owner = region;
msg_sub_value_region_tag_redraw.user_data = region;
msg_sub_value_region_tag_redraw.notify = ED_region_do_msg_notify_tag_redraw;
WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_region_tag_redraw);
}
@@ -630,7 +629,7 @@ static void buttons_navigation_bar_region_message_subscribe(
* showing that button set, to reduce unnecessary drawing. */
static void buttons_area_redraw(ScrArea *area, short buttons)
{
SpaceProperties *sbuts = area->spacedata.first;
SpaceProperties *sbuts = static_cast<SpaceProperties *>(area->spacedata.first);
/* if the area's current button set is equal to the one to redraw */
if (sbuts->mainb == buttons) {
@@ -649,7 +648,7 @@ static void buttons_area_listener(const wmSpaceTypeListenerParams *params)
{
ScrArea *area = params->area;
const wmNotifier *wmn = params->notifier;
SpaceProperties *sbuts = area->spacedata.first;
SpaceProperties *sbuts = static_cast<SpaceProperties *>(area->spacedata.first);
/* context changes */
switch (wmn->category) {
@@ -854,7 +853,7 @@ static void buttons_area_listener(const wmSpaceTypeListenerParams *params)
}
}
static void buttons_id_remap(ScrArea *UNUSED(area),
static void buttons_id_remap(ScrArea * /*area*/,
SpaceLink *slink,
const struct IDRemapper *mappings)
{
@@ -867,7 +866,7 @@ static void buttons_id_remap(ScrArea *UNUSED(area),
}
if (sbuts->path) {
ButsContextPath *path = sbuts->path;
ButsContextPath *path = static_cast<ButsContextPath *>(sbuts->path);
for (int i = 0; i < path->len; i++) {
switch (BKE_id_remapper_apply(mappings, &path->ptr[i].owner_id, ID_REMAP_APPLY_DEFAULT)) {
case ID_REMAP_RESULT_SOURCE_UNASSIGNED: {
@@ -902,29 +901,29 @@ static void buttons_id_remap(ScrArea *UNUSED(area),
}
if (sbuts->texuser) {
ButsContextTexture *ct = sbuts->texuser;
ButsContextTexture *ct = static_cast<ButsContextTexture *>(sbuts->texuser);
BKE_id_remapper_apply(mappings, (ID **)&ct->texture, ID_REMAP_APPLY_DEFAULT);
BLI_freelistN(&ct->users);
ct->user = NULL;
ct->user = nullptr;
}
}
static void buttons_space_blend_read_data(BlendDataReader *UNUSED(reader), SpaceLink *sl)
static void buttons_space_blend_read_data(BlendDataReader * /*reader*/, SpaceLink *sl)
{
SpaceProperties *sbuts = (SpaceProperties *)sl;
sbuts->path = NULL;
sbuts->texuser = NULL;
sbuts->path = nullptr;
sbuts->texuser = nullptr;
sbuts->mainbo = sbuts->mainb;
sbuts->mainbuser = sbuts->mainb;
sbuts->runtime = NULL;
sbuts->runtime = nullptr;
}
static void buttons_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
{
SpaceProperties *sbuts = (SpaceProperties *)sl;
BLO_read_id_address(reader, parent_id, &sbuts->pinid);
if (sbuts->pinid == NULL) {
if (sbuts->pinid == nullptr) {
sbuts->flag &= ~SB_PIN_CONTEXT;
}
}
@@ -942,7 +941,7 @@ static void buttons_space_blend_write(BlendWriter *writer, SpaceLink *sl)
void ED_spacetype_buttons(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype buttons");
SpaceType *st = static_cast<SpaceType *>(MEM_callocN(sizeof(SpaceType), "spacetype buttons"));
ARegionType *art;
st->spaceid = SPACE_PROPERTIES;
@@ -962,7 +961,7 @@ void ED_spacetype_buttons(void)
st->blend_write = buttons_space_blend_write;
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype buttons region"));
art->regionid = RGN_TYPE_WINDOW;
art->init = buttons_main_region_init;
art->layout = buttons_main_region_layout;
@@ -974,15 +973,15 @@ void ED_spacetype_buttons(void)
/* Register the panel types from modifiers. The actual panels are built per modifier rather
* than per modifier type. */
for (ModifierType i = 0; i < NUM_MODIFIER_TYPES; i++) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(i);
if (mti != NULL && mti->panelRegister != NULL) {
for (int i = 0; i < NUM_MODIFIER_TYPES; i++) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(i));
if (mti != nullptr && mti->panelRegister != nullptr) {
mti->panelRegister(art);
}
}
for (int i = 0; i < NUM_GREASEPENCIL_MODIFIER_TYPES; i++) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(i);
if (mti != NULL && mti->panelRegister != NULL) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(GpencilModifierType(i));
if (mti != nullptr && mti->panelRegister != nullptr) {
mti->panelRegister(art);
}
}
@@ -990,14 +989,14 @@ void ED_spacetype_buttons(void)
if (i == eShaderFxType_Light_deprecated) {
continue;
}
const ShaderFxTypeInfo *fxti = BKE_shaderfx_get_info(i);
if (fxti != NULL && fxti->panelRegister != NULL) {
const ShaderFxTypeInfo *fxti = BKE_shaderfx_get_info(ShaderFxType(i));
if (fxti != nullptr && fxti->panelRegister != nullptr) {
fxti->panelRegister(art);
}
}
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype buttons region"));
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
@@ -1008,7 +1007,8 @@ void ED_spacetype_buttons(void)
BLI_addhead(&st->regiontypes, art);
/* regions: navigation bar */
art = MEM_callocN(sizeof(ARegionType), "spacetype nav buttons region");
art = static_cast<ARegionType *>(
MEM_callocN(sizeof(ARegionType), "spacetype nav buttons region"));
art->regionid = RGN_TYPE_NAV_BAR;
art->prefsizex = AREAMINX;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES | ED_KEYMAP_NAVBAR;

View File

@@ -27,14 +27,14 @@ set(SRC
asset_catalog_tree_view.cc
file_draw.cc
file_indexer.cc
file_ops.c
file_panels.c
file_utils.c
file_ops.cc
file_panels.cc
file_utils.cc
filelist.cc
filesel.cc
folder_history.cc
fsmenu.c
space_file.c
space_file.cc
file_indexer.h
file_intern.h

View File

@@ -343,7 +343,7 @@ static FileSelect file_select(
/* Don't act on multiple selected files */
if (sel.first != sel.last) {
select = 0;
select = FileSelType(0);
}
/* Do we have a valid selection and are we actually selecting */
@@ -383,7 +383,7 @@ static bool fsmenu_write_file_and_refresh_or_report_error(struct FSMenu *fsmenu,
{
/* NOTE: use warning instead of error here, because the bookmark operation may be part of
* other actions which should not cause the operator to fail entirely. */
const char *cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL);
const char *cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, nullptr);
if (UNLIKELY(!cfgdir)) {
BKE_report(reports, RPT_ERROR, "Unable to create configuration directory to write bookmarks");
return false;
@@ -465,7 +465,7 @@ static int file_box_select_modal(bContext *C, wmOperator *op, const wmEvent *eve
file_select_deselect_all(sfile, FILE_SEL_HIGHLIGHTED);
filelist_entries_select_index_range_set(
sfile->files, &sel, FILE_SEL_ADD, FILE_SEL_HIGHLIGHTED, CHECK_ALL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, nullptr);
for (idx = sel.last; idx >= 0; idx--) {
const FileDirEntry *file = filelist_file(sfile->files, idx);
@@ -491,7 +491,7 @@ static int file_box_select_modal(bContext *C, wmOperator *op, const wmEvent *eve
params->sel_first = params->sel_last = -1;
fileselect_file_set(C, sfile, params->active_file);
file_select_deselect_all(sfile, FILE_SEL_HIGHLIGHTED);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, nullptr);
}
return result;
@@ -506,7 +506,7 @@ static int file_box_select_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rcti(op, &rect);
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
const bool select = (sel_op != SEL_OP_SUB);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
file_select_deselect_all(sfile, FILE_SEL_SELECTED);
@@ -521,10 +521,10 @@ static int file_box_select_exec(bContext *C, wmOperator *op)
filelist_entry_parent_select_set(sfile->files, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL);
if (FILE_SELECT_DIR == ret) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, nullptr);
}
else if (FILE_SELECT_FILE == ret) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, nullptr);
}
return OPERATOR_FINISHED;
}
@@ -632,14 +632,14 @@ static int file_select_exec(bContext *C, wmOperator *op)
}
}
else if (ret == FILE_SELECT_DIR) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, nullptr);
}
else if (ret == FILE_SELECT_FILE) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, nullptr);
}
WM_event_add_mousemove(CTX_wm_window(C)); /* for directory changes */
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, nullptr);
if ((ret_val == OPERATOR_FINISHED) && pass_through) {
ret_val |= OPERATOR_PASS_THROUGH;
@@ -914,7 +914,7 @@ static bool file_walk_select_do(bContext *C,
fill);
}
static int file_walk_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int file_walk_select_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C);
FileSelectParams *params = ED_fileselect_get_active_params(sfile);
@@ -923,7 +923,7 @@ static int file_walk_select_invoke(bContext *C, wmOperator *op, const wmEvent *U
const bool fill = RNA_boolean_get(op->ptr, "fill");
if (file_walk_select_do(C, sfile, params, direction, extend, fill)) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, nullptr);
return OPERATOR_FINISHED;
}
@@ -1042,7 +1042,7 @@ void FILE_OT_select_all(wmOperatorType *ot)
/** \name View Selected Operator
* \{ */
static int file_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
static int file_view_selected_exec(bContext *C, wmOperator * /*op*/)
{
SpaceFile *sfile = CTX_wm_space_file(C);
FileSelection sel = file_current_selection_range_get(sfile->files);
@@ -1109,7 +1109,7 @@ static int bookmark_select_exec(bContext *C, wmOperator *op)
BLI_path_normalize_dir(params->dir, sizeof(params->dir));
ED_file_change_dir(C);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, nullptr);
return OPERATOR_FINISHED;
}
@@ -1129,7 +1129,7 @@ void FILE_OT_select_bookmark(wmOperatorType *ot)
ot->poll = ED_operator_file_browsing_active;
/* properties */
prop = RNA_def_string(ot->srna, "dir", NULL, FILE_MAXDIR, "Directory", "");
prop = RNA_def_string(ot->srna, "dir", nullptr, FILE_MAXDIR, "Directory", "");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
@@ -1149,7 +1149,7 @@ static int bookmark_add_exec(bContext *C, wmOperator *op)
if (params->dir[0] != '\0') {
fsmenu_insert_entry(
fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, NULL, ICON_FILE_FOLDER, FS_INSERT_SAVE);
fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, nullptr, ICON_FILE_FOLDER, FS_INSERT_SAVE);
fsmenu_write_file_and_refresh_or_report_error(fsmenu, area, op->reports);
}
return OPERATOR_FINISHED;
@@ -1340,7 +1340,7 @@ void FILE_OT_bookmark_move(wmOperatorType *ot)
{FILE_BOOKMARK_MOVE_UP, "UP", 0, "Up", ""},
{FILE_BOOKMARK_MOVE_DOWN, "DOWN", 0, "Down", ""},
{FILE_BOOKMARK_MOVE_BOTTOM, "BOTTOM", 0, "Bottom", "Bottom of the list"},
{0, NULL, 0, NULL, NULL}};
{0, nullptr, 0, nullptr, nullptr}};
/* identifiers */
ot->name = "Move Bookmark";
@@ -1373,7 +1373,7 @@ static int reset_recent_exec(bContext *C, wmOperator *op)
ScrArea *area = CTX_wm_area(C);
struct FSMenu *fsmenu = ED_fsmenu_get();
while (ED_fsmenu_get_entry(fsmenu, FS_CATEGORY_RECENT, 0) != NULL) {
while (ED_fsmenu_get_entry(fsmenu, FS_CATEGORY_RECENT, 0) != nullptr) {
fsmenu_remove_entry(fsmenu, FS_CATEGORY_RECENT, 0);
}
@@ -1409,7 +1409,7 @@ int file_highlight_set(SpaceFile *sfile, ARegion *region, int mx, int my)
/* In case blender starts where the mouse is over a File browser,
* this operator can be invoked when the `sfile` or `sfile->layout` isn't initialized yet. */
if (sfile == NULL || sfile->files == NULL || sfile->layout == NULL) {
if (sfile == nullptr || sfile->files == nullptr || sfile->layout == nullptr) {
return 0;
}
@@ -1449,7 +1449,7 @@ int file_highlight_set(SpaceFile *sfile, ARegion *region, int mx, int my)
return (params->highlight_file != origfile);
}
static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static int file_highlight_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -1483,7 +1483,7 @@ void FILE_OT_highlight(wmOperatorType *ot)
* \{ */
static int file_column_sort_ui_context_invoke(bContext *C,
wmOperator *UNUSED(op),
wmOperator * /*op*/,
const wmEvent *event)
{
const ARegion *region = CTX_wm_region(C);
@@ -1509,7 +1509,7 @@ static int file_column_sort_ui_context_invoke(bContext *C,
params->flag &= ~FILE_SORT_INVERT;
}
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, nullptr);
}
}
@@ -1549,13 +1549,13 @@ static bool file_operator_poll(bContext *C)
return poll;
}
static int file_cancel_exec(bContext *C, wmOperator *UNUSED(unused))
static int file_cancel_exec(bContext *C, wmOperator * /*unused*/)
{
wmWindowManager *wm = CTX_wm_manager(C);
SpaceFile *sfile = CTX_wm_space_file(C);
wmOperator *op = sfile->op;
sfile->op = NULL;
sfile->op = nullptr;
WM_event_fileselect_event(wm, op, EVT_FILESELECT_CANCEL);
@@ -1735,7 +1735,7 @@ void file_draw_check_ex(bContext *C, ScrArea *area)
if (UNLIKELY(area->spacetype != SPACE_FILE)) {
return;
}
SpaceFile *sfile = area->spacedata.first;
SpaceFile *sfile = static_cast<SpaceFile *>(area->spacedata.first);
wmOperator *op = sfile->op;
if (op) { /* fail on reload */
if (op->type->check) {
@@ -1759,7 +1759,7 @@ void file_draw_check(bContext *C)
file_draw_check_ex(C, area);
}
void file_draw_check_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
void file_draw_check_cb(bContext *C, void * /*arg1*/, void * /*arg2*/)
{
file_draw_check(C);
}
@@ -1814,7 +1814,7 @@ static const EnumPropertyItem file_external_operation[] = {
0,
"Command Prompt Here",
"Open a command prompt here"},
{0, NULL, 0, NULL, NULL}};
{0, nullptr, 0, nullptr, nullptr}};
static int file_external_operation_exec(bContext *C, wmOperator *op)
{
@@ -1836,7 +1836,8 @@ static int file_external_operation_exec(bContext *C, wmOperator *op)
PointerRNA op_props;
WM_operator_properties_create_ptr(&op_props, ot);
RNA_string_set(&op_props, "filepath", filepath);
if (WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &op_props, NULL) == OPERATOR_FINISHED)
if (WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &op_props, nullptr) ==
OPERATOR_FINISHED)
{
WM_cursor_set(CTX_wm_window(C), WM_CURSOR_DEFAULT);
return OPERATOR_FINISHED;
@@ -1849,8 +1850,8 @@ static int file_external_operation_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
static char *file_external_operation_description(bContext *UNUSED(C),
wmOperatorType *UNUSED(ot),
static char *file_external_operation_description(bContext * /*C*/,
wmOperatorType * /*ot*/,
PointerRNA *ptr)
{
const char *description = "";
@@ -1875,7 +1876,7 @@ void FILE_OT_external_operation(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER; /* No undo! */
/* properties */
prop = RNA_def_string(ot->srna, "filepath", NULL, FILE_MAX, "File or folder path", "");
prop = RNA_def_string(ot->srna, "filepath", nullptr, FILE_MAX, "File or folder path", "");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
RNA_def_enum(ot->srna,
@@ -1905,7 +1906,7 @@ static void file_os_operations_menu_item(uiLayout *layout,
RNA_enum_name(file_external_operation, operation, &title);
PointerRNA props_ptr;
uiItemFullO_ptr(layout, ot, title, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &props_ptr);
uiItemFullO_ptr(layout, ot, title, ICON_NONE, nullptr, WM_OP_INVOKE_DEFAULT, 0, &props_ptr);
RNA_string_set(&props_ptr, "filepath", path);
if (operation) {
RNA_enum_set(&props_ptr, "operation", operation);
@@ -1928,12 +1929,12 @@ static void file_os_operations_menu_draw(const bContext *C_const, Menu *menu)
}
char dir[FILE_MAX_LIBEXTRA];
if (filelist_islibrary(sfile->files, dir, NULL)) {
if (filelist_islibrary(sfile->files, dir, nullptr)) {
return;
}
int numfiles = filelist_files_ensure(sfile->files);
FileDirEntry *fileentry = NULL;
FileDirEntry *fileentry = nullptr;
int num_selected = 0;
for (int i = 0; i < numfiles; i++) {
@@ -1978,7 +1979,7 @@ static void file_os_operations_menu_draw(const bContext *C_const, Menu *menu)
}
}
static bool file_os_operations_menu_poll(const bContext *C_const, MenuType *UNUSED(mt))
static bool file_os_operations_menu_poll(const bContext *C_const, MenuType * /*mt*/)
{
bContext *C = (bContext *)C_const;
@@ -1992,7 +1993,7 @@ static bool file_os_operations_menu_poll(const bContext *C_const, MenuType *UNUS
if (sfile && params) {
char dir[FILE_MAX_LIBEXTRA];
if (filelist_islibrary(sfile->files, dir, NULL)) {
if (filelist_islibrary(sfile->files, dir, nullptr)) {
return false;
}
@@ -2022,7 +2023,8 @@ void file_external_operations_menu_register(void)
{
MenuType *mt;
mt = MEM_callocN(sizeof(MenuType), "spacetype file menu file operations");
mt = static_cast<MenuType *>(
MEM_callocN(sizeof(MenuType), "spacetype file menu file operations"));
STRNCPY(mt->idname, "FILEBROWSER_MT_operations_menu");
STRNCPY(mt->label, N_("External"));
STRNCPY(mt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
@@ -2083,7 +2085,7 @@ static bool file_execute(bContext *C, SpaceFile *sfile)
wmOperator *op = sfile->op;
char filepath[FILE_MAX];
sfile->op = NULL;
sfile->op = nullptr;
file_sfile_to_operator_ex(C, bmain, op, sfile, filepath);
@@ -2091,9 +2093,9 @@ static bool file_execute(bContext *C, SpaceFile *sfile)
fsmenu_insert_entry(fsmenu,
FS_CATEGORY_RECENT,
params->dir,
NULL,
nullptr,
ICON_FILE_FOLDER,
FS_INSERT_SAVE | FS_INSERT_FIRST);
FSMenuInsert(FS_INSERT_SAVE | FS_INSERT_FIRST));
}
fsmenu_write_file_and_refresh_or_report_error(fsmenu, area, op->reports);
@@ -2104,7 +2106,7 @@ static bool file_execute(bContext *C, SpaceFile *sfile)
return true;
}
static int file_exec(bContext *C, wmOperator *UNUSED(op))
static int file_exec(bContext *C, wmOperator * /*op*/)
{
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -2144,7 +2146,7 @@ static bool file_ensure_hovered_is_active(bContext *C, const wmEvent *event)
return true;
}
static int file_execute_mouse_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static int file_execute_mouse_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -2191,7 +2193,7 @@ void FILE_OT_mouse_execute(wmOperatorType *ot)
/** \name Refresh File List Operator
* \{ */
static int file_refresh_exec(bContext *C, wmOperator *UNUSED(unused))
static int file_refresh_exec(bContext *C, wmOperator * /*unused*/)
{
wmWindowManager *wm = CTX_wm_manager(C);
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -2205,7 +2207,7 @@ static int file_refresh_exec(bContext *C, wmOperator *UNUSED(unused))
/* Update bookmarks 'valid' state. */
fsmenu_refresh_bookmarks_status(wm, fsmenu);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, nullptr);
return OPERATOR_FINISHED;
}
@@ -2228,7 +2230,7 @@ void FILE_OT_refresh(wmOperatorType *ot)
/** \name Navigate Parent Operator
* \{ */
static int file_parent_exec(bContext *C, wmOperator *UNUSED(unused))
static int file_parent_exec(bContext *C, wmOperator * /*unused*/)
{
Main *bmain = CTX_data_main(C);
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -2244,7 +2246,7 @@ static int file_parent_exec(bContext *C, wmOperator *UNUSED(unused))
params->recursion_level = 0;
filelist_setrecursion(sfile->files, params->recursion_level);
}
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, nullptr);
}
}
@@ -2270,7 +2272,7 @@ void FILE_OT_parent(wmOperatorType *ot)
/** \name Navigate Previous Operator
* \{ */
static int file_previous_exec(bContext *C, wmOperator *UNUSED(op))
static int file_previous_exec(bContext *C, wmOperator * /*op*/)
{
SpaceFile *sfile = CTX_wm_space_file(C);
FileSelectParams *params = ED_fileselect_get_active_params(sfile);
@@ -2282,7 +2284,7 @@ static int file_previous_exec(bContext *C, wmOperator *UNUSED(op))
ED_file_change_dir(C);
}
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, nullptr);
return OPERATOR_FINISHED;
}
@@ -2306,7 +2308,7 @@ void FILE_OT_previous(wmOperatorType *ot)
/** \name Navigate Next Operator
* \{ */
static int file_next_exec(bContext *C, wmOperator *UNUSED(unused))
static int file_next_exec(bContext *C, wmOperator * /*unused*/)
{
SpaceFile *sfile = CTX_wm_space_file(C);
FileSelectParams *params = ED_fileselect_get_active_params(sfile);
@@ -2319,7 +2321,7 @@ static int file_next_exec(bContext *C, wmOperator *UNUSED(unused))
ED_file_change_dir(C);
}
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, nullptr);
return OPERATOR_FINISHED;
}
@@ -2344,7 +2346,7 @@ void FILE_OT_next(wmOperatorType *ot)
* \{ */
/* only meant for timer usage */
static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static int file_smoothscroll_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
{
ScrArea *area = CTX_wm_area(C);
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -2353,7 +2355,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
int i;
/* escape if not our timer */
if (sfile->smoothscroll_timer == NULL || sfile->smoothscroll_timer != event->customdata) {
if (sfile->smoothscroll_timer == nullptr || sfile->smoothscroll_timer != event->customdata) {
return OPERATOR_PASS_THROUGH;
}
@@ -2558,7 +2560,7 @@ static int filepath_drop_exec(bContext *C, wmOperator *op)
file_draw_check(C);
}
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, nullptr);
return OPERATOR_FINISHED;
}
@@ -2670,11 +2672,11 @@ static int file_directory_new_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
eFileSel_Params_RenameFlag rename_flag = params->rename_flag;
eFileSel_Params_RenameFlag rename_flag = eFileSel_Params_RenameFlag(params->rename_flag);
/* If we don't enter the directory directly, remember file to jump into editing. */
if (do_diropen == false) {
BLI_assert_msg(params->rename_id == NULL,
BLI_assert_msg(params->rename_id == nullptr,
"File rename handling should immediately clear rename_id when done, "
"because otherwise it will keep taking precedence over renamefile.");
STRNCPY(params->renamefile, dirname);
@@ -2692,7 +2694,7 @@ static int file_directory_new_exec(bContext *C, wmOperator *op)
ED_file_change_dir(C);
}
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, nullptr);
return OPERATOR_FINISHED;
}
@@ -2713,7 +2715,7 @@ void FILE_OT_directory_new(wmOperatorType *ot)
ot->poll = ED_operator_file_browsing_active; /* <- important, handler is on window level */
prop = RNA_def_string_dir_path(
ot->srna, "directory", NULL, FILE_MAX, "Directory", "Name of new directory");
ot->srna, "directory", nullptr, FILE_MAX, "Directory", "Name of new directory");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "open", false, "Open", "Open new directory");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
@@ -2790,7 +2792,7 @@ static bool can_create_dir(const char *dir)
}
#endif
void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UNUSED(arg_but))
void file_directory_enter_handle(bContext *C, void * /*arg_unused*/, void * /*arg_but*/)
{
Main *bmain = CTX_data_main(C);
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -2854,7 +2856,7 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
char tdir[FILE_MAX_LIBEXTRA];
/* If we are 'inside' a blend library, we cannot do anything... */
if (lastdir && BKE_blendfile_library_path_explode(lastdir, tdir, NULL, NULL)) {
if (lastdir && BKE_blendfile_library_path_explode(lastdir, tdir, nullptr, nullptr)) {
STRNCPY(params->dir, lastdir);
}
else {
@@ -2872,21 +2874,21 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
STRNCPY(params->dir, lastdir);
}
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr, NULL);
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr, nullptr);
WM_operator_properties_free(&ptr);
}
}
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, nullptr);
}
}
void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg_but)
void file_filename_enter_handle(bContext *C, void * /*arg_unused*/, void *arg_but)
{
Main *bmain = CTX_data_main(C);
SpaceFile *sfile = CTX_wm_space_file(C);
FileSelectParams *params = ED_fileselect_get_active_params(sfile);
uiBut *but = arg_but;
uiBut *but = static_cast<uiBut *>(arg_but);
char matched_file[FILE_MAX];
if (params) {
@@ -2908,7 +2910,7 @@ void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg
* with the first selected file of the match */
STRNCPY(params->file, matched_file);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, nullptr);
}
if (matches == 1) {
@@ -2922,7 +2924,7 @@ void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg
params->file[0] = '\0';
ED_file_change_dir(C);
UI_textbutton_activate_but(C, but);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, nullptr);
}
}
else if (matches > 1) {
@@ -2937,7 +2939,7 @@ void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg
/** \name Toggle Show Hidden Files Operator
* \{ */
static int file_hidedot_exec(bContext *C, wmOperator *UNUSED(unused))
static int file_hidedot_exec(bContext *C, wmOperator * /*unused*/)
{
wmWindowManager *wm = CTX_wm_manager(C);
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -2946,7 +2948,7 @@ static int file_hidedot_exec(bContext *C, wmOperator *UNUSED(unused))
if (params) {
params->flag ^= FILE_HIDE_DOT;
ED_fileselect_clear(wm, sfile);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, nullptr);
}
return OPERATOR_FINISHED;
@@ -3026,7 +3028,7 @@ static int file_filenum_exec(bContext *C, wmOperator *op)
filenum_newname(params->file, sizeof(params->file), inc);
ED_area_tag_redraw(area);
file_draw_check(C);
// WM_event_add_notifier(C, NC_WINDOW, NULL);
// WM_event_add_notifier(C, NC_WINDOW, nullptr);
}
return OPERATOR_FINISHED;
@@ -3075,7 +3077,7 @@ static void file_rename_state_activate(SpaceFile *sfile, int file_idx, bool requ
}
}
static int file_rename_exec(bContext *C, wmOperator *UNUSED(op))
static int file_rename_exec(bContext *C, wmOperator * /*op*/)
{
ScrArea *area = CTX_wm_area(C);
SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C);
@@ -3121,7 +3123,7 @@ static bool file_delete_poll(bContext *C)
}
char dir[FILE_MAX_LIBEXTRA];
if (filelist_islibrary(sfile->files, dir, NULL)) {
if (filelist_islibrary(sfile->files, dir, nullptr)) {
return false;
}
@@ -3155,7 +3157,7 @@ static int file_delete_exec(bContext *C, wmOperator *op)
SpaceFile *sfile = CTX_wm_space_file(C);
int numfiles = filelist_files_ensure(sfile->files);
const char *error_message = NULL;
const char *error_message = nullptr;
bool report_error = false;
errno = 0;
for (int i = 0; i < numfiles; i++) {
@@ -3168,7 +3170,7 @@ static int file_delete_exec(bContext *C, wmOperator *op)
}
if (report_error) {
if (error_message != NULL) {
if (error_message != nullptr) {
BKE_reportf(op->reports, RPT_ERROR, "Could not delete file or directory: %s", error_message);
}
else {
@@ -3180,7 +3182,7 @@ static int file_delete_exec(bContext *C, wmOperator *op)
}
ED_fileselect_clear(wm, sfile);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, nullptr);
return OPERATOR_FINISHED;
}
@@ -3204,7 +3206,7 @@ void FILE_OT_delete(wmOperatorType *ot)
/** \name Enter Filter Text Operator
* \{ */
static int file_start_filter_exec(bContext *C, wmOperator *UNUSED(op))
static int file_start_filter_exec(bContext *C, wmOperator * /*op*/)
{
const ScrArea *area = CTX_wm_area(C);
const SpaceFile *sfile = CTX_wm_space_file(C);
@@ -3240,7 +3242,7 @@ void FILE_OT_start_filter(wmOperatorType *ot)
/** \name Edit Directory Path Operator
* \{ */
static int file_edit_directory_path_exec(bContext *C, wmOperator *UNUSED(op))
static int file_edit_directory_path_exec(bContext *C, wmOperator * /*op*/)
{
const ScrArea *area = CTX_wm_area(C);
const SpaceFile *sfile = CTX_wm_space_file(C);

View File

@@ -39,13 +39,13 @@
#include <string.h>
static bool file_panel_operator_poll(const bContext *C, PanelType *UNUSED(pt))
static bool file_panel_operator_poll(const bContext *C, PanelType * /*pt*/)
{
SpaceFile *sfile = CTX_wm_space_file(C);
return (sfile && sfile->op);
}
static bool file_panel_asset_browsing_poll(const bContext *C, PanelType *UNUSED(pt))
static bool file_panel_asset_browsing_poll(const bContext *C, PanelType * /*pt*/)
{
SpaceFile *sfile = CTX_wm_space_file(C);
return sfile && sfile->files && ED_fileselect_is_asset_browser(sfile);
@@ -64,7 +64,7 @@ static void file_panel_operator(const bContext *C, Panel *panel)
SpaceFile *sfile = CTX_wm_space_file(C);
wmOperator *op = sfile->op;
UI_block_func_set(uiLayoutGetBlock(panel->layout), file_draw_check_cb, NULL, NULL);
UI_block_func_set(uiLayoutGetBlock(panel->layout), file_draw_check_cb, nullptr, nullptr);
/* Hack: temporary hide. */
const char *hide[] = {"filepath", "files", "directory", "filename"};
@@ -86,14 +86,15 @@ static void file_panel_operator(const bContext *C, Panel *panel)
}
}
UI_block_func_set(uiLayoutGetBlock(panel->layout), NULL, NULL, NULL);
UI_block_func_set(uiLayoutGetBlock(panel->layout), nullptr, nullptr, nullptr);
}
void file_tool_props_region_panels_register(ARegionType *art)
{
PanelType *pt;
pt = MEM_callocN(sizeof(PanelType), "spacetype file operator properties");
pt = static_cast<PanelType *>(
MEM_callocN(sizeof(PanelType), "spacetype file operator properties"));
STRNCPY(pt->idname, "FILE_PT_operator");
STRNCPY(pt->label, N_("Operator"));
STRNCPY(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
@@ -146,7 +147,7 @@ static void file_panel_execution_buttons_draw(const bContext *C, Panel *panel)
uiLayoutSetScaleY(row, 1.3f);
/* callbacks for operator check functions */
UI_block_func_set(block, file_draw_check_cb, NULL, NULL);
UI_block_func_set(block, file_draw_check_cb, nullptr, nullptr);
but = uiDefButR(block,
UI_BTYPE_TEXT,
@@ -168,10 +169,10 @@ static void file_panel_execution_buttons_draw(const bContext *C, Panel *panel)
BLI_assert(!UI_but_flag_is_set(but, UI_BUT_UNDO));
BLI_assert(!UI_but_is_utf8(but));
UI_but_func_complete_set(but, autocomplete_file, NULL);
UI_but_func_complete_set(but, autocomplete_file, nullptr);
/* silly workaround calling NFunc to ensure this does not get called
* immediate ui_apply_but_func but only after button deactivates */
UI_but_funcN_set(but, file_filename_enter_handle, NULL, but);
UI_but_funcN_set(but, file_filename_enter_handle, nullptr, but);
if (params->flag & FILE_CHECK_EXISTING) {
but_extra_rna_ptr = UI_but_extra_operator_icon_add(
@@ -186,7 +187,7 @@ static void file_panel_execution_buttons_draw(const bContext *C, Panel *panel)
if (overwrite_alert) {
UI_but_flag_enable(but, UI_BUT_REDALERT);
}
UI_block_func_set(block, NULL, NULL, NULL);
UI_block_func_set(block, nullptr, nullptr, nullptr);
{
uiLayout *sub = uiLayoutRow(row, false);
@@ -207,7 +208,8 @@ void file_execute_region_panels_register(ARegionType *art)
{
PanelType *pt;
pt = MEM_callocN(sizeof(PanelType), "spacetype file execution buttons");
pt = static_cast<PanelType *>(
MEM_callocN(sizeof(PanelType), "spacetype file execution buttons"));
STRNCPY(pt->idname, "FILE_PT_execution_buttons");
STRNCPY(pt->label, N_("Execute Buttons"));
STRNCPY(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
@@ -224,7 +226,7 @@ static void file_panel_asset_catalog_buttons_draw(const bContext *C, Panel *pane
/* May be null if the library wasn't loaded yet. */
struct AssetLibrary *asset_library = filelist_asset_library(sfile->files);
FileAssetSelectParams *params = ED_fileselect_get_asset_params(sfile);
BLI_assert(params != NULL);
BLI_assert(params != nullptr);
uiLayout *col = uiLayoutColumn(panel->layout, false);
uiLayout *row = uiLayoutRow(col, true);
@@ -259,7 +261,8 @@ void file_tools_region_panels_register(ARegionType *art)
{
PanelType *pt;
pt = MEM_callocN(sizeof(PanelType), "spacetype file asset catalog buttons");
pt = static_cast<PanelType *>(
MEM_callocN(sizeof(PanelType), "spacetype file asset catalog buttons"));
STRNCPY(pt->idname, "FILE_PT_asset_catalog_buttons");
STRNCPY(pt->label, N_("Asset Catalogs"));
STRNCPY(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);

View File

@@ -17,6 +17,10 @@ enum FSMenuInsert;
struct FSMenu;
struct FSMenuEntry;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Inserts a new fsmenu entry with the given \a path.
* Duplicate entries are not added.
@@ -63,3 +67,7 @@ void fsmenu_refresh_bookmarks_status(struct wmWindowManager *wm, struct FSMenu *
int fsmenu_get_active_indices(struct FSMenu *fsmenu,
enum FSMenuCategory category,
const char *dir);
#ifdef __cplusplus
}
#endif

View File

@@ -52,50 +52,50 @@
/* ******************** default callbacks for file space ***************** */
static SpaceLink *file_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *file_create(const ScrArea * /*area*/, const Scene * /*scene*/)
{
ARegion *region;
SpaceFile *sfile;
sfile = MEM_callocN(sizeof(SpaceFile), "initfile");
sfile = static_cast<SpaceFile *>(MEM_callocN(sizeof(SpaceFile), "initfile"));
sfile->spacetype = SPACE_FILE;
/* header */
region = MEM_callocN(sizeof(ARegion), "header for file");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "header for file"));
BLI_addtail(&sfile->regionbase, region);
region->regiontype = RGN_TYPE_HEADER;
/* Ignore user preference "USER_HEADER_BOTTOM" here (always show top for new types). */
region->alignment = RGN_ALIGN_TOP;
/* Tools region */
region = MEM_callocN(sizeof(ARegion), "tools region for file");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "tools region for file"));
BLI_addtail(&sfile->regionbase, region);
region->regiontype = RGN_TYPE_TOOLS;
region->alignment = RGN_ALIGN_LEFT;
/* ui list region */
region = MEM_callocN(sizeof(ARegion), "ui region for file");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "ui region for file"));
BLI_addtail(&sfile->regionbase, region);
region->regiontype = RGN_TYPE_UI;
region->alignment = RGN_ALIGN_TOP;
region->flag = RGN_FLAG_DYNAMIC_SIZE;
/* execute region */
region = MEM_callocN(sizeof(ARegion), "execute region for file");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "execute region for file"));
BLI_addtail(&sfile->regionbase, region);
region->regiontype = RGN_TYPE_EXECUTE;
region->alignment = RGN_ALIGN_BOTTOM;
region->flag = RGN_FLAG_DYNAMIC_SIZE;
/* tools props region */
region = MEM_callocN(sizeof(ARegion), "tool props for file");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "tool props for file"));
BLI_addtail(&sfile->regionbase, region);
region->regiontype = RGN_TYPE_TOOL_PROPS;
region->alignment = RGN_ALIGN_RIGHT;
region->flag = RGN_FLAG_HIDDEN;
/* main region */
region = MEM_callocN(sizeof(ARegion), "main region for file");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "main region for file"));
BLI_addtail(&sfile->regionbase, region);
region->regiontype = RGN_TYPE_WINDOW;
region->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
@@ -112,14 +112,14 @@ static void file_free(SpaceLink *sl)
{
SpaceFile *sfile = (SpaceFile *)sl;
BLI_assert(sfile->previews_timer == NULL);
BLI_assert(sfile->previews_timer == nullptr);
if (sfile->files) {
/* XXX would need to do thumbnails_stop here, but no context available */
filelist_freelib(sfile->files);
filelist_free(sfile->files);
MEM_freeN(sfile->files);
sfile->files = NULL;
sfile->files = nullptr;
}
folder_history_list_free(sfile);
@@ -132,7 +132,7 @@ static void file_free(SpaceLink *sl)
}
/* spacetype; init callback, area size changes, screen set, etc */
static void file_init(wmWindowManager *UNUSED(wm), ScrArea *area)
static void file_init(wmWindowManager * /*wm*/, ScrArea *area)
{
SpaceFile *sfile = (SpaceFile *)area->spacedata.first;
@@ -140,8 +140,9 @@ static void file_init(wmWindowManager *UNUSED(wm), ScrArea *area)
sfile->layout->dirty = true;
}
if (sfile->runtime == NULL) {
sfile->runtime = MEM_callocN(sizeof(*sfile->runtime), __func__);
if (sfile->runtime == nullptr) {
sfile->runtime = static_cast<SpaceFile_Runtime *>(
MEM_callocN(sizeof(*sfile->runtime), __func__));
}
/* Validate the params right after file read. */
fileselect_refresh_params(sfile);
@@ -152,8 +153,8 @@ static void file_exit(wmWindowManager *wm, ScrArea *area)
SpaceFile *sfile = (SpaceFile *)area->spacedata.first;
if (sfile->previews_timer) {
WM_event_timer_remove_notifier(wm, NULL, sfile->previews_timer);
sfile->previews_timer = NULL;
WM_event_timer_remove_notifier(wm, nullptr, sfile->previews_timer);
sfile->previews_timer = nullptr;
}
ED_fileselect_exit(wm, sfile);
@@ -162,14 +163,14 @@ static void file_exit(wmWindowManager *wm, ScrArea *area)
static SpaceLink *file_duplicate(SpaceLink *sl)
{
SpaceFile *sfileo = (SpaceFile *)sl;
SpaceFile *sfilen = MEM_dupallocN(sl);
SpaceFile *sfilen = static_cast<SpaceFile *>(MEM_dupallocN(sl));
/* clear or remove stuff from old */
sfilen->op = NULL; /* file window doesn't own operators */
sfilen->runtime = NULL;
sfilen->op = nullptr; /* file window doesn't own operators */
sfilen->runtime = nullptr;
sfilen->previews_timer = NULL;
sfilen->smoothscroll_timer = NULL;
sfilen->previews_timer = nullptr;
sfilen->smoothscroll_timer = nullptr;
FileSelectParams *active_params_old = ED_fileselect_get_active_params(sfileo);
if (active_params_old) {
@@ -178,16 +179,17 @@ static SpaceLink *file_duplicate(SpaceLink *sl)
}
if (sfileo->params) {
sfilen->params = MEM_dupallocN(sfileo->params);
sfilen->params = static_cast<FileSelectParams *>(MEM_dupallocN(sfileo->params));
}
if (sfileo->asset_params) {
sfilen->asset_params = MEM_dupallocN(sfileo->asset_params);
sfilen->asset_params = static_cast<FileAssetSelectParams *>(
MEM_dupallocN(sfileo->asset_params));
}
sfilen->folder_histories = folder_history_list_duplicate(&sfileo->folder_histories);
if (sfileo->layout) {
sfilen->layout = MEM_dupallocN(sfileo->layout);
sfilen->layout = static_cast<FileLayout *>(MEM_dupallocN(sfileo->layout));
}
return (SpaceLink *)sfilen;
}
@@ -226,7 +228,7 @@ static void file_refresh(const bContext *C, ScrArea *area)
filelist_setdir(sfile->files, params->dir);
filelist_setrecursion(sfile->files, params->recursion_level);
filelist_setsorting(sfile->files, params->sort, params->flag & FILE_SORT_INVERT);
filelist_setlibrary(sfile->files, asset_params ? &asset_params->asset_library_ref : NULL);
filelist_setlibrary(sfile->files, asset_params ? &asset_params->asset_library_ref : nullptr);
filelist_setfilter_options(
sfile->files,
(params->flag & FILE_FILTER) != 0,
@@ -239,7 +241,9 @@ static void file_refresh(const bContext *C, ScrArea *area)
params->filter_search);
if (asset_params) {
filelist_set_asset_catalog_filter_options(
sfile->files, asset_params->asset_catalog_visibility, &asset_params->catalog_id);
sfile->files,
eFileSel_Params_AssetCatalogVisibility(asset_params->asset_catalog_visibility),
&asset_params->catalog_id);
}
if (ED_fileselect_is_asset_browser(sfile)) {
@@ -276,7 +280,7 @@ static void file_refresh(const bContext *C, ScrArea *area)
filelist_cache_previews_set(sfile->files, false);
if (sfile->previews_timer) {
WM_event_timer_remove_notifier(wm, win, sfile->previews_timer);
sfile->previews_timer = NULL;
sfile->previews_timer = nullptr;
}
}
@@ -290,7 +294,7 @@ static void file_refresh(const bContext *C, ScrArea *area)
if (area) {
ARegion *region_props = BKE_area_find_region_type(area, RGN_TYPE_TOOL_PROPS);
const bool region_flag_old = region_props->flag;
const short region_flag_old = region_props->flag;
if (!(region_props->v2d.flag & V2D_IS_INIT)) {
if (ED_fileselect_is_asset_browser(sfile)) {
/* Hide by default in asset browser. */
@@ -323,14 +327,14 @@ void file_on_reload_callback_register(SpaceFile *sfile,
static void file_on_reload_callback_call(SpaceFile *sfile)
{
if (sfile->runtime->on_reload == NULL) {
if (sfile->runtime->on_reload == nullptr) {
return;
}
sfile->runtime->on_reload(sfile, sfile->runtime->on_reload_custom_data);
sfile->runtime->on_reload = NULL;
sfile->runtime->on_reload_custom_data = NULL;
sfile->runtime->on_reload = nullptr;
sfile->runtime->on_reload_custom_data = nullptr;
}
static void file_reset_filelist_showing_main_data(ScrArea *area, SpaceFile *sfile)
@@ -387,7 +391,8 @@ static void file_listener(const wmSpaceTypeListenerParams *listener_params)
if (active_file_id && (wmn->reference == active_file_id)) {
FileSelectParams *params = ED_fileselect_get_active_params(sfile);
params->rename_id = active_file_id;
file_params_invoke_rename_postscroll(G_MAIN->wm.first, listener_params->window, sfile);
file_params_invoke_rename_postscroll(
static_cast<wmWindowManager *>(G_MAIN->wm.first), listener_params->window, sfile);
}
/* Force list to update sorting (with a full reset for now). */
@@ -460,17 +465,16 @@ static void file_main_region_message_subscribe(const wmRegionMessageSubscribePar
bScreen *screen = params->screen;
ScrArea *area = params->area;
ARegion *region = params->region;
SpaceFile *sfile = area->spacedata.first;
SpaceFile *sfile = static_cast<SpaceFile *>(area->spacedata.first);
FileSelectParams *file_params = ED_fileselect_ensure_active_params(sfile);
/* This is a bit odd that a region owns the subscriber for an area,
* keep for now since all subscribers for WM are regions.
* May be worth re-visiting later. */
wmMsgSubscribeValue msg_sub_value_area_tag_refresh = {
.owner = region,
.user_data = area,
.notify = ED_area_do_msg_notify_tag_refresh,
};
wmMsgSubscribeValue msg_sub_value_area_tag_refresh{};
msg_sub_value_area_tag_refresh.owner = region;
msg_sub_value_area_tag_refresh.user_data = area;
msg_sub_value_area_tag_refresh.notify = ED_area_do_msg_notify_tag_refresh;
/* SpaceFile itself. */
{
@@ -478,7 +482,7 @@ static void file_main_region_message_subscribe(const wmRegionMessageSubscribePar
RNA_pointer_create(&screen->id, &RNA_SpaceFileBrowser, sfile, &ptr);
/* All properties for this space type. */
WM_msg_subscribe_rna(mbus, &ptr, NULL, &msg_sub_value_area_tag_refresh, __func__);
WM_msg_subscribe_rna(mbus, &ptr, nullptr, &msg_sub_value_area_tag_refresh, __func__);
}
/* FileSelectParams */
@@ -487,13 +491,13 @@ static void file_main_region_message_subscribe(const wmRegionMessageSubscribePar
RNA_pointer_create(&screen->id, &RNA_FileSelectParams, file_params, &ptr);
/* All properties for this space type. */
WM_msg_subscribe_rna(mbus, &ptr, NULL, &msg_sub_value_area_tag_refresh, __func__);
WM_msg_subscribe_rna(mbus, &ptr, nullptr, &msg_sub_value_area_tag_refresh, __func__);
}
/* Experimental Asset Browser features option. */
{
PointerRNA ptr;
RNA_pointer_create(NULL, &RNA_PreferencesExperimental, &U.experimental, &ptr);
RNA_pointer_create(nullptr, &RNA_PreferencesExperimental, &U.experimental, &ptr);
PropertyRNA *prop = RNA_struct_find_property(&ptr, "use_extended_asset_browser");
/* All properties for this space type. */
@@ -527,7 +531,7 @@ static void file_main_region_draw(const bContext *C, ARegion *region)
View2D *v2d = &region->v2d;
if (file_main_region_needs_refresh_before_draw(sfile)) {
file_refresh(C, NULL);
file_refresh(C, nullptr);
}
/* clear and setup matrix */
@@ -642,13 +646,13 @@ static bool file_ui_region_poll(const RegionPollParams *params)
static bool file_tool_props_region_poll(const RegionPollParams *params)
{
const SpaceFile *sfile = (SpaceFile *)params->area->spacedata.first;
return (sfile->browse_mode == FILE_BROWSE_MODE_ASSETS) || (sfile->op != NULL);
return (sfile->browse_mode == FILE_BROWSE_MODE_ASSETS) || (sfile->op != nullptr);
}
static bool file_execution_region_poll(const RegionPollParams *params)
{
const SpaceFile *sfile = (SpaceFile *)params->area->spacedata.first;
return sfile->op != NULL;
return sfile->op != nullptr;
}
static void file_tools_region_init(wmWindowManager *wm, ARegion *region)
@@ -773,7 +777,7 @@ static void file_ui_region_listener(const wmRegionListenerParams *listener_param
}
}
static bool filepath_drop_poll(bContext *C, wmDrag *drag, const wmEvent *UNUSED(event))
static bool filepath_drop_poll(bContext *C, wmDrag *drag, const wmEvent * /*event*/)
{
if (drag->type == WM_DRAG_PATH) {
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -784,7 +788,7 @@ static bool filepath_drop_poll(bContext *C, wmDrag *drag, const wmEvent *UNUSED(
return false;
}
static void filepath_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop)
static void filepath_drop_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
{
RNA_string_set(drop->ptr, "filepath", WM_drag_get_path(drag));
}
@@ -794,18 +798,19 @@ static void file_dropboxes(void)
{
ListBase *lb = WM_dropboxmap_find("Window", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_dropbox_add(lb, "FILE_OT_filepath_drop", filepath_drop_poll, filepath_drop_copy, NULL, NULL);
WM_dropbox_add(
lb, "FILE_OT_filepath_drop", filepath_drop_poll, filepath_drop_copy, nullptr, nullptr);
}
static int file_space_subtype_get(ScrArea *area)
{
SpaceFile *sfile = area->spacedata.first;
SpaceFile *sfile = static_cast<SpaceFile *>(area->spacedata.first);
return sfile->browse_mode;
}
static void file_space_subtype_set(ScrArea *area, int value)
{
SpaceFile *sfile = area->spacedata.first;
SpaceFile *sfile = static_cast<SpaceFile *>(area->spacedata.first);
/* Force re-init. */
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
region->v2d.flag &= ~V2D_IS_INIT;
@@ -813,9 +818,7 @@ static void file_space_subtype_set(ScrArea *area, int value)
sfile->browse_mode = value;
}
static void file_space_subtype_item_extend(bContext *UNUSED(C),
EnumPropertyItem **item,
int *totitem)
static void file_space_subtype_item_extend(bContext * /*C*/, EnumPropertyItem **item, int *totitem)
{
RNA_enum_items_add(item, totitem, rna_enum_space_file_browse_mode_items);
}
@@ -827,7 +830,7 @@ const char *file_context_dir[] = {
"selected_asset_files",
"id",
"selected_ids",
NULL,
nullptr,
};
static int /*eContextResult*/ file_context(const bContext *C,
@@ -852,7 +855,7 @@ static int /*eContextResult*/ file_context(const bContext *C,
if (CTX_data_equals(member, "active_file")) {
FileDirEntry *file = filelist_file(sfile->files, params->active_file);
if (file == NULL) {
if (file == nullptr) {
return CTX_RESULT_NO_DATA;
}
@@ -903,12 +906,12 @@ static int /*eContextResult*/ file_context(const bContext *C,
}
if (CTX_data_equals(member, "id")) {
const FileDirEntry *file = filelist_file(sfile->files, params->active_file);
if (file == NULL) {
if (file == nullptr) {
return CTX_RESULT_NO_DATA;
}
ID *id = filelist_file_get_id(file);
if (id == NULL) {
if (id == nullptr) {
return CTX_RESULT_NO_DATA;
}
@@ -937,7 +940,7 @@ static int /*eContextResult*/ file_context(const bContext *C,
return CTX_RESULT_MEMBER_NOT_FOUND;
}
static void file_id_remap(ScrArea *area, SpaceLink *sl, const struct IDRemapper *UNUSED(mappings))
static void file_id_remap(ScrArea *area, SpaceLink *sl, const struct IDRemapper * /*mappings*/)
{
SpaceFile *sfile = (SpaceFile *)sl;
@@ -955,26 +958,26 @@ static void file_space_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
/* this sort of info is probably irrelevant for reloading...
* plus, it isn't saved to files yet!
*/
sfile->folders_prev = sfile->folders_next = NULL;
sfile->folders_prev = sfile->folders_next = nullptr;
BLI_listbase_clear(&sfile->folder_histories);
sfile->files = NULL;
sfile->layout = NULL;
sfile->op = NULL;
sfile->previews_timer = NULL;
sfile->files = nullptr;
sfile->layout = nullptr;
sfile->op = nullptr;
sfile->previews_timer = nullptr;
sfile->tags = 0;
sfile->runtime = NULL;
sfile->runtime = nullptr;
BLO_read_data_address(reader, &sfile->params);
BLO_read_data_address(reader, &sfile->asset_params);
if (sfile->params) {
sfile->params->rename_id = NULL;
sfile->params->rename_id = nullptr;
}
if (sfile->asset_params) {
sfile->asset_params->base_params.rename_id = NULL;
sfile->asset_params->base_params.rename_id = nullptr;
}
}
static void file_space_blend_read_lib(BlendLibReader *UNUSED(reader),
ID *UNUSED(parent_id),
static void file_space_blend_read_lib(BlendLibReader * /*reader*/,
ID * /*parent_id*/,
SpaceLink *sl)
{
SpaceFile *sfile = (SpaceFile *)sl;
@@ -996,7 +999,7 @@ static void file_space_blend_write(BlendWriter *writer, SpaceLink *sl)
void ED_spacetype_file(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype file");
SpaceType *st = static_cast<SpaceType *>(MEM_callocN(sizeof(SpaceType), "spacetype file"));
ARegionType *art;
st->spaceid = SPACE_FILE;
@@ -1022,7 +1025,7 @@ void ED_spacetype_file(void)
st->blend_write = file_space_blend_write;
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype file region"));
art->regionid = RGN_TYPE_WINDOW;
art->init = file_main_region_init;
art->draw = file_main_region_draw;
@@ -1032,7 +1035,7 @@ void ED_spacetype_file(void)
BLI_addhead(&st->regiontypes, art);
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype file region"));
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
@@ -1042,7 +1045,7 @@ void ED_spacetype_file(void)
BLI_addhead(&st->regiontypes, art);
/* regions: ui */
art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype file region"));
art->regionid = RGN_TYPE_UI;
art->keymapflag = ED_KEYMAP_UI;
art->poll = file_ui_region_poll;
@@ -1052,7 +1055,7 @@ void ED_spacetype_file(void)
BLI_addhead(&st->regiontypes, art);
/* regions: execution */
art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype file region"));
art->regionid = RGN_TYPE_EXECUTE;
art->keymapflag = ED_KEYMAP_UI;
art->poll = file_execution_region_poll;
@@ -1063,7 +1066,7 @@ void ED_spacetype_file(void)
file_execute_region_panels_register(art);
/* regions: channels (directories) */
art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype file region"));
art->regionid = RGN_TYPE_TOOLS;
art->prefsizex = 240;
art->prefsizey = 60;
@@ -1075,7 +1078,8 @@ void ED_spacetype_file(void)
file_tools_region_panels_register(art);
/* regions: tool properties */
art = MEM_callocN(sizeof(ARegionType), "spacetype file operator region");
art = static_cast<ARegionType *>(
MEM_callocN(sizeof(ARegionType), "spacetype file operator region"));
art->regionid = RGN_TYPE_TOOL_PROPS;
art->prefsizex = 240;
art->prefsizey = 60;
@@ -1113,7 +1117,7 @@ void ED_file_exit(void)
void ED_file_read_bookmarks(void)
{
const char *const cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, NULL);
const char *const cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, nullptr);
fsmenu_free();

View File

@@ -19,15 +19,15 @@ set(INC_SYS
)
set(SRC
graph_buttons.c
graph_draw.c
graph_edit.c
graph_ops.c
graph_select.c
graph_slider_ops.c
graph_utils.c
graph_view.c
space_graph.c
graph_buttons.cc
graph_draw.cc
graph_edit.cc
graph_ops.cc
graph_select.cc
graph_slider_ops.cc
graph_utils.cc
graph_view.cc
space_graph.cc
graph_intern.h
)

View File

@@ -64,7 +64,7 @@
static bool graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **fcu)
{
bAnimContext ac;
bAnimListElem *elem = NULL;
bAnimListElem *elem = nullptr;
/* For now, only draw if we could init the anim-context info
* (necessary for all animation-related tools)
@@ -77,7 +77,7 @@ static bool graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve *
/* try to find 'active' F-Curve */
elem = get_active_fcurve_channel(&ac);
if (elem == NULL) {
if (elem == nullptr) {
return false;
}
@@ -97,16 +97,16 @@ static bool graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve *
FCurve *ANIM_graph_context_fcurve(const bContext *C)
{
FCurve *fcu;
if (!graph_panel_context(C, NULL, &fcu)) {
return NULL;
if (!graph_panel_context(C, nullptr, &fcu)) {
return nullptr;
}
return fcu;
}
static bool graph_panel_poll(const bContext *C, PanelType *UNUSED(pt))
static bool graph_panel_poll(const bContext *C, PanelType * /*pt*/)
{
return graph_panel_context(C, NULL, NULL);
return graph_panel_context(C, nullptr, nullptr);
}
/** \} */
@@ -223,7 +223,7 @@ static void graph_panel_properties(const bContext *C, Panel *panel)
col = uiLayoutColumn(layout, false);
uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED) != 0);
uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA);
uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE);
uiItemR(col, &fcu_ptr, "array_index", 0, nullptr, ICON_NONE);
/* color settings */
col = uiLayoutColumn(layout, true);
@@ -252,7 +252,7 @@ static bool get_active_fcurve_keyframe_edit(const FCurve *fcu,
BezTriple **r_prevbezt)
{
/* zero the pointers */
*r_bezt = *r_prevbezt = NULL;
*r_bezt = *r_prevbezt = nullptr;
const int active_keyframe_index = BKE_fcurve_active_keyframe_index(fcu);
if (active_keyframe_index == FCURVE_ACTIVE_KEYFRAME_NONE) {
@@ -271,9 +271,7 @@ static bool get_active_fcurve_keyframe_edit(const FCurve *fcu,
}
/* update callback for active keyframe properties - base updates stuff */
static void graphedit_activekey_update_cb(bContext *UNUSED(C),
void *fcu_ptr,
void *UNUSED(bezt_ptr))
static void graphedit_activekey_update_cb(bContext * /*C*/, void *fcu_ptr, void * /*bezt_ptr*/)
{
FCurve *fcu = (FCurve *)fcu_ptr;
@@ -365,14 +363,14 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
}
block = uiLayoutGetBlock(layout);
// UI_block_func_handle_set(block, do_graph_region_buttons, NULL);
// UI_block_func_handle_set(block, do_graph_region_buttons, nullptr);
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
/* only show this info if there are keyframes to edit */
if (get_active_fcurve_keyframe_edit(fcu, &bezt, &prevbezt)) {
PointerRNA bezt_ptr, id_ptr, fcu_prop_ptr;
PropertyRNA *fcu_prop = NULL;
PropertyRNA *fcu_prop = nullptr;
uiBut *but;
int unit = B_UNIT_NONE;
@@ -394,24 +392,24 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
uiItemL(split, IFACE_("None for Enum/Boolean"), ICON_IPO_CONSTANT);
}
else {
uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE);
uiItemR(col, &bezt_ptr, "interpolation", 0, nullptr, ICON_NONE);
}
/* easing type */
if (bezt->ipo > BEZT_IPO_BEZ) {
uiItemR(col, &bezt_ptr, "easing", 0, NULL, 0);
uiItemR(col, &bezt_ptr, "easing", 0, nullptr, 0);
}
/* easing extra */
switch (bezt->ipo) {
case BEZT_IPO_BACK:
col = uiLayoutColumn(layout, 1);
uiItemR(col, &bezt_ptr, "back", 0, NULL, 0);
uiItemR(col, &bezt_ptr, "back", 0, nullptr, 0);
break;
case BEZT_IPO_ELASTIC:
col = uiLayoutColumn(layout, 1);
uiItemR(col, &bezt_ptr, "amplitude", 0, NULL, 0);
uiItemR(col, &bezt_ptr, "period", 0, NULL, 0);
uiItemR(col, &bezt_ptr, "amplitude", 0, nullptr, 0);
uiItemR(col, &bezt_ptr, "period", 0, nullptr, 0);
break;
default:
break;
@@ -440,7 +438,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
0,
0,
0,
NULL);
nullptr);
UI_but_func_set(but, graphedit_activekey_update_cb, fcu, bezt);
uiItemL_respect_property_split(col, IFACE_("Value"), ICON_NONE);
@@ -459,7 +457,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
0,
0,
0,
NULL);
nullptr);
UI_but_func_set(but, graphedit_activekey_update_cb, fcu, bezt);
UI_but_unit_type_set(but, unit);
}
@@ -472,7 +470,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
but = uiDefButR(block,
UI_BTYPE_MENU,
B_REDR,
NULL,
nullptr,
0,
0,
but_max_width,
@@ -503,7 +501,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
0,
0,
0,
NULL);
nullptr);
UI_but_func_set(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt);
uiItemL_respect_property_split(col, IFACE_("Value"), ICON_NONE);
@@ -522,7 +520,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
0,
0,
0,
NULL);
nullptr);
UI_but_func_set(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt);
UI_but_unit_type_set(but, unit);
}
@@ -536,7 +534,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
but = uiDefButR(block,
UI_BTYPE_MENU,
B_REDR,
NULL,
nullptr,
0,
0,
but_max_width,
@@ -567,7 +565,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
0,
0,
0,
NULL);
nullptr);
UI_but_func_set(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt);
uiItemL_respect_property_split(col, IFACE_("Value"), ICON_NONE);
@@ -586,13 +584,13 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
0,
0,
0,
NULL);
nullptr);
UI_but_func_set(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt);
UI_but_unit_type_set(but, unit);
}
}
else {
if ((fcu->bezt == NULL) && (fcu->modifiers.first)) {
if ((fcu->bezt == nullptr) && (fcu->modifiers.first)) {
/* modifiers only - so no keyframes to be active */
uiItemL(layout, TIP_("F-Curve only has F-Modifiers"), ICON_NONE);
uiItemL(layout, TIP_("See Modifiers panel below"), ICON_INFO);
@@ -626,12 +624,12 @@ static void do_graph_region_driver_buttons(bContext *C, void *id_v, int event)
switch (event) {
case B_IPO_DEPCHANGE: {
/* Was not actually run ever (NULL always passed as arg to this callback).
* If needed again, will need to check how to pass both fcurve and ID... :/ */
/* Was not actually run ever (nullptr always passed as arg to this callback).
* If needed again, will need to check how to pass both fcurve and ID... :/ */
#if 0
/* force F-Curve & Driver to get re-evaluated (same as the old Update Dependencies) */
FCurve *fcu = (FCurve *)fcu_v;
ChannelDriver *driver = (fcu) ? fcu->driver : NULL;
ChannelDriver *driver = (fcu) ? fcu->driver : nullptr;
/* clear invalid flags */
if (fcu) {
@@ -639,17 +637,17 @@ static void do_graph_region_driver_buttons(bContext *C, void *id_v, int event)
driver->flag &= ~DRIVER_FLAG_INVALID;
}
#endif
ID *id = id_v;
ID *id = static_cast<ID *>(id_v);
AnimData *adt = BKE_animdata_from_id(id);
/* Rebuild depsgraph for the new dependencies, and ensure COW copies get flushed. */
DEG_relations_tag_update(bmain);
DEG_id_tag_update_ex(bmain, id, ID_RECALC_COPY_ON_WRITE);
if (adt != NULL) {
if (adt->action != NULL) {
if (adt != nullptr) {
if (adt->action != nullptr) {
DEG_id_tag_update_ex(bmain, &adt->action->id, ID_RECALC_COPY_ON_WRITE);
}
if (adt->tmpact != NULL) {
if (adt->tmpact != nullptr) {
DEG_id_tag_update_ex(bmain, &adt->tmpact->id, ID_RECALC_COPY_ON_WRITE);
}
}
@@ -663,7 +661,7 @@ static void do_graph_region_driver_buttons(bContext *C, void *id_v, int event)
}
/* callback to add a target variable to the active driver */
static void driver_add_var_cb(bContext *C, void *driver_v, void *UNUSED(arg))
static void driver_add_var_cb(bContext *C, void *driver_v, void * /*arg*/)
{
ChannelDriver *driver = (ChannelDriver *)driver_v;
@@ -684,7 +682,7 @@ static void driver_delete_var_cb(bContext *C, void *driver_v, void *dvar_v)
}
/* callback to report why a driver variable is invalid */
static void driver_dvar_invalid_name_query_cb(bContext *C, void *dvar_v, void *UNUSED(arg))
static void driver_dvar_invalid_name_query_cb(bContext *C, void *dvar_v, void * /*arg*/)
{
uiPopupMenu *pup = UI_popup_menu_begin(
C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Invalid Variable Name"), ICON_NONE);
@@ -723,7 +721,7 @@ static void driver_dvar_invalid_name_query_cb(bContext *C, void *dvar_v, void *U
}
/* callback to reset the driver's flags */
static void driver_update_flags_cb(bContext *UNUSED(C), void *fcu_v, void *UNUSED(arg))
static void driver_update_flags_cb(bContext * /*C*/, void *fcu_v, void * /*arg*/)
{
return;
@@ -736,7 +734,7 @@ static void driver_update_flags_cb(bContext *UNUSED(C), void *fcu_v, void *UNUSE
}
/* drivers panel poll */
static bool graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt))
static bool graph_panel_drivers_poll(const bContext *C, PanelType * /*pt*/)
{
SpaceGraph *sipo = CTX_wm_space_graph(C);
@@ -744,7 +742,7 @@ static bool graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt))
return false;
}
return graph_panel_context(C, NULL, NULL);
return graph_panel_context(C, nullptr, nullptr);
}
/* settings for 'single property' driver variable type */
@@ -850,7 +848,7 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *
/* we can clear it again now - it's only needed when creating the ID/Bone fields */
uiLayoutSetRedAlert(col, false);
uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE);
uiItemR(col, &dtar_ptr, "transform_space", 0, nullptr, ICON_NONE);
/* Object 2 */
col = uiLayoutColumn(layout, true);
@@ -868,7 +866,7 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *
/* we can clear it again now - it's only needed when creating the ID/Bone fields */
uiLayoutSetRedAlert(col, false);
uiItemR(col, &dtar2_ptr, "transform_space", 0, NULL, ICON_NONE);
uiItemR(col, &dtar2_ptr, "transform_space", 0, nullptr, ICON_NONE);
}
/* settings for 'transform channel' driver variable type */
@@ -896,7 +894,7 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar
}
sub = uiLayoutColumn(layout, true);
uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE);
uiItemR(sub, &dtar_ptr, "transform_type", 0, nullptr, ICON_NONE);
if (ELEM(dtar->transChan,
DTAR_TRANSCHAN_ROTX,
@@ -922,15 +920,18 @@ static void graph_panel_driverVar__contextProp(uiLayout *layout, ID *id, DriverV
/* Target Property. */
{
uiLayout *row = uiLayoutRow(layout, false);
uiItemR(row, &dtar_ptr, "context_property", 0, NULL, ICON_NONE);
uiItemR(row, &dtar_ptr, "context_property", 0, nullptr, ICON_NONE);
}
/* Target Path */
{
uiLayout *col = uiLayoutColumn(layout, true);
uiLayoutSetRedAlert(col, (dtar->flag & DTAR_FLAG_INVALID));
uiTemplatePathBuilder(
col, &dtar_ptr, "data_path", NULL, CTX_IFACE_(BLT_I18NCONTEXT_EDITOR_FILEBROWSER, "Path"));
uiTemplatePathBuilder(col,
&dtar_ptr,
"data_path",
nullptr,
CTX_IFACE_(BLT_I18NCONTEXT_EDITOR_FILEBROWSER, "Path"));
}
}
@@ -1027,7 +1028,7 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
col = uiLayoutColumn(layout, true);
block = uiLayoutGetBlock(col);
uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE);
uiItemR(col, &driver_ptr, "type", 0, nullptr, ICON_NONE);
{
char valBuf[32];
@@ -1045,8 +1046,8 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
/* show expression box if doing scripted drivers,
* and/or error messages when invalid drivers exist */
if (driver->type == DRIVER_TYPE_PYTHON) {
bool bpy_data_expr_error = (strstr(driver->expression, "bpy.data.") != NULL);
bool bpy_ctx_expr_error = (strstr(driver->expression, "bpy.context.") != NULL);
bool bpy_data_expr_error = (strstr(driver->expression, "bpy.data.") != nullptr);
bool bpy_ctx_expr_error = (strstr(driver->expression, "bpy.context.") != nullptr);
/* expression */
/* TODO: "Show syntax hints" button */
@@ -1055,7 +1056,7 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
uiItemL(col, IFACE_("Expression:"), ICON_NONE);
uiItemR(col, &driver_ptr, "expression", 0, "", ICON_NONE);
uiItemR(col, &driver_ptr, "use_self", 0, NULL, ICON_NONE);
uiItemR(col, &driver_ptr, "use_self", 0, nullptr, ICON_NONE);
/* errors? */
col = uiLayoutColumn(layout, true);
@@ -1130,13 +1131,13 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
0,
10 * UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
0,
TIP_("Add a Driver Variable to keep track of an input used by the driver"));
UI_but_func_set(but, driver_add_var_cb, driver, NULL);
UI_but_func_set(but, driver_add_var_cb, driver, nullptr);
if (is_popover) {
/* add driver variable - add using eyedropper */
@@ -1152,7 +1153,7 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_driver_variables_paste");
/* loop over targets, drawing them */
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
for (dvar = static_cast<DriverVar *>(driver->variables.first); dvar; dvar = dvar->next) {
PointerRNA dvar_ptr;
uiLayout *box;
uiLayout *subrow, *sub;
@@ -1202,13 +1203,13 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0.0,
0.0,
TIP_("Invalid variable name, click here for details"));
UI_but_func_set(but, driver_dvar_invalid_name_query_cb, dvar, NULL); /* XXX: reports? */
UI_but_func_set(but, driver_dvar_invalid_name_query_cb, dvar, nullptr); /* XXX: reports? */
}
/* 1.3) remove button */
@@ -1220,7 +1221,7 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0.0,
@@ -1294,13 +1295,13 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
0,
10 * UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
0,
TIP_("Force updates of dependencies - Only use this if drivers are not updating correctly"));
UI_but_func_set(but, driver_update_flags_cb, fcu, NULL);
UI_but_func_set(but, driver_update_flags_cb, fcu, nullptr);
}
/* ----------------------------------------------------------------- */
@@ -1343,7 +1344,7 @@ static void graph_panel_drivers(const bContext *C, Panel *panel)
/* Poll to make this not show up in the graph editor,
* as this is only to be used as a popup elsewhere. */
static bool graph_panel_drivers_popover_poll(const bContext *C, PanelType *UNUSED(pt))
static bool graph_panel_drivers_popover_poll(const bContext *C, PanelType * /*pt*/)
{
return ED_operator_graphedit_active((bContext *)C) == false;
}
@@ -1353,10 +1354,10 @@ static void graph_panel_drivers_popover(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr = {NULL};
PropertyRNA *prop = NULL;
PointerRNA ptr = {nullptr};
PropertyRNA *prop = nullptr;
int index = -1;
uiBut *but = NULL;
uiBut *but = nullptr;
/* Get active property to show driver properties for */
but = UI_region_active_but_prop_get(CTX_wm_region(C), &ptr, &prop, &index);
@@ -1365,7 +1366,7 @@ static void graph_panel_drivers_popover(const bContext *C, Panel *panel)
bool driven, special;
fcu = BKE_fcurve_find_by_rna_context_ui(
(bContext *)C, &ptr, prop, index, NULL, NULL, &driven, &special);
(bContext *)C, &ptr, prop, index, nullptr, nullptr, &driven, &special);
/* Hack: Force all buttons in this panel to be able to know the driver button
* this panel is getting spawned from, so that things like the "Open Drivers Editor"
@@ -1414,17 +1415,17 @@ static void graph_panel_drivers_popover(const bContext *C, Panel *panel)
static void graph_fmodifier_panel_id(void *fcm_link, char *r_name)
{
FModifier *fcm = (FModifier *)fcm_link;
eFModifier_Types type = fcm->type;
eFModifier_Types type = eFModifier_Types(fcm->type);
const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(type);
BLI_snprintf(r_name, BKE_ST_MAXNAME, "%s_PT_%s", GRAPH_FMODIFIER_PANEL_PREFIX, fmi->name);
}
static void do_graph_region_modifier_buttons(bContext *C, void *UNUSED(arg), int event)
static void do_graph_region_modifier_buttons(bContext *C, void * /*arg*/, int event)
{
switch (event) {
case B_FMODIFIER_REDRAW: /* XXX this should send depsgraph updates too */
/* XXX: need a notifier specially for F-Modifiers */
WM_event_add_notifier(C, NC_ANIMATION, NULL);
WM_event_add_notifier(C, NC_ANIMATION, nullptr);
break;
}
}
@@ -1441,7 +1442,7 @@ static void graph_panel_modifiers(const bContext *C, Panel *panel)
}
block = uiLayoutGetBlock(panel->layout);
UI_block_func_handle_set(block, do_graph_region_modifier_buttons, NULL);
UI_block_func_handle_set(block, do_graph_region_modifier_buttons, nullptr);
/* 'add modifier' button at top of panel */
{
@@ -1473,7 +1474,8 @@ void graph_buttons_register(ARegionType *art)
{
PanelType *pt;
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
pt = static_cast<PanelType *>(
MEM_callocN(sizeof(PanelType), "spacetype graph panel properties"));
STRNCPY(pt->idname, "GRAPH_PT_properties");
STRNCPY(pt->label, N_("Active F-Curve"));
STRNCPY(pt->category, "F-Curve");
@@ -1482,7 +1484,8 @@ void graph_buttons_register(ARegionType *art)
pt->poll = graph_panel_poll;
BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
pt = static_cast<PanelType *>(
MEM_callocN(sizeof(PanelType), "spacetype graph panel properties"));
STRNCPY(pt->idname, "GRAPH_PT_key_properties");
STRNCPY(pt->label, N_("Active Keyframe"));
STRNCPY(pt->category, "F-Curve");
@@ -1491,7 +1494,8 @@ void graph_buttons_register(ARegionType *art)
pt->poll = graph_panel_poll;
BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers driven");
pt = static_cast<PanelType *>(
MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers driven"));
STRNCPY(pt->idname, "GRAPH_PT_driven_property");
STRNCPY(pt->label, N_("Driven Property"));
STRNCPY(pt->category, "Drivers");
@@ -1500,7 +1504,7 @@ void graph_buttons_register(ARegionType *art)
pt->poll = graph_panel_drivers_poll;
BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers");
pt = static_cast<PanelType *>(MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers"));
STRNCPY(pt->idname, "GRAPH_PT_drivers");
STRNCPY(pt->label, N_("Driver"));
STRNCPY(pt->category, "Drivers");
@@ -1510,7 +1514,8 @@ void graph_buttons_register(ARegionType *art)
pt->poll = graph_panel_drivers_poll;
BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers popover");
pt = static_cast<PanelType *>(
MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers popover"));
STRNCPY(pt->idname, "GRAPH_PT_drivers_popover");
STRNCPY(pt->label, N_("Add/Edit Driver"));
STRNCPY(pt->category, "Drivers");
@@ -1522,7 +1527,7 @@ void graph_buttons_register(ARegionType *art)
* Add explicitly to global list (so popovers work). */
WM_paneltype_add(pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel modifiers");
pt = static_cast<PanelType *>(MEM_callocN(sizeof(PanelType), "spacetype graph panel modifiers"));
STRNCPY(pt->idname, "GRAPH_PT_modifiers");
STRNCPY(pt->label, N_("Modifiers"));
STRNCPY(pt->category, "Modifiers");
@@ -1535,7 +1540,7 @@ void graph_buttons_register(ARegionType *art)
ANIM_modifier_panels_register_graph_and_NLA(art, GRAPH_FMODIFIER_PANEL_PREFIX, graph_panel_poll);
ANIM_modifier_panels_register_graph_only(art, GRAPH_FMODIFIER_PANEL_PREFIX, graph_panel_poll);
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel view");
pt = static_cast<PanelType *>(MEM_callocN(sizeof(PanelType), "spacetype graph panel view"));
STRNCPY(pt->idname, "GRAPH_PT_view");
STRNCPY(pt->label, N_("Show Cursor"));
STRNCPY(pt->category, "View");

View File

@@ -65,7 +65,7 @@ static float fcurve_display_alpha(FCurve *fcu)
/* TODO: draw a shaded poly showing the region of influence too!!! */
/**
* \param adt_nla_remap: Send NULL if no NLA remapping necessary.
* \param adt_nla_remap: Send nullptr if no NLA remapping necessary.
*/
static void draw_fcurve_modifier_controls_envelope(FModifier *fcm,
View2D *v2d,
@@ -324,7 +324,7 @@ static void draw_fcurve_selected_handle_vertices(
immBeginAtMost(GPU_PRIM_POINTS, fcu->totvert * 2);
BezTriple *bezt = fcu->bezt;
BezTriple *prevbezt = NULL;
BezTriple *prevbezt = nullptr;
for (int i = 0; i < fcu->totvert; i++, prevbezt = bezt, bezt++) {
/* Draw the editmode handles for a bezier curve (others don't have handles)
* if their selection status matches the selection status we're drawing for
@@ -444,12 +444,12 @@ static void draw_fcurve_vertices(
static bool draw_fcurve_handles_check(SpaceGraph *sipo, FCurve *fcu)
{
/* don't draw handle lines if handles are not to be shown */
if (
/* handles shouldn't be shown anywhere */
if (/* handles shouldn't be shown anywhere */
(sipo->flag & SIPO_NOHANDLES) ||
/* keyframes aren't editable */
(fcu->flag & FCURVE_PROTECTED) ||
#if 0 /* handles can still be selected and handle types set, better draw - campbell */
#if 0
/* handles can still be selected and handle types set, better draw - campbell */
/* editing the handles here will cause weird/incorrect interpolation issues */
(fcu->flag & FCURVE_INT_VALUES) ||
#endif
@@ -483,7 +483,7 @@ static void draw_fcurve_handles(SpaceGraph *sipo, FCurve *fcu)
* so that selected points are clearly visible
*/
for (sel = 0; sel < 2; sel++) {
BezTriple *bezt = fcu->bezt, *prevbezt = NULL;
BezTriple *bezt = fcu->bezt, *prevbezt = nullptr;
int basecol = (sel) ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE;
uchar col[4];
@@ -571,7 +571,7 @@ static void draw_fcurve_samples(ARegion *region, FCurve *fcu, const float unit_s
/* get verts */
first = fcu->fpt;
last = (first) ? (first + (fcu->totvert - 1)) : (NULL);
last = (first) ? (first + (fcu->totvert - 1)) : (nullptr);
/* draw */
if (first && last) {
@@ -620,7 +620,7 @@ static void draw_fcurve_curve(bAnimContext *ac,
/* disable any drivers */
FCurve fcurve_for_draw = *fcu_;
fcurve_for_draw.driver = NULL;
fcurve_for_draw.driver = nullptr;
/* compute unit correction factor */
float offset;
@@ -670,7 +670,7 @@ static void draw_fcurve_curve(bAnimContext *ac,
float stime = v2d->cur.xmin;
float etime = v2d->cur.xmax;
AnimData *adt = use_nla_remap ? BKE_animdata_from_id(id) : NULL;
AnimData *adt = use_nla_remap ? BKE_animdata_from_id(id) : nullptr;
/* If not drawing extrapolation, then change fcurve drawing bounds to its keyframe bounds clamped
* by graph editor bounds. */
@@ -1009,7 +1009,7 @@ static void draw_fcurve_curve_bezts(
}
else if (prevbezt->ipo == BEZT_IPO_BEZ) {
int resolution = calculate_bezt_draw_resolution(
bezt, prevbezt, max_bezt_resolution, fcu->driver != NULL);
bezt, prevbezt, max_bezt_resolution, fcu->driver != nullptr);
draw_bezt(bezt, prevbezt, resolution, pos);
}
@@ -1071,7 +1071,7 @@ static void draw_fcurve(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, bAn
/* map keyframes for drawing if scaled F-Curve */
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), 0, 0);
}
/* draw curve:
@@ -1146,9 +1146,9 @@ static void draw_fcurve(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, bAn
* So we undo the keyframe remapping and instead remap the evaluation time when drawing the
* curve itself. Afterward, we go back and redo the keyframe remapping so the controls are
* drawn properly. */
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, true, false);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), true, false);
draw_fcurve_curve(ac, ale->id, fcu, &region->v2d, shdr_pos, true, draw_extrapolation);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, false, false);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), false, false);
}
else {
draw_fcurve_curve(ac, ale->id, fcu, &region->v2d, shdr_pos, false, draw_extrapolation);
@@ -1235,7 +1235,7 @@ static void draw_fcurve(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, bAn
/* undo mapping of keyframes for drawing if scaled F-Curve */
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), 1, 0);
}
}
@@ -1391,7 +1391,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region
* See issue #109920 for details. */
const bool draw_extrapolation = false;
/* the ghost curves are simply sampled F-Curves stored in sipo->runtime.ghost_curves */
for (fcu = sipo->runtime.ghost_curves.first; fcu; fcu = fcu->next) {
for (fcu = static_cast<FCurve *>(sipo->runtime.ghost_curves.first); fcu; fcu = fcu->next) {
/* set whatever color the curve has set
* - this is set by the function which creates these
* - draw with a fixed opacity of 2
@@ -1399,7 +1399,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region
immUniformColor3fvAlpha(fcu->color, 0.5f);
/* simply draw the stored samples */
draw_fcurve_curve_samples(ac, NULL, fcu, &region->v2d, shdr_pos, draw_extrapolation);
draw_fcurve_curve_samples(ac, nullptr, fcu, &region->v2d, shdr_pos, draw_extrapolation);
}
immUnbindProgram();
@@ -1412,21 +1412,22 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region
void graph_draw_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, short sel)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
/* build list of curves to draw */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY);
filter |= ((sel) ? (ANIMFILTER_SEL) : (ANIMFILTER_UNSEL));
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* for each curve:
* draw curve, then handle-lines, and finally vertices in this order so that
* the data will be layered correctly
*/
bAnimListElem *ale_active_fcurve = NULL;
for (ale = anim_data.first; ale; ale = ale->next) {
bAnimListElem *ale_active_fcurve = nullptr;
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
const FCurve *fcu = (FCurve *)ale->key_data;
if (fcu->flag & FCURVE_ACTIVE) {
ale_active_fcurve = ale;
@@ -1437,7 +1438,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, shor
/* Draw the active FCurve last so that it (especially the active keyframe)
* shows on top of the other curves. */
if (ale_active_fcurve != NULL) {
if (ale_active_fcurve != nullptr) {
draw_fcurve(ac, sipo, region, ale_active_fcurve);
}
@@ -1453,7 +1454,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, shor
void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
@@ -1464,7 +1465,8 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
/* build list of channels to draw */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS |
ANIMFILTER_FCURVESONLY);
items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
items = ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Update max-extent of channels here (taking into account scrollers):
* - this is done to allow the channel list to be scrollable, but must be done here
@@ -1478,7 +1480,9 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
size_t channel_index = 0;
float ymax = ANIM_UI_get_first_channel_top(v2d);
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= channel_step, channel_index++)
{
const float ymin = ymax - ANIM_UI_get_channel_height();
/* check if visible */
@@ -1497,7 +1501,9 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
/* set blending again, as may not be set in previous step */
GPU_blend(GPU_BLEND_ALPHA);
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= channel_step, channel_index++)
{
const float ymin = ymax - ANIM_UI_get_channel_height();
/* check if visible */

View File

@@ -97,14 +97,14 @@ static const EnumPropertyItem prop_graphkeys_insertkey_types[] = {
0,
"Selected Channels at Cursor",
"Insert a keyframe for selected F-Curves at the cursor point"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* This function is responsible for snapping keyframes to frame-times. */
static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
{
ListBase anim_data = {NULL, NULL};
ListBase nla_cache = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
ListBase nla_cache = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
size_t num_items;
@@ -113,7 +113,7 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
Scene *scene = ac->scene;
ToolSettings *ts = scene->toolsettings;
eInsertKeyFlags flag = 0;
eInsertKeyFlags flag = eInsertKeyFlags(0);
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
@@ -125,7 +125,8 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
filter |= ANIMFILTER_ACTIVE;
}
num_items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
num_items = ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
if (num_items == 0) {
if (mode & GRAPHKEYS_INSERTKEY_ACTIVE) {
BKE_report(reports,
@@ -147,14 +148,14 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
/* Insert keyframes. */
if (mode & GRAPHKEYS_INSERTKEY_CURSOR) {
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcu = (FCurve *)ale->key_data;
short mapping_flag = ANIM_get_normalization_flags(ac);
float offset;
float unit_scale = ANIM_unit_mapping_get_factor(
ac->scene, ale->id, ale->key_data, mapping_flag, &offset);
ac->scene, ale->id, static_cast<FCurve *>(ale->key_data), mapping_flag, &offset);
float x, y;
@@ -178,7 +179,8 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
}
/* Insert keyframe directly into the F-Curve. */
insert_vert_fcurve(fcu, x, y, ts->keyframe_type, 0);
insert_vert_fcurve(
fcu, x, y, eBezTriple_KeyframeType(ts->keyframe_type), eInsertKeyFlags(0));
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -186,18 +188,18 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
else {
const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
ac->depsgraph, (float)scene->r.cfra);
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
/* Read value from property the F-Curve represents, or from the curve only?
*
* - ale->id != NULL:
* - ale->id != nullptr:
* Typically, this means that we have enough info to try resolving the path.
* - ale->owner != NULL:
* - ale->owner != nullptr:
* If this is set, then the path may not be resolvable from the ID alone,
* so it's easier for now to just read the F-Curve directly.
* (TODO: add the full-blown PointerRNA relative parsing case here... (Joshua Leung 2015))
* - fcu->driver != NULL:
* - fcu->driver != nullptr:
* If this is set, then it's a driver. If we don't check for this, we'd end
* up adding the keyframes on a new F-Curve in the action data instead.
*/
@@ -205,12 +207,12 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
insert_keyframe(ac->bmain,
reports,
ale->id,
NULL,
((fcu->grp) ? (fcu->grp->name) : (NULL)),
nullptr,
((fcu->grp) ? (fcu->grp->name) : (nullptr)),
fcu->rna_path,
fcu->array_index,
&anim_eval_context,
ts->keyframe_type,
eBezTriple_KeyframeType(ts->keyframe_type),
&nla_cache,
flag);
}
@@ -227,7 +229,8 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
}
const float curval = evaluate_fcurve_only_curve(fcu, cfra);
insert_vert_fcurve(fcu, cfra, curval, ts->keyframe_type, 0);
insert_vert_fcurve(
fcu, cfra, curval, eBezTriple_KeyframeType(ts->keyframe_type), eInsertKeyFlags(0));
}
ale->update |= ANIM_UPDATE_DEFAULT;
@@ -253,13 +256,13 @@ static int graphkeys_insertkey_exec(bContext *C, wmOperator *op)
}
/* Which channels to affect? */
mode = RNA_enum_get(op->ptr, "type");
mode = eGraphKeys_InsertKey_Types(RNA_enum_get(op->ptr, "type"));
/* Insert keyframes. */
insert_graph_keys(&ac, mode);
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, nullptr);
return OPERATOR_FINISHED;
}
@@ -304,13 +307,13 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
/* Get active F-Curve 'anim-list-element'. */
ale = get_active_fcurve_channel(&ac);
if (ELEM(NULL, ale, ale->data)) {
if (ELEM(nullptr, ale, ale->data)) {
if (ale) {
MEM_freeN(ale);
}
return OPERATOR_CANCELLED;
}
fcu = ale->data;
fcu = static_cast<FCurve *>(ale->data);
/* When there are F-Modifiers on the curve, only allow adding
* keyframes if these will be visible after doing so...
@@ -345,7 +348,8 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
val = val * scale - offset;
/* Insert keyframe on the specified frame + value. */
insert_vert_fcurve(fcu, frame, val, ts->keyframe_type, 0);
insert_vert_fcurve(
fcu, frame, val, eBezTriple_KeyframeType(ts->keyframe_type), eInsertKeyFlags(0));
ale->update |= ANIM_UPDATE_DEPS;
@@ -371,7 +375,7 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
MEM_freeN(ale);
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
/* Done */
return OPERATOR_FINISHED;
@@ -454,7 +458,7 @@ void GRAPH_OT_click_insert(wmOperatorType *ot)
static short copy_graph_keys(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
int filter, ok = 0;
/* Clear buffer first. */
@@ -467,8 +471,14 @@ static short copy_graph_keys(bAnimContext *ac)
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0) {
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
if (ANIM_animdata_filter(ac,
&anim_data,
eAnimFilter_Flags(filter | ANIMFILTER_SEL),
ac->data,
eAnimCont_Types(ac->datatype)) == 0)
{
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
}
/* Copy keyframes. */
@@ -486,7 +496,7 @@ static eKeyPasteError paste_graph_keys(bAnimContext *ac,
const eKeyMergeMode merge_mode,
bool flip)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
int filter;
/* Filter data
@@ -498,8 +508,14 @@ static eKeyPasteError paste_graph_keys(bAnimContext *ac,
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0) {
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
if (ANIM_animdata_filter(ac,
&anim_data,
eAnimFilter_Flags(filter | ANIMFILTER_SEL),
ac->data,
eAnimCont_Types(ac->datatype)) == 0)
{
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
}
/* Paste keyframes. */
@@ -552,9 +568,10 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset");
const eKeyPasteValueOffset value_offset_mode = RNA_enum_get(op->ptr, "value_offset");
const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge");
const eKeyPasteOffset offset_mode = eKeyPasteOffset(RNA_enum_get(op->ptr, "offset"));
const eKeyPasteValueOffset value_offset_mode = eKeyPasteValueOffset(
RNA_enum_get(op->ptr, "value_offset"));
const eKeyMergeMode merge_mode = eKeyMergeMode(RNA_enum_get(op->ptr, "merge"));
const bool flipped = RNA_boolean_get(op->ptr, "flipped");
/* Get editor data. */
@@ -581,13 +598,13 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op)
}
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
static char *graphkeys_paste_description(bContext *UNUSED(C),
wmOperatorType *UNUSED(op),
static char *graphkeys_paste_description(bContext * /*C*/,
wmOperatorType * /*op*/,
PointerRNA *ptr)
{
/* Custom description if the 'flipped' option is used. */
@@ -596,7 +613,7 @@ static char *graphkeys_paste_description(bContext *UNUSED(C),
}
/* Use the default description in the other cases. */
return NULL;
return nullptr;
}
void GRAPH_OT_paste(wmOperatorType *ot)
@@ -653,7 +670,7 @@ void GRAPH_OT_paste(wmOperatorType *ot)
static bool duplicate_graph_keys(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
bool changed = false;
@@ -661,10 +678,11 @@ static bool duplicate_graph_keys(bAnimContext *ac)
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Loop through filtered data and delete selected keys. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
changed |= duplicate_fcurve_keys((FCurve *)ale->key_data);
ale->update |= ANIM_UPDATE_DEFAULT;
@@ -678,7 +696,7 @@ static bool duplicate_graph_keys(bAnimContext *ac)
/* ------------------- */
static int graphkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
static int graphkeys_duplicate_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
@@ -693,7 +711,7 @@ static int graphkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
}
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, nullptr);
return OPERATOR_FINISHED;
}
@@ -724,7 +742,7 @@ void GRAPH_OT_duplicate(wmOperatorType *ot)
static bool delete_graph_keys(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
bool changed_final = false;
@@ -732,10 +750,11 @@ static bool delete_graph_keys(bAnimContext *ac)
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Loop through filtered data and delete selected keys. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
AnimData *adt = ale->adt;
bool changed;
@@ -751,7 +770,7 @@ static bool delete_graph_keys(bAnimContext *ac)
/* Only delete curve too if it won't be doing anything anymore. */
if (BKE_fcurve_is_empty(fcu)) {
ANIM_fcurve_delete_from_animdata(ac, adt, fcu);
ale->key_data = NULL;
ale->key_data = nullptr;
}
}
@@ -763,7 +782,7 @@ static bool delete_graph_keys(bAnimContext *ac)
/* ------------------- */
static int graphkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
static int graphkeys_delete_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
@@ -778,7 +797,7 @@ static int graphkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
}
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, nullptr);
return OPERATOR_FINISHED;
}
@@ -808,17 +827,18 @@ void GRAPH_OT_delete(wmOperatorType *ot)
static void clean_graph_keys(bAnimContext *ac, float thresh, bool clean_chan)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Loop through filtered data and clean curves. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
clean_fcurve(ac, ale, thresh, clean_chan);
ale->update |= ANIM_UPDATE_DEFAULT;
@@ -848,7 +868,7 @@ static int graphkeys_clean_exec(bContext *C, wmOperator *op)
clean_graph_keys(&ac, thresh, clean_chan);
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -885,25 +905,26 @@ void GRAPH_OT_clean(wmOperatorType *ot)
/* Bake each F-Curve into a set of samples. */
static void bake_graph_curves(bAnimContext *ac, int start, int end)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Loop through filtered data and add keys between selected keyframes on every frame. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
ChannelDriver *driver = fcu->driver;
/* Disable driver so that it don't muck up the sampling process. */
fcu->driver = NULL;
fcu->driver = nullptr;
/* Create samples. */
fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve);
fcurve_store_samples(fcu, nullptr, start, end, fcurve_samplingcb_evalcurve);
/* Restore driver. */
fcu->driver = driver;
@@ -917,10 +938,10 @@ static void bake_graph_curves(bAnimContext *ac, int start, int end)
/* ------------------- */
static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op))
static int graphkeys_bake_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
Scene *scene = NULL;
Scene *scene = nullptr;
int start, end;
/* Get editor data. */
@@ -939,7 +960,7 @@ static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op))
/* Set notifier that keyframes have changed. */
/* NOTE: some distinction between order/number of keyframes and type should be made? */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -974,16 +995,17 @@ void GRAPH_OT_bake(wmOperatorType *ot)
/* Un-Bake F-Points into F-Curves. */
static void unbake_graph_curves(bAnimContext *ac, int start, int end)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
/* Filter data. */
const int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Loop through filtered data and add keys between selected keyframes on every frame. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
fcurve_samples_to_keyframes(fcu, start, end);
@@ -997,10 +1019,10 @@ static void unbake_graph_curves(bAnimContext *ac, int start, int end)
/* ------------------- */
static int graphkeys_unbake_exec(bContext *C, wmOperator *UNUSED(op))
static int graphkeys_unbake_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
Scene *scene = NULL;
Scene *scene = nullptr;
int start, end;
/* Get editor data. */
@@ -1017,7 +1039,7 @@ static int graphkeys_unbake_exec(bContext *C, wmOperator *UNUSED(op))
/* Set notifier that keyframes have changed. */
/* NOTE: some distinction between order/number of keyframes and type should be made? */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1052,18 +1074,18 @@ void GRAPH_OT_unbake(wmOperatorType *ot)
/* Custom data storage passed to the F-Sample-ing function,
* which provides the necessary info for baking the sound.
*/
typedef struct tSoundBakeInfo {
struct tSoundBakeInfo {
float *samples;
int length;
int cfra;
} tSoundBakeInfo;
};
/* ------------------- */
/* Sampling callback used to determine the value from the sound to
* save in the F-Curve at the specified frame.
*/
static float fcurve_samplingcb_sound(FCurve *UNUSED(fcu), void *data, float evaltime)
static float fcurve_samplingcb_sound(FCurve * /*fcu*/, void *data, float evaltime)
{
tSoundBakeInfo *sbi = (tSoundBakeInfo *)data;
@@ -1080,12 +1102,12 @@ static float fcurve_samplingcb_sound(FCurve *UNUSED(fcu), void *data, float eval
static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
tSoundBakeInfo sbi;
Scene *scene = NULL;
Scene *scene = nullptr;
int start, end;
char filepath[FILE_MAX];
@@ -1119,7 +1141,7 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
&sbi.length,
0);
if (sbi.samples == NULL) {
if (sbi.samples == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
return OPERATOR_CANCELLED;
}
@@ -1131,10 +1153,11 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
/* Filter anim channels. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
/* Loop through all selected F-Curves, replacing its data with the sound samples. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
/* Sample the sound. */
@@ -1151,14 +1174,14 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
ANIM_animdata_freelist(&anim_data);
/* Set notifier that 'keyframes' have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
#else /* WITH_AUDASPACE */
static int graphkeys_sound_bake_exec(bContext *UNUSED(C), wmOperator *op)
static int graphkeys_sound_bake_exec(bContext * /*C*/, wmOperator *op)
{
BKE_report(op->reports, RPT_ERROR, "Compiled without sound support");
@@ -1291,17 +1314,18 @@ void GRAPH_OT_sound_bake(wmOperatorType *ot)
/* Evaluates the curves between each selected keyframe on each frame, and keys the value. */
static void sample_graph_keys(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Loop through filtered data and add keys between selected keyframes on every frame. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
sample_fcurve((FCurve *)ale->key_data);
ale->update |= ANIM_UPDATE_DEPS;
@@ -1313,7 +1337,7 @@ static void sample_graph_keys(bAnimContext *ac)
/* ------------------- */
static int graphkeys_sample_exec(bContext *C, wmOperator *UNUSED(op))
static int graphkeys_sample_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
@@ -1326,7 +1350,7 @@ static int graphkeys_sample_exec(bContext *C, wmOperator *UNUSED(op))
sample_graph_keys(&ac);
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1382,23 +1406,24 @@ static const EnumPropertyItem prop_graphkeys_expo_types[] = {
0,
"Clear Cyclic (F-Modifier)",
"Remove Cycles F-Modifier if not needed anymore"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* This function is responsible for setting extrapolation mode for keyframes. */
static void setexpo_graph_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Loop through setting mode per F-Curve. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
if (mode >= 0) {
@@ -1421,9 +1446,9 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode)
}
else if (mode == CLEAR_CYCLIC_EXPO) {
/* Remove all the modifiers fitting this description. */
FModifier *fcm, *fcn = NULL;
FModifier *fcm, *fcn = nullptr;
for (fcm = fcu->modifiers.first; fcm; fcm = fcn) {
for (fcm = static_cast<FModifier *>(fcu->modifiers.first); fcm; fcm = fcn) {
fcn = fcm->next;
if (fcm->type == FMODIFIER_TYPE_CYCLES) {
@@ -1459,7 +1484,7 @@ static int graphkeys_expo_exec(bContext *C, wmOperator *op)
setexpo_graph_keys(&ac, mode);
/* Set notifier that keyframe properties have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr);
return OPERATOR_FINISHED;
}
@@ -1492,7 +1517,7 @@ void GRAPH_OT_extrapolation_type(wmOperatorType *ot)
/* This function is responsible for setting interpolation mode for keyframes. */
static void setipo_graph_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
KeyframeEditFunc set_cb = ANIM_editkeyframes_ipo(mode);
@@ -1500,14 +1525,16 @@ static void setipo_graph_keys(bAnimContext *ac, short mode)
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Loop through setting BezTriple interpolation
* NOTE: we do not supply KeyframeEditData to the looper yet.
* Currently that's not necessary here.
*/
for (ale = anim_data.first; ale; ale = ale->next) {
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, BKE_fcurve_handles_recalc);
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
ANIM_fcurve_keyframes_loop(
nullptr, static_cast<FCurve *>(ale->key_data), nullptr, set_cb, BKE_fcurve_handles_recalc);
ale->update |= ANIM_UPDATE_DEFAULT_NOHANDLES;
}
@@ -1535,7 +1562,7 @@ static int graphkeys_ipo_exec(bContext *C, wmOperator *op)
setipo_graph_keys(&ac, mode);
/* Set notifier that keyframe properties have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr);
return OPERATOR_FINISHED;
}
@@ -1570,7 +1597,7 @@ void GRAPH_OT_interpolation_type(wmOperatorType *ot)
static void seteasing_graph_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
KeyframeEditFunc set_cb = ANIM_editkeyframes_easing(mode);
@@ -1578,14 +1605,16 @@ static void seteasing_graph_keys(bAnimContext *ac, short mode)
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Loop through setting BezTriple easing.
* NOTE: we do not supply KeyframeEditData to the looper yet.
* Currently that's not necessary here.
*/
for (ale = anim_data.first; ale; ale = ale->next) {
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, BKE_fcurve_handles_recalc);
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
ANIM_fcurve_keyframes_loop(
nullptr, static_cast<FCurve *>(ale->key_data), nullptr, set_cb, BKE_fcurve_handles_recalc);
ale->update |= ANIM_UPDATE_DEFAULT_NOHANDLES;
}
@@ -1611,7 +1640,7 @@ static int graphkeys_easing_exec(bContext *C, wmOperator *op)
seteasing_graph_keys(&ac, mode);
/* Set notifier that keyframe properties have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr);
return OPERATOR_FINISHED;
}
@@ -1646,7 +1675,7 @@ void GRAPH_OT_easing_type(wmOperatorType *ot)
/* This function is responsible for setting handle-type of selected keyframes. */
static void sethandles_graph_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
@@ -1656,19 +1685,20 @@ static void sethandles_graph_keys(bAnimContext *ac, short mode)
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Loop through setting flags for handles.
* NOTE: we do not supply KeyframeEditData to the looper yet.
* Currently that's not necessary here.
*/
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
/* Any selected keyframes for editing? */
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) {
if (ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, sel_cb, nullptr)) {
/* Change type of selected handles. */
ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, edit_cb, BKE_fcurve_handles_recalc);
ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, edit_cb, BKE_fcurve_handles_recalc);
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -1696,7 +1726,7 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op)
sethandles_graph_keys(&ac, mode);
/* Set notifier that keyframe properties have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr);
return OPERATOR_FINISHED;
}
@@ -1735,16 +1765,16 @@ void GRAPH_OT_handle_type(wmOperatorType *ot)
* \{ */
/* Set of three euler-rotation F-Curves. */
typedef struct tEulerFilter {
struct tEulerFilter {
struct tEulerFilter *next, *prev;
/** ID-block which owns the channels */
ID *id;
/** 3 Pointers to F-Curves. */
FCurve *(fcurves[3]);
FCurve *fcurves[3];
/** Pointer to one of the RNA Path's used by one of the F-Curves. */
const char *rna_path;
} tEulerFilter;
};
static bool keyframe_time_differs(BezTriple *keyframes[3])
{
@@ -1758,8 +1788,8 @@ static bool keyframe_time_differs(BezTriple *keyframes[3])
static ListBase /*tEulerFilter*/ euler_filter_group_channels(
const ListBase /*bAnimListElem*/ *anim_data, ReportList *reports, int *r_num_groups)
{
ListBase euler_groups = {NULL, NULL};
tEulerFilter *euf = NULL;
ListBase euler_groups = {nullptr, nullptr};
tEulerFilter *euf = nullptr;
*r_num_groups = 0;
LISTBASE_FOREACH (bAnimListElem *, ale, anim_data) {
@@ -1769,7 +1799,7 @@ static ListBase /*tEulerFilter*/ euler_filter_group_channels(
* - Only rotation curves.
* - For pchan curves, make sure we're only using the euler curves.
*/
if (strstr(fcu->rna_path, "rotation_euler") == NULL) {
if (strstr(fcu->rna_path, "rotation_euler") == nullptr) {
continue;
}
if (ELEM(fcu->array_index, 0, 1, 2) == 0) {
@@ -1797,7 +1827,7 @@ static ListBase /*tEulerFilter*/ euler_filter_group_channels(
}
/* Just add to a new block. */
euf = MEM_callocN(sizeof(tEulerFilter), "tEulerFilter");
euf = static_cast<tEulerFilter *>(MEM_callocN(sizeof(tEulerFilter), "tEulerFilter"));
BLI_addtail(&euler_groups, euf);
++*r_num_groups;
@@ -1815,14 +1845,14 @@ static ListBase /*tEulerFilter*/ euler_filter_group_channels(
static bool euler_filter_multi_channel(tEulerFilter *euf, ReportList *reports)
{
/* Sanity check: ensure that there are enough F-Curves to work on in this group. */
if (ELEM(NULL, euf->fcurves[0], euf->fcurves[1], euf->fcurves[2])) {
if (ELEM(nullptr, euf->fcurves[0], euf->fcurves[1], euf->fcurves[2])) {
/* Report which components are missing. */
BKE_reportf(reports,
RPT_INFO,
"Missing %s%s%s component(s) of euler rotation for ID='%s' and RNA-Path='%s'",
(euf->fcurves[0] == NULL) ? "X" : "",
(euf->fcurves[1] == NULL) ? "Y" : "",
(euf->fcurves[2] == NULL) ? "Z" : "",
(euf->fcurves[0] == nullptr) ? "X" : "",
(euf->fcurves[1] == nullptr) ? "Y" : "",
(euf->fcurves[2] == nullptr) ? "Z" : "",
euf->id->name,
euf->rna_path);
return false;
@@ -1900,7 +1930,7 @@ static bool euler_filter_single_channel(FCurve *fcu)
}
/* Skip baked FCurves. */
if (fcu->bezt == NULL) {
if (fcu->bezt == nullptr) {
return false;
}
@@ -1948,7 +1978,7 @@ static void euler_filter_perform_filter(ListBase /*tEulerFilter*/ *eulers,
for (int channel_index = 0; channel_index < 3; channel_index++) {
FCurve *fcu = euf->fcurves[channel_index];
if (fcu == NULL) {
if (fcu == nullptr) {
continue;
}
++*r_curves_seen;
@@ -1980,8 +2010,9 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
/* Step 1: extract only the rotation f-curves. */
const int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE |
ANIMFILTER_FCURVESONLY | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ListBase anim_data = {NULL, NULL};
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ListBase anim_data = {nullptr, nullptr};
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
int groups = 0;
ListBase eulers = euler_filter_group_channels(&anim_data, op->reports, &groups);
@@ -2036,7 +2067,7 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
}
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
/* Done at last. */
return OPERATOR_FINISHED;
@@ -2081,7 +2112,7 @@ static bool graphkeys_framejump_poll(bContext *C)
static KeyframeEditData sum_selected_keyframes(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
KeyframeEditData ked;
@@ -2092,25 +2123,31 @@ static KeyframeEditData sum_selected_keyframes(bAnimContext *ac)
/* Loop over action data, averaging values. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
short mapping_flag = ANIM_get_normalization_flags(ac);
KeyframeEditData current_ked;
float offset;
float unit_scale = ANIM_unit_mapping_get_factor(
ac->scene, ale->id, ale->key_data, mapping_flag | ANIM_UNITCONV_ONLYKEYS, &offset);
float unit_scale = ANIM_unit_mapping_get_factor(ac->scene,
ale->id,
static_cast<FCurve *>(ale->key_data),
mapping_flag | ANIM_UNITCONV_ONLYKEYS,
&offset);
memset(&current_ked, 0, sizeof(current_ked));
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&current_ked, ale->key_data, NULL, bezt_calc_average, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), 0, 1);
ANIM_fcurve_keyframes_loop(
&current_ked, static_cast<FCurve *>(ale->key_data), nullptr, bezt_calc_average, nullptr);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), 1, 1);
}
else {
ANIM_fcurve_keyframes_loop(&current_ked, ale->key_data, NULL, bezt_calc_average, NULL);
ANIM_fcurve_keyframes_loop(
&current_ked, static_cast<FCurve *>(ale->key_data), nullptr, bezt_calc_average, nullptr);
}
ked.f1 += current_ked.f1;
@@ -2125,7 +2162,7 @@ static KeyframeEditData sum_selected_keyframes(bAnimContext *ac)
}
/* Snap current-frame indicator to 'average time' of selected keyframe. */
static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
static int graphkeys_framejump_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
@@ -2221,21 +2258,22 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
if (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) {
filter |= ANIMFILTER_SEL;
}
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
float closest_frame = next ? FLT_MAX : -FLT_MAX;
bool found = false;
const float current_frame = BKE_scene_frame_get(scene);
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
const FCurve *fcu = ale->key_data;
const FCurve *fcu = static_cast<const FCurve *>(ale->key_data);
if (!fcu->bezt) {
continue;
}
@@ -2279,7 +2317,7 @@ void GRAPH_OT_keyframe_jump(wmOperatorType *ot)
}
/* snap 2D cursor value to the average value of selected keyframe */
static int graphkeys_snap_cursor_value_exec(bContext *C, wmOperator *UNUSED(op))
static int graphkeys_snap_cursor_value_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
@@ -2357,13 +2395,13 @@ static const EnumPropertyItem prop_graphkeys_snap_types[] = {
0,
"Flatten Handles",
"Flatten handles for a smoother transition"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* This function is responsible for snapping keyframes to frame-times. */
static void snap_graph_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
@@ -2375,14 +2413,15 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Init custom data for iterating over keyframes. */
memset(&ked, 0, sizeof(KeyframeEditData));
ked.scene = ac->scene;
if (mode == GRAPHKEYS_SNAP_NEAREST_MARKER) {
ked.list.first = (ac->markers) ? ac->markers->first : NULL;
ked.list.last = (ac->markers) ? ac->markers->last : NULL;
ked.list.first = (ac->markers) ? ac->markers->first : nullptr;
ked.list.last = (ac->markers) ? ac->markers->last : nullptr;
}
else if (mode == GRAPHKEYS_SNAP_VALUE) {
cursor_value = (sipo) ? sipo->cursorVal : 0.0f;
@@ -2402,7 +2441,7 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
/* Snap keyframes. */
const bool use_handle = (sipo->flag & SIPO_NOHANDLES) == 0;
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* Normalize cursor value (for normalized F-Curves display). */
@@ -2410,21 +2449,25 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
short mapping_flag = ANIM_get_normalization_flags(ac);
float offset;
float unit_scale = ANIM_unit_mapping_get_factor(
ac->scene, ale->id, ale->key_data, mapping_flag, &offset);
ac->scene, ale->id, static_cast<FCurve *>(ale->key_data), mapping_flag, &offset);
ked.f1 = (cursor_value / unit_scale) - offset;
}
/* Perform snapping. */
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
BKE_fcurve_merge_duplicate_keys(ale->key_data, BEZT_FLAG_TEMP_TAG, use_handle);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), 0, 0);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), nullptr, edit_cb, BKE_fcurve_handles_recalc);
BKE_fcurve_merge_duplicate_keys(
static_cast<FCurve *>(ale->key_data), BEZT_FLAG_TEMP_TAG, use_handle);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), 1, 0);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
BKE_fcurve_merge_duplicate_keys(ale->key_data, BEZT_FLAG_TEMP_TAG, use_handle);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), nullptr, edit_cb, BKE_fcurve_handles_recalc);
BKE_fcurve_merge_duplicate_keys(
static_cast<FCurve *>(ale->key_data), BEZT_FLAG_TEMP_TAG, use_handle);
}
ale->update |= ANIM_UPDATE_DEFAULT;
@@ -2453,7 +2496,7 @@ static int graphkeys_snap_exec(bContext *C, wmOperator *op)
snap_graph_keys(&ac, mode);
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -2461,22 +2504,23 @@ static int graphkeys_snap_exec(bContext *C, wmOperator *op)
static bool graph_has_selected_control_points(bContext *C)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
/* Get editor data. */
if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
return false;
}
/* Filter data. */
const int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
/* Check if any of the visible and editable f-curves have at least one selected control point. */
bool has_selected_control_points = false;
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
const FCurve *fcu = ale->key_data;
const FCurve *fcu = static_cast<const FCurve *>(ale->key_data);
if (BKE_fcurve_has_selected_control_points(fcu)) {
has_selected_control_points = true;
break;
@@ -2530,7 +2574,7 @@ static const EnumPropertyItem prop_graphkeys_equalize_handles_sides[] = {
{GRAPHKEYS_EQUALIZE_LEFT, "LEFT", 0, "Left", "Equalize selected keyframes' left handles"},
{GRAPHKEYS_EQUALIZE_RIGHT, "RIGHT", 0, "Right", "Equalize selected keyframes' right handles"},
{GRAPHKEYS_EQUALIZE_BOTH, "BOTH", 0, "Both", "Equalize both of a keyframe's handles"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* ------------------- */
@@ -2541,12 +2585,16 @@ static void equalize_graph_keys(bAnimContext *ac, int mode, float handle_length,
/* Filter data. */
const int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ListBase anim_data = {NULL, NULL};
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ListBase anim_data = {nullptr, nullptr};
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Equalize keyframes. */
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
ANIM_fcurve_equalize_keyframes_loop(ale->key_data, mode, handle_length, flatten);
ANIM_fcurve_equalize_keyframes_loop(static_cast<FCurve *>(ale->key_data),
eEditKeyframes_Equalize(mode),
handle_length,
flatten);
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -2571,7 +2619,7 @@ static int graphkeys_equalize_handles_exec(bContext *C, wmOperator *op)
/* Equalize graph keyframes. */
equalize_graph_keys(&ac, mode, handle_length, flatten);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -2650,13 +2698,13 @@ static const EnumPropertyItem prop_graphkeys_mirror_types[] = {
0,
"By Times Over First Selected Marker",
"Flip times of selected keyframes using the first selected marker as the reference point"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* This function is responsible for mirroring keyframes. */
static void mirror_graph_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
@@ -2671,7 +2719,7 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
/* Store mode-specific custom data... */
if (mode == GRAPHKEYS_MIRROR_MARKER) {
TimeMarker *marker = NULL;
TimeMarker *marker = nullptr;
/* Find first selected marker. */
marker = ED_markers_get_first_selected(ac->markers);
@@ -2703,30 +2751,36 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Mirror keyframes. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* Apply unit corrections. */
if (mode == GRAPHKEYS_MIRROR_VALUE) {
short mapping_flag = ANIM_get_normalization_flags(ac);
float offset;
float unit_scale = ANIM_unit_mapping_get_factor(
ac->scene, ale->id, ale->key_data, mapping_flag | ANIM_UNITCONV_ONLYKEYS, &offset);
float unit_scale = ANIM_unit_mapping_get_factor(ac->scene,
ale->id,
static_cast<FCurve *>(ale->key_data),
mapping_flag | ANIM_UNITCONV_ONLYKEYS,
&offset);
ked.f1 = (cursor_value - offset) / unit_scale;
}
/* Perform actual mirroring. */
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), 0, 0);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), nullptr, edit_cb, BKE_fcurve_handles_recalc);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), 1, 0);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), nullptr, edit_cb, BKE_fcurve_handles_recalc);
}
ale->update |= ANIM_UPDATE_DEFAULT;
@@ -2755,7 +2809,7 @@ static int graphkeys_mirror_exec(bContext *C, wmOperator *op)
mirror_graph_keys(&ac, mode);
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -2785,10 +2839,10 @@ void GRAPH_OT_mirror(wmOperatorType *ot)
/** \name Smooth Keyframes Operator
* \{ */
static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op))
static int graphkeys_smooth_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
@@ -2800,15 +2854,16 @@ static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op))
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
/* Smooth keyframes. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
/* For now, we can only smooth by flattening handles AND smoothing curve values.
* Perhaps the mode argument could be removed, as that functionality is offered through
* Snap->Flatten Handles anyway.
*/
smooth_fcurve(ale->key_data);
smooth_fcurve(static_cast<FCurve *>(ale->key_data));
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -2817,7 +2872,7 @@ static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_animdata_freelist(&anim_data);
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -2847,15 +2902,15 @@ void GRAPH_OT_smooth(wmOperatorType *ot)
* \{ */
static const EnumPropertyItem *graph_fmodifier_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;
int i = 0;
if (C == NULL) {
if (C == nullptr) {
return rna_enum_fmodifier_type_items;
}
@@ -2865,7 +2920,7 @@ static const EnumPropertyItem *graph_fmodifier_itemf(bContext *C,
int index;
/* Check if modifier is valid for this context. */
if (fmi == NULL) {
if (fmi == nullptr) {
continue;
}
@@ -2884,7 +2939,7 @@ static const EnumPropertyItem *graph_fmodifier_itemf(bContext *C,
static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
short type;
@@ -2907,10 +2962,11 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
else {
filter |= (ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE);
}
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
/* Add f-modifier to each curve. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
FModifier *fcm;
@@ -2931,7 +2987,7 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
ANIM_animdata_freelist(&anim_data);
/* Set notifier that things have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -3019,13 +3075,9 @@ void GRAPH_OT_fmodifier_copy(wmOperatorType *ot)
/* Flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* Id-props */
/* Id-props */
#if 0
ot->prop = RNA_def_boolean(ot->srna,
"all",
1,
"All F-Modifiers",
"Copy all the F-Modifiers, instead of just the active one");
ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All F-Modifiers", "Copy all the F-Modifiers, instead of just the active one");
#endif
}
@@ -3039,7 +3091,7 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
@@ -3064,10 +3116,11 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op)
ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
}
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
/* Paste modifiers. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
int tot;
@@ -3087,7 +3140,7 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op)
/* Successful or not? */
if (ok) {
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -3137,7 +3190,7 @@ static int graph_driver_vars_copy_exec(bContext *C, wmOperator *op)
PointerRNA ptr = CTX_data_pointer_get_type(C, "active_editable_fcurve", &RNA_FCurve);
/* If this exists, call the copy driver vars API function. */
FCurve *fcu = ptr.data;
FCurve *fcu = static_cast<FCurve *>(ptr.data);
if (fcu) {
ok = ANIM_driver_vars_copy(op->reports, fcu);
@@ -3179,7 +3232,7 @@ static int graph_driver_vars_paste_exec(bContext *C, wmOperator *op)
PointerRNA ptr = CTX_data_pointer_get_type(C, "active_editable_fcurve", &RNA_FCurve);
/* If this exists, call the paste driver vars API function. */
FCurve *fcu = ptr.data;
FCurve *fcu = static_cast<FCurve *>(ptr.data);
if (fcu) {
ok = ANIM_driver_vars_paste(op->reports, fcu, replace);
@@ -3230,7 +3283,7 @@ void GRAPH_OT_driver_variables_paste(wmOperatorType *ot)
static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
bool ok = false;
@@ -3246,12 +3299,13 @@ static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op)
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
/* Find invalid drivers. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
if (ELEM(NULL, fcu, fcu->driver)) {
if (ELEM(nullptr, fcu, fcu->driver)) {
continue;
}
if (!(fcu->driver->flag & DRIVER_FLAG_INVALID)) {
@@ -3271,7 +3325,7 @@ static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op)
if (deleted > 0) {
/* Notify the world of any changes. */
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, nullptr);
WM_reportf(RPT_INFO, "Deleted %u drivers", deleted);
}
else {
@@ -3292,7 +3346,7 @@ static bool graph_driver_delete_invalid_poll(bContext *C)
ScrArea *area = CTX_wm_area(C);
/* Firstly, check if in Graph Editor. */
if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) {
if ((area == nullptr) || (area->spacetype != SPACE_GRAPH)) {
return false;
}

View File

@@ -15,6 +15,10 @@ struct bAnimContext;
struct bAnimListElem;
struct bContext;
#ifdef __cplusplus
extern "C" {
#endif
/* internal exports only */
/* ***************************************** */
@@ -231,3 +235,7 @@ bool graphop_selected_fcurve_poll(struct bContext *C);
void graphedit_keymap(struct wmKeyConfig *keyconf);
void graphedit_operatortypes(void);
#ifdef __cplusplus
}
#endif

View File

@@ -116,7 +116,7 @@ static void graphview_cursor_setprops(bContext *C, wmOperator *op, const wmEvent
float viewx, viewy;
/* abort if not active region (should not really be possible) */
if (region == NULL) {
if (region == nullptr) {
return;
}
@@ -221,8 +221,8 @@ static void GRAPH_OT_cursor_set(wmOperatorType *ot)
static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ListBase all_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
ListBase all_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
const bool unselected = RNA_boolean_get(op->ptr, "unselected");
@@ -237,7 +237,8 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FCURVESONLY | ANIMFILTER_LIST_CHANNELS |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &all_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
/* filter data
* - of the remaining visible curves, we want to hide the ones that are
@@ -252,9 +253,10 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
filter |= ANIMFILTER_SEL;
}
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
/* hack: skip object channels for now, since flushing those will always flush everything,
* but they are always included */
/* TODO: find out why this is the case, and fix that */
@@ -282,9 +284,10 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
ANIMFILTER_FCURVESONLY;
/* flushing has been done */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
/* hack: skip object channels for now, since flushing those
* will always flush everything, but they are always included */
@@ -305,7 +308,7 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
}
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -334,8 +337,8 @@ static void GRAPH_OT_hide(wmOperatorType *ot)
static int graphview_curves_reveal_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ListBase all_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
ListBase all_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
const bool select = RNA_boolean_get(op->ptr, "select");
@@ -350,16 +353,18 @@ static int graphview_curves_reveal_exec(bContext *C, wmOperator *op)
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &all_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
/* filter data
* - just go through all visible channels, ensuring that everything is set to be curve-visible
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS |
ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
/* hack: skip object channels for now, since flushing those will always flush everything,
* but they are always included. */
/* TODO: find out why this is the case, and fix that */
@@ -379,7 +384,8 @@ static int graphview_curves_reveal_exec(bContext *C, wmOperator *op)
ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD);
/* now, also flush selection status up/down as appropriate */
ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, true);
ANIM_flush_setting_anim_channels(
&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, eAnimChannels_SetFlag(true));
}
/* cleanup */
@@ -387,7 +393,7 @@ static int graphview_curves_reveal_exec(bContext *C, wmOperator *op)
BLI_freelistN(&all_data);
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}

View File

@@ -47,7 +47,7 @@
* \{ */
/* temp info for caching handle vertices close */
typedef struct tNearestVertInfo {
struct tNearestVertInfo {
struct tNearestVertInfo *next, *prev;
FCurve *fcu; /* F-Curve that keyframe comes from */
@@ -62,14 +62,14 @@ typedef struct tNearestVertInfo {
eAnim_ChannelType ctype; /* type of animation channel this FCurve comes from */
float frame; /* frame that point was on when it matched (global time) */
} tNearestVertInfo;
};
/* Tags for the type of graph vert that we have */
typedef enum eGraphVertIndex {
enum eGraphVertIndex {
NEAREST_HANDLE_LEFT = -1,
NEAREST_HANDLE_KEY,
NEAREST_HANDLE_RIGHT,
} eGraphVertIndex;
};
/* Tolerance for absolute radius (in pixels) of the vert from the cursor to use */
/* TODO: perhaps this should depend a bit on the size that the user set the vertices to be? */
@@ -131,7 +131,8 @@ static void nearest_fcurve_vert_store(ListBase *matches,
}
/* add new if not replacing... */
if (replace == 0) {
nvi = MEM_callocN(sizeof(tNearestVertInfo), "Nearest Graph Vert Info - Bezt");
nvi = static_cast<tNearestVertInfo *>(
MEM_callocN(sizeof(tNearestVertInfo), "Nearest Graph Vert Info - Bezt"));
}
/* store values */
@@ -161,7 +162,7 @@ static void nearest_fcurve_vert_store(ListBase *matches,
/* helper for find_nearest_fcurve_vert() - build the list of nearest matches */
static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], ListBase *matches)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
@@ -180,9 +181,10 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
filter |= ANIMFILTER_SEL;
}
mapping_flag |= ANIM_get_normalization_flags(ac);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
float offset;
@@ -191,11 +193,11 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
/* apply NLA mapping to all the keyframes */
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), 0, 0);
}
if (fcu->bezt) {
BezTriple *bezt1 = fcu->bezt, *prevbezt = NULL;
BezTriple *bezt1 = fcu->bezt, *prevbezt = nullptr;
int i;
for (i = 0; i < fcu->totvert; i++, prevbezt = bezt1, bezt1++) {
@@ -203,9 +205,9 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
nearest_fcurve_vert_store(matches,
v2d,
fcu,
ale->type,
eAnim_ChannelType(ale->type),
bezt1,
NULL,
nullptr,
NEAREST_HANDLE_KEY,
mval,
unit_scale,
@@ -219,9 +221,9 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
nearest_fcurve_vert_store(matches,
v2d,
fcu,
ale->type,
eAnim_ChannelType(ale->type),
bezt1,
NULL,
nullptr,
NEAREST_HANDLE_LEFT,
mval,
unit_scale,
@@ -233,9 +235,9 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
nearest_fcurve_vert_store(matches,
v2d,
fcu,
ale->type,
eAnim_ChannelType(ale->type),
bezt1,
NULL,
nullptr,
NEAREST_HANDLE_RIGHT,
mval,
unit_scale,
@@ -250,7 +252,7 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
/* un-apply NLA mapping from all the keyframes */
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), 1, 0);
}
}
@@ -263,13 +265,13 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
{
/* abort if list is empty */
if (BLI_listbase_is_empty(matches)) {
return NULL;
return nullptr;
}
/* if list only has 1 item, remove it from the list and return */
if (BLI_listbase_is_single(matches)) {
/* need to remove from the list, otherwise it gets freed and then we can't return it */
return BLI_pophead(matches);
return static_cast<tNearestVertInfo *>(BLI_pophead(matches));
}
/* The goal of the remaining code below is to prioritize selecting verts on
@@ -279,7 +281,7 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
/* Try to find the first selected vert in `matches`. Additionally, if
* one exists, rotate `matches` to put it last in the list and the vert
* following it first, since that's the order we'll want to scan in. */
tNearestVertInfo *nvi_first_selected = NULL;
tNearestVertInfo *nvi_first_selected = nullptr;
LISTBASE_FOREACH (tNearestVertInfo *, nvi, matches) {
if (nvi->sel) {
nvi_first_selected = nvi;
@@ -290,7 +292,7 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
/* Try to find the next vert that's on the active fcurve, falling back
* to the next vert on any selected fcurve if that's not found. */
tNearestVertInfo *nvi_to_select = NULL;
tNearestVertInfo *nvi_to_select = nullptr;
LISTBASE_FOREACH (tNearestVertInfo *, nvi, matches) {
if (nvi == nvi_first_selected) {
continue;
@@ -315,7 +317,7 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
/* If we're still here, that means we didn't find any verts on selected
* fcurves. So return the head (which is also the item following
* `nvi_first_selected` if that was found). */
return BLI_pophead(matches);
return static_cast<tNearestVertInfo *>(BLI_pophead(matches));
}
/**
@@ -326,7 +328,7 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
*/
static tNearestVertInfo *find_nearest_fcurve_vert(bAnimContext *ac, const int mval[2])
{
ListBase matches = {NULL, NULL};
ListBase matches = {nullptr, nullptr};
tNearestVertInfo *nvi;
/* step 1: get the nearest verts */
@@ -354,11 +356,11 @@ static tNearestVertInfo *find_nearest_fcurve_vert(bAnimContext *ac, const int mv
void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channels)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
KeyframeEditFunc test_cb, sel_cb;
/* determine type-based settings */
@@ -366,15 +368,18 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel
ANIMFILTER_NODUPLIS);
/* filter data */
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* init BezTriple looping data */
test_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
/* See if we should be selecting or deselecting */
if (test) {
for (ale = anim_data.first; ale; ale = ale->next) {
if (ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, test_cb, NULL)) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
if (ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), nullptr, test_cb, nullptr))
{
sel = SELECT_SUBTRACT;
break;
}
@@ -385,11 +390,12 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel
sel_cb = ANIM_editkeyframes_select(sel);
/* Now set the flags */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
/* Keyframes First */
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), nullptr, sel_cb, nullptr);
/* affect channel selection status? */
if (do_channels) {
@@ -421,7 +427,7 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel
static int graphkeys_deselectall_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
bAnimListElem *ale_active = NULL;
bAnimListElem *ale_active = nullptr;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@@ -464,11 +470,11 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op)
fcu->flag |= (FCURVE_SELECTED | FCURVE_ACTIVE);
MEM_freeN(ale_active);
ale_active = NULL;
ale_active = nullptr;
}
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
@@ -529,8 +535,9 @@ static int initialize_animdata_selection_filter(void)
static ListBase initialize_box_select_anim_data(const int filter, bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ListBase anim_data = {nullptr, nullptr};
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
return anim_data;
}
@@ -545,13 +552,13 @@ static void initialize_box_select_key_editing_data(const bool incl_handles,
memset(r_ked, 0, sizeof(KeyframeEditData));
switch (mode) {
case BEZT_OK_REGION_LASSO: {
KeyframeEdit_LassoData *data_lasso = data;
KeyframeEdit_LassoData *data_lasso = static_cast<KeyframeEdit_LassoData *>(data);
data_lasso->rectf_scaled = scaled_rectf;
r_ked->data = data_lasso;
break;
}
case BEZT_OK_REGION_CIRCLE: {
KeyframeEdit_CircleData *data_circle = data;
KeyframeEdit_CircleData *data_circle = static_cast<KeyframeEdit_CircleData *>(data);
data_circle->rectf_scaled = scaled_rectf;
r_ked->data = data_circle;
break;
@@ -607,13 +614,13 @@ static bool box_select_graphkeys(bAnimContext *ac,
const KeyframeEditFunc ok_cb = ANIM_editkeyframes_ok(mode);
/* Try selecting the keyframes. */
bAnimListElem *ale = NULL;
bAnimListElem *ale = nullptr;
/* This variable will be set to true if any key is selected or deselected. */
bool any_key_selection_changed = false;
/* First loop over data, doing box select. try selecting keys only. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcu = (FCurve *)ale->key_data;
float offset;
@@ -624,7 +631,8 @@ static bool box_select_graphkeys(bAnimContext *ac,
* guess when a callback might use something different.
*/
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles == 0);
ANIM_nla_mapping_apply_fcurve(
adt, static_cast<FCurve *>(ale->key_data), 0, incl_handles == 0);
}
scaled_rectf.xmin = rectf.xmin;
@@ -646,9 +654,9 @@ static bool box_select_graphkeys(bAnimContext *ac,
}
/* Firstly, check if any keyframes will be hit by this. */
if (ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, ok_cb, NULL)) {
if (ANIM_fcurve_keyframes_loop(&ked, fcu, nullptr, ok_cb, nullptr)) {
/* select keyframes that are in the appropriate places */
ANIM_fcurve_keyframes_loop(&ked, fcu, ok_cb, select_cb, NULL);
ANIM_fcurve_keyframes_loop(&ked, fcu, ok_cb, select_cb, nullptr);
any_key_selection_changed = true;
/* Only change selection of channel when the visibility of keyframes
* doesn't depend on this. */
@@ -662,7 +670,8 @@ static bool box_select_graphkeys(bAnimContext *ac,
/* Un-apply NLA mapping from all the keyframes. */
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles == 0);
ANIM_nla_mapping_apply_fcurve(
adt, static_cast<FCurve *>(ale->key_data), 1, incl_handles == 0);
}
}
@@ -676,7 +685,7 @@ static bool box_select_graphkeys(bAnimContext *ac,
* This function is used to set all the keyframes of a given curve as selectable
* by the "select_cb" function inside of "box_select_graphcurves".
*/
static short ok_bezier_always_ok(KeyframeEditData *UNUSED(ked), BezTriple *UNUSED(bezt))
static short ok_bezier_always_ok(KeyframeEditData * /*ked*/, BezTriple * /*bezt*/)
{
return KEYFRAME_OK_KEY | KEYFRAME_OK_H1 | KEYFRAME_OK_H2;
}
@@ -760,7 +769,7 @@ static void box_select_graphcurves(bAnimContext *ac,
initialize_box_select_key_editing_data(
incl_handles, mode, ac, data, &scaled_rectf, &ked, &mapping_flag);
FCurve *last_selected_curve = NULL;
FCurve *last_selected_curve = nullptr;
/* Go through all the curves and try selecting them. This function is only called
* if no keyframe is in the selection area, so we only have to check if the curve
@@ -795,14 +804,18 @@ static void box_select_graphcurves(bAnimContext *ac,
else {
fcu->flag &= ~FCURVE_SELECTED;
}
ANIM_fcurve_keyframes_loop(&ked, fcu, ok_bezier_always_ok, select_cb, NULL);
ANIM_fcurve_keyframes_loop(&ked, fcu, ok_bezier_always_ok, select_cb, nullptr);
}
}
/* Make sure that one of the selected curves is active in the end. */
if (last_selected_curve != NULL) {
ANIM_set_active_channel(
ac, ac->data, ac->datatype, filter, last_selected_curve, ANIMTYPE_FCURVE);
if (last_selected_curve != nullptr) {
ANIM_set_active_channel(ac,
ac->data,
eAnimCont_Types(ac->datatype),
eAnimFilter_Flags(filter),
last_selected_curve,
ANIMTYPE_FCURVE);
}
ANIM_animdata_freelist(&anim_data);
@@ -821,7 +834,7 @@ static int graphkeys_box_select_invoke(bContext *C, wmOperator *op, const wmEven
int mval[2];
WM_event_drag_start_mval(event, ac.region, mval);
tNearestVertInfo *under_mouse = find_nearest_fcurve_vert(&ac, mval);
bool mouse_is_over_element = under_mouse != NULL;
bool mouse_is_over_element = under_mouse != nullptr;
if (under_mouse) {
MEM_freeN(under_mouse);
}
@@ -846,7 +859,7 @@ static int graphkeys_box_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
const int selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
deselect_graph_keys(&ac, 1, SELECT_SUBTRACT, true);
@@ -882,13 +895,13 @@ static int graphkeys_box_select_exec(bContext *C, wmOperator *op)
/* Apply box_select action. */
const bool any_key_selection_changed = box_select_graphkeys(
&ac, &rect_fl, mode, selectmode, incl_handles, NULL);
&ac, &rect_fl, mode, selectmode, incl_handles, nullptr);
const bool use_curve_selection = RNA_boolean_get(op->ptr, "use_curve_selection");
if (use_curve_selection && !any_key_selection_changed) {
box_select_graphcurves(&ac, &rect_fl, mode, selectmode, incl_handles, NULL);
box_select_graphcurves(&ac, &rect_fl, mode, selectmode, incl_handles, nullptr);
}
/* Send notifier that keyframe selection has changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
@@ -958,11 +971,11 @@ static int graphkeys_lassoselect_exec(bContext *C, wmOperator *op)
data_lasso.rectf_view = &rect_fl;
data_lasso.mcoords = WM_gesture_lasso_path_to_array(C, op, &data_lasso.mcoords_len);
if (data_lasso.mcoords == NULL) {
if (data_lasso.mcoords == nullptr) {
return OPERATOR_CANCELLED;
}
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
const short selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
deselect_graph_keys(&ac, 0, SELECT_SUBTRACT, true);
@@ -994,7 +1007,7 @@ static int graphkeys_lassoselect_exec(bContext *C, wmOperator *op)
MEM_freeN((void *)data_lasso.mcoords);
/* Send notifier that keyframe selection has changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1047,8 +1060,9 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
const eSelectOp sel_op = ED_select_op_modal(RNA_enum_get(op->ptr, "mode"),
WM_gesture_is_modal_first(op->customdata));
const eSelectOp sel_op = ED_select_op_modal(
eSelectOp(RNA_enum_get(op->ptr, "mode")),
WM_gesture_is_modal_first(static_cast<const wmGesture *>(op->customdata)));
const short selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
deselect_graph_keys(&ac, 0, SELECT_SUBTRACT, true);
@@ -1089,7 +1103,7 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op)
}
/* Send notifier that keyframe selection has changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1144,7 +1158,7 @@ static const EnumPropertyItem prop_column_select_types[] = {
0,
"Between Min/Max Selected Markers",
""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* ------------------- */
@@ -1154,12 +1168,12 @@ static const EnumPropertyItem prop_column_select_types[] = {
* action_select.c should de-duplicate. */
static void markers_selectkeys_between(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
KeyframeEditFunc ok_cb, select_cb;
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
float min, max;
/* get extreme markers */
@@ -1177,19 +1191,22 @@ static void markers_selectkeys_between(bAnimContext *ac)
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* select keys in-between */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), 0, 1);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), ok_cb, select_cb, nullptr);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), 1, 1);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), ok_cb, select_cb, nullptr);
}
}
@@ -1200,7 +1217,7 @@ static void markers_selectkeys_between(bAnimContext *ac)
/* Selects all visible keyframes in the same frames as the specified elements */
static void columnselect_graph_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
@@ -1217,10 +1234,12 @@ static void columnselect_graph_keys(bAnimContext *ac, short mode)
case GRAPHKEYS_COLUMNSEL_KEYS: /* list of selected keys */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL);
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), nullptr, bezt_to_cfraelem, nullptr);
}
ANIM_animdata_freelist(&anim_data);
@@ -1228,7 +1247,7 @@ static void columnselect_graph_keys(bAnimContext *ac, short mode)
case GRAPHKEYS_COLUMNSEL_CFRA: /* current frame */
/* make a single CfraElem for storing this */
ce = MEM_callocN(sizeof(CfraElem), "cfraElem");
ce = static_cast<CfraElem *>(MEM_callocN(sizeof(CfraElem), "cfraElem"));
BLI_addtail(&ked.list, ce);
ce->cfra = (float)scene->r.cfra;
@@ -1251,20 +1270,22 @@ static void columnselect_graph_keys(bAnimContext *ac, short mode)
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* loop over cfraelems (stored in the KeyframeEditData->list)
* - we need to do this here, as we can apply fewer NLA-mapping conversions
*/
for (ce = ked.list.first; ce; ce = ce->next) {
for (ce = static_cast<CfraElem *>(ked.list.first); ce; ce = ce->next) {
/* set frame for validation callback to refer to */
ked.f1 = BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP);
/* select elements with frame number matching cfraelem */
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), ok_cb, select_cb, nullptr);
}
}
@@ -1296,7 +1317,7 @@ static int graphkeys_columnselect_exec(bContext *C, wmOperator *op)
}
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1326,11 +1347,11 @@ void GRAPH_OT_select_column(wmOperatorType *ot)
/** \name Select Linked Operator
* \{ */
static int graphkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
static int graphkeys_select_linked_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
@@ -1345,15 +1366,16 @@ static int graphkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
/* loop through all of the keys and select additional keyframes based on these */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
/* check if anything selected? */
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) {
if (ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, ok_cb, nullptr)) {
/* select every keyframe in this curve then */
ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL);
ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, sel_cb, nullptr);
}
}
@@ -1361,7 +1383,7 @@ static int graphkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_animdata_freelist(&anim_data);
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1390,7 +1412,7 @@ void GRAPH_OT_select_linked(wmOperatorType *ot)
/* Common code to perform selection */
static void select_moreless_graph_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
@@ -1404,26 +1426,27 @@ static void select_moreless_graph_keys(bAnimContext *ac, short mode)
/* loop through all of the keys and select additional keyframes based on these */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
/* only continue if F-Curve has keyframes */
if (fcu->bezt == NULL) {
if (fcu->bezt == nullptr) {
continue;
}
/* build up map of whether F-Curve's keyframes should be selected or not */
ked.data = MEM_callocN(fcu->totvert, "selmap graphEdit");
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, build_cb, NULL);
ANIM_fcurve_keyframes_loop(&ked, fcu, nullptr, build_cb, nullptr);
/* based on this map, adjust the selection status of the keyframes */
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, bezt_selmap_flush, NULL);
ANIM_fcurve_keyframes_loop(&ked, fcu, nullptr, bezt_selmap_flush, nullptr);
/* free the selmap used here */
MEM_freeN(ked.data);
ked.data = NULL;
ked.data = nullptr;
}
/* Cleanup */
@@ -1432,7 +1455,7 @@ static void select_moreless_graph_keys(bAnimContext *ac, short mode)
/* ----------------- */
static int graphkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op))
static int graphkeys_select_more_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
@@ -1445,7 +1468,7 @@ static int graphkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op))
select_moreless_graph_keys(&ac, SELMAP_MORE);
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1467,7 +1490,7 @@ void GRAPH_OT_select_more(wmOperatorType *ot)
/* ----------------- */
static int graphkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op))
static int graphkeys_select_less_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
@@ -1480,7 +1503,7 @@ static int graphkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op))
select_moreless_graph_keys(&ac, SELMAP_LESS);
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1513,19 +1536,19 @@ static const EnumPropertyItem prop_graphkeys_leftright_select_types[] = {
{GRAPHKEYS_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""},
{GRAPHKEYS_LRSEL_LEFT, "LEFT", 0, "Before Current Frame", ""},
{GRAPHKEYS_LRSEL_RIGHT, "RIGHT", 0, "After Current Frame", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* --------------------------------- */
static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short select_mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
KeyframeEditFunc ok_cb, select_cb;
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
Scene *scene = ac->scene;
/* if select mode is replace, deselect all keyframes (and channels) first */
@@ -1553,19 +1576,22 @@ static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* select keys */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), 0, 1);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), ok_cb, select_cb, nullptr);
ANIM_nla_mapping_apply_fcurve(adt, static_cast<FCurve *>(ale->key_data), 1, 1);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), ok_cb, select_cb, nullptr);
}
}
@@ -1603,8 +1629,8 @@ static int graphkeys_select_leftright_exec(bContext *C, wmOperator *op)
graphkeys_select_leftright(&ac, leftright, selectmode);
/* set notifier that keyframe selection (and channels too) have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
@@ -1690,7 +1716,7 @@ static int mouse_graph_keys(bAnimContext *ac,
{
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
tNearestVertInfo *nvi;
BezTriple *bezt = NULL;
BezTriple *bezt = nullptr;
bool run_modal = false;
/* find the beztriple that we're selecting, and the handle that was clicked on */
@@ -1706,9 +1732,9 @@ static int mouse_graph_keys(bAnimContext *ac,
SIPO_RUNTIME_FLAG_TWEAK_HANDLES_RIGHT);
const bool already_selected =
(nvi != NULL) && (((nvi->hpoint == NEAREST_HANDLE_KEY) && (nvi->bezt->f2 & SELECT)) ||
((nvi->hpoint == NEAREST_HANDLE_LEFT) && (nvi->bezt->f1 & SELECT)) ||
((nvi->hpoint == NEAREST_HANDLE_RIGHT) && (nvi->bezt->f3 & SELECT)));
(nvi != nullptr) && (((nvi->hpoint == NEAREST_HANDLE_KEY) && (nvi->bezt->f2 & SELECT)) ||
((nvi->hpoint == NEAREST_HANDLE_LEFT) && (nvi->bezt->f1 & SELECT)) ||
((nvi->hpoint == NEAREST_HANDLE_RIGHT) && (nvi->bezt->f3 & SELECT)));
if (wait_to_deselect_others && nvi && already_selected) {
run_modal = true;
@@ -1716,7 +1742,7 @@ static int mouse_graph_keys(bAnimContext *ac,
/* For replacing selection, if we have something to select, we have to clear existing selection.
* The same goes if we found nothing to select, and deselect_all is true
* (deselect on nothing behavior). */
else if ((nvi != NULL && select_mode == SELECT_REPLACE) || (nvi == NULL && deselect_all)) {
else if ((nvi != nullptr && select_mode == SELECT_REPLACE) || (nvi == nullptr && deselect_all)) {
/* reset selection mode */
select_mode = SELECT_ADD;
@@ -1730,7 +1756,7 @@ static int mouse_graph_keys(bAnimContext *ac,
}
}
if (nvi == NULL) {
if (nvi == nullptr) {
return deselect_all ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -1794,7 +1820,7 @@ static int mouse_graph_keys(bAnimContext *ac,
select_cb = ANIM_editkeyframes_select(select_mode);
/* select all keyframes */
ANIM_fcurve_keyframes_loop(&ked, nvi->fcu, NULL, select_cb, NULL);
ANIM_fcurve_keyframes_loop(&ked, nvi->fcu, nullptr, select_cb, nullptr);
}
/* only change selection of channel when the visibility of keyframes doesn't depend on this */
@@ -1830,7 +1856,12 @@ static int mouse_graph_keys(bAnimContext *ac,
/* NOTE: Sync the filter flags with findnearest_fcurve_vert. */
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nvi->fcu, nvi->ctype);
ANIM_set_active_channel(ac,
ac->data,
eAnimCont_Types(ac->datatype),
eAnimFilter_Flags(filter),
nvi->fcu,
nvi->ctype);
}
if (nvi->hpoint == NEAREST_HANDLE_LEFT) {
@@ -1856,7 +1887,7 @@ static int graphkeys_mselect_column(bAnimContext *ac,
eEditKeyframes_Select select_mode,
bool wait_to_deselect_others)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
bool run_modal = false;
@@ -1869,7 +1900,7 @@ static int graphkeys_mselect_column(bAnimContext *ac,
nvi = find_nearest_fcurve_vert(ac, mval);
/* check if anything to select */
if (nvi == NULL) {
if (nvi == nullptr) {
return OPERATOR_CANCELLED;
}
@@ -1907,9 +1938,10 @@ static int graphkeys_mselect_column(bAnimContext *ac,
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* set frame for validation callback to refer to */
@@ -1921,7 +1953,8 @@ static int graphkeys_mselect_column(bAnimContext *ac,
}
/* select elements with frame number matching cfra */
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), ok_cb, select_cb, nullptr);
}
/* free elements */
@@ -1962,22 +1995,28 @@ static int graphkeys_clickselect_exec(bContext *C, wmOperator *op)
/* figure out action to take */
if (RNA_boolean_get(op->ptr, "column")) {
/* select all keyframes in the same frame as the one that was under the mouse */
ret_val = graphkeys_mselect_column(&ac, mval, selectmode, wait_to_deselect_others);
ret_val = graphkeys_mselect_column(
&ac, mval, eEditKeyframes_Select(selectmode), wait_to_deselect_others);
}
else if (RNA_boolean_get(op->ptr, "curves")) {
/* select all keyframes in the same F-Curve as the one under the mouse */
ret_val = mouse_graph_keys(&ac, mval, selectmode, deselect_all, true, wait_to_deselect_others);
ret_val = mouse_graph_keys(
&ac, mval, eEditKeyframes_Select(selectmode), deselect_all, true, wait_to_deselect_others);
}
else {
/* select keyframe under mouse */
ret_val = mouse_graph_keys(
&ac, mval, selectmode, deselect_all, false, wait_to_deselect_others);
ret_val = mouse_graph_keys(&ac,
mval,
eEditKeyframes_Select(selectmode),
deselect_all,
false,
wait_to_deselect_others);
}
/* set notifier that keyframe selection (and also channel selection in some cases) has
* changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, nullptr);
/* for tweak grab to work */
return ret_val | OPERATOR_PASS_THROUGH;

View File

@@ -53,7 +53,7 @@
ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS)
/* This data type is only used for modal operation. */
typedef struct tGraphSliderOp {
struct tGraphSliderOp {
bAnimContext ac;
Scene *scene;
ScrArea *area;
@@ -75,12 +75,12 @@ typedef struct tGraphSliderOp {
void (*free_operator_data)(void *operator_data);
NumInput num;
} tGraphSliderOp;
};
typedef struct tBeztCopyData {
struct tBeztCopyData {
int tot_vert;
BezTriple *bezt;
} tBeztCopyData;
};
/** \} */
@@ -98,9 +98,10 @@ static void apply_fcu_segment_function(bAnimContext *ac,
FCurveSegment *segment,
const float factor))
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, eAnimCont_Types(ac->datatype));
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
FCurve *fcu = (FCurve *)ale->key_data;
ListBase segments = find_fcurve_segments(fcu);
@@ -147,34 +148,36 @@ static void common_draw_status_header(bContext *C, tGraphSliderOp *gso, const ch
*/
static void store_original_bezt_arrays(tGraphSliderOp *gso)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimContext *ac = &gso->ac;
bAnimListElem *ale;
ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, eAnimCont_Types(ac->datatype));
/* Loop through filtered data and copy the curves. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
if (fcu->bezt == NULL) {
if (fcu->bezt == nullptr) {
/* This curve is baked, skip it. */
continue;
}
const int arr_size = sizeof(BezTriple) * fcu->totvert;
tBeztCopyData *copy = MEM_mallocN(sizeof(tBeztCopyData), "bezts_copy");
BezTriple *bezts_copy = MEM_mallocN(arr_size, "bezts_copy_array");
tBeztCopyData *copy = static_cast<tBeztCopyData *>(
MEM_mallocN(sizeof(tBeztCopyData), "bezts_copy"));
BezTriple *bezts_copy = static_cast<BezTriple *>(MEM_mallocN(arr_size, "bezts_copy_array"));
copy->tot_vert = fcu->totvert;
memcpy(bezts_copy, fcu->bezt, arr_size);
copy->bezt = bezts_copy;
LinkData *link = NULL;
LinkData *link = nullptr;
link = MEM_callocN(sizeof(LinkData), "Bezt Link");
link = static_cast<LinkData *>(MEM_callocN(sizeof(LinkData), "Bezt Link"));
link->data = copy;
BLI_addtail(&gso->bezt_arr_list, link);
@@ -186,31 +189,36 @@ static void store_original_bezt_arrays(tGraphSliderOp *gso)
/* Overwrite the current bezts arrays with the original data. */
static void reset_bezts(tGraphSliderOp *gso)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
LinkData *link_bezt;
bAnimListElem *ale;
bAnimContext *ac = &gso->ac;
/* Filter data. */
ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, eAnimCont_Types(ac->datatype));
/* Loop through filtered data and reset bezts. */
for (ale = anim_data.first, link_bezt = gso->bezt_arr_list.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first),
link_bezt = static_cast<LinkData *>(gso->bezt_arr_list.first);
ale;
ale = ale->next)
{
FCurve *fcu = (FCurve *)ale->key_data;
if (fcu->bezt == NULL) {
if (fcu->bezt == nullptr) {
/* This curve is baked, skip it. */
continue;
}
tBeztCopyData *data = link_bezt->data;
tBeztCopyData *data = static_cast<tBeztCopyData *>(link_bezt->data);
const int arr_size = sizeof(BezTriple) * data->tot_vert;
MEM_freeN(fcu->bezt);
fcu->bezt = MEM_mallocN(arr_size, __func__);
fcu->bezt = static_cast<BezTriple *>(MEM_mallocN(arr_size, __func__));
fcu->totvert = data->tot_vert;
memcpy(fcu->bezt, data->bezt, arr_size);
@@ -227,7 +235,7 @@ static void reset_bezts(tGraphSliderOp *gso)
*/
static float slider_factor_get_and_remember(wmOperator *op)
{
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
const float factor = ED_slider_factor_get(gso->slider);
RNA_property_float_set(op->ptr, gso->factor_prop, factor);
return factor;
@@ -241,15 +249,15 @@ static float slider_factor_get_and_remember(wmOperator *op)
static void graph_slider_exit(bContext *C, wmOperator *op)
{
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
wmWindow *win = CTX_wm_window(C);
/* If data exists, clear its data and exit. */
if (gso == NULL) {
if (gso == nullptr) {
return;
}
if (gso->free_operator_data != NULL) {
if (gso->free_operator_data != nullptr) {
gso->free_operator_data(gso->operator_data);
}
@@ -258,8 +266,9 @@ static void graph_slider_exit(bContext *C, wmOperator *op)
ED_slider_destroy(C, gso->slider);
for (link = gso->bezt_arr_list.first; link != NULL; link = link->next) {
tBeztCopyData *copy = link->data;
for (link = static_cast<LinkData *>(gso->bezt_arr_list.first); link != nullptr;
link = link->next) {
tBeztCopyData *copy = static_cast<tBeztCopyData *>(link->data);
MEM_freeN(copy->bezt);
MEM_freeN(link->data);
}
@@ -269,15 +278,15 @@ static void graph_slider_exit(bContext *C, wmOperator *op)
/* Return to normal cursor and header status. */
WM_cursor_modal_restore(win);
ED_area_status_text(area, NULL);
ED_area_status_text(area, nullptr);
/* cleanup */
op->customdata = NULL;
op->customdata = nullptr;
}
static int graph_slider_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
const bool has_numinput = hasNumInput(&gso->num);
@@ -302,7 +311,7 @@ static int graph_slider_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->val == KM_PRESS) {
reset_bezts(gso);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
graph_slider_exit(C, op);
@@ -355,7 +364,8 @@ static int graph_slider_invoke(bContext *C, wmOperator *op, const wmEvent *event
WM_cursor_modal_set(CTX_wm_window(C), WM_CURSOR_EW_SCROLL);
/* Init slide-op data. */
gso = op->customdata = MEM_callocN(sizeof(tGraphSliderOp), "tGraphSliderOp");
gso = static_cast<tGraphSliderOp *>(
op->customdata = MEM_callocN(sizeof(tGraphSliderOp), "tGraphSliderOp"));
/* Get editor data. */
if (ANIM_animdata_get_context(C, &gso->ac) == 0) {
@@ -372,7 +382,7 @@ static int graph_slider_invoke(bContext *C, wmOperator *op, const wmEvent *event
gso->slider = ED_slider_create(C);
ED_slider_init(gso->slider, event);
if (gso->bezt_arr_list.first == NULL) {
if (gso->bezt_arr_list.first == nullptr) {
WM_report(RPT_ERROR, "Cannot find keys to operate on");
graph_slider_exit(C, op);
return OPERATOR_CANCELLED;
@@ -388,21 +398,22 @@ static int graph_slider_invoke(bContext *C, wmOperator *op, const wmEvent *event
/** \name Decimate Keyframes Operator
* \{ */
typedef enum tDecimModes {
enum tDecimModes {
DECIM_RATIO = 1,
DECIM_ERROR,
} tDecimModes;
};
static void decimate_graph_keys(bAnimContext *ac, float factor, float error_sq_max)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
/* Filter data. */
ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, eAnimCont_Types(ac->datatype));
/* Loop through filtered data and clean curves. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
if (!decimate_fcurve(ale, factor, error_sq_max)) {
/* The selection contains unsupported keyframe types! */
WM_report(RPT_WARNING, "Decimate: Skipping non linear/bezier keyframes!");
@@ -444,7 +455,7 @@ static void decimate_modal_update(bContext *C, wmOperator *op)
{
/* Perform decimate updates - in response to some user action
* (e.g. pressing a key or moving the mouse). */
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
decimate_draw_status(C, gso);
@@ -456,7 +467,7 @@ static void decimate_modal_update(bContext *C, wmOperator *op)
/* We don't want to limit the decimation to a certain error margin. */
const float error_sq_max = FLT_MAX;
decimate_graph_keys(&gso->ac, factor, error_sq_max);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
}
static int decimate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -467,7 +478,7 @@ static int decimate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
}
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
gso->modal_update = decimate_modal_update;
ED_slider_allow_overshoot_set(gso->slider, false, false);
@@ -484,7 +495,7 @@ static int decimate_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
tDecimModes mode = RNA_enum_get(op->ptr, "mode");
tDecimModes mode = tDecimModes(RNA_enum_get(op->ptr, "mode"));
/* We want to be able to work on all available keyframes. */
float factor = 1.0f;
/* We don't want to limit the decimation to a certain error margin. */
@@ -510,14 +521,12 @@ static int decimate_exec(bContext *C, wmOperator *op)
decimate_graph_keys(&ac, factor, error_sq_max);
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
static bool decimate_poll_property(const bContext *UNUSED(C),
wmOperator *op,
const PropertyRNA *prop)
static bool decimate_poll_property(const bContext * /*C*/, wmOperator *op, const PropertyRNA *prop)
{
const char *prop_id = RNA_property_identifier(prop);
const int mode = RNA_enum_get(op->ptr, "mode");
@@ -532,7 +541,7 @@ static bool decimate_poll_property(const bContext *UNUSED(C),
return true;
}
static char *decimate_desc(bContext *UNUSED(C), wmOperatorType *UNUSED(op), PointerRNA *ptr)
static char *decimate_desc(bContext * /*C*/, wmOperatorType * /*op*/, PointerRNA *ptr)
{
if (RNA_enum_get(ptr, "mode") == DECIM_ERROR) {
@@ -541,7 +550,7 @@ static char *decimate_desc(bContext *UNUSED(C), wmOperatorType *UNUSED(op), Poin
}
/* Use default description. */
return NULL;
return nullptr;
}
static const EnumPropertyItem decimate_mode_items[] = {
@@ -556,7 +565,7 @@ static const EnumPropertyItem decimate_mode_items[] = {
"Error Margin",
"Use an error margin to specify how much the curve is allowed to deviate from the original "
"path"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
void GRAPH_OT_decimate(wmOperatorType *ot)
@@ -619,7 +628,7 @@ static void blend_to_neighbor_graph_keys(bAnimContext *ac, const float factor)
static void blend_to_neighbor_modal_update(bContext *C, wmOperator *op)
{
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
common_draw_status_header(C, gso, "Blend to Neighbor");
@@ -629,7 +638,7 @@ static void blend_to_neighbor_modal_update(bContext *C, wmOperator *op)
const float factor = slider_factor_get_and_remember(op);
blend_to_neighbor_graph_keys(&gso->ac, factor);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
}
static int blend_to_neighbor_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -640,7 +649,7 @@ static int blend_to_neighbor_invoke(bContext *C, wmOperator *op, const wmEvent *
return invoke_result;
}
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
gso->modal_update = blend_to_neighbor_modal_update;
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
common_draw_status_header(C, gso, "Blend to Neighbor");
@@ -663,7 +672,7 @@ static int blend_to_neighbor_exec(bContext *C, wmOperator *op)
blend_to_neighbor_graph_keys(&ac, factor);
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -708,7 +717,7 @@ static void breakdown_graph_keys(bAnimContext *ac, float factor)
static void breakdown_modal_update(bContext *C, wmOperator *op)
{
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
common_draw_status_header(C, gso, "Breakdown");
@@ -716,7 +725,7 @@ static void breakdown_modal_update(bContext *C, wmOperator *op)
reset_bezts(gso);
const float factor = slider_factor_get_and_remember(op);
breakdown_graph_keys(&gso->ac, factor);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
}
static int breakdown_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -727,7 +736,7 @@ static int breakdown_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return invoke_result;
}
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
gso->modal_update = breakdown_modal_update;
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
common_draw_status_header(C, gso, "Breakdown");
@@ -750,7 +759,7 @@ static int breakdown_exec(bContext *C, wmOperator *op)
breakdown_graph_keys(&ac, factor);
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -790,14 +799,15 @@ void GRAPH_OT_breakdown(wmOperatorType *ot)
static void blend_to_default_graph_keys(bAnimContext *ac, const float factor)
{
ListBase anim_data = {NULL, NULL};
ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype);
ListBase anim_data = {nullptr, nullptr};
ANIM_animdata_filter(
ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, eAnimCont_Types(ac->datatype));
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
FCurve *fcu = (FCurve *)ale->key_data;
/* Check if the curves actually have any points. */
if (fcu == NULL || fcu->bezt == NULL || fcu->totvert == 0) {
if (fcu == nullptr || fcu->bezt == nullptr || fcu->totvert == 0) {
continue;
}
@@ -814,7 +824,7 @@ static void blend_to_default_graph_keys(bAnimContext *ac, const float factor)
static void blend_to_default_modal_update(bContext *C, wmOperator *op)
{
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
common_draw_status_header(C, gso, "Blend to Default Value");
@@ -823,7 +833,7 @@ static void blend_to_default_modal_update(bContext *C, wmOperator *op)
const float factor = ED_slider_factor_get(gso->slider);
RNA_property_float_set(op->ptr, gso->factor_prop, factor);
blend_to_default_graph_keys(&gso->ac, factor);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
}
static int blend_to_default_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -834,7 +844,7 @@ static int blend_to_default_invoke(bContext *C, wmOperator *op, const wmEvent *e
return invoke_result;
}
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
gso->modal_update = blend_to_default_modal_update;
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
common_draw_status_header(C, gso, "Blend to Default Value");
@@ -856,7 +866,7 @@ static int blend_to_default_exec(bContext *C, wmOperator *op)
blend_to_default_graph_keys(&ac, factor);
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -900,7 +910,7 @@ static void ease_graph_keys(bAnimContext *ac, const float factor)
static void ease_modal_update(bContext *C, wmOperator *op)
{
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
common_draw_status_header(C, gso, "Ease Keys");
@@ -908,7 +918,7 @@ static void ease_modal_update(bContext *C, wmOperator *op)
reset_bezts(gso);
const float factor = slider_factor_get_and_remember(op);
ease_graph_keys(&gso->ac, factor);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
}
static int ease_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -919,7 +929,7 @@ static int ease_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return invoke_result;
}
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
gso->modal_update = ease_modal_update;
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
common_draw_status_header(C, gso, "Ease Keys");
@@ -943,7 +953,7 @@ static int ease_exec(bContext *C, wmOperator *op)
ease_graph_keys(&ac, factor);
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -982,48 +992,51 @@ void GRAPH_OT_ease(wmOperatorType *ot)
/* It is necessary to store data for smoothing when running in modal, because the sampling of
* FCurves shouldn't be done on every update. */
typedef struct tGaussOperatorData {
struct tGaussOperatorData {
double *kernel;
ListBase segment_links; /* tFCurveSegmentLink */
ListBase anim_data; /* bAnimListElem */
} tGaussOperatorData;
};
/* Store data to smooth an FCurve segment. */
typedef struct tFCurveSegmentLink {
struct tFCurveSegmentLink {
struct tFCurveSegmentLink *next, *prev;
FCurve *fcu;
FCurveSegment *segment;
float *samples; /* Array of y-values of the FCurve segment. */
} tFCurveSegmentLink;
};
static void gaussian_smooth_allocate_operator_data(tGraphSliderOp *gso,
const int filter_width,
const float sigma)
{
tGaussOperatorData *operator_data = MEM_callocN(sizeof(tGaussOperatorData),
"tGaussOperatorData");
tGaussOperatorData *operator_data = static_cast<tGaussOperatorData *>(
MEM_callocN(sizeof(tGaussOperatorData), "tGaussOperatorData"));
const int kernel_size = filter_width + 1;
double *kernel = MEM_callocN(sizeof(double) * kernel_size, "Gauss Kernel");
double *kernel = static_cast<double *>(
MEM_callocN(sizeof(double) * kernel_size, "Gauss Kernel"));
ED_ANIM_get_1d_gauss_kernel(sigma, kernel_size, kernel);
operator_data->kernel = kernel;
ListBase anim_data = {NULL, NULL};
ANIM_animdata_filter(&gso->ac, &anim_data, OPERATOR_DATA_FILTER, gso->ac.data, gso->ac.datatype);
ListBase anim_data = {nullptr, nullptr};
ANIM_animdata_filter(
&gso->ac, &anim_data, OPERATOR_DATA_FILTER, gso->ac.data, eAnimCont_Types(gso->ac.datatype));
ListBase segment_links = {NULL, NULL};
ListBase segment_links = {nullptr, nullptr};
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
FCurve *fcu = (FCurve *)ale->key_data;
ListBase fcu_segments = find_fcurve_segments(fcu);
LISTBASE_FOREACH (FCurveSegment *, segment, &fcu_segments) {
tFCurveSegmentLink *segment_link = MEM_callocN(sizeof(tFCurveSegmentLink),
"FCurve Segment Link");
tFCurveSegmentLink *segment_link = static_cast<tFCurveSegmentLink *>(
MEM_callocN(sizeof(tFCurveSegmentLink), "FCurve Segment Link"));
segment_link->fcu = fcu;
segment_link->segment = segment;
BezTriple left_bezt = fcu->bezt[segment->start_index];
BezTriple right_bezt = fcu->bezt[segment->start_index + segment->length - 1];
const int sample_count = (int)(right_bezt.vec[1][0] - left_bezt.vec[1][0]) +
(filter_width * 2 + 1);
float *samples = MEM_callocN(sizeof(float) * sample_count, "Smooth FCurve Op Samples");
float *samples = static_cast<float *>(
MEM_callocN(sizeof(float) * sample_count, "Smooth FCurve Op Samples"));
sample_fcurve_segment(fcu, left_bezt.vec[1][0] - filter_width, samples, sample_count);
segment_link->samples = samples;
BLI_addtail(&segment_links, segment_link);
@@ -1050,7 +1063,7 @@ static void gaussian_smooth_free_operator_data(void *operator_data)
static void gaussian_smooth_modal_update(bContext *C, wmOperator *op)
{
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
bAnimContext ac;
@@ -1078,7 +1091,7 @@ static void gaussian_smooth_modal_update(bContext *C, wmOperator *op)
}
ANIM_animdata_update(&ac, &operator_data->anim_data);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
}
static int gaussian_smooth_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -1089,7 +1102,7 @@ static int gaussian_smooth_invoke(bContext *C, wmOperator *op, const wmEvent *ev
return invoke_result;
}
tGraphSliderOp *gso = op->customdata;
tGraphSliderOp *gso = static_cast<tGraphSliderOp *>(op->customdata);
gso->modal_update = gaussian_smooth_modal_update;
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
@@ -1111,8 +1124,9 @@ static void gaussian_smooth_graph_keys(bAnimContext *ac,
double *kernel,
const int filter_width)
{
ListBase anim_data = {NULL, NULL};
ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype);
ListBase anim_data = {nullptr, nullptr};
ANIM_animdata_filter(
ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, eAnimCont_Types(ac->datatype));
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
FCurve *fcu = (FCurve *)ale->key_data;
@@ -1123,7 +1137,8 @@ static void gaussian_smooth_graph_keys(bAnimContext *ac,
BezTriple right_bezt = fcu->bezt[segment->start_index + segment->length - 1];
const int sample_count = (int)(right_bezt.vec[1][0] - left_bezt.vec[1][0]) +
(filter_width * 2 + 1);
float *samples = MEM_callocN(sizeof(float) * sample_count, "Smooth FCurve Op Samples");
float *samples = static_cast<float *>(
MEM_callocN(sizeof(float) * sample_count, "Smooth FCurve Op Samples"));
sample_fcurve_segment(fcu, left_bezt.vec[1][0] - filter_width, samples, sample_count);
smooth_fcurve_segment(fcu, segment, samples, factor, filter_width, kernel);
MEM_freeN(samples);
@@ -1147,7 +1162,8 @@ static int gaussian_smooth_exec(bContext *C, wmOperator *op)
const float factor = RNA_float_get(op->ptr, "factor");
const int filter_width = RNA_int_get(op->ptr, "filter_width");
const int kernel_size = filter_width + 1;
double *kernel = MEM_callocN(sizeof(double) * kernel_size, "Gauss Kernel");
double *kernel = static_cast<double *>(
MEM_callocN(sizeof(double) * kernel_size, "Gauss Kernel"));
ED_ANIM_get_1d_gauss_kernel(RNA_float_get(op->ptr, "sigma"), kernel_size, kernel);
gaussian_smooth_graph_keys(&ac, factor, kernel, filter_width);
@@ -1155,7 +1171,7 @@ static int gaussian_smooth_exec(bContext *C, wmOperator *op)
MEM_freeN(kernel);
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}

View File

@@ -81,10 +81,11 @@ void ED_drivers_editor_init(bContext *C, ScrArea *area)
bAnimListElem *get_active_fcurve_channel(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ACTIVE |
ANIMFILTER_FCURVESONLY);
size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
size_t items = ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* We take the first F-Curve only, since some other ones may have had 'active' flag set
* if they were from linked data.
@@ -100,7 +101,7 @@ bAnimListElem *get_active_fcurve_channel(bAnimContext *ac)
}
/* no active F-Curve */
return NULL;
return nullptr;
}
/** \} */
@@ -113,7 +114,7 @@ bool graphop_visible_keyframes_poll(bContext *C)
{
bAnimContext ac;
bAnimListElem *ale;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
ScrArea *area = CTX_wm_area(C);
size_t items;
int filter;
@@ -121,7 +122,7 @@ bool graphop_visible_keyframes_poll(bContext *C)
/* firstly, check if in Graph Editor */
/* TODO: also check for region? */
if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) {
if ((area == nullptr) || (area->spacetype != SPACE_GRAPH)) {
return found;
}
@@ -134,12 +135,13 @@ bool graphop_visible_keyframes_poll(bContext *C)
* stopping on the first successful match
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
items = ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
if (items == 0) {
return found;
}
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
/* visible curves for selection must fulfill the following criteria:
@@ -147,7 +149,7 @@ bool graphop_visible_keyframes_poll(bContext *C)
* - F-Curve modifiers do not interfere with the result too much
* (i.e. the modifier-control drawing check returns false)
*/
if (fcu->bezt == NULL) {
if (fcu->bezt == nullptr) {
continue;
}
if (BKE_fcurve_are_keyframes_usable(fcu)) {
@@ -165,7 +167,7 @@ bool graphop_editable_keyframes_poll(bContext *C)
{
bAnimContext ac;
bAnimListElem *ale;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
ScrArea *area = CTX_wm_area(C);
size_t items;
int filter;
@@ -173,7 +175,7 @@ bool graphop_editable_keyframes_poll(bContext *C)
/* firstly, check if in Graph Editor or Dopesheet */
/* TODO: also check for region? */
if (area == NULL || !ELEM(area->spacetype, SPACE_GRAPH, SPACE_ACTION)) {
if (area == nullptr || !ELEM(area->spacetype, SPACE_GRAPH, SPACE_ACTION)) {
return found;
}
@@ -187,13 +189,14 @@ bool graphop_editable_keyframes_poll(bContext *C)
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE |
ANIMFILTER_FCURVESONLY);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
items = ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
if (items == 0) {
CTX_wm_operator_poll_msg_set(C, "There is no animation data to operate on");
return found;
}
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
/* editable curves must fulfill the following criteria:
@@ -202,7 +205,7 @@ bool graphop_editable_keyframes_poll(bContext *C)
* - F-Curve modifiers do not interfere with the result too much
* (i.e. the modifier-control drawing check returns false)
*/
if (fcu->bezt == NULL && fcu->fpt != NULL) {
if (fcu->bezt == nullptr && fcu->fpt != nullptr) {
/* This is a baked curve, it is never editable. */
continue;
}
@@ -226,7 +229,7 @@ bool graphop_active_fcurve_poll(bContext *C)
/* firstly, check if in Graph Editor */
/* TODO: also check for region? */
if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) {
if ((area == nullptr) || (area->spacetype != SPACE_GRAPH)) {
return has_fcurve;
}
@@ -237,7 +240,7 @@ bool graphop_active_fcurve_poll(bContext *C)
/* try to get the Active F-Curve */
ale = get_active_fcurve_channel(&ac);
if (ale == NULL) {
if (ale == nullptr) {
return has_fcurve;
}
@@ -264,20 +267,20 @@ bool graphop_active_editable_fcurve_ctx_poll(bContext *C)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "active_editable_fcurve", &RNA_FCurve);
return ptr.data != NULL;
return ptr.data != nullptr;
}
bool graphop_selected_fcurve_poll(bContext *C)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
ScrArea *area = CTX_wm_area(C);
size_t items;
int filter;
/* firstly, check if in Graph Editor */
/* TODO: also check for region? */
if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) {
if ((area == nullptr) || (area->spacetype != SPACE_GRAPH)) {
return false;
}
@@ -291,7 +294,8 @@ bool graphop_selected_fcurve_poll(bContext *C)
* otherwise selecting a curve via list to edit is too cumbersome. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
items = ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
if (items == 0) {
return false;
}

View File

@@ -51,7 +51,7 @@ void get_graph_keyframe_extents(bAnimContext *ac,
{
Scene *scene = ac->scene;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
@@ -62,7 +62,8 @@ void get_graph_keyframe_extents(bAnimContext *ac,
filter |= ANIMFILTER_SEL;
}
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Set large values initial values that will be easy to override. */
if (xmin) {
@@ -83,14 +84,14 @@ void get_graph_keyframe_extents(bAnimContext *ac,
bool foundBounds = false;
/* Go through channels, finding max extents. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcu = (FCurve *)ale->key_data;
rctf bounds;
float unitFac, offset;
/* Get range. */
if (BKE_fcurve_calc_bounds(fcu, do_sel_only, include_handles, NULL, &bounds)) {
if (BKE_fcurve_calc_bounds(fcu, do_sel_only, include_handles, nullptr, &bounds)) {
short mapping_flag = ANIM_get_normalization_flags(ac);
/* Apply NLA scaling. */
@@ -188,7 +189,7 @@ void get_graph_keyframe_extents(bAnimContext *ac,
/** \name Automatic Preview-Range Operator
* \{ */
static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
static int graphkeys_previewrange_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
Scene *scene;
@@ -198,14 +199,14 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
}
if (ac.scene == NULL) {
if (ac.scene == nullptr) {
return OPERATOR_CANCELLED;
}
scene = ac.scene;
/* Set the range directly. */
get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL, true, false);
get_graph_keyframe_extents(&ac, &min, &max, nullptr, nullptr, true, false);
scene->r.flag |= SCER_PRV_RANGE;
scene->r.psfra = round_fl_to_int(min);
scene->r.pefra = round_fl_to_int(max);
@@ -384,7 +385,7 @@ void GRAPH_OT_view_frame(wmOperatorType *ot)
static void create_ghost_curves(bAnimContext *ac, int start, int end)
{
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
@@ -400,10 +401,11 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end)
/* Filter data. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(
ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
/* Loop through filtered data and add keys between selected keyframes on every frame. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
FCurve *gcu = BKE_fcurve_create();
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
@@ -414,7 +416,7 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end)
short mapping_flag = ANIM_get_normalization_flags(ac);
/* Disable driver so that it don't muck up the sampling process. */
fcu->driver = NULL;
fcu->driver = nullptr;
/* Calculate unit-mapping factor. */
unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset);
@@ -422,7 +424,8 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end)
/* Create samples, but store them in a new curve
* - we cannot use fcurve_store_samples() as that will only overwrite the original curve.
*/
gcu->fpt = fpt = MEM_callocN(sizeof(FPoint) * (end - start + 1), "Ghost FPoint Samples");
gcu->fpt = fpt = static_cast<FPoint *>(
MEM_callocN(sizeof(FPoint) * (end - start + 1), "Ghost FPoint Samples"));
gcu->totvert = end - start + 1;
/* Use the sampling callback at 1-frame intervals from start to end frames. */
@@ -430,7 +433,7 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end)
float cfrae = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
fpt->vec[0] = cfrae;
fpt->vec[1] = (fcurve_samplingcb_evalcurve(fcu, NULL, cfrae) + offset) * unitFac;
fpt->vec[1] = (fcurve_samplingcb_evalcurve(fcu, nullptr, cfrae) + offset) * unitFac;
}
/* Set color of ghost curve
@@ -453,7 +456,7 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end)
/* ------------------- */
static int graphkeys_create_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op))
static int graphkeys_create_ghostcurves_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
View2D *v2d;
@@ -505,7 +508,7 @@ void GRAPH_OT_ghost_curves_create(wmOperatorType *ot)
* This operator clears the 'ghost curves' for the active Graph Editor.
* \{ */
static int graphkeys_clear_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op))
static int graphkeys_clear_ghostcurves_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
SpaceGraph *sipo;

View File

@@ -52,19 +52,19 @@
/* ******************** default callbacks for ipo space ***************** */
static SpaceLink *graph_create(const ScrArea *UNUSED(area), const Scene *scene)
static SpaceLink *graph_create(const ScrArea * /*area*/, const Scene *scene)
{
ARegion *region;
SpaceGraph *sipo;
/* Graph Editor - general stuff */
sipo = MEM_callocN(sizeof(SpaceGraph), "init graphedit");
sipo = static_cast<SpaceGraph *>(MEM_callocN(sizeof(SpaceGraph), "init graphedit"));
sipo->spacetype = SPACE_GRAPH;
sipo->autosnap = SACTSNAP_FRAME;
/* allocate DopeSheet data for Graph Editor */
sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
sipo->ads = static_cast<bDopeSheet *>(MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"));
sipo->ads->source = (ID *)scene;
/* settings for making it easier by default to just see what you're interested in tweaking */
@@ -72,14 +72,14 @@ static SpaceLink *graph_create(const ScrArea *UNUSED(area), const Scene *scene)
sipo->flag |= SIPO_SHOW_MARKERS;
/* header */
region = MEM_callocN(sizeof(ARegion), "header for graphedit");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "header for graphedit"));
BLI_addtail(&sipo->regionbase, region);
region->regiontype = RGN_TYPE_HEADER;
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
/* channels */
region = MEM_callocN(sizeof(ARegion), "channels region for graphedit");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "channels region for graphedit"));
BLI_addtail(&sipo->regionbase, region);
region->regiontype = RGN_TYPE_CHANNELS;
@@ -88,14 +88,14 @@ static SpaceLink *graph_create(const ScrArea *UNUSED(area), const Scene *scene)
region->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
/* ui buttons */
region = MEM_callocN(sizeof(ARegion), "buttons region for graphedit");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "buttons region for graphedit"));
BLI_addtail(&sipo->regionbase, region);
region->regiontype = RGN_TYPE_UI;
region->alignment = RGN_ALIGN_RIGHT;
/* main region */
region = MEM_callocN(sizeof(ARegion), "main region for graphedit");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "main region for graphedit"));
BLI_addtail(&sipo->regionbase, region);
region->regiontype = RGN_TYPE_WINDOW;
@@ -142,10 +142,10 @@ static void graph_init(wmWindowManager *wm, ScrArea *area)
SpaceGraph *sipo = (SpaceGraph *)area->spacedata.first;
/* init dopesheet data if non-existent (i.e. for old files) */
if (sipo->ads == NULL) {
if (sipo->ads == nullptr) {
wmWindow *win = WM_window_find_by_area(wm, area);
sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
sipo->ads->source = win ? (ID *)WM_window_get_active_scene(win) : NULL;
sipo->ads = static_cast<bDopeSheet *>(MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"));
sipo->ads->source = win ? (ID *)WM_window_get_active_scene(win) : nullptr;
}
/* force immediate init of any invalid F-Curve colors */
@@ -158,13 +158,13 @@ static void graph_init(wmWindowManager *wm, ScrArea *area)
static SpaceLink *graph_duplicate(SpaceLink *sl)
{
SpaceGraph *sipon = MEM_dupallocN(sl);
SpaceGraph *sipon = static_cast<SpaceGraph *>(MEM_dupallocN(sl));
memset(&sipon->runtime, 0x0, sizeof(sipon->runtime));
/* clear or remove stuff from old */
BLI_duplicatelist(&sipon->runtime.ghost_curves, &((SpaceGraph *)sl)->runtime.ghost_curves);
sipon->ads = MEM_dupallocN(sipon->ads);
sipon->ads = static_cast<bDopeSheet *>(MEM_dupallocN(sipon->ads));
return (SpaceLink *)sipon;
}
@@ -335,7 +335,7 @@ static void graph_main_region_draw_overlay(const bContext *C, ARegion *region)
/* scrollers */
/* FIXME: args for scrollers depend on the type of data being shown. */
UI_view2d_scrollers_draw(v2d, NULL);
UI_view2d_scrollers_draw(v2d, nullptr);
/* scale numbers */
{
@@ -390,11 +390,11 @@ static void graph_channel_region_draw(const bContext *C, ARegion *region)
UI_view2d_view_restore(C);
/* scrollers */
UI_view2d_scrollers_draw(v2d, NULL);
UI_view2d_scrollers_draw(v2d, nullptr);
}
/* add handlers, stuff you only do once or on area/region changes */
static void graph_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
static void graph_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
{
ED_region_header_init(region);
}
@@ -497,11 +497,10 @@ static void graph_region_message_subscribe(const wmRegionMessageSubscribeParams
PointerRNA ptr;
RNA_pointer_create(&screen->id, &RNA_SpaceGraphEditor, area->spacedata.first, &ptr);
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
.user_data = region,
.notify = ED_region_do_msg_notify_tag_redraw,
};
wmMsgSubscribeValue msg_sub_value_region_tag_redraw{};
msg_sub_value_region_tag_redraw.owner = region;
msg_sub_value_region_tag_redraw.user_data = region;
msg_sub_value_region_tag_redraw.notify = ED_region_do_msg_notify_tag_redraw;
/* Timeline depends on scene properties. */
{
@@ -640,7 +639,7 @@ static void graph_refresh_fcurve_colors(const bContext *C)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
size_t items;
int filter;
@@ -657,10 +656,11 @@ static void graph_refresh_fcurve_colors(const bContext *C)
* mismatch between channel-colors and the drawn curves
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
items = ANIM_animdata_filter(
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
/* loop over F-Curves, assigning colors */
for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
for (ale = static_cast<bAnimListElem *>(anim_data.first), i = 0; ale; ale = ale->next, i++) {
FCurve *fcu = (FCurve *)ale->data;
/* set color of curve here */
@@ -791,7 +791,7 @@ static void graph_refresh(const bContext *C, ScrArea *area)
if (sipo->runtime.flag & SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR) {
sipo->runtime.flag &= ~SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR;
#if 0 /* Done below. */
graph_refresh_fcurve_colors(C);
graph_refresh_fcurve_colors(C);
#endif
ED_area_tag_redraw(area);
}
@@ -803,9 +803,7 @@ static void graph_refresh(const bContext *C, ScrArea *area)
graph_refresh_fcurve_colors(C);
}
static void graph_id_remap(ScrArea *UNUSED(area),
SpaceLink *slink,
const struct IDRemapper *mappings)
static void graph_id_remap(ScrArea * /*area*/, SpaceLink *slink, const struct IDRemapper *mappings)
{
SpaceGraph *sgraph = (SpaceGraph *)slink;
if (!sgraph->ads) {
@@ -818,17 +816,17 @@ static void graph_id_remap(ScrArea *UNUSED(area),
static int graph_space_subtype_get(ScrArea *area)
{
SpaceGraph *sgraph = area->spacedata.first;
SpaceGraph *sgraph = static_cast<SpaceGraph *>(area->spacedata.first);
return sgraph->mode;
}
static void graph_space_subtype_set(ScrArea *area, int value)
{
SpaceGraph *sgraph = area->spacedata.first;
SpaceGraph *sgraph = static_cast<SpaceGraph *>(area->spacedata.first);
sgraph->mode = value;
}
static void graph_space_subtype_item_extend(bContext *UNUSED(C),
static void graph_space_subtype_item_extend(bContext * /*C*/,
EnumPropertyItem **item,
int *totitem)
{
@@ -873,7 +871,7 @@ static void graph_space_blend_write(BlendWriter *writer, SpaceLink *sl)
void ED_spacetype_ipo(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype ipo");
SpaceType *st = static_cast<SpaceType *>(MEM_callocN(sizeof(SpaceType), "spacetype ipo"));
ARegionType *art;
st->spaceid = SPACE_GRAPH;
@@ -896,7 +894,7 @@ void ED_spacetype_ipo(void)
st->blend_write = graph_space_blend_write;
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"));
art->regionid = RGN_TYPE_WINDOW;
art->init = graph_main_region_init;
art->draw = graph_main_region_draw;
@@ -908,7 +906,7 @@ void ED_spacetype_ipo(void)
BLI_addhead(&st->regiontypes, art);
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"));
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
@@ -919,7 +917,7 @@ void ED_spacetype_ipo(void)
BLI_addhead(&st->regiontypes, art);
/* regions: channels */
art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"));
art->regionid = RGN_TYPE_CHANNELS;
/* 200 is the 'standard', but due to scrollers, we want a bit more to fit the lock icons in */
art->prefsizex = 200 + V2D_SCROLL_WIDTH;
@@ -932,7 +930,7 @@ void ED_spacetype_ipo(void)
BLI_addhead(&st->regiontypes, art);
/* regions: UI buttons */
art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"));
art->regionid = RGN_TYPE_UI;
art->prefsizex = UI_SIDEBAR_PANEL_WIDTH;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;

View File

@@ -25,13 +25,13 @@ set(INC_SYS
)
set(SRC
image_buttons.c
image_draw.c
image_edit.c
image_ops.c
image_sequence.c
image_buttons.cc
image_draw.cc
image_edit.cc
image_ops.cc
image_sequence.cc
image_undo.cc
space_image.c
space_image.cc
image_intern.h
)

View File

@@ -54,23 +54,23 @@ ImageUser *ntree_get_active_iuser(bNodeTree *ntree)
bNode *node;
if (ntree) {
for (node = ntree->nodes.first; node; node = node->next) {
for (node = static_cast<bNode *>(ntree->nodes.first); node; node = node->next) {
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
if (node->flag & NODE_DO_OUTPUT) {
return node->storage;
return static_cast<ImageUser *>(node->storage);
}
}
}
}
return NULL;
return nullptr;
}
/* ********************* callbacks for standard image buttons *************** */
static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *image_p)
static void ui_imageuser_slot_menu(bContext * /*C*/, uiLayout *layout, void *image_p)
{
uiBlock *block = uiLayoutGetBlock(layout);
Image *image = image_p;
Image *image = static_cast<Image *>(image_p);
int slot_id;
LISTBASE_FOREACH_INDEX (RenderSlot *, slot, &image->renderslots, slot_id) {
@@ -106,7 +106,7 @@ static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *
0,
UI_UNIT_X * 5,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -116,10 +116,10 @@ static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *
static bool ui_imageuser_slot_menu_step(bContext *C, int direction, void *image_p)
{
Image *image = image_p;
Image *image = static_cast<Image *>(image_p);
if (ED_image_slot_cycle(image, direction)) {
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, nullptr);
return true;
}
return true;
@@ -138,7 +138,7 @@ static const char *ui_imageuser_layer_fake_name(RenderResult *rr)
if (ibuf->byte_buffer.data) {
return IFACE_("Sequence");
}
return NULL;
return nullptr;
}
/* workaround for passing many args */
@@ -150,14 +150,15 @@ struct ImageUI_Data {
static struct ImageUI_Data *ui_imageuser_data_copy(const struct ImageUI_Data *rnd_pt_src)
{
struct ImageUI_Data *rnd_pt_dst = MEM_mallocN(sizeof(*rnd_pt_src), __func__);
struct ImageUI_Data *rnd_pt_dst = static_cast<ImageUI_Data *>(
MEM_mallocN(sizeof(*rnd_pt_src), __func__));
memcpy(rnd_pt_dst, rnd_pt_src, sizeof(*rnd_pt_src));
return rnd_pt_dst;
}
static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt)
static void ui_imageuser_layer_menu(bContext * /*C*/, uiLayout *layout, void *rnd_pt)
{
struct ImageUI_Data *rnd_data = rnd_pt;
struct ImageUI_Data *rnd_data = static_cast<ImageUI_Data *>(rnd_pt);
uiBlock *block = uiLayoutGetBlock(layout);
Image *image = rnd_data->image;
ImageUser *iuser = rnd_data->iuser;
@@ -165,7 +166,7 @@ static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void
/* May have been freed since drawing. */
RenderResult *rr = BKE_image_acquire_renderresult(scene, image);
if (UNLIKELY(rr == NULL)) {
if (UNLIKELY(rr == nullptr)) {
return;
}
@@ -191,7 +192,7 @@ static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void
}
int nr = fake_name ? 1 : 0;
for (RenderLayer *rl = rr->layers.first; rl; rl = rl->next, nr++) {
for (RenderLayer *rl = static_cast<RenderLayer *>(rr->layers.first); rl; rl = rl->next, nr++) {
uiDefButS(block,
UI_BTYPE_BUT_MENU,
B_NOP,
@@ -217,7 +218,7 @@ static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void
0,
UI_UNIT_X * 5,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -227,9 +228,9 @@ static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void
BKE_image_release_renderresult(scene, image);
}
static void ui_imageuser_pass_menu(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt)
static void ui_imageuser_pass_menu(bContext * /*C*/, uiLayout *layout, void *rnd_pt)
{
struct ImageUI_Data *rnd_data = rnd_pt;
struct ImageUI_Data *rnd_data = static_cast<ImageUI_Data *>(rnd_pt);
uiBlock *block = uiLayoutGetBlock(layout);
Image *image = rnd_data->image;
ImageUser *iuser = rnd_data->iuser;
@@ -243,23 +244,25 @@ static void ui_imageuser_pass_menu(bContext *UNUSED(C), uiLayout *layout, void *
/* may have been freed since drawing */
rr = BKE_image_acquire_renderresult(scene, image);
if (UNLIKELY(rr == NULL)) {
if (UNLIKELY(rr == nullptr)) {
return;
}
rl = BLI_findlink(&rr->layers, rpass_index);
rl = static_cast<RenderLayer *>(BLI_findlink(&rr->layers, rpass_index));
UI_block_layout_set_current(block, layout);
uiLayoutColumn(layout, false);
nr = (rl == NULL) ? 1 : 0;
nr = (rl == nullptr) ? 1 : 0;
ListBase added_passes;
BLI_listbase_clear(&added_passes);
/* rendered results don't have a Combined pass */
/* multiview: the ordering must be ascending, so the left-most pass is always the one picked */
for (rpass = rl ? rl->passes.first : NULL; rpass; rpass = rpass->next, nr++) {
for (rpass = static_cast<RenderPass *>(rl ? rl->passes.first : nullptr); rpass;
rpass = rpass->next, nr++)
{
/* just show one pass of each kind */
if (BLI_findstring_ptr(&added_passes, rpass->name, offsetof(LinkData, data))) {
continue;
@@ -291,7 +294,7 @@ static void ui_imageuser_pass_menu(bContext *UNUSED(C), uiLayout *layout, void *
0,
UI_UNIT_X * 5,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -304,9 +307,9 @@ static void ui_imageuser_pass_menu(bContext *UNUSED(C), uiLayout *layout, void *
}
/**************************** view menus *****************************/
static void ui_imageuser_view_menu_rr(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt)
static void ui_imageuser_view_menu_rr(bContext * /*C*/, uiLayout *layout, void *rnd_pt)
{
struct ImageUI_Data *rnd_data = rnd_pt;
struct ImageUI_Data *rnd_data = static_cast<ImageUI_Data *>(rnd_pt);
uiBlock *block = uiLayoutGetBlock(layout);
Image *image = rnd_data->image;
ImageUser *iuser = rnd_data->iuser;
@@ -317,7 +320,7 @@ static void ui_imageuser_view_menu_rr(bContext *UNUSED(C), uiLayout *layout, voi
/* may have been freed since drawing */
rr = BKE_image_acquire_renderresult(scene, image);
if (UNLIKELY(rr == NULL)) {
if (UNLIKELY(rr == nullptr)) {
return;
}
@@ -332,7 +335,7 @@ static void ui_imageuser_view_menu_rr(bContext *UNUSED(C), uiLayout *layout, voi
0,
UI_UNIT_X * 5,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -342,7 +345,9 @@ static void ui_imageuser_view_menu_rr(bContext *UNUSED(C), uiLayout *layout, voi
uiItemS(layout);
nr = (rr ? BLI_listbase_count(&rr->views) : 0) - 1;
for (rview = rr ? rr->views.last : NULL; rview; rview = rview->prev, nr--) {
for (rview = static_cast<RenderView *>(rr ? rr->views.last : nullptr); rview;
rview = rview->prev, nr--)
{
uiDefButS(block,
UI_BTYPE_BUT_MENU,
B_NOP,
@@ -362,9 +367,9 @@ static void ui_imageuser_view_menu_rr(bContext *UNUSED(C), uiLayout *layout, voi
BKE_image_release_renderresult(scene, image);
}
static void ui_imageuser_view_menu_multiview(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt)
static void ui_imageuser_view_menu_multiview(bContext * /*C*/, uiLayout *layout, void *rnd_pt)
{
struct ImageUI_Data *rnd_data = rnd_pt;
struct ImageUI_Data *rnd_data = static_cast<ImageUI_Data *>(rnd_pt);
uiBlock *block = uiLayoutGetBlock(layout);
Image *image = rnd_data->image;
ImageUser *iuser = rnd_data->iuser;
@@ -382,7 +387,7 @@ static void ui_imageuser_view_menu_multiview(bContext *UNUSED(C), uiLayout *layo
0,
UI_UNIT_X * 5,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -392,7 +397,7 @@ static void ui_imageuser_view_menu_multiview(bContext *UNUSED(C), uiLayout *layo
uiItemS(layout);
nr = BLI_listbase_count(&image->views) - 1;
for (iv = image->views.last; iv; iv = iv->prev, nr--) {
for (iv = static_cast<ImageView *>(image->views.last); iv; iv = iv->prev, nr--) {
uiDefButS(block,
UI_BTYPE_BUT_MENU,
B_NOP,
@@ -413,24 +418,24 @@ static void ui_imageuser_view_menu_multiview(bContext *UNUSED(C), uiLayout *layo
/* 5 layer button callbacks... */
static void image_multi_cb(bContext *C, void *rnd_pt, void *rr_v)
{
struct ImageUI_Data *rnd_data = rnd_pt;
struct ImageUI_Data *rnd_data = static_cast<ImageUI_Data *>(rnd_pt);
ImageUser *iuser = rnd_data->iuser;
BKE_image_multilayer_index(rr_v, iuser);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
BKE_image_multilayer_index(static_cast<RenderResult *>(rr_v), iuser);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, nullptr);
}
static bool ui_imageuser_layer_menu_step(bContext *C, int direction, void *rnd_pt)
{
Scene *scene = CTX_data_scene(C);
struct ImageUI_Data *rnd_data = rnd_pt;
struct ImageUI_Data *rnd_data = static_cast<ImageUI_Data *>(rnd_pt);
Image *image = rnd_data->image;
ImageUser *iuser = rnd_data->iuser;
RenderResult *rr;
bool changed = false;
rr = BKE_image_acquire_renderresult(scene, image);
if (UNLIKELY(rr == NULL)) {
if (UNLIKELY(rr == nullptr)) {
return false;
}
@@ -460,7 +465,7 @@ static bool ui_imageuser_layer_menu_step(bContext *C, int direction, void *rnd_p
if (changed) {
BKE_image_multilayer_index(rr, iuser);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, nullptr);
}
return changed;
@@ -469,7 +474,7 @@ static bool ui_imageuser_layer_menu_step(bContext *C, int direction, void *rnd_p
static bool ui_imageuser_pass_menu_step(bContext *C, int direction, void *rnd_pt)
{
Scene *scene = CTX_data_scene(C);
struct ImageUI_Data *rnd_data = rnd_pt;
struct ImageUI_Data *rnd_data = static_cast<ImageUI_Data *>(rnd_pt);
Image *image = rnd_data->image;
ImageUser *iuser = rnd_data->iuser;
RenderResult *rr;
@@ -479,7 +484,7 @@ static bool ui_imageuser_pass_menu_step(bContext *C, int direction, void *rnd_pt
RenderPass *rpass;
rr = BKE_image_acquire_renderresult(scene, image);
if (UNLIKELY(rr == NULL)) {
if (UNLIKELY(rr == nullptr)) {
BKE_image_release_renderresult(scene, image);
return false;
}
@@ -488,14 +493,14 @@ static bool ui_imageuser_pass_menu_step(bContext *C, int direction, void *rnd_pt
layer -= 1;
}
rl = BLI_findlink(&rr->layers, layer);
if (rl == NULL) {
rl = static_cast<RenderLayer *>(BLI_findlink(&rr->layers, layer));
if (rl == nullptr) {
BKE_image_release_renderresult(scene, image);
return false;
}
rpass = BLI_findlink(&rl->passes, iuser->pass);
if (rpass == NULL) {
rpass = static_cast<RenderPass *>(BLI_findlink(&rl->passes, iuser->pass));
if (rpass == nullptr) {
BKE_image_release_renderresult(scene, image);
return false;
}
@@ -522,7 +527,7 @@ static bool ui_imageuser_pass_menu_step(bContext *C, int direction, void *rnd_pt
return false;
}
for (rp = rl->passes.first; rp; rp = rp->next, rp_index++) {
for (rp = static_cast<RenderPass *>(rl->passes.first); rp; rp = rp->next, rp_index++) {
if (STREQ(rp->name, rpass->name)) {
iuser->pass = rp_index - 1;
changed = true;
@@ -538,21 +543,21 @@ static bool ui_imageuser_pass_menu_step(bContext *C, int direction, void *rnd_pt
if (changed) {
BKE_image_multilayer_index(rr, iuser);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, nullptr);
}
return changed;
}
/* 5 view button callbacks... */
static void image_multiview_cb(bContext *C, void *rnd_pt, void *UNUSED(arg_v))
static void image_multiview_cb(bContext *C, void *rnd_pt, void * /*arg_v*/)
{
struct ImageUI_Data *rnd_data = rnd_pt;
struct ImageUI_Data *rnd_data = static_cast<ImageUI_Data *>(rnd_pt);
Image *ima = rnd_data->image;
ImageUser *iuser = rnd_data->iuser;
BKE_image_multiview_index(ima, iuser);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, nullptr);
}
static void uiblock_layer_pass_buttons(uiLayout *layout,
@@ -562,16 +567,16 @@ static void uiblock_layer_pass_buttons(uiLayout *layout,
int w,
const short *render_slot)
{
struct ImageUI_Data rnd_pt_local, *rnd_pt = NULL;
struct ImageUI_Data rnd_pt_local, *rnd_pt = nullptr;
uiBlock *block = uiLayoutGetBlock(layout);
uiBut *but;
RenderLayer *rl = NULL;
RenderLayer *rl = nullptr;
int wmenu1, wmenu2, wmenu3, wmenu4;
const char *fake_name;
const char *display_name = "";
const bool show_stereo = (iuser->flag & IMA_SHOW_STEREO) != 0;
if (iuser->scene == NULL) {
if (iuser->scene == nullptr) {
return;
}
@@ -604,7 +609,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout,
UI_but_func_menu_step_set(but, ui_imageuser_slot_menu_step);
UI_but_funcN_set(but, image_multi_cb, rnd_pt, rr);
UI_but_type_set_menu_from_pulldown(but);
rnd_pt = NULL;
rnd_pt = nullptr;
}
if (rr) {
@@ -615,7 +620,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout,
/* layer */
fake_name = ui_imageuser_layer_fake_name(rr);
rpass_index = iuser->layer - (fake_name ? 1 : 0);
rl = BLI_findlink(&rr->layers, rpass_index);
rl = static_cast<RenderLayer *>(BLI_findlink(&rr->layers, rpass_index));
rnd_pt_local.rpass_index = rpass_index;
if (RE_layers_have_name(rr)) {
@@ -633,11 +638,11 @@ static void uiblock_layer_pass_buttons(uiLayout *layout,
UI_but_func_menu_step_set(but, ui_imageuser_layer_menu_step);
UI_but_funcN_set(but, image_multi_cb, rnd_pt, rr);
UI_but_type_set_menu_from_pulldown(but);
rnd_pt = NULL;
rnd_pt = nullptr;
}
/* pass */
rpass = (rl ? BLI_findlink(&rl->passes, iuser->pass) : NULL);
rpass = static_cast<RenderPass *>((rl ? BLI_findlink(&rl->passes, iuser->pass) : nullptr));
if (rl && RE_passes_have_name(rl)) {
display_name = rpass ? rpass->name : "";
@@ -654,14 +659,14 @@ static void uiblock_layer_pass_buttons(uiLayout *layout,
UI_but_func_menu_step_set(but, ui_imageuser_pass_menu_step);
UI_but_funcN_set(but, image_multi_cb, rnd_pt, rr);
UI_but_type_set_menu_from_pulldown(but);
rnd_pt = NULL;
rnd_pt = nullptr;
}
/* view */
if (BLI_listbase_count_at_most(&rr->views, 2) > 1 &&
((!show_stereo) || !RE_RenderResult_is_stereo(rr)))
{
rview = BLI_findlink(&rr->views, iuser->view);
rview = static_cast<RenderView *>(BLI_findlink(&rr->views, iuser->view));
display_name = rview ? rview->name : "";
rnd_pt = ui_imageuser_data_copy(&rnd_pt_local);
@@ -676,7 +681,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout,
TIP_("Select View"));
UI_but_funcN_set(but, image_multi_cb, rnd_pt, rr);
UI_but_type_set_menu_from_pulldown(but);
rnd_pt = NULL;
rnd_pt = nullptr;
}
}
@@ -687,7 +692,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout,
ImageView *iv;
int nr = 0;
for (iv = image->views.first; iv; iv = iv->next) {
for (iv = static_cast<ImageView *>(image->views.first); iv; iv = iv->next) {
if (nr++ == iuser->view) {
display_name = iv->name;
break;
@@ -704,19 +709,19 @@ static void uiblock_layer_pass_buttons(uiLayout *layout,
wmenu1,
UI_UNIT_Y,
TIP_("Select View"));
UI_but_funcN_set(but, image_multiview_cb, rnd_pt, NULL);
UI_but_funcN_set(but, image_multiview_cb, rnd_pt, nullptr);
UI_but_type_set_menu_from_pulldown(but);
rnd_pt = NULL;
rnd_pt = nullptr;
}
}
typedef struct RNAUpdateCb {
struct RNAUpdateCb {
PointerRNA ptr;
PropertyRNA *prop;
ImageUser *iuser;
} RNAUpdateCb;
};
static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
static void rna_update_cb(bContext *C, void *arg_cb, void * /*arg*/)
{
RNAUpdateCb *cb = (RNAUpdateCb *)arg_cb;
@@ -756,8 +761,8 @@ void uiTemplateImage(uiLayout *layout,
uiBlock *block = uiLayoutGetBlock(layout);
PointerRNA imaptr = RNA_property_pointer_get(ptr, prop);
Image *ima = imaptr.data;
ImageUser *iuser = userptr->data;
Image *ima = static_cast<Image *>(imaptr.data);
ImageUser *iuser = static_cast<ImageUser *>(userptr->data);
Scene *scene = CTX_data_scene(C);
BKE_image_user_frame_calc(ima, iuser, (int)scene->r.cfra);
@@ -766,24 +771,24 @@ void uiTemplateImage(uiLayout *layout,
uiLayoutSetContextPointer(layout, "edit_image_user", userptr);
SpaceImage *space_image = CTX_wm_space_image(C);
if (!compact && (space_image == NULL || iuser != &space_image->iuser)) {
if (!compact && (space_image == nullptr || iuser != &space_image->iuser)) {
uiTemplateID(layout,
C,
ptr,
propname,
ima ? NULL : "IMAGE_OT_new",
ima ? nullptr : "IMAGE_OT_new",
"IMAGE_OT_open",
NULL,
nullptr,
UI_TEMPLATE_ID_FILTER_ALL,
false,
NULL);
nullptr);
if (ima != NULL) {
if (ima != nullptr) {
uiItemS(layout);
}
}
if (ima == NULL) {
if (ima == nullptr) {
return;
}
@@ -809,11 +814,11 @@ void uiTemplateImage(uiLayout *layout,
}
/* Set custom callback for property updates. */
RNAUpdateCb *cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
RNAUpdateCb *cb = static_cast<RNAUpdateCb *>(MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"));
cb->ptr = *ptr;
cb->prop = prop;
cb->iuser = iuser;
UI_block_funcN_set(block, rna_update_cb, cb, NULL);
UI_block_funcN_set(block, rna_update_cb, cb, nullptr);
/* Disable editing if image was modified, to avoid losing changes. */
const bool is_dirty = BKE_image_is_dirty(ima);
@@ -832,7 +837,7 @@ void uiTemplateImage(uiLayout *layout,
{
uiLayout *col = uiLayoutColumn(layout, false);
uiLayoutSetPropSep(col, true);
uiItemR(col, &imaptr, "source", 0, NULL, ICON_NONE);
uiItemR(col, &imaptr, "source", 0, nullptr, ICON_NONE);
}
/* Filepath */
@@ -871,14 +876,14 @@ void uiTemplateImage(uiLayout *layout,
uiItemR(sub, &imaptr, "generated_width", 0, "X", ICON_NONE);
uiItemR(sub, &imaptr, "generated_height", 0, "Y", ICON_NONE);
uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE);
uiItemR(col, &imaptr, "use_generated_float", 0, nullptr, ICON_NONE);
uiItemS(col);
uiItemR(col, &imaptr, "generated_type", UI_ITEM_R_EXPAND, IFACE_("Type"), ICON_NONE);
ImageTile *base_tile = BKE_image_get_tile(ima, 0);
if (base_tile->gen_type == IMA_GENTYPE_BLANK) {
uiItemR(col, &imaptr, "generated_color", 0, NULL, ICON_NONE);
uiItemR(col, &imaptr, "generated_color", 0, nullptr, ICON_NONE);
}
}
else if (compact == 0) {
@@ -888,7 +893,7 @@ void uiTemplateImage(uiLayout *layout,
uiItemS(layout);
const float dpi_fac = UI_SCALE_FAC;
uiblock_layer_pass_buttons(layout, ima, ima->rr, iuser, 230 * dpi_fac, NULL);
uiblock_layer_pass_buttons(layout, ima, ima->rr, iuser, 230 * dpi_fac, nullptr);
}
if (BKE_image_is_animated(ima)) {
@@ -904,10 +909,10 @@ void uiTemplateImage(uiLayout *layout,
uiItemO(row, "", ICON_FILE_REFRESH, "IMAGE_OT_match_movie_length");
uiItemR(sub, userptr, "frame_start", 0, IFACE_("Start"), ICON_NONE);
uiItemR(sub, userptr, "frame_offset", 0, NULL, ICON_NONE);
uiItemR(sub, userptr, "frame_offset", 0, nullptr, ICON_NONE);
uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE);
uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE);
uiItemR(col, userptr, "use_cyclic", 0, nullptr, ICON_NONE);
uiItemR(col, userptr, "use_auto_refresh", 0, nullptr, ICON_NONE);
if (ima->source == IMA_SRC_MOVIE && compact == 0) {
uiItemR(col, &imaptr, "use_deinterlace", 0, IFACE_("Deinterlace"), ICON_NONE);
@@ -921,7 +926,7 @@ void uiTemplateImage(uiLayout *layout,
uiLayout *col = uiLayoutColumn(layout, false);
uiLayoutSetPropSep(col, true);
uiItemR(col, &imaptr, "use_multiview", 0, NULL, ICON_NONE);
uiItemR(col, &imaptr, "use_multiview", 0, nullptr, ICON_NONE);
if (RNA_boolean_get(&imaptr, "use_multiview")) {
uiTemplateImageViews(layout, &imaptr);
@@ -952,23 +957,23 @@ void uiTemplateImage(uiLayout *layout,
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
if (ibuf && ibuf->float_buffer.data && (ibuf->flags & IB_halffloat) == 0) {
uiItemR(col, &imaptr, "use_half_precision", 0, NULL, ICON_NONE);
uiItemR(col, &imaptr, "use_half_precision", 0, nullptr, ICON_NONE);
}
BKE_image_release_ibuf(ima, ibuf, lock);
}
}
uiItemR(col, &imaptr, "use_view_as_render", 0, NULL, ICON_NONE);
uiItemR(col, &imaptr, "seam_margin", 0, NULL, ICON_NONE);
uiItemR(col, &imaptr, "use_view_as_render", 0, nullptr, ICON_NONE);
uiItemR(col, &imaptr, "seam_margin", 0, nullptr, ICON_NONE);
}
}
UI_block_funcN_set(block, NULL, NULL, NULL);
UI_block_funcN_set(block, nullptr, nullptr, nullptr);
}
void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, bool color_management)
{
ImageFormatData *imf = imfptr->data;
ImageFormatData *imf = static_cast<ImageFormatData *>(imfptr->data);
ID *id = imfptr->owner_id;
const int depth_ok = BKE_imtype_valid_depths(imf->imtype);
/* some settings depend on this being a scene that's rendered */
@@ -981,7 +986,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, bool color_ma
uiLayoutSetPropSep(col, true);
uiLayoutSetPropDecorate(col, false);
uiItemR(col, imfptr, "file_format", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "file_format", 0, nullptr, ICON_NONE);
/* Multi-layer always saves raw unmodified channels. */
if (imf->imtype != R_IMF_IMTYPE_MULTILAYER) {
@@ -1003,57 +1008,57 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, bool color_ma
R_IMF_CHAN_DEPTH_24,
R_IMF_CHAN_DEPTH_32) == 0)
{
uiItemR(uiLayoutRow(col, true), imfptr, "color_depth", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiItemR(uiLayoutRow(col, true), imfptr, "color_depth", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
}
if (BKE_imtype_supports_quality(imf->imtype)) {
uiItemR(col, imfptr, "quality", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "quality", 0, nullptr, ICON_NONE);
}
if (BKE_imtype_supports_compress(imf->imtype)) {
uiItemR(col, imfptr, "compression", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "compression", 0, nullptr, ICON_NONE);
}
if (ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "exr_codec", 0, nullptr, ICON_NONE);
}
if (is_render_out && ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
uiItemR(col, imfptr, "use_preview", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "use_preview", 0, nullptr, ICON_NONE);
}
if (imf->imtype == R_IMF_IMTYPE_JP2) {
uiItemR(col, imfptr, "jpeg2k_codec", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "jpeg2k_codec", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "use_jpeg2k_cinema_preset", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "use_jpeg2k_cinema_48", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "use_jpeg2k_cinema_preset", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "use_jpeg2k_cinema_48", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "use_jpeg2k_ycc", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "use_jpeg2k_ycc", 0, nullptr, ICON_NONE);
}
if (imf->imtype == R_IMF_IMTYPE_DPX) {
uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "use_cineon_log", 0, nullptr, ICON_NONE);
}
if (imf->imtype == R_IMF_IMTYPE_CINEON) {
#if 1
uiItemL(col, TIP_("Hard coded Non-Linear, Gamma:1.7"), ICON_NONE);
#else
uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "cineon_black", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "cineon_white", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "cineon_gamma", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "use_cineon_log", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "cineon_black", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "cineon_white", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "cineon_gamma", 0, nullptr, ICON_NONE);
#endif
}
if (imf->imtype == R_IMF_IMTYPE_TIFF) {
uiItemR(col, imfptr, "tiff_codec", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "tiff_codec", 0, nullptr, ICON_NONE);
}
/* Override color management */
if (color_management) {
uiItemS(col);
uiItemR(col, imfptr, "color_management", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "color_management", 0, nullptr, ICON_NONE);
if (imf->color_management == R_IMF_COLOR_MANAGEMENT_OVERRIDE) {
if (BKE_imtype_requires_linear_float(imf->imtype)) {
@@ -1062,8 +1067,8 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, bool color_ma
}
else {
PointerRNA display_settings_ptr = RNA_pointer_get(imfptr, "display_settings");
uiItemR(col, &display_settings_ptr, "display_device", 0, NULL, ICON_NONE);
uiTemplateColormanagedViewSettings(col, NULL, imfptr, "view_settings");
uiItemR(col, &display_settings_ptr, "display_device", 0, nullptr, ICON_NONE);
uiTemplateColormanagedViewSettings(col, nullptr, imfptr, "view_settings");
}
}
}
@@ -1071,28 +1076,28 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, bool color_ma
void uiTemplateImageStereo3d(uiLayout *layout, PointerRNA *stereo3d_format_ptr)
{
Stereo3dFormat *stereo3d_format = stereo3d_format_ptr->data;
Stereo3dFormat *stereo3d_format = static_cast<Stereo3dFormat *>(stereo3d_format_ptr->data);
uiLayout *col;
col = uiLayoutColumn(layout, false);
uiItemR(col, stereo3d_format_ptr, "display_mode", 0, NULL, ICON_NONE);
uiItemR(col, stereo3d_format_ptr, "display_mode", 0, nullptr, ICON_NONE);
switch (stereo3d_format->display_mode) {
case S3D_DISPLAY_ANAGLYPH: {
uiItemR(col, stereo3d_format_ptr, "anaglyph_type", 0, NULL, ICON_NONE);
uiItemR(col, stereo3d_format_ptr, "anaglyph_type", 0, nullptr, ICON_NONE);
break;
}
case S3D_DISPLAY_INTERLACE: {
uiItemR(col, stereo3d_format_ptr, "interlace_type", 0, NULL, ICON_NONE);
uiItemR(col, stereo3d_format_ptr, "use_interlace_swap", 0, NULL, ICON_NONE);
uiItemR(col, stereo3d_format_ptr, "interlace_type", 0, nullptr, ICON_NONE);
uiItemR(col, stereo3d_format_ptr, "use_interlace_swap", 0, nullptr, ICON_NONE);
break;
}
case S3D_DISPLAY_SIDEBYSIDE: {
uiItemR(col, stereo3d_format_ptr, "use_sidebyside_crosseyed", 0, NULL, ICON_NONE);
uiItemR(col, stereo3d_format_ptr, "use_sidebyside_crosseyed", 0, nullptr, ICON_NONE);
ATTR_FALLTHROUGH;
}
case S3D_DISPLAY_TOPBOTTOM: {
uiItemR(col, stereo3d_format_ptr, "use_squeezed_frame", 0, NULL, ICON_NONE);
uiItemR(col, stereo3d_format_ptr, "use_squeezed_frame", 0, nullptr, ICON_NONE);
break;
}
}
@@ -1109,7 +1114,7 @@ static void uiTemplateViewsFormat(uiLayout *layout,
uiLayoutSetPropSep(col, true);
uiLayoutSetPropDecorate(col, false);
uiItemR(col, ptr, "views_format", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiItemR(col, ptr, "views_format", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
if (stereo3d_format_ptr && RNA_enum_get(ptr, "views_format") == R_IMF_VIEWS_STEREO_3D) {
uiTemplateImageStereo3d(col, stereo3d_format_ptr);
@@ -1118,7 +1123,7 @@ static void uiTemplateViewsFormat(uiLayout *layout,
void uiTemplateImageViews(uiLayout *layout, PointerRNA *imaptr)
{
Image *ima = imaptr->data;
Image *ima = static_cast<Image *>(imaptr->data);
if (ima->type != IMA_TYPE_MULTILAYER) {
PropertyRNA *prop;
@@ -1130,16 +1135,16 @@ void uiTemplateImageViews(uiLayout *layout, PointerRNA *imaptr)
uiTemplateViewsFormat(layout, imaptr, &stereo3d_format_ptr);
}
else {
uiTemplateViewsFormat(layout, imaptr, NULL);
uiTemplateViewsFormat(layout, imaptr, nullptr);
}
}
void uiTemplateImageFormatViews(uiLayout *layout, PointerRNA *imfptr, PointerRNA *ptr)
{
ImageFormatData *imf = imfptr->data;
ImageFormatData *imf = static_cast<ImageFormatData *>(imfptr->data);
if (ptr != NULL) {
uiItemR(layout, ptr, "use_multiview", 0, NULL, ICON_NONE);
if (ptr != nullptr) {
uiItemR(layout, ptr, "use_multiview", 0, nullptr, ICON_NONE);
if (!RNA_boolean_get(ptr, "use_multiview")) {
return;
}
@@ -1155,7 +1160,7 @@ void uiTemplateImageFormatViews(uiLayout *layout, PointerRNA *imfptr, PointerRNA
uiTemplateViewsFormat(layout, imfptr, &stereo3d_format_ptr);
}
else {
uiTemplateViewsFormat(layout, imfptr, NULL);
uiTemplateViewsFormat(layout, imfptr, nullptr);
}
}
@@ -1173,14 +1178,14 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser
/* Use BKE_image_acquire_renderresult so we get the correct slot in the menu. */
rr = BKE_image_acquire_renderresult(scene, ima);
uiblock_layer_pass_buttons(
layout, ima, rr, iuser, menus_width, is_render_result ? &ima->render_slot : NULL);
layout, ima, rr, iuser, menus_width, is_render_result ? &ima->render_slot : nullptr);
BKE_image_release_renderresult(scene, ima);
}
}
void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser)
{
if (ima == NULL || iuser == NULL) {
if (ima == nullptr || iuser == nullptr) {
return;
}
@@ -1191,7 +1196,7 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
uiLayout *col = uiLayoutColumn(layout, true);
uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_RIGHT);
if (ibuf == NULL) {
if (ibuf == nullptr) {
uiItemL(col, TIP_("Can't Load Image"), ICON_NONE);
}
else {
@@ -1234,7 +1239,7 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
/* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
Scene *scene = CTX_data_scene(C);
const int framenr = BKE_image_user_frame_get(iuser, scene->r.cfra, NULL);
const int framenr = BKE_image_user_frame_get(iuser, scene->r.cfra, nullptr);
char str[MAX_IMAGE_INFO_LEN];
int duration = 0;
@@ -1267,10 +1272,10 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
#undef MAX_IMAGE_INFO_LEN
static bool metadata_panel_context_poll(const bContext *C, PanelType *UNUSED(pt))
static bool metadata_panel_context_poll(const bContext *C, PanelType * /*pt*/)
{
SpaceImage *space_image = CTX_wm_space_image(C);
return space_image != NULL && space_image->image != NULL;
return space_image != nullptr && space_image->image != nullptr;
}
static void metadata_panel_context_draw(const bContext *C, Panel *panel)
@@ -1279,7 +1284,7 @@ static void metadata_panel_context_draw(const bContext *C, Panel *panel)
SpaceImage *space_image = CTX_wm_space_image(C);
Image *image = space_image->image;
ImBuf *ibuf = BKE_image_acquire_ibuf(image, &space_image->iuser, &lock);
if (ibuf != NULL) {
if (ibuf != nullptr) {
ED_region_image_metadata_panel_draw(ibuf, panel->layout);
}
BKE_image_release_ibuf(image, ibuf, lock);
@@ -1289,7 +1294,7 @@ void image_buttons_register(ARegionType *art)
{
PanelType *pt;
pt = MEM_callocN(sizeof(PanelType), "spacetype image panel metadata");
pt = static_cast<PanelType *>(MEM_callocN(sizeof(PanelType), "spacetype image panel metadata"));
STRNCPY(pt->idname, "IMAGE_PT_metadata");
STRNCPY(pt->label, N_("Metadata"));
STRNCPY(pt->category, "Image");

View File

@@ -70,7 +70,7 @@ static void draw_render_info(
{
Render *re = RE_GetSceneRender(scene);
Scene *stats_scene = ED_render_job_get_scene(C);
if (stats_scene == NULL) {
if (stats_scene == nullptr) {
stats_scene = CTX_data_scene(C);
}
@@ -139,8 +139,8 @@ void ED_image_draw_info(Scene *scene,
const int ymin = rect->ymin;
const int dy = ymin + 0.3f * UI_UNIT_Y;
/* text colors */
/* XXX colored text not allowed in Blender UI */
/* text colors */
/* XXX colored text not allowed in Blender UI */
#if 0
uchar red[3] = {255, 50, 50};
uchar green[3] = {0, 255, 0};
@@ -175,11 +175,11 @@ void ED_image_draw_info(Scene *scene,
BLF_draw(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
if (channels == 1 && (cp != NULL || fp != NULL)) {
if (fp != NULL) {
if (channels == 1 && (cp != nullptr || fp != nullptr)) {
if (fp != nullptr) {
SNPRINTF(str, " Val:%-.3f |", fp[0]);
}
else if (cp != NULL) {
else if (cp != nullptr) {
SNPRINTF(str, " Val:%-.3f |", cp[0] / 255.0f);
}
BLF_color3ub(blf_mono_font, 255, 255, 255);
@@ -259,7 +259,8 @@ void ED_image_draw_info(Scene *scene,
}
if (use_default_view) {
IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, NULL, &scene->display_settings);
IMB_colormanagement_pixel_to_display_space_v4(
rgba, rgba, nullptr, &scene->display_settings);
}
else {
IMB_colormanagement_pixel_to_display_space_v4(
@@ -300,7 +301,8 @@ void ED_image_draw_info(Scene *scene,
if (color_manage) {
if (use_default_view) {
IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, NULL, &scene->display_settings);
IMB_colormanagement_pixel_to_display_space_v4(
finalcol, col, nullptr, &scene->display_settings);
}
else {
IMB_colormanagement_pixel_to_display_space_v4(
@@ -350,7 +352,7 @@ void ED_image_draw_info(Scene *scene,
immRecti(pos, color_quater_x, color_quater_y, color_rect_half.xmax, color_rect_half.ymax);
immRecti(pos, color_rect_half.xmin, color_rect_half.ymin, color_quater_x, color_quater_y);
if (fp != NULL || cp != NULL) {
if (fp != nullptr || cp != nullptr) {
GPU_blend(GPU_BLEND_ALPHA);
immUniformColor3fvAlpha(finalcol, fp ? fp[3] : (cp[3] / 255.0f));
immRecti(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
@@ -471,14 +473,14 @@ void draw_image_main_helpers(const bContext *C, ARegion *region)
bool ED_space_image_show_cache(const SpaceImage *sima)
{
Image *image = ED_space_image(sima);
Mask *mask = NULL;
Mask *mask = nullptr;
if (sima->mode == SI_MODE_MASK) {
mask = ED_space_image_get_mask(sima);
}
if (image == NULL && mask == NULL) {
if (image == nullptr && mask == nullptr) {
return false;
}
if (mask == NULL) {
if (mask == nullptr) {
return ELEM(image->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE);
}
return true;
@@ -502,7 +504,7 @@ void draw_image_cache(const bContext *C, ARegion *region)
Image *image = ED_space_image(sima);
float x, cfra = scene->r.cfra, sfra = scene->r.sfra, efra = scene->r.efra,
framelen = region->winx / (efra - sfra + 1);
Mask *mask = NULL;
Mask *mask = nullptr;
if (!ED_space_image_show_cache(sima)) {
return;
@@ -522,14 +524,15 @@ void draw_image_cache(const bContext *C, ARegion *region)
ED_region_cache_draw_background(region);
/* Draw cached segments. */
if (image != NULL && image->cache != NULL &&
ELEM(image->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
if (image != nullptr && image->cache != nullptr &&
ELEM(image->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE))
{
int num_segments = 0;
int *points = NULL;
int *points = nullptr;
BLI_mutex_lock(image->runtime.cache_mutex);
BLI_mutex_lock(static_cast<ThreadMutex *>(image->runtime.cache_mutex));
IMB_moviecache_get_cache_segments(image->cache, IMB_PROXY_NONE, 0, &num_segments, &points);
BLI_mutex_unlock(image->runtime.cache_mutex);
BLI_mutex_unlock(static_cast<ThreadMutex *>(image->runtime.cache_mutex));
ED_region_cache_draw_cached_segments(
region, num_segments, points, sfra + sima->iuser.offset, efra + sima->iuser.offset);
@@ -549,7 +552,7 @@ void draw_image_cache(const bContext *C, ARegion *region)
ED_region_cache_draw_curfra_label(cfra, x, region_bottom + 8.0f * UI_SCALE_FAC);
if (mask != NULL) {
if (mask != nullptr) {
ED_mask_draw_frames(mask, region, cfra, sfra, efra);
}
}
@@ -574,7 +577,8 @@ void ED_space_image_grid_steps(SpaceImage *sima,
float grid_steps_y[SI_GRID_STEPS_LEN],
const int grid_dimension)
{
const eSpaceImage_GridShapeSource grid_shape_source = sima->grid_shape_source;
const eSpaceImage_GridShapeSource grid_shape_source = eSpaceImage_GridShapeSource(
sima->grid_shape_source);
for (int step = 0; step < SI_GRID_STEPS_LEN; step++) {
switch (grid_shape_source) {
case SI_GRID_SHAPE_DYNAMIC:

View File

@@ -53,7 +53,7 @@ void ED_space_image_set(Main *bmain, SpaceImage *sima, Image *ima, bool automati
sima->image = ima;
if (ima == NULL || ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE) {
if (ima == nullptr || ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE) {
if (sima->mode == SI_MODE_PAINT) {
sima->mode = SI_MODE_VIEW;
}
@@ -65,7 +65,7 @@ void ED_space_image_set(Main *bmain, SpaceImage *sima, Image *ima, bool automati
id_us_ensure_real((ID *)sima->image);
WM_main_add_notifier(NC_SPACE | ND_SPACE_IMAGE, NULL);
WM_main_add_notifier(NC_SPACE | ND_SPACE_IMAGE, nullptr);
}
void ED_space_image_sync(Main *bmain, Image *image, bool ignore_render_viewer)
@@ -108,12 +108,12 @@ void ED_space_image_auto_set(const bContext *C, SpaceImage *sima)
BMEditMesh *em = BKE_editmesh_from_object(ob);
BMesh *bm = em->bm;
BMFace *efa = BM_mesh_active_face_get(bm, true, false);
if (efa == NULL) {
if (efa == nullptr) {
return;
}
Image *ima = NULL;
ED_object_get_active_image(ob, efa->mat_nr + 1, &ima, NULL, NULL, NULL);
Image *ima = nullptr;
ED_object_get_active_image(ob, efa->mat_nr + 1, &ima, nullptr, nullptr, nullptr);
if (ima != sima->image) {
sima->image = ima;
@@ -172,14 +172,14 @@ ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **r_lock, int tile)
return ibuf;
}
BKE_image_release_ibuf(sima->image, ibuf, *r_lock);
*r_lock = NULL;
*r_lock = nullptr;
}
}
else {
*r_lock = NULL;
*r_lock = nullptr;
}
return NULL;
return nullptr;
}
void ED_space_image_release_buffer(SpaceImage *sima, ImBuf *ibuf, void *lock)
@@ -219,7 +219,7 @@ bool ED_space_image_has_buffer(SpaceImage *sima)
bool has_buffer;
ibuf = ED_space_image_acquire_buffer(sima, &lock, 0);
has_buffer = (ibuf != NULL);
has_buffer = (ibuf != nullptr);
ED_space_image_release_buffer(sima, ibuf, lock);
return has_buffer;
@@ -263,7 +263,7 @@ void ED_space_image_get_size_fl(SpaceImage *sima, float r_size[2])
void ED_space_image_get_aspect(SpaceImage *sima, float *r_aspx, float *r_aspy)
{
Image *ima = sima->image;
if ((ima == NULL) || (ima->aspx == 0.0f || ima->aspy == 0.0f)) {
if ((ima == nullptr) || (ima->aspx == 0.0f || ima->aspy == 0.0f)) {
*r_aspx = *r_aspy = 1.0;
}
else {
@@ -434,14 +434,14 @@ void ED_space_image_scopes_update(const bContext *C,
/* We also don't update scopes of render result during render. */
if (G.is_rendering) {
const Image *image = sima->image;
if (image != NULL && ELEM(image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) {
if (image != nullptr && ELEM(image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) {
return;
}
}
BKE_scopes_update(&sima->scopes,
ibuf,
use_view_settings ? &scene->view_settings : NULL,
use_view_settings ? &scene->view_settings : nullptr,
&scene->display_settings);
}
@@ -536,7 +536,7 @@ bool ED_space_image_maskedit_mask_poll(bContext *C)
{
if (ED_space_image_maskedit_poll(C)) {
SpaceImage *sima = CTX_wm_space_image(C);
return sima->mask_info.mask != NULL;
return sima->mask_info.mask != nullptr;
}
return false;

View File

@@ -16,6 +16,10 @@ struct bContext;
struct bNodeTree;
struct wmOperatorType;
#ifdef __cplusplus
extern "C" {
#endif
/* space_image.c */
extern const char *image_context_dir[]; /* doc access */
@@ -96,3 +100,7 @@ void IMAGE_OT_tile_fill(struct wmOperatorType *ot);
*/
struct ImageUser *ntree_get_active_iuser(struct bNodeTree *ntree);
void image_buttons_register(struct ARegionType *art);
#ifdef __cplusplus
}
#endif

View File

@@ -167,14 +167,14 @@ static void sima_zoom_set_from_bounds(SpaceImage *sima, ARegion *region, const r
size = min_ff(size_xy[0], size_xy[1]);
CLAMP_MAX(size, 100.0f);
sima_zoom_set(sima, region, size, NULL, false);
sima_zoom_set(sima, region, size, nullptr, false);
}
static Image *image_from_context(const bContext *C)
{
/* Edit image is set by templates used throughout the interface, so image
* operations work outside the image editor. */
Image *ima = CTX_data_pointer_get_type(C, "edit_image", &RNA_Image).data;
Image *ima = static_cast<Image *>(CTX_data_pointer_get_type(C, "edit_image", &RNA_Image).data);
if (ima) {
return ima;
@@ -182,14 +182,15 @@ static Image *image_from_context(const bContext *C)
/* Image editor. */
SpaceImage *sima = CTX_wm_space_image(C);
return (sima) ? sima->image : NULL;
return (sima) ? sima->image : nullptr;
}
static ImageUser *image_user_from_context(const bContext *C)
{
/* Edit image user is set by templates used throughout the interface, so
* image operations work outside the image editor. */
ImageUser *iuser = CTX_data_pointer_get_type(C, "edit_image_user", &RNA_ImageUser).data;
ImageUser *iuser = static_cast<ImageUser *>(
CTX_data_pointer_get_type(C, "edit_image_user", &RNA_ImageUser).data);
if (iuser) {
return iuser;
@@ -197,7 +198,7 @@ static ImageUser *image_user_from_context(const bContext *C)
/* Image editor. */
SpaceImage *sima = CTX_wm_space_image(C);
return (sima) ? &sima->iuser : NULL;
return (sima) ? &sima->iuser : nullptr;
}
static ImageUser image_user_from_context_and_active_tile(const bContext *C, Image *ima)
@@ -226,7 +227,7 @@ static bool image_from_context_has_data_poll(bContext *C)
Image *ima = image_from_context(C);
ImageUser *iuser = image_user_from_context(C);
if (ima == NULL) {
if (ima == nullptr) {
return false;
}
@@ -268,10 +269,10 @@ static void image_view_all(SpaceImage *sima, ARegion *region, wmOperator *op)
h = height * aspy;
float xof = 0.0f, yof = 0.0f;
if ((sima->image == NULL) || (sima->image->source == IMA_SRC_TILED)) {
if ((sima->image == nullptr) || (sima->image->source == IMA_SRC_TILED)) {
/* Extend the shown area to cover all UDIM tiles. */
int x_tiles, y_tiles;
if (sima->image == NULL) {
if (sima->image == nullptr) {
x_tiles = sima->tile_grid_shape[0];
y_tiles = sima->tile_grid_shape[1];
}
@@ -300,7 +301,7 @@ static void image_view_all(SpaceImage *sima, ARegion *region, wmOperator *op)
zoomx = (float)width / (w + 2 * margin);
zoomy = (float)height / (h + 2 * margin);
sima_zoom_set(sima, region, min_ff(zoomx, zoomy), NULL, false);
sima_zoom_set(sima, region, min_ff(zoomx, zoomy), nullptr, false);
}
else {
if ((w >= width || h >= height) && (width > 0 && height > 0)) {
@@ -308,10 +309,10 @@ static void image_view_all(SpaceImage *sima, ARegion *region, wmOperator *op)
zoomy = (float)height / h;
/* find the zoom value that will fit the image in the image space */
sima_zoom_set(sima, region, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL, false);
sima_zoom_set(sima, region, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), nullptr, false);
}
else {
sima_zoom_set(sima, region, 1.0f, NULL, false);
sima_zoom_set(sima, region, 1.0f, nullptr, false);
}
}
@@ -337,7 +338,7 @@ static bool space_image_main_area_not_uv_brush_poll(bContext *C)
Scene *scene = CTX_data_scene(C);
ToolSettings *toolsettings = scene->toolsettings;
if (sima && !toolsettings->uvsculpt && (CTX_data_edit_object(C) == NULL)) {
if (sima && !toolsettings->uvsculpt && (CTX_data_edit_object(C) == nullptr)) {
return true;
}
@@ -350,12 +351,12 @@ static bool space_image_main_area_not_uv_brush_poll(bContext *C)
/** \name View Pan Operator
* \{ */
typedef struct ViewPanData {
struct ViewPanData {
float x, y;
float xof, yof;
int launch_event;
bool own_cursor;
} ViewPanData;
};
static void image_view_pan_init(bContext *C, wmOperator *op, const wmEvent *event)
{
@@ -363,7 +364,8 @@ static void image_view_pan_init(bContext *C, wmOperator *op, const wmEvent *even
SpaceImage *sima = CTX_wm_space_image(C);
ViewPanData *vpd;
op->customdata = vpd = MEM_callocN(sizeof(ViewPanData), "ImageViewPanData");
op->customdata = vpd = static_cast<ViewPanData *>(
MEM_callocN(sizeof(ViewPanData), "ImageViewPanData"));
/* Grab will be set when running from gizmo. */
vpd->own_cursor = (win->grabcursor == 0);
@@ -383,7 +385,7 @@ static void image_view_pan_init(bContext *C, wmOperator *op, const wmEvent *even
static void image_view_pan_exit(bContext *C, wmOperator *op, bool cancel)
{
SpaceImage *sima = CTX_wm_space_image(C);
ViewPanData *vpd = op->customdata;
ViewPanData *vpd = static_cast<ViewPanData *>(op->customdata);
if (cancel) {
sima->xof = vpd->xof;
@@ -432,7 +434,7 @@ static int image_view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *eve
static int image_view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
SpaceImage *sima = CTX_wm_space_image(C);
ViewPanData *vpd = op->customdata;
ViewPanData *vpd = static_cast<ViewPanData *>(op->customdata);
float offset[2];
switch (event->type) {
@@ -481,7 +483,7 @@ void IMAGE_OT_view_pan(wmOperatorType *ot)
RNA_def_float_vector(ot->srna,
"offset",
2,
NULL,
nullptr,
-FLT_MAX,
FLT_MAX,
"Offset",
@@ -496,7 +498,7 @@ void IMAGE_OT_view_pan(wmOperatorType *ot)
/** \name View Zoom Operator
* \{ */
typedef struct ViewZoomData {
struct ViewZoomData {
float origx, origy;
float zoom;
int launch_event;
@@ -510,7 +512,7 @@ typedef struct ViewZoomData {
/* */
SpaceImage *sima;
ARegion *region;
} ViewZoomData;
};
static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event)
{
@@ -519,7 +521,8 @@ static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *eve
ARegion *region = CTX_wm_region(C);
ViewZoomData *vpd;
op->customdata = vpd = MEM_callocN(sizeof(ViewZoomData), "ImageViewZoomData");
op->customdata = vpd = static_cast<ViewZoomData *>(
MEM_callocN(sizeof(ViewZoomData), "ImageViewZoomData"));
/* Grab will be set when running from gizmo. */
vpd->own_cursor = (win->grabcursor == 0);
@@ -550,7 +553,7 @@ static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *eve
static void image_view_zoom_exit(bContext *C, wmOperator *op, bool cancel)
{
SpaceImage *sima = CTX_wm_space_image(C);
ViewZoomData *vpd = op->customdata;
ViewZoomData *vpd = static_cast<ViewZoomData *>(op->customdata);
if (cancel) {
sima->zoom = vpd->zoom;
@@ -572,7 +575,7 @@ static int image_view_zoom_exec(bContext *C, wmOperator *op)
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *region = CTX_wm_region(C);
sima_zoom_set_factor(sima, region, RNA_float_get(op->ptr, "factor"), NULL, false);
sima_zoom_set_factor(sima, region, RNA_float_get(op->ptr, "factor"), nullptr, false);
ED_region_tag_redraw(region);
@@ -667,7 +670,7 @@ static void image_zoom_apply(ViewZoomData *vpd,
static int image_view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
ViewZoomData *vpd = op->customdata;
ViewZoomData *vpd = static_cast<ViewZoomData *>(op->customdata);
short event_code = VIEW_PASS;
int ret = OPERATOR_RUNNING_MODAL;
@@ -765,7 +768,7 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot)
* that explains the negative signs in the code below
*/
static int image_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static int image_view_ndof_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
{
if (event->type != NDOF_MOTION) {
return OPERATOR_CANCELLED;
@@ -775,7 +778,7 @@ static int image_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmE
ARegion *region = CTX_wm_region(C);
float pan_vec[3];
const wmNDOFMotionData *ndof = event->customdata;
const wmNDOFMotionData *ndof = static_cast<const wmNDOFMotionData *>(event->customdata);
const float pan_speed = NDOF_PIXELS_PER_SECOND;
WM_event_ndof_pan_get(ndof, pan_vec, true);
@@ -783,7 +786,7 @@ static int image_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmE
mul_v3_fl(pan_vec, ndof->dt);
mul_v2_fl(pan_vec, pan_speed / sima->zoom);
sima_zoom_set_factor(sima, region, max_ff(0.0f, 1.0f - pan_vec[2]), NULL, false);
sima_zoom_set_factor(sima, region, max_ff(0.0f, 1.0f - pan_vec[2]), nullptr, false);
sima->xof += pan_vec[0];
sima->yof += pan_vec[1];
@@ -876,7 +879,7 @@ static int view_cursor_center_exec(bContext *C, wmOperator *op)
sima->cursor[1] = 0.5f;
/* Needed for updating the cursor. */
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, nullptr);
return OPERATOR_FINISHED;
}
@@ -905,7 +908,7 @@ void IMAGE_OT_view_cursor_center(wmOperatorType *ot)
/** \name Center View To Cursor Operator
* \{ */
static int view_center_cursor_exec(bContext *C, wmOperator *UNUSED(op))
static int view_center_cursor_exec(bContext *C, wmOperator * /*op*/)
{
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *region = CTX_wm_region(C);
@@ -935,7 +938,7 @@ void IMAGE_OT_view_center_cursor(wmOperatorType *ot)
/** \name Frame Selected Operator
* \{ */
static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
static int image_view_selected_exec(bContext *C, wmOperator * /*op*/)
{
SpaceImage *sima;
ARegion *region;
@@ -955,7 +958,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
if (ED_space_image_show_uvedit(sima, obedit)) {
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
scene, view_layer, ((View3D *)NULL), &objects_len);
scene, view_layer, ((View3D *)nullptr), &objects_len);
bool success = ED_uvedit_minmax_multi(scene, objects, objects_len, min, max);
MEM_freeN(objects);
if (!success) {
@@ -967,12 +970,11 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
}
rctf bounds = {
.xmin = min[0],
.ymin = min[1],
.xmax = max[0],
.ymax = max[1],
};
rctf bounds{};
bounds.xmin = min[0];
bounds.ymin = min[1];
bounds.xmax = max[0];
bounds.ymax = max[1];
/* add some margin */
BLI_rctf_scale(&bounds, 1.4f);
@@ -1056,7 +1058,7 @@ void IMAGE_OT_view_zoom_in(wmOperatorType *ot)
prop = RNA_def_float_vector(ot->srna,
"location",
2,
NULL,
nullptr,
-FLT_MAX,
FLT_MAX,
"Location",
@@ -1115,7 +1117,7 @@ void IMAGE_OT_view_zoom_out(wmOperatorType *ot)
prop = RNA_def_float_vector(ot->srna,
"location",
2,
NULL,
nullptr,
-FLT_MAX,
FLT_MAX,
"Location",
@@ -1136,7 +1138,7 @@ static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op)
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *region = CTX_wm_region(C);
sima_zoom_set(sima, region, RNA_float_get(op->ptr, "ratio"), NULL, false);
sima_zoom_set(sima, region, RNA_float_get(op->ptr, "ratio"), nullptr, false);
/* ensure pixel exact locations for draw */
sima->xof = (int)sima->xof;
@@ -1190,15 +1192,14 @@ static int image_view_zoom_border_exec(bContext *C, wmOperator *op)
UI_view2d_region_to_view_rctf(&region->v2d, &bounds, &bounds);
const struct {
struct {
float xof;
float yof;
float zoom;
} sima_view_prev = {
.xof = sima->xof,
.yof = sima->yof,
.zoom = sima->zoom,
};
} sima_view_prev{};
sima_view_prev.xof = sima->xof;
sima_view_prev.yof = sima->yof;
sima_view_prev.zoom = sima->zoom;
sima_zoom_set_from_bounds(sima, region, &bounds);
@@ -1246,24 +1247,26 @@ static void image_filesel(bContext *C, wmOperator *op, const char *path)
/** \name Open Image Operator
* \{ */
typedef struct ImageOpenData {
struct ImageOpenData {
PropertyPointerRNA pprop;
ImageUser *iuser;
ImageFormatData im_format;
} ImageOpenData;
};
static void image_open_init(bContext *C, wmOperator *op)
{
ImageOpenData *iod;
op->customdata = iod = MEM_callocN(sizeof(ImageOpenData), __func__);
iod->iuser = CTX_data_pointer_get_type(C, "image_user", &RNA_ImageUser).data;
op->customdata = iod = static_cast<ImageOpenData *>(
MEM_callocN(sizeof(ImageOpenData), __func__));
iod->iuser = static_cast<ImageUser *>(
CTX_data_pointer_get_type(C, "image_user", &RNA_ImageUser).data);
UI_context_active_but_prop_get_templateID(C, &iod->pprop.ptr, &iod->pprop.prop);
}
static void image_open_cancel(bContext *UNUSED(C), wmOperator *op)
static void image_open_cancel(bContext * /*C*/, wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
op->customdata = nullptr;
}
static Image *image_open_single(Main *bmain,
@@ -1274,7 +1277,7 @@ static Image *image_open_single(Main *bmain,
bool use_multiview)
{
bool exists = false;
Image *ima = NULL;
Image *ima = nullptr;
errno = 0;
ima = BKE_image_load_exists_ex(bmain, range->filepath, &exists);
@@ -1288,7 +1291,7 @@ static Image *image_open_single(Main *bmain,
"Cannot read '%s': %s",
range->filepath,
errno ? strerror(errno) : TIP_("unsupported image format"));
return NULL;
return nullptr;
}
if (!exists) {
@@ -1299,7 +1302,7 @@ static Image *image_open_single(Main *bmain,
/* handle multiview images */
if (use_multiview) {
ImageOpenData *iod = op->customdata;
ImageOpenData *iod = static_cast<ImageOpenData *>(op->customdata);
ImageFormatData *imf = &iod->im_format;
ima->flag |= IMA_USE_VIEWS;
@@ -1314,10 +1317,10 @@ static Image *image_open_single(Main *bmain,
if (ima->source == IMA_SRC_FILE) {
if (range->udims_detected && range->udim_tiles.first) {
ima->source = IMA_SRC_TILED;
ImageTile *first_tile = ima->tiles.first;
ImageTile *first_tile = static_cast<ImageTile *>(ima->tiles.first);
first_tile->tile_number = range->offset;
LISTBASE_FOREACH (LinkData *, node, &range->udim_tiles) {
BKE_image_add_tile(ima, POINTER_AS_INT(node->data), NULL);
BKE_image_add_tile(ima, POINTER_AS_INT(node->data), nullptr);
}
}
else if (range->length > 1) {
@@ -1334,8 +1337,8 @@ static int image_open_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
ScrArea *area = CTX_wm_area(C);
Scene *scene = CTX_data_scene(C);
ImageUser *iuser = NULL;
Image *ima = NULL;
ImageUser *iuser = nullptr;
Image *ima = nullptr;
int frame_seq_len = 0;
int frame_ofs = 1;
@@ -1353,7 +1356,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
bmain, op, range, BKE_main_blendfile_path(bmain), is_relative_path, use_multiview);
/* take the first image */
if ((ima == NULL) && ima_range) {
if ((ima == nullptr) && ima_range) {
ima = ima_range;
frame_seq_len = range->length;
frame_ofs = range->offset;
@@ -1363,12 +1366,12 @@ static int image_open_exec(bContext *C, wmOperator *op)
}
BLI_freelistN(&ranges);
if (ima == NULL) {
if (ima == nullptr) {
return OPERATOR_CANCELLED;
}
/* hook into UI */
ImageOpenData *iod = op->customdata;
ImageOpenData *iod = static_cast<ImageOpenData *>(op->customdata);
if (iod->pprop.prop) {
/* when creating new ID blocks, use is already 1, but RNA
@@ -1377,7 +1380,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
PointerRNA imaptr;
RNA_id_pointer_create(&ima->id, &imaptr);
RNA_property_pointer_set(&iod->pprop.ptr, iod->pprop.prop, imaptr, NULL);
RNA_property_pointer_set(&iod->pprop.ptr, iod->pprop.prop, imaptr, nullptr);
RNA_property_update(C, &iod->pprop.ptr, iod->pprop.prop);
}
@@ -1385,18 +1388,19 @@ static int image_open_exec(bContext *C, wmOperator *op)
iuser = iod->iuser;
}
else if (area && area->spacetype == SPACE_IMAGE) {
SpaceImage *sima = area->spacedata.first;
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
ED_space_image_set(bmain, sima, ima, false);
iuser = &sima->iuser;
}
else {
Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
Tex *tex = static_cast<Tex *>(CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data);
if (tex && tex->type == TEX_IMAGE) {
iuser = &tex->iuser;
}
if (iuser == NULL) {
Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data;
if (iuser == nullptr) {
Camera *cam = static_cast<Camera *>(
CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data);
if (cam) {
LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) {
if (bgpic->ima == ima) {
@@ -1435,25 +1439,25 @@ static int image_open_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
SpaceImage *sima = CTX_wm_space_image(C); /* XXX other space types can call */
const char *path = U.textudir;
Image *ima = NULL;
Image *ima = nullptr;
Scene *scene = CTX_data_scene(C);
if (sima) {
ima = sima->image;
}
if (ima == NULL) {
Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
if (ima == nullptr) {
Tex *tex = static_cast<Tex *>(CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data);
if (tex && tex->type == TEX_IMAGE) {
ima = tex->ima;
}
}
if (ima == NULL) {
if (ima == nullptr) {
PointerRNA ptr;
PropertyRNA *prop;
@@ -1493,28 +1497,33 @@ static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
return OPERATOR_RUNNING_MODAL;
}
static bool image_open_draw_check_prop(PointerRNA *UNUSED(ptr),
static bool image_open_draw_check_prop(PointerRNA * /*ptr*/,
PropertyRNA *prop,
void *UNUSED(user_data))
void * /*user_data*/)
{
const char *prop_id = RNA_property_identifier(prop);
return !STR_ELEM(prop_id, "filepath", "directory", "filename");
}
static void image_open_draw(bContext *UNUSED(C), wmOperator *op)
static void image_open_draw(bContext * /*C*/, wmOperator *op)
{
uiLayout *layout = op->layout;
ImageOpenData *iod = op->customdata;
ImageOpenData *iod = static_cast<ImageOpenData *>(op->customdata);
ImageFormatData *imf = &iod->im_format;
PointerRNA imf_ptr;
/* main draw call */
uiDefAutoButsRNA(
layout, op->ptr, image_open_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
uiDefAutoButsRNA(layout,
op->ptr,
image_open_draw_check_prop,
nullptr,
nullptr,
UI_BUT_LABEL_ALIGN_NONE,
false);
/* image template */
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
RNA_pointer_create(nullptr, &RNA_ImageFormatSettings, imf, &imf_ptr);
/* multiview template */
if (RNA_boolean_get(op->ptr, "show_multiview")) {
@@ -1577,8 +1586,8 @@ void IMAGE_OT_open(wmOperatorType *ot)
static int image_file_browse_exec(bContext *C, wmOperator *op)
{
Image *ima = op->customdata;
if (ima == NULL) {
Image *ima = static_cast<Image *>(op->customdata);
if (ima == nullptr) {
return OPERATOR_CANCELLED;
}
@@ -1629,7 +1638,7 @@ static int image_file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *
WM_operator_properties_create_ptr(&props_ptr, ot);
RNA_string_set(&props_ptr, "filepath", filepath);
WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &props_ptr, NULL);
WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &props_ptr, nullptr);
WM_operator_properties_free(&props_ptr);
return OPERATOR_CANCELLED;
@@ -1647,7 +1656,7 @@ static int image_file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *
static bool image_file_browse_poll(bContext *C)
{
return image_from_context(C) != NULL;
return image_from_context(C) != nullptr;
}
void IMAGE_OT_file_browse(wmOperatorType *ot)
@@ -1683,7 +1692,7 @@ void IMAGE_OT_file_browse(wmOperatorType *ot)
/** \name Match Movie Length Operator
* \{ */
static int image_match_len_exec(bContext *C, wmOperator *UNUSED(op))
static int image_match_len_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
Image *ima = image_from_context(C);
@@ -1691,7 +1700,7 @@ static int image_match_len_exec(bContext *C, wmOperator *UNUSED(op))
if (!ima || !iuser) {
/* Try to get a Texture, or a SpaceImage from context... */
Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
Tex *tex = static_cast<Tex *>(CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data);
if (tex && tex->type == TEX_IMAGE) {
ima = tex->ima;
iuser = &tex->iuser;
@@ -1770,7 +1779,7 @@ static int image_replace_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int image_replace_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int image_replace_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
SpaceImage *sima = CTX_wm_space_image(C);
@@ -1822,11 +1831,11 @@ void IMAGE_OT_replace(wmOperatorType *ot)
/** \name Save Image As Operator
* \{ */
typedef struct ImageSaveData {
struct ImageSaveData {
ImageUser *iuser;
Image *image;
ImageSaveOptions opts;
} ImageSaveData;
};
static void image_save_options_from_op(Main *bmain, ImageSaveOptions *opts, wmOperator *op)
{
@@ -1867,14 +1876,14 @@ static ImageSaveData *image_save_as_init(bContext *C, wmOperator *op)
ImageUser *iuser = image_user_from_context(C);
Scene *scene = CTX_data_scene(C);
ImageSaveData *isd = MEM_callocN(sizeof(*isd), __func__);
ImageSaveData *isd = static_cast<ImageSaveData *>(MEM_callocN(sizeof(*isd), __func__));
isd->image = image;
isd->iuser = iuser;
if (!BKE_image_save_options_init(&isd->opts, bmain, scene, image, iuser, true, false)) {
BKE_image_save_options_free(&isd->opts);
MEM_freeN(isd);
return NULL;
return nullptr;
}
isd->opts.do_newpath = true;
@@ -1907,11 +1916,11 @@ static ImageSaveData *image_save_as_init(bContext *C, wmOperator *op)
static void image_save_as_free(wmOperator *op)
{
if (op->customdata) {
ImageSaveData *isd = op->customdata;
ImageSaveData *isd = static_cast<ImageSaveData *>(op->customdata);
BKE_image_save_options_free(&isd->opts);
MEM_freeN(op->customdata);
op->customdata = NULL;
op->customdata = nullptr;
}
}
@@ -1921,11 +1930,11 @@ static int image_save_as_exec(bContext *C, wmOperator *op)
ImageSaveData *isd;
if (op->customdata) {
isd = op->customdata;
isd = static_cast<ImageSaveData *>(op->customdata);
}
else {
isd = image_save_as_init(C, op);
if (isd == NULL) {
if (isd == nullptr) {
return OPERATOR_CANCELLED;
}
}
@@ -1947,7 +1956,7 @@ static int image_save_as_exec(bContext *C, wmOperator *op)
static bool image_save_as_check(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
ImageSaveData *isd = op->customdata;
ImageSaveData *isd = static_cast<ImageSaveData *>(op->customdata);
image_save_options_from_op(bmain, &isd->opts, op);
BKE_image_save_options_update(&isd->opts, isd->image);
@@ -1955,14 +1964,14 @@ static bool image_save_as_check(bContext *C, wmOperator *op)
return WM_operator_filesel_ensure_ext_imtype(op, &isd->opts.im_format);
}
static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return image_save_as_exec(C, op);
}
ImageSaveData *isd = image_save_as_init(C, op);
if (isd == NULL) {
if (isd == nullptr) {
return OPERATOR_CANCELLED;
}
@@ -1971,14 +1980,14 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
return OPERATOR_RUNNING_MODAL;
}
static void image_save_as_cancel(bContext *UNUSED(C), wmOperator *op)
static void image_save_as_cancel(bContext * /*C*/, wmOperator *op)
{
image_save_as_free(op);
}
static bool image_save_as_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop, void *user_data)
{
ImageSaveData *isd = user_data;
ImageSaveData *isd = static_cast<ImageSaveData *>(user_data);
const char *prop_id = RNA_property_identifier(prop);
return !(STREQ(prop_id, "filepath") || STREQ(prop_id, "directory") ||
@@ -1988,10 +1997,10 @@ static bool image_save_as_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop, vo
(STREQ(prop_id, "save_as_render") && isd->image->source == IMA_SRC_VIEWER));
}
static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op)
static void image_save_as_draw(bContext * /*C*/, wmOperator *op)
{
uiLayout *layout = op->layout;
ImageSaveData *isd = op->customdata;
ImageSaveData *isd = static_cast<ImageSaveData *>(op->customdata);
PointerRNA imf_ptr;
const bool is_multiview = RNA_boolean_get(op->ptr, "show_multiview");
const bool save_as_render = RNA_boolean_get(op->ptr, "save_as_render");
@@ -2000,13 +2009,18 @@ static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op)
uiLayoutSetPropDecorate(layout, false);
/* Operator settings. */
uiDefAutoButsRNA(
layout, op->ptr, image_save_as_draw_check_prop, isd, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
uiDefAutoButsRNA(layout,
op->ptr,
image_save_as_draw_check_prop,
isd,
nullptr,
UI_BUT_LABEL_ALIGN_NONE,
false);
uiItemS(layout);
/* Image format settings. */
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &isd->opts.im_format, &imf_ptr);
RNA_pointer_create(nullptr, &RNA_ImageFormatSettings, &isd->opts.im_format, &imf_ptr);
uiTemplateImageSettings(layout, &imf_ptr, save_as_render);
if (!save_as_render) {
@@ -2029,7 +2043,7 @@ static bool image_save_as_poll(bContext *C)
}
if (G.is_rendering) {
/* no need to NULL check here */
/* no need to nullptr check here */
Image *ima = image_from_context(C);
if (ima->source == IMA_SRC_VIEWER) {
@@ -2094,7 +2108,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
* \{ */
/**
* \param iuser: Image user or NULL when called outside the image space.
* \param iuser: Image user or nullptr when called outside the image space.
*/
static bool image_file_format_writable(Image *ima, ImageUser *iuser)
{
@@ -2177,7 +2191,7 @@ static int image_save_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (!BKE_image_has_packedfile(ima) &&
(!BKE_image_has_filepath(ima) || !image_file_format_writable(ima, iuser)))
{
WM_operator_name_call(C, "IMAGE_OT_save_as", WM_OP_INVOKE_DEFAULT, NULL, event);
WM_operator_name_call(C, "IMAGE_OT_save_as", WM_OP_INVOKE_DEFAULT, nullptr, event);
return OPERATOR_CANCELLED;
}
return image_save_exec(C, op);
@@ -2208,12 +2222,12 @@ void IMAGE_OT_save(wmOperatorType *ot)
static int image_save_sequence_exec(bContext *C, wmOperator *op)
{
Image *image = image_from_context(C);
ImBuf *ibuf, *first_ibuf = NULL;
ImBuf *ibuf, *first_ibuf = nullptr;
int tot = 0;
char di[FILE_MAX];
struct MovieCacheIter *iter;
if (image == NULL) {
if (image == nullptr) {
return OPERATOR_CANCELLED;
}
@@ -2228,13 +2242,13 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
}
/* get total dirty buffers and first dirty buffer which is used for menu */
ibuf = NULL;
if (image->cache != NULL) {
ibuf = nullptr;
if (image->cache != nullptr) {
iter = IMB_moviecacheIter_new(image->cache);
while (!IMB_moviecacheIter_done(iter)) {
ibuf = IMB_moviecacheIter_getImBuf(iter);
if (ibuf != NULL && ibuf->userflags & IB_BITMAPDIRTY) {
if (first_ibuf == NULL) {
if (ibuf != nullptr && ibuf->userflags & IB_BITMAPDIRTY) {
if (first_ibuf == nullptr) {
first_ibuf = ibuf;
}
tot++;
@@ -2257,7 +2271,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
while (!IMB_moviecacheIter_done(iter)) {
ibuf = IMB_moviecacheIter_getImBuf(iter);
if (ibuf != NULL && ibuf->userflags & IB_BITMAPDIRTY) {
if (ibuf != nullptr && ibuf->userflags & IB_BITMAPDIRTY) {
if (0 == IMB_saveiff(ibuf, ibuf->filepath, IB_rect)) {
BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno));
break;
@@ -2342,7 +2356,9 @@ int ED_image_save_all_modified_info(const Main *bmain, ReportList *reports)
int num_saveable_images = 0;
for (Image *ima = bmain->images.first; ima; ima = ima->id.next) {
for (Image *ima = static_cast<Image *>(bmain->images.first); ima;
ima = static_cast<Image *>(ima->id.next))
{
bool is_format_writable;
if (image_should_be_saved(ima, &is_format_writable)) {
@@ -2399,7 +2415,9 @@ bool ED_image_save_all_modified(const bContext *C, ReportList *reports)
bool ok = true;
for (Image *ima = bmain->images.first; ima; ima = ima->id.next) {
for (Image *ima = static_cast<Image *>(bmain->images.first); ima;
ima = static_cast<Image *>(ima->id.next))
{
bool is_format_writable;
if (image_should_be_saved(ima, &is_format_writable)) {
@@ -2410,8 +2428,8 @@ bool ED_image_save_all_modified(const bContext *C, ReportList *reports)
if (image_has_valid_path(ima)) {
ImageSaveOptions opts;
Scene *scene = CTX_data_scene(C);
if (BKE_image_save_options_init(&opts, bmain, scene, ima, NULL, false, false)) {
bool saved_successfully = BKE_image_save(reports, bmain, ima, NULL, &opts);
if (BKE_image_save_options_init(&opts, bmain, scene, ima, nullptr, false, false)) {
bool saved_successfully = BKE_image_save(reports, bmain, ima, nullptr, &opts);
ok = ok && saved_successfully;
}
BKE_image_save_options_free(&opts);
@@ -2424,7 +2442,7 @@ bool ED_image_save_all_modified(const bContext *C, ReportList *reports)
static bool image_save_all_modified_poll(bContext *C)
{
int num_files = ED_image_save_all_modified_info(CTX_data_main(C), NULL);
int num_files = ED_image_save_all_modified_info(CTX_data_main(C), nullptr);
return num_files > 0;
}
@@ -2455,7 +2473,7 @@ void IMAGE_OT_save_all_modified(wmOperatorType *ot)
/** \name Reload Image Operator
* \{ */
static int image_reload_exec(bContext *C, wmOperator *UNUSED(op))
static int image_reload_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
Image *ima = image_from_context(C);
@@ -2504,17 +2522,17 @@ enum {
GEN_CONTEXT_PAINT_STENCIL = 2,
};
typedef struct ImageNewData {
struct ImageNewData {
PropertyPointerRNA pprop;
} ImageNewData;
};
static ImageNewData *image_new_init(bContext *C, wmOperator *op)
{
if (op->customdata) {
return op->customdata;
return static_cast<ImageNewData *>(op->customdata);
}
ImageNewData *data = MEM_callocN(sizeof(ImageNewData), __func__);
ImageNewData *data = static_cast<ImageNewData *>(MEM_callocN(sizeof(ImageNewData), __func__));
UI_context_active_but_prop_get_templateID(C, &data->pprop.ptr, &data->pprop.prop);
op->customdata = data;
return data;
@@ -2590,7 +2608,7 @@ static int image_new_exec(bContext *C, wmOperator *op)
PointerRNA imaptr;
RNA_id_pointer_create(&ima->id, &imaptr);
RNA_property_pointer_set(&data->pprop.ptr, data->pprop.prop, imaptr, NULL);
RNA_property_pointer_set(&data->pprop.ptr, data->pprop.prop, imaptr, nullptr);
RNA_property_update(C, &data->pprop.ptr, data->pprop.prop);
}
else if (sima) {
@@ -2602,7 +2620,7 @@ static int image_new_exec(bContext *C, wmOperator *op)
id_us_min(&ima->id);
}
BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE);
BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : nullptr, IMA_SIGNAL_USER_NEW_IMAGE);
WM_event_add_notifier(C, NC_IMAGE | NA_ADDED, ima);
@@ -2611,11 +2629,11 @@ static int image_new_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int image_new_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int image_new_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
/* Get property in advance, it doesn't work after WM_operator_props_dialog_popup. */
ImageNewData *data;
op->customdata = data = MEM_callocN(sizeof(ImageNewData), __func__);
op->customdata = data = static_cast<ImageNewData *>(MEM_callocN(sizeof(ImageNewData), __func__));
UI_context_active_but_prop_get_templateID(C, &data->pprop.ptr, &data->pprop.prop);
/* Better for user feedback. */
@@ -2623,7 +2641,7 @@ static int image_new_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
return WM_operator_props_dialog_popup(C, op, 300);
}
static void image_new_draw(bContext *UNUSED(C), wmOperator *op)
static void image_new_draw(bContext * /*C*/, wmOperator *op)
{
uiLayout *col;
uiLayout *layout = op->layout;
@@ -2638,24 +2656,24 @@ static void image_new_draw(bContext *UNUSED(C), wmOperator *op)
uiLayoutSetPropDecorate(layout, false);
col = uiLayoutColumn(layout, false);
uiItemR(col, op->ptr, "name", 0, NULL, ICON_NONE);
uiItemR(col, op->ptr, "width", 0, NULL, ICON_NONE);
uiItemR(col, op->ptr, "height", 0, NULL, ICON_NONE);
uiItemR(col, op->ptr, "color", 0, NULL, ICON_NONE);
uiItemR(col, op->ptr, "alpha", 0, NULL, ICON_NONE);
uiItemR(col, op->ptr, "generated_type", 0, NULL, ICON_NONE);
uiItemR(col, op->ptr, "float", 0, NULL, ICON_NONE);
uiItemR(col, op->ptr, "tiled", 0, NULL, ICON_NONE);
uiItemR(col, op->ptr, "name", 0, nullptr, ICON_NONE);
uiItemR(col, op->ptr, "width", 0, nullptr, ICON_NONE);
uiItemR(col, op->ptr, "height", 0, nullptr, ICON_NONE);
uiItemR(col, op->ptr, "color", 0, nullptr, ICON_NONE);
uiItemR(col, op->ptr, "alpha", 0, nullptr, ICON_NONE);
uiItemR(col, op->ptr, "generated_type", 0, nullptr, ICON_NONE);
uiItemR(col, op->ptr, "float", 0, nullptr, ICON_NONE);
uiItemR(col, op->ptr, "tiled", 0, nullptr, ICON_NONE);
#if 0
if (is_multiview) {
uiItemL(col[0], "", ICON_NONE);
uiItemR(col[1], op->ptr, "use_stereo_3d", 0, NULL, ICON_NONE);
uiItemR(col[1], op->ptr, "use_stereo_3d", 0, nullptr, ICON_NONE);
}
#endif
}
static void image_new_cancel(bContext *UNUSED(C), wmOperator *op)
static void image_new_cancel(bContext * /*C*/, wmOperator *op)
{
image_new_free(op);
}
@@ -2686,7 +2704,7 @@ void IMAGE_OT_new(wmOperatorType *ot)
prop = RNA_def_int(ot->srna, "height", 1024, 1, INT_MAX, "Height", "Image height", 1, 16384);
RNA_def_property_subtype(prop, PROP_PIXEL);
prop = RNA_def_float_color(
ot->srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f);
ot->srna, "color", 4, nullptr, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f);
RNA_def_property_subtype(prop, PROP_COLOR_GAMMA);
RNA_def_property_float_array_default(prop, default_color);
RNA_def_boolean(ot->srna, "alpha", 1, "Alpha", "Create an image with an alpha channel");
@@ -2718,11 +2736,11 @@ static int image_flip_exec(bContext *C, wmOperator *op)
{
Image *ima = image_from_context(C);
ImageUser iuser = image_user_from_context_and_active_tile(C, ima);
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, nullptr);
SpaceImage *sima = CTX_wm_space_image(C);
const bool is_paint = ((sima != NULL) && (sima->mode == SI_MODE_PAINT));
const bool is_paint = ((sima != nullptr) && (sima->mode == SI_MODE_PAINT));
if (ibuf == NULL) {
if (ibuf == nullptr) {
/* TODO: this should actually never happen, but does for render-results -> cleanup. */
return OPERATOR_CANCELLED;
}
@@ -2731,7 +2749,7 @@ static int image_flip_exec(bContext *C, wmOperator *op)
const bool use_flip_y = RNA_boolean_get(op->ptr, "use_flip_y");
if (!use_flip_x && !use_flip_y) {
BKE_image_release_ibuf(ima, ibuf, NULL);
BKE_image_release_ibuf(ima, ibuf, nullptr);
return OPERATOR_FINISHED;
}
@@ -2747,7 +2765,7 @@ static int image_flip_exec(bContext *C, wmOperator *op)
if (ibuf->float_buffer.data) {
float *float_pixels = ibuf->float_buffer.data;
float *orig_float_pixels = MEM_dupallocN(float_pixels);
float *orig_float_pixels = static_cast<float *>(MEM_dupallocN(float_pixels));
for (int x = 0; x < size_x; x++) {
const int source_pixel_x = use_flip_x ? size_x - x - 1 : x;
for (int y = 0; y < size_y; y++) {
@@ -2768,7 +2786,7 @@ static int image_flip_exec(bContext *C, wmOperator *op)
}
else if (ibuf->byte_buffer.data) {
uchar *char_pixels = ibuf->byte_buffer.data;
uchar *orig_char_pixels = MEM_dupallocN(char_pixels);
uchar *orig_char_pixels = static_cast<uchar *>(MEM_dupallocN(char_pixels));
for (int x = 0; x < size_x; x++) {
const int source_pixel_x = use_flip_x ? size_x - x - 1 : x;
for (int y = 0; y < size_y; y++) {
@@ -2784,7 +2802,7 @@ static int image_flip_exec(bContext *C, wmOperator *op)
MEM_freeN(orig_char_pixels);
}
else {
BKE_image_release_ibuf(ima, ibuf, NULL);
BKE_image_release_ibuf(ima, ibuf, nullptr);
return OPERATOR_CANCELLED;
}
@@ -2801,7 +2819,7 @@ static int image_flip_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
BKE_image_release_ibuf(ima, ibuf, NULL);
BKE_image_release_ibuf(ima, ibuf, nullptr);
return OPERATOR_FINISHED;
}
@@ -2838,7 +2856,7 @@ void IMAGE_OT_flip(wmOperatorType *ot)
static int image_clipboard_copy_exec(bContext *C, wmOperator *op)
{
Image *ima = image_from_context(C);
if (ima == NULL) {
if (ima == nullptr) {
return false;
}
@@ -2852,7 +2870,7 @@ static int image_clipboard_copy_exec(bContext *C, wmOperator *op)
void *lock;
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
if (ibuf == NULL) {
if (ibuf == nullptr) {
BKE_image_release_ibuf(ima, ibuf, lock);
WM_cursor_set(CTX_wm_window(C), WM_CURSOR_DEFAULT);
return OPERATOR_CANCELLED;
@@ -2915,7 +2933,7 @@ static int image_clipboard_paste_exec(bContext *C, wmOperator *op)
IMB_freeImBuf(ibuf);
ED_space_image_set(bmain, sima, ima, false);
BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE);
BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : nullptr, IMA_SIGNAL_USER_NEW_IMAGE);
WM_event_add_notifier(C, NC_IMAGE | NA_ADDED, ima);
WM_cursor_set(CTX_wm_window(C), WM_CURSOR_DEFAULT);
@@ -2958,9 +2976,9 @@ static int image_invert_exec(bContext *C, wmOperator *op)
{
Image *ima = image_from_context(C);
ImageUser iuser = image_user_from_context_and_active_tile(C, ima);
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, nullptr);
SpaceImage *sima = CTX_wm_space_image(C);
const bool is_paint = ((sima != NULL) && (sima->mode == SI_MODE_PAINT));
const bool is_paint = ((sima != nullptr) && (sima->mode == SI_MODE_PAINT));
/* flags indicate if this channel should be inverted */
const bool r = RNA_boolean_get(op->ptr, "invert_r");
@@ -2970,7 +2988,7 @@ static int image_invert_exec(bContext *C, wmOperator *op)
size_t i;
if (ibuf == NULL) {
if (ibuf == nullptr) {
/* TODO: this should actually never happen, but does for render-results -> cleanup */
return OPERATOR_CANCELLED;
}
@@ -3023,7 +3041,7 @@ static int image_invert_exec(bContext *C, wmOperator *op)
}
}
else {
BKE_image_release_ibuf(ima, ibuf, NULL);
BKE_image_release_ibuf(ima, ibuf, nullptr);
return OPERATOR_CANCELLED;
}
@@ -3040,7 +3058,7 @@ static int image_invert_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
BKE_image_release_ibuf(ima, ibuf, NULL);
BKE_image_release_ibuf(ima, ibuf, nullptr);
return OPERATOR_FINISHED;
}
@@ -3078,16 +3096,16 @@ void IMAGE_OT_invert(wmOperatorType *ot)
/** \name Scale Operator
* \{ */
static int image_scale_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int image_scale_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
Image *ima = image_from_context(C);
ImageUser iuser = image_user_from_context_and_active_tile(C, ima);
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "size");
if (!RNA_property_is_set(op->ptr, prop)) {
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, nullptr);
const int size[2] = {ibuf->x, ibuf->y};
RNA_property_int_set_array(op->ptr, prop, size);
BKE_image_release_ibuf(ima, ibuf, NULL);
BKE_image_release_ibuf(ima, ibuf, nullptr);
}
return WM_operator_props_dialog_popup(C, op, 200);
}
@@ -3096,11 +3114,11 @@ static int image_scale_exec(bContext *C, wmOperator *op)
{
Image *ima = image_from_context(C);
ImageUser iuser = image_user_from_context_and_active_tile(C, ima);
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, nullptr);
SpaceImage *sima = CTX_wm_space_image(C);
const bool is_paint = ((sima != NULL) && (sima->mode == SI_MODE_PAINT));
const bool is_paint = ((sima != nullptr) && (sima->mode == SI_MODE_PAINT));
if (ibuf == NULL) {
if (ibuf == nullptr) {
/* TODO: this should actually never happen, but does for render-results -> cleanup */
return OPERATOR_CANCELLED;
}
@@ -3125,7 +3143,7 @@ static int image_scale_exec(bContext *C, wmOperator *op)
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
IMB_scaleImBuf(ibuf, size[0], size[1]);
BKE_image_mark_dirty(ima, ibuf);
BKE_image_release_ibuf(ima, ibuf, NULL);
BKE_image_release_ibuf(ima, ibuf, nullptr);
ED_image_undo_push_end();
@@ -3150,7 +3168,7 @@ void IMAGE_OT_resize(wmOperatorType *ot)
ot->poll = image_from_context_has_data_poll_active_tile;
/* properties */
RNA_def_int_vector(ot->srna, "size", 2, NULL, 1, INT_MAX, "Size", "", 1, SHRT_MAX);
RNA_def_int_vector(ot->srna, "size", 2, nullptr, 1, INT_MAX, "Size", "", 1, SHRT_MAX);
/* flags */
ot->flag = OPTYPE_REGISTER;
@@ -3229,7 +3247,7 @@ static int image_unpack_exec(bContext *C, wmOperator *op)
if (RNA_struct_property_is_set(op->ptr, "id")) {
char imaname[MAX_ID_NAME - 2];
RNA_string_get(op->ptr, "id", imaname);
ima = BLI_findstring(&bmain->images, imaname, offsetof(ID, name) + 2);
ima = static_cast<Image *>(BLI_findstring(&bmain->images, imaname, offsetof(ID, name) + 2));
if (!ima) {
ima = image_from_context(C);
}
@@ -3253,14 +3271,14 @@ static int image_unpack_exec(bContext *C, wmOperator *op)
/* XXX BKE_packedfile_unpack_image frees image buffers */
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
BKE_packedfile_unpack_image(CTX_data_main(C), op->reports, ima, method);
BKE_packedfile_unpack_image(CTX_data_main(C), op->reports, ima, ePF_FileStatus(method));
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
return OPERATOR_FINISHED;
}
static int image_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int image_unpack_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
Image *ima = image_from_context(C);
@@ -3290,7 +3308,7 @@ static int image_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
"textures",
BKE_image_has_packedfile(ima) ?
((ImagePackedFile *)ima->packedfiles.first)->packedfile :
NULL);
nullptr);
return OPERATOR_FINISHED;
}
@@ -3314,7 +3332,7 @@ void IMAGE_OT_unpack(wmOperatorType *ot)
ot->srna, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "Method", "How to unpack");
/* XXX, weak!, will fail with library, name collisions */
RNA_def_string(
ot->srna, "id", NULL, MAX_ID_NAME - 2, "Image Name", "Image data-block name to unpack");
ot->srna, "id", nullptr, MAX_ID_NAME - 2, "Image Name", "Image data-block name to unpack");
}
/** \} */
@@ -3328,7 +3346,7 @@ bool ED_space_image_get_position(SpaceImage *sima, ARegion *region, int mval[2],
void *lock;
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, 0);
if (ibuf == NULL) {
if (ibuf == nullptr) {
ED_space_image_release_buffer(sima, ibuf, lock);
return false;
}
@@ -3345,18 +3363,18 @@ bool ED_space_image_color_sample(
if (r_is_data) {
*r_is_data = false;
}
if (sima->image == NULL) {
if (sima->image == nullptr) {
return false;
}
float uv[2];
UI_view2d_region_to_view(&region->v2d, mval[0], mval[1], &uv[0], &uv[1]);
int tile = BKE_image_get_tile_from_pos(sima->image, uv, uv, NULL);
int tile = BKE_image_get_tile_from_pos(sima->image, uv, uv, nullptr);
void *lock;
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, tile);
bool ret = false;
if (ibuf == NULL) {
if (ibuf == nullptr) {
ED_space_image_release_buffer(sima, ibuf, lock);
return false;
}
@@ -3442,7 +3460,7 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, tile);
Histogram *hist = &sima->sample_line_hist;
if (ibuf == NULL) {
if (ibuf == nullptr) {
ED_space_image_release_buffer(sima, ibuf, lock);
return OPERATOR_CANCELLED;
}
@@ -3515,7 +3533,7 @@ void IMAGE_OT_curves_point_set(wmOperatorType *ot)
static const EnumPropertyItem point_items[] = {
{0, "BLACK_POINT", 0, "Black Point", ""},
{1, "WHITE_POINT", 0, "White Point", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
@@ -3564,7 +3582,7 @@ static int image_cycle_render_slot_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, nullptr);
/* no undo push for browsing existing */
RenderSlot *slot = BKE_image_get_renderslot(ima, ima->render_slot);
@@ -3598,7 +3616,7 @@ void IMAGE_OT_cycle_render_slot(wmOperatorType *ot)
/** \name Clear Render Slot Operator
* \{ */
static int image_clear_render_slot_exec(bContext *C, wmOperator *UNUSED(op))
static int image_clear_render_slot_exec(bContext *C, wmOperator * /*op*/)
{
Image *ima = image_from_context(C);
ImageUser *iuser = image_user_from_context(C);
@@ -3607,7 +3625,7 @@ static int image_clear_render_slot_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, nullptr);
return OPERATOR_FINISHED;
}
@@ -3633,14 +3651,14 @@ void IMAGE_OT_clear_render_slot(wmOperatorType *ot)
/** \name Add Render Slot Operator
* \{ */
static int image_add_render_slot_exec(bContext *C, wmOperator *UNUSED(op))
static int image_add_render_slot_exec(bContext *C, wmOperator * /*op*/)
{
Image *ima = image_from_context(C);
RenderSlot *slot = BKE_image_add_renderslot(ima, NULL);
RenderSlot *slot = BKE_image_add_renderslot(ima, nullptr);
ima->render_slot = BLI_findindex(&ima->renderslots, slot);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, nullptr);
return OPERATOR_FINISHED;
}
@@ -3666,7 +3684,7 @@ void IMAGE_OT_add_render_slot(wmOperatorType *ot)
/** \name Remove Render Slot Operator
* \{ */
static int image_remove_render_slot_exec(bContext *C, wmOperator *UNUSED(op))
static int image_remove_render_slot_exec(bContext *C, wmOperator * /*op*/)
{
Image *ima = image_from_context(C);
ImageUser *iuser = image_user_from_context(C);
@@ -3675,7 +3693,7 @@ static int image_remove_render_slot_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, nullptr);
return OPERATOR_FINISHED;
}
@@ -3819,7 +3837,7 @@ void IMAGE_OT_change_frame(wmOperatorType *ot)
/* Reload cached render results... */
/* goes over all scenes, reads render layers */
static int image_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
static int image_read_viewlayers_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
@@ -3827,7 +3845,7 @@ static int image_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
Image *ima;
ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result");
if (sima->image == NULL) {
if (sima->image == nullptr) {
ED_space_image_set(bmain, sima, ima, false);
}
@@ -3863,7 +3881,7 @@ static int render_border_exec(bContext *C, wmOperator *op)
Render *re = RE_GetSceneRender(scene);
SpaceImage *sima = CTX_wm_space_image(C);
if (re == NULL) {
if (re == nullptr) {
/* Shouldn't happen, but better be safe close to the release. */
return OPERATOR_CANCELLED;
}
@@ -3912,7 +3930,7 @@ static int render_border_exec(bContext *C, wmOperator *op)
}
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
return OPERATOR_FINISHED;
}
@@ -3944,11 +3962,11 @@ void IMAGE_OT_render_border(wmOperatorType *ot)
/** \name Clear Render Border Operator
* \{ */
static int clear_render_border_exec(bContext *C, wmOperator *UNUSED(op))
static int clear_render_border_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
scene->r.mode &= ~R_BORDER;
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
BLI_rctf_init(&scene->r.border, 0.0f, 1.0f, 0.0f, 1.0f);
return OPERATOR_FINISHED;
}
@@ -3994,38 +4012,38 @@ static void draw_fill_tile(PointerRNA *ptr, uiLayout *layout)
uiLayoutSetPropDecorate(layout, false);
uiLayout *col = uiLayoutColumn(layout, false);
uiItemR(col, ptr, "color", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "width", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "height", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "alpha", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "generated_type", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "float", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "color", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "width", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "height", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "alpha", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "generated_type", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "float", 0, nullptr, ICON_NONE);
}
static void tile_fill_init(PointerRNA *ptr, Image *ima, ImageTile *tile)
{
ImageUser iuser;
BKE_imageuser_default(&iuser);
if (tile != NULL) {
if (tile != nullptr) {
iuser.tile = tile->tile_number;
}
/* Acquire ibuf to get the default values.
* If the specified tile has no ibuf, try acquiring the main tile instead
* (unless the specified tile already was the first tile). */
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
if (ibuf == NULL && (tile != NULL) && (tile != ima->tiles.first)) {
ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, nullptr);
if (ibuf == nullptr && (tile != nullptr) && (tile != ima->tiles.first)) {
ibuf = BKE_image_acquire_ibuf(ima, nullptr, nullptr);
}
if (ibuf != NULL) {
if (ibuf != nullptr) {
/* Initialize properties from reference tile. */
RNA_int_set(ptr, "width", ibuf->x);
RNA_int_set(ptr, "height", ibuf->y);
RNA_boolean_set(ptr, "float", ibuf->float_buffer.data != NULL);
RNA_boolean_set(ptr, "float", ibuf->float_buffer.data != nullptr);
RNA_boolean_set(ptr, "alpha", ibuf->planes > 24);
BKE_image_release_ibuf(ima, ibuf, NULL);
BKE_image_release_ibuf(ima, ibuf, nullptr);
}
}
@@ -4034,7 +4052,7 @@ static void def_fill_tile(StructOrFunctionRNA *srna)
PropertyRNA *prop;
static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
prop = RNA_def_float_color(
srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f);
srna, "color", 4, nullptr, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f);
RNA_def_property_subtype(prop, PROP_COLOR_GAMMA);
RNA_def_property_float_array_default(prop, default_color);
RNA_def_enum(srna,
@@ -4058,7 +4076,7 @@ static bool tile_add_poll(bContext *C)
{
Image *ima = CTX_data_edit_image(C);
return (ima != NULL && ima->source == IMA_SRC_TILED && BKE_image_has_ibuf(ima, NULL));
return (ima != nullptr && ima->source == IMA_SRC_TILED && BKE_image_has_ibuf(ima, nullptr));
}
static int tile_add_exec(bContext *C, wmOperator *op)
@@ -4074,16 +4092,16 @@ static int tile_add_exec(bContext *C, wmOperator *op)
}
bool fill_tile = RNA_boolean_get(op->ptr, "fill");
char *label = RNA_string_get_alloc(op->ptr, "label", NULL, 0, NULL);
char *label = RNA_string_get_alloc(op->ptr, "label", nullptr, 0, nullptr);
/* BKE_image_add_tile assumes a pre-sorted list of tiles. */
BKE_image_sort_tiles(ima);
ImageTile *last_tile_created = NULL;
ImageTile *last_tile_created = nullptr;
for (int tile_number = start_tile; tile_number <= end_tile; tile_number++) {
ImageTile *tile = BKE_image_add_tile(ima, tile_number, label);
if (tile != NULL) {
if (tile != nullptr) {
if (fill_tile) {
do_fill_tile(op->ptr, ima, tile);
}
@@ -4100,11 +4118,11 @@ static int tile_add_exec(bContext *C, wmOperator *op)
ima->active_tile_index = BLI_findindex(&ima->tiles, last_tile_created);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, nullptr);
return OPERATOR_FINISHED;
}
static int tile_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int tile_add_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
Image *ima = CTX_data_edit_image(C);
@@ -4113,12 +4131,12 @@ static int tile_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
int next_number = 0;
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
next_number = tile->tile_number + 1;
if (tile->next == NULL || tile->next->tile_number > next_number) {
if (tile->next == nullptr || tile->next->tile_number > next_number) {
break;
}
}
ImageTile *tile = BLI_findlink(&ima->tiles, ima->active_tile_index);
ImageTile *tile = static_cast<ImageTile *>(BLI_findlink(&ima->tiles, ima->active_tile_index));
tile_fill_init(op->ptr, ima, tile);
RNA_int_set(op->ptr, "number", next_number);
@@ -4128,7 +4146,7 @@ static int tile_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
return WM_operator_props_dialog_popup(C, op, 300);
}
static void tile_add_draw(bContext *UNUSED(C), wmOperator *op)
static void tile_add_draw(bContext * /*C*/, wmOperator *op)
{
uiLayout *col;
uiLayout *layout = op->layout;
@@ -4137,10 +4155,10 @@ static void tile_add_draw(bContext *UNUSED(C), wmOperator *op)
uiLayoutSetPropDecorate(layout, false);
col = uiLayoutColumn(layout, false);
uiItemR(col, op->ptr, "number", 0, NULL, ICON_NONE);
uiItemR(col, op->ptr, "count", 0, NULL, ICON_NONE);
uiItemR(col, op->ptr, "label", 0, NULL, ICON_NONE);
uiItemR(layout, op->ptr, "fill", 0, NULL, ICON_NONE);
uiItemR(col, op->ptr, "number", 0, nullptr, ICON_NONE);
uiItemR(col, op->ptr, "count", 0, nullptr, ICON_NONE);
uiItemR(col, op->ptr, "label", 0, nullptr, ICON_NONE);
uiItemR(layout, op->ptr, "fill", 0, nullptr, ICON_NONE);
if (RNA_boolean_get(op->ptr, "fill")) {
draw_fill_tile(op->ptr, layout);
@@ -4173,7 +4191,7 @@ void IMAGE_OT_tile_add(wmOperatorType *ot)
1001,
1099);
RNA_def_int(ot->srna, "count", 1, 1, INT_MAX, "Count", "How many tiles to add", 1, 1000);
RNA_def_string(ot->srna, "label", NULL, 0, "Label", "Optional tile label");
RNA_def_string(ot->srna, "label", nullptr, 0, "Label", "Optional tile label");
RNA_def_boolean(ot->srna, "fill", true, "Fill", "Fill new tile with a generated image");
def_fill_tile(ot->srna);
}
@@ -4188,14 +4206,14 @@ static bool tile_remove_poll(bContext *C)
{
Image *ima = CTX_data_edit_image(C);
return (ima != NULL && ima->source == IMA_SRC_TILED && !BLI_listbase_is_single(&ima->tiles));
return (ima != nullptr && ima->source == IMA_SRC_TILED && !BLI_listbase_is_single(&ima->tiles));
}
static int tile_remove_exec(bContext *C, wmOperator *UNUSED(op))
static int tile_remove_exec(bContext *C, wmOperator * /*op*/)
{
Image *ima = CTX_data_edit_image(C);
ImageTile *tile = BLI_findlink(&ima->tiles, ima->active_tile_index);
ImageTile *tile = static_cast<ImageTile *>(BLI_findlink(&ima->tiles, ima->active_tile_index));
if (!BKE_image_remove_tile(ima, tile)) {
return OPERATOR_CANCELLED;
}
@@ -4203,7 +4221,7 @@ static int tile_remove_exec(bContext *C, wmOperator *UNUSED(op))
/* Ensure that the active index is valid. */
ima->active_tile_index = min_ii(ima->active_tile_index, BLI_listbase_count(&ima->tiles) - 1);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, nullptr);
return OPERATOR_FINISHED;
}
@@ -4233,9 +4251,9 @@ static bool tile_fill_poll(bContext *C)
{
Image *ima = CTX_data_edit_image(C);
if (ima != NULL && ima->source == IMA_SRC_TILED) {
if (ima != nullptr && ima->source == IMA_SRC_TILED) {
/* Filling secondary tiles is only allowed if the primary tile exists. */
return (ima->active_tile_index == 0) || BKE_image_has_ibuf(ima, NULL);
return (ima->active_tile_index == 0) || BKE_image_has_ibuf(ima, nullptr);
}
return false;
}
@@ -4244,24 +4262,24 @@ static int tile_fill_exec(bContext *C, wmOperator *op)
{
Image *ima = CTX_data_edit_image(C);
ImageTile *tile = BLI_findlink(&ima->tiles, ima->active_tile_index);
ImageTile *tile = static_cast<ImageTile *>(BLI_findlink(&ima->tiles, ima->active_tile_index));
if (!do_fill_tile(op->ptr, ima, tile)) {
return OPERATOR_CANCELLED;
}
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, nullptr);
return OPERATOR_FINISHED;
}
static int tile_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int tile_fill_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
tile_fill_init(op->ptr, CTX_data_edit_image(C), NULL);
tile_fill_init(op->ptr, CTX_data_edit_image(C), nullptr);
return WM_operator_props_dialog_popup(C, op, 300);
}
static void tile_fill_draw(bContext *UNUSED(C), wmOperator *op)
static void tile_fill_draw(bContext * /*C*/, wmOperator *op)
{
draw_fill_tile(op->ptr, op->layout);
}

View File

@@ -28,10 +28,10 @@
#include "ED_image.h"
typedef struct ImageFrame {
struct ImageFrame {
struct ImageFrame *next, *prev;
int framenr;
} ImageFrame;
};
/**
* Get a list of frames from the list of image files matching the first file name sequence pattern.
@@ -43,7 +43,7 @@ static void image_sequence_get_frame_ranges(wmOperator *op, ListBase *ranges)
{
char dir[FILE_MAXDIR];
const bool do_frame_range = RNA_boolean_get(op->ptr, "use_sequence_detection");
ImageFrameRange *range = NULL;
ImageFrameRange *range = nullptr;
int range_first_frame = 0;
/* Track when a new series of files are found that aren't compatible with the previous file. */
char base_head[FILE_MAX], base_tail[FILE_MAX];
@@ -52,15 +52,15 @@ static void image_sequence_get_frame_ranges(wmOperator *op, ListBase *ranges)
RNA_BEGIN (op->ptr, itemptr, "files") {
char head[FILE_MAX], tail[FILE_MAX];
ushort digits;
char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0, NULL);
ImageFrame *frame = MEM_callocN(sizeof(ImageFrame), "image_frame");
char *filename = RNA_string_get_alloc(&itemptr, "name", nullptr, 0, nullptr);
ImageFrame *frame = static_cast<ImageFrame *>(MEM_callocN(sizeof(ImageFrame), "image_frame"));
/* use the first file in the list as base filename */
frame->framenr = BLI_path_sequence_decode(
filename, head, sizeof(head), tail, sizeof(tail), &digits);
/* still in the same sequence */
if (do_frame_range && (range != NULL) && STREQLEN(base_head, head, FILE_MAX) &&
if (do_frame_range && (range != nullptr) && STREQLEN(base_head, head, FILE_MAX) &&
STREQLEN(base_tail, tail, FILE_MAX))
{
/* Set filepath to first frame in the range. */
@@ -71,7 +71,7 @@ static void image_sequence_get_frame_ranges(wmOperator *op, ListBase *ranges)
}
else {
/* start a new frame range */
range = MEM_callocN(sizeof(*range), __func__);
range = static_cast<ImageFrameRange *>(MEM_callocN(sizeof(*range), __func__));
BLI_path_join(range->filepath, sizeof(range->filepath), dir, filename);
BLI_addtail(ranges, range);
@@ -89,8 +89,8 @@ static void image_sequence_get_frame_ranges(wmOperator *op, ListBase *ranges)
static int image_cmp_frame(const void *a, const void *b)
{
const ImageFrame *frame_a = a;
const ImageFrame *frame_b = b;
const ImageFrame *frame_a = static_cast<const ImageFrame *>(a);
const ImageFrame *frame_b = static_cast<const ImageFrame *>(b);
if (frame_a->framenr < frame_b->framenr) {
return -1;
@@ -123,12 +123,12 @@ static void image_detect_frame_range(ImageFrameRange *range, const bool detect_u
/* Image Sequence */
BLI_listbase_sort(&range->frames, image_cmp_frame);
ImageFrame *frame = range->frames.first;
if (frame != NULL) {
ImageFrame *frame = static_cast<ImageFrame *>(range->frames.first);
if (frame != nullptr) {
int frame_curr = frame->framenr;
range->offset = frame_curr;
while (frame != NULL && (frame->framenr == frame_curr)) {
while (frame != nullptr && (frame->framenr == frame_curr)) {
frame_curr++;
frame = frame->next;
}
@@ -167,7 +167,7 @@ ListBase ED_image_filesel_detect_sequences(Main *bmain, wmOperator *op, const bo
}
/* Filepath property for drag & drop etc. */
else {
ImageFrameRange *range = MEM_callocN(sizeof(*range), __func__);
ImageFrameRange *range = static_cast<ImageFrameRange *>(MEM_callocN(sizeof(*range), __func__));
BLI_addtail(&ranges, range);
STRNCPY(range->filepath, filepath);

View File

@@ -66,7 +66,7 @@ static void image_scopes_tag_refresh(ScrArea *area)
ARegion *region;
/* only while histogram is visible */
for (region = area->regionbase.first; region; region = region->next) {
for (region = static_cast<ARegion *>(area->regionbase.first); region; region = region->next) {
if (region->regiontype == RGN_TYPE_TOOL_PROPS && region->flag & RGN_FLAG_HIDDEN) {
return;
}
@@ -94,12 +94,12 @@ static void image_user_refresh_scene(const bContext *C, SpaceImage *sima)
/* ******************** default callbacks for image space ***************** */
static SpaceLink *image_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *image_create(const ScrArea * /*area*/, const Scene * /*scene*/)
{
ARegion *region;
SpaceImage *simage;
simage = MEM_callocN(sizeof(SpaceImage), "initimage");
simage = static_cast<SpaceImage *>(MEM_callocN(sizeof(SpaceImage), "initimage"));
simage->spacetype = SPACE_IMAGE;
simage->zoom = 1.0f;
simage->lock = true;
@@ -122,14 +122,14 @@ static SpaceLink *image_create(const ScrArea *UNUSED(area), const Scene *UNUSED(
simage->mask_info = *DNA_struct_default_get(MaskSpaceInfo);
/* header */
region = MEM_callocN(sizeof(ARegion), "header for image");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "header for image"));
BLI_addtail(&simage->regionbase, region);
region->regiontype = RGN_TYPE_HEADER;
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
/* tool header */
region = MEM_callocN(sizeof(ARegion), "tool header for image");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "tool header for image"));
BLI_addtail(&simage->regionbase, region);
region->regiontype = RGN_TYPE_TOOL_HEADER;
@@ -137,7 +137,7 @@ static SpaceLink *image_create(const ScrArea *UNUSED(area), const Scene *UNUSED(
region->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER;
/* buttons/list view */
region = MEM_callocN(sizeof(ARegion), "buttons for image");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "buttons for image"));
BLI_addtail(&simage->regionbase, region);
region->regiontype = RGN_TYPE_UI;
@@ -145,7 +145,7 @@ static SpaceLink *image_create(const ScrArea *UNUSED(area), const Scene *UNUSED(
region->flag = RGN_FLAG_HIDDEN;
/* scopes/uv sculpt/paint */
region = MEM_callocN(sizeof(ARegion), "buttons for image");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "buttons for image"));
BLI_addtail(&simage->regionbase, region);
region->regiontype = RGN_TYPE_TOOLS;
@@ -153,7 +153,7 @@ static SpaceLink *image_create(const ScrArea *UNUSED(area), const Scene *UNUSED(
region->flag = RGN_FLAG_HIDDEN;
/* main area */
region = MEM_callocN(sizeof(ARegion), "main area for image");
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "main area for image"));
BLI_addtail(&simage->regionbase, region);
region->regiontype = RGN_TYPE_WINDOW;
@@ -170,7 +170,7 @@ static void image_free(SpaceLink *sl)
}
/* spacetype; init callback, add handlers */
static void image_init(wmWindowManager *UNUSED(wm), ScrArea *area)
static void image_init(wmWindowManager * /*wm*/, ScrArea *area)
{
ListBase *lb = WM_dropboxmap_find("Image", SPACE_IMAGE, 0);
@@ -180,7 +180,7 @@ static void image_init(wmWindowManager *UNUSED(wm), ScrArea *area)
static SpaceLink *image_duplicate(SpaceLink *sl)
{
SpaceImage *simagen = MEM_dupallocN(sl);
SpaceImage *simagen = static_cast<SpaceImage *>(MEM_dupallocN(sl));
/* clear or remove stuff from old */
@@ -258,7 +258,7 @@ static bool image_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
return false;
}
if (drag->type == WM_DRAG_PATH) {
const eFileSel_File_Types file_type = WM_drag_get_path_file_type(drag);
const eFileSel_File_Types file_type = eFileSel_File_Types(WM_drag_get_path_file_type(drag));
if (ELEM(file_type, 0, FILE_TYPE_IMAGE, FILE_TYPE_MOVIE)) {
return true;
}
@@ -266,7 +266,7 @@ static bool image_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
return false;
}
static void image_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop)
static void image_drop_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
{
/* copy drag path to properties */
RNA_string_set(drop->ptr, "filepath", WM_drag_get_path(drag));
@@ -277,7 +277,7 @@ static void image_dropboxes(void)
{
ListBase *lb = WM_dropboxmap_find("Image", SPACE_IMAGE, 0);
WM_dropbox_add(lb, "IMAGE_OT_open", image_drop_poll, image_drop_copy, NULL, NULL);
WM_dropbox_add(lb, "IMAGE_OT_open", image_drop_poll, image_drop_copy, nullptr, nullptr);
}
/**
@@ -287,7 +287,7 @@ static void image_dropboxes(void)
static void image_refresh(const bContext *C, ScrArea *area)
{
Scene *scene = CTX_data_scene(C);
SpaceImage *sima = area->spacedata.first;
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
Image *ima;
ima = ED_space_image(sima);
@@ -439,7 +439,7 @@ static void image_listener(const wmSpaceTypeListenerParams *params)
}
}
const char *image_context_dir[] = {"edit_image", "edit_mask", NULL};
const char *image_context_dir[] = {"edit_image", "edit_mask", nullptr};
static int /*eContextResult*/ image_context(const bContext *C,
const char *member,
@@ -528,8 +528,8 @@ static void IMAGE_GGT_navigate(wmGizmoGroupType *gzgt)
static void image_widgets(void)
{
wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(
&(const struct wmGizmoMapType_Params){SPACE_IMAGE, RGN_TYPE_WINDOW});
const wmGizmoMapType_Params params{SPACE_IMAGE, RGN_TYPE_WINDOW};
wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&params);
WM_gizmogrouptype_append(IMAGE_GGT_gizmo2d);
WM_gizmogrouptype_append(IMAGE_GGT_gizmo2d_translate);
@@ -634,7 +634,7 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
SpaceImage *sima = CTX_wm_space_image(C);
Object *obedit = CTX_data_edit_object(C);
Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
Mask *mask = NULL;
Mask *mask = nullptr;
Scene *scene = CTX_data_scene(C);
View2D *v2d = &region->v2d;
Image *image = ED_space_image(sima);
@@ -707,11 +707,10 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
ED_mask_draw_region(depsgraph,
mask,
region,
/* Mask overlay is drawn by image/overlay engine. */
region, /* Mask overlay is drawn by image/overlay engine. */
sima->mask_info.draw_flag & ~MASK_DRAWFLAG_OVERLAY,
sima->mask_info.draw_type,
sima->mask_info.overlay_mode,
eMaskOverlayMode(sima->mask_info.overlay_mode),
sima->mask_info.blend_factor,
width,
height,
@@ -719,7 +718,7 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
aspy,
true,
false,
NULL,
nullptr,
C);
}
@@ -756,7 +755,7 @@ static void image_main_region_listener(const wmRegionListenerParams *params)
break;
case NC_MATERIAL:
if (wmn->data == ND_SHADING_LINKS) {
SpaceImage *sima = area->spacedata.first;
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
if (sima->iuser.scene && (sima->iuser.scene->toolsettings->uv_flag & UV_SHOW_SAME_IMAGE)) {
ED_region_tag_redraw(region);
@@ -788,7 +787,7 @@ static void image_buttons_region_init(wmWindowManager *wm, ARegion *region)
static void image_buttons_region_layout(const bContext *C, ARegion *region)
{
const enum eContextObjectMode mode = CTX_data_mode_enum(C);
const char *contexts_base[3] = {NULL};
const char *contexts_base[3] = {nullptr};
const char **contexts = contexts_base;
@@ -808,7 +807,7 @@ static void image_buttons_region_layout(const bContext *C, ARegion *region)
break;
}
ED_region_panels_layout_ex(C, region, &region->type->paneltypes, contexts_base, NULL);
ED_region_panels_layout_ex(C, region, &region->type->paneltypes, contexts_base, nullptr);
}
static void image_buttons_region_draw(const bContext *C, ARegion *region)
@@ -945,7 +944,7 @@ static void image_tools_region_listener(const wmRegionListenerParams *params)
/************************* header region **************************/
/* add handlers, stuff you only do once or on area/region changes */
static void image_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
static void image_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
{
ED_region_header_init(region);
}
@@ -953,7 +952,7 @@ static void image_header_region_init(wmWindowManager *UNUSED(wm), ARegion *regio
static void image_header_region_draw(const bContext *C, ARegion *region)
{
ScrArea *area = CTX_wm_area(C);
SpaceImage *sima = area->spacedata.first;
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
image_user_refresh_scene(C, sima);
@@ -991,9 +990,7 @@ static void image_header_region_listener(const wmRegionListenerParams *params)
}
}
static void image_id_remap(ScrArea *UNUSED(area),
SpaceLink *slink,
const struct IDRemapper *mappings)
static void image_id_remap(ScrArea * /*area*/, SpaceLink *slink, const struct IDRemapper *mappings)
{
SpaceImage *simg = (SpaceImage *)slink;
@@ -1014,13 +1011,13 @@ static void image_id_remap(ScrArea *UNUSED(area),
*/
static int image_space_subtype_get(ScrArea *area)
{
SpaceImage *sima = area->spacedata.first;
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
return sima->mode == SI_MODE_UV ? SI_MODE_UV : SI_MODE_VIEW;
}
static void image_space_subtype_set(ScrArea *area, int value)
{
SpaceImage *sima = area->spacedata.first;
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
if (value == SI_MODE_UV) {
if (sima->mode != SI_MODE_UV) {
sima->mode_prev = sima->mode;
@@ -1032,32 +1029,32 @@ static void image_space_subtype_set(ScrArea *area, int value)
}
}
static void image_space_subtype_item_extend(bContext *UNUSED(C),
static void image_space_subtype_item_extend(bContext * /*C*/,
EnumPropertyItem **item,
int *totitem)
{
RNA_enum_items_add(item, totitem, rna_enum_space_image_mode_items);
}
static void image_space_blend_read_data(BlendDataReader *UNUSED(reader), SpaceLink *sl)
static void image_space_blend_read_data(BlendDataReader * /*reader*/, SpaceLink *sl)
{
SpaceImage *sima = (SpaceImage *)sl;
sima->iuser.scene = NULL;
sima->scopes.waveform_1 = NULL;
sima->scopes.waveform_2 = NULL;
sima->scopes.waveform_3 = NULL;
sima->scopes.vecscope = NULL;
sima->iuser.scene = nullptr;
sima->scopes.waveform_1 = nullptr;
sima->scopes.waveform_2 = nullptr;
sima->scopes.waveform_3 = nullptr;
sima->scopes.vecscope = nullptr;
sima->scopes.ok = 0;
/* WARNING: gpencil data is no longer stored directly in sima after 2.5
* so sacrifice a few old files for now to avoid crashes with new files!
* committed: r28002 */
/* WARNING: gpencil data is no longer stored directly in sima after 2.5
* so sacrifice a few old files for now to avoid crashes with new files!
* committed: r28002 */
#if 0
sima->gpd = newdataadr(fd, sima->gpd);
if (sima->gpd) {
BKE_gpencil_blend_read_data(fd, sima->gpd);
}
sima->gpd = newdataadr(fd, sima->gpd);
if (sima->gpd) {
BKE_gpencil_blend_read_data(fd, sima->gpd);
}
#endif
}
@@ -1083,7 +1080,7 @@ static void image_space_blend_write(BlendWriter *writer, SpaceLink *sl)
void ED_spacetype_image(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype image");
SpaceType *st = static_cast<SpaceType *>(MEM_callocN(sizeof(SpaceType), "spacetype image"));
ARegionType *art;
st->spaceid = SPACE_IMAGE;
@@ -1109,7 +1106,7 @@ void ED_spacetype_image(void)
st->blend_write = image_space_blend_write;
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype image region"));
art->regionid = RGN_TYPE_WINDOW;
art->keymapflag = ED_KEYMAP_GIZMO | ED_KEYMAP_TOOL | ED_KEYMAP_FRAMES | ED_KEYMAP_GPENCIL;
art->init = image_main_region_init;
@@ -1118,7 +1115,7 @@ void ED_spacetype_image(void)
BLI_addhead(&st->regiontypes, art);
/* regions: list-view/buttons/scopes */
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype image region"));
art->regionid = RGN_TYPE_UI;
art->prefsizex = UI_SIDEBAR_PANEL_WIDTH;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
@@ -1133,7 +1130,7 @@ void ED_spacetype_image(void)
image_buttons_register(art);
/* regions: tool(bar) */
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype image region"));
art->regionid = RGN_TYPE_TOOLS;
art->prefsizex = (int)UI_TOOLBAR_WIDTH;
art->prefsizey = 50; /* XXX */
@@ -1146,7 +1143,8 @@ void ED_spacetype_image(void)
BLI_addhead(&st->regiontypes, art);
/* regions: tool header */
art = MEM_callocN(sizeof(ARegionType), "spacetype image tool header region");
art = static_cast<ARegionType *>(
MEM_callocN(sizeof(ARegionType), "spacetype image tool header region"));
art->regionid = RGN_TYPE_TOOL_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
@@ -1157,7 +1155,7 @@ void ED_spacetype_image(void)
BLI_addhead(&st->regiontypes, art);
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype image region"));
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;

View File

@@ -363,6 +363,8 @@ typedef struct ScrArea_Runtime {
} ScrArea_Runtime;
typedef struct ScrArea {
DNA_DEFINE_CXX_METHODS(ScrArea)
struct ScrArea *next, *prev;
/** Ordered (bottom-left, top-left, top-right, bottom-right). */

View File

@@ -154,6 +154,8 @@ typedef enum eSpaceInfo_RptMask {
/** Properties Editor. */
typedef struct SpaceProperties {
DNA_DEFINE_CXX_METHODS(SpaceProperties)
SpaceLink *next, *prev;
/** Storage of regions for inactive spaces. */
ListBase regionbase;