[Bf-blender-cvs] [e7e3431b299] blender-v3.0-release: Cleanup: Move object.c to C++
Germano Cavalcante
noreply at git.blender.org
Thu Nov 4 20:52:04 CET 2021
Commit: e7e3431b299448310f9c9e95d863055e3e04a8c4
Author: Germano Cavalcante
Date: Thu Nov 4 16:51:37 2021 -0300
Branches: blender-v3.0-release
https://developer.blender.org/rBe7e3431b299448310f9c9e95d863055e3e04a8c4
Cleanup: Move object.c to C++
This is useful to allow the use of features made in C++.
Differential Revision: https://developer.blender.org/D13115
===================================================================
M source/blender/blenkernel/BKE_lib_id.h
M source/blender/blenkernel/BKE_object.h
M source/blender/blenkernel/CMakeLists.txt
R088 source/blender/blenkernel/intern/object.c source/blender/blenkernel/intern/object.cc
M source/blender/makesdna/DNA_object_force_types.h
===================================================================
diff --git a/source/blender/blenkernel/BKE_lib_id.h b/source/blender/blenkernel/BKE_lib_id.h
index d79df4b2216..402787c8cc0 100644
--- a/source/blender/blenkernel/BKE_lib_id.h
+++ b/source/blender/blenkernel/BKE_lib_id.h
@@ -46,6 +46,7 @@
*/
#include "BLI_compiler_attrs.h"
+#include "BLI_utildefines.h"
#ifdef __cplusplus
extern "C" {
@@ -179,6 +180,8 @@ typedef enum eLibIDDuplicateFlags {
LIB_ID_DUPLICATE_IS_ROOT_ID = 1 << 1,
} eLibIDDuplicateFlags;
+ENUM_OPERATORS(eLibIDDuplicateFlags, LIB_ID_DUPLICATE_IS_ROOT_ID)
+
/* lib_remap.c (keep here since they're general functions) */
/**
* New freeing logic options.
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 0e153c5a82a..4e53af5562f 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -75,7 +75,7 @@ void BKE_object_modifier_gpencil_hook_reset(struct Object *ob,
struct HookGpencilModifierData *hmd);
bool BKE_object_modifier_gpencil_use_time(struct Object *ob, struct GpencilModifierData *md);
-bool BKE_object_shaderfx_use_time(struct Object *ob, struct ShaderFxData *md);
+bool BKE_object_shaderfx_use_time(struct Object *ob, struct ShaderFxData *fx);
bool BKE_object_supports_modifiers(const struct Object *ob);
bool BKE_object_support_modifier_type_check(const struct Object *ob, int modifier_type);
@@ -89,7 +89,7 @@ bool BKE_object_copy_modifier(struct Main *bmain,
struct Object *ob_dst,
const struct Object *ob_src,
struct ModifierData *md);
-bool BKE_object_copy_gpencil_modifier(struct Object *ob_dst, struct GpencilModifierData *md);
+bool BKE_object_copy_gpencil_modifier(struct Object *ob_dst, struct GpencilModifierData *gmd_src);
bool BKE_object_modifier_stack_copy(struct Object *ob_dst,
const struct Object *ob_src,
const bool do_copy_all,
@@ -155,7 +155,7 @@ bool BKE_object_obdata_is_libdata(const struct Object *ob);
struct Object *BKE_object_duplicate(struct Main *bmain,
struct Object *ob,
uint dupflag,
- const uint duplicate_options);
+ uint duplicate_options);
void BKE_object_obdata_size_init(struct Object *ob, const float size);
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index ef95d747948..d4ec7fd703d 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -226,7 +226,7 @@ set(SRC
intern/multires_versioning.c
intern/nla.c
intern/node.cc
- intern/object.c
+ intern/object.cc
intern/object_deform.c
intern/object_dupli.cc
intern/object_facemap.c
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.cc
similarity index 88%
rename from source/blender/blenkernel/intern/object.c
rename to source/blender/blenkernel/intern/object.cc
index dc6ef580408..495b1f0dafd 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.cc
@@ -24,9 +24,9 @@
/* Allow using deprecated functionality for .blend file I/O. */
#define DNA_DEPRECATED_ALLOW
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
+#include <cmath>
+#include <cstdio>
+#include <cstring>
#include "CLG_log.h"
@@ -201,24 +201,24 @@ static void object_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const in
const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
if (ob_src->totcol) {
- ob_dst->mat = MEM_dupallocN(ob_src->mat);
- ob_dst->matbits = MEM_dupallocN(ob_src->matbits);
+ ob_dst->mat = (Material **)MEM_dupallocN(ob_src->mat);
+ ob_dst->matbits = (char *)MEM_dupallocN(ob_src->matbits);
ob_dst->totcol = ob_src->totcol;
}
- else if (ob_dst->mat != NULL || ob_dst->matbits != NULL) {
+ else if (ob_dst->mat != nullptr || ob_dst->matbits != nullptr) {
/* This shall not be needed, but better be safe than sorry. */
BLI_assert_msg(
- 0, "Object copy: non-NULL material pointers with zero counter, should not happen.");
- ob_dst->mat = NULL;
- ob_dst->matbits = NULL;
+ 0, "Object copy: non-nullptr material pointers with zero counter, should not happen.");
+ ob_dst->mat = nullptr;
+ ob_dst->matbits = nullptr;
}
if (ob_src->iuser) {
- ob_dst->iuser = MEM_dupallocN(ob_src->iuser);
+ ob_dst->iuser = (ImageUser *)MEM_dupallocN(ob_src->iuser);
}
if (ob_src->runtime.bb) {
- ob_dst->runtime.bb = MEM_dupallocN(ob_src->runtime.bb);
+ ob_dst->runtime.bb = (BoundBox *)MEM_dupallocN(ob_src->runtime.bb);
}
BLI_listbase_clear(&ob_dst->shader_fx);
@@ -234,7 +234,7 @@ static void object_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const in
/* backwards compat... non-armatures can get poses in older files? */
if (ob_src->type == OB_ARMATURE) {
const bool do_pose_id_user = (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0;
- BKE_pose_rebuild(bmain, ob_dst, ob_dst->data, do_pose_id_user);
+ BKE_pose_rebuild(bmain, ob_dst, (bArmature *)ob_dst->data, do_pose_id_user);
}
}
@@ -242,12 +242,12 @@ static void object_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const in
BKE_constraints_copy_ex(&ob_dst->constraints, &ob_src->constraints, flag_subdata, true);
ob_dst->mode = ob_dst->type != OB_GPENCIL ? OB_MODE_OBJECT : ob_dst->mode;
- ob_dst->sculpt = NULL;
+ ob_dst->sculpt = nullptr;
if (ob_src->pd) {
- ob_dst->pd = MEM_dupallocN(ob_src->pd);
+ ob_dst->pd = (PartDeflect *)MEM_dupallocN(ob_src->pd);
if (ob_dst->pd->rng) {
- ob_dst->pd->rng = MEM_dupallocN(ob_src->pd->rng);
+ ob_dst->pd->rng = (RNG *)MEM_dupallocN(ob_src->pd->rng);
}
}
BKE_rigidbody_object_copy(bmain, ob_dst, ob_src, flag_subdata);
@@ -269,7 +269,7 @@ static void object_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const in
BKE_previewimg_id_copy(&ob_dst->id, &ob_src->id);
}
else {
- ob_dst->preview = NULL;
+ ob_dst->preview = nullptr;
}
}
@@ -291,17 +291,17 @@ static void object_free_data(ID *id)
BLI_freelistN(&ob->fmaps);
if (ob->pose) {
BKE_pose_free_ex(ob->pose, false);
- ob->pose = NULL;
+ ob->pose = nullptr;
}
if (ob->mpath) {
animviz_free_motionpath(ob->mpath);
- ob->mpath = NULL;
+ ob->mpath = nullptr;
}
BKE_constraints_free_ex(&ob->constraints, false);
BKE_partdeflect_free(ob->pd);
- BKE_rigidbody_free_object(ob, NULL);
+ BKE_rigidbody_free_object(ob, nullptr);
BKE_rigidbody_free_constraint(ob);
sbFree(ob);
@@ -317,7 +317,7 @@ static void object_free_data(ID *id)
MEM_freeN((void *)ob->runtime.curve_cache->anim_path_accum_length);
}
MEM_freeN(ob->runtime.curve_cache);
- ob->runtime.curve_cache = NULL;
+ ob->runtime.curve_cache = nullptr;
}
BKE_previewimg_free(&ob->preview);
@@ -361,18 +361,18 @@ static void object_make_local(Main *bmain, ID *id, const int flags)
BKE_lib_id_clear_library_data(bmain, &ob->id, flags);
BKE_lib_id_expand_local(bmain, &ob->id, flags);
if (clear_proxy) {
- if (ob->proxy_from != NULL) {
- ob->proxy_from->proxy = NULL;
- ob->proxy_from->proxy_group = NULL;
+ if (ob->proxy_from != nullptr) {
+ ob->proxy_from->proxy = nullptr;
+ ob->proxy_from->proxy_group = nullptr;
}
- ob->proxy = ob->proxy_from = ob->proxy_group = NULL;
+ ob->proxy = ob->proxy_from = ob->proxy_group = nullptr;
}
}
else if (force_copy) {
Object *ob_new = (Object *)BKE_id_copy(bmain, &ob->id);
id_us_min(&ob_new->id);
- ob_new->proxy = ob_new->proxy_from = ob_new->proxy_group = NULL;
+ ob_new->proxy = ob_new->proxy_from = ob_new->proxy_group = nullptr;
/* setting newid is mandatory for complex make_lib_local logic... */
ID_NEW_SET(ob, ob_new);
@@ -442,11 +442,11 @@ static void object_foreach_id(ID *id, LibraryForeachIDData *data)
/* object data special case */
if (object->type == OB_EMPTY) {
- /* empty can have NULL or Image */
+ /* empty can have nullptr or Image */
BKE_LIB_FOREACHID_PROCESS_ID(data, object->data, proxy_cb_flag | IDWALK_CB_USER);
}
else {
- /* when set, this can't be NULL */
+ /* when set, this can't be nullptr */
if (object->data) {
BKE_LIB_FOREACHID_PROCESS_ID(
data, object->data, proxy_cb_flag | IDWALK_CB_USER | IDWALK_CB_NEVER_NULL);
@@ -465,7 +465,7 @@ static void object_foreach_id(ID *id, LibraryForeachIDData *data)
{
const int cb_flag_orig = BKE_lib_query_foreachid_process_callback_flag_override(
data,
- (object->proxy_from != NULL && ID_IS_LINKED(object->proxy_from)) ?
+ (object->proxy_from != nullptr && ID_IS_LINKED(object->proxy_from)) ?
IDWALK_CB_INDIRECT_USAGE :
0,
true);
@@ -562,9 +562,9 @@ static void object_blend_write(BlendWriter *writer, ID *id, const void *id_addre
BLO_write_pointer_array(writer, ob->totcol, ob->mat);
BLO_write_raw(writer, sizeof(char) * ob->totcol, ob->matbits);
- bArmature *arm = NULL;
+ bArmature *arm = nullptr;
if (ob->type == OB_ARMATURE) {
- arm = ob->data;
+ arm = (bArmature *)ob->data;
if (arm && ob->pose && arm->act_bone) {
BLI_strncpy(ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone));
}
@@ -626,7 +626,7 @@ static void object_blend_read_data(BlendDataReader *reader, ID *id)
/* XXX This should not be needed - but seems like it can happen in some cases,
* so for now play safe. */
- ob->proxy_from = NULL;
+ ob->proxy_from = nullptr;
const bool is_undo = BLO_read_data_is_undo(reader);
if (ob->id.tag & (LIB_TAG_EXTERN | LIB_TAG_INDIRECT)) {
@@ -670,10 +670,10 @@ static void object_blend_read_data(BlendDataReader *reader, ID *id)
BKE_shaderfx_blend_read_data(reader, &ob->shader_fx);
BLO_read_list(reader, &ob->effect);
- paf = ob-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list