Cleanup: use boolean & nullptr literals

This commit is contained in:
Campbell Barton
2023-12-17 16:04:44 +11:00
parent 240b159918
commit 2b3c379850
11 changed files with 93 additions and 84 deletions

View File

@@ -3334,7 +3334,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
/* copy some info to scratch */
/* we only need that if we want to reconstruct IPO */
if (1) {
if (true) {
reference_to_scratch(ob);
SB_estimate_transform(ob, nullptr, nullptr, nullptr);
SB_estimate_transform(ob, nullptr, nullptr, nullptr);

View File

@@ -1188,7 +1188,7 @@ void BKE_sound_update_scene(Depsgraph *depsgraph, Scene *scene)
/* cheap test to skip looping over all objects (no speakers is a common case) */
if (DEG_id_type_any_exists(depsgraph, ID_SPK)) {
DEGObjectIterSettings deg_iter_settings = {0};
DEGObjectIterSettings deg_iter_settings = {nullptr};
deg_iter_settings.depsgraph = depsgraph;
deg_iter_settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY |

View File

@@ -840,7 +840,7 @@ static AVStream *alloc_video_stream(FFMpegContext *context,
}
/* "codec_id != AV_CODEC_ID_AV1" is required due to "preset" already being set by an AV1 codec.
*/
if (preset_name != NULL && codec_id != AV_CODEC_ID_AV1) {
if (preset_name != nullptr && codec_id != AV_CODEC_ID_AV1) {
av_dict_set(&opts, "preset", preset_name, 0);
}
if (deadline_name != nullptr) {
@@ -1190,7 +1190,7 @@ static int start_ffmpeg_impl(FFMpegContext *context,
return 0;
}
fmt = av_guess_format(NULL, exts[0], nullptr);
fmt = av_guess_format(nullptr, exts[0], nullptr);
if (!fmt) {
BKE_report(reports, RPT_ERROR, "No valid formats found");
return 0;
@@ -1652,7 +1652,7 @@ static void end_ffmpeg_impl(FFMpegContext *context, int is_autosplit)
context->img_convert_frame = nullptr;
}
if (context->outfile != NULL && context->outfile->oformat) {
if (context->outfile != nullptr && context->outfile->oformat) {
if (!(context->outfile->oformat->flags & AVFMT_NOFILE)) {
avio_close(context->outfile->pb);
}

View File

@@ -2409,56 +2409,56 @@ static bool isect_tri_tri_v2_impl_vert(const float t_a0[2],
if (line_point_side_v2(t_b2, t_b1, t_a1) <= 0.0f) {
if (line_point_side_v2(t_a0, t_b0, t_a1) > 0.0f) {
if (line_point_side_v2(t_a0, t_b1, t_a1) <= 0.0f) {
return 1;
return true;
}
return 0;
return false;
}
if (line_point_side_v2(t_a0, t_b0, t_a2) >= 0.0f) {
if (line_point_side_v2(t_a1, t_a2, t_b0) >= 0.0f) {
return 1;
return true;
}
return 0;
return false;
}
return 0;
return false;
}
if (line_point_side_v2(t_a0, t_b1, t_a1) <= 0.0f) {
if (line_point_side_v2(t_b2, t_b1, t_a2) <= 0.0f) {
if (line_point_side_v2(t_a1, t_a2, t_b1) >= 0.0f) {
return 1;
return true;
}
return 0;
return false;
}
return 0;
return false;
}
return 0;
return false;
}
if (line_point_side_v2(t_b2, t_b0, t_a2) >= 0.0f) {
if (line_point_side_v2(t_a1, t_a2, t_b2) >= 0.0f) {
if (line_point_side_v2(t_a0, t_b0, t_a2) >= 0.0f) {
return 1;
return true;
}
return 0;
return false;
}
if (line_point_side_v2(t_a1, t_a2, t_b1) >= 0.0f) {
if (line_point_side_v2(t_b2, t_a2, t_b1) >= 0.0f) {
return 1;
return true;
}
return 0;
return false;
}
return 0;
return false;
}
return 0;
return false;
}
static bool isect_tri_tri_v2_impl_edge(const float t_a0[2],
@@ -2473,40 +2473,40 @@ static bool isect_tri_tri_v2_impl_edge(const float t_a0[2],
if (line_point_side_v2(t_b2, t_b0, t_a1) >= 0.0f) {
if (line_point_side_v2(t_a0, t_b0, t_a1) >= 0.0f) {
if (line_point_side_v2(t_a0, t_a1, t_b2) >= 0.0f) {
return 1;
return true;
}
return 0;
return false;
}
if (line_point_side_v2(t_a1, t_a2, t_b0) >= 0.0f) {
if (line_point_side_v2(t_a2, t_a0, t_b0) >= 0.0f) {
return 1;
return true;
}
return 0;
return false;
}
return 0;
return false;
}
if (line_point_side_v2(t_b2, t_b0, t_a2) >= 0.0f) {
if (line_point_side_v2(t_a0, t_b0, t_a2) >= 0.0f) {
if (line_point_side_v2(t_a0, t_a2, t_b2) >= 0.0f) {
return 1;
return true;
}
if (line_point_side_v2(t_a1, t_a2, t_b2) >= 0.0f) {
return 1;
return true;
}
return 0;
return false;
}
return 0;
return false;
}
return 0;
return false;
}
static int isect_tri_tri_impl_ccw_v2(const float t_a0[2],

View File

@@ -349,27 +349,27 @@ void WM_OT_alembic_export(wmOperatorType *ot)
1.0f);
RNA_def_boolean(
ot->srna, "selected", 0, "Selected Objects Only", "Export only selected objects");
ot->srna, "selected", false, "Selected Objects Only", "Export only selected objects");
RNA_def_boolean(ot->srna,
"visible_objects_only",
0,
false,
"Visible Objects Only",
"Export only objects that are visible");
RNA_def_boolean(ot->srna,
"flatten",
0,
false,
"Flatten Hierarchy",
"Do not preserve objects' parent/children relationship");
RNA_def_boolean(ot->srna, "uvs", 1, "UVs", "Export UVs");
RNA_def_boolean(ot->srna, "uvs", true, "UVs", "Export UVs");
RNA_def_boolean(ot->srna, "packuv", 1, "Pack UV Islands", "Export UVs with packed island");
RNA_def_boolean(ot->srna, "packuv", true, "Pack UV Islands", "Export UVs with packed island");
RNA_def_boolean(ot->srna, "normals", 1, "Normals", "Export normals");
RNA_def_boolean(ot->srna, "normals", true, "Normals", "Export normals");
RNA_def_boolean(ot->srna, "vcolors", 0, "Color Attributes", "Export color attributes");
RNA_def_boolean(ot->srna, "vcolors", false, "Color Attributes", "Export color attributes");
RNA_def_boolean(ot->srna,
"orcos",
@@ -378,17 +378,17 @@ void WM_OT_alembic_export(wmOperatorType *ot)
"Export undeformed mesh vertex coordinates");
RNA_def_boolean(
ot->srna, "face_sets", 0, "Face Sets", "Export per face shading group assignments");
ot->srna, "face_sets", false, "Face Sets", "Export per face shading group assignments");
RNA_def_boolean(ot->srna,
"subdiv_schema",
0,
false,
"Use Subdivision Schema",
"Export meshes using Alembic's subdivision schema");
RNA_def_boolean(ot->srna,
"apply_subdiv",
0,
false,
"Apply Subdivision Surface",
"Export subdivision surfaces as meshes");
@@ -438,11 +438,11 @@ void WM_OT_alembic_export(wmOperatorType *ot)
RNA_def_boolean(ot->srna,
"export_hair",
1,
true,
"Export Hair",
"Exports hair particle systems as animated curves");
RNA_def_boolean(
ot->srna, "export_particles", 1, "Export Particles", "Exports non-hair particle systems");
ot->srna, "export_particles", true, "Export Particles", "Exports non-hair particle systems");
RNA_def_boolean(ot->srna,
"export_custom_properties",
@@ -689,7 +689,7 @@ void WM_OT_alembic_import(wmOperatorType *ot)
RNA_def_boolean(ot->srna,
"validate_meshes",
0,
false,
"Validate Meshes",
"Check imported mesh objects for invalid data (slow)");

View File

@@ -494,7 +494,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
RNA_def_boolean(ot->srna,
"apply_modifiers",
0,
false,
"Apply Modifiers",
"Apply modifiers to exported mesh (non destructive)");
@@ -596,7 +596,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
RNA_def_boolean(ot->srna,
"keep_smooth_curves",
0,
false,
"Keep Smooth curves",
"Export also the curve handles (if available) (this does only work when the "
"inverse parent matrix "
@@ -604,47 +604,50 @@ void WM_OT_collada_export(wmOperatorType *ot)
RNA_def_boolean(ot->srna,
"keep_keyframes",
0,
false,
"Keep Keyframes",
"Use existing keyframes as additional sample points (this helps when you want "
"to keep manual tweaks)");
RNA_def_boolean(ot->srna,
"keep_flat_curves",
0,
false,
"All Keyed Curves",
"Export also curves which have only one key or are totally flat");
RNA_def_boolean(
ot->srna, "active_uv_only", 0, "Only Selected UV Map", "Export only the selected UV Map");
RNA_def_boolean(ot->srna,
"active_uv_only",
false,
"Only Selected UV Map",
"Export only the selected UV Map");
RNA_def_boolean(ot->srna,
"use_texture_copies",
1,
true,
"Copy",
"Copy textures to same folder where the .dae file is exported");
RNA_def_boolean(ot->srna,
"triangulate",
1,
true,
"Triangulate",
"Export polygons (quads and n-gons) as triangles");
RNA_def_boolean(ot->srna,
"use_object_instantiation",
1,
true,
"Use Object Instances",
"Instantiate multiple Objects from same Data");
RNA_def_boolean(
ot->srna,
"use_blender_profile",
1,
true,
"Use Blender Profile",
"Export additional Blender specific information (for material, shaders, bones, etc.)");
RNA_def_boolean(
ot->srna, "sort_by_name", 0, "Sort by Object name", "Sort exported data by Object name");
ot->srna, "sort_by_name", false, "Sort by Object name", "Sort exported data by Object name");
RNA_def_int(ot->srna,
"export_object_transformation_type",
@@ -687,20 +690,20 @@ void WM_OT_collada_export(wmOperatorType *ot)
RNA_def_boolean(
ot->srna,
"open_sim",
0,
false,
"Export to SL/OpenSim",
"Compatibility mode for Second Life, OpenSimulator and other compatible online worlds");
RNA_def_boolean(ot->srna,
"limit_precision",
0,
false,
"Limit Precision",
"Reduce the precision of the exported data to 6 digits");
RNA_def_boolean(
ot->srna,
"keep_bind_info",
0,
false,
"Keep Bind Info",
"Store Bindpose information in custom bone properties for later use during Collada export");
}
@@ -813,32 +816,32 @@ void WM_OT_collada_import(wmOperatorType *ot)
RNA_def_boolean(ot->srna,
"import_units",
0,
false,
"Import Units",
"If disabled match import to Blender's current Unit settings, "
"otherwise use the settings from the Imported scene");
RNA_def_boolean(ot->srna,
"custom_normals",
1,
true,
"Custom Normals",
"Import custom normals, if available (otherwise Blender will compute them)");
RNA_def_boolean(ot->srna,
"fix_orientation",
0,
false,
"Fix Leaf Bones",
"Fix Orientation of Leaf Bones (Collada does only support Joints)");
RNA_def_boolean(ot->srna,
"find_chains",
0,
false,
"Find Bone Chains",
"Find best matching Bone Chains and ensure bones in chain are connected");
RNA_def_boolean(ot->srna,
"auto_connect",
0,
false,
"Auto Connect",
"Set use_connect for parent bones which have exactly one child bone");
@@ -855,7 +858,7 @@ void WM_OT_collada_import(wmOperatorType *ot)
RNA_def_boolean(
ot->srna,
"keep_bind_info",
0,
false,
"Keep Bind Info",
"Store Bindpose information in custom bone properties for later use during Collada export");
}

View File

@@ -731,7 +731,7 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
RNA_def_int(ot->srna, "bitrate", 192, 32, 512, "Bitrate", "Bitrate in kbit/s", 32, 512);
RNA_def_boolean(ot->srna,
"split_channels",
0,
false,
"Split channels",
"Each channel will be rendered into a mono file");
#endif /* WITH_AUDASPACE */

View File

@@ -263,7 +263,7 @@ void VKCommandBuffers::bind(const VKDescriptorSet &descriptor_set,
1,
&vk_descriptor_set,
0,
0);
nullptr);
command_buffer.command_recorded();
}

View File

@@ -352,7 +352,7 @@ void HydraSceneDelegate::check_updates()
do_update_collection = true;
}
DEGIDIterData data = {0};
DEGIDIterData data = {nullptr};
data.graph = depsgraph;
data.only_updated = true;
ITER_BEGIN (DEG_iterator_ids_begin, DEG_iterator_ids_next, DEG_iterator_ids_end, &data, ID *, id)
@@ -411,10 +411,10 @@ void HydraSceneDelegate::update_collection()
{
Set<std::string> available_objects;
DEGObjectIterSettings settings = {0};
DEGObjectIterSettings settings = {nullptr};
settings.depsgraph = depsgraph;
settings.flags = DEG_OBJECT_ITER_FOR_RENDER_ENGINE_FLAGS;
DEGObjectIterData data = {0};
DEGObjectIterData data = {nullptr};
data.settings = &settings;
data.graph = settings.depsgraph;
data.flag = settings.flags;

View File

@@ -361,30 +361,33 @@ void RNA_api_scene(StructRNA *srna)
func, "geom_samples", 1, 1, 128, "Geom samples", "Geometry samples per frame", 1, 128);
RNA_def_float(func, "shutter_open", 0.0f, -1.0f, 1.0f, "Shutter open", "", -1.0f, 1.0f);
RNA_def_float(func, "shutter_close", 1.0f, -1.0f, 1.0f, "Shutter close", "", -1.0f, 1.0f);
RNA_def_boolean(func, "selected_only", 0, "Selected only", "Export only selected objects");
RNA_def_boolean(func, "uvs", 1, "UVs", "Export UVs");
RNA_def_boolean(func, "normals", 1, "Normals", "Export normals");
RNA_def_boolean(func, "vcolors", 0, "Color Attributes", "Export color attributes");
RNA_def_boolean(func, "selected_only", false, "Selected only", "Export only selected objects");
RNA_def_boolean(func, "uvs", true, "UVs", "Export UVs");
RNA_def_boolean(func, "normals", true, "Normals", "Export normals");
RNA_def_boolean(func, "vcolors", false, "Color Attributes", "Export color attributes");
RNA_def_boolean(
func, "apply_subdiv", 1, "Subsurfs as meshes", "Export subdivision surfaces as meshes");
RNA_def_boolean(func, "flatten", 0, "Flatten hierarchy", "Flatten hierarchy");
func, "apply_subdiv", true, "Subsurfs as meshes", "Export subdivision surfaces as meshes");
RNA_def_boolean(func, "flatten", false, "Flatten hierarchy", "Flatten hierarchy");
RNA_def_boolean(func,
"visible_objects_only",
0,
false,
"Visible layers only",
"Export only objects in visible layers");
RNA_def_boolean(func, "face_sets", 0, "Facesets", "Export face sets");
RNA_def_boolean(func, "face_sets", false, "Facesets", "Export face sets");
RNA_def_boolean(func,
"subdiv_schema",
0,
false,
"Use Alembic subdivision Schema",
"Use Alembic subdivision Schema");
RNA_def_boolean(func,
"export_hair",
true,
"Export Hair",
"Exports hair particle systems as animated curves");
RNA_def_boolean(
func, "export_hair", 1, "Export Hair", "Exports hair particle systems as animated curves");
func, "export_particles", true, "Export Particles", "Exports non-hair particle systems");
RNA_def_boolean(
func, "export_particles", 1, "Export Particles", "Exports non-hair particle systems");
RNA_def_boolean(
func, "packuv", 0, "Export with packed UV islands", "Export with packed UV islands");
func, "packuv", false, "Export with packed UV islands", "Export with packed UV islands");
RNA_def_float(
func,
"scale",
@@ -395,8 +398,11 @@ void RNA_api_scene(StructRNA *srna)
"Value by which to enlarge or shrink the objects with respect to the world's origin",
0.0001f,
1000.0f);
RNA_def_boolean(
func, "triangulate", 0, "Triangulate", "Export polygons (quads and n-gons) as triangles");
RNA_def_boolean(func,
"triangulate",
false,
"Triangulate",
"Export polygons (quads and n-gons) as triangles");
RNA_def_enum(func,
"quad_method",
rna_enum_modifier_triangulate_quad_method_items,

View File

@@ -90,7 +90,7 @@ bool BPy_errors_to_report_ex(ReportList *reports,
/* Create a temporary report list so none of the reports are printed (only stored).
* In practically all cases printing should be handled by #PyErr_Print since this invokes
* `sys.excepthook` as expected. */
ReportList _reports_buf = {{0}};
ReportList _reports_buf = {{nullptr}};
ReportList *reports_orig = reports;
if ((reports->flag & RPT_PRINT_HANDLED_BY_OWNER) == 0) {
reports = &_reports_buf;