Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-05-18 07:13:20 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-05-18 07:16:34 +0300
commit8a26fec6ea76330d82f323c1bbf765320ceb7796 (patch)
tree0604a3de874d4ba5afdf665f3c6078fae49c9856 /source/blender/python/mathutils
parent4dfbaa34c98acd5940d7fb85b8d1f54ea7e4451e (diff)
Cleanup: use const casts in mathutils API
Diffstat (limited to 'source/blender/python/mathutils')
-rw-r--r--source/blender/python/mathutils/mathutils.c12
-rw-r--r--source/blender/python/mathutils/mathutils_Euler.c2
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c46
-rw-r--r--source/blender/python/mathutils/mathutils_kdtree.c2
4 files changed, 31 insertions, 31 deletions
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index 3791a6c2d29..16bf7120606 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -152,7 +152,7 @@ int mathutils_array_parse(
return -1;
}
- memcpy(array, ((BaseMathObject *)value)->data, size * sizeof(float));
+ memcpy(array, ((const BaseMathObject *)value)->data, size * sizeof(float));
}
else
#endif
@@ -235,7 +235,7 @@ int mathutils_array_parse_alloc(float **array,
}
*array = PyMem_Malloc(size * sizeof(float));
- memcpy(*array, ((BaseMathObject *)value)->data, size * sizeof(float));
+ memcpy(*array, ((const BaseMathObject *)value)->data, size * sizeof(float));
return size;
}
@@ -471,7 +471,7 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
return -1;
}
- eulO_to_mat3(rmat, ((EulerObject *)value)->eul, ((EulerObject *)value)->order);
+ eulO_to_mat3(rmat, ((const EulerObject *)value)->eul, ((const EulerObject *)value)->order);
return 0;
}
if (QuaternionObject_Check(value)) {
@@ -480,7 +480,7 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
}
float tquat[4];
- normalize_qt_qt(tquat, ((QuaternionObject *)value)->quat);
+ normalize_qt_qt(tquat, ((const QuaternionObject *)value)->quat);
quat_to_mat3(rmat, tquat);
return 0;
}
@@ -530,8 +530,8 @@ int EXPP_FloatsAreEqual(float af, float bf, int maxDiff)
{
/* solid, fast routine across all platforms
* with constant time behavior */
- const int ai = *(int *)(&af);
- const int bi = *(int *)(&bf);
+ const int ai = *(const int *)(&af);
+ const int bi = *(const int *)(&bf);
const int test = SIGNMASK(ai ^ bi);
int diff, v1, v2;
diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c
index f2a8af18073..b6a0183d04e 100644
--- a/source/blender/python/mathutils/mathutils_Euler.c
+++ b/source/blender/python/mathutils/mathutils_Euler.c
@@ -88,7 +88,7 @@ short euler_order_from_string(const char *str, const char *error_prefix)
# define MAKE_ID3(a, b, c) (((a) << 24) | ((b) << 16) | ((c) << 8))
#endif
- switch (*((PY_INT32_T *)str)) {
+ switch (*((const PY_INT32_T *)str)) {
case MAKE_ID3('X', 'Y', 'Z'):
return EULER_ORDER_XYZ;
case MAKE_ID3('X', 'Z', 'Y'):
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index e3c76408e62..c312012b24c 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -187,7 +187,7 @@ static int mathutils_matrix_col_get(BaseMathObject *bmo, int col)
}
/* for 'translation' size will always be '3' even on 4x4 vec */
- num_row = min_ii(self->num_row, ((VectorObject *)bmo)->size);
+ num_row = min_ii(self->num_row, ((const VectorObject *)bmo)->size);
for (row = 0; row < num_row; row++) {
bmo->data[row] = MATRIX_ITEM(self, row, col);
@@ -210,7 +210,7 @@ static int mathutils_matrix_col_set(BaseMathObject *bmo, int col)
}
/* for 'translation' size will always be '3' even on 4x4 vec */
- num_row = min_ii(self->num_row, ((VectorObject *)bmo)->size);
+ num_row = min_ii(self->num_row, ((const VectorObject *)bmo)->size);
for (row = 0; row < num_row; row++) {
MATRIX_ITEM(self, row, col) = bmo->data[row];
@@ -1034,7 +1034,7 @@ static PyObject *C_Matrix_LocRotScale(PyObject *cls, PyObject *args)
}
if (mat_obj->num_col == 3 && mat_obj->num_row == 3) {
- copy_m4_m3(mat, (float(*)[3])mat_obj->matrix);
+ copy_m4_m3(mat, (const float(*)[3])mat_obj->matrix);
}
else {
PyErr_SetString(PyExc_ValueError,
@@ -1127,7 +1127,7 @@ static float matrix_determinant_internal(const MatrixObject *self)
MATRIX_ITEM(self, 2, 2));
}
- return determinant_m4((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)
@@ -1135,15 +1135,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, (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, (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, (float(*)[4])mat_src);
+ adjoint_m4_m4((float(*)[4])mat_dst, (const float(*)[4])mat_src);
break;
}
default:
@@ -1213,7 +1213,7 @@ static void matrix_invert_safe_internal(const MatrixObject *self, float *r_mat)
float(*mat)[2] = (float(*)[2])in_mat;
if (in_mat != self->matrix) {
- copy_m2_m2(mat, (float(*)[2])self->matrix);
+ copy_m2_m2(mat, (const float(*)[2])self->matrix);
}
mat[0][0] += eps;
mat[1][1] += eps;
@@ -1228,7 +1228,7 @@ static void matrix_invert_safe_internal(const MatrixObject *self, float *r_mat)
float(*mat)[3] = (float(*)[3])in_mat;
if (in_mat != self->matrix) {
- copy_m3_m3(mat, (float(*)[3])self->matrix);
+ copy_m3_m3(mat, (const float(*)[3])self->matrix);
}
mat[0][0] += eps;
mat[1][1] += eps;
@@ -1244,7 +1244,7 @@ static void matrix_invert_safe_internal(const MatrixObject *self, float *r_mat)
float(*mat)[4] = (float(*)[4])in_mat;
if (in_mat != self->matrix) {
- copy_m4_m4(mat, (float(*)[4])self->matrix);
+ copy_m4_m4(mat, (const float(*)[4])self->matrix);
}
mat[0][0] += eps;
mat[1][1] += eps;
@@ -1292,7 +1292,7 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self)
mat3_to_quat(quat, (float(*)[3])self->matrix);
}
else {
- mat4_to_quat(quat, (float(*)[4])self->matrix);
+ mat4_to_quat(quat, (const float(*)[4])self->matrix);
}
return Quaternion_CreatePyObject(quat, NULL);
@@ -1341,10 +1341,10 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
/*must be 3-4 cols, 3-4 rows, square matrix */
if (self->num_row == 3 && self->num_col == 3) {
- copy_m3_m3(mat, (float(*)[3])self->matrix);
+ copy_m3_m3(mat, (const float(*)[3])self->matrix);
}
else if (self->num_row == 4 && self->num_col == 4) {
- copy_m3_m4(mat, (float(*)[4])self->matrix);
+ copy_m3_m4(mat, (const float(*)[4])self->matrix);
}
else {
PyErr_SetString(PyExc_ValueError,
@@ -1419,7 +1419,7 @@ static PyObject *Matrix_resize_4x4(MatrixObject *self)
memcpy(mat[col], MATRIX_COL_PTR(self, col), self->num_row * sizeof(float));
}
- copy_m4_m4((float(*)[4])self->matrix, (float(*)[4])mat);
+ copy_m4_m4((float(*)[4])self->matrix, (const float(*)[4])mat);
self->num_col = 4;
self->num_row = 4;
@@ -1577,7 +1577,7 @@ static bool matrix_invert_args_check(const MatrixObject *self, PyObject *args, b
return true;
case 1:
if (check_type) {
- const MatrixObject *fallback = (MatrixObject *)PyTuple_GET_ITEM(args, 0);
+ const MatrixObject *fallback = (const MatrixObject *)PyTuple_GET_ITEM(args, 0);
if (!MatrixObject_Check(fallback)) {
PyErr_SetString(PyExc_TypeError,
"Matrix.invert: "
@@ -1895,7 +1895,7 @@ static PyObject *Matrix_decompose(MatrixObject *self)
return NULL;
}
- mat4_to_loc_rot_size(loc, rot, size, (float(*)[4])self->matrix);
+ mat4_to_loc_rot_size(loc, rot, size, (const float(*)[4])self->matrix);
mat3_to_quat(quat, rot);
ret = PyTuple_New(3);
@@ -2157,7 +2157,7 @@ static PyObject *Matrix_identity(MatrixObject *self)
static PyObject *Matrix_copy_notest(MatrixObject *self, const float *matrix)
{
- return Matrix_CreatePyObject((float *)matrix, self->num_col, self->num_row, Py_TYPE(self));
+ return Matrix_CreatePyObject((const float *)matrix, self->num_col, self->num_row, Py_TYPE(self));
}
PyDoc_STRVAR(Matrix_copy_doc,
@@ -3058,10 +3058,10 @@ static PyObject *Matrix_is_negative_get(MatrixObject *self, void *UNUSED(closure
/*must be 3-4 cols, 3-4 rows, square matrix*/
if (self->num_row == 4 && self->num_col == 4) {
- return PyBool_FromLong(is_negative_m4((float(*)[4])self->matrix));
+ return PyBool_FromLong(is_negative_m4((const float(*)[4])self->matrix));
}
if (self->num_row == 3 && self->num_col == 3) {
- return PyBool_FromLong(is_negative_m3((float(*)[3])self->matrix));
+ return PyBool_FromLong(is_negative_m3((const float(*)[3])self->matrix));
}
PyErr_SetString(PyExc_AttributeError,
@@ -3080,10 +3080,10 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closu
/*must be 3-4 cols, 3-4 rows, square matrix*/
if (self->num_row == 4 && self->num_col == 4) {
- return PyBool_FromLong(is_orthonormal_m4((float(*)[4])self->matrix));
+ return PyBool_FromLong(is_orthonormal_m4((const float(*)[4])self->matrix));
}
if (self->num_row == 3 && self->num_col == 3) {
- return PyBool_FromLong(is_orthonormal_m3((float(*)[3])self->matrix));
+ return PyBool_FromLong(is_orthonormal_m3((const float(*)[3])self->matrix));
}
PyErr_SetString(PyExc_AttributeError,
@@ -3103,10 +3103,10 @@ static PyObject *Matrix_is_orthogonal_axis_vectors_get(MatrixObject *self, void
/*must be 3-4 cols, 3-4 rows, square matrix*/
if (self->num_row == 4 && self->num_col == 4) {
- return PyBool_FromLong(is_orthogonal_m4((float(*)[4])self->matrix));
+ return PyBool_FromLong(is_orthogonal_m4((const float(*)[4])self->matrix));
}
if (self->num_row == 3 && self->num_col == 3) {
- return PyBool_FromLong(is_orthogonal_m3((float(*)[3])self->matrix));
+ return PyBool_FromLong(is_orthogonal_m3((const float(*)[3])self->matrix));
}
PyErr_SetString(PyExc_AttributeError,
diff --git a/source/blender/python/mathutils/mathutils_kdtree.c b/source/blender/python/mathutils/mathutils_kdtree.c
index fe8f9ec0334..d54dbc9ab05 100644
--- a/source/blender/python/mathutils/mathutils_kdtree.c
+++ b/source/blender/python/mathutils/mathutils_kdtree.c
@@ -52,7 +52,7 @@ static void kdtree_nearest_to_py_tuple(const KDTreeNearest_3d *nearest, PyObject
BLI_assert(PyTuple_GET_SIZE(py_retval) == 3);
PyTuple_SET_ITEMS(py_retval,
- Vector_CreatePyObject((float *)nearest->co, 3, NULL),
+ Vector_CreatePyObject(nearest->co, 3, NULL),
PyLong_FromLong(nearest->index),
PyFloat_FromDouble(nearest->dist));
}