[Bf-blender-cvs] [4c407f20a62] master: Cleanup: Move object_add.c to C++
Hans Goudey
noreply at git.blender.org
Mon Feb 28 22:21:08 CET 2022
Commit: 4c407f20a62c7d437a9b3f2498b658f968102573
Author: Hans Goudey
Date: Mon Feb 28 16:20:55 2022 -0500
Branches: master
https://developer.blender.org/rB4c407f20a62c7d437a9b3f2498b658f968102573
Cleanup: Move object_add.c to C++
This patch was tested on the buildbot first, it builds on all platforms.
===================================================================
M source/blender/editors/object/CMakeLists.txt
R089 source/blender/editors/object/object_add.c source/blender/editors/object/object_add.cc
M source/blender/editors/object/object_intern.h
===================================================================
diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt
index 54db59dc2fa..a94387961ee 100644
--- a/source/blender/editors/object/CMakeLists.txt
+++ b/source/blender/editors/object/CMakeLists.txt
@@ -28,7 +28,7 @@ set(INC
)
set(SRC
- object_add.c
+ object_add.cc
object_bake.c
object_bake_api.c
object_collection.c
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.cc
similarity index 89%
rename from source/blender/editors/object/object_add.c
rename to source/blender/editors/object/object_add.cc
index 7771012f2a1..ef11337254c 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.cc
@@ -5,9 +5,9 @@
* \ingroup edobj
*/
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cctype>
+#include <cstdlib>
+#include <cstring>
#include "MEM_guardedalloc.h"
@@ -122,7 +122,7 @@ const EnumPropertyItem rna_enum_light_type_items[] = {
{LA_SUN, "SUN", ICON_LIGHT_SUN, "Sun", "Constant direction parallel ray light source"},
{LA_SPOT, "SPOT", ICON_LIGHT_SPOT, "Spot", "Directional cone light source"},
{LA_AREA, "AREA", ICON_LIGHT_AREA, "Area", "Directional area light source"},
- {0, NULL, 0, NULL, NULL},
+ {0, nullptr, 0, nullptr, nullptr},
};
/* copy from rna_object_force.c */
@@ -140,7 +140,7 @@ static const EnumPropertyItem field_type_items[] = {
{PFIELD_TURBULENCE, "TURBULENCE", ICON_FORCE_TURBULENCE, "Turbulence", ""},
{PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", ""},
{PFIELD_FLUIDFLOW, "FLUID", ICON_FORCE_FLUIDFLOW, "Fluid Flow", ""},
- {0, NULL, 0, NULL, NULL},
+ {0, nullptr, 0, nullptr, nullptr},
};
static EnumPropertyItem lightprobe_type_items[] = {
@@ -159,7 +159,7 @@ static EnumPropertyItem lightprobe_type_items[] = {
ICON_LIGHTPROBE_GRID,
"Irradiance Volume",
"Irradiance probe to capture diffuse indirect lighting"},
- {0, NULL, 0, NULL, NULL},
+ {0, nullptr, 0, nullptr, nullptr},
};
enum {
@@ -172,7 +172,7 @@ static const EnumPropertyItem align_options[] = {
{ALIGN_WORLD, "WORLD", 0, "World", "Align the new object to the world"},
{ALIGN_VIEW, "VIEW", 0, "View", "Align the new object to the view"},
{ALIGN_CURSOR, "CURSOR", 0, "3D Cursor", "Use the 3D cursor orientation for the new object"},
- {0, NULL, 0, NULL, NULL},
+ {0, nullptr, 0, nullptr, nullptr},
};
/** \} */
@@ -198,7 +198,7 @@ static void object_add_drop_xy_props(wmOperatorType *ot)
"X-coordinate (screen space) to place the new object under",
INT_MIN,
INT_MAX);
- RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE));
prop = RNA_def_int(ot->srna,
"drop_y",
0,
@@ -208,7 +208,7 @@ static void object_add_drop_xy_props(wmOperatorType *ot)
"Y-coordinate (screen space) to place the new object under",
INT_MIN,
INT_MAX);
- RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE));
}
static bool object_add_drop_xy_is_set(const wmOperator *op)
@@ -343,13 +343,13 @@ float ED_object_new_primitive_matrix(bContext *C,
invert_m3_m3(imat, mat);
mul_m3_v3(imat, r_primmat[3]);
- if (scale != NULL) {
+ if (scale != nullptr) {
rescale_m4(r_primmat, scale);
}
{
- const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) :
- ED_scene_grid_scale(scene, NULL);
+ const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, nullptr) :
+ ED_scene_grid_scale(scene, nullptr);
return dia;
}
@@ -393,20 +393,20 @@ void ED_object_add_generic_props(wmOperatorType *ot, bool do_editmode)
if (do_editmode) {
prop = RNA_def_boolean(ot->srna,
"enter_editmode",
- 0,
+ false,
"Enter Edit Mode",
"Enter edit mode when adding this object");
- RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE));
}
/* NOTE: this property gets hidden for add-camera operator. */
prop = RNA_def_enum(
ot->srna, "align", align_options, ALIGN_WORLD, "Align", "The alignment of the new object");
- RNA_def_property_update_runtime(prop, view_align_update);
+ RNA_def_property_update_runtime(prop, (void *)view_align_update);
prop = RNA_def_float_vector_xyz(ot->srna,
"location",
3,
- NULL,
+ nullptr,
-OBJECT_ADD_SIZE_MAXF,
OBJECT_ADD_SIZE_MAXF,
"Location",
@@ -417,7 +417,7 @@ void ED_object_add_generic_props(wmOperatorType *ot, bool do_editmode)
prop = RNA_def_float_rotation(ot->srna,
"rotation",
3,
- NULL,
+ nullptr,
-OBJECT_ADD_SIZE_MAXF,
OBJECT_ADD_SIZE_MAXF,
"Rotation",
@@ -429,14 +429,14 @@ void ED_object_add_generic_props(wmOperatorType *ot, bool do_editmode)
prop = RNA_def_float_vector_xyz(ot->srna,
"scale",
3,
- NULL,
+ nullptr,
-OBJECT_ADD_SIZE_MAXF,
OBJECT_ADD_SIZE_MAXF,
"Scale",
"Scale for the newly added object",
-1000.0f,
1000.0f);
- RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE));
}
void ED_object_add_mesh_props(wmOperatorType *ot)
@@ -461,11 +461,11 @@ bool ED_object_add_generic_get_opts(bContext *C,
r_enter_editmode = &_enter_editmode;
}
/* Only to ensure the value is _always_ set.
- * Typically the property will exist when the argument is non-NULL. */
+ * Typically the property will exist when the argument is non-nullptr. */
*r_enter_editmode = false;
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "enter_editmode");
- if (prop != NULL) {
+ if (prop != nullptr) {
if (RNA_property_is_set(op->ptr, prop) && r_enter_editmode) {
*r_enter_editmode = RNA_property_boolean_get(op->ptr, prop);
}
@@ -571,7 +571,7 @@ bool ED_object_add_generic_get_opts(bContext *C,
copy_v3_fl(r_scale, 1.0f);
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "scale");
- if (prop != NULL) {
+ if (prop != nullptr) {
if (RNA_property_is_set(op->ptr, prop)) {
RNA_property_float_get_array(op->ptr, prop, r_scale);
}
@@ -600,19 +600,19 @@ Object *ED_object_add_type_with_obdata(bContext *C,
{
Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
- if (obedit != NULL) {
+ if (obedit != nullptr) {
ED_object_editmode_exit_ex(bmain, scene, obedit, EM_FREEDATA);
}
}
/* deselects all, sets active object */
Object *ob;
- if (obdata != NULL) {
+ if (obdata != nullptr) {
BLI_assert(type == BKE_object_obdata_to_type(obdata));
ob = BKE_object_add_for_data(bmain, view_layer, type, name, obdata, true);
const short *materials_len_p = BKE_id_material_len_p(obdata);
if (materials_len_p && *materials_len_p > 0) {
- BKE_object_materials_test(bmain, ob, ob->data);
+ BKE_object_materials_test(bmain, ob, static_cast<ID *>(ob->data));
}
}
else {
@@ -630,7 +630,7 @@ Object *ED_object_add_type_with_obdata(bContext *C,
*/
DEG_id_type_tag(bmain, ID_OB);
DEG_relations_tag_update(bmain);
- if (ob->data != NULL) {
+ if (ob->data != nullptr) {
DEG_id_tag_update_ex(bmain, (ID *)ob->data, ID_RECALC_EDITORS);
}
@@ -657,7 +657,7 @@ Object *ED_object_add_type(bContext *C,
const ushort local_view_bits)
{
return ED_object_add_type_with_obdata(
- C, type, name, loc, rot, enter_editmode, local_view_bits, NULL);
+ C, type, name, loc, rot, enter_editmode, local_view_bits, nullptr);
}
/* for object add operator */
@@ -668,12 +668,12 @@ static int object_add_exec(bContext *C, wmOperator *op)
float loc[3], rot[3], radius;
WM_operator_view3d_unit_defaults(C, op);
if (!ED_object_add_generic_get_opts(
- C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL)) {
+ C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) {
return OPERATOR_CANCELLED;
}
radius = RNA_float_get(op->ptr, "radius");
Object *ob = ED_object_add_type(
- C, RNA_enum_get(op->ptr, "type"), NULL, loc, rot, enter_editmode, local_view_bits);
+ C, RNA_enum_get(op->ptr, "type"), nullptr, loc, rot, enter_editmode, local_view_bits);
if (ob->type == OB_LATTICE) {
/* lattice is a special case!
@@ -737,7 +737,7 @@ static int lightprobe_add_exec(bContext *C, wmOperator *op)
float loc[3], rot[3];
WM_operator_view3d_unit_defaults(C, op);
if (!ED_object_add_generic_get_opts(
- C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL)) {
+ C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) {
return OPERATOR_CANCELLED;
}
int type = RNA_enum_get(op->ptr, "type");
@@ -829,26 +829,25 @@ static int effector_add_exec(bContext *C, wmOperator *op)
float loc[3], rot[3];
WM_operator_view3d_unit_defaults(C, op);
if (!ED_object_add_generic_get_opts(
- C, op, 'Z', loc, rot, NULL, &enter_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list