Cleanup: replace C-style casts with functional casts for numeric types

This commit is contained in:
Campbell Barton 2022-09-25 18:33:28 +10:00
parent c7b247a118
commit f68cfd6bb0
310 changed files with 1541 additions and 1542 deletions

View File

@ -70,7 +70,7 @@ GHOST_TSuccess GHOST_DisplayManager::getDisplaySetting(uint8_t display,
uint8_t numDisplays;
success = getNumDisplays(numDisplays);
if (success == GHOST_kSuccess) {
if (display < numDisplays && ((uint8_t)index < m_settings[display].size())) {
if (display < numDisplays && (uint8_t(index) < m_settings[display].size())) {
setting = m_settings[display][index];
}
else {
@ -101,14 +101,14 @@ GHOST_TSuccess GHOST_DisplayManager::findMatch(uint8_t display,
"GHOST_DisplayManager::findMatch(): m_settingsInitialized=false");
int criteria[4] = {
(int)setting.xPixels, (int)setting.yPixels, (int)setting.bpp, (int)setting.frequency};
int(setting.xPixels), int(setting.yPixels), int(setting.bpp), int(setting.frequency)};
int capabilities[4];
double field, score;
double best = 1e12; /* A big number. */
int found = 0;
/* Look at all the display modes. */
for (int i = 0; (i < (int)m_settings[display].size()); i++) {
for (int i = 0; (i < int(m_settings[display].size())); i++) {
/* Store the capabilities of the display device. */
capabilities[0] = m_settings[display][i].xPixels;
capabilities[1] = m_settings[display][i].yPixels;

View File

@ -109,7 +109,7 @@ GHOST_TSuccess GHOST_DisplayManagerSDL::setCurrentDisplaySetting(
SDL_GetDisplayMode(display, i, &mode);
if ((int)setting.xPixels > mode.w || (int)setting.yPixels > mode.h) {
if (int(setting.xPixels) > mode.w || int(setting.yPixels) > mode.h) {
continue;
}

View File

@ -185,8 +185,8 @@ GHOST_TSuccess GHOST_DisplayManagerX11::setCurrentDisplaySetting(
}
}
else {
if (abs(calculate_rate(vidmodes[i]) - (int)setting.frequency) <
abs(calculate_rate(vidmodes[best_fit]) - (int)setting.frequency)) {
if (abs(calculate_rate(vidmodes[i]) - int(setting.frequency)) <
abs(calculate_rate(vidmodes[best_fit]) - int(setting.frequency))) {
best_fit = i;
}
}

View File

@ -31,7 +31,7 @@ GHOST_EventManager::~GHOST_EventManager()
uint32_t GHOST_EventManager::getNumEvents()
{
return (uint32_t)m_events.size();
return uint32_t(m_events.size());
}
uint32_t GHOST_EventManager::getNumEvents(GHOST_TEventType type)

View File

@ -257,7 +257,7 @@ bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short produ
}
if (m_buttonMask == 0) {
m_buttonMask = (int)~(UINT_MAX << m_buttonCount);
m_buttonMask = int(~(UINT_MAX << m_buttonCount));
}
#ifdef DEBUG_NDOF_BUTTONS

View File

@ -413,7 +413,7 @@ static char convert_keyboard_event_to_ascii(const SDL_KeyboardEvent &sdl_sub_evt
}
}
}
return (char)sym;
return char(sym);
}
/**

View File

@ -910,7 +910,7 @@ static wl_buffer *ghost_wl_buffer_create_for_image(struct wl_shm *shm,
wl_shm_pool_destroy(pool);
if (buffer) {
*r_buffer_data = buffer_data;
*r_buffer_data_size = (size_t)buffer_size;
*r_buffer_data_size = size_t(buffer_size);
}
else {
/* Highly unlikely. */
@ -1991,7 +1991,7 @@ static void tablet_tool_handle_pressure(void *data,
struct zwp_tablet_tool_v2 * /*zwp_tablet_tool_v2*/,
const uint32_t pressure)
{
const float pressure_unit = (float)pressure / 65535;
const float pressure_unit = float(pressure) / 65535;
CLOG_INFO(LOG, 2, "pressure (%.4f)", pressure_unit);
GWL_TabletTool *tablet_tool = static_cast<GWL_TabletTool *>(data);
@ -2012,8 +2012,8 @@ static void tablet_tool_handle_tilt(void *data,
{
/* Map degrees to `-1.0..1.0`. */
const float tilt_unit[2] = {
(float)(wl_fixed_to_double(tilt_x) / 90.0),
(float)(wl_fixed_to_double(tilt_y) / 90.0),
float(wl_fixed_to_double(tilt_x) / 90.0),
float(wl_fixed_to_double(tilt_y) / 90.0),
};
CLOG_INFO(LOG, 2, "tilt (x=%.4f, y=%.4f)", UNPACK2(tilt_unit));
GWL_TabletTool *tablet_tool = static_cast<GWL_TabletTool *>(data);

View File

@ -715,7 +715,7 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent)
XK_Super_R,
};
for (int i = 0; i < (int)ARRAY_SIZE(modifiers); i++) {
for (int i = 0; i < int(ARRAY_SIZE(modifiers)); i++) {
KeyCode kc = XKeysymToKeycode(m_display, modifiers[i]);
if (kc != 0 && ((xevent.xkeymap.key_vector[kc >> 3] >> (kc & 7)) & 1) != 0) {
pushEvent(new GHOST_EventKey(getMilliSeconds(),
@ -845,14 +845,14 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
}
else {
if (m_keycode_last_repeat_key == xke->keycode) {
m_keycode_last_repeat_key = (uint)-1;
m_keycode_last_repeat_key = uint(-1);
}
}
}
}
else if (xe->type == EnterNotify) {
/* We can't tell how the key state changed, clear it to avoid stuck keys. */
m_keycode_last_repeat_key = (uint)-1;
m_keycode_last_repeat_key = uint(-1);
}
#ifdef USE_XINPUT_HOTPLUG
@ -1193,7 +1193,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
int i = 0;
while (true) {
/* Search character boundary. */
if ((uchar)utf8_buf[i++] > 0x7f) {
if (uchar(utf8_buf[i++]) > 0x7f) {
for (; i < len; ++i) {
c = utf8_buf[i];
if (c < 0x80 || c > 0xbf) {
@ -1523,7 +1523,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
((void)(val = data->axis_data[axis - axis_first]), true))
if (AXIS_VALUE_GET(2, axis_value)) {
window->GetTabletData().Pressure = axis_value / ((float)xtablet.PressureLevels);
window->GetTabletData().Pressure = axis_value / float(xtablet.PressureLevels);
}
/* NOTE(@broken): the (short) cast and the & 0xffff is bizarre and unexplained anywhere,
@ -1535,12 +1535,12 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
* I don't think we need to cast to short here, but do not have a device to check this.
*/
if (AXIS_VALUE_GET(3, axis_value)) {
window->GetTabletData().Xtilt = (short)(axis_value & 0xffff) /
((float)xtablet.XtiltLevels);
window->GetTabletData().Xtilt = short(axis_value & 0xffff) /
float(xtablet.XtiltLevels);
}
if (AXIS_VALUE_GET(4, axis_value)) {
window->GetTabletData().Ytilt = (short)(axis_value & 0xffff) /
((float)xtablet.YtiltLevels);
window->GetTabletData().Ytilt = short(axis_value & 0xffff) /
float(xtablet.YtiltLevels);
}
# undef AXIS_VALUE_GET
@ -1897,7 +1897,7 @@ static GHOST_TKey ghost_key_from_keysym(const KeySym key)
#undef GXMAP
#define MAKE_ID(a, b, c, d) ((int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a))
#define MAKE_ID(a, b, c, d) (int(d) << 24 | int(c) << 16 | (b) << 8 | (a))
static GHOST_TKey ghost_key_from_keycode(const XkbDescPtr xkb_descr, const KeyCode keycode)
{
@ -2020,7 +2020,7 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt,
win,
m_atom.XCLIP_OUT,
0,
(long)pty_size,
long(pty_size),
False,
AnyPropertyType,
&pty_type,
@ -2106,7 +2106,7 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt,
win,
m_atom.XCLIP_OUT,
0,
(long)pty_size,
long(pty_size),
False,
AnyPropertyType,
&pty_type,
@ -2363,10 +2363,10 @@ class DialogData {
bool isInsideButton(XEvent &e, uint button_num)
{
return (
(e.xmotion.y > (int)(height - padding_y - button_height)) &&
(e.xmotion.y < (int)(height - padding_y)) &&
(e.xmotion.x > (int)(width - (padding_x + button_width) * button_num)) &&
(e.xmotion.x < (int)(width - padding_x - (padding_x + button_width) * (button_num - 1))));
(e.xmotion.y > int(height - padding_y - button_height)) &&
(e.xmotion.y < int(height - padding_y)) &&
(e.xmotion.x > int(width - (padding_x + button_width) * button_num)) &&
(e.xmotion.x < int(width - padding_x - (padding_x + button_width) * (button_num - 1))));
}
};
@ -2383,7 +2383,7 @@ static void split(const char *text, const char *seps, char ***str, int *count)
free(data);
data = strdup(text);
*str = (char **)malloc((size_t)(*count) * sizeof(char *));
*str = (char **)malloc(size_t(*count) * sizeof(char *));
for (i = 0, tok = strtok(data, seps); tok != nullptr; tok = strtok(nullptr, seps), i++) {
(*str)[i] = strdup(tok);
}
@ -2440,7 +2440,7 @@ GHOST_TSuccess GHOST_SystemX11::showMessageBox(const char *title,
8,
PropModeReplace,
(const unsigned char *)title,
(int)strlen(title));
int(strlen(title)));
XChangeProperty(
m_display, window, winType, XA_ATOM, 32, PropModeReplace, (unsigned char *)&typeDialog, 1);

View File

@ -26,7 +26,7 @@ GHOST_TimerManager::~GHOST_TimerManager()
uint32_t GHOST_TimerManager::getNumTimers()
{
return (uint32_t)m_timers.size();
return uint32_t(m_timers.size());
}
bool GHOST_TimerManager::getTimerFound(GHOST_TimerTask *timer)

View File

@ -485,7 +485,7 @@ static unsigned char sdl_std_cursor_arrow[] = {
#define sdl_std_cursor_HOT_Y_arrow -14
/* end cursor data */
static SDL_Cursor *sdl_std_cursor_array[(int)GHOST_kStandardCursorNumCursors] = {nullptr};
static SDL_Cursor *sdl_std_cursor_array[int(GHOST_kStandardCursorNumCursors)] = {nullptr};
/* utility function mostly a copy of SDL_CreateCursor but allows us to change
* color and supports blenders flipped bits */
@ -544,7 +544,7 @@ static SDL_Cursor *getStandardCursorShape(GHOST_TStandardCursor shape)
if (sdl_std_cursor_array[0] == nullptr) {
#define DEF_CURSOR(name, ind) \
{ \
sdl_std_cursor_array[(int)ind] = sdl_ghost_CreateCursor( \
sdl_std_cursor_array[int(ind)] = sdl_ghost_CreateCursor( \
sdl_std_cursor_##name, \
sdl_std_cursor_mask_##name, \
sdl_std_cursor_WIDTH_##name, \
@ -580,7 +580,7 @@ static SDL_Cursor *getStandardCursorShape(GHOST_TStandardCursor shape)
#undef DEF_CURSOR
}
return sdl_std_cursor_array[(int)shape];
return sdl_std_cursor_array[int(shape)];
}
GHOST_TSuccess GHOST_WindowSDL::setWindowCursorGrab(GHOST_TGrabCursorMode /*mode*/)
@ -641,5 +641,5 @@ uint16_t GHOST_WindowSDL::getDPIHint()
return 96;
}
return (int)ddpi;
return int(ddpi);
}

View File

@ -442,7 +442,7 @@ void GHOST_WindowX11::refreshXInputDevices()
}
}
XSelectExtensionEvent(m_display, m_window, xevents.data(), (int)xevents.size());
XSelectExtensionEvent(m_display, m_window, xevents.data(), int(xevents.size()));
}
}
@ -899,7 +899,7 @@ GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
bool is_max, is_full, is_motif_full;
cur_state = getState();
if (state == (int)cur_state) {
if (state == int(cur_state)) {
return GHOST_kSuccess;
}

View File

@ -36,7 +36,7 @@ class MemLeakPrinter {
const size_t mem_in_use = MEM_get_memory_in_use();
printf("Error: Not freed memory blocks: %u, total unfreed memory %f MB\n",
leaked_blocks,
(double)mem_in_use / 1024 / 1024);
double(mem_in_use) / 1024 / 1024);
MEM_printmemlist();
if (fail_on_memleak) {

View File

@ -120,8 +120,8 @@ static void ArHosekSkyModel_CookConfiguration(ArHosekSkyModel_Dataset dataset,
{
const double *elev_matrix;
int int_turbidity = (int)turbidity;
double turbidity_rem = turbidity - (double)int_turbidity;
int int_turbidity = int(turbidity);
double turbidity_rem = turbidity - double(int_turbidity);
solar_elevation = pow(solar_elevation / (MATH_PI / 2.0), (1.0 / 3.0));
@ -195,8 +195,8 @@ static double ArHosekSkyModel_CookRadianceConfiguration(ArHosekSkyModel_Radiance
{
const double *elev_matrix;
int int_turbidity = (int)turbidity;
double turbidity_rem = turbidity - (double)int_turbidity;
int int_turbidity = int(turbidity);
double turbidity_rem = turbidity - double(int_turbidity);
double res;
solar_elevation = pow(solar_elevation / (MATH_PI / 2.0), (1.0 / 3.0));
@ -274,7 +274,7 @@ double SKY_arhosekskymodel_radiance(SKY_ArHosekSkyModelState *state,
double gamma,
double wavelength)
{
int low_wl = (int)((wavelength - 320.0) / 40.0);
int low_wl = int((wavelength - 320.0) / 40.0);
if (low_wl < 0 || low_wl >= 11) {
return 0.0;

View File

@ -95,5 +95,5 @@ int main(int argc, char *argv[])
eThumbStatus ret = extract_png_from_blend_file(argv[1], argv[2]);
return (int)ret;
return int(ret);
}

View File

@ -103,7 +103,7 @@ static bool file_seek(FileReader *file, size_t len)
blender::Array<char> dummy_data(dummy_data_size);
while (len > 0) {
const size_t len_chunk = std::min(len, dummy_data_size);
if ((size_t)file->read(file, dummy_data.data(), len_chunk) != len_chunk) {
if (size_t(file->read(file, dummy_data.data(), len_chunk)) != len_chunk) {
return false;
}
len -= len_chunk;

View File

@ -354,7 +354,7 @@ CustomDataLayer *BKE_id_attribute_search(ID *id,
get_domains(id, info);
for (eAttrDomain domain = ATTR_DOMAIN_POINT; domain < ATTR_DOMAIN_NUM;
domain = static_cast<eAttrDomain>((int(domain)) + 1)) {
domain = static_cast<eAttrDomain>(int(domain) + 1)) {
if (!(domain_mask & ATTR_DOMAIN_AS_MASK(domain))) {
continue;
}
@ -388,7 +388,7 @@ int BKE_id_attributes_length(const ID *id, eAttrDomainMask domain_mask, eCustomD
continue;
}
if ((1 << (int)domain) & domain_mask) {
if ((1 << int(domain)) & domain_mask) {
length += CustomData_number_of_layers_typemask(customdata, mask);
}
}
@ -574,7 +574,7 @@ CustomDataLayer *BKE_id_attribute_from_index(ID *id,
for (const int domain : IndexRange(ATTR_DOMAIN_NUM)) {
CustomData *customdata = info[domain].customdata;
if (!customdata || !((1 << (int)domain) & domain_mask)) {
if (!customdata || !((1 << int(domain)) & domain_mask)) {
continue;
}

View File

@ -2358,7 +2358,7 @@ void BKE_brush_scale_unprojected_radius(float *unprojected_radius,
float scale = new_brush_size;
/* avoid division by zero */
if (old_brush_size != 0) {
scale /= (float)old_brush_size;
scale /= float(old_brush_size);
}
(*unprojected_radius) *= scale;
}

View File

@ -1682,7 +1682,7 @@ void BKE_curve_calc_coords_axis(const BezTriple *bezt_array,
bezt_next->vec[0][axis],
bezt_next->vec[1][axis],
r_points_offset,
(int)resolu,
int(resolu),
stride);
r_points_offset = (float *)POINTER_OFFSET(r_points_offset, resolu_stride);
}
@ -1695,7 +1695,7 @@ void BKE_curve_calc_coords_axis(const BezTriple *bezt_array,
bezt_next->vec[0][axis],
bezt_next->vec[1][axis],
r_points_offset,
(int)resolu,
int(resolu),
stride);
r_points_offset = (float *)POINTER_OFFSET(r_points_offset, resolu_stride);
if (use_cyclic_duplicate_endpoint) {
@ -1719,7 +1719,7 @@ void BKE_curve_forward_diff_bezier(
float rt0, rt1, rt2, rt3, f;
int a;
f = (float)it;
f = float(it);
rt0 = q0;
rt1 = 3.0f * (q1 - q0) / f;
f *= f;
@ -1747,7 +1747,7 @@ void BKE_curve_forward_diff_tangent_bezier(
float rt0, rt1, rt2, f;
int a;
f = 1.0f / (float)it;
f = 1.0f / float(it);
rt0 = 3.0f * (q1 - q0);
rt1 = f * (3.0f * (q3 - q0) + 9.0f * (q1 - q2));
@ -1778,7 +1778,7 @@ static void forward_diff_bezier_cotangent(const float p0[3],
*
* This could also be optimized like BKE_curve_forward_diff_bezier */
for (int a = 0; a <= it; a++) {
float t = (float)a / (float)it;
float t = float(a) / float(it);
for (int i = 0; i < 3; i++) {
p[i] = (-6.0f * t + 6.0f) * p0[i] + (18.0f * t - 12.0f) * p1[i] +
@ -2005,7 +2005,7 @@ static void tilt_bezpart(const BezTriple *prevbezt,
}
fac = 0.0;
dfac = 1.0f / (float)resolu;
dfac = 1.0f / float(resolu);
for (a = 0; a < resolu; a++, fac += dfac) {
if (tilt_array) {
@ -2328,7 +2328,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
nr = bl->nr;
while (nr--) {
ang_fac = angle * (1.0f - ((float)nr / bl->nr)); /* also works */
ang_fac = angle * (1.0f - (float(nr) / bl->nr)); /* also works */
axis_angle_to_quat(q, bevp1->dir, ang_fac);
mul_qt_qtqt(bevp1->quat, q, bevp1->quat);
@ -2515,7 +2515,7 @@ static void make_bevel_list_2D(BevList *bl)
/* first */
bevp = bl->bevpoints;
angle = atan2f(bevp->dir[0], bevp->dir[1]) - (float)M_PI_2;
angle = atan2f(bevp->dir[0], bevp->dir[1]) - float(M_PI_2);
bevp->sina = sinf(angle);
bevp->cosa = cosf(angle);
vec_to_quat(bevp->quat, bevp->dir, 5, 1);
@ -2523,7 +2523,7 @@ static void make_bevel_list_2D(BevList *bl)
/* last */
bevp = bl->bevpoints;
bevp += (bl->nr - 1);
angle = atan2f(bevp->dir[0], bevp->dir[1]) - (float)M_PI_2;
angle = atan2f(bevp->dir[0], bevp->dir[1]) - float(M_PI_2);
bevp->sina = sinf(angle);
bevp->cosa = cosf(angle);
vec_to_quat(bevp->quat, bevp->dir, 5, 1);
@ -5153,7 +5153,7 @@ bool BKE_curve_center_median(Curve *cu, float cent[3])
}
if (total) {
mul_v3_fl(cent, 1.0f / (float)total);
mul_v3_fl(cent, 1.0f / float(total));
}
return (total != 0);
@ -5392,7 +5392,7 @@ bool BKE_curve_material_index_validate(Curve *cu)
void BKE_curve_material_remap(Curve *cu, const uint *remap, uint remap_len)
{
const int curvetype = BKE_curve_type_get(cu);
const short remap_len_short = (short)remap_len;
const short remap_len_short = short(remap_len);
#define MAT_NR_REMAP(n) \
if (n < remap_len_short) { \

View File

@ -207,7 +207,7 @@ bool BKE_curveprofile_remove_point(CurveProfile *profile, CurveProfilePoint *poi
CurveProfilePoint *new_path = (CurveProfilePoint *)MEM_mallocN(
sizeof(CurveProfilePoint) * profile->path_len, __func__);
int i_delete = (int)(point - profile->path);
int i_delete = int(point - profile->path);
BLI_assert(i_delete > 0);
/* Copy the before and after the deleted point. */
@ -379,8 +379,8 @@ static void curveprofile_build_supports(CurveProfile *profile)
point_init(&profile->path[0], 1.0f, 0.0f, 0, HD_VECT, HD_VECT);
point_init(&profile->path[1], 1.0f, 0.5f, 0, HD_VECT, HD_VECT);
for (int i = 1; i < n - 2; i++) {
const float x = 1.0f - (0.5f * (1.0f - cosf((float)(i / (float)(n - 3)) * M_PI_2)));
const float y = 0.5f + 0.5f * sinf((float)((i / (float)(n - 3)) * M_PI_2));
const float x = 1.0f - (0.5f * (1.0f - cosf(float(i / float(n - 3)) * M_PI_2)));
const float y = 0.5f + 0.5f * sinf(float((i / float(n - 3)) * M_PI_2));
point_init(&profile->path[i], x, y, 0, HD_AUTO, HD_AUTO);
}
point_init(&profile->path[n - 2], 0.5f, 1.0f, 0, HD_VECT, HD_VECT);
@ -408,8 +408,8 @@ static void curveprofile_build_steps(CurveProfile *profile)
for (int i = 0; i < n; i++) {
int step_x = (i + 1) / 2;
int step_y = i / 2;
const float x = 1.0f - ((float)(2 * step_x) / n_steps_x);
const float y = (float)(2 * step_y) / n_steps_y;
const float x = 1.0f - (float(2 * step_x) / n_steps_x);
const float y = float(2 * step_y) / n_steps_y;
point_init(&profile->path[i], x, y, 0, HD_VECT, HD_VECT);
}
}

View File

@ -841,7 +841,7 @@ static void layerCopyValue_mloopcol(const void *source,
/* Modes that do a full copy or nothing. */
if (ELEM(mixmode, CDT_MIX_REPLACE_ABOVE_THRESHOLD, CDT_MIX_REPLACE_BELOW_THRESHOLD)) {
/* TODO: Check for a real valid way to get 'factor' value of our dest color? */
const float f = ((float)m2->r + (float)m2->g + (float)m2->b) / 3.0f;
const float f = (float(m2->r) + float(m2->g) + float(m2->b)) / 3.0f;
if (mixmode == CDT_MIX_REPLACE_ABOVE_THRESHOLD && f < mixfactor) {
return; /* Do Nothing! */
}
@ -876,10 +876,10 @@ static void layerCopyValue_mloopcol(const void *source,
blend_color_interpolate_byte(dst, dst, tmp_col, mixfactor);
m2->r = (char)dst[0];
m2->g = (char)dst[1];
m2->b = (char)dst[2];
m2->a = (char)dst[3];
m2->r = char(dst[0]);
m2->g = char(dst[1]);
m2->b = char(dst[2]);
m2->a = char(dst[3]);
}
}
@ -901,10 +901,10 @@ static void layerMultiply_mloopcol(void *data, const float fac)
{
MLoopCol *m = static_cast<MLoopCol *>(data);
m->r = (float)m->r * fac;
m->g = (float)m->g * fac;
m->b = (float)m->b * fac;
m->a = (float)m->a * fac;
m->r = float(m->r) * fac;
m->g = float(m->g) * fac;
m->b = float(m->b) * fac;
m->a = float(m->a) * fac;
}
static void layerAdd_mloopcol(void *data1, const void *data2)
@ -3119,7 +3119,7 @@ static void *customData_duplicate_referenced_layer_index(CustomData *data,
if (typeInfo->copy) {
void *dst_data = MEM_malloc_arrayN(
(size_t)totelem, typeInfo->size, "CD duplicate ref layer");
size_t(totelem), typeInfo->size, "CD duplicate ref layer");
typeInfo->copy(layer->data, dst_data, totelem);
layer->data = dst_data;
}
@ -3250,7 +3250,7 @@ void CustomData_copy_elements(const int type,
typeInfo->copy(src_data_ofs, dst_data_ofs, count);
}
else {
memcpy(dst_data_ofs, src_data_ofs, (size_t)count * typeInfo->size);
memcpy(dst_data_ofs, src_data_ofs, size_t(count) * typeInfo->size);
}
}
@ -3269,8 +3269,8 @@ void CustomData_copy_data_layer(const CustomData *source,
typeInfo = layerType_getInfo(source->layers[src_layer_index].type);
const size_t src_offset = (size_t)src_index * typeInfo->size;
const size_t dst_offset = (size_t)dst_index * typeInfo->size;
const size_t src_offset = size_t(src_index) * typeInfo->size;
const size_t dst_offset = size_t(dst_index) * typeInfo->size;
if (!count || !src_data || !dst_data) {
if (count && !(src_data == nullptr && dst_data == nullptr)) {
@ -3290,7 +3290,7 @@ void CustomData_copy_data_layer(const CustomData *source,
else {
memcpy(POINTER_OFFSET(dst_data, dst_offset),
POINTER_OFFSET(src_data, src_offset),
(size_t)count * typeInfo->size);
size_t(count) * typeInfo->size);
}
}
@ -3379,7 +3379,7 @@ void CustomData_free_elem(CustomData *data, const int index, const int count)
const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[i].type);
if (typeInfo->free) {
size_t offset = (size_t)index * typeInfo->size;
size_t offset = size_t(index) * typeInfo->size;
typeInfo->free(POINTER_OFFSET(data->layers[i].data, offset), count, typeInfo->size);
}
@ -3415,7 +3415,7 @@ void CustomData_interp(const CustomData *source,
if (weights == nullptr) {
default_weights = (count > SOURCE_BUF_SIZE) ?
static_cast<float *>(
MEM_mallocN(sizeof(*weights) * (size_t)count, __func__)) :
MEM_mallocN(sizeof(*weights) * size_t(count), __func__)) :
default_weights_buf;
copy_vn_fl(default_weights, count, 1.0f / count);
weights = default_weights;
@ -3446,7 +3446,7 @@ void CustomData_interp(const CustomData *source,
void *src_data = source->layers[src_i].data;
for (int j = 0; j < count; j++) {
sources[j] = POINTER_OFFSET(src_data, (size_t)src_indices[j] * typeInfo->size);
sources[j] = POINTER_OFFSET(src_data, size_t(src_indices[j]) * typeInfo->size);
}
typeInfo->interp(
@ -3454,7 +3454,7 @@ void CustomData_interp(const CustomData *source,
weights,
sub_weights,
count,
POINTER_OFFSET(dest->layers[dest_i].data, (size_t)dest_index * typeInfo->size));
POINTER_OFFSET(dest->layers[dest_i].data, size_t(dest_index) * typeInfo->size));
/* if there are multiple source & dest layers of the same type,
* we don't want to copy all source layers to the same dest, so
@ -3478,7 +3478,7 @@ void CustomData_swap_corners(CustomData *data, const int index, const int *corne
const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[i].type);
if (typeInfo->swap) {
const size_t offset = (size_t)index * typeInfo->size;
const size_t offset = size_t(index) * typeInfo->size;
typeInfo->swap(POINTER_OFFSET(data->layers[i].data, offset), corner_indices);
}
@ -3523,7 +3523,7 @@ void *CustomData_get(const CustomData *data, const int index, const int type)
}
/* get the offset of the desired element */
const size_t offset = (size_t)index * layerType_getInfo(type)->size;
const size_t offset = size_t(index) * layerType_getInfo(type)->size;
return POINTER_OFFSET(data->layers[layer_index].data, offset);
}
@ -3538,7 +3538,7 @@ void *CustomData_get_n(const CustomData *data, const int type, const int index,
return nullptr;
}
const size_t offset = (size_t)index * layerType_getInfo(type)->size;
const size_t offset = size_t(index) * layerType_getInfo(type)->size;
return POINTER_OFFSET(data->layers[layer_index + n].data, offset);
}

View File

@ -503,7 +503,7 @@ static float displist_calc_taper(Depsgraph *depsgraph,
float BKE_displist_calc_taper(
Depsgraph *depsgraph, const Scene *scene, Object *taperobj, int cur, int tot)
{
const float fac = ((float)cur) / (float)(tot - 1);
const float fac = float(cur) / float(tot - 1);
return displist_calc_taper(depsgraph, scene, taperobj, fac);
}
@ -518,7 +518,7 @@ static ModifierData *curve_get_tessellate_point(const Scene *scene,
ModifierMode required_mode = for_render ? eModifierMode_Render : eModifierMode_Realtime;
if (editmode) {
required_mode = (ModifierMode)((int)required_mode | eModifierMode_Editmode);
required_mode = (ModifierMode)(int(required_mode) | eModifierMode_Editmode);
}
ModifierData *pretessellatePoint = nullptr;
@ -562,7 +562,7 @@ void BKE_curve_calc_modifiers_pre(Depsgraph *depsgraph,
const bool editmode = (!for_render && (cu->editnurb || cu->editfont));
ModifierMode required_mode = for_render ? eModifierMode_Render : eModifierMode_Realtime;
if (editmode) {
required_mode = (ModifierMode)((int)required_mode | eModifierMode_Editmode);
required_mode = (ModifierMode)(int(required_mode) | eModifierMode_Editmode);
}
ModifierApplyFlag apply_flag = (ModifierApplyFlag)0;
@ -689,7 +689,7 @@ static GeometrySet curve_calc_modifiers_post(Depsgraph *depsgraph,
ModifierApplyFlag apply_flag = for_render ? MOD_APPLY_RENDER : (ModifierApplyFlag)0;
ModifierMode required_mode = for_render ? eModifierMode_Render : eModifierMode_Realtime;
if (editmode) {
required_mode = (ModifierMode)((int)required_mode | eModifierMode_Editmode);
required_mode = (ModifierMode)(int(required_mode) | eModifierMode_Editmode);
}
const ModifierEvalContext mectx_deform = {
@ -970,13 +970,13 @@ static void calc_bevfac_segment_mapping(
int bevcount = 0, nr = bl->nr;
float bev_fl = bevfac * (bl->nr - 1);
*r_bev = (int)bev_fl;
*r_bev = int(bev_fl);
while (bevcount < nr - 1) {
float normlen = *seglen / spline_length;
if (normsum + normlen > bevfac) {
bev_fl = bevcount + (bevfac - normsum) / normlen * *segbevcount;
*r_bev = (int)bev_fl;
*r_bev = int(bev_fl);
*r_blend = bev_fl - *r_bev;
break;
}
@ -1046,7 +1046,7 @@ static void calc_bevfac_mapping(const Curve *cu,
switch (cu->bevfac1_mapping) {
case CU_BEVFAC_MAP_RESOLU: {
const float start_fl = cu->bevfac1 * (bl->nr - 1);
*r_start = (int)start_fl;
*r_start = int(start_fl);
*r_firstblend = 1.0f - (start_fl - (*r_start));
break;
}
@ -1065,7 +1065,7 @@ static void calc_bevfac_mapping(const Curve *cu,
switch (cu->bevfac2_mapping) {
case CU_BEVFAC_MAP_RESOLU: {
const float end_fl = cu->bevfac2 * (bl->nr - 1);
end = (int)end_fl;
end = int(end_fl);
*r_steps = 2 + end - *r_start;
*r_lastblend = end_fl - end;
@ -1238,12 +1238,12 @@ static GeometrySet evaluate_curve_type_object(Depsgraph *depsgraph,
taper_factor = 1.0f;
}
else {
taper_factor = ((float)a - (1.0f - first_blend)) / len;
taper_factor = (float(a) - (1.0f - first_blend)) / len;
}
}
else {
float len = bl->nr - 1;
taper_factor = (float)i / len;
taper_factor = float(i) / len;
if (a == 0) {
taper_factor += (1.0f - first_blend) / len;

View File

@ -33,9 +33,9 @@ struct SGLSLEditMeshToTangent {
uint GetNumFaces()
{
#ifdef USE_LOOPTRI_DETECT_QUADS
return (uint)num_face_as_quad_map;
return uint(num_face_as_quad_map);
#else
return (uint)numTessFaces;
return uint(numTessFaces);
#endif
}
@ -194,21 +194,21 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
for (int i = 0; i < tangent_names_len; i++) {
if (tangent_names[i][0]) {
BKE_mesh_add_loop_tangent_named_layer_for_uv(
&bm->ldata, loopdata_out, (int)loopdata_out_len, tangent_names[i]);
&bm->ldata, loopdata_out, int(loopdata_out_len), tangent_names[i]);
}
}
if ((tangent_mask & DM_TANGENT_MASK_ORCO) &&
CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, "") == -1) {
CustomData_add_layer_named(
loopdata_out, CD_TANGENT, CD_SET_DEFAULT, nullptr, (int)loopdata_out_len, "");
loopdata_out, CD_TANGENT, CD_SET_DEFAULT, nullptr, int(loopdata_out_len), "");
}
if (calc_act && act_uv_name[0]) {
BKE_mesh_add_loop_tangent_named_layer_for_uv(
&bm->ldata, loopdata_out, (int)loopdata_out_len, act_uv_name);
&bm->ldata, loopdata_out, int(loopdata_out_len), act_uv_name);
}
if (calc_ren && ren_uv_name[0]) {
BKE_mesh_add_loop_tangent_named_layer_for_uv(
&bm->ldata, loopdata_out, (int)loopdata_out_len, ren_uv_name);
&bm->ldata, loopdata_out, int(loopdata_out_len), ren_uv_name);
}
int totface = em->tottri;
#ifdef USE_LOOPTRI_DETECT_QUADS

View File

@ -746,7 +746,7 @@ bool BKE_gpencil_stroke_stretch(bGPDstroke *gps,
* `curvature = delta angle/delta arclength = len_v3(total_angle) / overshoot_length` */
float curvature = normalize_v3(total_angle) / overshoot_length;
/* Compensate for the weights powf(added_len, segment_influence). */
curvature /= powf(overshoot_length / fminf(overshoot_parameter, (float)j), segment_influence);
curvature /= powf(overshoot_length / fminf(overshoot_parameter, float(j)), segment_influence);
if (invert_curvature) {
curvature = -curvature;
}
@ -1044,14 +1044,14 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps,
(iterations * iterations) / 4 + 2 * iterations + 12;
double w = keep_shape ? 2.0 : 1.0;
double w2 = keep_shape ?
(1.0 / M_SQRT3) * exp((2 * iterations * iterations) / (double)(n_half * 3)) :
(1.0 / M_SQRT3) * exp((2 * iterations * iterations) / double(n_half * 3)) :
0.0;
double total_w = 0.0;
for (int step = iterations; step > 0; step--) {
int before = point_index - step;
int after = point_index + step;
float w_before = (float)(w - w2);
float w_after = (float)(w - w2);
float w_before = float(w - w2);
float w_after = float(w - w2);
if (is_cyclic) {
before = (before % gps->totpoints + gps->totpoints) % gps->totpoints;
@ -1060,13 +1060,13 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps,
else {
if (before < 0) {
if (!smooth_caps) {
w_before *= -before / (float)point_index;
w_before *= -before / float(point_index);
}
before = 0;
}
if (after > gps->totpoints - 1) {
if (!smooth_caps) {
w_after *= (after - (gps->totpoints - 1)) / (float)(gps->totpoints - 1 - point_index);
w_after *= (after - (gps->totpoints - 1)) / float(gps->totpoints - 1 - point_index);
}
after = gps->totpoints - 1;
}
@ -1081,14 +1081,14 @@ bool BKE_gpencil_stroke_smooth_point(bGPDstroke *gps,
total_w += w_before;
total_w += w_after;
w *= (n_half + step) / (double)(n_half + 1 - step);
w2 *= (n_half * 3 + step) / (double)(n_half * 3 + 1 - step);
w *= (n_half + step) / double(n_half + 1 - step);
w2 *= (n_half * 3 + step) / double(n_half * 3 + 1 - step);
}
total_w += w - w2;
/* The accumulated weight total_w should be
* ~sqrt(M_PI * n_half) * exp((iterations * iterations) / n_half) < 100
* here, but sometimes not quite. */
mul_v3_fl(sco, (float)(1.0 / total_w));
mul_v3_fl(sco, float(1.0 / total_w));
/* Shift back to global coordinates. */
add_v3_v3(sco, &pt->x);
@ -1123,8 +1123,8 @@ bool BKE_gpencil_stroke_smooth_strength(
for (int step = iterations; step > 0; step--) {
int before = point_index - step;
int after = point_index + step;
float w_before = (float)w;
float w_after = (float)w;
float w_before = float(w);
float w_after = float(w);
if (is_cyclic) {
before = (before % gps->totpoints + gps->totpoints) % gps->totpoints;
@ -1142,7 +1142,7 @@ bool BKE_gpencil_stroke_smooth_strength(
total_w += w_before;
total_w += w_after;
w *= (n_half + step) / (double)(n_half + 1 - step);
w *= (n_half + step) / double(n_half + 1 - step);
}
total_w += w;
/* The accumulated weight total_w should be
@ -1181,8 +1181,8 @@ bool BKE_gpencil_stroke_smooth_thickness(
for (int step = iterations; step > 0; step--) {
int before = point_index - step;
int after = point_index + step;
float w_before = (float)w;
float w_after = (float)w;
float w_before = float(w);
float w_after = float(w);
if (is_cyclic) {
before = (before % gps->totpoints + gps->totpoints) % gps->totpoints;
@ -1200,7 +1200,7 @@ bool BKE_gpencil_stroke_smooth_thickness(
total_w += w_before;
total_w += w_after;
w *= (n_half + step) / (double)(n_half + 1 - step);
w *= (n_half + step) / double(n_half + 1 - step);
}
total_w += w;
/* The accumulated weight total_w should be
@ -1251,8 +1251,8 @@ bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps,
for (int step = iterations; step > 0; step--) {
int before = point_index - step;
int after = point_index + step;
float w_before = (float)w;
float w_after = (float)w;
float w_before = float(w);
float w_after = float(w);
if (is_cyclic) {
before = (before % gps->totpoints + gps->totpoints) % gps->totpoints;
@ -1260,11 +1260,11 @@ bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps,
}
else {
if (before < 0) {
w_before *= -before / (float)point_index;
w_before *= -before / float(point_index);
before = 0;
}
if (after > gps->totpoints - 1) {
w_after *= (after - (gps->totpoints - 1)) / (float)(gps->totpoints - 1 - point_index);
w_after *= (after - (gps->totpoints - 1)) / float(gps->totpoints - 1 - point_index);
after = gps->totpoints - 1;
}
}
@ -1278,7 +1278,7 @@ bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps,
total_w += w_before;
total_w += w_after;
w *= (n_half + step) / (double)(n_half + 1 - step);
w *= (n_half + step) / double(n_half + 1 - step);
}
total_w += w;
/* The accumulated weight total_w should be
@ -1353,7 +1353,7 @@ void BKE_gpencil_stroke_2d_flat(const bGPDspoint *points,
const bGPDspoint *pt0 = &points[0];
const bGPDspoint *pt1 = &points[1];
const bGPDspoint *pt3 = &points[(int)(totpoints * 0.75)];
const bGPDspoint *pt3 = &points[int(totpoints * 0.75)];
float locx[3];
float locy[3];
@ -1430,7 +1430,7 @@ void BKE_gpencil_stroke_2d_flat_ref(const bGPDspoint *ref_points,
const bGPDspoint *pt0 = &ref_points[0];
const bGPDspoint *pt1 = &ref_points[1];
const bGPDspoint *pt3 = &ref_points[(int)(ref_totpoints * 0.75)];
const bGPDspoint *pt3 = &ref_points[int(ref_totpoints * 0.75)];
float locx[3];
float locy[3];
@ -1499,7 +1499,7 @@ void BKE_gpencil_stroke_2d_flat_ref(const bGPDspoint *ref_points,
}
/* Concave (-1), Convex (1), or Auto-detect (0)? */
*r_direction = (int)locy[2];
*r_direction = int(locy[2]);
}
/* Calc texture coordinates using flat projected points. */
@ -1564,7 +1564,7 @@ void BKE_gpencil_stroke_fill_triangulate(bGPDstroke *gps)
/* convert to 2d and triangulate */
BKE_gpencil_stroke_2d_flat(gps->points, gps->totpoints, points2d, &direction);
BLI_polyfill_calc(points2d, (uint)gps->totpoints, direction, tmp_triangles);
BLI_polyfill_calc(points2d, uint(gps->totpoints), direction, tmp_triangles);
/* calc texture coordinates automatically */
float minv[2];
@ -1844,7 +1844,7 @@ bool BKE_gpencil_stroke_close(bGPDstroke *gps)
pt2 = &gps->points[0];
bGPDspoint *pt = &gps->points[old_tot];
for (int i = 1; i < tot_newpoints + 1; i++, pt++) {
float step = (tot_newpoints > 1) ? ((float)i / (float)tot_newpoints) : 0.99f;
float step = (tot_newpoints > 1) ? (float(i) / float(tot_newpoints)) : 0.99f;
/* Clamp last point to be near, but not on top of first point. */
if ((tot_newpoints > 1) && (i == tot_newpoints)) {
step *= 0.99f;
@ -1988,7 +1988,7 @@ void BKE_gpencil_stroke_normal(const bGPDstroke *gps, float r_normal[3])
const bGPDspoint *pt0 = &points[0];
const bGPDspoint *pt1 = &points[1];
const bGPDspoint *pt3 = &points[(int)(totpoints * 0.75)];
const bGPDspoint *pt3 = &points[int(totpoints * 0.75)];
float vec1[3];
float vec2[3];
@ -3117,7 +3117,7 @@ bGPDstroke *BKE_gpencil_stroke_delete_tagged_points(bGPdata *gpd,
bGPDstroke *new_stroke = nullptr;
bGPDstroke *gps_first = nullptr;
const bool is_cyclic = (bool)(gps->flag & GP_STROKE_CYCLIC);
const bool is_cyclic = bool(gps->flag & GP_STROKE_CYCLIC);
/* First Pass: Identify start/end of islands */
bGPDspoint *pt = gps->points;
@ -3210,7 +3210,7 @@ bGPDstroke *BKE_gpencil_stroke_delete_tagged_points(bGPdata *gpd,
float delta = gps->points[island->start_idx].time;
int j;
new_stroke->inittime += (double)delta;
new_stroke->inittime += double(delta);
pts = new_stroke->points;
for (j = 0; j < new_stroke->totpoints; j++, pts++) {
@ -3502,7 +3502,7 @@ void BKE_gpencil_stroke_join(bGPDstroke *gps_a,
/* Ratio to apply in the points to keep the same thickness in the joined stroke using the
* destination stroke thickness. */
const float ratio = (fit_thickness && gps_a->thickness > 0.0f) ?
(float)gps_b->thickness / (float)gps_a->thickness :
float(gps_b->thickness) / float(gps_a->thickness) :
1.0f;
/* 3rd: add all points */
@ -3863,7 +3863,7 @@ static int generate_arc_from_point_to_point(ListBase *list,
* points to insert. */
int num_points = (int)(((1 << (subdivisions + 1)) - 1) * (angle / M_PI));
if (num_points > 0) {
float angle_incr = angle / (float)num_points;
float angle_incr = angle / float(num_points);
float vec_p[3];
float vec_t[3];
@ -3918,7 +3918,7 @@ static int generate_semi_circle_from_point_to_point(ListBase *list,
}
float vec_p[3];
float angle_incr = M_PI / ((float)num_points - 1);
float angle_incr = M_PI / (float(num_points) - 1);
tPerimeterPoint *last_point = from;
for (int i = 1; i < num_points; i++) {
@ -4324,7 +4324,7 @@ float BKE_gpencil_stroke_average_pressure_get(bGPDstroke *gps)
tot += pt->pressure;
}
return tot / (float)gps->totpoints;
return tot / float(gps->totpoints);
}
bool BKE_gpencil_stroke_is_pressure_constant(bGPDstroke *gps)

View File

@ -479,7 +479,7 @@ PreviewImage *BKE_previewimg_cached_thumbnail_read(const char *name,
if (prv && force_update) {
const char *prv_deferred_data = (char *)PRV_DEFERRED_DATA(prv);
if (((int)prv_deferred_data[0] == source) && STREQ(&prv_deferred_data[1], filepath)) {
if ((int(prv_deferred_data[0]) == source) && STREQ(&prv_deferred_data[1], filepath)) {
/* If same filepath, no need to re-allocate preview, just clear it up. */
BKE_previewimg_clear(prv);
}

View File

@ -256,7 +256,7 @@ static void image_foreach_cache(ID *id,
function_callback(id, &key, (void **)&image->rr, 0, user_data);
LISTBASE_FOREACH (RenderSlot *, slot, &image->renderslots) {
key.offset_in_ID = (size_t)BLI_ghashutil_strhash_p(slot->name);
key.offset_in_ID = size_t(BLI_ghashutil_strhash_p(slot->name));
function_callback(id, &key, (void **)&slot->render, 0, user_data);
}
}
@ -846,8 +846,8 @@ int BKE_image_get_tile_from_pos(Image *ima, const float uv[2], float r_uv[2], fl
return 0;
}
int ix = (int)uv[0];
int iy = (int)uv[1];
int ix = int(uv[0]);
int iy = int(uv[1]);
int tile_number = 1001 + 10 * iy + ix;
if (BKE_image_get_tile(ima, tile_number) == nullptr) {
@ -1534,14 +1534,14 @@ void BKE_image_print_memlist(Main *bmain)
totsize += image_mem_size(ima);
}
printf("\ntotal image memory len: %.3f MB\n", (double)totsize / (double)(1024 * 1024));
printf("\ntotal image memory len: %.3f MB\n", double(totsize) / double(1024 * 1024));
for (ima = static_cast<Image *>(bmain->images.first); ima;
ima = static_cast<Image *>(ima->id.next)) {
size = image_mem_size(ima);
if (size) {
printf("%s len: %.3f MB\n", ima->id.name + 2, (double)size / (double)(1024 * 1024));
printf("%s len: %.3f MB\n", ima->id.name + 2, double(size) / double(1024 * 1024));
}
}
}
@ -1967,7 +1967,7 @@ void BKE_image_stamp_buf(Scene *scene,
* for now though this is only used for renders which use scene settings */
#define TEXT_SIZE_CHECK(str, w, h) \
((str[0]) && ((void)(h = h_fixed), (w = (int)BLF_width(mono, str, sizeof(str)))))
((str[0]) && ((void)(h = h_fixed), (w = int(BLF_width(mono, str, sizeof(str))))))
/* must enable BLF_WORD_WRAP before using */
#define TEXT_SIZE_CHECK_WORD_WRAP(str, w, h) \
@ -5187,8 +5187,8 @@ void BKE_image_get_size_fl(Image *image, ImageUser *iuser, float r_size[2])
int width, height;
BKE_image_get_size(image, iuser, &width, &height);
r_size[0] = (float)width;
r_size[1] = (float)height;
r_size[0] = float(width);
r_size[1] = float(height);
}
void BKE_image_get_aspect(Image *image, float *r_aspx, float *r_aspy)

View File

@ -551,7 +551,7 @@ void BKE_image_free_anim_gputextures(Main *bmain)
void BKE_image_free_old_gputextures(Main *bmain)
{
static int lasttime = 0;
int ctime = (int)PIL_check_seconds_timer();
int ctime = int(PIL_check_seconds_timer());
/*
* Run garbage collector once for every collecting period of time
@ -602,8 +602,8 @@ static ImBuf *update_do_scale(uchar *rect,
int full_h)
{
/* Partial update with scaling. */
float xratio = limit_w / (float)full_w;
float yratio = limit_h / (float)full_h;
float xratio = limit_w / float(full_w);
float yratio = limit_h / float(full_h);
int part_w = *w, part_h = *h;
@ -611,8 +611,8 @@ static ImBuf *update_do_scale(uchar *rect,
* losing 1 pixel due to rounding errors in x,y. */
*x *= xratio;
*y *= yratio;
*w = (int)ceil(xratio * (*w));
*h = (int)ceil(yratio * (*h));
*w = int(ceil(xratio * (*w)));
*h = int(ceil(yratio * (*h)));
/* ...but take back if we are over the limit! */
if (*x + *w > limit_w) {

View File

@ -62,7 +62,7 @@ static bool id_name_final_build(char *name, char *base_name, size_t base_name_le
/* Code above may have generated invalid utf-8 string, due to raw truncation.
* Ensure we get a valid one now. */
base_name_len -= (size_t)BLI_str_utf8_invalid_strip(base_name, base_name_len);
base_name_len -= size_t(BLI_str_utf8_invalid_strip(base_name, base_name_len));
/* Also truncate orig name, and start the whole check again. */
name[base_name_len] = '\0';

View File

@ -529,7 +529,7 @@ bool BKE_mball_center_median(const MetaBall *mb, float r_cent[3])
}
if (total) {
mul_v3_fl(r_cent, 1.0f / (float)total);
mul_v3_fl(r_cent, 1.0f / float(total));
}
return (total != 0);

View File

@ -1396,7 +1396,7 @@ void BKE_mesh_material_remap(Mesh *me, const uint *remap, uint remap_len)
{
using namespace blender;
using namespace blender::bke;
const short remap_len_short = (short)remap_len;
const short remap_len_short = short(remap_len);
#define MAT_NR_REMAP(n) \
if (n < remap_len_short) { \
@ -1832,7 +1832,7 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh,
* only in case auto-smooth is enabled. */
const bool use_split_normals = (r_lnors_spacearr != nullptr) ||
((mesh->flag & ME_AUTOSMOOTH) != 0);
const float split_angle = (mesh->flag & ME_AUTOSMOOTH) != 0 ? mesh->smoothresh : (float)M_PI;
const float split_angle = (mesh->flag & ME_AUTOSMOOTH) != 0 ? mesh->smoothresh : float(M_PI);
/* may be nullptr */
clnors = (short(*)[2])CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL);

View File

@ -274,13 +274,13 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
mloop[0].v = startvert + index[0];
mloop[1].v = startvert + index[2];
mloop[2].v = startvert + index[1];
mpoly->loopstart = (int)(mloop - loops.data());
mpoly->loopstart = int(mloop - loops.data());
mpoly->totloop = 3;
material_indices.span[mpoly - polys.data()] = dl->col;
if (mloopuv) {
for (int i = 0; i < 3; i++, mloopuv++) {
mloopuv->uv[0] = (mloop[i].v - startvert) / (float)(dl->nr - 1);
mloopuv->uv[0] = (mloop[i].v - startvert) / float(dl->nr - 1);
mloopuv->uv[1] = 0.0f;
}
}
@ -334,7 +334,7 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
mloop[1].v = p3;
mloop[2].v = p4;
mloop[3].v = p2;
mpoly->loopstart = (int)(mloop - loops.data());
mpoly->loopstart = int(mloop - loops.data());
mpoly->totloop = 4;
material_indices.span[mpoly - polys.data()] = dl->col;
@ -357,8 +357,8 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
/* find uv based on vertex index into grid array */
int v = mloop[i].v - startvert;
mloopuv->uv[0] = (v / dl->nr) / (float)orco_sizev;
mloopuv->uv[1] = (v % dl->nr) / (float)orco_sizeu;
mloopuv->uv[0] = (v / dl->nr) / float(orco_sizev);
mloopuv->uv[1] = (v % dl->nr) / float(orco_sizeu);
/* cyclic correction */
if ((ELEM(i, 1, 2)) && mloopuv->uv[0] == 0.0f) {
@ -1133,11 +1133,11 @@ static void add_shapekey_layers(Mesh *mesh_dest, Mesh *mesh_src)
mesh_src->totvert,
kb->name,
kb->totelem);
array = (float *)MEM_calloc_arrayN((size_t)mesh_src->totvert, sizeof(float[3]), __func__);
array = (float *)MEM_calloc_arrayN(size_t(mesh_src->totvert), sizeof(float[3]), __func__);
}
else {
array = (float *)MEM_malloc_arrayN((size_t)mesh_src->totvert, sizeof(float[3]), __func__);
memcpy(array, kb->data, sizeof(float[3]) * (size_t)mesh_src->totvert);
array = (float *)MEM_malloc_arrayN(size_t(mesh_src->totvert), sizeof(float[3]), __func__);
memcpy(array, kb->data, sizeof(float[3]) * size_t(mesh_src->totvert));
}
CustomData_add_layer_named(

View File

@ -150,7 +150,7 @@ static void mesh_calc_ngon_center(const MPoly *mpoly,
const MVert *mvert,
float cent[3])
{
const float w = 1.0f / (float)mpoly->totloop;
const float w = 1.0f / float(mpoly->totloop);
zero_v3(cent);
@ -190,7 +190,7 @@ float BKE_mesh_calc_poly_area(const MPoly *mpoly, const MLoop *loopstart, const
}
const MLoop *l_iter = loopstart;
float(*vertexcos)[3] = (float(*)[3])BLI_array_alloca(vertexcos, (size_t)mpoly->totloop);
float(*vertexcos)[3] = (float(*)[3])BLI_array_alloca(vertexcos, size_t(mpoly->totloop));
/* pack vertex cos into an array for area_poly_v3 */
for (int i = 0; i < mpoly->totloop; i++, l_iter++) {
@ -198,7 +198,7 @@ float BKE_mesh_calc_poly_area(const MPoly *mpoly, const MLoop *loopstart, const
}
/* finally calculate the area */
float area = area_poly_v3((const float(*)[3])vertexcos, (uint)mpoly->totloop);
float area = area_poly_v3((const float(*)[3])vertexcos, uint(mpoly->totloop));
return area;
}
@ -221,7 +221,7 @@ float BKE_mesh_calc_poly_uv_area(const MPoly *mpoly, const MLoopUV *uv_array)
int i, l_iter = mpoly->loopstart;
float area;
float(*vertexcos)[2] = (float(*)[2])BLI_array_alloca(vertexcos, (size_t)mpoly->totloop);
float(*vertexcos)[2] = (float(*)[2])BLI_array_alloca(vertexcos, size_t(mpoly->totloop));
/* pack vertex cos into an array for area_poly_v2 */
for (i = 0; i < mpoly->totloop; i++, l_iter++) {
@ -229,7 +229,7 @@ float BKE_mesh_calc_poly_uv_area(const MPoly *mpoly, const MLoopUV *uv_array)
}
/* finally calculate the area */
area = area_poly_v2(vertexcos, (uint)mpoly->totloop);
area = area_poly_v2(vertexcos, uint(mpoly->totloop));
return area;
}
@ -407,7 +407,7 @@ bool BKE_mesh_center_median(const Mesh *me, float r_cent[3])
}
/* otherwise we get NAN for 0 verts */
if (me->totvert) {
mul_v3_fl(r_cent, 1.0f / (float)me->totvert);
mul_v3_fl(r_cent, 1.0f / float(me->totvert));
}
return (me->totvert != 0);
}
@ -428,7 +428,7 @@ bool BKE_mesh_center_median_from_polys(const Mesh *me, float r_cent[3])
}
/* otherwise we get NAN for 0 verts */
if (me->totpoly) {
mul_v3_fl(r_cent, 1.0f / (float)tot);
mul_v3_fl(r_cent, 1.0f / float(tot));
}
return (me->totpoly != 0);
}
@ -638,7 +638,7 @@ void BKE_mesh_mdisp_flip(MDisps *md, const bool use_loop_mdisp_flip)
return;
}
const int sides = (int)sqrt(md->totdisp);
const int sides = int(sqrt(md->totdisp));
float(*co)[3] = md->disps;
for (int x = 0; x < sides; x++) {
@ -922,9 +922,9 @@ void BKE_mesh_calc_relative_deform(const MPoly *mpoly,
const MPoly *mp;
int i;
int *vert_accum = (int *)MEM_calloc_arrayN((size_t)totvert, sizeof(*vert_accum), __func__);
int *vert_accum = (int *)MEM_calloc_arrayN(size_t(totvert), sizeof(*vert_accum), __func__);
memset(vert_cos_new, '\0', sizeof(*vert_cos_new) * (size_t)totvert);
memset(vert_cos_new, '\0', sizeof(*vert_cos_new) * size_t(totvert));
for (i = 0, mp = mpoly; i < totpoly; i++, mp++) {
const MLoop *loopstart = mloop + mp->loopstart;
@ -952,7 +952,7 @@ void BKE_mesh_calc_relative_deform(const MPoly *mpoly,
for (i = 0; i < totvert; i++) {
if (vert_accum[i]) {
mul_v3_fl(vert_cos_new[i], 1.0f / (float)vert_accum[i]);
mul_v3_fl(vert_cos_new[i], 1.0f / float(vert_accum[i]));
}
else {
copy_v3_v3(vert_cos_new[i], vert_cos_org[i]);

View File

@ -82,7 +82,7 @@ class FairingContext {
LoopWeight *loop_weight)
{
fair_verts_ex(affected, (int)depth, vertex_weight, loop_weight);
fair_verts_ex(affected, int(depth), vertex_weight, loop_weight);
}
protected:

View File

@ -110,24 +110,24 @@ static void bm_corners_to_loops_ex(ID *id,
BLI_assert(fd->totdisp == 0);
}
else {
const int side = (int)sqrtf((float)(fd->totdisp / corners));
const int side = int(sqrtf(float(fd->totdisp / corners)));
const int side_sq = side * side;
for (int i = 0; i < tot; i++, disps += side_sq, ld++) {
ld->totdisp = side_sq;
ld->level = (int)(logf((float)side - 1.0f) / (float)M_LN2) + 1;
ld->level = int(logf(float(side) - 1.0f) / float(M_LN2)) + 1;
if (ld->disps) {
MEM_freeN(ld->disps);
}
ld->disps = (float(*)[3])MEM_malloc_arrayN(
(size_t)side_sq, sizeof(float[3]), "converted loop mdisps");
size_t(side_sq), sizeof(float[3]), "converted loop mdisps");
if (fd->disps) {
memcpy(ld->disps, disps, (size_t)side_sq * sizeof(float[3]));
memcpy(ld->disps, disps, size_t(side_sq) * sizeof(float[3]));
}
else {
memset(ld->disps, 0, (size_t)side_sq * sizeof(float[3]));
memset(ld->disps, 0, size_t(side_sq) * sizeof(float[3]));
}
}
}
@ -212,7 +212,7 @@ static void convert_mfaces_to_mpolys(ID *id,
CustomData_external_read(fdata, id, CD_MASK_MDISPS, totface_i);
}
eh = BLI_edgehash_new_ex(__func__, (uint)totedge_i);
eh = BLI_edgehash_new_ex(__func__, uint(totedge_i));
/* build edge hash */
me = medge;
@ -609,15 +609,15 @@ static int mesh_tessface_calc(CustomData *fdata,
* if all faces are triangles it will be correct, `quads == 2x` allocations. */
/* Take care since memory is _not_ zeroed so be sure to initialize each field. */
mface_to_poly_map = (int *)MEM_malloc_arrayN(
(size_t)looptri_num, sizeof(*mface_to_poly_map), __func__);
mface = (MFace *)MEM_malloc_arrayN((size_t)looptri_num, sizeof(*mface), __func__);
lindices = (uint(*)[4])MEM_malloc_arrayN((size_t)looptri_num, sizeof(*lindices), __func__);
size_t(looptri_num), sizeof(*mface_to_poly_map), __func__);
mface = (MFace *)MEM_malloc_arrayN(size_t(looptri_num), sizeof(*mface), __func__);
lindices = (uint(*)[4])MEM_malloc_arrayN(size_t(looptri_num), sizeof(*lindices), __func__);
mface_index = 0;
mp = mpoly;
for (poly_index = 0; poly_index < totpoly; poly_index++, mp++) {
const uint mp_loopstart = (uint)mp->loopstart;
const uint mp_totloop = (uint)mp->totloop;
const uint mp_loopstart = uint(mp->loopstart);
const uint mp_totloop = uint(mp->totloop);
uint l1, l2, l3, l4;
uint *lidx;
if (mp_totloop < 3) {
@ -701,8 +701,8 @@ static int mesh_tessface_calc(CustomData *fdata,
arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
}
tris = (uint(*)[3])BLI_memarena_alloc(arena, sizeof(*tris) * (size_t)totfilltri);
projverts = (float(*)[2])BLI_memarena_alloc(arena, sizeof(*projverts) * (size_t)mp_totloop);
tris = (uint(*)[3])BLI_memarena_alloc(arena, sizeof(*tris) * size_t(totfilltri));
projverts = (float(*)[2])BLI_memarena_alloc(arena, sizeof(*projverts) * size_t(mp_totloop));
zero_v3(normal);
@ -774,9 +774,9 @@ static int mesh_tessface_calc(CustomData *fdata,
/* Not essential but without this we store over-allocated memory in the #CustomData layers. */
if (LIKELY(looptri_num != totface)) {
mface = (MFace *)MEM_reallocN(mface, sizeof(*mface) * (size_t)totface);
mface = (MFace *)MEM_reallocN(mface, sizeof(*mface) * size_t(totface));
mface_to_poly_map = (int *)MEM_reallocN(mface_to_poly_map,
sizeof(*mface_to_poly_map) * (size_t)totface);
sizeof(*mface_to_poly_map) * size_t(totface));
}
CustomData_add_layer(fdata, CD_MFACE, CD_ASSIGN, mface, totface);

View File

@ -64,7 +64,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
}
vmap = (UvVertMap *)MEM_callocN(sizeof(*vmap), "UvVertMap");
buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * (size_t)totuv, "UvMapVert");
buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * size_t(totuv), "UvMapVert");
vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert) * totvert, "UvMapVert*");
if (use_winding) {
winding = static_cast<bool *>(MEM_callocN(sizeof(*winding) * totpoly, "winding"));
@ -81,13 +81,13 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
float(*tf_uv)[2] = NULL;
if (use_winding) {
tf_uv = (float(*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, (size_t)mp->totloop);
tf_uv = (float(*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, size_t(mp->totloop));
}
nverts = mp->totloop;
for (i = 0; i < nverts; i++) {
buf->loop_of_poly_index = (ushort)i;
buf->loop_of_poly_index = ushort(i);
buf->poly_index = a;
buf->separate = 0;
buf->next = vmap->vert[mloop[mp->loopstart + i].v];
@ -101,7 +101,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
}
if (use_winding) {
winding[a] = cross_poly_v2(tf_uv, (uint)nverts) > 0;
winding[a] = cross_poly_v2(tf_uv, uint(nverts)) > 0;
}
}
}
@ -196,11 +196,11 @@ static void mesh_vert_poly_or_loop_map_create(MeshElemMap **r_map,
int totloop,
const bool do_loops)
{
MeshElemMap *map = MEM_cnew_array<MeshElemMap>((size_t)totvert, __func__);
MeshElemMap *map = MEM_cnew_array<MeshElemMap>(size_t(totvert), __func__);
int *indices, *index_iter;
int i, j;
indices = static_cast<int *>(MEM_mallocN(sizeof(int) * (size_t)totloop, __func__));
indices = static_cast<int *>(MEM_mallocN(sizeof(int) * size_t(totloop), __func__));
index_iter = indices;
/* Count number of polys for each vertex */
@ -268,8 +268,8 @@ void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map,
const MLoop *mloop,
const int UNUSED(totloop))
{
MeshElemMap *map = MEM_cnew_array<MeshElemMap>((size_t)totvert, __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int) * (size_t)totlooptri * 3, __func__));
MeshElemMap *map = MEM_cnew_array<MeshElemMap>(size_t(totvert), __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int) * size_t(totlooptri) * 3, __func__));
int *index_step;
const MLoopTri *mlt;
int i;
@ -306,8 +306,8 @@ void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map,
void BKE_mesh_vert_edge_map_create(
MeshElemMap **r_map, int **r_mem, const MEdge *medge, int totvert, int totedge)
{
MeshElemMap *map = MEM_cnew_array<MeshElemMap>((size_t)totvert, __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int[2]) * (size_t)totedge, __func__));
MeshElemMap *map = MEM_cnew_array<MeshElemMap>(size_t(totvert), __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int[2]) * size_t(totedge), __func__));
int *i_pt = indices;
int i;
@ -345,8 +345,8 @@ void BKE_mesh_vert_edge_map_create(
void BKE_mesh_vert_edge_vert_map_create(
MeshElemMap **r_map, int **r_mem, const MEdge *medge, int totvert, int totedge)
{
MeshElemMap *map = MEM_cnew_array<MeshElemMap>((size_t)totvert, __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int[2]) * (size_t)totedge, __func__));
MeshElemMap *map = MEM_cnew_array<MeshElemMap>(size_t(totvert), __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int[2]) * size_t(totedge), __func__));
int *i_pt = indices;
int i;
@ -370,8 +370,8 @@ void BKE_mesh_vert_edge_vert_map_create(
for (i = 0; i < totedge; i++) {
const uint v[2] = {medge[i].v1, medge[i].v2};
map[v[0]].indices[map[v[0]].count] = (int)v[1];
map[v[1]].indices[map[v[1]].count] = (int)v[0];
map[v[0]].indices[map[v[0]].count] = int(v[1]);
map[v[1]].indices[map[v[1]].count] = int(v[0]);
map[v[0]].count++;
map[v[1]].count++;
@ -390,8 +390,8 @@ void BKE_mesh_edge_loop_map_create(MeshElemMap **r_map,
const MLoop *mloop,
const int totloop)
{
MeshElemMap *map = MEM_cnew_array<MeshElemMap>((size_t)totedge, __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int) * (size_t)totloop * 2, __func__));
MeshElemMap *map = MEM_cnew_array<MeshElemMap>(size_t(totedge), __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int) * size_t(totloop) * 2, __func__));
int *index_step;
const MPoly *mp;
int i;
@ -443,8 +443,8 @@ void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map,
const MLoop *mloop,
const int totloop)
{
MeshElemMap *map = MEM_cnew_array<MeshElemMap>((size_t)totedge, __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int) * (size_t)totloop, __func__));
MeshElemMap *map = MEM_cnew_array<MeshElemMap>(size_t(totedge), __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int) * size_t(totloop), __func__));
int *index_step;
const MPoly *mp;
int i;
@ -488,8 +488,8 @@ void BKE_mesh_origindex_map_create(MeshElemMap **r_map,
const int *final_origindex,
const int totfinal)
{
MeshElemMap *map = MEM_cnew_array<MeshElemMap>((size_t)totsource, __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int) * (size_t)totfinal, __func__));
MeshElemMap *map = MEM_cnew_array<MeshElemMap>(size_t(totsource), __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int) * size_t(totfinal), __func__));
int *index_step;
int i;
@ -530,8 +530,8 @@ void BKE_mesh_origindex_map_create_looptri(MeshElemMap **r_map,
const MLoopTri *looptri,
const int looptri_num)
{
MeshElemMap *map = MEM_cnew_array<MeshElemMap>((size_t)mpoly_num, __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int) * (size_t)looptri_num, __func__));
MeshElemMap *map = MEM_cnew_array<MeshElemMap>(size_t(mpoly_num), __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int) * size_t(looptri_num), __func__));
int *index_step;
int i;
@ -662,7 +662,7 @@ static void poly_edge_loop_islands_calc(const MEdge *medge,
mp = &mpoly[poly];
for (ml = &mloop[mp->loopstart], j = mp->totloop; j--; ml++) {
/* loop over poly users */
const int me_idx = (int)ml->e;
const int me_idx = int(ml->e);
const MEdge *me = &medge[me_idx];
const MeshElemMap *map_ele = &edge_poly_map[me_idx];
const int *p = map_ele->indices;
@ -1097,7 +1097,7 @@ static bool mesh_calc_islands_loop_poly_uv(const MVert *UNUSED(verts),
(edge_border_count[ml->e] < 2)) {
edge_border_count[ml->e]++;
if (edge_border_count[ml->e] == 2) {
edge_innercut_indices[num_einnercuts++] = (int)ml->e;
edge_innercut_indices[num_einnercuts++] = int(ml->e);
}
}
}

View File

@ -69,7 +69,7 @@ static void merge_uvs_for_vertex(const Span<int> loops_for_vert, Span<MLoopUV *>
BLI_assert(loops_merge.is_empty());
loops_merge.extend_unchecked(loops_for_vert);
while (loops_merge.size() > 1) {
uint i_last = (uint)loops_merge.size() - 1;
uint i_last = uint(loops_merge.size()) - 1;
const float *uv_src = mloopuv[loops_merge[0]].uv;
for (uint i = 1; i <= i_last;) {
float *uv_dst = mloopuv[loops_merge[i]].uv;

View File

@ -320,7 +320,7 @@ void BKE_mesh_calc_normals_poly_and_vertex(const MVert *mvert,
BLI_parallel_range_settings_defaults(&settings);
settings.min_iter_per_thread = 1024;
memset(r_vert_normals, 0, sizeof(*r_vert_normals) * (size_t)mvert_len);
memset(r_vert_normals, 0, sizeof(*r_vert_normals) * size_t(mvert_len));
MeshCalcNormalsData_PolyAndVertex data = {};
data.mpoly = mpoly;
@ -476,10 +476,10 @@ void BKE_mesh_calc_normals_looptri(MVert *mverts,
int looptri_num,
float (*r_tri_nors)[3])
{
float(*tnorms)[3] = (float(*)[3])MEM_calloc_arrayN((size_t)numVerts, sizeof(*tnorms), "tnorms");
float(*tnorms)[3] = (float(*)[3])MEM_calloc_arrayN(size_t(numVerts), sizeof(*tnorms), "tnorms");
float(*fnors)[3] = (r_tri_nors) ? r_tri_nors :
(float(*)[3])MEM_calloc_arrayN(
(size_t)looptri_num, sizeof(*fnors), "meshnormals");
size_t(looptri_num), sizeof(*fnors), "meshnormals");
if (!tnorms || !fnors) {
goto cleanup;
@ -535,9 +535,9 @@ void BKE_lnor_spacearr_init(MLoopNorSpaceArray *lnors_spacearr,
}
mem = lnors_spacearr->mem;
lnors_spacearr->lspacearr = (MLoopNorSpace **)BLI_memarena_calloc(
mem, sizeof(MLoopNorSpace *) * (size_t)numLoops);
mem, sizeof(MLoopNorSpace *) * size_t(numLoops));
lnors_spacearr->loops_pool = (LinkNode *)BLI_memarena_alloc(
mem, sizeof(LinkNode) * (size_t)numLoops);
mem, sizeof(LinkNode) * size_t(numLoops));
lnors_spacearr->spaces_num = 0;
}
@ -598,7 +598,7 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
float vec_other[3],
BLI_Stack *edge_vectors)
{
const float pi2 = (float)M_PI * 2.0f;
const float pi2 = float(M_PI) * 2.0f;
float tvec[3], dtp;
const float dtp_ref = dot_v3v3(vec_ref, lnor);
const float dtp_other = dot_v3v3(vec_other, lnor);
@ -632,7 +632,7 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
* a smooth vertex with only two edges and two faces (our Monkey's nose has that, e.g.).
*/
BLI_assert(count >= 2); /* This piece of code shall only be called for more than one loop. */
lnor_space->ref_alpha = alpha / (float)count;
lnor_space->ref_alpha = alpha / float(count);
}
else {
lnor_space->ref_alpha = (saacosf(dot_v3v3(vec_ref, lnor)) +
@ -690,13 +690,13 @@ void BKE_lnor_space_add_loop(MLoopNorSpaceArray *lnors_spacearr,
MINLINE float unit_short_to_float(const short val)
{
return (float)val / (float)SHRT_MAX;
return float(val) / float(SHRT_MAX);
}
MINLINE short unit_float_to_short(const float val)
{
/* Rounding. */
return (short)floorf(val * (float)SHRT_MAX + 0.5f);
return short(floorf(val * float(SHRT_MAX) + 0.5f));
}
void BKE_lnor_space_custom_data_to_normal(MLoopNorSpace *lnor_space,
@ -712,7 +712,7 @@ void BKE_lnor_space_custom_data_to_normal(MLoopNorSpace *lnor_space,
{
/* TODO: Check whether using #sincosf() gives any noticeable benefit
* (could not even get it working under linux though)! */
const float pi2 = (float)(M_PI * 2.0);
const float pi2 = float(M_PI * 2.0);
const float alphafac = unit_short_to_float(clnor_data[0]);
const float alpha = (alphafac > 0.0f ? lnor_space->ref_alpha : pi2 - lnor_space->ref_alpha) *
alphafac;
@ -745,7 +745,7 @@ void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space,
}
{
const float pi2 = (float)(M_PI * 2.0);
const float pi2 = float(M_PI * 2.0);
const float cos_alpha = dot_v3v3(lnor_space->vec_lnor, custom_lnor);
float vec[3], cos_beta;
float alpha;
@ -955,17 +955,17 @@ void BKE_edges_sharp_from_angle_set(const struct MVert *mverts,
const int numPolys,
const float split_angle)
{
if (split_angle >= (float)M_PI) {
if (split_angle >= float(M_PI)) {
/* Nothing to do! */
return;
}
/* Mapping edge -> loops. See BKE_mesh_normals_loop_split() for details. */
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 = (int *)MEM_malloc_arrayN((size_t)numLoops, sizeof(*loop_to_poly), __func__);
int *loop_to_poly = (int *)MEM_malloc_arrayN(size_t(numLoops), sizeof(*loop_to_poly), __func__);
LoopSplitTaskDataCommon common_data = {};
common_data.mverts = mverts;
@ -1278,8 +1278,8 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli
}
while ((clnor = (short *)BLI_SMALLSTACK_POP(clnors))) {
// print_v2("org clnor", clnor);
clnor[0] = (short)clnors_avg[0];
clnor[1] = (short)clnors_avg[1];
clnor[0] = short(clnors_avg[0]);
clnor[1] = short(clnors_avg[1]);
}
// print_v2("new clnors", clnors_avg);
}
@ -1952,7 +1952,7 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
LinkNode *loops = lnors_spacearr.lspacearr[i]->loops;
if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) {
BLI_assert(POINTER_AS_INT(loops) == i);
const int nidx = use_vertices ? (int)mloops[i].v : i;
const int nidx = use_vertices ? int(mloops[i].v) : i;
float *nor = r_custom_loopnors[nidx];
BKE_lnor_space_custom_normal_to_data(lnors_spacearr.lspacearr[i], nor, r_clnors_data[i]);
@ -1966,7 +1966,7 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
zero_v3(avg_nor);
while (loops) {
const int lidx = POINTER_AS_INT(loops->link);
const int nidx = use_vertices ? (int)mloops[lidx].v : lidx;
const int nidx = use_vertices ? int(mloops[lidx].v) : lidx;
float *nor = r_custom_loopnors[nidx];
avg_nor_count++;
@ -1977,7 +1977,7 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
done_loops[lidx].reset();
}
mul_v3_fl(avg_nor, 1.0f / (float)avg_nor_count);
mul_v3_fl(avg_nor, 1.0f / float(avg_nor_count));
BKE_lnor_space_custom_normal_to_data(lnors_spacearr.lspacearr[i], avg_nor, clnor_data_tmp);
while ((clnor_data = (short *)BLI_SMALLSTACK_POP(clnors_data))) {
@ -2113,7 +2113,7 @@ void BKE_mesh_normals_loop_to_vertex(const int numVerts,
}
for (i = 0; i < numVerts; i++) {
mul_v3_fl(r_vert_clnors[i], 1.0f / (float)vert_loops_count[i]);
mul_v3_fl(r_vert_clnors[i], 1.0f / float(vert_loops_count[i]));
}
MEM_freeN(vert_loops_count);

View File

@ -407,8 +407,8 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source)
bvhtree.tree, target_verts[i].co, &nearest, bvhtree.nearest_callback, &bvhtree);
if (nearest.index != -1) {
memcpy(POINTER_OFFSET(target_data, (size_t)i * data_size),
POINTER_OFFSET(source_data, (size_t)nearest.index * data_size),
memcpy(POINTER_OFFSET(target_data, size_t(i) * data_size),
POINTER_OFFSET(source_data, size_t(nearest.index) * data_size),
data_size);
}
}
@ -469,11 +469,11 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source)
source_loops->count,
target_loops->indices[0]);
void *elem = POINTER_OFFSET(target_data, (size_t)target_loops->indices[0] * data_size);
void *elem = POINTER_OFFSET(target_data, size_t(target_loops->indices[0]) * data_size);
/* Copy to rest of target loops. */
for (int j = 1; j < target_loops->count; j++) {
memcpy(POINTER_OFFSET(target_data, (size_t)target_loops->indices[j] * data_size),
memcpy(POINTER_OFFSET(target_data, size_t(target_loops->indices[j]) * data_size),
elem,
data_size);
}
@ -586,7 +586,7 @@ struct Mesh *BKE_mesh_remesh_voxel_fix_poles(const Mesh *mesh)
BMVert *vert = BM_edge_other_vert(ed, v);
add_v3_v3(co, vert->co);
}
mul_v3_fl(co, 1.0f / (float)BM_vert_edge_count(v));
mul_v3_fl(co, 1.0f / float(BM_vert_edge_count(v)));
mid_v3_v3v3(v->co, v->co, co);
}
}

View File

@ -36,34 +36,34 @@
struct BKEMeshToTangent {
uint GetNumFaces()
{
return (uint)num_polys;
return uint(num_polys);
}
uint GetNumVerticesOfFace(const uint face_num)
{
return (uint)mpolys[face_num].totloop;
return uint(mpolys[face_num].totloop);
}
mikk::float3 GetPosition(const uint face_num, const uint vert_num)
{
const uint loop_idx = (uint)mpolys[face_num].loopstart + vert_num;
const uint loop_idx = uint(mpolys[face_num].loopstart) + vert_num;
return mikk::float3(mverts[mloops[loop_idx].v].co);
}
mikk::float3 GetTexCoord(const uint face_num, const uint vert_num)
{
const float *uv = luvs[(uint)mpolys[face_num].loopstart + vert_num].uv;
const float *uv = luvs[uint(mpolys[face_num].loopstart) + vert_num].uv;
return mikk::float3(uv[0], uv[1], 1.0f);
}
mikk::float3 GetNormal(const uint face_num, const uint vert_num)
{
return mikk::float3(lnors[(uint)mpolys[face_num].loopstart + vert_num]);
return mikk::float3(lnors[uint(mpolys[face_num].loopstart) + vert_num]);
}
void SetTangentSpace(const uint face_num, const uint vert_num, mikk::float3 T, bool orientation)
{
float *p_res = tangents[(uint)mpolys[face_num].loopstart + vert_num];
float *p_res = tangents[uint(mpolys[face_num].loopstart) + vert_num];
copy_v4_fl4(p_res, T.x, T.y, T.z, orientation ? 1.0f : -1.0f);
}
@ -166,9 +166,9 @@ struct SGLSLMeshToTangent {
uint GetNumFaces()
{
#ifdef USE_LOOPTRI_DETECT_QUADS
return (uint)num_face_as_quad_map;
return uint(num_face_as_quad_map);
#else
return (uint)numTessFaces;
return uint(numTessFaces);
#endif
}
@ -196,7 +196,7 @@ struct SGLSLMeshToTangent {
lt = &looptri[face_as_quad_map[face_num]];
const MPoly *mp = &mpoly[lt->poly];
if (mp->totloop == 4) {
return ((uint)mp->loopstart + vert_num);
return (uint(mp->loopstart) + vert_num);
}
/* fall through to regular triangle */
}
@ -382,7 +382,7 @@ void BKE_mesh_calc_loop_tangent_step_0(const CustomData *loopData,
add = true;
}
if (add) {
*rtangent_mask |= (short)(1 << n);
*rtangent_mask |= short(1 << n);
}
}
@ -437,21 +437,21 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
for (int i = 0; i < tangent_names_len; i++) {
if (tangent_names[i][0]) {
BKE_mesh_add_loop_tangent_named_layer_for_uv(
loopdata, loopdata_out, (int)loopdata_out_len, tangent_names[i]);
loopdata, loopdata_out, int(loopdata_out_len), tangent_names[i]);
}
}
if ((tangent_mask & DM_TANGENT_MASK_ORCO) &&
CustomData_get_named_layer_index(loopdata, CD_TANGENT, "") == -1) {
CustomData_add_layer_named(
loopdata_out, CD_TANGENT, CD_SET_DEFAULT, nullptr, (int)loopdata_out_len, "");
loopdata_out, CD_TANGENT, CD_SET_DEFAULT, nullptr, int(loopdata_out_len), "");
}
if (calc_act && act_uv_name[0]) {
BKE_mesh_add_loop_tangent_named_layer_for_uv(
loopdata, loopdata_out, (int)loopdata_out_len, act_uv_name);
loopdata, loopdata_out, int(loopdata_out_len), act_uv_name);
}
if (calc_ren && ren_uv_name[0]) {
BKE_mesh_add_loop_tangent_named_layer_for_uv(
loopdata, loopdata_out, (int)loopdata_out_len, ren_uv_name);
loopdata, loopdata_out, int(loopdata_out_len), ren_uv_name);
}
#ifdef USE_LOOPTRI_DETECT_QUADS
@ -465,7 +465,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
/* map fake face index to looptri */
face_as_quad_map = static_cast<int *>(MEM_mallocN(sizeof(int) * looptri_len, __func__));
int k, j;
for (k = 0, j = 0; j < (int)looptri_len; k++, j++) {
for (k = 0, j = 0; j < int(looptri_len); k++, j++) {
face_as_quad_map[k] = j;
/* step over all quads */
if (mpoly[looptri[j].poly].totloop == 4) {
@ -475,7 +475,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
num_face_as_quad_map = k;
}
else {
num_face_as_quad_map = (int)looptri_len;
num_face_as_quad_map = int(looptri_len);
}
#endif
@ -491,7 +491,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
int index = CustomData_get_layer_index_n(loopdata_out, CD_TANGENT, n);
BLI_assert(n < MAX_MTFACE);
SGLSLMeshToTangent *mesh2tangent = &data_array[n];
mesh2tangent->numTessFaces = (int)looptri_len;
mesh2tangent->numTessFaces = int(looptri_len);
#ifdef USE_LOOPTRI_DETECT_QUADS
mesh2tangent->face_as_quad_map = face_as_quad_map;
mesh2tangent->num_face_as_quad_map = num_face_as_quad_map;
@ -525,7 +525,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
int uv_start = CustomData_get_layer_index(loopdata, CD_MLOOPUV);
BLI_assert(uv_ind != -1 && uv_start != -1);
BLI_assert(uv_ind - uv_start < MAX_MTFACE);
tangent_mask_curr |= (short)(1 << (uv_ind - uv_start));
tangent_mask_curr |= short(1 << (uv_ind - uv_start));
}
mesh2tangent->tangent = static_cast<float(*)[4]>(loopdata_out->layers[index].data);
@ -583,10 +583,10 @@ void BKE_mesh_calc_loop_tangents(Mesh *me_eval,
BKE_mesh_calc_loop_tangent_ex(
BKE_mesh_verts(me_eval),
BKE_mesh_polys(me_eval),
(uint)me_eval->totpoly,
uint(me_eval->totpoly),
BKE_mesh_loops(me_eval),
me_eval->runtime.looptris.array,
(uint)me_eval->runtime.looptris.len,
uint(me_eval->runtime.looptris.len),
&me_eval->ldata,
calc_active_tangent,
tangent_names,
@ -598,7 +598,7 @@ void BKE_mesh_calc_loop_tangents(Mesh *me_eval,
static_cast<const float(*)[3]>(CustomData_get_layer(&me_eval->vdata, CD_ORCO)),
/* result */
&me_eval->ldata,
(uint)me_eval->totloop,
uint(me_eval->totloop),
&tangent_mask);
}

View File

@ -49,8 +49,8 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const MLoop *mloop,
const bool face_normal,
const float normal_precalc[3])
{
const uint mp_loopstart = (uint)mpoly[poly_index].loopstart;
const uint mp_totloop = (uint)mpoly[poly_index].totloop;
const uint mp_loopstart = uint(mpoly[poly_index].loopstart);
const uint mp_totloop = uint(mpoly[poly_index].totloop);
#define ML_TO_MLT(i1, i2, i3) \
{ \
@ -125,9 +125,9 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const MLoop *mloop,
}
uint(*tris)[3] = static_cast<uint(*)[3]>(
BLI_memarena_alloc(pf_arena, sizeof(*tris) * (size_t)totfilltri));
BLI_memarena_alloc(pf_arena, sizeof(*tris) * size_t(totfilltri)));
float(*projverts)[2] = static_cast<float(*)[2]>(
BLI_memarena_alloc(pf_arena, sizeof(*projverts) * (size_t)mp_totloop));
BLI_memarena_alloc(pf_arena, sizeof(*projverts) * size_t(mp_totloop)));
ml = mloop + mp_loopstart;
for (uint j = 0; j < mp_totloop; j++, ml++) {
@ -186,7 +186,7 @@ static void mesh_recalc_looptri__single_threaded(const MLoop *mloop,
uint tri_index = 0;
if (poly_normals != nullptr) {
for (uint poly_index = 0; poly_index < (uint)totpoly; poly_index++, mp++) {
for (uint poly_index = 0; poly_index < uint(totpoly); poly_index++, mp++) {
mesh_calc_tessellation_for_face_with_normal(mloop,
mpoly,
mvert,
@ -194,14 +194,14 @@ static void mesh_recalc_looptri__single_threaded(const MLoop *mloop,
&mlooptri[tri_index],
&pf_arena,
poly_normals[poly_index]);
tri_index += (uint)(mp->totloop - 2);
tri_index += uint(mp->totloop - 2);
}
}
else {
for (uint poly_index = 0; poly_index < (uint)totpoly; poly_index++, mp++) {
for (uint poly_index = 0; poly_index < uint(totpoly); poly_index++, mp++) {
mesh_calc_tessellation_for_face(
mloop, mpoly, mvert, poly_index, &mlooptri[tri_index], &pf_arena);
tri_index += (uint)(mp->totloop - 2);
tri_index += uint(mp->totloop - 2);
}
}
@ -209,7 +209,7 @@ static void mesh_recalc_looptri__single_threaded(const MLoop *mloop,
BLI_memarena_free(pf_arena);
pf_arena = nullptr;
}
BLI_assert(tri_index == (uint)poly_to_tri_count(totpoly, totloop));
BLI_assert(tri_index == uint(poly_to_tri_count(totpoly, totloop)));
UNUSED_VARS_NDEBUG(totloop);
}
@ -239,7 +239,7 @@ static void mesh_calc_tessellation_for_face_fn(void *__restrict userdata,
mesh_calc_tessellation_for_face_impl(data->mloop,
data->mpoly,
data->mvert,
(uint)index,
uint(index),
&data->mlooptri[tri_index],
&tls_data->pf_arena,
false,
@ -256,7 +256,7 @@ static void mesh_calc_tessellation_for_face_with_normal_fn(void *__restrict user
mesh_calc_tessellation_for_face_impl(data->mloop,
data->mpoly,
data->mvert,
(uint)index,
uint(index),
&data->mlooptri[tri_index],
&tls_data->pf_arena,
true,

View File

@ -987,7 +987,7 @@ static bool mesh_validate_customdata(CustomData *data,
}
}
PRINT_MSG("%s: Finished (is_valid=%d)\n\n", __func__, (int)!has_fixes);
PRINT_MSG("%s: Finished (is_valid=%d)\n\n", __func__, int(!has_fixes));
*r_change = has_fixes;

View File

@ -374,7 +374,7 @@ static void node_foreach_cache(ID *id,
if (nodetree->type == NTREE_COMPOSIT) {
LISTBASE_FOREACH (bNode *, node, &nodetree->nodes) {
if (node->type == CMP_NODE_MOVIEDISTORTION) {
key.offset_in_ID = (size_t)BLI_ghashutil_strhash_p(node->name);
key.offset_in_ID = size_t(BLI_ghashutil_strhash_p(node->name));
function_callback(id, &key, (void **)&node->storage, 0, user_data);
}
}

View File

@ -1432,7 +1432,7 @@ class NodeTreeMainUpdater {
}
/* When the hashes for the linked sockets are ready, combine them into a hash for the input
* socket. */
const uint64_t socket_ptr = (uintptr_t)&socket;
const uint64_t socket_ptr = uintptr_t(&socket);
uint32_t socket_hash = noise::hash(socket_ptr, socket_ptr >> 32);
for (const bNodeSocket *origin_socket : socket.logically_linked_sockets()) {
const uint32_t origin_socket_hash = *hash_by_socket_id[origin_socket->index_in_tree()];
@ -1457,7 +1457,7 @@ class NodeTreeMainUpdater {
}
/* When all input socket hashes have been computed, combine them into a hash for the output
* socket. */
const uint64_t socket_ptr = (uintptr_t)&socket;
const uint64_t socket_ptr = uintptr_t(&socket);
uint32_t socket_hash = noise::hash(socket_ptr, socket_ptr >> 32);
for (const bNodeSocket *input_socket : node.input_sockets()) {
if (input_socket->is_available()) {

View File

@ -211,7 +211,7 @@ static DupliObject *make_dupli(
if (dob->persistent_id[0] != INT_MAX) {
for (i = 0; i < MAX_DUPLI_RECUR; i++) {
dob->random_id = BLI_hash_int_2d(dob->random_id, (uint)dob->persistent_id[i]);
dob->random_id = BLI_hash_int_2d(dob->random_id, uint(dob->persistent_id[i]));
}
}
else {
@ -727,7 +727,7 @@ static void make_duplis_font(const DupliContext *ctx)
/* XXX That G.main is *really* ugly, but not sure what to do here.
* Definitively don't think it would be safe to put back `Main *bmain` pointer
* in #DupliContext as done in 2.7x? */
ob = find_family_object(G.main, cu->family, family_len, (uint)text[a], family_gh);
ob = find_family_object(G.main, cu->family, family_len, uint(text[a]), family_gh);
if (is_eval_curve) {
/* Workaround for the above hack. */
@ -953,7 +953,7 @@ static void get_dupliface_transform_from_coords(Span<float3> coords,
for (const float3 &coord : coords) {
location += coord;
}
location *= 1.0f / (float)coords.size();
location *= 1.0f / float(coords.size());
/* Rotation. */
float quat[4];
@ -964,7 +964,7 @@ static void get_dupliface_transform_from_coords(Span<float3> coords,
/* Scale. */
float scale;
if (use_scale) {
const float area = area_poly_v3((const float(*)[3])coords.data(), (uint)coords.size());
const float area = area_poly_v3((const float(*)[3])coords.data(), uint(coords.size()));
scale = sqrtf(area) * scale_fac;
}
else {
@ -1094,7 +1094,7 @@ static void make_child_duplis_faces_from_mesh(const DupliContext *ctx,
DupliObject *dob = face_dupli_from_mesh(
fdd->params.ctx, inst_ob, child_imat, a, use_scale, scale_fac, mp, loopstart, mvert);
const float w = 1.0f / (float)mp->totloop;
const float w = 1.0f / float(mp->totloop);
if (orco) {
for (int j = 0; j < mp->totloop; j++) {
madd_v3_v3fl(dob->orco, orco[loopstart[j].v], w);
@ -1134,7 +1134,7 @@ static void make_child_duplis_faces_from_editmesh(const DupliContext *ctx,
fdd->params.ctx, inst_ob, child_imat, a, use_scale, scale_fac, f, vert_coords);
if (fdd->has_orco) {
const float w = 1.0f / (float)f->len;
const float w = 1.0f / float(f->len);
BMLoop *l_first, *l_iter;
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
@ -1294,7 +1294,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
totpart = psys->totcached;
}
RNG *rng = BLI_rng_new_srandom(31415926u + (uint)psys->seed);
RNG *rng = BLI_rng_new_srandom(31415926u + uint(psys->seed));
psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);

View File

@ -2031,7 +2031,7 @@ int BKE_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
const MLoop *l = &loops[p->loopstart + j];
avg += paint_mask[l->v];
}
avg /= (float)p->totloop;
avg /= float(p->totloop);
/* fill in multires mask corner */
for (j = 0; j < p->totloop; j++) {

View File

@ -112,7 +112,7 @@ static void pbvh_vertex_color_get(const PBVH &pbvh, PBVHVertRef vertex, float r_
}
if (count) {
mul_v4_fl(r_color, 1.0f / (float)count);
mul_v4_fl(r_color, 1.0f / float(count));
}
}
else {

View File

@ -137,7 +137,7 @@ static void scene_init_data(ID *id)
scene->toolsettings = DNA_struct_default_alloc(ToolSettings);
scene->toolsettings->autokey_mode = (uchar)U.autokey_mode;
scene->toolsettings->autokey_mode = uchar(U.autokey_mode);
/* Grease pencil multi-frame falloff curve. */
scene->toolsettings->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
@ -156,9 +156,9 @@ static void scene_init_data(ID *id)
scene->unit.system = USER_UNIT_METRIC;
scene->unit.scale_length = 1.0f;
scene->unit.length_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_LENGTH);
scene->unit.mass_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_MASS);
scene->unit.time_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_TIME);
scene->unit.length_unit = uchar(BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_LENGTH));
scene->unit.mass_unit = uchar(BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_MASS));
scene->unit.time_unit = uchar(BKE_unit_base_of_type_get(USER_UNIT_METRIC, B_UNIT_TIME));
scene->unit.temperature_unit = (uchar)BKE_unit_base_of_type_get(USER_UNIT_METRIC,
B_UNIT_TEMPERATURE);
@ -880,7 +880,7 @@ static bool seq_foreach_path_callback(Sequence *seq, void *user_data)
}
else if ((seq->type == SEQ_TYPE_IMAGE) && se) {
/* NOTE: An option not to loop over all strips could be useful? */
uint len = (uint)MEM_allocN_len(se) / (uint)sizeof(*se);
uint len = uint(MEM_allocN_len(se)) / uint(sizeof(*se));
uint i;
if (bpath_data->flag & BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE) {
@ -1005,10 +1005,10 @@ static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_addres
if (sce->r.avicodecdata) {
BLO_write_struct(writer, AviCodecData, sce->r.avicodecdata);
if (sce->r.avicodecdata->lpFormat) {
BLO_write_raw(writer, (size_t)sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat);
BLO_write_raw(writer, size_t(sce->r.avicodecdata->cbFormat), sce->r.avicodecdata->lpFormat);
}
if (sce->r.avicodecdata->lpParms) {
BLO_write_raw(writer, (size_t)sce->r.avicodecdata->cbParms, sce->r.avicodecdata->lpParms);
BLO_write_raw(writer, size_t(sce->r.avicodecdata->cbParms), sce->r.avicodecdata->lpParms);
}
}
@ -1207,8 +1207,8 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
intptr_t seqbase_offset;
intptr_t channels_offset;
seqbase_offset = ((intptr_t) & (temp.seqbase)) - ((intptr_t)&temp);
channels_offset = ((intptr_t) & (temp.channels)) - ((intptr_t)&temp);
seqbase_offset = intptr_t(&(temp).seqbase) - intptr_t(&temp);
channels_offset = intptr_t(&(temp).channels) - intptr_t(&temp);
/* seqbase root pointer */
if (ed->seqbasep == old_seqbasep) {
@ -1326,7 +1326,7 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
/* make sure simulation starts from the beginning after loading file */
if (rbw->pointcache) {
rbw->ltime = (float)rbw->pointcache->startframe;
rbw->ltime = float(rbw->pointcache->startframe);
}
}
else {
@ -1340,7 +1340,7 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
/* make sure simulation starts from the beginning after loading file */
if (rbw->shared->pointcache) {
rbw->ltime = (float)rbw->shared->pointcache->startframe;
rbw->ltime = float(rbw->shared->pointcache->startframe);
}
}
rbw->objects = nullptr;
@ -2426,7 +2426,7 @@ void BKE_scene_frame_set(Scene *scene, float frame)
{
double intpart;
scene->r.subframe = modf((double)frame, &intpart);
scene->r.cfra = (int)intpart;
scene->r.cfra = int(intpart);
}
/* -------------------------------------------------------------------- */

View File

@ -222,7 +222,7 @@ static void vertex_interpolation_init(const SubdivMeshContext *ctx,
vertex_interpolation->vertex_data_storage_allocated = true;
/* Interpolate center of poly right away, it stays unchanged for all
* ptex faces. */
const float weight = 1.0f / (float)coarse_poly->totloop;
const float weight = 1.0f / float(coarse_poly->totloop);
blender::Array<float, 32> weights(coarse_poly->totloop);
blender::Array<int, 32> indices(coarse_poly->totloop);
for (int i = 0; i < coarse_poly->totloop; i++) {
@ -355,7 +355,7 @@ static void loop_interpolation_init(const SubdivMeshContext *ctx,
loop_interpolation->loop_data_storage_allocated = true;
/* Interpolate center of poly right away, it stays unchanged for all
* ptex faces. */
const float weight = 1.0f / (float)coarse_poly->totloop;
const float weight = 1.0f / float(coarse_poly->totloop);
blender::Array<float, 32> weights(coarse_poly->totloop);
blender::Array<int, 32> indices(coarse_poly->totloop);
for (int i = 0; i < coarse_poly->totloop; i++) {

View File

@ -49,7 +49,7 @@ static float3 float_to_float3(const float &a)
}
static int32_t float_to_int(const float &a)
{
return (int32_t)a;
return int32_t(a);
}
static bool float_to_bool(const float &a)
{
@ -79,7 +79,7 @@ static float float2_to_float(const float2 &a)
}
static int float2_to_int(const float2 &a)
{
return (int32_t)((a.x + a.y) / 2.0f);
return int32_t((a.x + a.y) / 2.0f);
}
static bool float2_to_bool(const float2 &a)
{
@ -112,7 +112,7 @@ static float float3_to_float(const float3 &a)
}
static int float3_to_int(const float3 &a)
{
return (int)((a.x + a.y + a.z) / 3.0f);
return int((a.x + a.y + a.z) / 3.0f);
}
static float2 float3_to_float2(const float3 &a)
{
@ -138,19 +138,19 @@ static int8_t int_to_int8(const int32_t &a)
}
static float int_to_float(const int32_t &a)
{
return (float)a;
return float(a);
}
static float2 int_to_float2(const int32_t &a)
{
return float2((float)a);
return float2(float(a));
}
static float3 int_to_float3(const int32_t &a)
{
return float3((float)a);
return float3(float(a));
}
static ColorGeometry4f int_to_color(const int32_t &a)
{
return ColorGeometry4f((float)a, (float)a, (float)a, 1.0f);
return ColorGeometry4f(float(a), float(a), float(a), 1.0f);
}
static ColorGeometry4b int_to_byte_color(const int32_t &a)
{
@ -167,19 +167,19 @@ static int int8_to_int(const int8_t &a)
}
static float int8_to_float(const int8_t &a)
{
return (float)a;
return float(a);
}
static float2 int8_to_float2(const int8_t &a)
{
return float2((float)a);
return float2(float(a));
}
static float3 int8_to_float3(const int8_t &a)
{
return float3((float)a);
return float3(float(a));
}
static ColorGeometry4f int8_to_color(const int8_t &a)
{
return ColorGeometry4f((float)a, (float)a, (float)a, 1.0f);
return ColorGeometry4f(float(a), float(a), float(a), 1.0f);
}
static ColorGeometry4b int8_to_byte_color(const int8_t &a)
{
@ -188,7 +188,7 @@ static ColorGeometry4b int8_to_byte_color(const int8_t &a)
static float bool_to_float(const bool &a)
{
return (bool)a;
return bool(a);
}
static int8_t bool_to_int8(const bool &a)
{
@ -196,7 +196,7 @@ static int8_t bool_to_int8(const bool &a)
}
static int32_t bool_to_int(const bool &a)
{
return (int32_t)a;
return int32_t(a);
}
static float2 bool_to_float2(const bool &a)
{
@ -225,7 +225,7 @@ static float color_to_float(const ColorGeometry4f &a)
}
static int32_t color_to_int(const ColorGeometry4f &a)
{
return (int)rgb_to_grayscale(a);
return int(rgb_to_grayscale(a));
}
static int8_t color_to_int8(const ColorGeometry4f &a)
{

View File

@ -1636,8 +1636,8 @@ bool BKE_volume_grid_bounds(openvdb::GridBase::ConstPtr grid, float3 &r_min, flo
openvdb::BBoxd bbox = grid->transform().indexToWorld(coordbbox);
r_min = float3((float)bbox.min().x(), (float)bbox.min().y(), (float)bbox.min().z());
r_max = float3((float)bbox.max().x(), (float)bbox.max().y(), (float)bbox.max().z());
r_min = float3(float(bbox.min().x()), float(bbox.min().y()), float(bbox.min().z()));
r_max = float3(float(bbox.max().x()), float(bbox.max().y()), float(bbox.max().z()));
return true;
}

View File

@ -93,7 +93,7 @@ void Graph::set_random_cluster_bgcolors()
void Cluster::set_random_cluster_bgcolors()
{
float hue = rand() / (float)RAND_MAX;
float hue = rand() / float(RAND_MAX);
float staturation = 0.3f;
float value = 0.8f;
this->attributes.set("bgcolor", color_attr_from_hsv(hue, staturation, value));
@ -227,7 +227,7 @@ void Attributes::export__as_bracket_list(std::stringstream &ss) const
void Node::export__as_id(std::stringstream &ss) const
{
ss << '"' << (uintptr_t)this << '"';
ss << '"' << uintptr_t(this) << '"';
}
void Node::export__as_declaration(std::stringstream &ss) const

View File

@ -193,7 +193,7 @@ static RobustInitCaller init_caller;
y = b - bvirt
#define Fast_Two_Sum(a, b, x, y) \
x = (double)(a + b); \
x = double(a + b); \
Fast_Two_Sum_Tail(a, b, x, y)
#define Fast_Two_Diff_Tail(a, b, x, y) \
@ -205,30 +205,30 @@ static RobustInitCaller init_caller;
Fast_Two_Diff_Tail(a, b, x, y)
#define Two_Sum_Tail(a, b, x, y) \
bvirt = (double)(x - a); \
bvirt = double(x - a); \
avirt = x - bvirt; \
bround = b - bvirt; \
around = a - avirt; \
y = around + bround
#define Two_Sum(a, b, x, y) \
x = (double)(a + b); \
x = double(a + b); \
Two_Sum_Tail(a, b, x, y)
#define Two_Diff_Tail(a, b, x, y) \
bvirt = (double)(a - x); \
bvirt = double(a - x); \
avirt = x + bvirt; \
bround = bvirt - b; \
around = a - avirt; \
y = around + bround
#define Two_Diff(a, b, x, y) \
x = (double)(a - b); \
x = double(a - b); \
Two_Diff_Tail(a, b, x, y)
#define Split(a, ahi, alo) \
c = (double)(splitter * a); \
abig = (double)(c - a); \
c = double(splitter * a); \
abig = double(c - a); \
ahi = c - abig; \
alo = a - ahi
@ -241,11 +241,11 @@ static RobustInitCaller init_caller;
y = (alo * blo) - err3
#define Two_Product(a, b, x, y) \
x = (double)(a * b); \
x = double(a * b); \
Two_Product_Tail(a, b, x, y)
#define Two_Product_Presplit(a, b, bhi, blo, x, y) \
x = (double)(a * b); \
x = double(a * b); \
Split(a, ahi, alo); \
err1 = x - (ahi * bhi); \
err2 = err1 - (alo * bhi); \
@ -266,7 +266,7 @@ static RobustInitCaller init_caller;
y = (alo * alo) - err3
#define Square(a, x, y) \
x = (double)(a * a); \
x = double(a * a); \
Square_Tail(a, x, y)
#define Two_One_Sum(a1, a0, b, x2, x1, x0) \
@ -647,10 +647,10 @@ static double orient2dadapt(const double *pa, const double *pb, const double *pc
INEXACT double _i, _j;
double _0;
acx = (double)(pa[0] - pc[0]);
bcx = (double)(pb[0] - pc[0]);
acy = (double)(pa[1] - pc[1]);
bcy = (double)(pb[1] - pc[1]);
acx = double(pa[0] - pc[0]);
bcx = double(pb[0] - pc[0]);
acy = double(pa[1] - pc[1]);
bcy = double(pb[1] - pc[1]);
Two_Product(acx, bcy, detleft, detlefttail);
Two_Product(acy, bcx, detright, detrighttail);
@ -834,15 +834,15 @@ static double orient3dadapt(
INEXACT double _i, _j, _k;
double _0;
adx = (double)(pa[0] - pd[0]);
bdx = (double)(pb[0] - pd[0]);
cdx = (double)(pc[0] - pd[0]);
ady = (double)(pa[1] - pd[1]);
bdy = (double)(pb[1] - pd[1]);
cdy = (double)(pc[1] - pd[1]);
adz = (double)(pa[2] - pd[2]);
bdz = (double)(pb[2] - pd[2]);
cdz = (double)(pc[2] - pd[2]);
adx = double(pa[0] - pd[0]);
bdx = double(pb[0] - pd[0]);
cdx = double(pc[0] - pd[0]);
ady = double(pa[1] - pd[1]);
bdy = double(pb[1] - pd[1]);
cdy = double(pc[1] - pd[1]);
adz = double(pa[2] - pd[2]);
bdz = double(pb[2] - pd[2]);
cdz = double(pc[2] - pd[2]);
Two_Product(bdx, cdy, bdxcdy1, bdxcdy0);
Two_Product(cdx, bdy, cdxbdy1, cdxbdy0);
@ -1358,12 +1358,12 @@ static double incircleadapt(
INEXACT double _i, _j;
double _0;
adx = (double)(pa[0] - pd[0]);
bdx = (double)(pb[0] - pd[0]);
cdx = (double)(pc[0] - pd[0]);
ady = (double)(pa[1] - pd[1]);
bdy = (double)(pb[1] - pd[1]);
cdy = (double)(pc[1] - pd[1]);
adx = double(pa[0] - pd[0]);
bdx = double(pb[0] - pd[0]);
cdx = double(pc[0] - pd[0]);
ady = double(pa[1] - pd[1]);
bdy = double(pb[1] - pd[1]);
cdy = double(pc[1] - pd[1]);
Two_Product(bdx, cdy, bdxcdy1, bdxcdy0);
Two_Product(cdx, bdy, cdxbdy1, cdxbdy0);

View File

@ -379,7 +379,7 @@ BLI_INLINE float noise_grad(uint32_t hash, float x, float y, float z, float w)
BLI_INLINE float floor_fraction(float x, int &i)
{
i = (int)x - ((x < 0) ? 1 : 0);
i = int(x) - ((x < 0) ? 1 : 0);
return x - i;
}
@ -729,7 +729,7 @@ float musgrave_fBm(const float co,
const float pwHL = std::pow(lacunarity, -H);
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 0; i < (int)octaves; i++) {
for (int i = 0; i < int(octaves); i++) {
value += perlin_signed(p) * pwr;
pwr *= pwHL;
p *= lacunarity;
@ -754,7 +754,7 @@ float musgrave_multi_fractal(const float co,
const float pwHL = std::pow(lacunarity, -H);
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 0; i < (int)octaves; i++) {
for (int i = 0; i < int(octaves); i++) {
value *= (pwr * perlin_signed(p) + 1.0f);
pwr *= pwHL;
p *= lacunarity;
@ -783,7 +783,7 @@ float musgrave_hetero_terrain(const float co,
float value = offset + perlin_signed(p);
p *= lacunarity;
for (int i = 1; i < (int)octaves; i++) {
for (int i = 1; i < int(octaves); i++) {
float increment = (perlin_signed(p) + offset) * pwr * value;
value += increment;
pwr *= pwHL;
@ -815,7 +815,7 @@ float musgrave_hybrid_multi_fractal(const float co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 0; (weight > 0.001f) && (i < (int)octaves); i++) {
for (int i = 0; (weight > 0.001f) && (i < int(octaves)); i++) {
if (weight > 1.0f) {
weight = 1.0f;
}
@ -857,7 +857,7 @@ float musgrave_ridged_multi_fractal(const float co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 1; i < (int)octaves; i++) {
for (int i = 1; i < int(octaves); i++) {
p *= lacunarity;
weight = CLAMPIS(signal * gain, 0.0f, 1.0f);
signal = offset - std::abs(perlin_signed(p));
@ -883,7 +883,7 @@ float musgrave_fBm(const float2 co,
const float pwHL = std::pow(lacunarity, -H);
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 0; i < (int)octaves; i++) {
for (int i = 0; i < int(octaves); i++) {
value += perlin_signed(p) * pwr;
pwr *= pwHL;
p *= lacunarity;
@ -908,7 +908,7 @@ float musgrave_multi_fractal(const float2 co,
const float pwHL = std::pow(lacunarity, -H);
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 0; i < (int)octaves; i++) {
for (int i = 0; i < int(octaves); i++) {
value *= (pwr * perlin_signed(p) + 1.0f);
pwr *= pwHL;
p *= lacunarity;
@ -938,7 +938,7 @@ float musgrave_hetero_terrain(const float2 co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 1; i < (int)octaves; i++) {
for (int i = 1; i < int(octaves); i++) {
float increment = (perlin_signed(p) + offset) * pwr * value;
value += increment;
pwr *= pwHL;
@ -970,7 +970,7 @@ float musgrave_hybrid_multi_fractal(const float2 co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 0; (weight > 0.001f) && (i < (int)octaves); i++) {
for (int i = 0; (weight > 0.001f) && (i < int(octaves)); i++) {
if (weight > 1.0f) {
weight = 1.0f;
}
@ -1012,7 +1012,7 @@ float musgrave_ridged_multi_fractal(const float2 co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 1; i < (int)octaves; i++) {
for (int i = 1; i < int(octaves); i++) {
p *= lacunarity;
weight = CLAMPIS(signal * gain, 0.0f, 1.0f);
signal = offset - std::abs(perlin_signed(p));
@ -1039,7 +1039,7 @@ float musgrave_fBm(const float3 co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 0; i < (int)octaves; i++) {
for (int i = 0; i < int(octaves); i++) {
value += perlin_signed(p) * pwr;
pwr *= pwHL;
p *= lacunarity;
@ -1065,7 +1065,7 @@ float musgrave_multi_fractal(const float3 co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 0; i < (int)octaves; i++) {
for (int i = 0; i < int(octaves); i++) {
value *= (pwr * perlin_signed(p) + 1.0f);
pwr *= pwHL;
p *= lacunarity;
@ -1095,7 +1095,7 @@ float musgrave_hetero_terrain(const float3 co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 1; i < (int)octaves; i++) {
for (int i = 1; i < int(octaves); i++) {
float increment = (perlin_signed(p) + offset) * pwr * value;
value += increment;
pwr *= pwHL;
@ -1127,7 +1127,7 @@ float musgrave_hybrid_multi_fractal(const float3 co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 0; (weight > 0.001f) && (i < (int)octaves); i++) {
for (int i = 0; (weight > 0.001f) && (i < int(octaves)); i++) {
if (weight > 1.0f) {
weight = 1.0f;
}
@ -1169,7 +1169,7 @@ float musgrave_ridged_multi_fractal(const float3 co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 1; i < (int)octaves; i++) {
for (int i = 1; i < int(octaves); i++) {
p *= lacunarity;
weight = CLAMPIS(signal * gain, 0.0f, 1.0f);
signal = offset - std::abs(perlin_signed(p));
@ -1196,7 +1196,7 @@ float musgrave_fBm(const float4 co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 0; i < (int)octaves; i++) {
for (int i = 0; i < int(octaves); i++) {
value += perlin_signed(p) * pwr;
pwr *= pwHL;
p *= lacunarity;
@ -1222,7 +1222,7 @@ float musgrave_multi_fractal(const float4 co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 0; i < (int)octaves; i++) {
for (int i = 0; i < int(octaves); i++) {
value *= (pwr * perlin_signed(p) + 1.0f);
pwr *= pwHL;
p *= lacunarity;
@ -1252,7 +1252,7 @@ float musgrave_hetero_terrain(const float4 co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 1; i < (int)octaves; i++) {
for (int i = 1; i < int(octaves); i++) {
float increment = (perlin_signed(p) + offset) * pwr * value;
value += increment;
pwr *= pwHL;
@ -1284,7 +1284,7 @@ float musgrave_hybrid_multi_fractal(const float4 co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 0; (weight > 0.001f) && (i < (int)octaves); i++) {
for (int i = 0; (weight > 0.001f) && (i < int(octaves)); i++) {
if (weight > 1.0f) {
weight = 1.0f;
}
@ -1326,7 +1326,7 @@ float musgrave_ridged_multi_fractal(const float4 co,
const float octaves = CLAMPIS(octaves_unclamped, 0.0f, 15.0f);
for (int i = 1; i < (int)octaves; i++) {
for (int i = 1; i < int(octaves); i++) {
p *= lacunarity;
weight = CLAMPIS(signal * gain, 0.0f, 1.0f);
signal = offset - std::abs(perlin_signed(p));

View File

@ -161,7 +161,7 @@ void BLI_rng_shuffle_bitmap(struct RNG *rng, BLI_bitmap *bitmap, uint bits_num)
void BLI_rng_skip(RNG *rng, int n)
{
rng->rng.skip((uint)n);
rng->rng.skip(uint(n));
}
/***/
@ -239,7 +239,7 @@ RNG_THREAD_ARRAY *BLI_rng_threaded_new()
"random_array");
for (i = 0; i < BLENDER_MAX_THREADS; i++) {
BLI_rng_srandom(&rngarr->rng_tab[i], (uint)clock());
BLI_rng_srandom(&rngarr->rng_tab[i], uint(clock()));
}
return rngarr;
@ -283,7 +283,7 @@ BLI_INLINE double halton_ex(double invprimes, double *offset)
void BLI_halton_1d(uint prime, double offset, int n, double *r)
{
const double invprime = 1.0 / (double)prime;
const double invprime = 1.0 / double(prime);
*r = 0.0;
@ -294,7 +294,7 @@ void BLI_halton_1d(uint prime, double offset, int n, double *r)
void BLI_halton_2d(const uint prime[2], double offset[2], int n, double *r)
{
const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]};
const double invprimes[2] = {1.0 / double(prime[0]), 1.0 / double(prime[1])};
r[0] = r[1] = 0.0;
@ -308,7 +308,7 @@ void BLI_halton_2d(const uint prime[2], double offset[2], int n, double *r)
void BLI_halton_3d(const uint prime[3], double offset[3], int n, double *r)
{
const double invprimes[3] = {
1.0 / (double)prime[0], 1.0 / (double)prime[1], 1.0 / (double)prime[2]};
1.0 / double(prime[0]), 1.0 / double(prime[1]), 1.0 / double(prime[2])};
r[0] = r[1] = r[2] = 0.0;
@ -321,7 +321,7 @@ void BLI_halton_3d(const uint prime[3], double offset[3], int n, double *r)
void BLI_halton_2d_sequence(const uint prime[2], double offset[2], int n, double *r)
{
const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]};
const double invprimes[2] = {1.0 / double(prime[0]), 1.0 / double(prime[1])};
for (int s = 0; s < n; s++) {
for (int i = 0; i < 2; i++) {
@ -355,7 +355,7 @@ void BLI_hammersley_1d(uint n, double *r)
void BLI_hammersley_2d_sequence(uint n, double *r)
{
for (uint s = 0; s < n; s++) {
r[s * 2 + 0] = (double)(s + 0.5) / (double)n;
r[s * 2 + 0] = double(s + 0.5) / double(n);
r[s * 2 + 1] = radical_inverse(s);
}
}
@ -377,12 +377,12 @@ int RandomNumberGenerator::round_probabilistic(float x)
BLI_assert(x >= 0.0f);
const float round_up_probability = fractf(x);
const bool round_up = round_up_probability > this->get_float();
return (int)x + (int)round_up;
return int(x) + int(round_up);
}
float2 RandomNumberGenerator::get_unit_float2()
{
float a = (float)(M_PI * 2.0) * this->get_float();
float a = float(M_PI * 2.0) * this->get_float();
return {cosf(a), sinf(a)};
}
@ -391,7 +391,7 @@ float3 RandomNumberGenerator::get_unit_float3()
float z = (2.0f * this->get_float()) - 1.0f;
float r = 1.0f - z * z;
if (r > 0.0f) {
float a = (float)(M_PI * 2.0) * this->get_float();
float a = float(M_PI * 2.0) * this->get_float();
r = sqrtf(r);
float x = r * cosf(a);
float y = r * sinf(a);

View File

@ -345,7 +345,7 @@ void extract_normalized_words(StringRef str,
LinearAllocator<> &allocator,
Vector<StringRef, 64> &r_words)
{
const uint32_t unicode_space = (uint32_t)' ';
const uint32_t unicode_space = uint32_t(' ');
const uint32_t unicode_right_triangle = UI_MENU_ARROW_SEP_UNICODE;
BLI_assert(unicode_space == BLI_str_utf8_as_unicode(" "));
@ -418,7 +418,7 @@ void BLI_string_search_add(StringSearch *search,
StringRef str_ref{str};
string_search::extract_normalized_words(str_ref, search->allocator, words);
search->items.append({search->allocator.construct_array_copy(words.as_span()),
(int)str_ref.size(),
int(str_ref.size()),
user_data,
weight});
}

View File

@ -293,7 +293,7 @@ int BLI_system_thread_count()
#ifdef WIN32
SYSTEM_INFO info;
GetSystemInfo(&info);
t = (int)info.dwNumberOfProcessors;
t = int(info.dwNumberOfProcessors);
#else
# ifdef __APPLE__
int mib[2];
@ -304,7 +304,7 @@ int BLI_system_thread_count()
len = sizeof(t);
sysctl(mib, 2, &t, &len, nullptr, 0);
# else
t = (int)sysconf(_SC_NPROCESSORS_ONLN);
t = int(sysconf(_SC_NPROCESSORS_ONLN));
# endif
#endif
}

View File

@ -308,7 +308,7 @@ TEST(edgehash, StressTest)
std::vector<Edge> edges;
for (int i = 0; i < amount; i++) {
edges.push_back({(uint)i, amount + (uint)std::rand() % 12345});
edges.push_back({uint(i), amount + uint(std::rand()) % 12345});
}
EdgeHash *eh = BLI_edgehash_new(__func__);

View File

@ -20,7 +20,7 @@ TEST(generic_array, TypeConstructor)
TEST(generic_array, MoveConstructor)
{
GArray array_a(CPPType::get<int32_t>(), (int64_t)10);
GArray array_a(CPPType::get<int32_t>(), int64_t(10));
GMutableSpan span_a = array_a.as_mutable_span();
MutableSpan<int32_t> typed_span_a = span_a.typed<int32_t>();
typed_span_a.fill(42);
@ -40,7 +40,7 @@ TEST(generic_array, MoveConstructor)
TEST(generic_array, CopyConstructor)
{
GArray array_a(CPPType::get<int32_t>(), (int64_t)10);
GArray array_a(CPPType::get<int32_t>(), int64_t(10));
GMutableSpan span_a = array_a.as_mutable_span();
MutableSpan<int32_t> typed_span_a = span_a.typed<int32_t>();
typed_span_a.fill(42);
@ -79,7 +79,7 @@ TEST(generic_array, BufferAndSizeConstructor)
TEST(generic_array, Reinitialize)
{
GArray array(CPPType::get<int32_t>(), (int64_t)5);
GArray array(CPPType::get<int32_t>(), int64_t(5));
EXPECT_FALSE(array.data() == nullptr);
GMutableSpan span = array.as_mutable_span();
MutableSpan<int32_t> typed_span = span.typed<int32_t>();
@ -106,7 +106,7 @@ TEST(generic_array, InContainer)
{
blender::Array<GArray<>> arrays;
for (GArray<> &array : arrays) {
array = GArray(CPPType::get<int32_t>(), (int64_t)5);
array = GArray(CPPType::get<int32_t>(), int64_t(5));
array.as_mutable_span().typed<int32_t>().fill(55);
}
for (GArray<> &array : arrays) {

View File

@ -18,7 +18,7 @@ static void range_fl(float *array_tar, const int size)
float *array_pt = array_tar + (size - 1);
int i = size;
while (i--) {
*(array_pt--) = (float)i;
*(array_pt--) = float(i);
}
}
@ -53,7 +53,7 @@ TEST(heap, SimpleRange)
const int items_total = SIZE;
HeapSimple *heap = BLI_heapsimple_new();
for (int in = 0; in < items_total; in++) {
BLI_heapsimple_insert(heap, (float)in, POINTER_FROM_INT(in));
BLI_heapsimple_insert(heap, float(in), POINTER_FROM_INT(in));
}
for (int out_test = 0; out_test < items_total; out_test++) {
EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heapsimple_pop_min(heap)));
@ -67,7 +67,7 @@ TEST(heap, SimpleRangeReverse)
const int items_total = SIZE;
HeapSimple *heap = BLI_heapsimple_new();
for (int in = 0; in < items_total; in++) {
BLI_heapsimple_insert(heap, (float)-in, POINTER_FROM_INT(-in));
BLI_heapsimple_insert(heap, float(-in), POINTER_FROM_INT(-in));
}
for (int out_test = items_total - 1; out_test >= 0; out_test--) {
EXPECT_EQ(-out_test, POINTER_AS_INT(BLI_heapsimple_pop_min(heap)));
@ -97,7 +97,7 @@ static void random_heapsimple_helper(const int items_total, const int random_see
range_fl(values, items_total);
BLI_array_randomize(values, sizeof(float), items_total, random_seed);
for (int i = 0; i < items_total; i++) {
BLI_heapsimple_insert(heap, values[i], POINTER_FROM_INT((int)values[i]));
BLI_heapsimple_insert(heap, values[i], POINTER_FROM_INT(int(values[i])));
}
for (int out_test = 0; out_test < items_total; out_test++) {
EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heapsimple_pop_min(heap)));

View File

@ -17,7 +17,7 @@ static void range_fl(float *array_tar, const int size)
float *array_pt = array_tar + (size - 1);
int i = size;
while (i--) {
*(array_pt--) = (float)i;
*(array_pt--) = float(i);
}
}
@ -52,7 +52,7 @@ TEST(heap, Range)
const int items_total = SIZE;
Heap *heap = BLI_heap_new();
for (int in = 0; in < items_total; in++) {
BLI_heap_insert(heap, (float)in, POINTER_FROM_INT(in));
BLI_heap_insert(heap, float(in), POINTER_FROM_INT(in));
}
for (int out_test = 0; out_test < items_total; out_test++) {
EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
@ -66,7 +66,7 @@ TEST(heap, RangeReverse)
const int items_total = SIZE;
Heap *heap = BLI_heap_new();
for (int in = 0; in < items_total; in++) {
BLI_heap_insert(heap, (float)-in, POINTER_FROM_INT(-in));
BLI_heap_insert(heap, float(-in), POINTER_FROM_INT(-in));
}
for (int out_test = items_total - 1; out_test >= 0; out_test--) {
EXPECT_EQ(-out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
@ -81,7 +81,7 @@ TEST(heap, RangeRemove)
Heap *heap = BLI_heap_new();
HeapNode **nodes = (HeapNode **)MEM_mallocN(sizeof(HeapNode *) * items_total, __func__);
for (int in = 0; in < items_total; in++) {
nodes[in] = BLI_heap_insert(heap, (float)in, POINTER_FROM_INT(in));
nodes[in] = BLI_heap_insert(heap, float(in), POINTER_FROM_INT(in));
}
for (int i = 0; i < items_total; i += 2) {
BLI_heap_remove(heap, nodes[i]);
@ -116,7 +116,7 @@ static void random_heap_helper(const int items_total, const int random_seed)
range_fl(values, items_total);
BLI_array_randomize(values, sizeof(float), items_total, random_seed);
for (int i = 0; i < items_total; i++) {
BLI_heap_insert(heap, values[i], POINTER_FROM_INT((int)values[i]));
BLI_heap_insert(heap, values[i], POINTER_FROM_INT(int(values[i])));
}
for (int out_test = 0; out_test < items_total; out_test++) {
EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
@ -145,10 +145,10 @@ TEST(heap, ReInsertSimple)
Heap *heap = BLI_heap_new();
HeapNode **nodes = (HeapNode **)MEM_mallocN(sizeof(HeapNode *) * items_total, __func__);
for (int in = 0; in < items_total; in++) {
nodes[in] = BLI_heap_insert(heap, (float)in, POINTER_FROM_INT(in));
nodes[in] = BLI_heap_insert(heap, float(in), POINTER_FROM_INT(in));
}
for (int i = 0; i < items_total; i++) {
BLI_heap_node_value_update(heap, nodes[i], (float)(items_total + i));
BLI_heap_node_value_update(heap, nodes[i], float(items_total + i));
}
for (int out_test = 0; out_test < items_total; out_test++) {
@ -165,11 +165,11 @@ static void random_heap_reinsert_helper(const int items_total, const int random_
Heap *heap = BLI_heap_new();
HeapNode **nodes = (HeapNode **)MEM_mallocN(sizeof(HeapNode *) * items_total, __func__);
for (int in = 0; in < items_total; in++) {
nodes[in] = BLI_heap_insert(heap, (float)in, POINTER_FROM_INT(in));
nodes[in] = BLI_heap_insert(heap, float(in), POINTER_FROM_INT(in));
}
BLI_array_randomize(nodes, sizeof(HeapNode *), items_total, random_seed);
for (int i = 0; i < items_total; i++) {
BLI_heap_node_value_update(heap, nodes[i], (float)i);
BLI_heap_node_value_update(heap, nodes[i], float(i));
}
EXPECT_TRUE(BLI_heap_is_valid(heap));
@ -177,7 +177,7 @@ static void random_heap_reinsert_helper(const int items_total, const int random_
HeapNode *node_top = BLI_heap_top(heap);
float out = BLI_heap_node_value(node_top);
EXPECT_EQ(out, BLI_heap_top_value(heap));
EXPECT_EQ((float)out_test, out);
EXPECT_EQ(float(out_test), out);
BLI_heap_pop_min(heap);
}
EXPECT_TRUE(BLI_heap_is_empty(heap));

View File

@ -18,7 +18,7 @@ static void rng_v3_round(float *coords, int coords_len, struct RNG *rng, int rou
{
for (int i = 0; i < coords_len; i++) {
float f = BLI_rng_get_float(rng) * 2.0f - 1.0f;
coords[i] = ((float)((int)(f * round)) / (float)round) * scale;
coords[i] = (float(int(f * round)) / float(round)) * scale;
}
}
@ -90,7 +90,7 @@ static void find_nearest_points_test(
if (j != i) {
#if 0
const float dist = len_v3v3(points[i], points[j]);
if (dist > (1.0f / (float)round)) {
if (dist > (1.0f / float(round))) {
printf("%.15f (%d %d)\n", dist, i, j);
print_v3_id(points[i]);
print_v3_id(points[j]);

View File

@ -36,13 +36,13 @@ TEST(linear_allocator, PackedAllocation)
blender::AlignedBuffer<256, 32> buffer;
allocator.provide_buffer(buffer);
uintptr_t ptr1 = (uintptr_t)allocator.allocate(10, 4); /* 0 - 10 */
uintptr_t ptr2 = (uintptr_t)allocator.allocate(10, 4); /* 12 - 22 */
uintptr_t ptr3 = (uintptr_t)allocator.allocate(8, 32); /* 32 - 40 */
uintptr_t ptr4 = (uintptr_t)allocator.allocate(16, 8); /* 40 - 56 */
uintptr_t ptr5 = (uintptr_t)allocator.allocate(1, 8); /* 56 - 57 */
uintptr_t ptr6 = (uintptr_t)allocator.allocate(1, 4); /* 60 - 61 */
uintptr_t ptr7 = (uintptr_t)allocator.allocate(1, 1); /* 61 - 62 */
uintptr_t ptr1 = uintptr_t(allocator.allocate(10, 4)); /* 0 - 10 */
uintptr_t ptr2 = uintptr_t(allocator.allocate(10, 4)); /* 12 - 22 */
uintptr_t ptr3 = uintptr_t(allocator.allocate(8, 32)); /* 32 - 40 */
uintptr_t ptr4 = uintptr_t(allocator.allocate(16, 8)); /* 40 - 56 */
uintptr_t ptr5 = uintptr_t(allocator.allocate(1, 8)); /* 56 - 57 */
uintptr_t ptr6 = uintptr_t(allocator.allocate(1, 4)); /* 60 - 61 */
uintptr_t ptr7 = uintptr_t(allocator.allocate(1, 1)); /* 61 - 62 */
EXPECT_EQ(ptr2 - ptr1, 12); /* 12 - 0 = 12 */
EXPECT_EQ(ptr3 - ptr2, 20); /* 32 - 12 = 20 */

View File

@ -68,7 +68,7 @@ TEST(math_color, LinearRGBTosRGBRoundtrip)
const int N = 50;
int i;
for (i = 0; i < N; ++i) {
float orig_linear_color = (float)i / N;
float orig_linear_color = float(i) / N;
float srgb_color = linearrgb_to_srgb(orig_linear_color);
float linear_color = srgb_to_linearrgb(srgb_color);
EXPECT_NEAR(orig_linear_color, linear_color, 1e-5);

View File

@ -161,7 +161,7 @@ static void test_sin_cos_from_fraction_accuracy(const int range, const float exp
for (int i = 0; i < range; i++) {
float sin_cos_fl[2];
sin_cos_from_fraction(i, range, &sin_cos_fl[0], &sin_cos_fl[1]);
const float phi = (float)(2.0 * M_PI) * ((float)i / (float)range);
const float phi = float(2.0 * M_PI) * (float(i) / float(range));
const float sin_cos_test_fl[2] = {sinf(phi), cosf(phi)};
EXPECT_V2_NEAR(sin_cos_fl, sin_cos_test_fl, expected_eps);
}

View File

@ -651,7 +651,7 @@ TEST(path_util, PathRelPath)
abs_path_in[FILE_MAX - 1] = '\0';
abs_path_out[0] = '/';
abs_path_out[1] = '/';
for (int i = 2; i < FILE_MAX - ((int)ref_path_in_len - 1); i++) {
for (int i = 2; i < FILE_MAX - (int(ref_path_in_len) - 1); i++) {
abs_path_out[i] = 'A';
}
abs_path_out[FILE_MAX - (ref_path_in_len - 1)] = '\0';

View File

@ -94,10 +94,10 @@ static void test_polyfill_topology(const float /*poly*/[][2],
const uint v2 = tris[i][(j + 1) % 3];
void **p = BLI_edgehash_lookup_p(edgehash, v1, v2);
if (p) {
*p = (void *)((intptr_t)*p + (intptr_t)1);
*p = (void *)(intptr_t(*p) + intptr_t(1));
}
else {
BLI_edgehash_insert(edgehash, v1, v2, (void *)(intptr_t)1);
BLI_edgehash_insert(edgehash, v1, v2, (void *)intptr_t(1));
}
}
}

View File

@ -274,7 +274,7 @@ TEST(string, Utf8InvalidBytes)
for (int i = 0; utf8_invalid_tests[i][0] != nullptr; i++) {
const char *tst = utf8_invalid_tests[i][0];
const char *tst_stripped = utf8_invalid_tests[i][1];
const int errors_num = (int)utf8_invalid_tests[i][2][0];
const int errors_num = int(utf8_invalid_tests[i][2][0]);
char buff[80];
memcpy(buff, tst, sizeof(buff));
@ -352,13 +352,13 @@ template<size_t Size> void utf8_as_char32_test_at_buffer_size()
/* Offset trailing bytes up and down in steps of 1, 2, 4 .. etc. */
if (Size > 1) {
for (int mul = 1; mul < 256; mul *= 2) {
for (int ofs = 1; ofs < (int)Size; ofs++) {
utf8_src[ofs] = (char)(i + (ofs * mul));
for (int ofs = 1; ofs < int(Size); ofs++) {
utf8_src[ofs] = char(i + (ofs * mul));
}
utf8_as_char32_test_compare<Size>(utf8_src);
for (int ofs = 1; ofs < (int)Size; ofs++) {
utf8_src[ofs] = (char)(i - (ofs * mul));
for (int ofs = 1; ofs < int(Size); ofs++) {
utf8_src[ofs] = char(i - (ofs * mul));
}
utf8_as_char32_test_compare<Size>(utf8_src);
}

View File

@ -98,7 +98,7 @@ TEST(virtual_array, VectorSet)
TEST(virtual_array, Func)
{
auto func = [](int64_t index) { return (int)(index * index); };
auto func = [](int64_t index) { return int(index * index); };
VArray<int> varray = VArray<int>::ForFunc(10, func);
EXPECT_EQ(varray.size(), 10);
EXPECT_EQ(varray[0], 0);
@ -108,7 +108,7 @@ TEST(virtual_array, Func)
TEST(virtual_array, AsSpan)
{
auto func = [](int64_t index) { return (int)(10 * index); };
auto func = [](int64_t index) { return int(10 * index); };
VArray<int> func_varray = VArray<int>::ForFunc(10, func);
VArraySpan span_varray{func_varray};
EXPECT_EQ(span_varray.size(), 10);
@ -210,7 +210,7 @@ TEST(virtual_array, MaterializeCompressed)
EXPECT_EQ(compressed_array[2], 4);
}
{
VArray<int> varray = VArray<int>::ForFunc(10, [](const int64_t i) { return (int)(i * i); });
VArray<int> varray = VArray<int>::ForFunc(10, [](const int64_t i) { return int(i * i); });
std::array<int, 3> compressed_array;
varray.materialize_compressed({5, 7, 8}, compressed_array);
EXPECT_EQ(compressed_array[0], 25);

View File

@ -270,7 +270,7 @@ static void randint_ghash_tests(GHash *ghash, const char *id, const uint count)
{
printf("\n========== STARTING %s ==========\n", id);
uint *data = (uint *)MEM_mallocN(sizeof(*data) * (size_t)count, __func__);
uint *data = (uint *)MEM_mallocN(sizeof(*data) * size_t(count), __func__);
uint *dt;
uint i;
@ -379,7 +379,7 @@ static void int4_ghash_tests(GHash *ghash, const char *id, const uint count)
{
printf("\n========== STARTING %s ==========\n", id);
void *data_v = MEM_mallocN(sizeof(uint[4]) * (size_t)count, __func__);
void *data_v = MEM_mallocN(sizeof(uint[4]) * size_t(count), __func__);
uint(*data)[4] = (uint(*)[4])data_v;
uint(*dt)[4];
uint i, j;
@ -485,7 +485,7 @@ TEST(ghash, Int2NoHash50000000)
static void multi_small_ghash_tests_one(GHash *ghash, RNG *rng, const uint count)
{
uint *data = (uint *)MEM_mallocN(sizeof(*data) * (size_t)count, __func__);
uint *data = (uint *)MEM_mallocN(sizeof(*data) * size_t(count), __func__);
uint *dt;
uint i;

View File

@ -69,7 +69,7 @@ static void task_listbase_heavy_iter_func(void *UNUSED(userdata),
LinkData *data = (LinkData *)item;
/* 'Random' number of iterations. */
const uint num = gen_pseudo_random_number((uint)index);
const uint num = gen_pseudo_random_number(uint(index));
for (uint i = 0; i < num; i++) {
data->data = POINTER_FROM_INT(POINTER_AS_INT(data->data) + ((i % 2) ? -index : index));
@ -86,7 +86,7 @@ static void task_listbase_heavy_membarrier_iter_func(void *userdata,
int *count = (int *)userdata;
/* 'Random' number of iterations. */
const uint num = gen_pseudo_random_number((uint)index);
const uint num = gen_pseudo_random_number(uint(index));
for (uint i = 0; i < num; i++) {
data->data = POINTER_FROM_INT(POINTER_AS_INT(data->data) + ((i % 2) ? -index : index));

View File

@ -193,7 +193,7 @@ typedef struct BHeadN {
struct BHead bhead;
} BHeadN;
#define BHEADN_FROM_BHEAD(bh) ((BHeadN *)POINTER_OFFSET(bh, -(int)offsetof(BHeadN, bhead)))
#define BHEADN_FROM_BHEAD(bh) ((BHeadN *)POINTER_OFFSET(bh, -int(offsetof(BHeadN, bhead))))
/**
* We could change this in the future, for now it's simplest if only data is delayed
@ -475,7 +475,7 @@ static void split_libdata(ListBase *lb_src, Main **lib_main_array, const uint li
idnext = static_cast<ID *>(id->next);
if (id->lib) {
if (((uint)id->lib->temp_index < lib_main_array_len) &&
if ((uint(id->lib->temp_index) < lib_main_array_len) &&
/* this check should never fail, just in case 'id->lib' is a dangling pointer. */
(lib_main_array[id->lib->temp_index]->curlib == id->lib)) {
Main *mainvar = lib_main_array[id->lib->temp_index];
@ -591,7 +591,7 @@ static void read_file_bhead_idname_map_create(FileData *fd)
if (code_prev != bhead->code) {
code_prev = bhead->code;
is_link = blo_bhead_is_id_valid_type(bhead) ?
BKE_idtype_idcode_is_linkable((short)code_prev) :
BKE_idtype_idcode_is_linkable(short(code_prev)) :
false;
}
@ -608,7 +608,7 @@ static void read_file_bhead_idname_map_create(FileData *fd)
if (code_prev != bhead->code) {
code_prev = bhead->code;
is_link = blo_bhead_is_id_valid_type(bhead) ?
BKE_idtype_idcode_is_linkable((short)code_prev) :
BKE_idtype_idcode_is_linkable(short(code_prev)) :
false;
}
@ -738,7 +738,7 @@ static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, bool do_endian_swap)
/* this patch is to avoid `intptr_t` being read from not-eight aligned positions
* is necessary on any modern 64bit architecture) */
memcpy(&old, &bhead8->old, 8);
bhead4->old = (int)(old >> 3);
bhead4->old = int(old >> 3);
bhead4->SDNAnr = bhead8->SDNAnr;
bhead4->nr = bhead8->nr;
@ -862,7 +862,7 @@ static BHeadN *get_bhead(FileData *fd)
#endif
else {
new_bhead = static_cast<BHeadN *>(
MEM_mallocN(sizeof(BHeadN) + (size_t)bhead.len, "new_bhead"));
MEM_mallocN(sizeof(BHeadN) + size_t(bhead.len), "new_bhead"));
if (new_bhead) {
new_bhead->next = new_bhead->prev = nullptr;
#ifdef USE_BHEAD_READ_ON_DEMAND
@ -872,7 +872,7 @@ static BHeadN *get_bhead(FileData *fd)
new_bhead->is_memchunk_identical = false;
new_bhead->bhead = bhead;
readsize = fd->file->read(fd->file, new_bhead + 1, (size_t)bhead.len);
readsize = fd->file->read(fd->file, new_bhead + 1, size_t(bhead.len));
if (readsize != bhead.len) {
fd->is_eof = true;
@ -966,7 +966,7 @@ static bool blo_bhead_read_data(FileData *fd, BHead *thisblock, void *buf)
success = false;
}
else {
if (fd->file->read(fd->file, buf, (size_t)new_bhead->bhead.len) != new_bhead->bhead.len) {
if (fd->file->read(fd->file, buf, size_t(new_bhead->bhead.len)) != new_bhead->bhead.len) {
success = false;
}
if (fd->flags & FD_FLAGS_IS_MEMFILE) {

View File

@ -233,7 +233,7 @@ 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)
#endif

View File

@ -169,7 +169,7 @@ static void version_idproperty_move_data_float(IDPropertyUIDataFloat *ui_data,
MEM_malloc_arrayN(array_len, sizeof(double), __func__));
const float *old_default_array = static_cast<const float *>(IDP_Array(default_value));
for (int i = 0; i < ui_data->default_array_len; i++) {
ui_data->default_array[i] = (double)old_default_array[i];
ui_data->default_array[i] = double(old_default_array[i]);
}
}
else if (default_value->subtype == IDP_DOUBLE) {
@ -412,9 +412,9 @@ static void do_versions_sequencer_speed_effect_recursive(Scene *scene, const Lis
else {
v->speed_control_type = SEQ_SPEED_MULTIPLY;
v->speed_fader = globalSpeed *
((float)seq->seq1->len /
max_ff((float)(SEQ_time_right_handle_frame_get(scene, seq->seq1) -
seq->seq1->start),
(float(seq->seq1->len) /
max_ff(float(SEQ_time_right_handle_frame_get(scene, seq->seq1) -
seq->seq1->start),
1.0f));
}
}
@ -430,7 +430,7 @@ static void do_versions_sequencer_speed_effect_recursive(Scene *scene, const Lis
}
else {
v->speed_control_type = SEQ_SPEED_FRAME_NUMBER;
v->speed_fader_frame_number = (int)(seq->speed_fader * globalSpeed);
v->speed_fader_frame_number = int(seq->speed_fader * globalSpeed);
substr = "speed_frame_number";
}

View File

@ -685,7 +685,7 @@ static void writestruct_at_address_nr(
}
mywrite(wd, &bh, sizeof(BHead));
mywrite(wd, data, (size_t)bh.len);
mywrite(wd, data, size_t(bh.len));
}
static void writestruct_nr(
@ -709,14 +709,14 @@ static void writedata(WriteData *wd, int filecode, size_t len, const void *adr)
}
/* align to 4 (writes uninitialized bytes in some cases) */
len = (len + 3) & ~((size_t)3);
len = (len + 3) & ~size_t(3);
/* init BHead */
bh.code = filecode;
bh.old = adr;
bh.nr = 1;
bh.SDNAnr = 0;
bh.len = (int)len;
bh.len = int(len);
mywrite(wd, &bh, sizeof(BHead));
mywrite(wd, adr, len);

View File

@ -65,7 +65,7 @@ void BM_face_uv_calc_center_median_weighted(const BMFace *f,
} while ((l_iter = l_iter->next) != l_first);
if (totw != 0.0f) {
mul_v2_fl(r_cent, 1.0f / (float)totw);
mul_v2_fl(r_cent, 1.0f / float(totw));
}
/* Reverse aspect. */
r_cent[0] /= aspect[0];
@ -85,7 +85,7 @@ void BM_face_uv_calc_center_median(const BMFace *f, const int cd_loop_uv_offset,
add_v2_v2(r_cent, luv->uv);
} while ((l_iter = l_iter->next) != l_first);
mul_v2_fl(r_cent, 1.0f / (float)f->len);
mul_v2_fl(r_cent, 1.0f / float(f->len));
}
float BM_face_uv_calc_cross(const BMFace *f, const int cd_loop_uv_offset)

View File

@ -10,8 +10,8 @@ double ChunkOrderHotspot::calc_distance(int x, int y)
{
int dx = this->x - x;
int dy = this->y - y;
double result = sqrt((double)(dx * dx + dy * dy));
result += (double)this->addition;
double result = sqrt(double(dx * dx + dy * dy));
result += double(this->addition);
return result;
}

View File

@ -436,8 +436,8 @@ inline void ExecutionGroup::determine_chunk_rect(rcti *r_rect,
else {
const uint minx = x_chunk * chunk_size_ + viewer_border_.xmin;
const uint miny = y_chunk * chunk_size_ + viewer_border_.ymin;
const uint width = MIN2((uint)viewer_border_.xmax, width_);
const uint height = MIN2((uint)viewer_border_.ymax, height_);
const uint width = MIN2(uint(viewer_border_.xmax), width_);
const uint height = MIN2(uint(viewer_border_.ymax), height_);
BLI_rcti_init(r_rect,
MIN2(minx, width_),
MIN2(minx + chunk_size_, width),
@ -480,14 +480,14 @@ bool ExecutionGroup::schedule_area_when_possible(ExecutionSystem *graph, rcti *a
int maxx = min_ii(area->xmax - viewer_border_.xmin, viewer_border_.xmax - viewer_border_.xmin);
int miny = max_ii(area->ymin - viewer_border_.ymin, 0);
int maxy = min_ii(area->ymax - viewer_border_.ymin, viewer_border_.ymax - viewer_border_.ymin);
int minxchunk = minx / (int)chunk_size_;
int maxxchunk = (maxx + (int)chunk_size_ - 1) / (int)chunk_size_;
int minychunk = miny / (int)chunk_size_;
int maxychunk = (maxy + (int)chunk_size_ - 1) / (int)chunk_size_;
int minxchunk = minx / int(chunk_size_);
int maxxchunk = (maxx + int(chunk_size_) - 1) / int(chunk_size_);
int minychunk = miny / int(chunk_size_);
int maxychunk = (maxy + int(chunk_size_) - 1) / int(chunk_size_);
minxchunk = max_ii(minxchunk, 0);
minychunk = max_ii(minychunk, 0);
maxxchunk = min_ii(maxxchunk, (int)x_chunks_len_);
maxychunk = min_ii(maxychunk, (int)y_chunks_len_);
maxxchunk = min_ii(maxxchunk, int(x_chunks_len_));
maxychunk = min_ii(maxychunk, int(y_chunks_len_));
bool result = true;
for (indexx = minxchunk; indexx < maxxchunk; indexx++) {
@ -516,10 +516,10 @@ bool ExecutionGroup::schedule_chunk_when_possible(ExecutionSystem *graph,
const int chunk_x,
const int chunk_y)
{
if (chunk_x < 0 || chunk_x >= (int)x_chunks_len_) {
if (chunk_x < 0 || chunk_x >= int(x_chunks_len_)) {
return true;
}
if (chunk_y < 0 || chunk_y >= (int)y_chunks_len_) {
if (chunk_y < 0 || chunk_y >= int(y_chunks_len_)) {
return true;
}

View File

@ -266,7 +266,7 @@ void MemoryBuffer::copy_from(const uchar *src,
const float *row_end = to_elem + width * this->elem_stride;
while (to_elem < row_end) {
for (int i = 0; i < elem_size; i++) {
to_elem[i] = ((float)from_elem[i]) * (1.0f / 255.0f);
to_elem[i] = float(from_elem[i]) * (1.0f / 255.0f);
}
to_elem += this->elem_stride;
from_elem += elem_stride;
@ -427,7 +427,7 @@ void MemoryBuffer::read_elem_filtered(
const float deriv[2][2] = {{dx[0], dx[1]}, {dy[0], dy[1]}};
float inv_width = 1.0f / (float)this->get_width(), inv_height = 1.0f / (float)this->get_height();
float inv_width = 1.0f / float(this->get_width()), inv_height = 1.0f / float(this->get_height());
/* TODO(sergey): Render pipeline uses normalized coordinates and derivatives,
* but compositor uses pixel space. For now let's just divide the values and
* switch compositor to normalized space for EWA later.
@ -463,8 +463,8 @@ void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivat
}
else {
BLI_assert(datatype_ == DataType::Color);
float inv_width = 1.0f / (float)this->get_width(),
inv_height = 1.0f / (float)this->get_height();
float inv_width = 1.0f / float(this->get_width()),
inv_height = 1.0f / float(this->get_height());
/* TODO(sergey): Render pipeline uses normalized coordinates and derivatives,
* but compositor uses pixel space. For now let's just divide the values and
* switch compositor to normalized space for EWA later.

View File

@ -187,8 +187,8 @@ void OpenCLDevice::COM_cl_enqueue_range(cl_kernel kernel, MemoryBuffer *output_m
{
cl_int error;
const size_t size[] = {
(size_t)output_memory_buffer->get_width(),
(size_t)output_memory_buffer->get_height(),
size_t(output_memory_buffer->get_width()),
size_t(output_memory_buffer->get_height()),
};
error = clEnqueueNDRangeKernel(queue_, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);

View File

@ -25,15 +25,15 @@ static void compositor_init_node_previews(const RenderData *render_data, bNodeTr
/* We fit the aspect into COM_PREVIEW_SIZE x COM_PREVIEW_SIZE image to avoid
* insane preview resolution, which might even overflow preview dimensions. */
const float aspect = render_data->xsch > 0 ?
(float)render_data->ysch / (float)render_data->xsch :
float(render_data->ysch) / float(render_data->xsch) :
1.0f;
int preview_width, preview_height;
if (aspect < 1.0f) {
preview_width = blender::compositor::COM_PREVIEW_SIZE;
preview_height = (int)(blender::compositor::COM_PREVIEW_SIZE * aspect);
preview_height = int(blender::compositor::COM_PREVIEW_SIZE * aspect);
}
else {
preview_width = (int)(blender::compositor::COM_PREVIEW_SIZE / aspect);
preview_width = int(blender::compositor::COM_PREVIEW_SIZE / aspect);
preview_height = blender::compositor::COM_PREVIEW_SIZE;
}
BKE_node_preview_init_tree(node_tree, preview_width, preview_height);

View File

@ -16,8 +16,8 @@ void CropNode::convert_to_operations(NodeConverter &converter,
{
const bNode *node = get_bnode();
NodeTwoXYs *crop_settings = (NodeTwoXYs *)node->storage;
bool relative = (bool)node->custom2;
bool crop_image = (bool)node->custom1;
bool relative = bool(node->custom2);
bool crop_image = bool(node->custom1);
CropBaseOperation *operation;
if (crop_image) {
operation = new CropImageOperation();

View File

@ -17,7 +17,7 @@ void MapUVNode::convert_to_operations(NodeConverter &converter,
const bNode *node = this->get_bnode();
MapUVOperation *operation = new MapUVOperation();
operation->set_alpha((float)node->custom1);
operation->set_alpha(float(node->custom1));
operation->set_canvas_input_index(1);
converter.add_operation(operation);

View File

@ -41,7 +41,7 @@ void MaskNode::convert_to_operations(NodeConverter &converter,
operation->set_mask(mask);
operation->set_framenumber(context.get_framenumber());
operation->set_feather((bool)(editor_node->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0);
operation->set_feather(bool(editor_node->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0);
if ((editor_node->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) && (editor_node->custom2 > 1) &&
(editor_node->custom3 > FLT_EPSILON)) {

View File

@ -20,7 +20,7 @@ void SceneTimeNode::convert_to_operations(NodeConverter &converter,
const int frameNumber = context.get_framenumber();
const Scene *scene = context.get_scene();
const double frameRate = (((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base);
const double frameRate = (double(scene->r.frs_sec) / double(scene->r.frs_sec_base));
SecondOperation->set_value(float(frameNumber / frameRate));
converter.add_operation(SecondOperation);

View File

@ -31,7 +31,7 @@ void TimeNode::convert_to_operations(NodeConverter &converter,
fac = 1.0f;
}
else if (node->custom1 < node->custom2) {
fac = (context.get_framenumber() - node->custom1) / (float)(node->custom2 - node->custom1);
fac = (context.get_framenumber() - node->custom1) / float(node->custom2 - node->custom1);
}
BKE_curvemapping_init((CurveMapping *)node->storage);

View File

@ -71,7 +71,7 @@ float *BlurBaseOperation::make_gausstab(float rad, int size)
sum = 0.0f;
float fac = (rad > 0.0f ? 1.0f / rad : 0.0f);
for (i = -size; i <= size; i++) {
val = RE_filter_value(data_.filtertype, (float)i * fac);
val = RE_filter_value(data_.filtertype, float(i) * fac);
sum += val;
gausstab[i + size] = val;
}
@ -107,7 +107,7 @@ float *BlurBaseOperation::make_dist_fac_inverse(float rad, int size, int falloff
float fac = (rad > 0.0f ? 1.0f / rad : 0.0f);
for (i = -size; i <= size; i++) {
val = 1.0f - fabsf((float)i * fac);
val = 1.0f - fabsf(float(i) * fac);
/* keep in sync with rna_enum_proportional_falloff_curve_only_items */
switch (falloff) {

View File

@ -16,13 +16,13 @@ void BokehImageOperation::init_execution()
center_[1] = get_height() / 2;
inverse_rounding_ = 1.0f - data_->rounding;
circular_distance_ = get_width() / 2;
flap_rad_ = (float)(M_PI * 2) / data_->flaps;
flap_rad_ = float(M_PI * 2) / data_->flaps;
flap_rad_add_ = data_->angle;
while (flap_rad_add_ < 0.0f) {
flap_rad_add_ += (float)(M_PI * 2.0);
flap_rad_add_ += float(M_PI * 2.0);
}
while (flap_rad_add_ > (float)M_PI) {
flap_rad_add_ -= (float)(M_PI * 2.0);
while (flap_rad_add_ > float(M_PI)) {
flap_rad_add_ -= float(M_PI * 2.0);
}
}
void BokehImageOperation::detemine_start_point_of_flap(float r[2], int flap_number, float distance)
@ -43,8 +43,8 @@ float BokehImageOperation::is_inside_bokeh(float distance, float x, float y)
point[1] = y;
const float distance_to_center = len_v2v2(point, center_);
const float bearing = (atan2f(deltaX, deltaY) + (float)(M_PI * 2.0));
int flap_number = (int)((bearing - flap_rad_add_) / flap_rad_);
const float bearing = (atan2f(deltaX, deltaY) + float(M_PI * 2.0));
int flap_number = int((bearing - flap_rad_add_) / flap_rad_);
detemine_start_point_of_flap(line_p1, flap_number, distance);
detemine_start_point_of_flap(line_p2, flap_number + 1, distance);

View File

@ -19,10 +19,10 @@ void BoxMaskOperation::init_execution()
{
input_mask_ = this->get_input_socket_reader(0);
input_value_ = this->get_input_socket_reader(1);
const double rad = (double)data_->rotation;
const double rad = double(data_->rotation);
cosine_ = cos(rad);
sine_ = sin(rad);
aspect_ratio_ = ((float)this->get_width()) / this->get_height();
aspect_ratio_ = float(this->get_width()) / this->get_height();
}
void BoxMaskOperation::execute_pixel_sampled(float output[4],

View File

@ -74,7 +74,7 @@ void *CalculateStandardDeviationOperation::initialize_tile_data(rcti *rect)
}
}
}
standard_deviation_ = sqrt(sum / (float)(pixels - 1));
standard_deviation_ = sqrt(sum / float(pixels - 1));
iscalculated_ = true;
}
unlock_mutex();
@ -98,7 +98,7 @@ void CalculateStandardDeviationOperation::update_memory_buffer_started(
join.num_pixels += chunk.num_pixels;
});
standard_deviation_ = total.num_pixels <= 1 ? 0.0f :
sqrt(total.sum / (float)(total.num_pixels - 1));
sqrt(total.sum / float(total.num_pixels - 1));
iscalculated_ = true;
}
}

View File

@ -46,8 +46,8 @@ void ConvertDepthToRadiusOperation::init_execution()
}
inverse_focal_distance_ = 1.0f / focal_distance;
aspect_ = (this->get_width() > this->get_height()) ?
(this->get_height() / (float)this->get_width()) :
(this->get_width() / (float)this->get_height());
(this->get_height() / float(this->get_width())) :
(this->get_width() / float(this->get_height()));
aperture_ = 0.5f * (cam_lens_ / (aspect_ * cam_sensor)) / f_stop_;
const float minsz = MIN2(get_width(), get_height());
dof_sp_ = minsz / ((cam_sensor / 2.0f) /

View File

@ -42,8 +42,8 @@ void CryptomatteOperation::execute_pixel(float output[4], int x, int y, void *da
::memcpy(&m3hash, &input[0], sizeof(uint32_t));
/* Since the red channel is likely to be out of display range,
* setting green and blue gives more meaningful images. */
output[1] = ((float)(m3hash << 8) / (float)UINT32_MAX);
output[2] = ((float)(m3hash << 16) / (float)UINT32_MAX);
output[1] = (float(m3hash << 8) / float(UINT32_MAX));
output[2] = (float(m3hash << 16) / float(UINT32_MAX));
}
for (float hash : object_index_) {
if (input[0] == hash) {
@ -71,8 +71,8 @@ void CryptomatteOperation::update_memory_buffer_partial(MemoryBuffer *output,
::memcpy(&m3hash, &input[0], sizeof(uint32_t));
/* Since the red channel is likely to be out of display range,
* setting green and blue gives more meaningful images. */
it.out[1] = ((float)(m3hash << 8) / (float)UINT32_MAX);
it.out[2] = ((float)(m3hash << 16) / (float)UINT32_MAX);
it.out[1] = (float(m3hash << 8) / float(UINT32_MAX));
it.out[2] = (float(m3hash << 16) / float(UINT32_MAX));
}
for (const float hash : object_index_) {
if (input[0] == hash) {

View File

@ -178,7 +178,7 @@ static bool are_guiding_passes_noise_free(const NodeDenoise *settings)
void DenoiseOperation::hash_output_params()
{
if (settings_) {
hash_params((int)settings_->hdr, are_guiding_passes_noise_free(settings_));
hash_params(int(settings_->hdr), are_guiding_passes_noise_free(settings_));
}
}

View File

@ -99,7 +99,7 @@ void DespeckleOperation::execute_pixel(float output[4], int x, int y, void * /*d
input_operation_->read(in1, x3, y3, nullptr);
COLOR_ADD(TOT_DIV_CNR)
mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * (float)M_SQRT1_2)));
mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * float(M_SQRT1_2))));
// mul_v4_fl(color_mid, 1.0f / w);
if ((w != 0.0f) && ((w / WTOT) > (threshold_neighbor_)) &&
@ -214,7 +214,7 @@ void DespeckleOperation::update_memory_buffer_partial(MemoryBuffer *output,
in1 = image->get_elem(x3, y3);
COLOR_ADD(TOT_DIV_CNR)
mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * (float)M_SQRT1_2)));
mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * float(M_SQRT1_2))));
// mul_v4_fl(color_mid, 1.0f / w);
if ((w != 0.0f) && ((w / WTOT) > (threshold_neighbor_)) &&

View File

@ -181,8 +181,8 @@ static float get_min_distance(DilateErodeThresholdOperation::PixelData &p)
* true. */
const TCompare compare;
float min_dist = p.distance;
const float *row = p.elem + ((intptr_t)p.ymin - p.y) * p.row_stride +
((intptr_t)p.xmin - p.x) * p.elem_stride;
const float *row = p.elem + (intptr_t(p.ymin) - p.y) * p.row_stride +
(intptr_t(p.xmin) - p.x) * p.elem_stride;
for (int yi = p.ymin; yi < p.ymax; yi++) {
const float dy = yi - p.y;
const float dist_y = dy * dy;
@ -410,8 +410,8 @@ static float get_distance_value(DilateDistanceOperation::PixelData &p, const flo
const TCompare compare;
const float min_dist = p.min_distance;
float value = start_value;
const float *row = p.elem + ((intptr_t)p.ymin - p.y) * p.row_stride +
((intptr_t)p.xmin - p.x) * p.elem_stride;
const float *row = p.elem + (intptr_t(p.ymin) - p.y) * p.row_stride +
(intptr_t(p.xmin) - p.x) * p.elem_stride;
for (int yi = p.ymin; yi < p.ymax; yi++) {
const float dy = yi - p.y;
const float dist_y = dy * dy;

View File

@ -30,7 +30,7 @@ void DirectionalBlurOperation::init_execution()
const float height = get_height();
const float a = angle;
const float itsc = 1.0f / powf(2.0f, (float)iterations);
const float itsc = 1.0f / powf(2.0f, float(iterations));
float D;
D = distance * sqrtf(width * width + height * height);

View File

@ -113,7 +113,7 @@ void DisplaceOperation::pixel_transform(const float xy[2], float r_uv[2], float
num++;
}
if (num > 0) {
float numinv = 1.0f / (float)num;
float numinv = 1.0f / float(num);
r_deriv[0][0] *= numinv;
r_deriv[1][0] *= numinv;
}
@ -130,7 +130,7 @@ void DisplaceOperation::pixel_transform(const float xy[2], float r_uv[2], float
num++;
}
if (num > 0) {
float numinv = 1.0f / (float)num;
float numinv = 1.0f / float(num);
r_deriv[0][1] *= numinv;
r_deriv[1][1] *= numinv;
}
@ -227,7 +227,7 @@ void DisplaceOperation::update_memory_buffer_partial(MemoryBuffer *output,
{
const MemoryBuffer *input_color = inputs[0];
for (BuffersIterator<float> it = output->iterate_with({}, area); !it.is_end(); ++it) {
const float xy[2] = {(float)it.x, (float)it.y};
const float xy[2] = {float(it.x), float(it.y)};
float uv[2];
float deriv[2][2];

View File

@ -19,10 +19,10 @@ void EllipseMaskOperation::init_execution()
{
input_mask_ = this->get_input_socket_reader(0);
input_value_ = this->get_input_socket_reader(1);
const double rad = (double)data_->rotation;
const double rad = double(data_->rotation);
cosine_ = cos(rad);
sine_ = sin(rad);
aspect_ratio_ = ((float)this->get_width()) / this->get_height();
aspect_ratio_ = float(this->get_width()) / this->get_height();
}
void EllipseMaskOperation::execute_pixel_sampled(float output[4],

View File

@ -26,8 +26,8 @@ void FlipOperation::deinit_execution()
void FlipOperation::execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler)
{
float nx = flip_x_ ? ((int)this->get_width() - 1) - x : x;
float ny = flip_y_ ? ((int)this->get_height() - 1) - y : y;
float nx = flip_x_ ? (int(this->get_width()) - 1) - x : x;
float ny = flip_y_ ? (int(this->get_height()) - 1) - y : y;
input_operation_->read_sampled(output, nx, ny, sampler);
}
@ -39,7 +39,7 @@ bool FlipOperation::determine_depending_area_of_interest(rcti *input,
rcti new_input;
if (flip_x_) {
const int w = (int)this->get_width() - 1;
const int w = int(this->get_width()) - 1;
new_input.xmax = (w - input->xmin) + 1;
new_input.xmin = (w - input->xmax) - 1;
}
@ -48,7 +48,7 @@ bool FlipOperation::determine_depending_area_of_interest(rcti *input,
new_input.xmax = input->xmax;
}
if (flip_y_) {
const int h = (int)this->get_height() - 1;
const int h = int(this->get_height()) - 1;
new_input.ymax = (h - input->ymin) + 1;
new_input.ymin = (h - input->ymax) - 1;
}
@ -85,7 +85,7 @@ void FlipOperation::get_area_of_interest(const int input_idx,
BLI_assert(input_idx == 0);
UNUSED_VARS_NDEBUG(input_idx);
if (flip_x_) {
const int w = (int)this->get_width() - 1;
const int w = int(this->get_width()) - 1;
r_input_area.xmax = (w - output_area.xmin) + 1;
r_input_area.xmin = (w - output_area.xmax) + 1;
}
@ -94,7 +94,7 @@ void FlipOperation::get_area_of_interest(const int input_idx,
r_input_area.xmax = output_area.xmax;
}
if (flip_y_) {
const int h = (int)this->get_height() - 1;
const int h = int(this->get_height()) - 1;
r_input_area.ymax = (h - output_area.ymin) + 1;
r_input_area.ymin = (h - output_area.ymax) + 1;
}
@ -112,8 +112,8 @@ void FlipOperation::update_memory_buffer_partial(MemoryBuffer *output,
const int input_offset_x = input_img->get_rect().xmin;
const int input_offset_y = input_img->get_rect().ymin;
for (BuffersIterator<float> it = output->iterate_with({}, area); !it.is_end(); ++it) {
const int nx = flip_x_ ? ((int)this->get_width() - 1) - it.x : it.x;
const int ny = flip_y_ ? ((int)this->get_height() - 1) - it.y : it.y;
const int nx = flip_x_ ? (int(this->get_width()) - 1) - it.x : it.x;
const int ny = flip_y_ ? (int(this->get_height()) - 1) - it.y : it.y;
input_img->read_elem(input_offset_x + nx, input_offset_y + ny, it.out);
}
}

View File

@ -114,7 +114,7 @@ void GaussianAlphaBlurBaseOperation::update_memory_buffer_partial(MemoryBuffer *
float distfacinv_max = 1.0f; /* 0 to 1 */
const int step = QualityStepHelper::get_step();
const float *in = it.in(0) + ((intptr_t)coord_min - coord) * elem_stride;
const float *in = it.in(0) + (intptr_t(coord_min) - coord) * elem_stride;
const int in_stride = elem_stride * step;
int index = (coord_min - coord) + filtersize_;
const int index_end = index + (coord_max - coord_min);

View File

@ -112,7 +112,7 @@ void GaussianBlurBaseOperation::update_memory_buffer_partial(MemoryBuffer *outpu
float multiplier_accum = 0.0f;
const int step = QualityStepHelper::get_step();
const float *in = it.in(0) + ((intptr_t)coord_min - coord) * elem_stride;
const float *in = it.in(0) + (intptr_t(coord_min) - coord) * elem_stride;
const int in_stride = elem_stride * step;
int gauss_idx = (coord_min - coord) + filtersize_;
const int gauss_end = gauss_idx + (coord_max - coord_min);

View File

@ -35,11 +35,11 @@ void GaussianBokehBlurOperation::init_data()
}
}
radxf_ = size_ * (float)data_.sizex;
radxf_ = size_ * float(data_.sizex);
CLAMP(radxf_, 0.0f, width / 2.0f);
/* Vertical. */
radyf_ = size_ * (float)data_.sizey;
radyf_ = size_ * float(data_.sizey);
CLAMP(radyf_, 0.0f, height / 2.0f);
radx_ = ceil(radxf_);
@ -71,8 +71,8 @@ void GaussianBokehBlurOperation::update_gauss()
float facy = (radyf_ > 0.0f ? 1.0f / radyf_ : 0.0f);
for (int j = -rady_; j <= rady_; j++) {
for (int i = -radx_; i <= radx_; i++, dgauss++) {
float fj = (float)j * facy;
float fi = (float)i * facx;
float fj = float(j) * facy;
float fi = float(i) * facx;
float dist = sqrt(fj * fj + fi * fi);
*dgauss = RE_filter_value(data_.filtertype, dist);
@ -105,10 +105,10 @@ void GaussianBokehBlurOperation::execute_pixel(float output[4], int x, int y, vo
const float width = this->get_width();
const float height = this->get_height();
radxf_ = size_ * (float)data_.sizex;
radxf_ = size_ * float(data_.sizex);
CLAMP(radxf_, 0.0f, width / 2.0f);
radyf_ = size_ * (float)data_.sizey;
radyf_ = size_ * float(data_.sizey);
CLAMP(radyf_, 0.0f, height / 2.0f);
radx_ = ceil(radxf_);
@ -265,22 +265,22 @@ void GaussianBlurReferenceOperation::init_data()
if (data_.relative) {
switch (data_.aspect) {
case CMP_NODE_BLUR_ASPECT_NONE:
data_.sizex = (int)(data_.percentx * 0.01f * data_.image_in_width);
data_.sizey = (int)(data_.percenty * 0.01f * data_.image_in_height);
data_.sizex = int(data_.percentx * 0.01f * data_.image_in_width);
data_.sizey = int(data_.percenty * 0.01f * data_.image_in_height);
break;
case CMP_NODE_BLUR_ASPECT_Y:
data_.sizex = (int)(data_.percentx * 0.01f * data_.image_in_width);
data_.sizey = (int)(data_.percenty * 0.01f * data_.image_in_width);
data_.sizex = int(data_.percentx * 0.01f * data_.image_in_width);
data_.sizey = int(data_.percenty * 0.01f * data_.image_in_width);
break;
case CMP_NODE_BLUR_ASPECT_X:
data_.sizex = (int)(data_.percentx * 0.01f * data_.image_in_height);
data_.sizey = (int)(data_.percenty * 0.01f * data_.image_in_height);
data_.sizex = int(data_.percentx * 0.01f * data_.image_in_height);
data_.sizey = int(data_.percenty * 0.01f * data_.image_in_height);
break;
}
}
/* Horizontal. */
filtersizex_ = (float)data_.sizex;
filtersizex_ = float(data_.sizex);
int imgx = get_width() / 2;
if (filtersizex_ > imgx) {
filtersizex_ = imgx;
@ -288,10 +288,10 @@ void GaussianBlurReferenceOperation::init_data()
else if (filtersizex_ < 1) {
filtersizex_ = 1;
}
radx_ = (float)filtersizex_;
radx_ = float(filtersizex_);
/* Vertical. */
filtersizey_ = (float)data_.sizey;
filtersizey_ = float(data_.sizey);
int imgy = get_height() / 2;
if (filtersizey_ > imgy) {
filtersizey_ = imgy;
@ -299,7 +299,7 @@ void GaussianBlurReferenceOperation::init_data()
else if (filtersizey_ < 1) {
filtersizey_ = 1;
}
rady_ = (float)filtersizey_;
rady_ = float(filtersizey_);
}
void *GaussianBlurReferenceOperation::initialize_tile_data(rcti * /*rect*/)
@ -340,8 +340,8 @@ void GaussianBlurReferenceOperation::execute_pixel(float output[4], int x, int y
float temp_size[4];
input_size_->read(temp_size, x, y, data);
float ref_size = temp_size[0];
int refradx = (int)(ref_size * radx_);
int refrady = (int)(ref_size * rady_);
int refradx = int(ref_size * radx_);
int refrady = int(ref_size * rady_);
if (refradx > filtersizex_) {
refradx = filtersizex_;
}
@ -447,8 +447,8 @@ void GaussianBlurReferenceOperation::update_memory_buffer_partial(MemoryBuffer *
MemoryBuffer *size_input = inputs[SIZE_INPUT_INDEX];
for (BuffersIterator<float> it = output->iterate_with({size_input}, area); !it.is_end(); ++it) {
const float ref_size = *it.in(0);
int ref_radx = (int)(ref_size * radx_);
int ref_rady = (int)(ref_size * rady_);
int ref_radx = int(ref_size * radx_);
int ref_rady = int(ref_size * rady_);
if (ref_radx > filtersizex_) {
ref_radx = filtersizex_;
}

Some files were not shown because too many files have changed in this diff Show More