Cleanup: Move five mesh related files to C++
To faciliate further mesh data structure refactoring. See #103343. Pull Request #105354
This commit is contained in:
@@ -91,7 +91,7 @@ struct MDeformWeight *BKE_defvert_find_index(const struct MDeformVert *dv, int d
|
||||
/**
|
||||
* Ensures that `dv` has a deform weight entry for the specified defweight group.
|
||||
*
|
||||
* \note this function is mirrored in editmesh_tools.c, for use for edit-vertices.
|
||||
* \note this function is mirrored in editmesh_tools.cc, for use for edit-vertices.
|
||||
*/
|
||||
struct MDeformWeight *BKE_defvert_ensure_index(struct MDeformVert *dv, int defgroup);
|
||||
/**
|
||||
|
||||
@@ -177,26 +177,26 @@ void BKE_gpencil_stroke_uv_update(struct bGPDstroke *gps);
|
||||
void BKE_gpencil_transform(struct bGPdata *gpd, const float mat[4][4]);
|
||||
|
||||
typedef struct GPencilPointCoordinates {
|
||||
/* This is used when doing "move only origin" in object_data_transform.c.
|
||||
/* This is used when doing "move only origin" in object_data_transform.cc.
|
||||
* pressure is needs to be stored here as it is tied to object scale. */
|
||||
float co[3];
|
||||
float pressure;
|
||||
} GPencilPointCoordinates;
|
||||
|
||||
/**
|
||||
* \note Used for "move only origins" in object_data_transform.c.
|
||||
* \note Used for "move only origins" in object_data_transform.cc.
|
||||
*/
|
||||
int BKE_gpencil_stroke_point_count(const struct bGPdata *gpd);
|
||||
/**
|
||||
* \note Used for "move only origins" in object_data_transform.c.
|
||||
* \note Used for "move only origins" in object_data_transform.cc.
|
||||
*/
|
||||
void BKE_gpencil_point_coords_get(struct bGPdata *gpd, GPencilPointCoordinates *elem_data);
|
||||
/**
|
||||
* \note Used for "move only origins" in object_data_transform.c.
|
||||
* \note Used for "move only origins" in object_data_transform.cc.
|
||||
*/
|
||||
void BKE_gpencil_point_coords_apply(struct bGPdata *gpd, const GPencilPointCoordinates *elem_data);
|
||||
/**
|
||||
* \note Used for "move only origins" in object_data_transform.c.
|
||||
* \note Used for "move only origins" in object_data_transform.cc.
|
||||
*/
|
||||
void BKE_gpencil_point_coords_apply_with_mat4(struct bGPdata *gpd,
|
||||
const GPencilPointCoordinates *elem_data,
|
||||
|
||||
@@ -514,10 +514,6 @@ struct Object *BKE_view_layer_non_active_selected_object(const struct Scene *sce
|
||||
struct ViewLayer *view_layer,
|
||||
const struct View3D *v3d);
|
||||
|
||||
#define BKE_view_layer_array_selected_objects(view_layer, v3d, r_len, ...) \
|
||||
BKE_view_layer_array_selected_objects_params( \
|
||||
view_layer, v3d, r_len, &(const struct ObjectsInViewLayerParams)__VA_ARGS__)
|
||||
|
||||
struct ObjectsInModeParams {
|
||||
int object_mode;
|
||||
uint no_dup_data : 1;
|
||||
|
||||
@@ -40,7 +40,7 @@ struct wmKeyConfig;
|
||||
struct wmOperator;
|
||||
struct wmOperatorType;
|
||||
|
||||
/* object_edit.c */
|
||||
/* object_edit.cc */
|
||||
|
||||
/** `context.object` */
|
||||
struct Object *ED_object_context(const struct bContext *C);
|
||||
@@ -737,7 +737,7 @@ void ED_object_facemap_face_add(struct Object *ob, struct bFaceMap *fmap, int fa
|
||||
*/
|
||||
void ED_object_facemap_face_remove(struct Object *ob, struct bFaceMap *fmap, int facenum);
|
||||
|
||||
/* object_data_transform.c */
|
||||
/* object_data_transform.cc */
|
||||
|
||||
struct XFormObjectData *ED_object_data_xform_create_ex(struct ID *id, bool is_edit_mode);
|
||||
struct XFormObjectData *ED_object_data_xform_create(struct ID *id);
|
||||
|
||||
@@ -39,7 +39,7 @@ set(SRC
|
||||
editmesh_inset.c
|
||||
editmesh_intersect.c
|
||||
editmesh_knife.c
|
||||
editmesh_knife_project.c
|
||||
editmesh_knife_project.cc
|
||||
editmesh_loopcut.c
|
||||
editmesh_mask_extract.cc
|
||||
editmesh_path.c
|
||||
@@ -50,7 +50,7 @@ set(SRC
|
||||
editmesh_rip_edge.c
|
||||
editmesh_select.cc
|
||||
editmesh_select_similar.c
|
||||
editmesh_tools.c
|
||||
editmesh_tools.cc
|
||||
editmesh_undo.cc
|
||||
editmesh_utils.c
|
||||
mesh_data.cc
|
||||
|
||||
@@ -52,7 +52,7 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C,
|
||||
if (ob->type == OB_MESH || ob->runtime.data_eval) {
|
||||
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
|
||||
me_eval = BKE_object_get_evaluated_mesh(ob_eval);
|
||||
if (me_eval == NULL) {
|
||||
if (me_eval == nullptr) {
|
||||
Scene *scene_eval = (Scene *)DEG_get_evaluated_id(depsgraph, &scene->id);
|
||||
me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
|
||||
}
|
||||
@@ -64,26 +64,26 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C,
|
||||
me_eval_needs_free = true;
|
||||
}
|
||||
else {
|
||||
me_eval = NULL;
|
||||
me_eval = nullptr;
|
||||
}
|
||||
|
||||
if (me_eval) {
|
||||
ListBase nurbslist = {NULL, NULL};
|
||||
ListBase nurbslist = {nullptr, nullptr};
|
||||
float projmat[4][4];
|
||||
|
||||
BKE_mesh_to_curve_nurblist(me_eval, &nurbslist, 0); /* wire */
|
||||
BKE_mesh_to_curve_nurblist(me_eval, &nurbslist, 1); /* boundary */
|
||||
|
||||
ED_view3d_ob_project_mat_get(region->regiondata, ob, projmat);
|
||||
ED_view3d_ob_project_mat_get(static_cast<RegionView3D *>(region->regiondata), ob, projmat);
|
||||
|
||||
if (nurbslist.first) {
|
||||
Nurb *nu;
|
||||
for (nu = nurbslist.first; nu; nu = nu->next) {
|
||||
LISTBASE_FOREACH (Nurb *, nu, &nurbslist) {
|
||||
if (nu->bp) {
|
||||
int a;
|
||||
BPoint *bp;
|
||||
bool is_cyclic = (nu->flagu & CU_NURB_CYCLIC) != 0;
|
||||
float(*mval)[2] = MEM_mallocN(sizeof(*mval) * (nu->pntsu + is_cyclic), __func__);
|
||||
float(*mval)[2] = static_cast<float(*)[2]>(
|
||||
MEM_mallocN(sizeof(*mval) * (nu->pntsu + is_cyclic), __func__));
|
||||
|
||||
for (bp = nu->bp, a = 0; a < nu->pntsu; a++, bp++) {
|
||||
ED_view3d_project_float_v2_m4(region, bp->vec, mval[a], projmat);
|
||||
@@ -100,7 +100,7 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C,
|
||||
BKE_nurbList_free(&nurbslist);
|
||||
|
||||
if (me_eval_needs_free) {
|
||||
BKE_id_free(NULL, (ID *)me_eval);
|
||||
BKE_id_free(nullptr, (ID *)me_eval);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ static int knifeproject_exec(bContext *C, wmOperator *op)
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
const bool cut_through = RNA_boolean_get(op->ptr, "cut_through");
|
||||
|
||||
LinkNode *polys = NULL;
|
||||
LinkNode *polys = nullptr;
|
||||
|
||||
CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
|
||||
if (BKE_object_is_in_editmode(ob)) {
|
||||
@@ -122,7 +122,7 @@ static int knifeproject_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
if (polys == NULL) {
|
||||
if (polys == nullptr) {
|
||||
BKE_report(op->reports,
|
||||
RPT_ERROR,
|
||||
"No other selected objects have wire or boundary edges to use for projection");
|
||||
File diff suppressed because it is too large
Load Diff
@@ -230,7 +230,7 @@ void MESH_OT_shortest_path_select(struct wmOperatorType *ot);
|
||||
|
||||
extern struct EnumPropertyItem *corner_type_items;
|
||||
|
||||
/* *** editmesh_tools.c *** */
|
||||
/* *** editmesh_tools.cc *** */
|
||||
void MESH_OT_subdivide(struct wmOperatorType *ot);
|
||||
void MESH_OT_subdivide_edgering(struct wmOperatorType *ot);
|
||||
void MESH_OT_unsubdivide(struct wmOperatorType *ot);
|
||||
|
||||
@@ -39,8 +39,8 @@ set(SRC
|
||||
object_collection.c
|
||||
object_constraint.c
|
||||
object_data_transfer.c
|
||||
object_data_transform.c
|
||||
object_edit.c
|
||||
object_data_transform.cc
|
||||
object_edit.cc
|
||||
object_facemap_ops.c
|
||||
object_gpencil_modifier.c
|
||||
object_hook.c
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
* so we don't lose precision over time.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "DNA_anim_types.h"
|
||||
#include "DNA_armature_types.h"
|
||||
@@ -75,10 +75,10 @@ struct ElemData_Armature {
|
||||
float zwidth;
|
||||
};
|
||||
|
||||
static struct ElemData_Armature *armature_coords_and_quats_get_recurse(
|
||||
const ListBase *bone_base, struct ElemData_Armature *elem_array)
|
||||
static ElemData_Armature *armature_coords_and_quats_get_recurse(const ListBase *bone_base,
|
||||
ElemData_Armature *elem_array)
|
||||
{
|
||||
struct ElemData_Armature *elem = elem_array;
|
||||
ElemData_Armature *elem = elem_array;
|
||||
LISTBASE_FOREACH (const Bone *, bone, bone_base) {
|
||||
|
||||
#define COPY_PTR(member) memcpy(elem->member, bone->member, sizeof(bone->member))
|
||||
@@ -102,16 +102,15 @@ static struct ElemData_Armature *armature_coords_and_quats_get_recurse(
|
||||
return elem;
|
||||
}
|
||||
|
||||
static void armature_coords_and_quats_get(const bArmature *arm,
|
||||
struct ElemData_Armature *elem_array)
|
||||
static void armature_coords_and_quats_get(const bArmature *arm, ElemData_Armature *elem_array)
|
||||
{
|
||||
armature_coords_and_quats_get_recurse(&arm->bonebase, elem_array);
|
||||
}
|
||||
|
||||
static const struct ElemData_Armature *armature_coords_and_quats_apply_with_mat4_recurse(
|
||||
ListBase *bone_base, const struct ElemData_Armature *elem_array, const float mat[4][4])
|
||||
static const ElemData_Armature *armature_coords_and_quats_apply_with_mat4_recurse(
|
||||
ListBase *bone_base, const ElemData_Armature *elem_array, const float mat[4][4])
|
||||
{
|
||||
const struct ElemData_Armature *elem = elem_array;
|
||||
const ElemData_Armature *elem = elem_array;
|
||||
LISTBASE_FOREACH (Bone *, bone, bone_base) {
|
||||
|
||||
#define COPY_PTR(member) memcpy(bone->member, elem->member, sizeof(bone->member))
|
||||
@@ -136,15 +135,14 @@ static const struct ElemData_Armature *armature_coords_and_quats_apply_with_mat4
|
||||
}
|
||||
|
||||
static void armature_coords_and_quats_apply_with_mat4(bArmature *arm,
|
||||
const struct ElemData_Armature *elem_array,
|
||||
const ElemData_Armature *elem_array,
|
||||
const float mat[4][4])
|
||||
{
|
||||
armature_coords_and_quats_apply_with_mat4_recurse(&arm->bonebase, elem_array, mat);
|
||||
BKE_armature_transform(arm, mat, true);
|
||||
}
|
||||
|
||||
static void armature_coords_and_quats_apply(bArmature *arm,
|
||||
const struct ElemData_Armature *elem_array)
|
||||
static void armature_coords_and_quats_apply(bArmature *arm, const ElemData_Armature *elem_array)
|
||||
{
|
||||
/* Avoid code duplication by using a unit matrix. */
|
||||
float mat[4][4];
|
||||
@@ -153,11 +151,11 @@ static void armature_coords_and_quats_apply(bArmature *arm,
|
||||
}
|
||||
|
||||
/* Edit Armature */
|
||||
static void edit_armature_coords_and_quats_get(const bArmature *arm,
|
||||
struct ElemData_Armature *elem_array)
|
||||
static void edit_armature_coords_and_quats_get(const bArmature *arm, ElemData_Armature *elem_array)
|
||||
{
|
||||
struct ElemData_Armature *elem = elem_array;
|
||||
for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next, elem++) {
|
||||
ElemData_Armature *elem = elem_array;
|
||||
for (EditBone *ebone = static_cast<EditBone *>(arm->edbo->first); ebone;
|
||||
ebone = ebone->next, elem++) {
|
||||
|
||||
#define COPY_PTR(member) memcpy(elem->member, ebone->member, sizeof(ebone->member))
|
||||
#define COPY_VAL(member) memcpy(&elem->member, &ebone->member, sizeof(ebone->member))
|
||||
@@ -175,11 +173,13 @@ static void edit_armature_coords_and_quats_get(const bArmature *arm,
|
||||
}
|
||||
}
|
||||
|
||||
static void edit_armature_coords_and_quats_apply_with_mat4(
|
||||
bArmature *arm, const struct ElemData_Armature *elem_array, const float mat[4][4])
|
||||
static void edit_armature_coords_and_quats_apply_with_mat4(bArmature *arm,
|
||||
const ElemData_Armature *elem_array,
|
||||
const float mat[4][4])
|
||||
{
|
||||
const struct ElemData_Armature *elem = elem_array;
|
||||
for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next, elem++) {
|
||||
const ElemData_Armature *elem = elem_array;
|
||||
for (EditBone *ebone = static_cast<EditBone *>(arm->edbo->first); ebone;
|
||||
ebone = ebone->next, elem++) {
|
||||
|
||||
#define COPY_PTR(member) memcpy(ebone->member, elem->member, sizeof(ebone->member))
|
||||
#define COPY_VAL(member) memcpy(&ebone->member, &elem->member, sizeof(ebone->member))
|
||||
@@ -199,7 +199,7 @@ static void edit_armature_coords_and_quats_apply_with_mat4(
|
||||
}
|
||||
|
||||
static void edit_armature_coords_and_quats_apply(bArmature *arm,
|
||||
const struct ElemData_Armature *elem_array)
|
||||
const ElemData_Armature *elem_array)
|
||||
{
|
||||
/* Avoid code duplication by using a unit matrix. */
|
||||
float mat[4][4];
|
||||
@@ -219,7 +219,8 @@ struct ElemData_MetaBall {
|
||||
static void metaball_coords_and_quats_get(const MetaBall *mb, struct ElemData_MetaBall *elem_array)
|
||||
{
|
||||
struct ElemData_MetaBall *elem = elem_array;
|
||||
for (const MetaElem *ml = mb->elems.first; ml; ml = ml->next, elem++) {
|
||||
for (const MetaElem *ml = static_cast<const MetaElem *>(mb->elems.first); ml;
|
||||
ml = ml->next, elem++) {
|
||||
copy_v3_v3(elem->co, &ml->x);
|
||||
copy_qt_qt(elem->quat, ml->quat);
|
||||
copy_v3_v3(elem->exp, &ml->expx);
|
||||
@@ -232,7 +233,7 @@ static void metaball_coords_and_quats_apply_with_mat4(MetaBall *mb,
|
||||
const float mat[4][4])
|
||||
{
|
||||
const struct ElemData_MetaBall *elem = elem_array;
|
||||
for (MetaElem *ml = mb->elems.first; ml; ml = ml->next, elem++) {
|
||||
for (MetaElem *ml = static_cast<MetaElem *>(mb->elems.first); ml; ml = ml->next, elem++) {
|
||||
copy_v3_v3(&ml->x, elem->co);
|
||||
copy_qt_qt(ml->quat, elem->quat);
|
||||
copy_v3_v3(&ml->expx, elem->exp);
|
||||
@@ -266,52 +267,52 @@ struct XFormObjectData {
|
||||
};
|
||||
|
||||
struct XFormObjectData_Mesh {
|
||||
struct XFormObjectData base;
|
||||
XFormObjectData base;
|
||||
/* Optional data for shape keys. */
|
||||
void *key_data;
|
||||
float elem_array[0][3];
|
||||
};
|
||||
|
||||
struct XFormObjectData_Lattice {
|
||||
struct XFormObjectData base;
|
||||
XFormObjectData base;
|
||||
/* Optional data for shape keys. */
|
||||
void *key_data;
|
||||
float elem_array[0][3];
|
||||
};
|
||||
|
||||
struct XFormObjectData_Curve {
|
||||
struct XFormObjectData base;
|
||||
XFormObjectData base;
|
||||
/* Optional data for shape keys. */
|
||||
void *key_data;
|
||||
float elem_array[0][3];
|
||||
};
|
||||
|
||||
struct XFormObjectData_Armature {
|
||||
struct XFormObjectData base;
|
||||
struct ElemData_Armature elem_array[0];
|
||||
XFormObjectData base;
|
||||
ElemData_Armature elem_array[0];
|
||||
};
|
||||
|
||||
struct XFormObjectData_MetaBall {
|
||||
struct XFormObjectData base;
|
||||
struct ElemData_MetaBall elem_array[0];
|
||||
XFormObjectData base;
|
||||
ElemData_MetaBall elem_array[0];
|
||||
};
|
||||
|
||||
struct XFormObjectData_GPencil {
|
||||
struct XFormObjectData base;
|
||||
struct GPencilPointCoordinates elem_array[0];
|
||||
XFormObjectData base;
|
||||
GPencilPointCoordinates elem_array[0];
|
||||
};
|
||||
|
||||
struct XFormObjectData *ED_object_data_xform_create_ex(ID *id, bool is_edit_mode)
|
||||
XFormObjectData *ED_object_data_xform_create_ex(ID *id, bool is_edit_mode)
|
||||
{
|
||||
struct XFormObjectData *xod_base = NULL;
|
||||
if (id == NULL) {
|
||||
XFormObjectData *xod_base = nullptr;
|
||||
if (id == nullptr) {
|
||||
return xod_base;
|
||||
}
|
||||
|
||||
switch (GS(id->name)) {
|
||||
case ID_ME: {
|
||||
Mesh *me = (Mesh *)id;
|
||||
struct Key *key = me->key;
|
||||
Key *key = me->key;
|
||||
const int key_index = -1;
|
||||
|
||||
if (is_edit_mode) {
|
||||
@@ -319,35 +320,37 @@ struct XFormObjectData *ED_object_data_xform_create_ex(ID *id, bool is_edit_mode
|
||||
/* Always operate on all keys for the moment. */
|
||||
// key_index = bm->shapenr - 1;
|
||||
const int elem_array_len = bm->totvert;
|
||||
struct XFormObjectData_Mesh *xod = MEM_mallocN(
|
||||
sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__);
|
||||
XFormObjectData_Mesh *xod = static_cast<XFormObjectData_Mesh *>(
|
||||
MEM_mallocN(sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__));
|
||||
memset(xod, 0x0, sizeof(*xod));
|
||||
|
||||
BM_mesh_vert_coords_get(bm, xod->elem_array);
|
||||
xod_base = &xod->base;
|
||||
|
||||
if (key != NULL) {
|
||||
if (key != nullptr) {
|
||||
const size_t key_size = BKE_keyblock_element_calc_size_from_shape(key, key_index);
|
||||
if (key_size) {
|
||||
xod->key_data = MEM_mallocN(key_size, __func__);
|
||||
BKE_keyblock_data_get_from_shape(key, xod->key_data, key_index);
|
||||
BKE_keyblock_data_get_from_shape(
|
||||
key, static_cast<float(*)[3]>(xod->key_data), key_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const int elem_array_len = me->totvert;
|
||||
struct XFormObjectData_Mesh *xod = MEM_mallocN(
|
||||
sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__);
|
||||
XFormObjectData_Mesh *xod = static_cast<XFormObjectData_Mesh *>(
|
||||
MEM_mallocN(sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__));
|
||||
memset(xod, 0x0, sizeof(*xod));
|
||||
|
||||
BKE_mesh_vert_coords_get(me, xod->elem_array);
|
||||
xod_base = &xod->base;
|
||||
|
||||
if (key != NULL) {
|
||||
if (key != nullptr) {
|
||||
const size_t key_size = BKE_keyblock_element_calc_size_from_shape(key, key_index);
|
||||
if (key_size) {
|
||||
xod->key_data = MEM_mallocN(key_size, __func__);
|
||||
BKE_keyblock_data_get_from_shape(key, xod->key_data, key_index);
|
||||
BKE_keyblock_data_get_from_shape(
|
||||
key, static_cast<float(*)[3]>(xod->key_data), key_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -356,7 +359,7 @@ struct XFormObjectData *ED_object_data_xform_create_ex(ID *id, bool is_edit_mode
|
||||
case ID_LT: {
|
||||
Lattice *lt_orig = (Lattice *)id;
|
||||
Lattice *lt = is_edit_mode ? lt_orig->editlatt->latt : lt_orig;
|
||||
struct Key *key = lt->key;
|
||||
Key *key = lt->key;
|
||||
const int key_index = -1;
|
||||
|
||||
if (is_edit_mode) {
|
||||
@@ -365,18 +368,19 @@ struct XFormObjectData *ED_object_data_xform_create_ex(ID *id, bool is_edit_mode
|
||||
}
|
||||
|
||||
const int elem_array_len = lt->pntsu * lt->pntsv * lt->pntsw;
|
||||
struct XFormObjectData_Lattice *xod = MEM_mallocN(
|
||||
sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__);
|
||||
XFormObjectData_Lattice *xod = static_cast<XFormObjectData_Lattice *>(
|
||||
MEM_mallocN(sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__));
|
||||
memset(xod, 0x0, sizeof(*xod));
|
||||
|
||||
BKE_lattice_vert_coords_get(lt, xod->elem_array);
|
||||
xod_base = &xod->base;
|
||||
|
||||
if (key != NULL) {
|
||||
if (key != nullptr) {
|
||||
const size_t key_size = BKE_keyblock_element_calc_size_from_shape(key, key_index);
|
||||
if (key_size) {
|
||||
xod->key_data = MEM_mallocN(key_size, __func__);
|
||||
BKE_keyblock_data_get_from_shape(key, xod->key_data, key_index);
|
||||
BKE_keyblock_data_get_from_shape(
|
||||
key, static_cast<float(*)[3]>(xod->key_data), key_index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,7 +388,7 @@ struct XFormObjectData *ED_object_data_xform_create_ex(ID *id, bool is_edit_mode
|
||||
}
|
||||
case ID_CU_LEGACY: {
|
||||
Curve *cu = (Curve *)id;
|
||||
struct Key *key = cu->key;
|
||||
Key *key = cu->key;
|
||||
|
||||
const short ob_type = BKE_curve_type_get(cu);
|
||||
if (ob_type == OB_FONT) {
|
||||
@@ -405,18 +409,19 @@ struct XFormObjectData *ED_object_data_xform_create_ex(ID *id, bool is_edit_mode
|
||||
}
|
||||
|
||||
const int elem_array_len = BKE_nurbList_verts_count(nurbs);
|
||||
struct XFormObjectData_Curve *xod = MEM_mallocN(
|
||||
sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__);
|
||||
XFormObjectData_Curve *xod = static_cast<XFormObjectData_Curve *>(
|
||||
MEM_mallocN(sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__));
|
||||
memset(xod, 0x0, sizeof(*xod));
|
||||
|
||||
BKE_curve_nurbs_vert_coords_get(nurbs, xod->elem_array, elem_array_len);
|
||||
xod_base = &xod->base;
|
||||
|
||||
if (key != NULL) {
|
||||
if (key != nullptr) {
|
||||
const size_t key_size = BKE_keyblock_element_calc_size_from_shape(key, key_index);
|
||||
if (key_size) {
|
||||
xod->key_data = MEM_mallocN(key_size, __func__);
|
||||
BKE_keyblock_data_get_from_shape(key, xod->key_data, key_index);
|
||||
BKE_keyblock_data_get_from_shape(
|
||||
key, static_cast<float(*)[3]>(xod->key_data), key_index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,8 +431,8 @@ struct XFormObjectData *ED_object_data_xform_create_ex(ID *id, bool is_edit_mode
|
||||
bArmature *arm = (bArmature *)id;
|
||||
if (is_edit_mode) {
|
||||
const int elem_array_len = BLI_listbase_count(arm->edbo);
|
||||
struct XFormObjectData_Armature *xod = MEM_mallocN(
|
||||
sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__);
|
||||
XFormObjectData_Armature *xod = static_cast<XFormObjectData_Armature *>(
|
||||
MEM_mallocN(sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__));
|
||||
memset(xod, 0x0, sizeof(*xod));
|
||||
|
||||
edit_armature_coords_and_quats_get(arm, xod->elem_array);
|
||||
@@ -435,8 +440,8 @@ struct XFormObjectData *ED_object_data_xform_create_ex(ID *id, bool is_edit_mode
|
||||
}
|
||||
else {
|
||||
const int elem_array_len = BKE_armature_bonelist_count(&arm->bonebase);
|
||||
struct XFormObjectData_Armature *xod = MEM_mallocN(
|
||||
sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__);
|
||||
XFormObjectData_Armature *xod = static_cast<XFormObjectData_Armature *>(
|
||||
MEM_mallocN(sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__));
|
||||
memset(xod, 0x0, sizeof(*xod));
|
||||
|
||||
armature_coords_and_quats_get(arm, xod->elem_array);
|
||||
@@ -448,8 +453,8 @@ struct XFormObjectData *ED_object_data_xform_create_ex(ID *id, bool is_edit_mode
|
||||
/* Edit mode and object mode are shared. */
|
||||
MetaBall *mb = (MetaBall *)id;
|
||||
const int elem_array_len = BLI_listbase_count(&mb->elems);
|
||||
struct XFormObjectData_MetaBall *xod = MEM_mallocN(
|
||||
sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__);
|
||||
XFormObjectData_MetaBall *xod = static_cast<XFormObjectData_MetaBall *>(
|
||||
MEM_mallocN(sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__));
|
||||
memset(xod, 0x0, sizeof(*xod));
|
||||
|
||||
metaball_coords_and_quats_get(mb, xod->elem_array);
|
||||
@@ -459,8 +464,8 @@ struct XFormObjectData *ED_object_data_xform_create_ex(ID *id, bool is_edit_mode
|
||||
case ID_GD: {
|
||||
bGPdata *gpd = (bGPdata *)id;
|
||||
const int elem_array_len = BKE_gpencil_stroke_point_count(gpd);
|
||||
struct XFormObjectData_GPencil *xod = MEM_mallocN(
|
||||
sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__);
|
||||
XFormObjectData_GPencil *xod = static_cast<XFormObjectData_GPencil *>(
|
||||
MEM_mallocN(sizeof(*xod) + (sizeof(*xod->elem_array) * elem_array_len), __func__));
|
||||
memset(xod, 0x0, sizeof(*xod));
|
||||
|
||||
BKE_gpencil_point_coords_get(gpd, xod->elem_array);
|
||||
@@ -492,22 +497,22 @@ void ED_object_data_xform_destroy(struct XFormObjectData *xod_base)
|
||||
{
|
||||
switch (GS(xod_base->id->name)) {
|
||||
case ID_ME: {
|
||||
struct XFormObjectData_Mesh *xod = (struct XFormObjectData_Mesh *)xod_base;
|
||||
if (xod->key_data != NULL) {
|
||||
XFormObjectData_Mesh *xod = (XFormObjectData_Mesh *)xod_base;
|
||||
if (xod->key_data != nullptr) {
|
||||
MEM_freeN(xod->key_data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ID_LT: {
|
||||
struct XFormObjectData_Lattice *xod = (struct XFormObjectData_Lattice *)xod_base;
|
||||
if (xod->key_data != NULL) {
|
||||
XFormObjectData_Lattice *xod = (XFormObjectData_Lattice *)xod_base;
|
||||
if (xod->key_data != nullptr) {
|
||||
MEM_freeN(xod->key_data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ID_CU_LEGACY: {
|
||||
struct XFormObjectData_Curve *xod = (struct XFormObjectData_Curve *)xod_base;
|
||||
if (xod->key_data != NULL) {
|
||||
XFormObjectData_Curve *xod = (XFormObjectData_Curve *)xod_base;
|
||||
if (xod->key_data != nullptr) {
|
||||
MEM_freeN(xod->key_data);
|
||||
}
|
||||
break;
|
||||
@@ -525,10 +530,10 @@ void ED_object_data_xform_by_mat4(struct XFormObjectData *xod_base, const float
|
||||
case ID_ME: {
|
||||
Mesh *me = (Mesh *)xod_base->id;
|
||||
|
||||
struct Key *key = me->key;
|
||||
Key *key = me->key;
|
||||
const int key_index = -1;
|
||||
|
||||
struct XFormObjectData_Mesh *xod = (struct XFormObjectData_Mesh *)xod_base;
|
||||
XFormObjectData_Mesh *xod = (XFormObjectData_Mesh *)xod_base;
|
||||
if (xod_base->is_edit_mode) {
|
||||
BMesh *bm = me->edit_mesh->bm;
|
||||
BM_mesh_vert_coords_apply_with_mat4(bm, xod->elem_array, mat);
|
||||
@@ -539,8 +544,9 @@ void ED_object_data_xform_by_mat4(struct XFormObjectData *xod_base, const float
|
||||
BKE_mesh_vert_coords_apply_with_mat4(me, xod->elem_array, mat);
|
||||
}
|
||||
|
||||
if (key != NULL) {
|
||||
BKE_keyblock_data_set_with_mat4(key, key_index, xod->key_data, mat);
|
||||
if (key != nullptr) {
|
||||
BKE_keyblock_data_set_with_mat4(
|
||||
key, key_index, static_cast<float(*)[3]>(xod->key_data), mat);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -549,18 +555,19 @@ void ED_object_data_xform_by_mat4(struct XFormObjectData *xod_base, const float
|
||||
Lattice *lt_orig = (Lattice *)xod_base->id;
|
||||
Lattice *lt = xod_base->is_edit_mode ? lt_orig->editlatt->latt : lt_orig;
|
||||
|
||||
struct Key *key = lt->key;
|
||||
Key *key = lt->key;
|
||||
const int key_index = -1;
|
||||
|
||||
struct XFormObjectData_Lattice *xod = (struct XFormObjectData_Lattice *)xod_base;
|
||||
XFormObjectData_Lattice *xod = (XFormObjectData_Lattice *)xod_base;
|
||||
BKE_lattice_vert_coords_apply_with_mat4(lt, xod->elem_array, mat);
|
||||
if (xod_base->is_edit_mode) {
|
||||
/* Always operate on all keys for the moment. */
|
||||
// key_index = lt_orig->editlatt->shapenr - 1;
|
||||
}
|
||||
|
||||
if ((key != NULL) && (xod->key_data != NULL)) {
|
||||
BKE_keyblock_data_set_with_mat4(key, key_index, xod->key_data, mat);
|
||||
if ((key != nullptr) && (xod->key_data != nullptr)) {
|
||||
BKE_keyblock_data_set_with_mat4(
|
||||
key, key_index, static_cast<float(*)[3]>(xod->key_data), mat);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -569,11 +576,11 @@ void ED_object_data_xform_by_mat4(struct XFormObjectData *xod_base, const float
|
||||
BLI_assert(xod_base->is_edit_mode == false); /* Not used currently. */
|
||||
Curve *cu = (Curve *)xod_base->id;
|
||||
|
||||
struct Key *key = cu->key;
|
||||
Key *key = cu->key;
|
||||
const int key_index = -1;
|
||||
ListBase *nurb = NULL;
|
||||
ListBase *nurb = nullptr;
|
||||
|
||||
struct XFormObjectData_Curve *xod = (struct XFormObjectData_Curve *)xod_base;
|
||||
XFormObjectData_Curve *xod = (XFormObjectData_Curve *)xod_base;
|
||||
if (xod_base->is_edit_mode) {
|
||||
EditNurb *editnurb = cu->editnurb;
|
||||
nurb = &editnurb->nurbs;
|
||||
@@ -587,7 +594,7 @@ void ED_object_data_xform_by_mat4(struct XFormObjectData *xod_base, const float
|
||||
BKE_curve_nurbs_vert_coords_apply_with_mat4(&cu->nurb, xod->elem_array, mat, CU_IS_2D(cu));
|
||||
}
|
||||
|
||||
if ((key != NULL) && (xod->key_data != NULL)) {
|
||||
if ((key != nullptr) && (xod->key_data != nullptr)) {
|
||||
BKE_keyblock_curve_data_set_with_mat4(key, nurb, key_index, xod->key_data, mat);
|
||||
}
|
||||
|
||||
@@ -596,7 +603,7 @@ void ED_object_data_xform_by_mat4(struct XFormObjectData *xod_base, const float
|
||||
case ID_AR: {
|
||||
BLI_assert(xod_base->is_edit_mode == false); /* Not used currently. */
|
||||
bArmature *arm = (bArmature *)xod_base->id;
|
||||
struct XFormObjectData_Armature *xod = (struct XFormObjectData_Armature *)xod_base;
|
||||
XFormObjectData_Armature *xod = (XFormObjectData_Armature *)xod_base;
|
||||
if (xod_base->is_edit_mode) {
|
||||
edit_armature_coords_and_quats_apply_with_mat4(arm, xod->elem_array, mat);
|
||||
}
|
||||
@@ -608,13 +615,13 @@ void ED_object_data_xform_by_mat4(struct XFormObjectData *xod_base, const float
|
||||
case ID_MB: {
|
||||
/* Metaballs are a special case, edit-mode and object mode data is shared. */
|
||||
MetaBall *mb = (MetaBall *)xod_base->id;
|
||||
struct XFormObjectData_MetaBall *xod = (struct XFormObjectData_MetaBall *)xod_base;
|
||||
XFormObjectData_MetaBall *xod = (XFormObjectData_MetaBall *)xod_base;
|
||||
metaball_coords_and_quats_apply_with_mat4(mb, xod->elem_array, mat);
|
||||
break;
|
||||
}
|
||||
case ID_GD: {
|
||||
bGPdata *gpd = (bGPdata *)xod_base->id;
|
||||
struct XFormObjectData_GPencil *xod = (struct XFormObjectData_GPencil *)xod_base;
|
||||
XFormObjectData_GPencil *xod = (XFormObjectData_GPencil *)xod_base;
|
||||
BKE_gpencil_point_coords_apply_with_mat4(gpd, xod->elem_array, mat);
|
||||
break;
|
||||
}
|
||||
@@ -630,10 +637,10 @@ void ED_object_data_xform_restore(struct XFormObjectData *xod_base)
|
||||
case ID_ME: {
|
||||
Mesh *me = (Mesh *)xod_base->id;
|
||||
|
||||
struct Key *key = me->key;
|
||||
Key *key = me->key;
|
||||
const int key_index = -1;
|
||||
|
||||
struct XFormObjectData_Mesh *xod = (struct XFormObjectData_Mesh *)xod_base;
|
||||
XFormObjectData_Mesh *xod = (XFormObjectData_Mesh *)xod_base;
|
||||
if (xod_base->is_edit_mode) {
|
||||
BMesh *bm = me->edit_mesh->bm;
|
||||
BM_mesh_vert_coords_apply(bm, xod->elem_array);
|
||||
@@ -644,7 +651,7 @@ void ED_object_data_xform_restore(struct XFormObjectData *xod_base)
|
||||
BKE_mesh_vert_coords_apply(me, xod->elem_array);
|
||||
}
|
||||
|
||||
if ((key != NULL) && (xod->key_data != NULL)) {
|
||||
if ((key != nullptr) && (xod->key_data != nullptr)) {
|
||||
BKE_keyblock_data_set(key, key_index, xod->key_data);
|
||||
}
|
||||
|
||||
@@ -654,17 +661,17 @@ void ED_object_data_xform_restore(struct XFormObjectData *xod_base)
|
||||
Lattice *lt_orig = (Lattice *)xod_base->id;
|
||||
Lattice *lt = xod_base->is_edit_mode ? lt_orig->editlatt->latt : lt_orig;
|
||||
|
||||
struct Key *key = lt->key;
|
||||
Key *key = lt->key;
|
||||
const int key_index = -1;
|
||||
|
||||
struct XFormObjectData_Lattice *xod = (struct XFormObjectData_Lattice *)xod_base;
|
||||
XFormObjectData_Lattice *xod = (XFormObjectData_Lattice *)xod_base;
|
||||
BKE_lattice_vert_coords_apply(lt, xod->elem_array);
|
||||
if (xod_base->is_edit_mode) {
|
||||
/* Always operate on all keys for the moment. */
|
||||
// key_index = lt_orig->editlatt->shapenr - 1;
|
||||
}
|
||||
|
||||
if ((key != NULL) && (xod->key_data != NULL)) {
|
||||
if ((key != nullptr) && (xod->key_data != nullptr)) {
|
||||
BKE_keyblock_data_set(key, key_index, xod->key_data);
|
||||
}
|
||||
|
||||
@@ -673,10 +680,10 @@ void ED_object_data_xform_restore(struct XFormObjectData *xod_base)
|
||||
case ID_CU_LEGACY: {
|
||||
Curve *cu = (Curve *)xod_base->id;
|
||||
|
||||
struct Key *key = cu->key;
|
||||
Key *key = cu->key;
|
||||
const int key_index = -1;
|
||||
|
||||
struct XFormObjectData_Curve *xod = (struct XFormObjectData_Curve *)xod_base;
|
||||
XFormObjectData_Curve *xod = (XFormObjectData_Curve *)xod_base;
|
||||
if (xod_base->is_edit_mode) {
|
||||
EditNurb *editnurb = cu->editnurb;
|
||||
BKE_curve_nurbs_vert_coords_apply(&editnurb->nurbs, xod->elem_array, CU_IS_2D(cu));
|
||||
@@ -687,7 +694,7 @@ void ED_object_data_xform_restore(struct XFormObjectData *xod_base)
|
||||
BKE_curve_nurbs_vert_coords_apply(&cu->nurb, xod->elem_array, CU_IS_2D(cu));
|
||||
}
|
||||
|
||||
if ((key != NULL) && (xod->key_data != NULL)) {
|
||||
if ((key != nullptr) && (xod->key_data != nullptr)) {
|
||||
BKE_keyblock_data_set(key, key_index, xod->key_data);
|
||||
}
|
||||
|
||||
@@ -695,7 +702,7 @@ void ED_object_data_xform_restore(struct XFormObjectData *xod_base)
|
||||
}
|
||||
case ID_AR: {
|
||||
bArmature *arm = (bArmature *)xod_base->id;
|
||||
struct XFormObjectData_Armature *xod = (struct XFormObjectData_Armature *)xod_base;
|
||||
XFormObjectData_Armature *xod = (XFormObjectData_Armature *)xod_base;
|
||||
if (xod_base->is_edit_mode) {
|
||||
edit_armature_coords_and_quats_apply(arm, xod->elem_array);
|
||||
}
|
||||
@@ -707,13 +714,13 @@ void ED_object_data_xform_restore(struct XFormObjectData *xod_base)
|
||||
case ID_MB: {
|
||||
/* Metaballs are a special case, edit-mode and object mode data is shared. */
|
||||
MetaBall *mb = (MetaBall *)xod_base->id;
|
||||
struct XFormObjectData_MetaBall *xod = (struct XFormObjectData_MetaBall *)xod_base;
|
||||
XFormObjectData_MetaBall *xod = (XFormObjectData_MetaBall *)xod_base;
|
||||
metaball_coords_and_quats_apply(mb, xod->elem_array);
|
||||
break;
|
||||
}
|
||||
case ID_GD: {
|
||||
bGPdata *gpd = (bGPdata *)xod_base->id;
|
||||
struct XFormObjectData_GPencil *xod = (struct XFormObjectData_GPencil *)xod_base;
|
||||
XFormObjectData_GPencil *xod = (XFormObjectData_GPencil *)xod_base;
|
||||
BKE_gpencil_point_coords_apply(gpd, xod->elem_array);
|
||||
break;
|
||||
}
|
||||
@@ -729,12 +736,11 @@ void ED_object_data_xform_tag_update(struct XFormObjectData *xod_base)
|
||||
case ID_ME: {
|
||||
Mesh *me = (Mesh *)xod_base->id;
|
||||
if (xod_base->is_edit_mode) {
|
||||
EDBM_update(me,
|
||||
&(const struct EDBMUpdate_Params){
|
||||
.calc_looptri = true,
|
||||
.calc_normals = true,
|
||||
.is_destructive = false,
|
||||
});
|
||||
EDBMUpdate_Params params{};
|
||||
params.calc_looptri = true;
|
||||
params.calc_normals = true;
|
||||
params.is_destructive = false;
|
||||
EDBM_update(me, ¶ms);
|
||||
}
|
||||
DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY);
|
||||
break;
|
||||
@@ -108,9 +108,8 @@
|
||||
static CLG_LogRef LOG = {"ed.object.edit"};
|
||||
|
||||
/* prototypes */
|
||||
typedef struct MoveToCollectionData MoveToCollectionData;
|
||||
static void move_to_collection_menus_items(struct uiLayout *layout,
|
||||
struct MoveToCollectionData *menu);
|
||||
struct MoveToCollectionData;
|
||||
static void move_to_collection_menus_items(uiLayout *layout, MoveToCollectionData *menu);
|
||||
static ListBase selected_objects_get(bContext *C);
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -119,12 +118,12 @@ static ListBase selected_objects_get(bContext *C);
|
||||
|
||||
Object *ED_object_context(const bContext *C)
|
||||
{
|
||||
return CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
||||
return static_cast<Object *>(CTX_data_pointer_get_type(C, "object", &RNA_Object).data);
|
||||
}
|
||||
|
||||
Object *ED_object_active_context(const bContext *C)
|
||||
{
|
||||
Object *ob = NULL;
|
||||
Object *ob = nullptr;
|
||||
if (C) {
|
||||
ob = ED_object_context(C);
|
||||
if (!ob) {
|
||||
@@ -144,17 +143,17 @@ Object **ED_object_array_in_mode_or_selected(bContext *C,
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
BKE_view_layer_synced_ensure(scene, view_layer);
|
||||
Object *ob_active = BKE_view_layer_active_object_get(view_layer);
|
||||
ID *id_pin = NULL;
|
||||
const bool use_objects_in_mode = (ob_active != NULL) &&
|
||||
ID *id_pin = nullptr;
|
||||
const bool use_objects_in_mode = (ob_active != nullptr) &&
|
||||
(ob_active->mode & (OB_MODE_EDIT | OB_MODE_POSE));
|
||||
const char space_type = area ? area->spacetype : SPACE_EMPTY;
|
||||
Object **objects;
|
||||
|
||||
Object *ob = NULL;
|
||||
Object *ob = nullptr;
|
||||
bool use_ob = true;
|
||||
|
||||
if (space_type == SPACE_PROPERTIES) {
|
||||
SpaceProperties *sbuts = area->spacedata.first;
|
||||
SpaceProperties *sbuts = static_cast<SpaceProperties *>(area->spacedata.first);
|
||||
id_pin = sbuts->pinid;
|
||||
}
|
||||
|
||||
@@ -182,21 +181,23 @@ Object **ED_object_array_in_mode_or_selected(bContext *C,
|
||||
}
|
||||
|
||||
if (use_ob) {
|
||||
if ((ob != NULL) && !filter_fn(ob, filter_user_data)) {
|
||||
ob = NULL;
|
||||
if ((ob != nullptr) && !filter_fn(ob, filter_user_data)) {
|
||||
ob = nullptr;
|
||||
}
|
||||
*r_objects_len = (ob != NULL) ? 1 : 0;
|
||||
objects = MEM_mallocN(sizeof(*objects) * *r_objects_len, __func__);
|
||||
if (ob != NULL) {
|
||||
*r_objects_len = (ob != nullptr) ? 1 : 0;
|
||||
objects = static_cast<Object **>(MEM_mallocN(sizeof(*objects) * *r_objects_len, __func__));
|
||||
if (ob != nullptr) {
|
||||
objects[0] = ob;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const View3D *v3d = (space_type == SPACE_VIEW3D) ? area->spacedata.first : NULL;
|
||||
const View3D *v3d = (space_type == SPACE_VIEW3D) ?
|
||||
static_cast<const View3D *>(area->spacedata.first) :
|
||||
nullptr;
|
||||
/* When in a mode that supports multiple active objects, use "objects in mode"
|
||||
* instead of the object's selection. */
|
||||
if (use_objects_in_mode) {
|
||||
struct ObjectsInModeParams params = {0};
|
||||
ObjectsInModeParams params = {0};
|
||||
params.object_mode = ob_active->mode;
|
||||
params.no_dup_data = true;
|
||||
params.filter_fn = filter_fn;
|
||||
@@ -205,11 +206,12 @@ Object **ED_object_array_in_mode_or_selected(bContext *C,
|
||||
scene, view_layer, v3d, r_objects_len, ¶ms);
|
||||
}
|
||||
else {
|
||||
objects = BKE_view_layer_array_selected_objects(
|
||||
view_layer,
|
||||
v3d,
|
||||
r_objects_len,
|
||||
{.no_dup_data = true, .filter_fn = filter_fn, .filter_userdata = filter_user_data});
|
||||
ObjectsInViewLayerParams params{};
|
||||
params.no_dup_data = true;
|
||||
params.filter_fn = filter_fn;
|
||||
params.filter_userdata = filter_user_data;
|
||||
objects = BKE_view_layer_array_selected_objects_params(
|
||||
view_layer, v3d, r_objects_len, ¶ms);
|
||||
}
|
||||
}
|
||||
return objects;
|
||||
@@ -226,12 +228,13 @@ int ED_object_in_mode_to_index(const Scene *scene,
|
||||
const eObjectMode mode,
|
||||
const Object *ob)
|
||||
{
|
||||
BLI_assert(ob != NULL);
|
||||
/* NOTE: the `v3d` is always NULL because the purpose of this function is to return
|
||||
* a reusable index, using the `v3d` only increases the chance the index may become invalid. */
|
||||
BLI_assert(ob != nullptr);
|
||||
/* NOTE: the `v3d` is always nullptr because the purpose of this function is to return
|
||||
* a reusable index, using the `v3d` only increases the chance the index may become
|
||||
* invalidparams. */
|
||||
int index = -1;
|
||||
int i = 0;
|
||||
FOREACH_BASE_IN_MODE_BEGIN (scene, view_layer, NULL, -1, mode, base_iter) {
|
||||
FOREACH_BASE_IN_MODE_BEGIN (scene, view_layer, nullptr, -1, mode, base_iter) {
|
||||
if (base_iter->object == ob) {
|
||||
index = i;
|
||||
break;
|
||||
@@ -248,9 +251,9 @@ Object *ED_object_in_mode_from_index(const Scene *scene,
|
||||
int index)
|
||||
{
|
||||
BLI_assert(index >= 0);
|
||||
Object *ob = NULL;
|
||||
Object *ob = nullptr;
|
||||
int i = 0;
|
||||
FOREACH_BASE_IN_MODE_BEGIN (scene, view_layer, NULL, -1, mode, base_iter) {
|
||||
FOREACH_BASE_IN_MODE_BEGIN (scene, view_layer, nullptr, -1, mode, base_iter) {
|
||||
if (index == i) {
|
||||
ob = base_iter->object;
|
||||
break;
|
||||
@@ -269,7 +272,7 @@ Object *ED_object_in_mode_from_index(const Scene *scene,
|
||||
|
||||
static bool object_hide_poll(bContext *C)
|
||||
{
|
||||
if (CTX_wm_space_outliner(C) != NULL) {
|
||||
if (CTX_wm_space_outliner(C) != nullptr) {
|
||||
return ED_outliner_collections_editor_poll(C);
|
||||
}
|
||||
return ED_operator_view3d_active(C);
|
||||
@@ -324,7 +327,7 @@ void OBJECT_OT_hide_view_clear(wmOperatorType *ot)
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
PropertyRNA *prop = RNA_def_boolean(ot->srna, "select", true, "Select", "");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_SKIP_SAVE | PROP_HIDDEN));
|
||||
}
|
||||
|
||||
static int object_hide_view_set_exec(bContext *C, wmOperator *op)
|
||||
@@ -385,7 +388,7 @@ void OBJECT_OT_hide_view_set(wmOperatorType *ot)
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_boolean(
|
||||
ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_SKIP_SAVE | PROP_HIDDEN));
|
||||
}
|
||||
|
||||
static int object_hide_collection_exec(bContext *C, wmOperator *op)
|
||||
@@ -433,7 +436,7 @@ void ED_collection_hide_menu_draw(const bContext *C, uiLayout *layout)
|
||||
{
|
||||
const Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
LayerCollection *lc_scene = view_layer->layer_collections.first;
|
||||
LayerCollection *lc_scene = static_cast<LayerCollection *>(view_layer->layer_collections.first);
|
||||
|
||||
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
|
||||
|
||||
@@ -466,7 +469,7 @@ void ED_collection_hide_menu_draw(const bContext *C, uiLayout *layout)
|
||||
}
|
||||
}
|
||||
|
||||
static int object_hide_collection_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int object_hide_collection_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
/* Immediately execute if collection index was specified. */
|
||||
int index = RNA_int_get(op->ptr, "collection_index");
|
||||
@@ -512,11 +515,11 @@ void OBJECT_OT_hide_collection(wmOperatorType *ot)
|
||||
"Index of the collection to change visibility",
|
||||
0,
|
||||
INT_MAX);
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_SKIP_SAVE | PROP_HIDDEN));
|
||||
prop = RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", "Toggle visibility");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_SKIP_SAVE | PROP_HIDDEN));
|
||||
prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend visibility");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_SKIP_SAVE | PROP_HIDDEN));
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -559,13 +562,13 @@ static bool ED_object_editmode_load_free_ex(Main *bmain,
|
||||
{
|
||||
BLI_assert(load_data || free_data);
|
||||
|
||||
if (obedit == NULL) {
|
||||
if (obedit == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obedit->type == OB_MESH) {
|
||||
Mesh *me = obedit->data;
|
||||
if (me->edit_mesh == NULL) {
|
||||
Mesh *me = static_cast<Mesh *>(obedit->data);
|
||||
if (me->edit_mesh == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -585,7 +588,7 @@ static bool ED_object_editmode_load_free_ex(Main *bmain,
|
||||
if (free_data) {
|
||||
EDBM_mesh_free_data(me->edit_mesh);
|
||||
MEM_freeN(me->edit_mesh);
|
||||
me->edit_mesh = NULL;
|
||||
me->edit_mesh = nullptr;
|
||||
}
|
||||
/* will be recalculated as needed. */
|
||||
{
|
||||
@@ -594,22 +597,22 @@ static bool ED_object_editmode_load_free_ex(Main *bmain,
|
||||
}
|
||||
}
|
||||
else if (obedit->type == OB_ARMATURE) {
|
||||
const bArmature *arm = obedit->data;
|
||||
if (arm->edbo == NULL) {
|
||||
const bArmature *arm = static_cast<const bArmature *>(obedit->data);
|
||||
if (arm->edbo == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (load_data) {
|
||||
ED_armature_from_edit(bmain, obedit->data);
|
||||
ED_armature_from_edit(bmain, static_cast<bArmature *>(obedit->data));
|
||||
}
|
||||
|
||||
if (free_data) {
|
||||
ED_armature_edit_free(obedit->data);
|
||||
ED_armature_edit_free(static_cast<bArmature *>(obedit->data));
|
||||
|
||||
if (load_data == false) {
|
||||
/* Don't keep unused pose channels created by duplicating bones
|
||||
* which may have been deleted/undone, see: #87631. */
|
||||
if (obedit->pose != NULL) {
|
||||
if (obedit->pose != nullptr) {
|
||||
BKE_pose_channels_clear_with_null_bone(obedit->pose, true);
|
||||
}
|
||||
}
|
||||
@@ -621,8 +624,8 @@ static bool ED_object_editmode_load_free_ex(Main *bmain,
|
||||
DEG_relations_tag_update(bmain);
|
||||
}
|
||||
else if (ELEM(obedit->type, OB_CURVES_LEGACY, OB_SURF)) {
|
||||
const Curve *cu = obedit->data;
|
||||
if (cu->editnurb == NULL) {
|
||||
const Curve *cu = static_cast<const Curve *>(obedit->data);
|
||||
if (cu->editnurb == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -635,8 +638,8 @@ static bool ED_object_editmode_load_free_ex(Main *bmain,
|
||||
}
|
||||
}
|
||||
else if (obedit->type == OB_FONT) {
|
||||
const Curve *cu = obedit->data;
|
||||
if (cu->editfont == NULL) {
|
||||
const Curve *cu = static_cast<const Curve *>(obedit->data);
|
||||
if (cu->editfont == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -649,8 +652,8 @@ static bool ED_object_editmode_load_free_ex(Main *bmain,
|
||||
}
|
||||
}
|
||||
else if (obedit->type == OB_LATTICE) {
|
||||
const Lattice *lt = obedit->data;
|
||||
if (lt->editlatt == NULL) {
|
||||
const Lattice *lt = static_cast<const Lattice *>(obedit->data);
|
||||
if (lt->editlatt == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -663,8 +666,8 @@ static bool ED_object_editmode_load_free_ex(Main *bmain,
|
||||
}
|
||||
}
|
||||
else if (obedit->type == OB_MBALL) {
|
||||
const MetaBall *mb = obedit->data;
|
||||
if (mb->editelems == NULL) {
|
||||
const MetaBall *mb = static_cast<const MetaBall *>(obedit->data);
|
||||
if (mb->editelems == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -684,7 +687,8 @@ static bool ED_object_editmode_load_free_ex(Main *bmain,
|
||||
}
|
||||
|
||||
if (load_data) {
|
||||
char *needs_flush_ptr = BKE_object_data_editmode_flush_ptr_get(obedit->data);
|
||||
char *needs_flush_ptr = BKE_object_data_editmode_flush_ptr_get(
|
||||
static_cast<ID *>(obedit->data));
|
||||
if (needs_flush_ptr) {
|
||||
*needs_flush_ptr = false;
|
||||
}
|
||||
@@ -757,7 +761,7 @@ bool ED_object_editmode_exit_multi_ex(Main *bmain, Scene *scene, ViewLayer *view
|
||||
{
|
||||
BKE_view_layer_synced_ensure(scene, view_layer);
|
||||
Object *obedit = BKE_view_layer_edit_object_get(view_layer);
|
||||
if (obedit == NULL) {
|
||||
if (obedit == nullptr) {
|
||||
return false;
|
||||
}
|
||||
bool changed = false;
|
||||
@@ -785,7 +789,7 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED(ob) || ID_IS_OVERRIDE_LIBRARY(ob) ||
|
||||
if (ELEM(nullptr, ob, ob->data) || ID_IS_LINKED(ob) || ID_IS_OVERRIDE_LIBRARY(ob) ||
|
||||
ID_IS_OVERRIDE_LIBRARY(ob->data)) {
|
||||
return false;
|
||||
}
|
||||
@@ -810,7 +814,7 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag
|
||||
if (ob->type == OB_MESH) {
|
||||
ok = true;
|
||||
|
||||
const bool use_key_index = mesh_needs_keyindex(bmain, ob->data);
|
||||
const bool use_key_index = mesh_needs_keyindex(bmain, static_cast<const Mesh *>(ob->data));
|
||||
|
||||
EDBM_mesh_make(ob, scene->toolsettings->selectmode, use_key_index);
|
||||
|
||||
@@ -819,10 +823,10 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag
|
||||
BKE_editmesh_looptri_and_normals_calc(em);
|
||||
}
|
||||
|
||||
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_MESH, NULL);
|
||||
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_MESH, nullptr);
|
||||
}
|
||||
else if (ob->type == OB_ARMATURE) {
|
||||
bArmature *arm = ob->data;
|
||||
bArmature *arm = static_cast<bArmature *>(ob->data);
|
||||
ok = true;
|
||||
ED_armature_to_edit(arm);
|
||||
/* To ensure all goes in rest-position and without striding. */
|
||||
@@ -841,7 +845,7 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag
|
||||
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_TEXT, scene);
|
||||
}
|
||||
else if (ob->type == OB_MBALL) {
|
||||
MetaBall *mb = ob->data;
|
||||
MetaBall *mb = static_cast<MetaBall *>(ob->data);
|
||||
|
||||
ok = true;
|
||||
ED_mball_editmball_make(ob);
|
||||
@@ -901,10 +905,10 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op)
|
||||
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
||||
const int mode_flag = OB_MODE_EDIT;
|
||||
const bool is_mode_set = (obact->mode & mode_flag) != 0;
|
||||
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
|
||||
wmMsgBus *mbus = CTX_wm_message_bus(C);
|
||||
|
||||
if (!is_mode_set) {
|
||||
if (!ED_object_mode_compat_set(C, obact, mode_flag, op->reports)) {
|
||||
if (!ED_object_mode_compat_set(C, obact, eObjectMode(mode_flag), op->reports)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
}
|
||||
@@ -947,7 +951,7 @@ static bool editmode_toggle_poll(bContext *C)
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
|
||||
/* Covers liboverrides too. */
|
||||
if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED(ob->data) || ID_IS_OVERRIDE_LIBRARY(ob) ||
|
||||
if (ELEM(nullptr, ob, ob->data) || ID_IS_LINKED(ob->data) || ID_IS_OVERRIDE_LIBRARY(ob) ||
|
||||
ID_IS_OVERRIDE_LIBRARY(ob->data)) {
|
||||
return false;
|
||||
}
|
||||
@@ -984,14 +988,14 @@ void OBJECT_OT_editmode_toggle(wmOperatorType *ot)
|
||||
|
||||
static int posemode_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
|
||||
struct Main *bmain = CTX_data_main(C);
|
||||
wmMsgBus *mbus = CTX_wm_message_bus(C);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
Base *base = CTX_data_active_base(C);
|
||||
|
||||
/* If the base is NULL it means we have an active object, but the object itself is hidden. */
|
||||
if (base == NULL) {
|
||||
/* If the base is nullptr it means we have an active object, but the object itself is hidden. */
|
||||
if (base == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
@@ -1000,7 +1004,7 @@ static int posemode_exec(bContext *C, wmOperator *op)
|
||||
bool is_mode_set = (obact->mode & mode_flag) != 0;
|
||||
|
||||
if (!is_mode_set) {
|
||||
if (!ED_object_mode_compat_set(C, obact, mode_flag, op->reports)) {
|
||||
if (!ED_object_mode_compat_set(C, obact, eObjectMode(mode_flag), op->reports)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
}
|
||||
@@ -1083,23 +1087,23 @@ void ED_object_check_force_modifiers(Main *bmain, Scene *scene, Object *object)
|
||||
if (pd && (pd->shape == PFIELD_SHAPE_SURFACE) &&
|
||||
!ELEM(pd->forcefield, 0, PFIELD_GUIDE, PFIELD_TEXTURE)) {
|
||||
if (ELEM(object->type, OB_MESH, OB_SURF, OB_FONT, OB_CURVES_LEGACY)) {
|
||||
ED_object_modifier_add(NULL, bmain, scene, object, NULL, eModifierType_Surface);
|
||||
ED_object_modifier_add(nullptr, bmain, scene, object, nullptr, eModifierType_Surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!pd || (pd->shape != PFIELD_SHAPE_SURFACE) ||
|
||||
ELEM(pd->forcefield, 0, PFIELD_GUIDE, PFIELD_TEXTURE)) {
|
||||
ED_object_modifier_remove(NULL, bmain, scene, object, md);
|
||||
ED_object_modifier_remove(nullptr, bmain, scene, object, md);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int forcefield_toggle_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
|
||||
if (ob->pd == NULL) {
|
||||
if (ob->pd == nullptr) {
|
||||
ob->pd = BKE_partdeflect_new(PFIELD_FORCE);
|
||||
}
|
||||
else if (ob->pd->forcefield == 0) {
|
||||
@@ -1155,7 +1159,7 @@ static eAnimvizCalcRange object_path_convert_range(eObjectPathCalcRange range)
|
||||
|
||||
void ED_objects_recalculate_paths_selected(bContext *C, Scene *scene, eObjectPathCalcRange range)
|
||||
{
|
||||
ListBase selected_objects = {NULL, NULL};
|
||||
ListBase selected_objects = {nullptr, nullptr};
|
||||
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
|
||||
BLI_addtail(&selected_objects, BLI_genericNodeN(ob));
|
||||
}
|
||||
@@ -1168,7 +1172,7 @@ void ED_objects_recalculate_paths_selected(bContext *C, Scene *scene, eObjectPat
|
||||
|
||||
void ED_objects_recalculate_paths_visible(bContext *C, Scene *scene, eObjectPathCalcRange range)
|
||||
{
|
||||
ListBase visible_objects = {NULL, NULL};
|
||||
ListBase visible_objects = {nullptr, nullptr};
|
||||
CTX_DATA_BEGIN (C, Object *, ob, visible_objects) {
|
||||
BLI_addtail(&visible_objects, BLI_genericNodeN(ob));
|
||||
}
|
||||
@@ -1195,16 +1199,16 @@ void ED_objects_recalculate_paths(bContext *C,
|
||||
ListBase *ld_objects)
|
||||
{
|
||||
/* Transform doesn't always have context available to do update. */
|
||||
if (C == NULL) {
|
||||
if (C == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
Main *bmain = CTX_data_main(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
|
||||
ListBase targets = {NULL, NULL};
|
||||
ListBase targets = {nullptr, nullptr};
|
||||
LISTBASE_FOREACH (LinkData *, link, ld_objects) {
|
||||
Object *ob = link->data;
|
||||
Object *ob = static_cast<Object *>(link->data);
|
||||
|
||||
/* set flag to force recalc, then grab path(s) from object */
|
||||
if (has_object_motion_paths(ob)) {
|
||||
@@ -1242,7 +1246,7 @@ void ED_objects_recalculate_paths(bContext *C,
|
||||
/* Tag objects for copy on write - so paths will draw/redraw
|
||||
* For currently frame only we update evaluated object directly. */
|
||||
LISTBASE_FOREACH (LinkData *, link, ld_objects) {
|
||||
Object *ob = link->data;
|
||||
Object *ob = static_cast<Object *>(link->data);
|
||||
|
||||
if (has_object_motion_paths(ob) || has_pose_motion_paths(ob)) {
|
||||
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
|
||||
@@ -1257,11 +1261,11 @@ void ED_objects_recalculate_paths(bContext *C,
|
||||
}
|
||||
|
||||
/* show popup to determine settings */
|
||||
static int object_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int object_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
|
||||
if (ob == NULL) {
|
||||
if (ob == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
@@ -1293,7 +1297,7 @@ static int object_calculate_paths_exec(bContext *C, wmOperator *op)
|
||||
animviz_motionpath_compute_range(ob, scene);
|
||||
|
||||
/* verify that the selected object has the appropriate settings */
|
||||
animviz_verify_motionpaths(op->reports, scene, ob, NULL);
|
||||
animviz_verify_motionpaths(op->reports, scene, ob, nullptr);
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
@@ -1301,10 +1305,10 @@ static int object_calculate_paths_exec(bContext *C, wmOperator *op)
|
||||
ED_objects_recalculate_paths_selected(C, scene, OBJECT_PATH_CALC_RANGE_FULL);
|
||||
|
||||
/* notifiers for updates */
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW_ANIMVIZ, NULL);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW_ANIMVIZ, nullptr);
|
||||
/* NOTE: the notifier below isn't actually correct, but kept around just to be on the safe side.
|
||||
* If further testing shows it's not necessary (for both bones and objects) removal is fine. */
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM | ND_POSE, NULL);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM | ND_POSE, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1359,13 +1363,13 @@ static int object_update_paths_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
if (scene == NULL) {
|
||||
if (scene == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
|
||||
animviz_motionpath_compute_range(ob, scene);
|
||||
/* verify that the selected object has the appropriate settings */
|
||||
animviz_verify_motionpaths(op->reports, scene, ob, NULL);
|
||||
animviz_verify_motionpaths(op->reports, scene, ob, nullptr);
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
@@ -1373,10 +1377,10 @@ static int object_update_paths_exec(bContext *C, wmOperator *op)
|
||||
ED_objects_recalculate_paths_selected(C, scene, OBJECT_PATH_CALC_RANGE_FULL);
|
||||
|
||||
/* notifiers for updates */
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW_ANIMVIZ, NULL);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW_ANIMVIZ, nullptr);
|
||||
/* NOTE: the notifier below isn't actually correct, but kept around just to be on the safe side.
|
||||
* If further testing shows it's not necessary (for both bones and objects) removal is fine. */
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM | ND_POSE, NULL);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM | ND_POSE, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1402,22 +1406,22 @@ void OBJECT_OT_paths_update(wmOperatorType *ot)
|
||||
/** \name Update All Motion Paths Operator
|
||||
* \{ */
|
||||
|
||||
static bool object_update_all_paths_poll(bContext *UNUSED(C))
|
||||
static bool object_update_all_paths_poll(bContext * /*C*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static int object_update_all_paths_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int object_update_all_paths_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
if (scene == NULL) {
|
||||
if (scene == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
ED_objects_recalculate_paths_visible(C, scene, OBJECT_PATH_CALC_RANGE_FULL);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE | ND_TRANSFORM, NULL);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE | ND_TRANSFORM, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1448,7 +1452,7 @@ static void object_clear_mpath(Object *ob)
|
||||
{
|
||||
if (ob->mpath) {
|
||||
animviz_free_motionpath(ob->mpath);
|
||||
ob->mpath = NULL;
|
||||
ob->mpath = nullptr;
|
||||
ob->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
|
||||
|
||||
/* tag object for copy on write - so removed paths don't still show */
|
||||
@@ -1483,14 +1487,14 @@ static int object_clear_paths_exec(bContext *C, wmOperator *op)
|
||||
ED_objects_clear_paths(C, only_selected);
|
||||
|
||||
/* notifiers for updates */
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static char *object_clear_paths_description(struct bContext *UNUSED(C),
|
||||
struct wmOperatorType *UNUSED(ot),
|
||||
struct PointerRNA *ptr)
|
||||
static char *object_clear_paths_description(bContext * /*C*/,
|
||||
wmOperatorType * /*ot*/,
|
||||
PointerRNA *ptr)
|
||||
{
|
||||
const bool only_selected = RNA_boolean_get(ptr, "only_selected");
|
||||
if (only_selected) {
|
||||
@@ -1534,8 +1538,8 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
|
||||
bool changed_multi = false;
|
||||
bool has_linked_data = false;
|
||||
|
||||
ListBase ctx_objects = {NULL, NULL};
|
||||
CollectionPointerLink ctx_ob_single_active = {NULL};
|
||||
ListBase ctx_objects = {nullptr, nullptr};
|
||||
CollectionPointerLink ctx_ob_single_active = {nullptr};
|
||||
|
||||
/* For modes that only use an active object, don't handle the whole selection. */
|
||||
{
|
||||
@@ -1554,9 +1558,9 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (CollectionPointerLink *, ctx_ob, &ctx_objects) {
|
||||
Object *ob = ctx_ob->ptr.data;
|
||||
ID *data = ob->data;
|
||||
if (data != NULL) {
|
||||
Object *ob = static_cast<Object *>(ctx_ob->ptr.data);
|
||||
ID *data = static_cast<ID *>(ob->data);
|
||||
if (data != nullptr) {
|
||||
data->tag |= LIB_TAG_DOIT;
|
||||
}
|
||||
}
|
||||
@@ -1564,9 +1568,9 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
|
||||
Main *bmain = CTX_data_main(C);
|
||||
LISTBASE_FOREACH (CollectionPointerLink *, ctx_ob, &ctx_objects) {
|
||||
/* Always un-tag all object data-blocks irrespective of our ability to operate on them. */
|
||||
Object *ob = ctx_ob->ptr.data;
|
||||
ID *data = ob->data;
|
||||
if ((data == NULL) || ((data->tag & LIB_TAG_DOIT) == 0)) {
|
||||
Object *ob = static_cast<Object *>(ctx_ob->ptr.data);
|
||||
ID *data = static_cast<ID *>(ob->data);
|
||||
if ((data == nullptr) || ((data->tag & LIB_TAG_DOIT) == 0)) {
|
||||
continue;
|
||||
}
|
||||
data->tag &= ~LIB_TAG_DOIT;
|
||||
@@ -1579,17 +1583,18 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
|
||||
|
||||
bool changed = false;
|
||||
if (ob->type == OB_MESH) {
|
||||
BKE_mesh_smooth_flag_set(ob->data, use_smooth);
|
||||
BKE_mesh_smooth_flag_set(static_cast<Mesh *>(ob->data), use_smooth);
|
||||
if (use_smooth) {
|
||||
const bool use_auto_smooth = RNA_boolean_get(op->ptr, "use_auto_smooth");
|
||||
const float auto_smooth_angle = RNA_float_get(op->ptr, "auto_smooth_angle");
|
||||
BKE_mesh_auto_smooth_flag_set(ob->data, use_auto_smooth, auto_smooth_angle);
|
||||
BKE_mesh_auto_smooth_flag_set(
|
||||
static_cast<Mesh *>(ob->data), use_auto_smooth, auto_smooth_angle);
|
||||
}
|
||||
BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
|
||||
BKE_mesh_batch_cache_dirty_tag(static_cast<Mesh *>(ob->data), BKE_MESH_BATCH_DIRTY_ALL);
|
||||
changed = true;
|
||||
}
|
||||
else if (ELEM(ob->type, OB_SURF, OB_CURVES_LEGACY)) {
|
||||
BKE_curve_smooth_flag_set(ob->data, use_smooth);
|
||||
BKE_curve_smooth_flag_set(static_cast<Curve *>(ob->data), use_smooth);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
@@ -1618,9 +1623,9 @@ static bool shade_poll(bContext *C)
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
BKE_view_layer_synced_ensure(scene, view_layer);
|
||||
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
||||
if (obact != NULL) {
|
||||
if (obact != nullptr) {
|
||||
/* Doesn't handle edit-data, sculpt dynamic-topology, or their undo systems. */
|
||||
if (obact->mode & (OB_MODE_EDIT | OB_MODE_SCULPT) || obact->data == NULL ||
|
||||
if (obact->mode & (OB_MODE_EDIT | OB_MODE_SCULPT) || obact->data == nullptr ||
|
||||
ID_IS_OVERRIDE_LIBRARY(obact) || ID_IS_OVERRIDE_LIBRARY(obact->data)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1684,12 +1689,12 @@ void OBJECT_OT_shade_smooth(wmOperatorType *ot)
|
||||
* \{ */
|
||||
|
||||
static const EnumPropertyItem *object_mode_set_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
const EnumPropertyItem *input = rna_enum_object_mode_items;
|
||||
EnumPropertyItem *item = NULL;
|
||||
EnumPropertyItem *item = nullptr;
|
||||
int totitem = 0;
|
||||
|
||||
if (!C) { /* needed for docs */
|
||||
@@ -1699,7 +1704,7 @@ static const EnumPropertyItem *object_mode_set_itemf(bContext *C,
|
||||
const Object *ob = CTX_data_active_object(C);
|
||||
if (ob) {
|
||||
while (input->identifier) {
|
||||
if (ED_object_mode_compat_test(ob, input->value)) {
|
||||
if (ED_object_mode_compat_test(ob, eObjectMode(input->value))) {
|
||||
RNA_enum_item_add(&item, &totitem, input);
|
||||
}
|
||||
input++;
|
||||
@@ -1728,7 +1733,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
const bool use_submode = STREQ(op->idname, "OBJECT_OT_mode_set_with_submode");
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
eObjectMode mode = RNA_enum_get(op->ptr, "mode");
|
||||
eObjectMode mode = eObjectMode(RNA_enum_get(op->ptr, "mode"));
|
||||
const bool toggle = RNA_boolean_get(op->ptr, "toggle");
|
||||
|
||||
/* by default the operator assume is a mesh, but if gp object change mode */
|
||||
@@ -1764,7 +1769,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
else {
|
||||
const eObjectMode mode_prev = ob->mode;
|
||||
const eObjectMode mode_prev = eObjectMode(ob->mode);
|
||||
/* When toggling object mode, we always use the restore mode,
|
||||
* otherwise there is nothing to do. */
|
||||
if (mode == OB_MODE_OBJECT) {
|
||||
@@ -1776,7 +1781,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
else {
|
||||
if (ob->restore_mode != OB_MODE_OBJECT) {
|
||||
ED_object_mode_set_ex(C, ob->restore_mode, true, op->reports);
|
||||
ED_object_mode_set_ex(C, eObjectMode(ob->restore_mode), true, op->reports);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1791,7 +1796,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
else {
|
||||
if (ob->restore_mode != OB_MODE_OBJECT) {
|
||||
ED_object_mode_set_ex(C, ob->restore_mode, true, op->reports);
|
||||
ED_object_mode_set_ex(C, eObjectMode(ob->restore_mode), true, op->reports);
|
||||
}
|
||||
else {
|
||||
ED_object_mode_set_ex(C, OB_MODE_OBJECT, true, op->reports);
|
||||
@@ -1855,7 +1860,7 @@ void OBJECT_OT_mode_set_with_submode(wmOperatorType *ot)
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_enum_flag(
|
||||
ot->srna, "mesh_select_mode", rna_enum_mesh_select_mode_items, 0, "Mesh Mode", "");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -1866,9 +1871,9 @@ void OBJECT_OT_mode_set_with_submode(wmOperatorType *ot)
|
||||
|
||||
static ListBase selected_objects_get(bContext *C)
|
||||
{
|
||||
ListBase objects = {NULL};
|
||||
ListBase objects = {nullptr};
|
||||
|
||||
if (CTX_wm_space_outliner(C) != NULL) {
|
||||
if (CTX_wm_space_outliner(C) != nullptr) {
|
||||
ED_outliner_selected_objects_get(C, &objects);
|
||||
}
|
||||
else {
|
||||
@@ -1883,7 +1888,7 @@ static ListBase selected_objects_get(bContext *C)
|
||||
|
||||
static bool move_to_collection_poll(bContext *C)
|
||||
{
|
||||
if (CTX_wm_space_outliner(C) != NULL) {
|
||||
if (CTX_wm_space_outliner(C) != nullptr) {
|
||||
return ED_outliner_collections_editor_poll(C);
|
||||
}
|
||||
return ED_operator_objectmode(C);
|
||||
@@ -1904,7 +1909,7 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
|
||||
|
||||
int collection_index = RNA_property_int_get(op->ptr, prop);
|
||||
Collection *collection = BKE_collection_from_index(scene, collection_index);
|
||||
if (collection == NULL) {
|
||||
if (collection == nullptr) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Unexpected error, collection not found");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
@@ -1922,10 +1927,12 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
|
||||
collection = BKE_collection_add(bmain, collection, new_collection_name);
|
||||
}
|
||||
|
||||
Object *single_object = BLI_listbase_is_single(&objects) ? ((LinkData *)objects.first)->data :
|
||||
NULL;
|
||||
Object *single_object = BLI_listbase_is_single(&objects) ?
|
||||
static_cast<Object *>(((LinkData *)objects.first)->data) :
|
||||
nullptr;
|
||||
|
||||
if ((single_object != NULL) && is_link && BKE_collection_has_object(collection, single_object)) {
|
||||
if ((single_object != nullptr) && is_link &&
|
||||
BKE_collection_has_object(collection, single_object)) {
|
||||
BKE_reportf(op->reports,
|
||||
RPT_ERROR,
|
||||
"%s already in %s",
|
||||
@@ -1936,10 +1943,10 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (LinkData *, link, &objects) {
|
||||
Object *ob = link->data;
|
||||
Object *ob = static_cast<Object *>(link->data);
|
||||
|
||||
if (!is_link) {
|
||||
BKE_collection_object_move(bmain, scene, collection, NULL, ob);
|
||||
BKE_collection_object_move(bmain, scene, collection, nullptr, ob);
|
||||
}
|
||||
else {
|
||||
BKE_collection_object_add(bmain, collection, ob);
|
||||
@@ -1948,7 +1955,7 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
|
||||
BLI_freelistN(&objects);
|
||||
|
||||
if (is_link) {
|
||||
if (single_object != NULL) {
|
||||
if (single_object != nullptr) {
|
||||
BKE_reportf(op->reports,
|
||||
RPT_INFO,
|
||||
"%s linked to %s",
|
||||
@@ -1961,7 +1968,7 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (single_object != NULL) {
|
||||
if (single_object != nullptr) {
|
||||
BKE_reportf(op->reports,
|
||||
RPT_INFO,
|
||||
"%s moved to %s",
|
||||
@@ -1985,12 +1992,12 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
struct MoveToCollectionData {
|
||||
struct MoveToCollectionData *next, *prev;
|
||||
MoveToCollectionData *next, *prev;
|
||||
int index;
|
||||
struct Collection *collection;
|
||||
struct ListBase submenus;
|
||||
Collection *collection;
|
||||
ListBase submenus;
|
||||
PointerRNA ptr;
|
||||
struct wmOperatorType *ot;
|
||||
wmOperatorType *ot;
|
||||
};
|
||||
|
||||
static int move_to_collection_menus_create(wmOperator *op, MoveToCollectionData *menu)
|
||||
@@ -1998,7 +2005,7 @@ static int move_to_collection_menus_create(wmOperator *op, MoveToCollectionData
|
||||
int index = menu->index;
|
||||
LISTBASE_FOREACH (CollectionChild *, child, &menu->collection->children) {
|
||||
Collection *collection = child->collection;
|
||||
MoveToCollectionData *submenu = MEM_callocN(sizeof(MoveToCollectionData), __func__);
|
||||
MoveToCollectionData *submenu = MEM_cnew<MoveToCollectionData>(__func__);
|
||||
BLI_addtail(&menu->submenus, submenu);
|
||||
submenu->collection = collection;
|
||||
submenu->index = ++index;
|
||||
@@ -2018,18 +2025,18 @@ static void move_to_collection_menus_free_recursive(MoveToCollectionData *menu)
|
||||
|
||||
static void move_to_collection_menus_free(MoveToCollectionData **menu)
|
||||
{
|
||||
if (*menu == NULL) {
|
||||
if (*menu == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
move_to_collection_menus_free_recursive(*menu);
|
||||
MEM_freeN(*menu);
|
||||
*menu = NULL;
|
||||
*menu = nullptr;
|
||||
}
|
||||
|
||||
static void move_to_collection_menu_create(bContext *C, uiLayout *layout, void *menu_v)
|
||||
{
|
||||
MoveToCollectionData *menu = menu_v;
|
||||
MoveToCollectionData *menu = static_cast<MoveToCollectionData *>(menu_v);
|
||||
const char *name = BKE_collection_ui_name_get(menu->collection);
|
||||
|
||||
UI_block_flag_enable(uiLayoutGetBlock(layout), UI_BLOCK_IS_FLIP);
|
||||
@@ -2042,10 +2049,10 @@ static void move_to_collection_menu_create(bContext *C, uiLayout *layout, void *
|
||||
menu->ot,
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "New Collection"),
|
||||
ICON_ADD,
|
||||
menu->ptr.data,
|
||||
static_cast<IDProperty *>(menu->ptr.data),
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
0,
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
@@ -2078,9 +2085,9 @@ static void move_to_collection_menus_items(uiLayout *layout, MoveToCollectionDat
|
||||
}
|
||||
|
||||
/* This is allocated statically because we need this available for the menus creation callback. */
|
||||
static MoveToCollectionData *master_collection_menu = NULL;
|
||||
static MoveToCollectionData *master_collection_menu = nullptr;
|
||||
|
||||
static int move_to_collection_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int move_to_collection_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
@@ -2122,9 +2129,9 @@ static int move_to_collection_invoke(bContext *C, wmOperator *op, const wmEvent
|
||||
* called to an operator that exit with OPERATOR_INTERFACE to launch a menu.
|
||||
*
|
||||
* So we are left with a memory that will necessarily leak. It's a small leak though. */
|
||||
if (master_collection_menu == NULL) {
|
||||
master_collection_menu = MEM_callocN(sizeof(MoveToCollectionData),
|
||||
"MoveToCollectionData menu - expected eventual memleak");
|
||||
if (master_collection_menu == nullptr) {
|
||||
master_collection_menu = MEM_cnew<MoveToCollectionData>(
|
||||
"MoveToCollectionData menu - expected eventual memleak");
|
||||
}
|
||||
|
||||
master_collection_menu->collection = master_collection;
|
||||
@@ -2174,12 +2181,12 @@ void OBJECT_OT_move_to_collection(wmOperatorType *ot)
|
||||
"Index of the collection to move to",
|
||||
0,
|
||||
INT_MAX);
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_SKIP_SAVE | PROP_HIDDEN));
|
||||
prop = RNA_def_boolean(ot->srna, "is_new", false, "New", "Move objects to a new collection");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_SKIP_SAVE | PROP_HIDDEN));
|
||||
prop = RNA_def_string(ot->srna,
|
||||
"new_collection_name",
|
||||
NULL,
|
||||
nullptr,
|
||||
MAX_NAME,
|
||||
"Name",
|
||||
"Name of the newly added collection");
|
||||
@@ -2213,12 +2220,12 @@ void OBJECT_OT_link_to_collection(wmOperatorType *ot)
|
||||
"Index of the collection to move to",
|
||||
0,
|
||||
INT_MAX);
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_SKIP_SAVE | PROP_HIDDEN));
|
||||
prop = RNA_def_boolean(ot->srna, "is_new", false, "New", "Move objects to a new collection");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
||||
RNA_def_property_flag(prop, PropertyFlag(PROP_SKIP_SAVE | PROP_HIDDEN));
|
||||
prop = RNA_def_string(ot->srna,
|
||||
"new_collection_name",
|
||||
NULL,
|
||||
nullptr,
|
||||
MAX_NAME,
|
||||
"Name",
|
||||
"Name of the newly added collection");
|
||||
@@ -72,7 +72,7 @@ void OBJECT_OT_drop_geometry_nodes(struct wmOperatorType *ot);
|
||||
*/
|
||||
void OBJECT_OT_unlink_data(struct wmOperatorType *ot);
|
||||
|
||||
/* object_edit.c */
|
||||
/* object_edit.cc */
|
||||
|
||||
void OBJECT_OT_hide_view_set(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_hide_view_clear(struct wmOperatorType *ot);
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern PyTypeObject BPy_BMesh_Type;
|
||||
extern PyTypeObject BPy_BMVert_Type;
|
||||
extern PyTypeObject BPy_BMEdge_Type;
|
||||
@@ -233,3 +237,7 @@ extern struct PyC_FlagSet bpy_bm_htype_vert_edge_face_flags[];
|
||||
extern struct PyC_FlagSet bpy_bm_htype_all_flags[];
|
||||
extern struct PyC_FlagSet bpy_bm_hflag_all_flags[];
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,7 @@ set(SRC
|
||||
mathutils_Matrix.c
|
||||
mathutils_Quaternion.c
|
||||
mathutils_Vector.c
|
||||
mathutils_bvhtree.c
|
||||
mathutils_bvhtree.cc
|
||||
mathutils_geometry.c
|
||||
mathutils_interpolate.c
|
||||
mathutils_kdtree.c
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct DynStr;
|
||||
|
||||
extern char BaseMathObject_is_wrapped_doc[];
|
||||
@@ -228,3 +232,7 @@ int column_vector_multiplication(float r_vec[4], VectorObject *vec, MatrixObject
|
||||
/* dynstr as python string utility functions, frees 'ds'! */
|
||||
PyObject *mathutils_dynstr_to_py(struct DynStr *ds);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern PyTypeObject vector_Type;
|
||||
|
||||
#define VectorObject_Check(v) PyObject_TypeCheck((v), &vector_Type)
|
||||
@@ -47,3 +51,7 @@ PyObject *Vector_CreatePyObject_alloc(float *vec,
|
||||
int vec_num,
|
||||
PyTypeObject *base_type) ATTR_WARN_UNUSED_RESULT
|
||||
ATTR_NONNULL(1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -78,7 +78,7 @@ static const float max_dist_default = 1.844674352395373e+19f;
|
||||
static const char PY_BVH_TREE_TYPE_DEFAULT = 4;
|
||||
static const char PY_BVH_AXIS_DEFAULT = 6;
|
||||
|
||||
typedef struct {
|
||||
struct PyBVHTree {
|
||||
PyObject_HEAD
|
||||
BVHTree *tree;
|
||||
float epsilon;
|
||||
@@ -92,7 +92,7 @@ typedef struct {
|
||||
int *orig_index;
|
||||
/* aligned with array that 'orig_index' points to */
|
||||
float (*orig_normal)[3];
|
||||
} PyBVHTree;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Utility helper functions
|
||||
@@ -138,8 +138,8 @@ static void py_bvhtree_raycast_to_py_tuple(const BVHTreeRayHit *hit, PyObject *p
|
||||
BLI_assert(PyTuple_GET_SIZE(py_retval) == 4);
|
||||
|
||||
PyTuple_SET_ITEMS(py_retval,
|
||||
Vector_CreatePyObject(hit->co, 3, NULL),
|
||||
Vector_CreatePyObject(hit->no, 3, NULL),
|
||||
Vector_CreatePyObject(hit->co, 3, nullptr),
|
||||
Vector_CreatePyObject(hit->no, 3, nullptr),
|
||||
PyLong_FromLong(hit->index),
|
||||
PyFloat_FromDouble(hit->dist));
|
||||
}
|
||||
@@ -192,8 +192,8 @@ static void py_bvhtree_nearest_to_py_tuple(const BVHTreeNearest *nearest, PyObje
|
||||
BLI_assert(PyTuple_GET_SIZE(py_retval) == 4);
|
||||
|
||||
PyTuple_SET_ITEMS(py_retval,
|
||||
Vector_CreatePyObject(nearest->co, 3, NULL),
|
||||
Vector_CreatePyObject(nearest->no, 3, NULL),
|
||||
Vector_CreatePyObject(nearest->co, 3, nullptr),
|
||||
Vector_CreatePyObject(nearest->no, 3, nullptr),
|
||||
PyLong_FromLong(nearest->index),
|
||||
PyFloat_FromDouble(sqrtf(nearest->dist_sq)));
|
||||
}
|
||||
@@ -260,7 +260,7 @@ static void py_bvhtree_raycast_cb(void *userdata,
|
||||
const BVHTreeRay *ray,
|
||||
BVHTreeRayHit *hit)
|
||||
{
|
||||
const PyBVHTree *self = userdata;
|
||||
const PyBVHTree *self = static_cast<const PyBVHTree *>(userdata);
|
||||
|
||||
const float(*coords)[3] = (const float(*)[3])self->coords;
|
||||
const uint *tri = self->tris[index];
|
||||
@@ -292,7 +292,7 @@ static void py_bvhtree_nearest_point_cb(void *userdata,
|
||||
const float co[3],
|
||||
BVHTreeNearest *nearest)
|
||||
{
|
||||
PyBVHTree *self = userdata;
|
||||
PyBVHTree *self = static_cast<PyBVHTree *>(userdata);
|
||||
|
||||
const float(*coords)[3] = (const float(*)[3])self->coords;
|
||||
const uint *tri = self->tris[index];
|
||||
@@ -337,13 +337,13 @@ static PyObject *py_bvhtree_ray_cast(PyBVHTree *self, PyObject *args)
|
||||
PyObject *py_co, *py_direction;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "OO|f:ray_cast", &py_co, &py_direction, &max_dist)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if ((mathutils_array_parse(co, 2, 3 | MU_ARRAY_ZERO, py_co, error_prefix) == -1) ||
|
||||
(mathutils_array_parse(direction, 2, 3 | MU_ARRAY_ZERO, py_direction, error_prefix) ==
|
||||
-1)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
normalize_v3(direction);
|
||||
@@ -385,11 +385,11 @@ static PyObject *py_bvhtree_find_nearest(PyBVHTree *self, PyObject *args)
|
||||
PyObject *py_co;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O|f:find_nearest", &py_co, &max_dist)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (mathutils_array_parse(co, 2, 3 | MU_ARRAY_ZERO, py_co, error_prefix) == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,9 +416,9 @@ struct PyBVH_RangeData {
|
||||
static void py_bvhtree_nearest_point_range_cb(void *userdata,
|
||||
int index,
|
||||
const float co[3],
|
||||
float UNUSED(dist_sq_bvh))
|
||||
float /*dist_sq_bvh*/)
|
||||
{
|
||||
struct PyBVH_RangeData *data = userdata;
|
||||
PyBVH_RangeData *data = static_cast<PyBVH_RangeData *>(userdata);
|
||||
PyBVHTree *self = data->self;
|
||||
|
||||
const float(*coords)[3] = self->coords;
|
||||
@@ -466,23 +466,21 @@ static PyObject *py_bvhtree_find_nearest_range(PyBVHTree *self, PyObject *args)
|
||||
PyObject *py_co;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O|f:find_nearest_range", &py_co, &max_dist)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (mathutils_array_parse(co, 2, 3 | MU_ARRAY_ZERO, py_co, error_prefix) == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *ret = PyList_New(0);
|
||||
|
||||
if (self->tree) {
|
||||
struct PyBVH_RangeData data = {
|
||||
.self = self,
|
||||
.result = ret,
|
||||
.dist_sq = square_f(max_dist),
|
||||
};
|
||||
|
||||
PyBVH_RangeData data{};
|
||||
data.self = self;
|
||||
data.result = ret;
|
||||
data.dist_sq = square_f(max_dist);
|
||||
BLI_bvhtree_range_query(self->tree, co, max_dist, py_bvhtree_nearest_point_range_cb, &data);
|
||||
}
|
||||
|
||||
@@ -491,15 +489,15 @@ static PyObject *py_bvhtree_find_nearest_range(PyBVHTree *self, PyObject *args)
|
||||
|
||||
BLI_INLINE uint overlap_hash(const void *overlap_v)
|
||||
{
|
||||
const BVHTreeOverlap *overlap = overlap_v;
|
||||
const BVHTreeOverlap *overlap = static_cast<const BVHTreeOverlap *>(overlap_v);
|
||||
/* same constants as edge-hash */
|
||||
return (((uint)overlap->indexA * 65) ^ ((uint)overlap->indexA * 31));
|
||||
return ((uint(overlap->indexA) * 65) ^ (uint(overlap->indexA) * 31));
|
||||
}
|
||||
|
||||
BLI_INLINE bool overlap_cmp(const void *a_v, const void *b_v)
|
||||
{
|
||||
const BVHTreeOverlap *a = a_v;
|
||||
const BVHTreeOverlap *b = b_v;
|
||||
const BVHTreeOverlap *a = static_cast<const BVHTreeOverlap *>(a_v);
|
||||
const BVHTreeOverlap *b = static_cast<const BVHTreeOverlap *>(b_v);
|
||||
return (memcmp(a, b, sizeof(*a)) != 0);
|
||||
}
|
||||
|
||||
@@ -508,9 +506,9 @@ struct PyBVHTree_OverlapData {
|
||||
float epsilon;
|
||||
};
|
||||
|
||||
static bool py_bvhtree_overlap_cb(void *userdata, int index_a, int index_b, int UNUSED(thread))
|
||||
static bool py_bvhtree_overlap_cb(void *userdata, int index_a, int index_b, int /*thread*/)
|
||||
{
|
||||
struct PyBVHTree_OverlapData *data = userdata;
|
||||
PyBVHTree_OverlapData *data = static_cast<PyBVHTree_OverlapData *>(userdata);
|
||||
PyBVHTree *tree_a = data->tree_pair[0];
|
||||
PyBVHTree *tree_b = data->tree_pair[1];
|
||||
const uint *tri_a = tree_a->tris[index_a];
|
||||
@@ -553,14 +551,14 @@ PyDoc_STRVAR(
|
||||
" :rtype: :class:`list`\n");
|
||||
static PyObject *py_bvhtree_overlap(PyBVHTree *self, PyBVHTree *other)
|
||||
{
|
||||
struct PyBVHTree_OverlapData data;
|
||||
PyBVHTree_OverlapData data;
|
||||
BVHTreeOverlap *overlap;
|
||||
uint overlap_len = 0;
|
||||
PyObject *ret;
|
||||
|
||||
if (!PyBVHTree_CheckExact(other)) {
|
||||
PyErr_SetString(PyExc_ValueError, "Expected a BVHTree argument");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
data.tree_pair[0] = self;
|
||||
@@ -572,14 +570,14 @@ static PyObject *py_bvhtree_overlap(PyBVHTree *self, PyBVHTree *other)
|
||||
|
||||
ret = PyList_New(0);
|
||||
|
||||
if (overlap == NULL) {
|
||||
if (overlap == nullptr) {
|
||||
/* pass */
|
||||
}
|
||||
else {
|
||||
const bool use_unique = (self->orig_index || other->orig_index);
|
||||
GSet *pair_test = use_unique ?
|
||||
BLI_gset_new_ex(overlap_hash, overlap_cmp, __func__, overlap_len) :
|
||||
NULL;
|
||||
nullptr;
|
||||
/* simple case, no index remapping */
|
||||
uint i;
|
||||
|
||||
@@ -608,7 +606,7 @@ static PyObject *py_bvhtree_overlap(PyBVHTree *self, PyBVHTree *other)
|
||||
}
|
||||
|
||||
if (pair_test) {
|
||||
BLI_gset_free(pair_test, NULL);
|
||||
BLI_gset_free(pair_test, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -638,26 +636,26 @@ PyDoc_STRVAR(
|
||||
" :arg all_triangles: Use when all **polygons** are triangles for more efficient "
|
||||
"conversion.\n"
|
||||
" :type all_triangles: bool\n" PYBVH_FROM_GENERIC_EPSILON_DOC);
|
||||
static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, PyObject *kwargs)
|
||||
static PyObject *C_BVHTree_FromPolygons(PyObject * /*cls*/, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
const char *error_prefix = "BVHTree.FromPolygons";
|
||||
const char *keywords[] = {"vertices", "polygons", "all_triangles", "epsilon", NULL};
|
||||
const char *keywords[] = {"vertices", "polygons", "all_triangles", "epsilon", nullptr};
|
||||
|
||||
PyObject *py_coords, *py_tris;
|
||||
PyObject *py_coords_fast = NULL, *py_tris_fast = NULL;
|
||||
PyObject *py_coords_fast = nullptr, *py_tris_fast = nullptr;
|
||||
|
||||
MemArena *poly_arena = NULL;
|
||||
MemArena *pf_arena = NULL;
|
||||
MemArena *poly_arena = nullptr;
|
||||
MemArena *pf_arena = nullptr;
|
||||
|
||||
float(*coords)[3] = NULL;
|
||||
uint(*tris)[3] = NULL;
|
||||
float(*coords)[3] = nullptr;
|
||||
uint(*tris)[3] = nullptr;
|
||||
uint coords_len, tris_len;
|
||||
float epsilon = 0.0f;
|
||||
bool all_triangles = false;
|
||||
|
||||
/* when all_triangles is False */
|
||||
int *orig_index = NULL;
|
||||
float(*orig_normal)[3] = NULL;
|
||||
int *orig_index = nullptr;
|
||||
float(*orig_normal)[3] = nullptr;
|
||||
|
||||
uint i;
|
||||
bool valid = true;
|
||||
@@ -671,19 +669,19 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
|
||||
PyC_ParseBool,
|
||||
&all_triangles,
|
||||
&epsilon)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!(py_coords_fast = PySequence_Fast(py_coords, error_prefix)) ||
|
||||
!(py_tris_fast = PySequence_Fast(py_tris, error_prefix))) {
|
||||
Py_XDECREF(py_coords_fast);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (valid) {
|
||||
PyObject **py_coords_fast_items = PySequence_Fast_ITEMS(py_coords_fast);
|
||||
coords_len = (uint)PySequence_Fast_GET_SIZE(py_coords_fast);
|
||||
coords = MEM_mallocN((size_t)coords_len * sizeof(*coords), __func__);
|
||||
coords_len = uint(PySequence_Fast_GET_SIZE(py_coords_fast));
|
||||
coords = static_cast<float(*)[3]>(MEM_mallocN(size_t(coords_len) * sizeof(*coords), __func__));
|
||||
|
||||
for (i = 0; i < coords_len; i++) {
|
||||
PyObject *py_vert = py_coords_fast_items[i];
|
||||
@@ -701,8 +699,8 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
|
||||
else if (all_triangles) {
|
||||
/* all triangles, simple case */
|
||||
PyObject **py_tris_fast_items = PySequence_Fast_ITEMS(py_tris_fast);
|
||||
tris_len = (uint)PySequence_Fast_GET_SIZE(py_tris_fast);
|
||||
tris = MEM_mallocN((size_t)tris_len * sizeof(*tris), __func__);
|
||||
tris_len = uint(PySequence_Fast_GET_SIZE(py_tris_fast));
|
||||
tris = static_cast<uint(*)[3]>(MEM_mallocN(size_t(tris_len) * sizeof(*tris), __func__));
|
||||
|
||||
for (i = 0; i < tris_len; i++) {
|
||||
PyObject *py_tricoords = py_tris_fast_items[i];
|
||||
@@ -731,7 +729,7 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
|
||||
|
||||
for (j = 0; j < 3; j++) {
|
||||
tri[j] = PyC_Long_AsU32(py_tricoords_fast_items[j]);
|
||||
if (UNLIKELY(tri[j] >= (uint)coords_len)) {
|
||||
if (UNLIKELY(tri[j] >= uint(coords_len))) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%s: index %d must be less than %d",
|
||||
error_prefix,
|
||||
@@ -749,12 +747,12 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
|
||||
}
|
||||
else {
|
||||
/* ngon support (much more involved) */
|
||||
const uint polys_len = (uint)PySequence_Fast_GET_SIZE(py_tris_fast);
|
||||
const uint polys_len = uint(PySequence_Fast_GET_SIZE(py_tris_fast));
|
||||
struct PolyLink {
|
||||
struct PolyLink *next;
|
||||
uint len;
|
||||
uint poly[0];
|
||||
} *plink_first = NULL, **p_plink_prev = &plink_first, *plink = NULL;
|
||||
} *plink_first = nullptr, **p_plink_prev = &plink_first, *plink = nullptr;
|
||||
int poly_index;
|
||||
|
||||
tris_len = 0;
|
||||
@@ -773,19 +771,19 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
|
||||
break;
|
||||
}
|
||||
|
||||
py_tricoords_len = (uint)PySequence_Fast_GET_SIZE(py_tricoords_fast);
|
||||
py_tricoords_len = uint(PySequence_Fast_GET_SIZE(py_tricoords_fast));
|
||||
py_tricoords_fast_items = PySequence_Fast_ITEMS(py_tricoords_fast);
|
||||
|
||||
plink = BLI_memarena_alloc(poly_arena,
|
||||
sizeof(*plink) + (sizeof(int) * (size_t)py_tricoords_len));
|
||||
plink = static_cast<PolyLink *>(BLI_memarena_alloc(
|
||||
poly_arena, sizeof(*plink) + (sizeof(int) * size_t(py_tricoords_len))));
|
||||
|
||||
plink->len = (uint)py_tricoords_len;
|
||||
plink->len = uint(py_tricoords_len);
|
||||
*p_plink_prev = plink;
|
||||
p_plink_prev = &plink->next;
|
||||
|
||||
for (j = 0; j < py_tricoords_len; j++) {
|
||||
plink->poly[j] = PyC_Long_AsU32(py_tricoords_fast_items[j]);
|
||||
if (UNLIKELY(plink->poly[j] >= (uint)coords_len)) {
|
||||
if (UNLIKELY(plink->poly[j] >= uint(coords_len))) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%s: index %d must be less than %d",
|
||||
error_prefix,
|
||||
@@ -803,15 +801,16 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
|
||||
tris_len += (py_tricoords_len - 2);
|
||||
}
|
||||
}
|
||||
*p_plink_prev = NULL;
|
||||
*p_plink_prev = nullptr;
|
||||
|
||||
/* all ngon's are parsed, now tessellate */
|
||||
|
||||
pf_arena = BLI_memarena_new(BLI_POLYFILL_ARENA_SIZE, __func__);
|
||||
tris = MEM_mallocN(sizeof(*tris) * (size_t)tris_len, __func__);
|
||||
tris = static_cast<uint(*)[3]>(MEM_mallocN(sizeof(*tris) * size_t(tris_len), __func__));
|
||||
|
||||
orig_index = MEM_mallocN(sizeof(*orig_index) * (size_t)tris_len, __func__);
|
||||
orig_normal = MEM_mallocN(sizeof(*orig_normal) * (size_t)polys_len, __func__);
|
||||
orig_index = static_cast<int *>(MEM_mallocN(sizeof(*orig_index) * size_t(tris_len), __func__));
|
||||
orig_normal = static_cast<float(*)[3]>(
|
||||
MEM_mallocN(sizeof(*orig_normal) * size_t(polys_len), __func__));
|
||||
|
||||
for (plink = plink_first, poly_index = 0, i = 0; plink; plink = plink->next, poly_index++) {
|
||||
if (plink->len == 3) {
|
||||
@@ -822,7 +821,8 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
|
||||
i++;
|
||||
}
|
||||
else if (plink->len > 3) {
|
||||
float(*proj_coords)[2] = BLI_memarena_alloc(pf_arena, sizeof(*proj_coords) * plink->len);
|
||||
float(*proj_coords)[2] = static_cast<float(*)[2]>(
|
||||
BLI_memarena_alloc(pf_arena, sizeof(*proj_coords) * plink->len));
|
||||
float *normal = orig_normal[poly_index];
|
||||
const float *co_prev;
|
||||
const float *co_curr;
|
||||
@@ -882,7 +882,7 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
|
||||
if (valid) {
|
||||
BVHTree *tree;
|
||||
|
||||
tree = BLI_bvhtree_new((int)tris_len, epsilon, PY_BVH_TREE_TYPE_DEFAULT, PY_BVH_AXIS_DEFAULT);
|
||||
tree = BLI_bvhtree_new(int(tris_len), epsilon, PY_BVH_TREE_TYPE_DEFAULT, PY_BVH_AXIS_DEFAULT);
|
||||
if (tree) {
|
||||
for (i = 0; i < tris_len; i++) {
|
||||
float co[3][3];
|
||||
@@ -891,7 +891,7 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
|
||||
copy_v3_v3(co[1], coords[tris[i][1]]);
|
||||
copy_v3_v3(co[2], coords[tris[i][2]]);
|
||||
|
||||
BLI_bvhtree_insert(tree, (int)i, co[0], 3);
|
||||
BLI_bvhtree_insert(tree, int(i), co[0], 3);
|
||||
}
|
||||
|
||||
BLI_bvhtree_balance(tree);
|
||||
@@ -908,7 +908,7 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
|
||||
MEM_freeN(tris);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifndef MATH_STANDALONE
|
||||
@@ -920,14 +920,14 @@ PyDoc_STRVAR(C_BVHTree_FromBMesh_doc,
|
||||
"\n"
|
||||
" :arg bmesh: BMesh data.\n"
|
||||
" :type bmesh: :class:`BMesh`\n" PYBVH_FROM_GENERIC_EPSILON_DOC);
|
||||
static PyObject *C_BVHTree_FromBMesh(PyObject *UNUSED(cls), PyObject *args, PyObject *kwargs)
|
||||
static PyObject *C_BVHTree_FromBMesh(PyObject * /*cls*/, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
const char *keywords[] = {"bmesh", "epsilon", NULL};
|
||||
const char *keywords[] = {"bmesh", "epsilon", nullptr};
|
||||
|
||||
BPy_BMesh *py_bm;
|
||||
|
||||
float(*coords)[3] = NULL;
|
||||
uint(*tris)[3] = NULL;
|
||||
float(*coords)[3] = nullptr;
|
||||
uint(*tris)[3] = nullptr;
|
||||
uint coords_len, tris_len;
|
||||
float epsilon = 0.0f;
|
||||
|
||||
@@ -941,20 +941,21 @@ static PyObject *C_BVHTree_FromBMesh(PyObject *UNUSED(cls), PyObject *args, PyOb
|
||||
&BPy_BMesh_Type,
|
||||
&py_bm,
|
||||
&epsilon)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bm = py_bm->bm;
|
||||
|
||||
/* Get data for tessellation */
|
||||
{
|
||||
coords_len = (uint)bm->totvert;
|
||||
tris_len = (uint)poly_to_tri_count(bm->totface, bm->totloop);
|
||||
coords_len = uint(bm->totvert);
|
||||
tris_len = uint(poly_to_tri_count(bm->totface, bm->totloop));
|
||||
|
||||
coords = MEM_mallocN(sizeof(*coords) * (size_t)coords_len, __func__);
|
||||
tris = MEM_mallocN(sizeof(*tris) * (size_t)tris_len, __func__);
|
||||
coords = static_cast<float(*)[3]>(MEM_mallocN(sizeof(*coords) * size_t(coords_len), __func__));
|
||||
tris = static_cast<uint(*)[3]>(MEM_mallocN(sizeof(*tris) * size_t(tris_len), __func__));
|
||||
|
||||
looptris = MEM_mallocN(sizeof(*looptris) * (size_t)tris_len, __func__);
|
||||
looptris = static_cast<BMLoop *(*)[3]>(
|
||||
MEM_mallocN(sizeof(*looptris) * size_t(tris_len), __func__));
|
||||
|
||||
BM_mesh_calc_tessellation(bm, looptris);
|
||||
}
|
||||
@@ -964,39 +965,41 @@ static PyObject *C_BVHTree_FromBMesh(PyObject *UNUSED(cls), PyObject *args, PyOb
|
||||
BVHTree *tree;
|
||||
uint i;
|
||||
|
||||
int *orig_index = NULL;
|
||||
float(*orig_normal)[3] = NULL;
|
||||
int *orig_index = nullptr;
|
||||
float(*orig_normal)[3] = nullptr;
|
||||
|
||||
tree = BLI_bvhtree_new((int)tris_len, epsilon, PY_BVH_TREE_TYPE_DEFAULT, PY_BVH_AXIS_DEFAULT);
|
||||
tree = BLI_bvhtree_new(int(tris_len), epsilon, PY_BVH_TREE_TYPE_DEFAULT, PY_BVH_AXIS_DEFAULT);
|
||||
if (tree) {
|
||||
BMFace *f;
|
||||
BMVert *v;
|
||||
|
||||
orig_index = MEM_mallocN(sizeof(*orig_index) * (size_t)tris_len, __func__);
|
||||
orig_normal = MEM_mallocN(sizeof(*orig_normal) * (size_t)bm->totface, __func__);
|
||||
orig_index = static_cast<int *>(
|
||||
MEM_mallocN(sizeof(*orig_index) * size_t(tris_len), __func__));
|
||||
orig_normal = static_cast<float(*)[3]>(
|
||||
MEM_mallocN(sizeof(*orig_normal) * size_t(bm->totface), __func__));
|
||||
|
||||
BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
|
||||
copy_v3_v3(coords[i], v->co);
|
||||
BM_elem_index_set(v, (int)i); /* set_inline */
|
||||
BM_elem_index_set(v, int(i)); /* set_inline */
|
||||
}
|
||||
BM_ITER_MESH_INDEX (f, &iter, bm, BM_FACES_OF_MESH, i) {
|
||||
copy_v3_v3(orig_normal[i], f->no);
|
||||
BM_elem_index_set(f, (int)i); /* set_inline */
|
||||
BM_elem_index_set(f, int(i)); /* set_inline */
|
||||
}
|
||||
bm->elem_index_dirty &= (char)~(BM_VERT | BM_FACE);
|
||||
|
||||
for (i = 0; i < tris_len; i++) {
|
||||
float co[3][3];
|
||||
|
||||
tris[i][0] = (uint)BM_elem_index_get(looptris[i][0]->v);
|
||||
tris[i][1] = (uint)BM_elem_index_get(looptris[i][1]->v);
|
||||
tris[i][2] = (uint)BM_elem_index_get(looptris[i][2]->v);
|
||||
tris[i][0] = uint(BM_elem_index_get(looptris[i][0]->v));
|
||||
tris[i][1] = uint(BM_elem_index_get(looptris[i][1]->v));
|
||||
tris[i][2] = uint(BM_elem_index_get(looptris[i][2]->v));
|
||||
|
||||
copy_v3_v3(co[0], coords[tris[i][0]]);
|
||||
copy_v3_v3(co[1], coords[tris[i][1]]);
|
||||
copy_v3_v3(co[2], coords[tris[i][2]]);
|
||||
|
||||
BLI_bvhtree_insert(tree, (int)i, co[0], 3);
|
||||
BLI_bvhtree_insert(tree, int(i), co[0], 3);
|
||||
orig_index[i] = BM_elem_index_get(looptris[i][0]->f);
|
||||
}
|
||||
|
||||
@@ -1012,8 +1015,8 @@ static PyObject *C_BVHTree_FromBMesh(PyObject *UNUSED(cls), PyObject *args, PyOb
|
||||
|
||||
/* return various derived meshes based on requested settings */
|
||||
static Mesh *bvh_get_mesh(const char *funcname,
|
||||
struct Depsgraph *depsgraph,
|
||||
struct Scene *scene,
|
||||
Depsgraph *depsgraph,
|
||||
Scene *scene,
|
||||
Object *ob,
|
||||
const bool use_deform,
|
||||
const bool use_cage,
|
||||
@@ -1033,13 +1036,13 @@ static Mesh *bvh_get_mesh(const char *funcname,
|
||||
PyExc_ValueError,
|
||||
"%s(...): cage arg is unsupported when dependency graph evaluation mode is RENDER",
|
||||
funcname);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
*r_free_mesh = true;
|
||||
return mesh_create_eval_final(depsgraph, scene, ob, &data_masks);
|
||||
}
|
||||
if (ob_eval != NULL) {
|
||||
if (ob_eval != nullptr) {
|
||||
if (use_cage) {
|
||||
return mesh_get_eval_deform(depsgraph, scene, ob_eval, &data_masks);
|
||||
}
|
||||
@@ -1050,7 +1053,7 @@ static Mesh *bvh_get_mesh(const char *funcname,
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%s(...): Cannot get evaluated data from given dependency graph / object pair",
|
||||
funcname);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* !use_deform */
|
||||
@@ -1060,7 +1063,7 @@ static Mesh *bvh_get_mesh(const char *funcname,
|
||||
PyExc_ValueError,
|
||||
"%s(...): cage arg is unsupported when dependency graph evaluation mode is RENDER",
|
||||
funcname);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
*r_free_mesh = true;
|
||||
@@ -1072,7 +1075,7 @@ static Mesh *bvh_get_mesh(const char *funcname,
|
||||
"%s(...): cage arg is unsupported when deform=False and dependency graph "
|
||||
"evaluation mode is not RENDER",
|
||||
funcname);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
*r_free_mesh = true;
|
||||
@@ -1093,15 +1096,15 @@ PyDoc_STRVAR(C_BVHTree_FromObject_doc,
|
||||
" :type deform: bool\n"
|
||||
" :arg cage: Use modifiers cage.\n"
|
||||
" :type cage: bool\n" PYBVH_FROM_GENERIC_EPSILON_DOC);
|
||||
static PyObject *C_BVHTree_FromObject(PyObject *UNUSED(cls), PyObject *args, PyObject *kwargs)
|
||||
static PyObject *C_BVHTree_FromObject(PyObject * /*cls*/, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
/* NOTE: options here match #bpy_bmesh_from_object. */
|
||||
const char *keywords[] = {"object", "depsgraph", "deform", "cage", "epsilon", NULL};
|
||||
const char *keywords[] = {"object", "depsgraph", "deform", "cage", "epsilon", nullptr};
|
||||
|
||||
PyObject *py_ob, *py_depsgraph;
|
||||
Object *ob;
|
||||
struct Depsgraph *depsgraph;
|
||||
struct Scene *scene;
|
||||
Depsgraph *depsgraph;
|
||||
Scene *scene;
|
||||
Mesh *mesh;
|
||||
bool use_deform = true;
|
||||
bool use_cage = false;
|
||||
@@ -1110,8 +1113,8 @@ static PyObject *C_BVHTree_FromObject(PyObject *UNUSED(cls), PyObject *args, PyO
|
||||
const MLoopTri *lt;
|
||||
const MLoop *mloop;
|
||||
|
||||
float(*coords)[3] = NULL;
|
||||
uint(*tris)[3] = NULL;
|
||||
float(*coords)[3] = nullptr;
|
||||
uint(*tris)[3] = nullptr;
|
||||
uint coords_len, tris_len;
|
||||
float epsilon = 0.0f;
|
||||
|
||||
@@ -1126,28 +1129,29 @@ static PyObject *C_BVHTree_FromObject(PyObject *UNUSED(cls), PyObject *args, PyO
|
||||
PyC_ParseBool,
|
||||
&use_cage,
|
||||
&epsilon) ||
|
||||
((ob = PyC_RNA_AsPointer(py_ob, "Object")) == NULL) ||
|
||||
((depsgraph = PyC_RNA_AsPointer(py_depsgraph, "Depsgraph")) == NULL)) {
|
||||
return NULL;
|
||||
((ob = static_cast<Object *>(PyC_RNA_AsPointer(py_ob, "Object"))) == nullptr) ||
|
||||
((depsgraph = static_cast<Depsgraph *>(PyC_RNA_AsPointer(py_depsgraph, "Depsgraph"))) ==
|
||||
nullptr)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
scene = DEG_get_evaluated_scene(depsgraph);
|
||||
mesh = bvh_get_mesh("BVHTree", depsgraph, scene, ob, use_deform, use_cage, &free_mesh);
|
||||
|
||||
if (mesh == NULL) {
|
||||
return NULL;
|
||||
if (mesh == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Get data for tessellation */
|
||||
{
|
||||
lt = BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
|
||||
tris_len = (uint)BKE_mesh_runtime_looptri_len(mesh);
|
||||
coords_len = (uint)mesh->totvert;
|
||||
tris_len = uint(BKE_mesh_runtime_looptri_len(mesh));
|
||||
coords_len = uint(mesh->totvert);
|
||||
|
||||
coords = MEM_mallocN(sizeof(*coords) * (size_t)coords_len, __func__);
|
||||
tris = MEM_mallocN(sizeof(*tris) * (size_t)tris_len, __func__);
|
||||
memcpy(coords, BKE_mesh_vert_positions(mesh), sizeof(float[3]) * (size_t)mesh->totvert);
|
||||
coords = static_cast<float(*)[3]>(MEM_mallocN(sizeof(*coords) * size_t(coords_len), __func__));
|
||||
tris = static_cast<uint(*)[3]>(MEM_mallocN(sizeof(*tris) * size_t(tris_len), __func__));
|
||||
memcpy(coords, BKE_mesh_vert_positions(mesh), sizeof(float[3]) * size_t(mesh->totvert));
|
||||
|
||||
mloop = BKE_mesh_loops(mesh);
|
||||
}
|
||||
@@ -1156,14 +1160,15 @@ static PyObject *C_BVHTree_FromObject(PyObject *UNUSED(cls), PyObject *args, PyO
|
||||
BVHTree *tree;
|
||||
uint i;
|
||||
|
||||
int *orig_index = NULL;
|
||||
float(*orig_normal)[3] = NULL;
|
||||
int *orig_index = nullptr;
|
||||
float(*orig_normal)[3] = nullptr;
|
||||
|
||||
tree = BLI_bvhtree_new((int)tris_len, epsilon, PY_BVH_TREE_TYPE_DEFAULT, PY_BVH_AXIS_DEFAULT);
|
||||
tree = BLI_bvhtree_new(int(tris_len), epsilon, PY_BVH_TREE_TYPE_DEFAULT, PY_BVH_AXIS_DEFAULT);
|
||||
if (tree) {
|
||||
orig_index = MEM_mallocN(sizeof(*orig_index) * (size_t)tris_len, __func__);
|
||||
orig_index = static_cast<int *>(
|
||||
MEM_mallocN(sizeof(*orig_index) * size_t(tris_len), __func__));
|
||||
if (!BKE_mesh_poly_normals_are_dirty(mesh)) {
|
||||
orig_normal = MEM_dupallocN(BKE_mesh_poly_normals_ensure(mesh));
|
||||
orig_normal = static_cast<float(*)[3]>(MEM_dupallocN(BKE_mesh_poly_normals_ensure(mesh)));
|
||||
}
|
||||
|
||||
for (i = 0; i < tris_len; i++, lt++) {
|
||||
@@ -1177,15 +1182,15 @@ static PyObject *C_BVHTree_FromObject(PyObject *UNUSED(cls), PyObject *args, PyO
|
||||
copy_v3_v3(co[1], coords[tris[i][1]]);
|
||||
copy_v3_v3(co[2], coords[tris[i][2]]);
|
||||
|
||||
BLI_bvhtree_insert(tree, (int)i, co[0], 3);
|
||||
orig_index[i] = (int)lt->poly;
|
||||
BLI_bvhtree_insert(tree, int(i), co[0], 3);
|
||||
orig_index[i] = int(lt->poly);
|
||||
}
|
||||
|
||||
BLI_bvhtree_balance(tree);
|
||||
}
|
||||
|
||||
if (free_mesh) {
|
||||
BKE_id_free(NULL, mesh);
|
||||
BKE_id_free(nullptr, mesh);
|
||||
}
|
||||
|
||||
return bvhtree_CreatePyObject(
|
||||
@@ -1227,59 +1232,59 @@ static PyMethodDef py_bvhtree_methods[] = {
|
||||
METH_VARARGS | METH_KEYWORDS | METH_CLASS,
|
||||
C_BVHTree_FromObject_doc},
|
||||
#endif
|
||||
{NULL, NULL, 0, NULL},
|
||||
{nullptr, nullptr, 0, nullptr},
|
||||
};
|
||||
|
||||
PyTypeObject PyBVHTree_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
PyVarObject_HEAD_INIT(nullptr, 0)
|
||||
/*tp_name*/ "BVHTree",
|
||||
/*tp_basicsize*/ sizeof(PyBVHTree),
|
||||
/*tp_itemsize*/ 0,
|
||||
/*tp_dealloc*/ (destructor)py_bvhtree__tp_dealloc,
|
||||
/*tp_vectorcall_offset*/ 0,
|
||||
/*tp_getattr*/ NULL,
|
||||
/*tp_setattr*/ NULL,
|
||||
/*tp_as_async*/ NULL,
|
||||
/*tp_repr*/ NULL,
|
||||
/*tp_as_number*/ NULL,
|
||||
/*tp_as_sequence*/ NULL,
|
||||
/*tp_as_mapping*/ NULL,
|
||||
/*tp_hash*/ NULL,
|
||||
/*tp_call*/ NULL,
|
||||
/*tp_str*/ NULL,
|
||||
/*tp_getattro*/ NULL,
|
||||
/*tp_setattro*/ NULL,
|
||||
/*tp_as_buffer*/ NULL,
|
||||
/*tp_getattr*/ nullptr,
|
||||
/*tp_setattr*/ nullptr,
|
||||
/*tp_as_async*/ nullptr,
|
||||
/*tp_repr*/ nullptr,
|
||||
/*tp_as_number*/ nullptr,
|
||||
/*tp_as_sequence*/ nullptr,
|
||||
/*tp_as_mapping*/ nullptr,
|
||||
/*tp_hash*/ nullptr,
|
||||
/*tp_call*/ nullptr,
|
||||
/*tp_str*/ nullptr,
|
||||
/*tp_getattro*/ nullptr,
|
||||
/*tp_setattro*/ nullptr,
|
||||
/*tp_as_buffer*/ nullptr,
|
||||
/*tp_flags*/ Py_TPFLAGS_DEFAULT,
|
||||
/*tp_doc*/ NULL,
|
||||
/*tp_traverse*/ NULL,
|
||||
/*tp_clear*/ NULL,
|
||||
/*tp_richcompare*/ NULL,
|
||||
/*tp_doc*/ nullptr,
|
||||
/*tp_traverse*/ nullptr,
|
||||
/*tp_clear*/ nullptr,
|
||||
/*tp_richcompare*/ nullptr,
|
||||
/*tp_weaklistoffset*/ 0,
|
||||
/*tp_iter*/ NULL,
|
||||
/*tp_iternext*/ NULL,
|
||||
/*tp_iter*/ nullptr,
|
||||
/*tp_iternext*/ nullptr,
|
||||
/*tp_methods*/ py_bvhtree_methods,
|
||||
/*tp_members*/ NULL,
|
||||
/*tp_getset*/ NULL,
|
||||
/*tp_base*/ NULL,
|
||||
/*tp_dict*/ NULL,
|
||||
/*tp_descr_get*/ NULL,
|
||||
/*tp_descr_set*/ NULL,
|
||||
/*tp_members*/ nullptr,
|
||||
/*tp_getset*/ nullptr,
|
||||
/*tp_base*/ nullptr,
|
||||
/*tp_dict*/ nullptr,
|
||||
/*tp_descr_get*/ nullptr,
|
||||
/*tp_descr_set*/ nullptr,
|
||||
/*tp_dictoffset*/ 0,
|
||||
/*tp_init*/ NULL,
|
||||
/*tp_init*/ nullptr,
|
||||
/*tp_alloc*/ (allocfunc)PyType_GenericAlloc,
|
||||
/*tp_new*/ (newfunc)PyType_GenericNew,
|
||||
/*tp_free*/ (freefunc)0,
|
||||
/*tp_is_gc*/ NULL,
|
||||
/*tp_bases*/ NULL,
|
||||
/*tp_mro*/ NULL,
|
||||
/*tp_cache*/ NULL,
|
||||
/*tp_subclasses*/ NULL,
|
||||
/*tp_weaklist*/ NULL,
|
||||
/*tp_del*/ (destructor)NULL,
|
||||
/*tp_is_gc*/ nullptr,
|
||||
/*tp_bases*/ nullptr,
|
||||
/*tp_mro*/ nullptr,
|
||||
/*tp_cache*/ nullptr,
|
||||
/*tp_subclasses*/ nullptr,
|
||||
/*tp_weaklist*/ nullptr,
|
||||
/*tp_del*/ (destructor) nullptr,
|
||||
/*tp_version_tag*/ 0,
|
||||
/*tp_finalize*/ NULL,
|
||||
/*tp_vectorcall*/ NULL,
|
||||
/*tp_finalize*/ nullptr,
|
||||
/*tp_vectorcall*/ nullptr,
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -1287,29 +1292,29 @@ PyTypeObject PyBVHTree_Type = {
|
||||
|
||||
PyDoc_STRVAR(py_bvhtree_doc,
|
||||
"BVH tree structures for proximity searches and ray casts on geometry.");
|
||||
static struct PyModuleDef bvhtree_moduledef = {
|
||||
static PyModuleDef bvhtree_moduledef = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
/*m_name*/ "mathutils.bvhtree",
|
||||
/*m_doc*/ py_bvhtree_doc,
|
||||
/*m_size*/ 0,
|
||||
/*m_methods*/ NULL,
|
||||
/*m_slots*/ NULL,
|
||||
/*m_traverse*/ NULL,
|
||||
/*m_clear*/ NULL,
|
||||
/*m_free*/ NULL,
|
||||
/*m_methods*/ nullptr,
|
||||
/*m_slots*/ nullptr,
|
||||
/*m_traverse*/ nullptr,
|
||||
/*m_clear*/ nullptr,
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC PyInit_mathutils_bvhtree(void)
|
||||
{
|
||||
PyObject *m = PyModule_Create(&bvhtree_moduledef);
|
||||
|
||||
if (m == NULL) {
|
||||
return NULL;
|
||||
if (m == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Register classes */
|
||||
if (PyType_Ready(&PyBVHTree_Type) < 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyModule_AddType(m, &PyBVHTree_Type);
|
||||
Reference in New Issue
Block a user