[Bf-blender-cvs] [3d5a4fbcc2e] master: Cleanup: move some files that use normals to C++
Jacques Lucke
noreply at git.blender.org
Fri Dec 2 12:35:52 CET 2022
Commit: 3d5a4fbcc2e4d85344f993a58ae767ed2b252d5b
Author: Jacques Lucke
Date: Fri Dec 2 12:34:26 2022 +0100
Branches: master
https://developer.blender.org/rB3d5a4fbcc2e4d85344f993a58ae767ed2b252d5b
Cleanup: move some files that use normals to C++
Doing this to help with T102858.
===================================================================
M source/blender/blenkernel/CMakeLists.txt
R093 source/blender/blenkernel/intern/data_transfer.c source/blender/blenkernel/intern/data_transfer.cc
R086 source/blender/blenkernel/intern/key.c source/blender/blenkernel/intern/key.cc
R087 source/blender/blenkernel/intern/mesh_mirror.c source/blender/blenkernel/intern/mesh_mirror.cc
M source/blender/blenlib/BLI_linklist.h
M source/blender/bmesh/CMakeLists.txt
R089 source/blender/bmesh/intern/bmesh_mesh_normals.c source/blender/bmesh/intern/bmesh_mesh_normals.cc
M source/blender/modifiers/CMakeLists.txt
R088 source/blender/modifiers/intern/MOD_displace.c source/blender/modifiers/intern/MOD_displace.cc
R070 source/blender/modifiers/intern/MOD_triangulate.c source/blender/modifiers/intern/MOD_triangulate.cc
M source/blender/render/CMakeLists.txt
R094 source/blender/render/intern/bake.c source/blender/render/intern/bake.cc
R095 source/blender/render/intern/multires_bake.c source/blender/render/intern/multires_bake.cc
===================================================================
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 9ea57c7deb9..f56acc43582 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -118,7 +118,7 @@ set(SRC
intern/curves_utils.cc
intern/customdata.cc
intern/customdata_file.c
- intern/data_transfer.c
+ intern/data_transfer.cc
intern/deform.c
intern/displist.cc
intern/dynamicpaint.c
@@ -164,7 +164,7 @@ set(SRC
intern/instances.cc
intern/ipo.c
intern/kelvinlet.c
- intern/key.c
+ intern/key.cc
intern/keyconfig.c
intern/lattice.c
intern/lattice_deform.c
@@ -203,7 +203,7 @@ set(SRC
intern/mesh_mapping.cc
intern/mesh_merge.c
intern/mesh_merge_customdata.cc
- intern/mesh_mirror.c
+ intern/mesh_mirror.cc
intern/mesh_normals.cc
intern/mesh_remap.cc
intern/mesh_remesh_voxel.cc
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.cc
similarity index 93%
rename from source/blender/blenkernel/intern/data_transfer.c
rename to source/blender/blenkernel/intern/data_transfer.cc
index 7b81f74206d..0e2fa029a77 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.cc
@@ -271,18 +271,19 @@ static void data_transfer_dtdata_type_preprocess(Mesh *me_src,
const float split_angle_dst = me_dst->smoothresh;
/* This should be ensured by cddata_masks we pass to code generating/giving us me_src now. */
- BLI_assert(CustomData_get_layer(&me_src->ldata, CD_NORMAL) != NULL);
+ BLI_assert(CustomData_get_layer(&me_src->ldata, CD_NORMAL) != nullptr);
(void)me_src;
float(*loop_nors_dst)[3];
- short(*custom_nors_dst)[2] = CustomData_get_layer(ldata_dst, CD_CUSTOMLOOPNORMAL);
+ short(*custom_nors_dst)[2] = static_cast<short(*)[2]>(
+ CustomData_get_layer(ldata_dst, CD_CUSTOMLOOPNORMAL));
/* Cache loop nors into a temp CDLayer. */
- loop_nors_dst = CustomData_get_layer(ldata_dst, CD_NORMAL);
- const bool do_loop_nors_dst = (loop_nors_dst == NULL);
+ loop_nors_dst = static_cast<float(*)[3]>(CustomData_get_layer(ldata_dst, CD_NORMAL));
+ const bool do_loop_nors_dst = (loop_nors_dst == nullptr);
if (do_loop_nors_dst) {
- loop_nors_dst = CustomData_add_layer(
- ldata_dst, CD_NORMAL, CD_SET_DEFAULT, NULL, num_loops_dst);
+ loop_nors_dst = static_cast<float(*)[3]>(
+ CustomData_add_layer(ldata_dst, CD_NORMAL, CD_SET_DEFAULT, nullptr, num_loops_dst));
CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
}
if (dirty_nors_dst || do_loop_nors_dst) {
@@ -299,8 +300,8 @@ static void data_transfer_dtdata_type_preprocess(Mesh *me_src,
num_polys_dst,
use_split_nors_dst,
split_angle_dst,
- NULL,
- NULL,
+ nullptr,
+ nullptr,
custom_nors_dst);
}
}
@@ -330,12 +331,14 @@ static void data_transfer_dtdata_type_postprocess(Object *UNUSED(ob_src),
CustomData *ldata_dst = &me_dst->ldata;
const float(*poly_nors_dst)[3] = BKE_mesh_poly_normals_ensure(me_dst);
- float(*loop_nors_dst)[3] = CustomData_get_layer(ldata_dst, CD_NORMAL);
- short(*custom_nors_dst)[2] = CustomData_get_layer(ldata_dst, CD_CUSTOMLOOPNORMAL);
+ float(*loop_nors_dst)[3] = static_cast<float(*)[3]>(
+ CustomData_get_layer(ldata_dst, CD_NORMAL));
+ short(*custom_nors_dst)[2] = static_cast<short(*)[2]>(
+ CustomData_get_layer(ldata_dst, CD_CUSTOMLOOPNORMAL));
if (!custom_nors_dst) {
- custom_nors_dst = CustomData_add_layer(
- ldata_dst, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, NULL, num_loops_dst);
+ custom_nors_dst = static_cast<short(*)[2]>(CustomData_add_layer(
+ ldata_dst, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, num_loops_dst));
}
/* Note loop_nors_dst contains our custom normals as transferred from source... */
@@ -364,7 +367,7 @@ static MeshRemapIslandsCalc data_transfer_get_loop_islands_generator(const int c
default:
break;
}
- return NULL;
+ return nullptr;
}
float data_transfer_interp_float_do(const int mix_mode,
@@ -422,9 +425,9 @@ void data_transfer_layersmapping_add_item(ListBase *r_map,
cd_datatransfer_interp interp,
void *interp_data)
{
- CustomDataTransferLayerMap *item = MEM_mallocN(sizeof(*item), __func__);
+ CustomDataTransferLayerMap *item = MEM_new<CustomDataTransferLayerMap>(__func__);
- BLI_assert(data_dst != NULL);
+ BLI_assert(data_dst != nullptr);
item->data_type = cddata_type;
item->mix_mode = mix_mode;
@@ -487,7 +490,7 @@ static void data_transfer_layersmapping_add_item_cd(ListBase *r_map,
* \note
* All those layer mapping handlers return false *only* if they were given invalid parameters.
* This means that even if they do nothing, they will return true if all given parameters were OK.
- * Also, r_map may be NULL, in which case they will 'only' create/delete destination layers
+ * Also, r_map may be nullptr, in which case they will 'only' create/delete destination layers
* according to given parameters.
*/
static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map,
@@ -508,10 +511,10 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
void *interp_data)
{
const void *data_src;
- void *data_dst = NULL;
+ void *data_dst = nullptr;
int idx_src = num_layers_src;
int idx_dst, tot_dst = CustomData_number_of_layers(cd_dst, cddata_type);
- bool *data_dst_to_delete = NULL;
+ bool *data_dst_to_delete = nullptr;
if (!use_layers_src) {
/* No source at all, we can only delete all dest if requested... */
@@ -538,7 +541,7 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
if (use_create) {
/* Create as much data layers as necessary! */
for (; idx_dst < idx_src; idx_dst++) {
- CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst);
+ CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst);
}
}
else {
@@ -581,8 +584,8 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
case DT_LAYERS_NAME_DST:
if (use_delete) {
if (tot_dst) {
- data_dst_to_delete = MEM_mallocN(sizeof(*data_dst_to_delete) * (size_t)tot_dst,
- __func__);
+ data_dst_to_delete = static_cast<bool *>(
+ MEM_mallocN(sizeof(*data_dst_to_delete) * (size_t)tot_dst, __func__));
memset(data_dst_to_delete, true, sizeof(*data_dst_to_delete) * (size_t)tot_dst);
}
}
@@ -600,7 +603,7 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
if ((idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name)) == -1) {
if (use_create) {
CustomData_add_layer_named(
- cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst, name);
+ cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst, name);
idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
}
else {
@@ -673,7 +676,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
{
int idx_src, idx_dst;
const void *data_src;
- void *data_dst = NULL;
+ void *data_dst = nullptr;
if (CustomData_layertype_is_singleton(cddata_type)) {
if (!(data_src = CustomData_get_layer(cd_src, cddata_type))) {
@@ -688,7 +691,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
if (!use_create) {
return true;
}
- data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst);
+ data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst);
}
else if (use_dupref_dst && r_map) {
/* If dest is a evaluated mesh (from modifier),
@@ -741,7 +744,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
if (!use_create) {
return true;
}
- data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst);
+ data_dst = CustomData_add_layer(
+ cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst);
}
else {
/* If dest is a evaluated mesh (from modifier),
@@ -764,7 +768,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
}
/* Create as much data layers as necessary! */
for (; num <= idx_dst; num++) {
- CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst);
+ CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst);
}
}
/* If dest is a evaluated mesh (from modifier),
@@ -783,7 +787,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
if (!use_create) {
return true;
}
- CustomData_add_layer_named(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst, name);
+ CustomData_add_layer_named(
+ cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst, name);
idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
}
/* If dest is a evaluated mesh (from modifier),
@@ -818,9 +823,9 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
}
else if (fromlayers == DT_LAYERS_ALL_SRC) {
int num_src = CustomData_number_of_layers(cd_src, cddata_type);
- bool *use_layers_src = num_src ?
- MEM_mallocN(sizeof(*use_layers_src) * (size_t)num_src, __func__) :
- NULL;
+ boo
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list