Cleanup: various non-functional changes for C++ (python, windowmanager)
- Remove redundant void, struct. - Use function style casts.
This commit is contained in:
@@ -77,7 +77,7 @@ Py_hash_t mathutils_array_hash(const float *array, size_t array_len)
|
||||
x = 0x345678UL;
|
||||
i = 0;
|
||||
while (--len >= 0) {
|
||||
y = _Py_HashDouble(nullptr, (double)(array[i++]));
|
||||
y = _Py_HashDouble(nullptr, double(array[i++]));
|
||||
if (y == -1) {
|
||||
return -1;
|
||||
}
|
||||
@@ -395,7 +395,7 @@ int mathutils_array_parse_alloc_viseq(
|
||||
start = 0;
|
||||
for (i = 0; i < size; i++) {
|
||||
subseq = value_fast_items[i];
|
||||
if ((subseq_len = (int)PySequence_Size(subseq)) == -1) {
|
||||
if ((subseq_len = int(PySequence_Size(subseq))) == -1) {
|
||||
PyErr_Format(
|
||||
PyExc_ValueError, "%.200s: sequence expected to have subsequences", error_prefix);
|
||||
PyMem_Free(*start_table);
|
||||
@@ -495,7 +495,7 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
|
||||
* [3] https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
|
||||
* instead.
|
||||
*/
|
||||
#define SIGNMASK(i) (-(int)(((uint)(i)) >> 31))
|
||||
#define SIGNMASK(i) (-int((uint(i)) >> 31))
|
||||
|
||||
int EXPP_FloatsAreEqual(float af, float bf, int maxDiff)
|
||||
{
|
||||
@@ -792,7 +792,7 @@ static PyModuleDef M_Mathutils_module_def = {
|
||||
# include "mathutils_noise.h"
|
||||
#endif
|
||||
|
||||
PyMODINIT_FUNC PyInit_mathutils(void)
|
||||
PyMODINIT_FUNC PyInit_mathutils()
|
||||
{
|
||||
PyObject *mod;
|
||||
PyObject *submodule;
|
||||
|
||||
@@ -42,7 +42,7 @@ static PyObject *Color_to_tuple_ex(ColorObject *self, int ndigits)
|
||||
|
||||
if (ndigits >= 0) {
|
||||
for (i = 0; i < COLOR_SIZE; i++) {
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->col[i], ndigits)));
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round(double(self->col[i]), ndigits)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -76,7 +76,7 @@ static PyObject *Euler_to_tuple_ex(EulerObject *self, int ndigits)
|
||||
|
||||
if (ndigits >= 0) {
|
||||
for (i = 0; i < EULER_SIZE; i++) {
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->eul[i], ndigits)));
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round(double(self->eul[i]), ndigits)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -228,7 +228,7 @@ static PyObject *Euler_rotate_axis(EulerObject *self, PyObject *args)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rotate_eulO(self->eul, self->order, (char)axis, angle);
|
||||
rotate_eulO(self->eul, self->order, char(axis), angle);
|
||||
|
||||
(void)BaseMath_WriteCallback(self);
|
||||
|
||||
|
||||
@@ -1592,7 +1592,7 @@ static bool matrix_invert_args_check(const MatrixObject *self, PyObject *args, b
|
||||
}
|
||||
}
|
||||
|
||||
static void matrix_invert_raise_degenerate(void)
|
||||
static void matrix_invert_raise_degenerate()
|
||||
{
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Matrix.invert(ed): "
|
||||
@@ -1804,7 +1804,7 @@ static PyObject *Matrix_adjugate(MatrixObject *self)
|
||||
}
|
||||
else {
|
||||
PyErr_Format(
|
||||
PyExc_ValueError, "Matrix adjugate(d): size (%d) unsupported", (int)self->col_num);
|
||||
PyExc_ValueError, "Matrix adjugate(d): size (%d) unsupported", int(self->col_num));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1992,7 +1992,7 @@ static PyObject *Matrix_determinant(MatrixObject *self)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble((double)matrix_determinant_internal(self));
|
||||
return PyFloat_FromDouble(double(matrix_determinant_internal(self)));
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -2869,9 +2869,9 @@ static PyObject *Matrix_matmul(PyObject *m1, PyObject *m2)
|
||||
for (row = 0; row < mat1->row_num; row++) {
|
||||
double dot = 0.0f;
|
||||
for (item = 0; item < mat1->col_num; item++) {
|
||||
dot += (double)(MATRIX_ITEM(mat1, row, item) * MATRIX_ITEM(mat2, item, col));
|
||||
dot += double(MATRIX_ITEM(mat1, row, item) * MATRIX_ITEM(mat2, item, col));
|
||||
}
|
||||
mat[(col * mat1->row_num) + row] = (float)dot;
|
||||
mat[(col * mat1->row_num) + row] = float(dot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2942,11 +2942,11 @@ static PyObject *Matrix_imatmul(PyObject *m1, PyObject *m2)
|
||||
for (row = 0; row < mat1->row_num; row++) {
|
||||
double dot = 0.0f;
|
||||
for (item = 0; item < mat1->col_num; item++) {
|
||||
dot += (double)(MATRIX_ITEM(mat1, row, item) * MATRIX_ITEM(mat2, item, col));
|
||||
dot += double(MATRIX_ITEM(mat1, row, item) * MATRIX_ITEM(mat2, item, col));
|
||||
}
|
||||
/* store in new matrix as overwriting original at this point will cause
|
||||
* subsequent iterations to use incorrect values */
|
||||
mat[(col * mat1->row_num) + row] = (float)dot;
|
||||
mat[(col * mat1->row_num) + row] = float(dot);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ static PyObject *Quaternion_to_tuple_ext(QuaternionObject *self, int ndigits)
|
||||
|
||||
if (ndigits >= 0) {
|
||||
for (i = 0; i < QUAT_SIZE; i++) {
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->quat[i], ndigits)));
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round(double(self->quat[i]), ndigits)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -923,7 +923,7 @@ static int Quaternion_ass_item(QuaternionObject *self, Py_ssize_t i, PyObject *o
|
||||
return -1;
|
||||
}
|
||||
|
||||
f = (float)PyFloat_AsDouble(ob);
|
||||
f = float(PyFloat_AsDouble(ob));
|
||||
|
||||
if (f == -1.0f && PyErr_Occurred()) { /* parsed item not a number */
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
|
||||
@@ -81,9 +81,9 @@ static int row_vector_multiplication(float r_vec[MAX_DIMENSIONS],
|
||||
for (col = 0; col < mat->col_num; col++) {
|
||||
double dot = 0.0;
|
||||
for (row = 0; row < mat->row_num; row++) {
|
||||
dot += (double)(MATRIX_ITEM(mat, row, col) * vec_cpy[row]);
|
||||
dot += double(MATRIX_ITEM(mat, row, col) * vec_cpy[row]);
|
||||
}
|
||||
r_vec[z++] = (float)dot;
|
||||
r_vec[z++] = float(dot);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ static PyObject *Vector_to_tuple_ex(VectorObject *self, int ndigits)
|
||||
|
||||
if (ndigits >= 0) {
|
||||
for (i = 0; i < self->vec_num; i++) {
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->vec[i], ndigits)));
|
||||
PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round(double(self->vec[i]), ndigits)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -288,7 +288,7 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
range_vn_fl(vec, vec_num, (float)start, (float)step);
|
||||
range_vn_fl(vec, vec_num, float(start), float(step));
|
||||
|
||||
return Vector_CreatePyObject_alloc(vec, vec_num, (PyTypeObject *)cls);
|
||||
}
|
||||
@@ -320,7 +320,7 @@ static PyObject *C_Vector_Linspace(PyObject *cls, PyObject *args)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
step = (end - start) / (float)(vec_num - 1);
|
||||
step = (end - start) / float(vec_num - 1);
|
||||
|
||||
vec = static_cast<float *>(PyMem_Malloc(vec_num * sizeof(float)));
|
||||
|
||||
@@ -1110,9 +1110,9 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
for (x = 0; x < vec_num; x++) {
|
||||
dot_self += (double)self->vec[x] * (double)self->vec[x];
|
||||
dot_other += (double)tvec[x] * (double)tvec[x];
|
||||
dot += (double)self->vec[x] * (double)tvec[x];
|
||||
dot_self += double(self->vec[x]) * double(self->vec[x]);
|
||||
dot_other += double(tvec[x]) * double(tvec[x]);
|
||||
dot += double(self->vec[x]) * double(tvec[x]);
|
||||
}
|
||||
|
||||
if (!dot_self || !dot_other) {
|
||||
@@ -1273,13 +1273,13 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value)
|
||||
|
||||
/* get dot products */
|
||||
for (x = 0; x < vec_num; x++) {
|
||||
dot += (double)(self->vec[x] * tvec[x]);
|
||||
dot2 += (double)(tvec[x] * tvec[x]);
|
||||
dot += double(self->vec[x] * tvec[x]);
|
||||
dot2 += double(tvec[x] * tvec[x]);
|
||||
}
|
||||
/* projection */
|
||||
dot /= dot2;
|
||||
for (x = 0; x < vec_num; x++) {
|
||||
tvec[x] *= (float)dot;
|
||||
tvec[x] *= float(dot);
|
||||
}
|
||||
return Vector_CreatePyObject_alloc(tvec, vec_num, Py_TYPE(self));
|
||||
}
|
||||
@@ -1395,7 +1395,7 @@ static PyObject *Vector_slerp(VectorObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
/* We have sane state, execute slerp */
|
||||
cosom = (float)dot_vn_vn(self_vec, other_vec, vec_num);
|
||||
cosom = float(dot_vn_vn(self_vec, other_vec, vec_num));
|
||||
|
||||
/* direct opposite, can't slerp */
|
||||
if (UNLIKELY(cosom < (-1.0f + FLT_EPSILON))) {
|
||||
@@ -2081,9 +2081,9 @@ int column_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *vec,
|
||||
for (row = 0; row < mat->row_num; row++) {
|
||||
double dot = 0.0f;
|
||||
for (col = 0; col < mat->col_num; col++) {
|
||||
dot += (double)(MATRIX_ITEM(mat, row, col) * vec_cpy[col]);
|
||||
dot += double(MATRIX_ITEM(mat, row, col) * vec_cpy[col]);
|
||||
}
|
||||
r_vec[z++] = (float)dot;
|
||||
r_vec[z++] = float(dot);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -2694,7 +2694,7 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure
|
||||
}
|
||||
else if ((void)PyErr_Clear(), /* run but ignore the result */
|
||||
(size_from = (size_t)mathutils_array_parse(
|
||||
vec_assign, 2, 4, value, "Vector.**** = swizzle assignment")) == (size_t)-1)
|
||||
vec_assign, 2, 4, value, "Vector.**** = swizzle assignment")) == size_t(-1))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1103,7 +1103,7 @@ struct PointsInPlanes_UserData {
|
||||
|
||||
static void points_in_planes_fn(const float co[3], int i, int j, int k, void *user_data_p)
|
||||
{
|
||||
struct PointsInPlanes_UserData *user_data = static_cast<PointsInPlanes_UserData *>(user_data_p);
|
||||
PointsInPlanes_UserData *user_data = static_cast<PointsInPlanes_UserData *>(user_data_p);
|
||||
PyList_APPEND(user_data->py_verts, Vector_CreatePyObject(co, 3, nullptr));
|
||||
user_data->planes_used[i] = true;
|
||||
user_data->planes_used[j] = true;
|
||||
@@ -1377,8 +1377,8 @@ static int boxPack_FromPyObject(PyObject *value, BoxPack **r_boxarray)
|
||||
item_1 = PyList_GET_ITEM(list_item, 2);
|
||||
item_2 = PyList_GET_ITEM(list_item, 3);
|
||||
|
||||
box->w = (float)PyFloat_AsDouble(item_1);
|
||||
box->h = (float)PyFloat_AsDouble(item_2);
|
||||
box->w = float(PyFloat_AsDouble(item_1));
|
||||
box->h = float(PyFloat_AsDouble(item_2));
|
||||
box->index = i;
|
||||
|
||||
/* accounts for error case too and overwrites with own error */
|
||||
@@ -1656,7 +1656,7 @@ static PyObject *M_Geometry_delaunay_2d_cdt(PyObject * /*self*/, PyObject *args)
|
||||
goto exit_cdt;
|
||||
}
|
||||
|
||||
in.verts_len = (int)vert_coords_len;
|
||||
in.verts_len = int(vert_coords_len);
|
||||
in.vert_coords = in_coords;
|
||||
in.edges_len = edges_len;
|
||||
in.faces_len = faces_len;
|
||||
@@ -1686,8 +1686,8 @@ static PyObject *M_Geometry_delaunay_2d_cdt(PyObject * /*self*/, PyObject *args)
|
||||
out_edges = PyList_New(res->edges_len);
|
||||
for (i = 0; i < res->edges_len; i++) {
|
||||
item = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(item, 0, PyLong_FromLong((long)res->edges[i][0]));
|
||||
PyTuple_SET_ITEM(item, 1, PyLong_FromLong((long)res->edges[i][1]));
|
||||
PyTuple_SET_ITEM(item, 0, PyLong_FromLong(long(res->edges[i][0])));
|
||||
PyTuple_SET_ITEM(item, 1, PyLong_FromLong(long(res->edges[i][1])));
|
||||
PyList_SET_ITEM(out_edges, i, item);
|
||||
}
|
||||
PyTuple_SET_ITEM(ret_value, 1, out_edges);
|
||||
@@ -1844,7 +1844,7 @@ static PyModuleDef M_Geometry_module_def = {
|
||||
|
||||
/*----------------------------MODULE INIT-------------------------*/
|
||||
|
||||
PyMODINIT_FUNC PyInit_mathutils_geometry(void)
|
||||
PyMODINIT_FUNC PyInit_mathutils_geometry()
|
||||
{
|
||||
PyObject *submodule = PyModule_Create(&M_Geometry_module_def);
|
||||
return submodule;
|
||||
|
||||
@@ -104,7 +104,7 @@ static PyModuleDef M_Interpolate_module_def = {
|
||||
|
||||
/*----------------------------MODULE INIT-------------------------*/
|
||||
|
||||
PyMODINIT_FUNC PyInit_mathutils_interpolate(void)
|
||||
PyMODINIT_FUNC PyInit_mathutils_interpolate()
|
||||
{
|
||||
PyObject *submodule = PyModule_Create(&M_Interpolate_module_def);
|
||||
return submodule;
|
||||
|
||||
@@ -171,7 +171,7 @@ static int py_find_nearest_cb(void *user_data, int index, const float co[3], flo
|
||||
{
|
||||
UNUSED_VARS(co, dist_sq);
|
||||
|
||||
struct PyKDTree_NearestData *data = static_cast<PyKDTree_NearestData *>(user_data);
|
||||
PyKDTree_NearestData *data = static_cast<PyKDTree_NearestData *>(user_data);
|
||||
|
||||
PyObject *py_args = PyTuple_New(1);
|
||||
PyTuple_SET_ITEM(py_args, 0, PyLong_FromLong(index));
|
||||
@@ -183,7 +183,7 @@ static int py_find_nearest_cb(void *user_data, int index, const float co[3], flo
|
||||
const int ok = PyC_ParseBool(result, &use_node);
|
||||
Py_DECREF(result);
|
||||
if (ok) {
|
||||
return (int)use_node;
|
||||
return int(use_node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ static PyObject *py_kdtree_find(PyKDTree *self, PyObject *args, PyObject *kwargs
|
||||
BLI_kdtree_3d_find_nearest(self->obj, co, &nearest);
|
||||
}
|
||||
else {
|
||||
struct PyKDTree_NearestData data = {0};
|
||||
PyKDTree_NearestData data = {0};
|
||||
|
||||
data.py_filter = py_filter;
|
||||
data.is_error = false;
|
||||
@@ -441,7 +441,7 @@ static PyModuleDef kdtree_moduledef = {
|
||||
/*m_free*/ nullptr,
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC PyInit_mathutils_kdtree(void)
|
||||
PyMODINIT_FUNC PyInit_mathutils_kdtree()
|
||||
{
|
||||
PyObject *m = PyModule_Create(&kdtree_moduledef);
|
||||
|
||||
|
||||
@@ -81,12 +81,12 @@ static void init_genrand(ulong s)
|
||||
const float range = 32; /* range in both pos/neg direction */
|
||||
for (j = 0; j < ARRAY_SIZE(state_offset_vector); j++, state_offset++) {
|
||||
/* overflow is fine here */
|
||||
state_offset_vector[j] = (float)(int)(*state_offset) * (1.0f / ((float)INT_MAX / range));
|
||||
state_offset_vector[j] = float(int(*state_offset)) * (1.0f / (float(INT_MAX) / range));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void next_state(void)
|
||||
static void next_state()
|
||||
{
|
||||
ulong *p = state;
|
||||
int j;
|
||||
@@ -123,7 +123,7 @@ static void setRndSeed(int seed)
|
||||
}
|
||||
|
||||
/* Float number in range [0, 1) using the mersenne twister random number generator. */
|
||||
static float frand(void)
|
||||
static float frand()
|
||||
{
|
||||
ulong y;
|
||||
|
||||
@@ -138,7 +138,7 @@ static float frand(void)
|
||||
y ^= (y << 15) & 0xefc60000UL;
|
||||
y ^= (y >> 18);
|
||||
|
||||
return (float)y / 4294967296.0f;
|
||||
return float(y) / 4294967296.0f;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------*/
|
||||
@@ -218,7 +218,7 @@ static float turb(
|
||||
float amp, out, t;
|
||||
int i;
|
||||
amp = 1.0f;
|
||||
out = (float)(2.0f * BLI_noise_generic_noise(1.0f, x, y, z, false, nb) - 1.0f);
|
||||
out = float(2.0f * BLI_noise_generic_noise(1.0f, x, y, z, false, nb) - 1.0f);
|
||||
if (hard) {
|
||||
out = fabsf(out);
|
||||
}
|
||||
@@ -227,7 +227,7 @@ static float turb(
|
||||
x *= freqscale;
|
||||
y *= freqscale;
|
||||
z *= freqscale;
|
||||
t = (float)(amp * (2.0f * BLI_noise_generic_noise(1.0f, x, y, z, false, nb) - 1.0f));
|
||||
t = float(amp * (2.0f * BLI_noise_generic_noise(1.0f, x, y, z, false, nb) - 1.0f));
|
||||
if (hard) {
|
||||
t = fabsf(t);
|
||||
}
|
||||
@@ -1112,7 +1112,7 @@ static PyModuleDef M_Noise_module_def = {
|
||||
|
||||
/*----------------------------MODULE INIT-------------------------*/
|
||||
|
||||
PyMODINIT_FUNC PyInit_mathutils_noise(void)
|
||||
PyMODINIT_FUNC PyInit_mathutils_noise()
|
||||
{
|
||||
PyObject *submodule = PyModule_Create(&M_Noise_module_def);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user