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 <campbell@blender.org>2022-09-25 13:27:46 +0300
committerCampbell Barton <campbell@blender.org>2022-09-25 15:31:31 +0300
commit21d77a417e17ac92bfc10dbd742c867d4019ce69 (patch)
treeec664b5c6ca7882bcc5a1e1ce09cad67b842af9d
parentd35a10134cfdbd3e24a56218ef3f05aac2a2fc7e (diff)
Cleanup: replace C-style casts with functional casts for numeric types
Some changes missed from f68cfd6bb078482c4a779a6e26a56e2734edb5b8.
-rw-r--r--intern/ghost/intern/GHOST_DropTargetWin32.cpp2
-rw-r--r--intern/ghost/intern/GHOST_EventPrinter.cpp2
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerUnix.cpp4
-rw-r--r--intern/ghost/intern/GHOST_PathUtils.cpp4
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp2
-rw-r--r--intern/ghost/intern/GHOST_WindowSDL.cpp2
-rw-r--r--intern/ghost/intern/GHOST_Wintab.cpp8
-rw-r--r--intern/ghost/intern/GHOST_XrControllerModel.cpp26
-rw-r--r--intern/ghost/intern/GHOST_XrSession.cpp2
-rw-r--r--intern/ghost/test/gears/GHOST_Test.cpp2
-rw-r--r--intern/libmv/libmv/simple_pipeline/keyframe_selection.cc2
-rw-r--r--intern/libmv/libmv/simple_pipeline/pipeline.cc12
-rw-r--r--source/blender/blendthumb/src/blendthumb_png.cc4
-rw-r--r--source/blender/blendthumb/src/blendthumb_win32.cc4
-rw-r--r--source/blender/blenkernel/intern/curveprofile.cc14
-rw-r--r--source/blender/blenkernel/intern/customdata.cc22
-rw-r--r--source/blender/blenkernel/intern/mesh_mapping.cc26
-rw-r--r--source/blender/blenkernel/intern/mesh_normals.cc12
-rw-r--r--source/blender/blenkernel/intern/object_dupli.cc2
-rw-r--r--source/blender/blenkernel/intern/scene.cc4
-rw-r--r--source/blender/blenloader/intern/undofile.cc12
-rw-r--r--source/blender/blenloader/intern/writefile.cc14
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.cc2
-rw-r--r--source/blender/editors/interface/interface.cc4
-rw-r--r--source/blender/editors/interface/view2d_ops.cc4
-rw-r--r--source/blender/editors/object/object_transform.cc2
-rw-r--r--source/blender/editors/space_file/filelist.cc4
-rw-r--r--source/blender/editors/uvedit/uvedit_islands.cc4
-rw-r--r--source/blender/geometry/intern/mesh_merge_by_distance.cc8
-rw-r--r--source/blender/geometry/intern/uv_parametrizer.cc34
-rw-r--r--source/blender/gpu/intern/gpu_matrix.cc2
-rw-r--r--source/blender/gpu/intern/gpu_vertex_buffer.cc2
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp6
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp16
-rw-r--r--source/blender/io/collada/MeshImporter.cpp12
-rw-r--r--source/blender/makesrna/intern/rna_path.cc4
-rw-r--r--source/blender/python/gpu/gpu_py_shader_create_info.cc6
-rw-r--r--source/blender/simulation/intern/SIM_mass_spring.cpp8
-rw-r--r--source/blender/simulation/intern/hair_volume.cpp22
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.cc2
40 files changed, 162 insertions, 162 deletions
diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.cpp b/intern/ghost/intern/GHOST_DropTargetWin32.cpp
index 2831f2ee8ad..a38af619662 100644
--- a/intern/ghost/intern/GHOST_DropTargetWin32.cpp
+++ b/intern/ghost/intern/GHOST_DropTargetWin32.cpp
@@ -341,7 +341,7 @@ void printLastError(void)
(LPTSTR)&s,
0,
NULL)) {
- printf("\nLastError: (%d) %s\n", (int)err, s);
+ printf("\nLastError: (%d) %s\n", int(err), s);
LocalFree(s);
}
}
diff --git a/intern/ghost/intern/GHOST_EventPrinter.cpp b/intern/ghost/intern/GHOST_EventPrinter.cpp
index 7c20cd701b0..0d7f05009ff 100644
--- a/intern/ghost/intern/GHOST_EventPrinter.cpp
+++ b/intern/ghost/intern/GHOST_EventPrinter.cpp
@@ -161,7 +161,7 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event)
void GHOST_EventPrinter::getKeyString(GHOST_TKey key, char str[32]) const
{
if ((key >= GHOST_kKeyComma) && (key <= GHOST_kKeyRightBracket)) {
- sprintf(str, "%c", (char)key);
+ sprintf(str, "%c", char(key));
}
else if ((key >= GHOST_kKeyNumpad0) && (key <= GHOST_kKeyNumpad9)) {
sprintf(str, "Numpad %d", (key - GHOST_kKeyNumpad0));
diff --git a/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp b/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp
index 7770f5f39ce..6cf9aa1ed04 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp
@@ -86,8 +86,8 @@ bool GHOST_NDOFManagerUnix::processEvents()
case SPNAV_EVENT_MOTION: {
/* convert to blender view coords */
uint64_t now = m_system.getMilliSeconds();
- const int t[3] = {(int)e.motion.x, (int)e.motion.y, (int)-e.motion.z};
- const int r[3] = {(int)-e.motion.rx, (int)-e.motion.ry, (int)e.motion.rz};
+ const int t[3] = {int(e.motion.x), int(e.motion.y), int(-e.motion.z)};
+ const int r[3] = {int(-e.motion.rx), int(-e.motion.ry), int(e.motion.rz)};
updateTranslation(t, now);
updateRotation(r, now);
diff --git a/intern/ghost/intern/GHOST_PathUtils.cpp b/intern/ghost/intern/GHOST_PathUtils.cpp
index 3b57480039a..bcccd369460 100644
--- a/intern/ghost/intern/GHOST_PathUtils.cpp
+++ b/intern/ghost/intern/GHOST_PathUtils.cpp
@@ -37,7 +37,7 @@ void GHOST_URL_decode(char *buf_dst, int buf_dst_size, const char *buf_src)
case STATE_SEARCH: {
if (buf_src[i] != '%') {
strncat(buf_dst, &buf_src[i], 1);
- assert((int)strlen(buf_dst) < buf_dst_size);
+ assert(int(strlen(buf_dst)) < buf_dst_size);
break;
}
@@ -71,7 +71,7 @@ void GHOST_URL_decode(char *buf_dst, int buf_dst_size, const char *buf_src)
sscanf(temp_num_buf, "%x", &ascii_character);
/* Ensure we aren't going to overflow. */
- assert((int)strlen(buf_dst) < buf_dst_size);
+ assert(int(strlen(buf_dst)) < buf_dst_size);
/* Concatenate this character onto the output. */
strncat(buf_dst, (char *)&ascii_character, 1);
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index a383710256a..5c1ac157980 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -2470,7 +2470,7 @@ GHOST_TSuccess GHOST_SystemX11::showMessageBox(const char *title,
dialog_data.padding_x,
dialog_data.padding_x + (i + 1) * dialog_data.line_height,
text_splitted[i],
- (int)strlen(text_splitted[i]));
+ int(strlen(text_splitted[i])));
}
dialog_data.drawButton(m_display, window, buttonBorderGC, buttonGC, 1, continue_label);
if (strlen(link)) {
diff --git a/intern/ghost/intern/GHOST_WindowSDL.cpp b/intern/ghost/intern/GHOST_WindowSDL.cpp
index 64642abc2af..6866f01736f 100644
--- a/intern/ghost/intern/GHOST_WindowSDL.cpp
+++ b/intern/ghost/intern/GHOST_WindowSDL.cpp
@@ -551,7 +551,7 @@ static SDL_Cursor *getStandardCursorShape(GHOST_TStandardCursor shape)
sdl_std_cursor_HEIGHT_##name, \
(sdl_std_cursor_WIDTH_##name + (sdl_std_cursor_HOT_X_##name)) - 1, \
(sdl_std_cursor_HEIGHT_##name + (sdl_std_cursor_HOT_Y_##name)) - 1); \
- assert(sdl_std_cursor_array[(int)ind] != nullptr); \
+ assert(sdl_std_cursor_array[int(ind)] != nullptr); \
} \
(void)0
diff --git a/intern/ghost/intern/GHOST_Wintab.cpp b/intern/ghost/intern/GHOST_Wintab.cpp
index c75a39bb34b..edc5f18af4d 100644
--- a/intern/ghost/intern/GHOST_Wintab.cpp
+++ b/intern/ghost/intern/GHOST_Wintab.cpp
@@ -331,7 +331,7 @@ void GHOST_Wintab::getInput(std::vector<GHOST_WintabInfoWin32> &outWintabInfo)
out.y = pkt.pkY;
if (m_maxPressure > 0) {
- out.tabletData.Pressure = (float)pkt.pkNormalPressure / (float)m_maxPressure;
+ out.tabletData.Pressure = float(pkt.pkNormalPressure) / float(m_maxPressure);
}
if ((m_maxAzimuth > 0) && (m_maxAltitude > 0)) {
@@ -351,15 +351,15 @@ void GHOST_Wintab::getInput(std::vector<GHOST_WintabInfoWin32> &outWintabInfo)
ORIENTATION ort = pkt.pkOrientation;
/* Convert raw fixed point data to radians. */
- float altRad = (float)((fabs((float)ort.orAltitude) / (float)m_maxAltitude) * M_PI_2);
- float azmRad = (float)(((float)ort.orAzimuth / (float)m_maxAzimuth) * M_PI * 2.0);
+ float altRad = float((fabs(float(ort.orAltitude)) / float(m_maxAltitude)) * M_PI_2);
+ float azmRad = float((float(ort.orAzimuth) / float(m_maxAzimuth)) * M_PI * 2.0);
/* Find length of the stylus' projected vector on the XY plane. */
float vecLen = cos(altRad);
/* From there calculate X and Y components based on azimuth. */
out.tabletData.Xtilt = sin(azmRad) * vecLen;
- out.tabletData.Ytilt = (float)(sin(M_PI_2 - azmRad) * vecLen);
+ out.tabletData.Ytilt = float(sin(M_PI_2 - azmRad) * vecLen);
}
out.time = pkt.pkTime;
diff --git a/intern/ghost/intern/GHOST_XrControllerModel.cpp b/intern/ghost/intern/GHOST_XrControllerModel.cpp
index 5be3a8e70ad..dc77f6e8976 100644
--- a/intern/ghost/intern/GHOST_XrControllerModel.cpp
+++ b/intern/ghost/intern/GHOST_XrControllerModel.cpp
@@ -230,10 +230,10 @@ static void calc_node_transforms(const tinygltf::Node &gltf_node,
* both. */
if (gltf_node.matrix.size() == 16) {
const std::vector<double> &dm = gltf_node.matrix;
- float m[4][4] = {{(float)dm[0], (float)dm[1], (float)dm[2], (float)dm[3]},
- {(float)dm[4], (float)dm[5], (float)dm[6], (float)dm[7]},
- {(float)dm[8], (float)dm[9], (float)dm[10], (float)dm[11]},
- {(float)dm[12], (float)dm[13], (float)dm[14], (float)dm[15]}};
+ float m[4][4] = {{float(dm[0]), float(dm[1]), float(dm[2]), float(dm[3])},
+ {float(dm[4]), float(dm[5]), float(dm[6]), float(dm[7])},
+ {float(dm[8]), float(dm[9]), float(dm[10]), float(dm[11])},
+ {float(dm[12]), float(dm[13]), float(dm[14]), float(dm[15])}};
memcpy(r_local_transform, m, sizeof(float[4][4]));
}
else {
@@ -259,21 +259,21 @@ static void calc_node_transforms(const tinygltf::Node &gltf_node,
scale[0] = scale[1] = scale[2] = 1.0;
}
- q.w() = (float)rotation[3];
- q.x() = (float)rotation[0];
- q.y() = (float)rotation[1];
- q.z() = (float)rotation[2];
+ q.w() = float(rotation[3]);
+ q.x() = float(rotation[0]);
+ q.y() = float(rotation[1]);
+ q.z() = float(rotation[2]);
q.normalize();
scalemat.setIdentity();
- scalemat(0, 0) = (float)scale[0];
- scalemat(1, 1) = (float)scale[1];
- scalemat(2, 2) = (float)scale[2];
+ scalemat(0, 0) = float(scale[0]);
+ scalemat(1, 1) = float(scale[1]);
+ scalemat(2, 2) = float(scale[2]);
m.setIdentity();
m.block<3, 3>(0, 0) = q.toRotationMatrix() * scalemat;
m.block<3, 1>(0, 3) = Eigen::Vector3f(
- (float)translation[0], (float)translation[1], (float)translation[2]);
+ float(translation[0]), float(translation[1]), float(translation[2]));
}
*(Eigen::Matrix4f *)r_world_transform = *(Eigen::Matrix4f *)parent_transform *
@@ -450,7 +450,7 @@ void GHOST_XrControllerModel::loadControllerModel(XrSession session)
CHECK_XR(g_xrLoadControllerModelMSFT(session, m_model_key, 0, &buf_size, nullptr),
"Failed to get controller model buffer size.");
- std::vector<uint8_t> buf((size_t)buf_size);
+ std::vector<uint8_t> buf((size_t(buf_size)));
CHECK_XR(g_xrLoadControllerModelMSFT(session, m_model_key, buf_size, &buf_size, buf.data()),
"Failed to load controller model binary buffers.");
diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp
index 1966a4e77da..0031c1f1278 100644
--- a/intern/ghost/intern/GHOST_XrSession.cpp
+++ b/intern/ghost/intern/GHOST_XrSession.cpp
@@ -484,7 +484,7 @@ void GHOST_XrSession::drawView(GHOST_XrSwapchain &swapchain,
swapchain.updateCompositionLayerProjectViewSubImage(r_proj_layer_view.subImage);
assert(view_idx < 256);
- draw_view_info.view_idx = (char)view_idx;
+ draw_view_info.view_idx = char(view_idx);
draw_view_info.swapchain_format = swapchain.getFormat();
draw_view_info.expects_srgb_buffer = swapchain.isBufferSRGB();
draw_view_info.ofsx = r_proj_layer_view.subImage.imageRect.offset.x;
diff --git a/intern/ghost/test/gears/GHOST_Test.cpp b/intern/ghost/test/gears/GHOST_Test.cpp
index f5ef2527d75..1891f1eca77 100644
--- a/intern/ghost/test/gears/GHOST_Test.cpp
+++ b/intern/ghost/test/gears/GHOST_Test.cpp
@@ -57,7 +57,7 @@ void StereoProjection(float left,
static void testTimerProc(GHOST_ITimerTask * /*task*/, uint64_t time)
{
- std::cout << "timer1, time=" << (int)time << "\n";
+ std::cout << "timer1, time=" << int(time) << "\n";
}
static void gearGL(
diff --git a/intern/libmv/libmv/simple_pipeline/keyframe_selection.cc b/intern/libmv/libmv/simple_pipeline/keyframe_selection.cc
index 5526d730651..e3e59171b63 100644
--- a/intern/libmv/libmv/simple_pipeline/keyframe_selection.cc
+++ b/intern/libmv/libmv/simple_pipeline/keyframe_selection.cc
@@ -333,7 +333,7 @@ void SelectKeyframesBasedOnGRICAndVariance(const Tracks& _tracks,
}
double success_intersects_factor =
- (double)intersects_success / intersects_total;
+ double(intersects_success) / intersects_total;
if (success_intersects_factor < success_intersects_factor_best) {
LG << "Skip keyframe candidate because of "
diff --git a/intern/libmv/libmv/simple_pipeline/pipeline.cc b/intern/libmv/libmv/simple_pipeline/pipeline.cc
index 5d52aeb7406..7203ddf1329 100644
--- a/intern/libmv/libmv/simple_pipeline/pipeline.cc
+++ b/intern/libmv/libmv/simple_pipeline/pipeline.cc
@@ -180,7 +180,7 @@ void InternalCompleteReconstruction(
<< " reconstructed markers for track " << track;
if (reconstructed_markers.size() >= 2) {
CompleteReconstructionLogProgress(update_callback,
- (double)tot_resects / (max_image));
+ double(tot_resects) / (max_image));
if (PipelineRoutines::Intersect(reconstructed_markers,
reconstruction)) {
num_intersects++;
@@ -192,7 +192,7 @@ void InternalCompleteReconstruction(
}
if (num_intersects) {
CompleteReconstructionLogProgress(
- update_callback, (double)tot_resects / (max_image), "Bundling...");
+ update_callback, double(tot_resects) / (max_image), "Bundling...");
PipelineRoutines::Bundle(tracks, reconstruction);
LG << "Ran Bundle() after intersections.";
}
@@ -218,7 +218,7 @@ void InternalCompleteReconstruction(
<< " reconstructed markers for image " << image;
if (reconstructed_markers.size() >= 5) {
CompleteReconstructionLogProgress(update_callback,
- (double)tot_resects / (max_image));
+ double(tot_resects) / (max_image));
if (PipelineRoutines::Resect(
reconstructed_markers, reconstruction, false)) {
num_resects++;
@@ -231,7 +231,7 @@ void InternalCompleteReconstruction(
}
if (num_resects) {
CompleteReconstructionLogProgress(
- update_callback, (double)tot_resects / (max_image), "Bundling...");
+ update_callback, double(tot_resects) / (max_image), "Bundling...");
PipelineRoutines::Bundle(tracks, reconstruction);
}
LG << "Did " << num_resects << " resects.";
@@ -254,7 +254,7 @@ void InternalCompleteReconstruction(
}
if (reconstructed_markers.size() >= 5) {
CompleteReconstructionLogProgress(update_callback,
- (double)tot_resects / (max_image));
+ double(tot_resects) / (max_image));
if (PipelineRoutines::Resect(
reconstructed_markers, reconstruction, true)) {
num_resects++;
@@ -266,7 +266,7 @@ void InternalCompleteReconstruction(
}
if (num_resects) {
CompleteReconstructionLogProgress(
- update_callback, (double)tot_resects / (max_image), "Bundling...");
+ update_callback, double(tot_resects) / (max_image), "Bundling...");
PipelineRoutines::Bundle(tracks, reconstruction);
}
}
diff --git a/source/blender/blendthumb/src/blendthumb_png.cc b/source/blender/blendthumb/src/blendthumb_png.cc
index e3e3e929e63..17c0492af42 100644
--- a/source/blender/blendthumb/src/blendthumb_png.cc
+++ b/source/blender/blendthumb/src/blendthumb_png.cc
@@ -110,7 +110,7 @@ std::optional<blender::Vector<uint8_t>> blendthumb_create_png_data_from_thumb(
0x00, /* Filter method. */
0x00, /* Interlace method. */
});
- BLI_assert((size_t)ihdr_data.size() == ihdr_data_final_size);
+ BLI_assert(size_t(ihdr_data.size()) == ihdr_data_final_size);
}
/* Join it all together to create a PNG image. */
@@ -135,7 +135,7 @@ std::optional<blender::Vector<uint8_t>> blendthumb_create_png_data_from_thumb(
png_chunk_create(png_buf, MAKE_ID('I', 'D', 'A', 'T'), image_data);
png_chunk_create(png_buf, MAKE_ID('I', 'E', 'N', 'D'), {});
- BLI_assert((size_t)png_buf.size() == png_buf_final_size);
+ BLI_assert(size_t(png_buf.size()) == png_buf_final_size);
}
return png_buf;
diff --git a/source/blender/blendthumb/src/blendthumb_win32.cc b/source/blender/blendthumb/src/blendthumb_win32.cc
index 2acc8f20a12..4ba91955bd3 100644
--- a/source/blender/blendthumb/src/blendthumb_win32.cc
+++ b/source/blender/blendthumb/src/blendthumb_win32.cc
@@ -110,7 +110,7 @@ static ssize_t stream_read(FileReader *reader, void *buffer, size_t size)
stream->_pStream->Read(buffer, size, &readsize);
stream->reader.offset += readsize;
- return (ssize_t)readsize;
+ return ssize_t(readsize);
}
static off64_t stream_seek(FileReader *reader, off64_t offset, int whence)
@@ -173,7 +173,7 @@ IFACEMETHODIMP CBlendThumb::GetThumbnail(UINT cx, HBITMAP *phbmp, WTS_ALPHATYPE
/* Scale up the thumbnail if required. */
if ((unsigned)thumb.width < cx && (unsigned)thumb.height < cx) {
- float scale = 1.0f / (std::max(thumb.width, thumb.height) / (float)cx);
+ float scale = 1.0f / (std::max(thumb.width, thumb.height) / float(cx));
LONG NewWidth = (LONG)(thumb.width * scale);
LONG NewHeight = (LONG)(thumb.height * scale);
diff --git a/source/blender/blenkernel/intern/curveprofile.cc b/source/blender/blenkernel/intern/curveprofile.cc
index 5cff804cb18..db0cf16d467 100644
--- a/source/blender/blenkernel/intern/curveprofile.cc
+++ b/source/blender/blenkernel/intern/curveprofile.cc
@@ -1048,13 +1048,13 @@ void BKE_curveprofile_evaluate_length_portion(const CurveProfile *profile,
#ifdef DEBUG_CURVEPROFILE_EVALUATE
printf("CURVEPROFILE EVALUATE\n");
- printf(" length portion input: %f\n", (double)length_portion);
- printf(" requested path length: %f\n", (double)requested_length);
- printf(" distance to next point: %f\n", (double)distance_to_next_point);
- printf(" length travelled: %f\n", (double)length_travelled);
- printf(" lerp-factor: %f\n", (double)lerp_factor);
- printf(" ith point (%f, %f)\n", (double)profile->path[i].x, (double)profile->path[i].y);
- printf(" next point(%f, %f)\n", (double)profile->path[i + 1].x, (double)profile->path[i + 1].y);
+ printf(" length portion input: %f\n", double(length_portion));
+ printf(" requested path length: %f\n", double(requested_length));
+ printf(" distance to next point: %f\n", double(distance_to_next_point));
+ printf(" length travelled: %f\n", double(length_travelled));
+ printf(" lerp-factor: %f\n", double(lerp_factor));
+ printf(" ith point (%f, %f)\n", double(profile->path[i].x), double(profile->path[i].y));
+ printf(" next point(%f, %f)\n", double(profile->path[i + 1].x), double(profile->path[i + 1].y));
#endif
*x_out = interpf(profile->table[i].x, profile->table[i + 1].x, lerp_factor);
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index 0968f9a8a01..3acd7bb0c80 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -4278,7 +4278,7 @@ void CustomData_bmesh_interp(CustomData *data,
float *default_weights = nullptr;
if (weights == nullptr) {
default_weights = (count > SOURCE_BUF_SIZE) ?
- (float *)MEM_mallocN(sizeof(*weights) * (size_t)count, __func__) :
+ (float *)MEM_mallocN(sizeof(*weights) * size_t(count), __func__) :
default_weights_buf;
copy_vn_fl(default_weights, count, 1.0f / count);
weights = default_weights;
@@ -4341,7 +4341,7 @@ void CustomData_to_bmesh_block(const CustomData *source,
void *dest_data = POINTER_OFFSET(*dest_block, offset);
const LayerTypeInfo *typeInfo = layerType_getInfo(dest->layers[dest_i].type);
- const size_t src_offset = (size_t)src_index * typeInfo->size;
+ const size_t src_offset = size_t(src_index) * typeInfo->size;
if (typeInfo->copy) {
typeInfo->copy(POINTER_OFFSET(src_data, src_offset), dest_data, 1);
@@ -4393,7 +4393,7 @@ void CustomData_from_bmesh_block(const CustomData *source,
int offset = source->layers[src_i].offset;
const void *src_data = POINTER_OFFSET(src_block, offset);
void *dst_data = POINTER_OFFSET(dest->layers[dest_i].data,
- (size_t)dest_index * typeInfo->size);
+ size_t(dest_index) * typeInfo->size);
if (typeInfo->copy) {
typeInfo->copy(src_data, dst_data, 1);
@@ -4998,13 +4998,13 @@ static bool check_bit_flag(const void *data, const size_t data_size, const uint6
{
switch (data_size) {
case 1:
- return ((*((uint8_t *)data) & ((uint8_t)flag)) != 0);
+ return ((*((uint8_t *)data) & uint8_t(flag)) != 0);
case 2:
- return ((*((uint16_t *)data) & ((uint16_t)flag)) != 0);
+ return ((*((uint16_t *)data) & uint16_t(flag)) != 0);
case 4:
- return ((*((uint32_t *)data) & ((uint32_t)flag)) != 0);
+ return ((*((uint32_t *)data) & uint32_t(flag)) != 0);
case 8:
- return ((*((uint64_t *)data) & ((uint64_t)flag)) != 0);
+ return ((*((uint64_t *)data) & uint64_t(flag)) != 0);
default:
// CLOG_ERROR(&LOG, "Unknown flags-container size (%zu)", datasize);
return false;
@@ -5047,7 +5047,7 @@ static void customdata_data_transfer_interp_generic(const CustomDataTransferLaye
else {
const LayerTypeInfo *type_info = layerType_getInfo(data_type);
- data_size = (size_t)type_info->size;
+ data_size = size_t(type_info->size);
interp_cd = type_info->interp;
copy_cd = type_info->copy;
}
@@ -5200,7 +5200,7 @@ void CustomData_data_transfer(const MeshPairRemap *me_remap,
const LayerTypeInfo *type_info = layerType_getInfo(data_type);
/* NOTE: we can use 'fake' CDLayers for crease :/. */
- data_size = (size_t)type_info->size;
+ data_size = size_t(type_info->size);
data_step = laymap->elem_size ? laymap->elem_size : data_size;
data_offset = laymap->data_offset;
}
@@ -5219,13 +5219,13 @@ void CustomData_data_transfer(const MeshPairRemap *me_remap,
if (tmp_data_src) {
if (UNLIKELY(sources_num > tmp_buff_size)) {
- tmp_buff_size = (size_t)sources_num;
+ tmp_buff_size = size_t(sources_num);
tmp_data_src = (const void **)MEM_reallocN((void *)tmp_data_src,
sizeof(*tmp_data_src) * tmp_buff_size);
}
for (int j = 0; j < sources_num; j++) {
- const size_t src_idx = (size_t)mapit->indices_src[j];
+ const size_t src_idx = size_t(mapit->indices_src[j]);
tmp_data_src[j] = POINTER_OFFSET(data_src, (data_step * src_idx) + data_offset);
}
}
diff --git a/source/blender/blenkernel/intern/mesh_mapping.cc b/source/blender/blenkernel/intern/mesh_mapping.cc
index bd3902298b2..2db0adce033 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.cc
+++ b/source/blender/blenkernel/intern/mesh_mapping.cc
@@ -623,8 +623,8 @@ static void poly_edge_loop_islands_calc(const MEdge *medge,
&edge_poly_map, &edge_poly_mem, medge, totedge, mpoly, totpoly, mloop, totloop);
}
- poly_groups = static_cast<int *>(MEM_callocN(sizeof(int) * (size_t)totpoly, __func__));
- poly_stack = static_cast<int *>(MEM_mallocN(sizeof(int) * (size_t)totpoly, __func__));
+ poly_groups = static_cast<int *>(MEM_callocN(sizeof(int) * size_t(totpoly), __func__));
+ poly_stack = static_cast<int *>(MEM_mallocN(sizeof(int) * size_t(totpoly), __func__));
while (true) {
int poly;
@@ -838,7 +838,7 @@ void BKE_mesh_loop_islands_init(MeshIslandStore *island_store,
island_store->item_type = item_type;
island_store->items_to_islands_num = items_num;
island_store->items_to_islands = static_cast<int *>(
- BLI_memarena_alloc(mem, sizeof(*island_store->items_to_islands) * (size_t)items_num));
+ BLI_memarena_alloc(mem, sizeof(*island_store->items_to_islands) * size_t(items_num)));
island_store->island_type = island_type;
island_store->islands_num_alloc = MISLAND_DEFAULT_BUFSIZE;
@@ -890,7 +890,7 @@ void BKE_mesh_loop_islands_add(MeshIslandStore *island_store,
MeshElemMap *isld, *innrcut;
const int curr_island_idx = island_store->islands_num++;
- const size_t curr_num_islands = (size_t)island_store->islands_num;
+ const size_t curr_num_islands = size_t(island_store->islands_num);
int i = item_num;
while (i--) {
@@ -916,17 +916,17 @@ void BKE_mesh_loop_islands_add(MeshIslandStore *island_store,
BLI_memarena_alloc(mem, sizeof(*isld)));
isld->count = num_island_items;
isld->indices = static_cast<int *>(
- BLI_memarena_alloc(mem, sizeof(*isld->indices) * (size_t)num_island_items));
- memcpy(isld->indices, island_item_indices, sizeof(*isld->indices) * (size_t)num_island_items);
+ BLI_memarena_alloc(mem, sizeof(*isld->indices) * size_t(num_island_items)));
+ memcpy(isld->indices, island_item_indices, sizeof(*isld->indices) * size_t(num_island_items));
island_store->innercuts[curr_island_idx] = innrcut = static_cast<MeshElemMap *>(
BLI_memarena_alloc(mem, sizeof(*innrcut)));
innrcut->count = num_innercut_items;
innrcut->indices = static_cast<int *>(
- BLI_memarena_alloc(mem, sizeof(*innrcut->indices) * (size_t)num_innercut_items));
+ BLI_memarena_alloc(mem, sizeof(*innrcut->indices) * size_t(num_innercut_items)));
memcpy(innrcut->indices,
innercut_item_indices,
- sizeof(*innrcut->indices) * (size_t)num_innercut_items);
+ sizeof(*innrcut->indices) * size_t(num_innercut_items));
}
/* TODO: I'm not sure edge seam flag is enough to define UV islands?
@@ -1066,22 +1066,22 @@ static bool mesh_calc_islands_loop_poly_uv(const MVert *UNUSED(verts),
if (num_edge_borders) {
edge_border_count = static_cast<char *>(
- MEM_mallocN(sizeof(*edge_border_count) * (size_t)totedge, __func__));
+ MEM_mallocN(sizeof(*edge_border_count) * size_t(totedge), __func__));
edge_innercut_indices = static_cast<int *>(
- MEM_mallocN(sizeof(*edge_innercut_indices) * (size_t)num_edge_borders, __func__));
+ MEM_mallocN(sizeof(*edge_innercut_indices) * size_t(num_edge_borders), __func__));
}
poly_indices = static_cast<int *>(
- MEM_mallocN(sizeof(*poly_indices) * (size_t)totpoly, __func__));
+ MEM_mallocN(sizeof(*poly_indices) * size_t(totpoly), __func__));
loop_indices = static_cast<int *>(
- MEM_mallocN(sizeof(*loop_indices) * (size_t)totloop, __func__));
+ MEM_mallocN(sizeof(*loop_indices) * size_t(totloop), __func__));
/* NOTE: here we ignore '0' invalid group - this should *never* happen in this case anyway? */
for (grp_idx = 1; grp_idx <= num_poly_groups; grp_idx++) {
num_pidx = num_lidx = 0;
if (num_edge_borders) {
num_einnercuts = 0;
- memset(edge_border_count, 0, sizeof(*edge_border_count) * (size_t)totedge);
+ memset(edge_border_count, 0, sizeof(*edge_border_count) * size_t(totedge));
}
for (p_idx = 0; p_idx < totpoly; p_idx++) {
diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc
index 3eeebc8485a..450c6f36568 100644
--- a/source/blender/blenkernel/intern/mesh_normals.cc
+++ b/source/blender/blenkernel/intern/mesh_normals.cc
@@ -1670,12 +1670,12 @@ void BKE_mesh_normals_loop_split(const MVert *mverts,
* to retrieve the real value later in code).
* Note also that loose edges always have both values set to 0! */
int(*edge_to_loops)[2] = (int(*)[2])MEM_calloc_arrayN(
- (size_t)numEdges, sizeof(*edge_to_loops), __func__);
+ size_t(numEdges), sizeof(*edge_to_loops), __func__);
/* Simple mapping from a loop to its polygon index. */
int *loop_to_poly = r_loop_to_poly ? r_loop_to_poly :
(int *)MEM_malloc_arrayN(
- (size_t)numLoops, sizeof(*loop_to_poly), __func__);
+ size_t(numLoops), sizeof(*loop_to_poly), __func__);
/* When using custom loop normals, disable the angle feature! */
const bool check_angle = (split_angle < (float)M_PI) && (clnors_data == nullptr);
@@ -1779,8 +1779,8 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
* So better to keep some simplicity here, and just call #BKE_mesh_normals_loop_split() twice! */
MLoopNorSpaceArray lnors_spacearr = {nullptr};
BitVector<> done_loops(numLoops, false);
- float(*lnors)[3] = (float(*)[3])MEM_calloc_arrayN((size_t)numLoops, sizeof(*lnors), __func__);
- int *loop_to_poly = (int *)MEM_malloc_arrayN((size_t)numLoops, sizeof(int), __func__);
+ float(*lnors)[3] = (float(*)[3])MEM_calloc_arrayN(size_t(numLoops), sizeof(*lnors), __func__);
+ int *loop_to_poly = (int *)MEM_malloc_arrayN(size_t(numLoops), sizeof(int), __func__);
/* In this case we always consider split nors as ON,
* and do not want to use angle to define smooth fans! */
const bool use_split_normals = true;
@@ -2056,7 +2056,7 @@ static void mesh_set_custom_normals(Mesh *mesh, float (*r_custom_nors)[3], const
clnors = (short(*)[2])CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL);
if (clnors != nullptr) {
- memset(clnors, 0, sizeof(*clnors) * (size_t)numloops);
+ memset(clnors, 0, sizeof(*clnors) * size_t(numloops));
}
else {
clnors = (short(*)[2])CustomData_add_layer(
@@ -2099,7 +2099,7 @@ void BKE_mesh_normals_loop_to_vertex(const int numVerts,
float (*r_vert_clnors)[3])
{
int *vert_loops_count = (int *)MEM_calloc_arrayN(
- (size_t)numVerts, sizeof(*vert_loops_count), __func__);
+ size_t(numVerts), sizeof(*vert_loops_count), __func__);
copy_vn_fl((float *)r_vert_clnors, 3 * numVerts, 0.0f);
diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc
index 4d9b4baaffc..e28aaabb4e1 100644
--- a/source/blender/blenkernel/intern/object_dupli.cc
+++ b/source/blender/blenkernel/intern/object_dupli.cc
@@ -1326,7 +1326,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END;
}
- oblist = (Object **)MEM_callocN((size_t)totcollection * sizeof(Object *),
+ oblist = (Object **)MEM_callocN(size_t(totcollection) * sizeof(Object *),
"dupcollection object list");
if (use_collection_count) {
diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc
index bc2235f9205..7959ab845e8 100644
--- a/source/blender/blenkernel/intern/scene.cc
+++ b/source/blender/blenkernel/intern/scene.cc
@@ -2425,7 +2425,7 @@ float BKE_scene_frame_get(const Scene *scene)
void BKE_scene_frame_set(Scene *scene, float frame)
{
double intpart;
- scene->r.subframe = modf((double)frame, &intpart);
+ scene->r.subframe = modf(double(frame), &intpart);
scene->r.cfra = int(intpart);
}
@@ -2997,7 +2997,7 @@ double BKE_scene_unit_scale(const UnitSettings *unit, const int unit_type, doubl
case B_UNIT_LENGTH:
case B_UNIT_VELOCITY:
case B_UNIT_ACCELERATION:
- return value * (double)unit->scale_length;
+ return value * double(unit->scale_length);
case B_UNIT_AREA:
case B_UNIT_POWER:
return value * pow(unit->scale_length, 2);
diff --git a/source/blender/blenloader/intern/undofile.cc b/source/blender/blenloader/intern/undofile.cc
index 4c417c41297..99d1ca336fe 100644
--- a/source/blender/blenloader/intern/undofile.cc
+++ b/source/blender/blenloader/intern/undofile.cc
@@ -233,9 +233,9 @@ bool BLO_memfile_write_file(struct MemFile *memfile, const char *filepath)
for (chunk = static_cast<MemFileChunk *>(memfile->chunks.first); chunk;
chunk = static_cast<MemFileChunk *>(chunk->next)) {
#ifdef _WIN32
- if ((size_t)write(file, chunk->buf, uint(chunk->size)) != chunk->size)
+ if (size_t(write(file, chunk->buf, uint(chunk->size))) != chunk->size)
#else
- if ((size_t)write(file, chunk->buf, chunk->size) != chunk->size)
+ if (size_t(write(file, chunk->buf, chunk->size)) != chunk->size)
#endif
{
break;
@@ -269,19 +269,19 @@ static ssize_t undo_read(FileReader *reader, void *buffer, size_t size)
return 0;
}
- if (seek != (size_t)undo->reader.offset) {
+ if (seek != size_t(undo->reader.offset)) {
chunk = static_cast<MemFileChunk *>(undo->memfile->chunks.first);
seek = 0;
while (chunk) {
- if (seek + chunk->size > (size_t)undo->reader.offset) {
+ if (seek + chunk->size > size_t(undo->reader.offset)) {
break;
}
seek += chunk->size;
chunk = static_cast<MemFileChunk *>(chunk->next);
}
offset = seek;
- seek = (size_t)undo->reader.offset;
+ seek = size_t(undo->reader.offset);
}
if (chunk) {
@@ -323,7 +323,7 @@ static ssize_t undo_read(FileReader *reader, void *buffer, size_t size)
chunk->is_identical_future;
} while (totread < size);
- return (ssize_t)totread;
+ return ssize_t(totread);
}
return 0;
diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc
index 757bce97bf1..cff17bf186d 100644
--- a/source/blender/blenloader/intern/writefile.cc
+++ b/source/blender/blenloader/intern/writefile.cc
@@ -1256,7 +1256,7 @@ static bool write_file_handle(Main *mainvar,
*
* Note that we *borrow* the pointer to 'DNAstr',
* so writing each time uses the same address and doesn't cause unnecessary undo overhead. */
- writedata(wd, DNA1, (size_t)wd->sdna->data_len, wd->sdna->data);
+ writedata(wd, DNA1, size_t(wd->sdna->data_len), wd->sdna->data);
/* end of file */
memset(&bhead, 0, sizeof(BHead));
@@ -1575,32 +1575,32 @@ int BLO_get_struct_id_by_name(BlendWriter *writer, const char *struct_name)
void BLO_write_int32_array(BlendWriter *writer, uint num, const int32_t *data_ptr)
{
- BLO_write_raw(writer, sizeof(int32_t) * (size_t)num, data_ptr);
+ BLO_write_raw(writer, sizeof(int32_t) * size_t(num), data_ptr);
}
void BLO_write_uint32_array(BlendWriter *writer, uint num, const uint32_t *data_ptr)
{
- BLO_write_raw(writer, sizeof(uint32_t) * (size_t)num, data_ptr);
+ BLO_write_raw(writer, sizeof(uint32_t) * size_t(num), data_ptr);
}
void BLO_write_float_array(BlendWriter *writer, uint num, const float *data_ptr)
{
- BLO_write_raw(writer, sizeof(float) * (size_t)num, data_ptr);
+ BLO_write_raw(writer, sizeof(float) * size_t(num), data_ptr);
}
void BLO_write_double_array(BlendWriter *writer, uint num, const double *data_ptr)
{
- BLO_write_raw(writer, sizeof(double) * (size_t)num, data_ptr);
+ BLO_write_raw(writer, sizeof(double) * size_t(num), data_ptr);
}
void BLO_write_pointer_array(BlendWriter *writer, uint num, const void *data_ptr)
{
- BLO_write_raw(writer, sizeof(void *) * (size_t)num, data_ptr);
+ BLO_write_raw(writer, sizeof(void *) * size_t(num), data_ptr);
}
void BLO_write_float3_array(BlendWriter *writer, uint num, const float *data_ptr)
{
- BLO_write_raw(writer, sizeof(float[3]) * (size_t)num, data_ptr);
+ BLO_write_raw(writer, sizeof(float[3]) * size_t(num), data_ptr);
}
void BLO_write_string(BlendWriter *writer, const char *data_ptr)
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc
index cd0015ff717..872b256c497 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -273,7 +273,7 @@ void schedule_node(DepsgraphEvalState *state,
return;
}
/* Actually schedule the node. */
- bool is_scheduled = atomic_fetch_and_or_uint8((uint8_t *)&node->scheduled, (uint8_t) true);
+ bool is_scheduled = atomic_fetch_and_or_uint8((uint8_t *)&node->scheduled, uint8_t(true));
if (!is_scheduled) {
if (node->is_noop()) {
/* skip NOOP node, schedule children right away */
diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc
index b2d2fa64fde..7e5556adcc9 100644
--- a/source/blender/editors/interface/interface.cc
+++ b/source/blender/editors/interface/interface.cc
@@ -3740,10 +3740,10 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
case UI_BTYPE_NUM_SLIDER:
if (validate) {
UI_GET_BUT_VALUE_INIT(but, value);
- if (value < (double)but->hardmin) {
+ if (value < double(but->hardmin)) {
ui_but_value_set(but, but->hardmin);
}
- else if (value > (double)but->hardmax) {
+ else if (value > double(but->hardmax)) {
ui_but_value_set(but, but->hardmax);
}
diff --git a/source/blender/editors/interface/view2d_ops.cc b/source/blender/editors/interface/view2d_ops.cc
index 1df2acd5ef7..0282c1b1813 100644
--- a/source/blender/editors/interface/view2d_ops.cc
+++ b/source/blender/editors/interface/view2d_ops.cc
@@ -1583,10 +1583,10 @@ void UI_view2d_smooth_view(const bContext *C,
if (changed) {
sms.orig_cur = v2d->cur;
- sms.time_allowed = (double)smooth_viewtx / 1000.0;
+ sms.time_allowed = double(smooth_viewtx) / 1000.0;
/* scale the time allowed the change in view */
- sms.time_allowed *= (double)fac;
+ sms.time_allowed *= double(fac);
/* keep track of running timer! */
if (v2d->sms == nullptr) {
diff --git a/source/blender/editors/object/object_transform.cc b/source/blender/editors/object/object_transform.cc
index 0735e93437d..680cf1c94cd 100644
--- a/source/blender/editors/object/object_transform.cc
+++ b/source/blender/editors/object/object_transform.cc
@@ -2101,7 +2101,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const
}
#endif
- double depth = (double)depth_fl;
+ double depth = double(depth_fl);
if ((depth > depths->depth_range[0]) && (depth < depths->depth_range[1])) {
xfd->prev.depth = depth_fl;
xfd->prev.is_depth_valid = true;
diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc
index 06224b3a28c..e2d4f094137 100644
--- a/source/blender/editors/space_file/filelist.cc
+++ b/source/blender/editors/space_file/filelist.cc
@@ -2008,8 +2008,8 @@ static FileDirEntry *filelist_file_create_entry(FileList *filelist, const int in
ret = MEM_cnew<FileDirEntry>(__func__);
- ret->size = (uint64_t)entry->st.st_size;
- ret->time = (int64_t)entry->st.st_mtime;
+ ret->size = uint64_t(entry->st.st_size);
+ ret->time = int64_t(entry->st.st_mtime);
ret->relpath = BLI_strdup(entry->relpath);
if (entry->free_name) {
diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc
index 793b72b67de..d28aba9816f 100644
--- a/source/blender/editors/uvedit/uvedit_islands.cc
+++ b/source/blender/editors/uvedit/uvedit_islands.cc
@@ -349,7 +349,7 @@ int bm_mesh_calc_uv_islands(const Scene *scene,
BM_mesh_elem_table_ensure(bm, BM_FACE);
int *groups_array = static_cast<int *>(
- MEM_mallocN(sizeof(*groups_array) * (size_t)bm->totface, __func__));
+ MEM_mallocN(sizeof(*groups_array) * size_t(bm->totface), __func__));
int(*group_index)[2];
@@ -524,7 +524,7 @@ void ED_uvedit_pack_islands_multi(const Scene *scene,
island_array[index] = island;
if (margin > 0.0f) {
- area += (double)sqrtf(box->w * box->h);
+ area += double(sqrtf(box->w * box->h));
}
}
diff --git a/source/blender/geometry/intern/mesh_merge_by_distance.cc b/source/blender/geometry/intern/mesh_merge_by_distance.cc
index 55d757d0e81..288fd407641 100644
--- a/source/blender/geometry/intern/mesh_merge_by_distance.cc
+++ b/source/blender/geometry/intern/mesh_merge_by_distance.cc
@@ -1280,10 +1280,10 @@ static void customdata_weld(
else if (CustomData_layer_has_math(dest, dest_i)) {
const int size = CustomData_sizeof(type);
void *dst_data = dest->layers[dest_i].data;
- void *v_dst = POINTER_OFFSET(dst_data, (size_t)dest_index * size);
+ void *v_dst = POINTER_OFFSET(dst_data, size_t(dest_index) * size);
for (j = 0; j < count; j++) {
CustomData_data_add(
- type, v_dst, POINTER_OFFSET(src_data, (size_t)src_indices[j] * size));
+ type, v_dst, POINTER_OFFSET(src_data, size_t(src_indices[j]) * size));
}
}
else {
@@ -1326,7 +1326,7 @@ static void customdata_weld(
else if (CustomData_layer_has_math(dest, dest_i)) {
const int size = CustomData_sizeof(type);
void *dst_data = layer_dst->data;
- void *v_dst = POINTER_OFFSET(dst_data, (size_t)dest_index * size);
+ void *v_dst = POINTER_OFFSET(dst_data, size_t(dest_index) * size);
CustomData_data_multiply(type, v_dst, fac);
}
}
@@ -1630,7 +1630,7 @@ std::optional<Mesh *> mesh_merge_by_distance_connected(const Mesh &mesh,
const float dist_sq = len_squared_v3(edgedir);
if (dist_sq <= merge_dist_sq) {
float influence = (v2_cluster->merged_verts + 1) /
- (float)(v1_cluster->merged_verts + v2_cluster->merged_verts + 2);
+ float(v1_cluster->merged_verts + v2_cluster->merged_verts + 2);
madd_v3_v3fl(v1_cluster->co, edgedir, influence);
v1_cluster->merged_verts += v2_cluster->merged_verts + 1;
diff --git a/source/blender/geometry/intern/uv_parametrizer.cc b/source/blender/geometry/intern/uv_parametrizer.cc
index 1829f943a5d..a6883476b94 100644
--- a/source/blender/geometry/intern/uv_parametrizer.cc
+++ b/source/blender/geometry/intern/uv_parametrizer.cc
@@ -195,7 +195,7 @@ static int PHashSizes[] = {
1048583, 2097169, 4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 268435459,
};
-#define PHASH_hash(ph, item) (uintptr_t(item) % ((uint)(ph)->cursize))
+#define PHASH_hash(ph, item) (uintptr_t(item) % (uint((ph)->cursize)))
#define PHASH_edge(v1, v2) (((v1) < (v2)) ? ((v1)*39) ^ ((v2)*31) : ((v1)*31) ^ ((v2)*39))
static PHash *phash_new(PHashLink **list, int sizehint)
@@ -1903,7 +1903,7 @@ static bool p_collapse_allowed_geometric(PEdge *edge, PEdge *pair)
if (p_vert_interior(oldv)) {
/* HLSCM criterion: angular defect smaller than threshold. */
- if (fabsf(angulardefect) > (float)(M_PI * 30.0 / 180.0)) {
+ if (fabsf(angulardefect) > float(M_PI * 30.0 / 180.0)) {
return false;
}
}
@@ -2465,7 +2465,7 @@ static float p_abf_compute_gradient(PAbfSystem *sys, PChart *chart)
norm += galpha1 * galpha1 + galpha2 * galpha2 + galpha3 * galpha3;
- gtriangle = sys->alpha[e1->u.id] + sys->alpha[e2->u.id] + sys->alpha[e3->u.id] - (float)M_PI;
+ gtriangle = sys->alpha[e1->u.id] + sys->alpha[e2->u.id] + sys->alpha[e3->u.id] - float(M_PI);
sys->bTriangle[f->u.id] = -gtriangle;
norm += gtriangle * gtriangle;
}
@@ -2696,8 +2696,8 @@ static bool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
/* clamp */
PEdge *e = f->edge;
do {
- if (sys->alpha[e->u.id] > (float)M_PI) {
- sys->alpha[e->u.id] = (float)M_PI;
+ if (sys->alpha[e->u.id] > float(M_PI)) {
+ sys->alpha[e->u.id] = float(M_PI);
}
else if (sys->alpha[e->u.id] < 0.0f) {
sys->alpha[e->u.id] = 0.0f;
@@ -2706,8 +2706,8 @@ static bool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
}
for (int i = 0; i < ninterior; i++) {
- sys->lambdaPlanar[i] += (float)EIG_linear_solver_variable_get(context, 0, i);
- sys->lambdaLength[i] += (float)EIG_linear_solver_variable_get(context, 0, ninterior + i);
+ sys->lambdaPlanar[i] += float(EIG_linear_solver_variable_get(context, 0, i));
+ sys->lambdaLength[i] += float(EIG_linear_solver_variable_get(context, 0, ninterior + i));
}
}
@@ -2780,7 +2780,7 @@ static bool p_chart_abf_solve(PChart *chart)
e = e->next->next->pair;
} while (e && (e != v->edge));
- scale = (anglesum == 0.0f) ? 0.0f : 2.0f * (float)M_PI / anglesum;
+ scale = (anglesum == 0.0f) ? 0.0f : 2.0f * float(M_PI) / anglesum;
e = v->edge;
do {
@@ -3409,7 +3409,7 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng)
trusted_radius /= 2 * nedges;
- random_angle = BLI_rng_get_float(rng) * 2.0f * (float)M_PI;
+ random_angle = BLI_rng_get_float(rng) * 2.0f * float(M_PI);
dir[0] = trusted_radius * cosf(random_angle);
dir[1] = trusted_radius * sinf(random_angle);
@@ -3588,7 +3588,7 @@ static float p_chart_minimum_area_angle(PChart *chart)
p2 = points[i];
p3 = (i == npoints - 1) ? points[0] : points[i + 1];
- angles[i] = (float)M_PI - p_vec2_angle(p1->uv, p2->uv, p3->uv);
+ angles[i] = float(M_PI) - p_vec2_angle(p1->uv, p2->uv, p3->uv);
if (points[i]->uv[1] < miny) {
miny = points[i]->uv[1];
@@ -3628,7 +3628,7 @@ static float p_chart_minimum_area_angle(PChart *chart)
minarea = 1e10;
minangle = 0.0;
- while (rotated <= (float)M_PI_2) { /* INVESTIGATE: how far to rotate? */
+ while (rotated <= float(M_PI_2)) { /* INVESTIGATE: how far to rotate? */
/* rotate with the smallest angle */
i_min = 0;
mina = 1e10;
@@ -3675,8 +3675,8 @@ static float p_chart_minimum_area_angle(PChart *chart)
}
/* try keeping rotation as small as possible */
- if (minangle > (float)M_PI_4) {
- minangle -= (float)M_PI_2;
+ if (minangle > float(M_PI_4)) {
+ minangle -= float(M_PI_2);
}
MEM_freeN(angles);
@@ -3869,9 +3869,9 @@ static void p_add_ngon(ParamHandle *handle,
Heap *heap = handle->polyfill_heap;
uint nfilltri = nverts - 2;
uint(*tris)[3] = static_cast<uint(*)[3]>(
- BLI_memarena_alloc(arena, sizeof(*tris) * (size_t)nfilltri));
+ BLI_memarena_alloc(arena, sizeof(*tris) * size_t(nfilltri)));
float(*projverts)[2] = static_cast<float(*)[2]>(
- BLI_memarena_alloc(arena, sizeof(*projverts) * (size_t)nverts));
+ BLI_memarena_alloc(arena, sizeof(*projverts) * size_t(nverts)));
/* Calc normal, flipped: to get a positive 2d cross product. */
float normal[3];
@@ -4209,7 +4209,7 @@ void GEO_uv_parametrizer_pack(ParamHandle *handle,
box->index = i; /* Warning this index skips chart->has_pins boxes. */
if (margin > 0.0f) {
- area += (double)sqrtf(box->w * box->h);
+ area += double(sqrtf(box->w * box->h));
}
}
@@ -4342,7 +4342,7 @@ void GEO_uv_parametrizer_average(ParamHandle *phandle,
/* Compute correction transform. */
float t[2][2];
t[0][0] = scale_factor_u;
- t[1][0] = clamp_f((float)(scale_cross / weight_sum), -0.5f, 0.5f);
+ t[1][0] = clamp_f(float(scale_cross / weight_sum), -0.5f, 0.5f);
t[0][1] = 0;
t[1][1] = 1.0f / scale_factor_u;
diff --git a/source/blender/gpu/intern/gpu_matrix.cc b/source/blender/gpu/intern/gpu_matrix.cc
index 12bbe13a296..b46860cf0f4 100644
--- a/source/blender/gpu/intern/gpu_matrix.cc
+++ b/source/blender/gpu/intern/gpu_matrix.cc
@@ -700,7 +700,7 @@ float GPU_polygon_offset_calc(const float (*winmat)[4], float viewdist, float di
if (depth_fac == 0.0f) {
/* Hard-code for 24 bit precision. */
int depthbits = 24;
- depth_fac = 1.0f / (float)((1 << depthbits) - 1);
+ depth_fac = 1.0f / float((1 << depthbits) - 1);
}
ofs = (-1.0 / winmat[2][2]) * dist * depth_fac;
diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.cc b/source/blender/gpu/intern/gpu_vertex_buffer.cc
index a441cfe2fb8..abf5d2dc4c0 100644
--- a/source/blender/gpu/intern/gpu_vertex_buffer.cc
+++ b/source/blender/gpu/intern/gpu_vertex_buffer.cc
@@ -278,7 +278,7 @@ void GPU_vertbuf_attr_get_raw_data(GPUVertBuf *verts_, uint a_idx, GPUVertBufRaw
access->data = (uchar *)verts->data + a->offset;
access->data_init = access->data;
#ifdef DEBUG
- access->_data_end = access->data_init + (size_t)(verts->vertex_alloc * format->stride);
+ access->_data_end = access->data_init + size_t(verts->vertex_alloc * format->stride);
#endif
}
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index a3a3fb3aa94..78fb75ddb40 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -1483,7 +1483,7 @@ static IK_Scene *convert_tree(
}
/* set the weight */
e_matrix &Wq = arm->getWq();
- assert(Wq.cols() == (int)weights.size());
+ assert(Wq.cols() == int(weights.size()));
for (int q = 0; q < Wq.cols(); q++) {
Wq(q, q) = weights[q];
}
@@ -1826,9 +1826,9 @@ static void execute_scene(struct Depsgraph *depsgraph,
}
if (joint->getType() == KDL::Joint::TransY) {
/* stretch bones have a TY joint, compute the scale */
- scale = (float)(q[0] / q_rest[0]);
+ scale = float(q[0] / q_rest[0]);
/* the length is the joint itself */
- length = (float)q[0];
+ length = float(q[0]);
}
else {
scale = 1.0f;
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index ab2f0207be4..272014ea5eb 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -1464,19 +1464,19 @@ void DirectDrawSurface::printInfo() const
if (header.pf.fourcc != 0) {
/* Display fourcc code even when DDPF_FOURCC flag not set. */
printf("\tFourCC: '%c%c%c%c' (0x%.8X)\n",
- (int)((header.pf.fourcc >> 0) & 0xFF),
- (int)((header.pf.fourcc >> 8) & 0xFF),
- (int)((header.pf.fourcc >> 16) & 0xFF),
- (int)((header.pf.fourcc >> 24) & 0xFF),
+ int((header.pf.fourcc >> 0) & 0xFF),
+ int((header.pf.fourcc >> 8) & 0xFF),
+ int((header.pf.fourcc >> 16) & 0xFF),
+ int((header.pf.fourcc >> 24) & 0xFF),
header.pf.fourcc);
}
if ((header.pf.flags & DDPF_FOURCC) && (header.pf.bitcount != 0)) {
printf("\tSwizzle: '%c%c%c%c' (0x%.8X)\n",
- (int)(header.pf.bitcount >> 0) & 0xFF,
- (int)(header.pf.bitcount >> 8) & 0xFF,
- (int)(header.pf.bitcount >> 16) & 0xFF,
- (int)(header.pf.bitcount >> 24) & 0xFF,
+ int(header.pf.bitcount >> 0) & 0xFF,
+ int(header.pf.bitcount >> 8) & 0xFF,
+ int(header.pf.bitcount >> 16) & 0xFF,
+ int(header.pf.bitcount >> 24) & 0xFF,
header.pf.bitcount);
}
else {
diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp
index 6f77c233aac..ce7eada84d6 100644
--- a/source/blender/io/collada/MeshImporter.cpp
+++ b/source/blender/io/collada/MeshImporter.cpp
@@ -102,7 +102,7 @@ void WVDataWrapper::print()
COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
if (values->getCount()) {
for (int i = 0; i < values->getCount(); i += 2) {
- fprintf(stderr, "%.1f, %.1f\n", (float)(*values)[i], (float)(*values)[i + 1]);
+ fprintf(stderr, "%.1f, %.1f\n", float((*values)[i]), float((*values)[i + 1]));
}
}
} break;
@@ -133,8 +133,8 @@ void UVDataWrapper::getUV(int uv_index, float *uv)
if (values->empty()) {
return;
}
- uv[0] = (float)(*values)[uv_index * stride];
- uv[1] = (float)(*values)[uv_index * stride + 1];
+ uv[0] = float((*values)[uv_index * stride]);
+ uv[1] = float((*values)[uv_index * stride + 1]);
} break;
case COLLADAFW::MeshVertexData::DATA_TYPE_UNKNOWN:
@@ -832,10 +832,10 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData &arr, int i,
return;
}
- v[0] = (float)(*values)[i++];
- v[1] = (float)(*values)[i++];
+ v[0] = float((*values)[i++]);
+ v[1] = float((*values)[i++]);
if (stride >= 3) {
- v[2] = (float)(*values)[i];
+ v[2] = float((*values)[i]);
}
else {
v[2] = 0.0f;
diff --git a/source/blender/makesrna/intern/rna_path.cc b/source/blender/makesrna/intern/rna_path.cc
index 96f46f5dbe6..e555368561b 100644
--- a/source/blender/makesrna/intern/rna_path.cc
+++ b/source/blender/makesrna/intern/rna_path.cc
@@ -708,7 +708,7 @@ const char *RNA_path_array_index_token_find(const char *rna_path, const Property
if (UNLIKELY(rna_path[0] == '\0')) {
return nullptr;
}
- size_t rna_path_len = (size_t)strlen(rna_path) - 1;
+ size_t rna_path_len = size_t(strlen(rna_path)) - 1;
if (rna_path[rna_path_len] != ']') {
return nullptr;
}
@@ -861,7 +861,7 @@ static char *rna_idp_path(PointerRNA *ptr,
IDProperty *array = IDP_IDPArray(iter);
if (needle >= array && needle < (iter->len + array)) { /* found! */
link.name = iter->name;
- link.index = (int)(needle - array);
+ link.index = int(needle - array);
path = rna_idp_path_create(&link);
break;
}
diff --git a/source/blender/python/gpu/gpu_py_shader_create_info.cc b/source/blender/python/gpu/gpu_py_shader_create_info.cc
index 7bd0bf4aedf..afef873ab6b 100644
--- a/source/blender/python/gpu/gpu_py_shader_create_info.cc
+++ b/source/blender/python/gpu/gpu_py_shader_create_info.cc
@@ -35,9 +35,9 @@ using blender::gpu::shader::Qualifier;
" - ``READ``\n" \
" - ``WRITE``\n"
static const struct PyC_FlagSet pygpu_qualifiers[] = {
- {(int)Qualifier::NO_RESTRICT, "NO_RESTRICT"},
- {(int)Qualifier::READ, "READ"},
- {(int)Qualifier::WRITE, "WRITE"},
+ {int(Qualifier::NO_RESTRICT), "NO_RESTRICT"},
+ {int(Qualifier::READ), "READ"},
+ {int(Qualifier::WRITE), "WRITE"},
{0, nullptr},
};
#endif
diff --git a/source/blender/simulation/intern/SIM_mass_spring.cpp b/source/blender/simulation/intern/SIM_mass_spring.cpp
index 0d403eeeb3d..b1782d67a04 100644
--- a/source/blender/simulation/intern/SIM_mass_spring.cpp
+++ b/source/blender/simulation/intern/SIM_mass_spring.cpp
@@ -1029,8 +1029,8 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
for (i = 0; i < size; i++) {
float x[3], v[3], gvel[3], gvel_smooth[3], gdensity;
- madd_v3_v3v3fl(x, offset, a, (float)i / (float)(size - 1));
- madd_v3_v3fl(x, b, (float)j / (float)(size - 1));
+ madd_v3_v3v3fl(x, offset, a, float(i) / float(size - 1));
+ madd_v3_v3fl(x, b, float(j) / float(size - 1));
zero_v3(v);
SIM_hair_volume_grid_interpolate(grid, x, &gdensity, gvel, gvel_smooth, NULL, NULL);
@@ -1237,7 +1237,7 @@ static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *r
sres->min_iterations = min_ii(sres->min_iterations, result->iterations);
sres->max_iterations = max_ii(sres->max_iterations, result->iterations);
- sres->avg_iterations += (float)result->iterations * dt;
+ sres->avg_iterations += float(result->iterations) * dt;
}
else {
/* error only makes sense for successful iterations */
@@ -1247,7 +1247,7 @@ static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *r
}
sres->min_iterations = sres->max_iterations = result->iterations;
- sres->avg_iterations += (float)result->iterations * dt;
+ sres->avg_iterations += float(result->iterations) * dt;
}
sres->status |= result->status;
diff --git a/source/blender/simulation/intern/hair_volume.cpp b/source/blender/simulation/intern/hair_volume.cpp
index cd2f1ae33ec..054426b8874 100644
--- a/source/blender/simulation/intern/hair_volume.cpp
+++ b/source/blender/simulation/intern/hair_volume.cpp
@@ -448,12 +448,12 @@ BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
HairGridVert *vert_j = vert + jmin * stride_j;
float loc_j[3] = {loc[0], loc[1], loc[2]};
- loc_j[axis_j] += (float)jmin;
+ loc_j[axis_j] += float(jmin);
for (j = jmin; j <= jmax; j++, vert_j += stride_j, loc_j[axis_j] += 1.0f) {
HairGridVert *vert_k = vert_j + kmin * stride_k;
float loc_k[3] = {loc_j[0], loc_j[1], loc_j[2]};
- loc_k[axis_k] += (float)kmin;
+ loc_k[axis_k] += float(kmin);
for (k = kmin; k <= kmax; k++, vert_k += stride_k, loc_k[axis_k] += 1.0f) {
hair_volume_eval_grid_vertex(vert_k, loc_k, radius, dist_scale, x2, v2, x3, v3);
@@ -542,7 +542,7 @@ void SIM_hair_volume_add_segment(HairGrid *grid,
float shift1, shift2; /* fraction of a full cell shift [0.0, 1.0) */
int jmin, jmax, kmin, kmax;
- h = CLAMPIS((float)i, start0, end0);
+ h = CLAMPIS(float(i), start0, end0);
shift1 = start1 + (h - start0) * inc1;
shift2 = start2 + (h - start0) * inc2;
@@ -565,7 +565,7 @@ void SIM_hair_volume_add_segment(HairGrid *grid,
}
vert0 = grid->verts + i * stride0;
- loc0[axis0] = (float)i;
+ loc0[axis0] = float(i);
loc0[axis1] = 0.0f;
loc0[axis2] = 0.0f;
@@ -802,9 +802,9 @@ bool SIM_hair_volume_solve_divergence(HairGrid *grid,
float col[3];
float fac;
- loc[0] = (float)(i - 1);
- loc[1] = (float)(j - 1);
- loc[2] = (float)(k - 1);
+ loc[0] = float(i - 1);
+ loc[1] = float(j - 1);
+ loc[2] = float(k - 1);
grid_to_world(grid, wloc, loc);
if (divergence > 0.0f) {
@@ -968,9 +968,9 @@ bool SIM_hair_volume_solve_divergence(HairGrid *grid,
float col[3];
float fac;
- loc[0] = (float)(i - 1);
- loc[1] = (float)(j - 1);
- loc[2] = (float)(k - 1);
+ loc[0] = float(i - 1);
+ loc[1] = float(j - 1);
+ loc[2] = float(k - 1);
grid_to_world(grid, wloc, loc);
float pressure = p[u];
@@ -1078,7 +1078,7 @@ void SIM_hair_volume_vertex_grid_filter_box(HairVertexGrid *grid, int kernel_siz
}
tot = kernel_size * 2 + 1;
- invD = 1.0f / (float)(tot * tot * tot);
+ invD = 1.0f / float(tot * tot * tot);
/* clear values for convolution */
for (i = 0; i < size; i++) {
diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc
index 9fe7a6b23b0..201fc177b9c 100644
--- a/source/blender/windowmanager/intern/wm_event_system.cc
+++ b/source/blender/windowmanager/intern/wm_event_system.cc
@@ -4275,7 +4275,7 @@ void WM_event_modal_handler_region_replace(wmWindow *win,
* it needs to keep old region stored in handler, so don't change it. */
if ((handler->context.region == old_region) && (handler->is_fileselect == false)) {
handler->context.region = new_region;
- handler->context.region_type = new_region ? new_region->regiontype : (int)RGN_TYPE_WINDOW;
+ handler->context.region_type = new_region ? new_region->regiontype : int(RGN_TYPE_WINDOW);
}
}
}