Cleanup: Formatting

Run `make format` after the library update in the previous commit.
This commit is contained in:
Hans Goudey
2025-10-02 12:55:42 -04:00
parent 66224d69b0
commit a68d39e9d9
383 changed files with 1343 additions and 1365 deletions

View File

@@ -1542,14 +1542,14 @@ static PyObject *bpy_bmesh_transform(BPy_BMElem *self, PyObject *args, PyObject
if (!filter_flags) {
BM_ITER_MESH (eve, &iter, self->bm, BM_VERTS_OF_MESH) {
mul_m4_v3((float(*)[4])mat_ptr, eve->co);
mul_m4_v3((float (*)[4])mat_ptr, eve->co);
}
}
else {
const char filter_flags_ch = char(filter_flags);
BM_ITER_MESH (eve, &iter, self->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, filter_flags_ch)) {
mul_m4_v3((float(*)[4])mat_ptr, eve->co);
mul_m4_v3((float (*)[4])mat_ptr, eve->co);
}
}
}

View File

@@ -498,7 +498,7 @@ static PyObject *bpy_bm_utils_face_split(PyObject * /*self*/, PyObject *args, Py
py_face->f,
l_a,
l_b,
(float(*)[3])coords,
(float (*)[3])coords,
ncoords,
&l_new,
py_edge_example ? py_edge_example->e : nullptr);

View File

@@ -483,8 +483,8 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar
region,
GPU_offscreen_width(self->ofs),
GPU_offscreen_height(self->ofs),
(const float(*)[4])py_mat_view->matrix,
(const float(*)[4])py_mat_projection->matrix,
(const float (*)[4])py_mat_view->matrix,
(const float (*)[4])py_mat_projection->matrix,
true,
draw_background,
"",

View File

@@ -8295,7 +8295,7 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
/* Stupid/simple case. */
if (srna == nullptr) {
newclass = nullptr; /* Nothing to do. */
} /* The class may have already been declared & allocated. */
} /* The class may have already been declared & allocated. */
else if ((newclass = static_cast<PyObject *>(RNA_struct_py_type_get(srna)))) {
/* Add a reference for the return value. */
Py_INCREF(newclass);

View File

@@ -192,7 +192,7 @@ static PyObject *Euler_to_matrix(EulerObject *self)
return nullptr;
}
eulO_to_mat3((float(*)[3])mat, self->eul, self->order);
eulO_to_mat3((float (*)[3])mat, self->eul, self->order);
return Matrix_CreatePyObject(mat, 3, 3, nullptr);
}

View File

@@ -139,7 +139,7 @@ static float matrix_determinant_internal(const MatrixObject *self)
MATRIX_ITEM(self, 2, 2));
}
return determinant_m4((const float(*)[4])self->matrix);
return determinant_m4((const float (*)[4])self->matrix);
}
static void adjoint_matrix_n(float *mat_dst, const float *mat_src, const ushort dim)
@@ -147,15 +147,15 @@ static void adjoint_matrix_n(float *mat_dst, const float *mat_src, const ushort
/* calculate the classical adjoint */
switch (dim) {
case 2: {
adjoint_m2_m2((float(*)[2])mat_dst, (const float(*)[2])mat_src);
adjoint_m2_m2((float (*)[2])mat_dst, (const float (*)[2])mat_src);
break;
}
case 3: {
adjoint_m3_m3((float(*)[3])mat_dst, (const float(*)[3])mat_src);
adjoint_m3_m3((float (*)[3])mat_dst, (const float (*)[3])mat_src);
break;
}
case 4: {
adjoint_m4_m4((float(*)[4])mat_dst, (const float(*)[4])mat_src);
adjoint_m4_m4((float (*)[4])mat_dst, (const float (*)[4])mat_src);
break;
}
default:
@@ -222,10 +222,10 @@ static void matrix_invert_safe_internal(const MatrixObject *self, float *r_mat)
switch (self->col_num) {
case 2: {
float(*mat)[2] = (float(*)[2])in_mat;
float (*mat)[2] = (float (*)[2])in_mat;
if (in_mat != self->matrix) {
copy_m2_m2(mat, (const float(*)[2])self->matrix);
copy_m2_m2(mat, (const float (*)[2])self->matrix);
}
mat[0][0] += eps;
mat[1][1] += eps;
@@ -237,10 +237,10 @@ static void matrix_invert_safe_internal(const MatrixObject *self, float *r_mat)
break;
}
case 3: {
float(*mat)[3] = (float(*)[3])in_mat;
float (*mat)[3] = (float (*)[3])in_mat;
if (in_mat != self->matrix) {
copy_m3_m3(mat, (const float(*)[3])self->matrix);
copy_m3_m3(mat, (const float (*)[3])self->matrix);
}
mat[0][0] += eps;
mat[1][1] += eps;
@@ -253,10 +253,10 @@ static void matrix_invert_safe_internal(const MatrixObject *self, float *r_mat)
break;
}
case 4: {
float(*mat)[4] = (float(*)[4])in_mat;
float (*mat)[4] = (float (*)[4])in_mat;
if (in_mat != self->matrix) {
copy_m4_m4(mat, (const float(*)[4])self->matrix);
copy_m4_m4(mat, (const float (*)[4])self->matrix);
}
mat[0][0] += eps;
mat[1][1] += eps;
@@ -757,14 +757,14 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
return nullptr;
}
axis_angle_to_mat3((float(*)[3])mat, tvec, angle);
axis_angle_to_mat3((float (*)[3])mat, tvec, angle);
}
else if (matSize == 2) {
angle_to_mat2((float(*)[2])mat, angle);
angle_to_mat2((float (*)[2])mat, angle);
}
else {
/* valid axis checked above */
axis_angle_to_mat3_single((float(*)[3])mat, axis[0], angle);
axis_angle_to_mat3_single((float (*)[3])mat, axis[0], angle);
}
if (matSize == 4) {
@@ -1215,7 +1215,7 @@ static PyObject *C_Matrix_LocRotScale(PyObject *cls, PyObject *args)
}
if (mat_obj->col_num == 3 && mat_obj->row_num == 3) {
copy_m4_m3(mat, (const float(*)[3])mat_obj->matrix);
copy_m4_m3(mat, (const float (*)[3])mat_obj->matrix);
}
else {
PyErr_SetString(PyExc_ValueError,
@@ -1280,10 +1280,10 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self)
return nullptr;
}
if (self->row_num == 3) {
mat3_to_quat(quat, (const float(*)[3])self->matrix);
mat3_to_quat(quat, (const float (*)[3])self->matrix);
}
else {
mat4_to_quat(quat, (const float(*)[4])self->matrix);
mat4_to_quat(quat, (const float (*)[4])self->matrix);
}
return Quaternion_CreatePyObject(quat, nullptr);
}
@@ -1337,10 +1337,10 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
/* Must be 3-4 cols, 3-4 rows, square matrix. */
if (self->row_num == 3 && self->col_num == 3) {
copy_m3_m3(mat, (const float(*)[3])self->matrix);
copy_m3_m3(mat, (const float (*)[3])self->matrix);
}
else if (self->row_num == 4 && self->col_num == 4) {
copy_m3_m4(mat, (const float(*)[4])self->matrix);
copy_m3_m4(mat, (const float (*)[4])self->matrix);
}
else {
PyErr_SetString(PyExc_ValueError,
@@ -1416,7 +1416,7 @@ static PyObject *Matrix_resize_4x4(MatrixObject *self)
memcpy(mat[col], MATRIX_COL_PTR(self, col), self->row_num * sizeof(float));
}
copy_m4_m4((float(*)[4])self->matrix, (const float(*)[4])mat);
copy_m4_m4((float (*)[4])self->matrix, (const float (*)[4])mat);
self->col_num = 4;
self->row_num = 4;
@@ -1903,7 +1903,7 @@ static PyObject *Matrix_rotate(MatrixObject *self, PyObject *value)
matrix_as_3x3(self_rmat, self);
mul_m3_m3m3(rmat, other_rmat, self_rmat);
copy_m3_m3((float(*)[3])(self->matrix), rmat);
copy_m3_m3((float (*)[3])(self->matrix), rmat);
(void)BaseMath_WriteCallback(self);
Py_RETURN_NONE;
@@ -1943,7 +1943,7 @@ static PyObject *Matrix_decompose(MatrixObject *self)
return nullptr;
}
mat4_to_loc_rot_size(loc, rot, size, (const float(*)[4])self->matrix);
mat4_to_loc_rot_size(loc, rot, size, (const float (*)[4])self->matrix);
mat3_normalized_to_quat_fast(quat, rot);
ret = PyTuple_New(3);
@@ -1997,16 +1997,16 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args)
/* TODO: different sized matrix. */
if (self->col_num == 4 && self->row_num == 4) {
#ifdef MATH_STANDALONE
blend_m4_m4m4((float(*)[4])mat, (float(*)[4])self->matrix, (float(*)[4])mat2->matrix, fac);
blend_m4_m4m4((float (*)[4])mat, (float (*)[4])self->matrix, (float (*)[4])mat2->matrix, fac);
#else
interp_m4_m4m4((float(*)[4])mat, (float(*)[4])self->matrix, (float(*)[4])mat2->matrix, fac);
interp_m4_m4m4((float (*)[4])mat, (float (*)[4])self->matrix, (float (*)[4])mat2->matrix, fac);
#endif
}
else if (self->col_num == 3 && self->row_num == 3) {
#ifdef MATH_STANDALONE
blend_m3_m3m3((float(*)[3])mat, (float(*)[3])self->matrix, (float(*)[3])mat2->matrix, fac);
blend_m3_m3m3((float (*)[3])mat, (float (*)[3])self->matrix, (float (*)[3])mat2->matrix, fac);
#else
interp_m3_m3m3((float(*)[3])mat, (float(*)[3])self->matrix, (float(*)[3])mat2->matrix, fac);
interp_m3_m3m3((float (*)[3])mat, (float (*)[3])self->matrix, (float (*)[3])mat2->matrix, fac);
#endif
}
else {
@@ -2079,10 +2079,10 @@ static PyObject *Matrix_transpose(MatrixObject *self)
MATRIX_ITEM(self, 0, 1) = t;
}
else if (self->col_num == 3) {
transpose_m3((float(*)[3])self->matrix);
transpose_m3((float (*)[3])self->matrix);
}
else {
transpose_m4((float(*)[4])self->matrix);
transpose_m4((float (*)[4])self->matrix);
}
(void)BaseMath_WriteCallback(self);
@@ -2131,10 +2131,10 @@ static PyObject *Matrix_normalize(MatrixObject *self)
}
if (self->col_num == 3) {
normalize_m3((float(*)[3])self->matrix);
normalize_m3((float (*)[3])self->matrix);
}
else if (self->col_num == 4) {
normalize_m4((float(*)[4])self->matrix);
normalize_m4((float (*)[4])self->matrix);
}
else {
PyErr_SetString(PyExc_ValueError,
@@ -2200,13 +2200,13 @@ static void matrix_identity_internal(MatrixObject *self)
BLI_assert((self->col_num == self->row_num) && (self->row_num <= 4));
if (self->col_num == 2) {
unit_m2((float(*)[2])self->matrix);
unit_m2((float (*)[2])self->matrix);
}
else if (self->col_num == 3) {
unit_m3((float(*)[3])self->matrix);
unit_m3((float (*)[3])self->matrix);
}
else {
unit_m4((float(*)[4])self->matrix);
unit_m4((float (*)[4])self->matrix);
}
}
@@ -3219,7 +3219,7 @@ static int Matrix_translation_set(MatrixObject *self, PyObject *value, void * /*
return -1;
}
copy_v3_v3(((float(*)[4])self->matrix)[3], tvec);
copy_v3_v3(((float (*)[4])self->matrix)[3], tvec);
(void)BaseMath_WriteCallback(self);
@@ -3304,10 +3304,10 @@ static PyObject *Matrix_is_negative_get(MatrixObject *self, void * /*closure*/)
/* Must be 3-4 cols, 3-4 rows, square matrix. */
if (self->row_num == 4 && self->col_num == 4) {
return PyBool_FromLong(is_negative_m4((const float(*)[4])self->matrix));
return PyBool_FromLong(is_negative_m4((const float (*)[4])self->matrix));
}
if (self->row_num == 3 && self->col_num == 3) {
return PyBool_FromLong(is_negative_m3((const float(*)[3])self->matrix));
return PyBool_FromLong(is_negative_m3((const float (*)[3])self->matrix));
}
PyErr_SetString(PyExc_AttributeError,
@@ -3330,10 +3330,10 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void * /*closure*/
/* Must be 3-4 cols, 3-4 rows, square matrix. */
if (self->row_num == 4 && self->col_num == 4) {
return PyBool_FromLong(is_orthonormal_m4((const float(*)[4])self->matrix));
return PyBool_FromLong(is_orthonormal_m4((const float (*)[4])self->matrix));
}
if (self->row_num == 3 && self->col_num == 3) {
return PyBool_FromLong(is_orthonormal_m3((const float(*)[3])self->matrix));
return PyBool_FromLong(is_orthonormal_m3((const float (*)[3])self->matrix));
}
PyErr_SetString(PyExc_AttributeError,
@@ -3357,10 +3357,10 @@ static PyObject *Matrix_is_orthogonal_axis_vectors_get(MatrixObject *self, void
/* Must be 3-4 cols, 3-4 rows, square matrix. */
if (self->row_num == 4 && self->col_num == 4) {
return PyBool_FromLong(is_orthogonal_m4((const float(*)[4])self->matrix));
return PyBool_FromLong(is_orthogonal_m4((const float (*)[4])self->matrix));
}
if (self->row_num == 3 && self->col_num == 3) {
return PyBool_FromLong(is_orthogonal_m3((const float(*)[3])self->matrix));
return PyBool_FromLong(is_orthogonal_m3((const float (*)[3])self->matrix));
}
PyErr_SetString(PyExc_AttributeError,

View File

@@ -266,7 +266,7 @@ static PyObject *Quaternion_to_matrix(QuaternionObject *self)
return nullptr;
}
quat_to_mat3((float(*)[3])mat, self->quat);
quat_to_mat3((float (*)[3])mat, self->quat);
return Matrix_CreatePyObject(mat, 3, 3, nullptr);
}

View File

@@ -1494,7 +1494,7 @@ static PyObject *Vector_rotate(VectorObject *self, PyObject *value)
if (!Matrix_Parse2x2(value, &pymat)) {
return nullptr;
}
normalize_m2_m2(other_rmat, (const float(*)[2])pymat->matrix);
normalize_m2_m2(other_rmat, (const float (*)[2])pymat->matrix);
/* Equivalent to a rotation along the Z axis. */
mul_m2_v2(other_rmat, self->vec);
}
@@ -2914,31 +2914,46 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure
#define VECTOR_SWIZZLE2_RW_DEF(attr, a, b) \
{ \
attr, (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, Vector_swizzle_doc, \
SWIZZLE2(a, b), \
attr, \
(getter)Vector_swizzle_get, \
(setter)Vector_swizzle_set, \
Vector_swizzle_doc, \
SWIZZLE2(a, b), \
}
#define VECTOR_SWIZZLE2_RO_DEF(attr, a, b) \
{ \
attr, (getter)Vector_swizzle_get, (setter) nullptr, Vector_swizzle_doc, SWIZZLE2(a, b), \
attr, \
(getter)Vector_swizzle_get, \
(setter) nullptr, \
Vector_swizzle_doc, \
SWIZZLE2(a, b), \
}
#define VECTOR_SWIZZLE3_RW_DEF(attr, a, b, c) \
{ \
attr, (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, Vector_swizzle_doc, \
SWIZZLE3(a, b, c), \
attr, \
(getter)Vector_swizzle_get, \
(setter)Vector_swizzle_set, \
Vector_swizzle_doc, \
SWIZZLE3(a, b, c), \
}
#define VECTOR_SWIZZLE3_RO_DEF(attr, a, b, c) \
{ \
attr, (getter)Vector_swizzle_get, (setter) nullptr, Vector_swizzle_doc, SWIZZLE3(a, b, c), \
attr, \
(getter)Vector_swizzle_get, \
(setter) nullptr, \
Vector_swizzle_doc, \
SWIZZLE3(a, b, c), \
}
#define VECTOR_SWIZZLE4_RW_DEF(attr, a, b, c, d) \
{ \
attr, (getter)Vector_swizzle_get, (setter)Vector_swizzle_set, Vector_swizzle_doc, \
SWIZZLE4(a, b, c, d), \
attr, \
(getter)Vector_swizzle_get, \
(setter)Vector_swizzle_set, \
Vector_swizzle_doc, \
SWIZZLE4(a, b, c, d), \
}
#define VECTOR_SWIZZLE4_RO_DEF(attr, a, b, c, d) \
{ \
attr, (getter)Vector_swizzle_get, (setter) nullptr, Vector_swizzle_doc, SWIZZLE4(a, b, c, d) \
}
{attr, (getter)Vector_swizzle_get, (setter) nullptr, Vector_swizzle_doc, SWIZZLE4(a, b, c, d)}
/** \} */

View File

@@ -263,7 +263,7 @@ static void py_bvhtree_raycast_cb(void *userdata,
{
const PyBVHTree *self = static_cast<const PyBVHTree *>(userdata);
const float(*coords)[3] = self->coords;
const float (*coords)[3] = self->coords;
const uint *tri = self->tris[index];
const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
float dist;
@@ -296,7 +296,7 @@ static void py_bvhtree_nearest_point_cb(void *userdata,
{
PyBVHTree *self = static_cast<PyBVHTree *>(userdata);
const float(*coords)[3] = (const float(*)[3])self->coords;
const float (*coords)[3] = (const float (*)[3])self->coords;
const uint *tri = self->tris[index];
const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
float nearest_tmp[3], dist_sq;
@@ -429,7 +429,7 @@ static void py_bvhtree_nearest_point_range_cb(void *userdata,
PyBVH_RangeData *data = static_cast<PyBVH_RangeData *>(userdata);
PyBVHTree *self = data->self;
const float(*coords)[3] = self->coords;
const float (*coords)[3] = self->coords;
const uint *tri = self->tris[index];
const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
float nearest_tmp[3], dist_sq;
@@ -658,7 +658,7 @@ static PyObject *C_BVHTree_FromPolygons(PyObject * /*cls*/, PyObject *args, PyOb
MemArena *poly_arena = nullptr;
MemArena *pf_arena = nullptr;
float(*coords)[3] = nullptr;
float (*coords)[3] = nullptr;
uint(*tris)[3] = nullptr;
uint coords_len, tris_len;
float epsilon = 0.0f;
@@ -666,7 +666,7 @@ static PyObject *C_BVHTree_FromPolygons(PyObject * /*cls*/, PyObject *args, PyOb
/* when all_triangles is False */
int *orig_index = nullptr;
float(*orig_normal)[3] = nullptr;
float (*orig_normal)[3] = nullptr;
uint i;
bool valid = true;
@@ -833,7 +833,7 @@ static PyObject *C_BVHTree_FromPolygons(PyObject * /*cls*/, PyObject *args, PyOb
i++;
}
else if (plink->len > 3) {
float(*proj_coords)[2] = static_cast<float(*)[2]>(
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;
@@ -940,7 +940,7 @@ static PyObject *C_BVHTree_FromBMesh(PyObject * /*cls*/, PyObject *args, PyObjec
BPy_BMesh *py_bm;
float(*coords)[3] = nullptr;
float (*coords)[3] = nullptr;
uint(*tris)[3] = nullptr;
uint coords_len, tris_len;
float epsilon = 0.0f;
@@ -977,7 +977,7 @@ static PyObject *C_BVHTree_FromBMesh(PyObject * /*cls*/, PyObject *args, PyObjec
uint i;
int *orig_index = nullptr;
float(*orig_normal)[3] = nullptr;
float (*orig_normal)[3] = nullptr;
tree = BLI_bvhtree_new(int(tris_len), epsilon, PY_BVH_TREE_TYPE_DEFAULT, PY_BVH_AXIS_DEFAULT);
if (tree) {
@@ -1188,7 +1188,7 @@ static PyObject *C_BVHTree_FromObject(PyObject * /*cls*/, PyObject *args, PyObje
const uint coords_len = uint(mesh->verts_num);
float(*coords)[3] = MEM_malloc_arrayN<float[3]>(size_t(coords_len), __func__);
float (*coords)[3] = MEM_malloc_arrayN<float[3]>(size_t(coords_len), __func__);
uint(*tris)[3] = MEM_malloc_arrayN<uint[3]>(size_t(corner_tris.size()), __func__);
memcpy(coords, mesh->vert_positions().data(), sizeof(float[3]) * size_t(mesh->verts_num));
@@ -1236,7 +1236,7 @@ static PyObject *C_BVHTree_FromObject(PyObject * /*cls*/, PyObject *args, PyObje
tris,
uint(corner_tris.size()),
orig_index,
reinterpret_cast<float(*)[3]>(orig_normal));
reinterpret_cast<float (*)[3]>(orig_normal));
}
#endif /* MATH_STANDALONE */

View File

@@ -352,7 +352,7 @@ PyDoc_STRVAR(
" :rtype: :class:`mathutils.Vector`\n");
static PyObject *M_Geometry_normal(PyObject * /*self*/, PyObject *args)
{
float(*coords)[3];
float (*coords)[3];
int coords_len;
float n[3];
PyObject *ret = nullptr;
@@ -1228,7 +1228,7 @@ PyDoc_STRVAR(
static PyObject *M_Geometry_points_in_planes(PyObject * /*self*/, PyObject *args)
{
PyObject *py_planes;
float(*planes)[4];
float (*planes)[4];
float eps_coplanar = 1e-4f;
float eps_isect = 1e-6f;
uint planes_len;
@@ -1577,7 +1577,7 @@ PyDoc_STRVAR(
" :rtype: float\n");
static PyObject *M_Geometry_box_fit_2d(PyObject * /*self*/, PyObject *pointlist)
{
float(*points)[2];
float (*points)[2];
Py_ssize_t len;
float angle = 0.0f;
@@ -1610,7 +1610,7 @@ PyDoc_STRVAR(
" :rtype: list[int]\n");
static PyObject *M_Geometry_convex_hull_2d(PyObject * /*self*/, PyObject *pointlist)
{
float(*points)[2];
float (*points)[2];
Py_ssize_t len;
PyObject *ret;
@@ -1718,8 +1718,8 @@ static PyObject *M_Geometry_delaunay_2d_cdt(PyObject * /*self*/, PyObject *args)
int output_type;
float epsilon;
bool need_ids = true;
float(*in_coords)[2] = nullptr;
int(*in_edges)[2] = nullptr;
float (*in_coords)[2] = nullptr;
int (*in_edges)[2] = nullptr;
Py_ssize_t vert_coords_len, edges_len;
PyObject *out_vert_coords = nullptr;
PyObject *out_edges = nullptr;

View File

@@ -37,7 +37,7 @@ PyDoc_STRVAR(
static PyObject *M_Interpolate_poly_3d_calc(PyObject * /*self*/, PyObject *args)
{
float fp[3];
float(*vecs)[3];
float (*vecs)[3];
Py_ssize_t len;
PyObject *point, *veclist, *ret;