Cleanup: use C++ function style casts, NULL -> nullptr

This commit is contained in:
Campbell Barton
2023-07-18 14:18:07 +10:00
parent 29c2e71d1f
commit 17563e9a91
71 changed files with 567 additions and 569 deletions
@@ -856,7 +856,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
}
VertDataMulN(q, (float)1 / sharpCount, ss);
VertDataMulN(q, float(1) / sharpCount, ss);
if (sharpCount != 2 || allSharp) {
/* q = q + (co - q) * avgSharpness */
@@ -956,7 +956,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
VertDataMulN(r, 1.0f / (2.0f + numFaces), ss);
VertDataCopy(nCo, co, ss);
VertDataMulN(nCo, (float)numFaces, ss);
VertDataMulN(nCo, float(numFaces), ss);
VertDataAdd(nCo, q, ss);
VertDataAdd(nCo, r, ss);
VertDataMulN(nCo, 1.0f / (2 + numFaces), ss);
@@ -1202,7 +1202,7 @@ void ccgSubSurf__sync_legacy(CCGSubSurf *ss)
}
}
VertDataMulN(static_cast<float *>(q), (float)1 / sharpCount, ss);
VertDataMulN(static_cast<float *>(q), float(1) / sharpCount, ss);
if (sharpCount != 2 || allSharp) {
/* q = q + (co - q) * avgSharpness */
@@ -198,7 +198,7 @@ static void _stdAllocator_free(CCGAllocatorHDL /*a*/, void *ptr)
MEM_freeN(ptr);
}
CCGAllocatorIFC *ccg_getStandardAllocatorIFC(void)
CCGAllocatorIFC *ccg_getStandardAllocatorIFC()
{
static CCGAllocatorIFC ifc;
@@ -214,7 +214,7 @@ static void action_flip_pchan(Object *ob_arm,
#undef FCURVE_ASSIGN_ARRAY
/* Array of F-Curves, for convenient access. */
#define FCURVE_CHANNEL_LEN (sizeof(fkc_pchan) / sizeof(struct FCurve_KeyCache))
#define FCURVE_CHANNEL_LEN (sizeof(fkc_pchan) / sizeof(FCurve_KeyCache))
FCurve *fcurve_array[FCURVE_CHANNEL_LEN];
int fcurve_array_len = 0;
+3 -3
View File
@@ -32,7 +32,7 @@ static CLG_LogRef LOG = {"bke.addon"};
/** \name Add-on New/Free
* \{ */
bAddon *BKE_addon_new(void)
bAddon *BKE_addon_new()
{
bAddon *addon = static_cast<bAddon *>(MEM_callocN(sizeof(bAddon), "bAddon"));
return addon;
@@ -115,13 +115,13 @@ void BKE_addon_pref_type_remove(const bAddonPrefType *apt)
BLI_ghash_remove(global_addonpreftype_hash, apt->idname, nullptr, MEM_freeN);
}
void BKE_addon_pref_type_init(void)
void BKE_addon_pref_type_init()
{
BLI_assert(global_addonpreftype_hash == nullptr);
global_addonpreftype_hash = BLI_ghash_str_new(__func__);
}
void BKE_addon_pref_type_free(void)
void BKE_addon_pref_type_free()
{
BLI_ghash_free(global_addonpreftype_hash, nullptr, MEM_freeN);
global_addonpreftype_hash = nullptr;
+14 -14
View File
@@ -424,39 +424,39 @@ bool BKE_animsys_read_from_rna_path(PathResolvedRNA *anim_rna, float *r_value)
case PROP_BOOLEAN: {
if (array_index != -1) {
const int orig_value_coerce = RNA_property_boolean_get_index(ptr, prop, array_index);
orig_value = (float)orig_value_coerce;
orig_value = float(orig_value_coerce);
}
else {
const int orig_value_coerce = RNA_property_boolean_get(ptr, prop);
orig_value = (float)orig_value_coerce;
orig_value = float(orig_value_coerce);
}
break;
}
case PROP_INT: {
if (array_index != -1) {
const int orig_value_coerce = RNA_property_int_get_index(ptr, prop, array_index);
orig_value = (float)orig_value_coerce;
orig_value = float(orig_value_coerce);
}
else {
const int orig_value_coerce = RNA_property_int_get(ptr, prop);
orig_value = (float)orig_value_coerce;
orig_value = float(orig_value_coerce);
}
break;
}
case PROP_FLOAT: {
if (array_index != -1) {
const float orig_value_coerce = RNA_property_float_get_index(ptr, prop, array_index);
orig_value = (float)orig_value_coerce;
orig_value = float(orig_value_coerce);
}
else {
const float orig_value_coerce = RNA_property_float_get(ptr, prop);
orig_value = (float)orig_value_coerce;
orig_value = float(orig_value_coerce);
}
break;
}
case PROP_ENUM: {
const int orig_value_coerce = RNA_property_enum_get(ptr, prop);
orig_value = (float)orig_value_coerce;
orig_value = float(orig_value_coerce);
break;
}
default: /* nothing can be done here... so it is unsuccessful? */
@@ -501,7 +501,7 @@ bool BKE_animsys_write_to_rna_path(PathResolvedRNA *anim_rna, const float value)
break;
}
case PROP_INT: {
int value_coerce = (int)value;
int value_coerce = int(value);
RNA_property_int_clamp(ptr, prop, &value_coerce);
if (array_index != -1) {
RNA_property_int_set_index(ptr, prop, array_index, value_coerce);
@@ -523,7 +523,7 @@ bool BKE_animsys_write_to_rna_path(PathResolvedRNA *anim_rna, const float value)
break;
}
case PROP_ENUM: {
const int value_coerce = (int)value;
const int value_coerce = int(value);
RNA_property_enum_set(ptr, prop, value_coerce);
break;
}
@@ -1400,7 +1400,7 @@ static void nlaevalchan_get_default_values(NlaEvalChannel *nec, float *r_values)
tmp_bool = static_cast<bool *>(MEM_malloc_arrayN(length, sizeof(*tmp_bool), __func__));
RNA_property_boolean_get_default_array(ptr, prop, tmp_bool);
for (int i = 0; i < length; i++) {
r_values[i] = (float)tmp_bool[i];
r_values[i] = float(tmp_bool[i]);
}
MEM_freeN(tmp_bool);
break;
@@ -1408,7 +1408,7 @@ static void nlaevalchan_get_default_values(NlaEvalChannel *nec, float *r_values)
tmp_int = static_cast<int *>(MEM_malloc_arrayN(length, sizeof(*tmp_int), __func__));
RNA_property_int_get_default_array(ptr, prop, tmp_int);
for (int i = 0; i < length; i++) {
r_values[i] = (float)tmp_int[i];
r_values[i] = float(tmp_int[i]);
}
MEM_freeN(tmp_int);
break;
@@ -1424,16 +1424,16 @@ static void nlaevalchan_get_default_values(NlaEvalChannel *nec, float *r_values)
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
*r_values = (float)RNA_property_boolean_get_default(ptr, prop);
*r_values = float(RNA_property_boolean_get_default(ptr, prop));
break;
case PROP_INT:
*r_values = (float)RNA_property_int_get_default(ptr, prop);
*r_values = float(RNA_property_int_get_default(ptr, prop));
break;
case PROP_FLOAT:
*r_values = RNA_property_float_get_default(ptr, prop);
break;
case PROP_ENUM:
*r_values = (float)RNA_property_enum_get_default(ptr, prop);
*r_values = float(RNA_property_enum_get_default(ptr, prop));
break;
default:
*r_values = 0.0f;
+14 -14
View File
@@ -86,7 +86,7 @@ static bool is_appdir_init = false;
# define ASSERT_IS_INIT() ((void)0)
#endif
void BKE_appdir_init(void)
void BKE_appdir_init()
{
#ifndef NDEBUG
BLI_assert(is_appdir_init == false);
@@ -94,7 +94,7 @@ void BKE_appdir_init(void)
#endif
}
void BKE_appdir_exit(void)
void BKE_appdir_exit()
{
#ifndef NDEBUG
BLI_assert(is_appdir_init == true);
@@ -125,7 +125,7 @@ static char *blender_version_decimal(const int version)
/** \name Default Directories
* \{ */
const char *BKE_appdir_folder_default(void)
const char *BKE_appdir_folder_default()
{
#ifndef WIN32
return BLI_getenv("HOME");
@@ -140,7 +140,7 @@ const char *BKE_appdir_folder_default(void)
#endif /* WIN32 */
}
const char *BKE_appdir_folder_root(void)
const char *BKE_appdir_folder_root()
{
#ifndef WIN32
return "/";
@@ -151,7 +151,7 @@ const char *BKE_appdir_folder_root(void)
#endif
}
const char *BKE_appdir_folder_default_or_root(void)
const char *BKE_appdir_folder_default_or_root()
{
const char *path = BKE_appdir_folder_default();
if (path == nullptr) {
@@ -160,7 +160,7 @@ const char *BKE_appdir_folder_default_or_root(void)
return path;
}
const char *BKE_appdir_folder_home(void)
const char *BKE_appdir_folder_home()
{
#ifdef WIN32
return BLI_getenv("userprofile");
@@ -405,7 +405,7 @@ static bool get_path_local(char *targetpath,
targetpath, targetpath_maxncpy, folder_name, subfolder_name, version, check_is_dir);
}
bool BKE_appdir_app_is_portable_install(void)
bool BKE_appdir_app_is_portable_install()
{
/* Detect portable install by the existence of `config` folder. */
char dirpath[FILE_MAX];
@@ -844,7 +844,7 @@ static void where_am_i(char *program_filepath,
if (!BLI_exists(program_filepath)) {
CLOG_ERROR(&LOG,
"path can't be found: \"%.*s\"",
(int)program_filepath_maxncpy,
int(program_filepath_maxncpy),
program_filepath);
MessageBox(nullptr,
"path contains invalid characters or is too long (see console)",
@@ -914,7 +914,7 @@ void BKE_appdir_program_path_init(const char *argv0)
#endif
}
const char *BKE_appdir_program_path(void)
const char *BKE_appdir_program_path()
{
#ifndef WITH_PYTHON_MODULE /* Default's to empty when building as a Python module. */
BLI_assert(g_app.program_filepath[0]);
@@ -922,7 +922,7 @@ const char *BKE_appdir_program_path(void)
return g_app.program_filepath;
}
const char *BKE_appdir_program_dir(void)
const char *BKE_appdir_program_dir()
{
BLI_assert(g_app.program_dirname[0]);
return g_app.program_dirname;
@@ -1016,7 +1016,7 @@ static const int app_template_directory_id[2] = {
BLENDER_SYSTEM_SCRIPTS,
};
bool BKE_appdir_app_template_any(void)
bool BKE_appdir_app_template_any()
{
char temp_dir[FILE_MAX];
for (int i = 0; i < ARRAY_SIZE(app_template_directory_id); i++) {
@@ -1177,17 +1177,17 @@ void BKE_tempdir_init(const char *userdir)
g_app.temp_dirname_session, sizeof(g_app.temp_dirname_session), g_app.temp_dirname_base);
}
const char *BKE_tempdir_session(void)
const char *BKE_tempdir_session()
{
return g_app.temp_dirname_session[0] ? g_app.temp_dirname_session : BKE_tempdir_base();
}
const char *BKE_tempdir_base(void)
const char *BKE_tempdir_base()
{
return g_app.temp_dirname_base;
}
void BKE_tempdir_session_purge(void)
void BKE_tempdir_session_purge()
{
if (g_app.temp_dirname_session[0] && BLI_is_dir(g_app.temp_dirname_session)) {
BLI_delete(g_app.temp_dirname_session, true, true);
+8 -8
View File
@@ -1393,7 +1393,7 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters *param,
const float log_scale_out_len = logf(param->scale_out[1]);
for (int i = 0; i < param->segments; i++) {
const float fac = ((float)i) / (param->segments - 1);
const float fac = (float(i)) / (param->segments - 1);
segment_scales[i] = expf(interpf(log_scale_out_len, log_scale_in_len, fac));
}
@@ -1429,7 +1429,7 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters *param,
for (int a = 1; a < param->segments; a++) {
evaluate_cubic_bezier(bezt_controls, bezt_points[a], cur, axis);
float fac = ((float)a) / param->segments;
float fac = (float(a)) / param->segments;
float roll = interpf(roll2, roll1, fac);
float scalex = interpf(param->scale_out[0], param->scale_in[0], fac);
float scalez = interpf(param->scale_out[2], param->scale_in[2], fac);
@@ -1481,13 +1481,13 @@ static void allocate_bbone_cache(bPoseChannel *pchan, int segments)
runtime->bbone_segments = segments;
runtime->bbone_rest_mats = static_cast<Mat4 *>(MEM_malloc_arrayN(
1 + (uint)segments, sizeof(Mat4), "bPoseChannel_Runtime::bbone_rest_mats"));
1 + uint(segments), sizeof(Mat4), "bPoseChannel_Runtime::bbone_rest_mats"));
runtime->bbone_pose_mats = static_cast<Mat4 *>(MEM_malloc_arrayN(
1 + (uint)segments, sizeof(Mat4), "bPoseChannel_Runtime::bbone_pose_mats"));
1 + uint(segments), sizeof(Mat4), "bPoseChannel_Runtime::bbone_pose_mats"));
runtime->bbone_deform_mats = static_cast<Mat4 *>(MEM_malloc_arrayN(
2 + (uint)segments, sizeof(Mat4), "bPoseChannel_Runtime::bbone_deform_mats"));
2 + uint(segments), sizeof(Mat4), "bPoseChannel_Runtime::bbone_deform_mats"));
runtime->bbone_dual_quats = static_cast<DualQuat *>(MEM_malloc_arrayN(
1 + (uint)segments, sizeof(DualQuat), "bPoseChannel_Runtime::bbone_dual_quats"));
1 + uint(segments), sizeof(DualQuat), "bPoseChannel_Runtime::bbone_dual_quats"));
}
}
@@ -1578,9 +1578,9 @@ void BKE_pchan_bbone_deform_segment_index(const bPoseChannel *pchan,
* Integer part is the first segment's index.
* Integer part plus 1 is the second segment's index.
* Fractional part is the blend factor. */
float pre_blend = pos * (float)segments;
float pre_blend = pos * float(segments);
int index = (int)floorf(pre_blend);
int index = int(floorf(pre_blend));
CLAMP(index, 0, segments - 1);
float blend = pre_blend - index;
@@ -107,7 +107,7 @@ static void splineik_init_tree_from_pchan(Scene * /*scene*/,
/* Perform binding step if required. */
if ((ik_data->flag & CONSTRAINT_SPLINEIK_BOUND) == 0) {
float segmentLen = (1.0f / (float)segcount);
float segmentLen = (1.0f / float(segcount));
/* Setup new empty array for the points list. */
if (ik_data->points) {
@@ -656,7 +656,7 @@ static void splineik_evaluate_bone(
float range = bulge_max - 1.0f;
float scale = (range > 0.0f) ? 1.0f / range : 0.0f;
float soft = 1.0f + range * atanf((bulge - 1.0f) * scale) / (float)M_PI_2;
float soft = 1.0f + range * atanf((bulge - 1.0f) * scale) / float(M_PI_2);
bulge = interpf(soft, hard, ik_data->bulge_smooth);
}
@@ -668,7 +668,7 @@ static void splineik_evaluate_bone(
float range = 1.0f - bulge_min;
float scale = (range > 0.0f) ? 1.0f / range : 0.0f;
float soft = 1.0f - range * atanf((1.0f - bulge) * scale) / (float)M_PI_2;
float soft = 1.0f - range * atanf((1.0f - bulge) * scale) / float(M_PI_2);
bulge = interpf(soft, hard, ik_data->bulge_smooth);
}
+7 -7
View File
@@ -56,7 +56,7 @@ UserDef U;
/** \name Blender Free on Exit
* \{ */
void BKE_blender_free(void)
void BKE_blender_free()
{
/* samples are in a global list..., also sets G_MAIN->sound->sample nullptr */
@@ -93,7 +93,7 @@ void BKE_blender_free(void)
static char blender_version_string[48] = "";
static void blender_version_init(void)
static void blender_version_init()
{
const char *version_cycle = "";
if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "alpha")) {
@@ -120,12 +120,12 @@ static void blender_version_init(void)
version_cycle);
}
const char *BKE_blender_version_string(void)
const char *BKE_blender_version_string()
{
return blender_version_string;
}
bool BKE_blender_version_is_alpha(void)
bool BKE_blender_version_is_alpha()
{
bool is_alpha = STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "alpha");
return is_alpha;
@@ -137,7 +137,7 @@ bool BKE_blender_version_is_alpha(void)
/** \name Blender #Global Initialize/Clear
* \{ */
void BKE_blender_globals_init(void)
void BKE_blender_globals_init()
{
blender_version_init();
@@ -158,7 +158,7 @@ void BKE_blender_globals_init(void)
G.log.level = 1;
}
void BKE_blender_globals_clear(void)
void BKE_blender_globals_clear()
{
if (G_MAIN == nullptr) {
return;
@@ -430,7 +430,7 @@ void BKE_blender_atexit_unregister(void (*func)(void *user_data), const void *us
}
}
void BKE_blender_atexit(void)
void BKE_blender_atexit()
{
struct AtExitData *ae = g_atexit, *ae_next;
while (ae) {
@@ -183,7 +183,7 @@ static BlendHandle *link_append_context_library_blohandle_ensure(
if (blo_handle == nullptr) {
if (STREQ(libname, BLO_EMBEDDED_STARTUP_BLEND)) {
blo_handle = BLO_blendhandle_from_memory(lapp_context->blendfile_mem,
(int)lapp_context->blendfile_memsize,
int(lapp_context->blendfile_memsize),
&lib_context->bf_reports);
}
else {
@@ -254,7 +254,7 @@ void BKE_blendfile_link_append_context_embedded_blendfile_set(
"Please explicitly clear reference to an embedded blender memfile before "
"setting a new one");
lapp_context->blendfile_mem = blendfile_mem;
lapp_context->blendfile_memsize = (size_t)blendfile_memsize;
lapp_context->blendfile_memsize = size_t(blendfile_memsize);
}
void BKE_blendfile_link_append_context_embedded_blendfile_clear(
+8 -8
View File
@@ -466,8 +466,8 @@ static bool rule_flock(BoidRule * /*rule*/,
add_v3_v3(vec, bbd->sim->psys->particles[ptn[n].index].prev_state.vel);
}
mul_v3_fl(loc, 1.0f / ((float)neighbors - 1.0f));
mul_v3_fl(vec, 1.0f / ((float)neighbors - 1.0f));
mul_v3_fl(loc, 1.0f / (float(neighbors) - 1.0f));
mul_v3_fl(vec, 1.0f / (float(neighbors) - 1.0f));
sub_v3_v3(loc, pa->prev_state.co);
sub_v3_v3(vec, pa->prev_state.vel);
@@ -812,7 +812,7 @@ static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData *
if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
val->max_speed = boids->land_max_speed * bpa->data.health / boids->health;
val->max_acc = boids->land_max_acc * val->max_speed;
val->max_ave = boids->land_max_ave * (float)M_PI * bpa->data.health / boids->health;
val->max_ave = boids->land_max_ave * float(M_PI) * bpa->data.health / boids->health;
val->min_speed = 0.0f; /* no minimum speed on land */
val->personal_space = boids->land_personal_space;
val->jump_speed = boids->land_jump_speed * bpa->data.health / boids->health;
@@ -820,7 +820,7 @@ static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData *
else {
val->max_speed = boids->air_max_speed * bpa->data.health / boids->health;
val->max_acc = boids->air_max_acc * val->max_speed;
val->max_ave = boids->air_max_ave * (float)M_PI * bpa->data.health / boids->health;
val->max_ave = boids->air_max_ave * float(M_PI) * bpa->data.health / boids->health;
val->min_speed = boids->air_min_speed * boids->air_max_speed;
val->personal_space = boids->air_personal_space;
val->jump_speed = 0.0f; /* no jumping in air */
@@ -1085,8 +1085,8 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
bbd->wanted_speed = 0.0f;
/* create random seed for every particle & frame */
rand = (int)(psys_frand(psys, psys->seed + p) * 1000);
rand = (int)(psys_frand(psys, (int)bbd->cfra + rand) * 1000);
rand = int(psys_frand(psys, psys->seed + p) * 1000);
rand = int(psys_frand(psys, int(bbd->cfra) + rand) * 1000);
set_boid_values(&val, bbd->part->boids, pa);
@@ -1123,8 +1123,8 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
}
if (n > 1) {
mul_v3_fl(wanted_co, 1.0f / (float)n);
wanted_speed /= (float)n;
mul_v3_fl(wanted_co, 1.0f / float(n));
wanted_speed /= float(n);
}
copy_v3_v3(bbd->wanted_co, wanted_co);
+1 -1
View File
@@ -642,7 +642,7 @@ static bool bpath_list_append(BPathForeachPathData *bpath_data,
/* NOTE: the PathStore and its string are allocated together in a single alloc. */
struct PathStore *path_store = static_cast<PathStore *>(
MEM_mallocN(sizeof(struct PathStore) + path_size, __func__));
MEM_mallocN(sizeof(PathStore) + path_size, __func__));
char *filepath = path_store->filepath;
@@ -163,12 +163,12 @@ IDTypeInfo IDType_ID_CF = {
/* TODO: make this per cache file to avoid global locks. */
static SpinLock spin;
void BKE_cachefiles_init(void)
void BKE_cachefiles_init()
{
BLI_spin_init(&spin);
}
void BKE_cachefiles_exit(void)
void BKE_cachefiles_exit()
{
BLI_spin_end(&spin);
}
@@ -401,8 +401,8 @@ bool BKE_cachefile_filepath_get(const Main *bmain,
if (cache_file->is_sequence && BLI_path_frame_get(r_filepath, &fframe, &frame_len)) {
Scene *scene = DEG_get_evaluated_scene(depsgraph);
const float ctime = BKE_scene_ctime_get(scene);
const double fps = (((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base);
const int frame = (int)BKE_cachefile_time_offset(cache_file, (double)ctime, fps);
const double fps = double(scene->r.frs_sec) / double(scene->r.frs_sec_base);
const int frame = int(BKE_cachefile_time_offset(cache_file, double(ctime), fps));
char ext[32];
BLI_path_frame_strip(r_filepath, ext, sizeof(ext));
@@ -418,8 +418,8 @@ bool BKE_cachefile_filepath_get(const Main *bmain,
double BKE_cachefile_time_offset(const CacheFile *cache_file, const double time, const double fps)
{
const double time_offset = (double)cache_file->frame_offset / fps;
const double frame = (cache_file->override_frame ? (double)cache_file->frame : time);
const double time_offset = double(cache_file->frame_offset) / fps;
const double frame = (cache_file->override_frame ? double(cache_file->frame) : time);
return cache_file->is_sequence ? frame : frame / fps - time_offset;
}
@@ -454,7 +454,7 @@ CacheFileLayer *BKE_cachefile_add_layer(CacheFile *cache_file, const char filepa
BLI_addtail(&cache_file->layers, layer);
cache_file->active_layer = (char)(num_layers + 1);
cache_file->active_layer = char(num_layers + 1);
return layer;
}
@@ -111,12 +111,12 @@ void BKE_callback_remove(bCallbackFuncStore *funcstore, eCbEvent evt)
}
}
void BKE_callback_global_init(void)
void BKE_callback_global_init()
{
callbacks_initialized = true;
}
void BKE_callback_global_finalize(void)
void BKE_callback_global_finalize()
{
for (int evt_i = 0; evt_i < BKE_CB_EVT_TOT; evt_i++) {
const eCbEvent evt = eCbEvent(evt_i);
+6 -6
View File
@@ -399,10 +399,10 @@ void BKE_camera_params_compute_viewplane(
/* compute view plane:
* Fully centered, Z-buffer fills in jittered between `-.5` and `+.5`. */
viewplane.xmin = -0.5f * (float)winx;
viewplane.ymin = -0.5f * params->ycor * (float)winy;
viewplane.xmax = 0.5f * (float)winx;
viewplane.ymax = 0.5f * params->ycor * (float)winy;
viewplane.xmin = -0.5f * float(winx);
viewplane.ymin = -0.5f * params->ycor * float(winy);
viewplane.xmax = 0.5f * float(winx);
viewplane.ymax = 0.5f * params->ycor * float(winy);
/* lens shift and offset */
dx = params->shiftx * viewfac + winx * params->offsetx;
@@ -470,8 +470,8 @@ void BKE_camera_view_frame_ex(const Scene *scene,
/* aspect correction */
if (scene) {
float aspx = (float)scene->r.xsch * scene->r.xasp;
float aspy = (float)scene->r.ysch * scene->r.yasp;
float aspx = float(scene->r.xsch) * scene->r.xasp;
float aspy = float(scene->r.ysch) * scene->r.yasp;
int sensor_fit = BKE_camera_sensor_fit(camera->sensor_fit, aspx, aspy);
if (sensor_fit == CAMERA_SENSOR_FIT_HOR) {
@@ -1095,7 +1095,7 @@ static void collection_gobject_assert_internal_consistency(Collection *collectio
static GHash *collection_gobject_hash_alloc(const Collection *collection)
{
return BLI_ghash_ptr_new_ex(__func__, (uint)BLI_listbase_count(&collection->gobject));
return BLI_ghash_ptr_new_ex(__func__, uint(BLI_listbase_count(&collection->gobject)));
}
static void collection_gobject_hash_create(Collection *collection)
@@ -73,7 +73,7 @@ static void colorband_init_from_table_rgba_simple(ColorBand *coba,
BLI_assert(array_len < MAXCOLORBAND);
int stops = min_ii(MAXCOLORBAND, array_len);
if (stops) {
const float step_size = 1.0f / (float)max_ii(stops - 1, 1);
const float step_size = 1.0f / float(max_ii(stops - 1, 1));
int i_curr = -1;
for (int i_step = 0; i_step < stops; i_step++) {
if ((i_curr != -1) && compare_v4v4(&coba->data[i_curr].r, array[i_step], eps)) {
@@ -151,7 +151,7 @@ static float filter_gauss(float x)
const float gaussfac = 1.6f;
const float two_gaussfac2 = 2.0f * gaussfac * gaussfac;
x *= 3.0f * gaussfac;
return 1.0f / sqrtf((float)M_PI * two_gaussfac2) * expf(-x * x / two_gaussfac2);
return 1.0f / sqrtf(float(M_PI) * two_gaussfac2) * expf(-x * x / two_gaussfac2);
}
static void colorband_init_from_table_rgba_resample(ColorBand *coba,
@@ -166,7 +166,7 @@ static void colorband_init_from_table_rgba_resample(ColorBand *coba,
int carr_len = array_len;
c = carr;
{
const float step_size = 1.0f / (float)(array_len - 1);
const float step_size = 1.0f / float(array_len - 1);
for (int i = 0; i < array_len; i++, c++) {
copy_v4_v4(carr[i].rgba, array[i]);
c->next = c + 1;
@@ -242,10 +242,10 @@ static void colorband_init_from_table_rgba_resample(ColorBand *coba,
copy_v4_v4(rgba, c->rgba);
if (steps_prev) {
const float step_size = 1.0 / (float)(steps_prev + 1);
const float step_size = 1.0 / float(steps_prev + 1);
int j = steps_prev;
for (struct ColorResampleElem *c_other = c - 1; c_other != c->prev; c_other--, j--) {
const float step_pos = (float)j * step_size;
const float step_pos = float(j) * step_size;
BLI_assert(step_pos > 0.0f && step_pos < 1.0f);
const float f = filter_gauss(step_pos);
madd_v4_v4fl(rgba, c_other->rgba, f);
@@ -253,10 +253,10 @@ static void colorband_init_from_table_rgba_resample(ColorBand *coba,
}
}
if (steps_next) {
const float step_size = 1.0 / (float)(steps_next + 1);
const float step_size = 1.0 / float(steps_next + 1);
int j = steps_next;
for (struct ColorResampleElem *c_other = c + 1; c_other != c->next; c_other++, j--) {
const float step_pos = (float)j * step_size;
const float step_pos = float(j) * step_size;
BLI_assert(step_pos > 0.0f && step_pos < 1.0f);
const float f = filter_gauss(step_pos);
madd_v4_v4fl(rgba, c_other->rgba, f);
@@ -565,7 +565,7 @@ void BKE_colorband_evaluate_table_rgba(const ColorBand *coba, float **array, int
*array = static_cast<float *>(MEM_callocN(sizeof(float) * (*size) * 4, "ColorBand"));
for (a = 0; a < *size; a++) {
BKE_colorband_evaluate(coba, (float)a / (float)CM_TABLE, &(*array)[a * 4]);
BKE_colorband_evaluate(coba, float(a) / float(CM_TABLE), &(*array)[a * 4]);
}
}
+23 -23
View File
@@ -337,7 +337,7 @@ void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope
break;
case CURVE_PRESET_MID9: {
for (int i = 0; i < cuma->totpoint; i++) {
cuma->curve[i].x = i / ((float)cuma->totpoint - 1);
cuma->curve[i].x = i / (float(cuma->totpoint) - 1);
cuma->curve[i].y = 0.5;
}
break;
@@ -750,7 +750,7 @@ static void curvemap_make_table(const CurveMapping *cumap, CurveMap *cuma)
MEM_callocN((CM_TABLE + 1) * sizeof(CurveMapPoint), "dist table"));
for (int a = 0; a <= CM_TABLE; a++) {
float cur_x = cuma->mintable + range * (float)a;
float cur_x = cuma->mintable + range * float(a);
cmp[a].x = cur_x;
/* Get the first point with x coordinate larger than cur_x. */
@@ -962,7 +962,7 @@ float BKE_curvemap_evaluateF(const CurveMapping *cumap, const CurveMap *cuma, fl
{
/* index in table */
float fi = (value - cuma->mintable) * cuma->range;
int i = (int)fi;
int i = int(fi);
/* fi is table float index and should check against table range i.e. [0.0 CM_TABLE] */
if (fi < 0.0f || fi > CM_TABLE) {
@@ -976,7 +976,7 @@ float BKE_curvemap_evaluateF(const CurveMapping *cumap, const CurveMap *cuma, fl
return cuma->table[CM_TABLE].y;
}
fi = fi - (float)i;
fi = fi - float(i);
return (1.0f - fi) * cuma->table[i].y + (fi)*cuma->table[i + 1].y;
}
@@ -1113,9 +1113,9 @@ void BKE_curvemapping_evaluate_premulRGB(const CurveMapping *cumap,
{
float vecin[3], vecout[3];
vecin[0] = (float)vecin_byte[0] / 255.0f;
vecin[1] = (float)vecin_byte[1] / 255.0f;
vecin[2] = (float)vecin_byte[2] / 255.0f;
vecin[0] = float(vecin_byte[0]) / 255.0f;
vecin[1] = float(vecin_byte[1]) / 255.0f;
vecin[2] = float(vecin_byte[2]) / 255.0f;
BKE_curvemapping_evaluate_premulRGBF(cumap, vecout, vecin);
@@ -1325,7 +1325,7 @@ void BKE_curvemapping_blend_read(BlendDataReader *reader, CurveMapping *cumap)
BLI_INLINE int get_bin_float(float f)
{
int bin = (int)((f * 255.0f) + 0.5f); /* 0.5 to prevent quantization differences */
int bin = int((f * 255.0f) + 0.5f); /* 0.5 to prevent quantization differences */
/* NOTE: clamp integer instead of float to avoid problems with NaN. */
CLAMP(bin, 0, 255);
@@ -1401,8 +1401,8 @@ void BKE_histogram_update_sample_line(Histogram *hist,
}
for (i = 0; i < 256; i++) {
x = (int)(0.5f + x1 + (float)i * (x2 - x1) / 255.0f);
y = (int)(0.5f + y1 + (float)i * (y2 - y1) / 255.0f);
x = int(0.5f + x1 + float(i) * (x2 - x1) / 255.0f);
y = int(0.5f + y1 + float(i) * (y2 - y1) / 255.0f);
if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y) {
hist->data_luma[i] = hist->data_r[i] = hist->data_g[i] = hist->data_b[i] = hist->data_a[i] =
@@ -1443,11 +1443,11 @@ void BKE_histogram_update_sample_line(Histogram *hist,
}
else if (ibuf->byte_buffer.data) {
cp = ibuf->byte_buffer.data + 4 * (y * ibuf->x + x);
hist->data_luma[i] = (float)IMB_colormanagement_get_luminance_byte(cp) / 255.0f;
hist->data_r[i] = (float)cp[0] / 255.0f;
hist->data_g[i] = (float)cp[1] / 255.0f;
hist->data_b[i] = (float)cp[2] / 255.0f;
hist->data_a[i] = (float)cp[3] / 255.0f;
hist->data_luma[i] = float(IMB_colormanagement_get_luminance_byte(cp)) / 255.0f;
hist->data_r[i] = float(cp[0]) / 255.0f;
hist->data_g[i] = float(cp[1]) / 255.0f;
hist->data_b[i] = float(cp[2]) / 255.0f;
hist->data_a[i] = float(cp[3]) / 255.0f;
}
}
}
@@ -1505,10 +1505,10 @@ static void scopes_update_cb(void *__restrict userdata,
const bool is_float = (ibuf->float_buffer.data != nullptr);
if (is_float) {
rf = ibuf->float_buffer.data + ((size_t)y) * ibuf->x * ibuf->channels;
rf = ibuf->float_buffer.data + (size_t(y)) * ibuf->x * ibuf->channels;
}
else {
rc = display_buffer + ((size_t)y) * ibuf->x * ibuf->channels;
rc = display_buffer + (size_t(y)) * ibuf->x * ibuf->channels;
}
for (int x = 0; x < ibuf->x; x++) {
@@ -1564,7 +1564,7 @@ static void scopes_update_cb(void *__restrict userdata,
/* save sample if needed */
if (do_sample_line) {
const float fx = (float)x / (float)ibuf->x;
const float fx = float(x) / float(ibuf->x);
const int idx = 2 * (ibuf->x * savedlines + x);
save_sample_line(scopes, idx, fx, rgba, ycc);
}
@@ -1748,11 +1748,11 @@ void BKE_scopes_update(Scopes *scopes,
na = data_chunk.bin_a[a];
}
}
divl = nl ? 1.0 / (double)nl : 1.0;
diva = na ? 1.0 / (double)na : 1.0;
divr = nr ? 1.0 / (double)nr : 1.0;
divg = ng ? 1.0 / (double)ng : 1.0;
divb = nb ? 1.0 / (double)nb : 1.0;
divl = nl ? 1.0 / double(nl) : 1.0;
diva = na ? 1.0 / double(na) : 1.0;
divr = nr ? 1.0 / double(nr) : 1.0;
divg = ng ? 1.0 / double(ng) : 1.0;
divb = nb ? 1.0 / double(nb) : 1.0;
for (a = 0; a < 256; a++) {
scopes->hist.data_luma[a] = data_chunk.bin_lum[a] * divl;
+16 -17
View File
@@ -922,7 +922,7 @@ static void default_get_tarmat_full_bbone(Depsgraph * /*depsgraph*/,
if (no_copy == 0) { \
datatar = ct->tar; \
STRNCPY(datasubtarget, ct->subtarget); \
con->tarspace = (char)ct->space; \
con->tarspace = char(ct->space); \
} \
\
BLI_freelinkN(list, ct); \
@@ -943,7 +943,7 @@ static void default_get_tarmat_full_bbone(Depsgraph * /*depsgraph*/,
bConstraintTarget *ctn = ct->next; \
if (no_copy == 0) { \
datatar = ct->tar; \
con->tarspace = (char)ct->space; \
con->tarspace = char(ct->space); \
} \
\
BLI_freelinkN(list, ct); \
@@ -1245,7 +1245,7 @@ static void vectomat(const float vec[3],
if (axis != upflag) {
right_index = 3 - axis - upflag;
neg = (float)basis_cross(axis, upflag);
neg = float(basis_cross(axis, upflag));
/* account for up direction, track direction */
m[right_index][0] = neg * right[0];
@@ -1290,7 +1290,7 @@ static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
* for backwards compatibility it seems. */
sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]);
vectomat(
vec, ct->matrix[2], (short)data->reserved1, (short)data->reserved2, data->flags, totmat);
vec, ct->matrix[2], short(data->reserved1), short(data->reserved2), data->flags, totmat);
mul_m4_m3m4(cob->matrix, totmat, cob->matrix);
}
@@ -2865,7 +2865,7 @@ static void actcon_get_tarmat(Depsgraph *depsgraph,
axis = data->type - 20;
}
BLI_assert((uint)axis < 3);
BLI_assert(uint(axis) < 3);
/* Target defines the animation */
s = (vec[axis] - data->min) / (data->max - data->min);
@@ -3391,8 +3391,7 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
else if (data->flag & LIMITDIST_USESOFT) {
/* FIXME: there's a problem with "jumping" when this kicks in */
if (dist >= (data->dist - data->soft)) {
sfac = (float)(data->soft * (1.0f - expf(-(dist - data->dist) / data->soft)) +
data->dist);
sfac = float(data->soft * (1.0f - expf(-(dist - data->dist) / data->soft)) + data->dist);
if (dist != 0.0f) {
sfac /= dist;
}
@@ -3542,7 +3541,7 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
float range = bulge_max - 1.0f;
float scale_fac = (range > 0.0f) ? 1.0f / range : 0.0f;
float soft = 1.0f + range * atanf((bulge - 1.0f) * scale_fac) / (float)M_PI_2;
float soft = 1.0f + range * atanf((bulge - 1.0f) * scale_fac) / float(M_PI_2);
bulge = interpf(soft, hard, data->bulge_smooth);
}
@@ -3554,7 +3553,7 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
float range = 1.0f - bulge_min;
float scale_fac = (range > 0.0f) ? 1.0f / range : 0.0f;
float soft = 1.0f - range * atanf((1.0f - bulge) * scale_fac) / (float)M_PI_2;
float soft = 1.0f - range * atanf((1.0f - bulge) * scale_fac) / float(M_PI_2);
bulge = interpf(soft, hard, data->bulge_smooth);
}
@@ -3899,7 +3898,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
else if (ownLoc[clamp_axis] > curveMax[clamp_axis]) {
/* bounding-box range is after */
offset = curveMax[clamp_axis] +
(int)((ownLoc[clamp_axis] - curveMax[clamp_axis]) / len) * len;
int((ownLoc[clamp_axis] - curveMax[clamp_axis]) / len) * len;
/* Now, we calculate as per normal,
* except using offset instead of curveMax[clamp_axis]. */
@@ -4093,7 +4092,7 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
to_min = data->to_min_scale;
to_max = data->to_max_scale;
for (int i = 0; i < 3; i++) {
newsize[i] = to_min[i] + (sval[(int)data->map[i]] * (to_max[i] - to_min[i]));
newsize[i] = to_min[i] + (sval[int(data->map[i])] * (to_max[i] - to_min[i]));
}
switch (data->mix_mode_scale) {
case TRANS_MIXSCALE_MULTIPLY:
@@ -4109,7 +4108,7 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
to_min = data->to_min_rot;
to_max = data->to_max_rot;
for (int i = 0; i < 3; i++) {
neweul[i] = to_min[i] + (sval[(int)data->map[i]] * (to_max[i] - to_min[i]));
neweul[i] = to_min[i] + (sval[int(data->map[i])] * (to_max[i] - to_min[i]));
}
switch (data->mix_mode_rot) {
case TRANS_MIXROT_REPLACE:
@@ -4136,7 +4135,7 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
to_min = data->to_min;
to_max = data->to_max;
for (int i = 0; i < 3; i++) {
newloc[i] = (to_min[i] + (sval[(int)data->map[i]] * (to_max[i] - to_min[i])));
newloc[i] = (to_min[i] + (sval[int(data->map[i])] * (to_max[i] - to_min[i])));
}
switch (data->mix_mode_loc) {
case TRANS_MIXLOC_REPLACE:
@@ -5009,14 +5008,14 @@ static void followtrack_fit_frame(FollowTrackContext *context,
if ((asp_src > asp_dst) == (context->frame_method == FOLLOWTRACK_FRAME_CROP)) {
/* fit X */
float div = asp_src / asp_dst;
float cent = (float)clip_width / 2.0f;
float cent = float(clip_width) / 2.0f;
marker_position[0] = (((marker_position[0] * clip_width - cent) * div) + cent) / clip_width;
}
else {
/* fit Y */
float div = asp_dst / asp_src;
float cent = (float)clip_height / 2.0f;
float cent = float(clip_height) / 2.0f;
marker_position[1] = (((marker_position[1] * clip_height - cent) * div) + cent) / clip_height;
}
@@ -5376,7 +5375,7 @@ static void transformcache_evaluate(bConstraint *con, bConstraintOb *cob, ListBa
}
const float frame = DEG_get_ctime(cob->depsgraph);
const double time = BKE_cachefile_time_offset(cache_file, (double)frame, FPS);
const double time = BKE_cachefile_time_offset(cache_file, double(frame), FPS);
if (!data->reader || !STREQ(data->reader_object_path, data->object_path)) {
STRNCPY(data->reader_object_path, data->object_path);
@@ -5457,7 +5456,7 @@ static bConstraintTypeInfo *constraintsTypeInfo[NUM_CONSTRAINT_TYPES];
static short CTI_INIT = 1; /* when non-zero, the list needs to be updated */
/* This function only gets called when CTI_INIT is non-zero */
static void constraints_init_typeinfo(void)
static void constraints_init_typeinfo()
{
constraintsTypeInfo[0] = nullptr; /* 'Null' Constraint */
constraintsTypeInfo[1] = &CTI_CHILDOF; /* ChildOf Constraint */
@@ -50,10 +50,10 @@ static void bevel_quarter_fill(const Curve *curve,
{
if (curve->bevel_mode == CU_BEV_MODE_ROUND) {
float angle = 0.0f;
const float dangle = (float)M_PI_2 / (curve->bevresol + 1);
const float dangle = float(M_PI_2) / (curve->bevresol + 1);
for (int i = 0; i < curve->bevresol + 1; i++) {
quarter_coords_x[i] = (float)(cosf(angle) * (curve->bevel_radius));
quarter_coords_y[i] = (float)(sinf(angle) * (curve->bevel_radius));
quarter_coords_x[i] = float(cosf(angle) * (curve->bevel_radius));
quarter_coords_y[i] = float(sinf(angle) * (curve->bevel_radius));
angle += dangle;
}
}
@@ -67,8 +67,8 @@ static void bevel_quarter_fill(const Curve *curve,
quarter_coords_x[0] = curve->bevel_radius;
quarter_coords_y[0] = 0.0f;
for (int i = 1; i < curve->bevresol + 1; i++) {
quarter_coords_x[i] = (float)(curve->bevel_profile->segments[i].x * (curve->bevel_radius));
quarter_coords_y[i] = (float)(curve->bevel_profile->segments[i].y * (curve->bevel_radius));
quarter_coords_x[i] = float(curve->bevel_profile->segments[i].x * (curve->bevel_radius));
quarter_coords_y[i] = float(curve->bevel_profile->segments[i].y * (curve->bevel_radius));
}
}
}
@@ -196,7 +196,7 @@ static void curve_bevel_make_full_circle(const Curve *cu, ListBase *disp)
dl->nr = nr;
float *fp = dl->verts;
const float dangle = (2.0f * (float)M_PI / (nr));
const float dangle = (2.0f * float(M_PI) / (nr));
float angle = -(nr - 1) * dangle;
for (int i = 0; i < nr; i++) {
@@ -278,7 +278,7 @@ uint BKE_curve_decimate_bezt_array(BezTriple *bezt_array,
knots_len_decimated--;
}
else {
bezt_array[i].f2 &= (char)~flag_set;
bezt_array[i].f2 &= char(~flag_set);
if (is_cyclic || i != 0) {
uint i_prev = (i != 0) ? i - 1 : bezt_array_last;
if (knots[i_prev].is_removed) {
@@ -314,7 +314,7 @@ void BKE_curve_decimate_nurb(Nurb *nu,
const char flag_test = BEZT_FLAG_TEMP_TAG;
const uint pntsu_dst = BKE_curve_decimate_bezt_array(nu->bezt,
(uint)nu->pntsu,
uint(nu->pntsu),
resolu,
(nu->flagu & CU_NURB_CYCLIC) != 0,
SELECT,
@@ -322,7 +322,7 @@ void BKE_curve_decimate_nurb(Nurb *nu,
error_sq_max,
error_target_len);
if (pntsu_dst == (uint)nu->pntsu) {
if (pntsu_dst == uint(nu->pntsu)) {
return;
}
@@ -84,7 +84,7 @@ struct CDataFile {
/********************************* Create/Free *******************************/
static int cdf_endian(void)
static int cdf_endian()
{
if (ENDIAN_ORDER == L_ENDIAN) {
return CDF_ENDIAN_LITTLE;
+13 -13
View File
@@ -81,7 +81,7 @@ PartDeflect *BKE_partdeflect_new(int type)
pd->pdef_sbift = 0.2f;
pd->pdef_sboft = 0.02f;
pd->pdef_cfrict = 5.0f;
pd->seed = ((uint)ceil(PIL_check_seconds_timer()) + 1) % 128;
pd->seed = (uint(ceil(PIL_check_seconds_timer())) + 1) % 128;
pd->f_strength = 1.0f;
pd->f_damp = 1.0f;
@@ -137,7 +137,7 @@ void BKE_partdeflect_free(PartDeflect *pd)
static void precalculate_effector(Depsgraph *depsgraph, EffectorCache *eff)
{
float ctime = DEG_get_ctime(depsgraph);
uint cfra = (uint)(ctime >= 0 ? ctime : -ctime);
uint cfra = uint(ctime >= 0 ? ctime : -ctime);
if (!eff->pd->rng) {
eff->pd->rng = BLI_rng_new(eff->pd->seed + cfra);
}
@@ -430,7 +430,7 @@ void pd_point_from_loc(Scene *scene, float *loc, float *vel, int index, Effected
point->index = index;
point->size = 0.0f;
point->vel_to_sec = (float)scene->r.frs_sec;
point->vel_to_sec = float(scene->r.frs_sec);
point->vel_to_frame = 1.0f;
point->flag = 0;
@@ -445,7 +445,7 @@ void pd_point_from_soft(Scene *scene, float *loc, float *vel, int index, Effecte
point->index = index;
point->size = 0.0f;
point->vel_to_sec = (float)scene->r.frs_sec;
point->vel_to_sec = float(scene->r.frs_sec);
point->vel_to_frame = 1.0f;
point->flag = PE_WIND_AS_SPEED;
@@ -547,9 +547,9 @@ static float wind_func(RNG *rng, float strength)
float sign = 0;
/* Dividing by 2 is not giving equal sign distribution. */
sign = ((float)random > 64.0f) ? 1.0f : -1.0f;
sign = (float(random) > 64.0f) ? 1.0f : -1.0f;
ret = sign * ((float)random / force) * strength / 128.0f;
ret = sign * (float(random) / force) * strength / 128.0f;
return ret;
}
@@ -573,7 +573,7 @@ static float falloff_func(
mindist = 0.0;
}
return pow((double)(1.0f + fac - mindist), (double)(-power));
return pow(double(1.0f + fac - mindist), double(-power));
}
static float falloff_func_dist(PartDeflect *pd, float fac)
@@ -855,7 +855,7 @@ static void get_effector_tot(
int totpart = eff->psys->totpart;
int amount = eff->psys->part->effector_amount;
*step = (totpart > amount) ? (int)ceil((float)totpart / (float)amount) : 1;
*step = (totpart > amount) ? int(ceil(float(totpart) / float(amount))) : 1;
}
}
else {
@@ -1241,7 +1241,7 @@ SimDebugData *_sim_debug_data = nullptr;
uint BKE_sim_debug_data_hash(int i)
{
return BLI_ghashutil_uinthash((uint)i);
return BLI_ghashutil_uinthash(uint(i));
}
uint BKE_sim_debug_data_hash_combine(uint kx, uint ky)
@@ -1312,12 +1312,12 @@ void BKE_sim_debug_data_set_enabled(bool enable)
}
}
bool BKE_sim_debug_data_get_enabled(void)
bool BKE_sim_debug_data_get_enabled()
{
return _sim_debug_data != nullptr;
}
void BKE_sim_debug_data_free(void)
void BKE_sim_debug_data_free()
{
if (_sim_debug_data) {
if (_sim_debug_data->gh) {
@@ -1402,7 +1402,7 @@ void BKE_sim_debug_data_remove_element(uint hash)
BLI_ghash_remove(_sim_debug_data->gh, &dummy, nullptr, debug_element_free);
}
void BKE_sim_debug_data_clear(void)
void BKE_sim_debug_data_clear()
{
if (!_sim_debug_data) {
return;
@@ -1414,7 +1414,7 @@ void BKE_sim_debug_data_clear(void)
void BKE_sim_debug_data_clear_category(const char *category)
{
int category_hash = (int)BLI_ghashutil_strhash_p(category);
int category_hash = int(BLI_ghashutil_strhash_p(category));
if (!_sim_debug_data) {
return;
+32 -32
View File
@@ -52,7 +52,7 @@ static CLG_LogRef LOG = {"bke.fcurve"};
/** \name F-Curve Data Create
* \{ */
FCurve *BKE_fcurve_create(void)
FCurve *BKE_fcurve_create()
{
FCurve *fcu = static_cast<FCurve *>(MEM_callocN(sizeof(FCurve), __func__));
return fcu;
@@ -822,9 +822,9 @@ float *BKE_fcurves_calc_keyed_frames_ex(FCurve **fcurve_array,
const FCurve *fcu = fcurve_array[fcurve_index];
for (int i = 0; i < fcu->totvert; i++) {
const BezTriple *bezt = &fcu->bezt[i];
const double value = round((double)bezt->vec[1][0] / interval_db);
const double value = round(double(bezt->vec[1][0]) / interval_db);
BLI_assert(value > INT_MIN && value < INT_MAX);
BLI_gset_add(frames_unique, POINTER_FROM_INT((int)value));
BLI_gset_add(frames_unique, POINTER_FROM_INT(int(value)));
}
}
@@ -835,7 +835,7 @@ float *BKE_fcurves_calc_keyed_frames_ex(FCurve **fcurve_array,
int i = 0;
GSET_ITER_INDEX (gs_iter, frames_unique, i) {
const int value = POINTER_AS_INT(BLI_gsetIterator_getKey(&gs_iter));
frames[i] = (double)value * interval_db;
frames[i] = double(value) * interval_db;
}
BLI_gset_free(frames_unique, nullptr);
@@ -875,7 +875,7 @@ void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
/* The active keyframe should always be selected. */
BLI_assert_msg(BEZT_ISSEL_ANY(active_bezt), "active keyframe must be selected");
fcu->active_keyframe_index = (int)offset;
fcu->active_keyframe_index = int(offset);
}
int BKE_fcurve_active_keyframe_index(const FCurve *fcu)
@@ -1082,8 +1082,8 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample
/* Use the sampling callback at 1-frame intervals from start to end frames. */
for (int cfra = start; cfra <= end; cfra++, fpt++) {
fpt->vec[0] = (float)cfra;
fpt->vec[1] = sample_cb(fcu, data, (float)cfra);
fpt->vec[0] = float(cfra);
fpt->vec[1] = sample_cb(fcu, data, float(cfra));
}
/* Free any existing sample/keyframe data on curve. */
@@ -1139,7 +1139,7 @@ void fcurve_samples_to_keyframes(FCurve *fcu, const int start, const int end)
int sample_points = fcu->totvert;
BezTriple *bezt = fcu->bezt = static_cast<BezTriple *>(
MEM_callocN(sizeof(*fcu->bezt) * (size_t)keyframes_to_insert, __func__));
MEM_callocN(sizeof(*fcu->bezt) * size_t(keyframes_to_insert), __func__));
fcu->totvert = keyframes_to_insert;
/* Get first sample point to 'copy' as keyframe. */
@@ -1153,7 +1153,7 @@ void fcurve_samples_to_keyframes(FCurve *fcu, const int start, const int end)
/* Add leading dummy flat points if needed. */
for (; keyframes_to_insert && (fpt->vec[0] > start); cur_pos++, bezt++, keyframes_to_insert--) {
init_unbaked_bezt_data(bezt);
bezt->vec[1][0] = (float)cur_pos;
bezt->vec[1][0] = float(cur_pos);
bezt->vec[1][1] = fpt->vec[1];
}
@@ -1168,7 +1168,7 @@ void fcurve_samples_to_keyframes(FCurve *fcu, const int start, const int end)
/* Add trailing dummy flat points if needed. */
for (fpt--; keyframes_to_insert; cur_pos++, bezt++, keyframes_to_insert--) {
init_unbaked_bezt_data(bezt);
bezt->vec[1][0] = (float)cur_pos;
bezt->vec[1][0] = float(cur_pos);
bezt->vec[1][1] = fpt->vec[1];
}
@@ -1499,9 +1499,9 @@ static int solve_cubic(double c0, double c1, double c2, double c3, float *o)
if (d > 0.0) {
t = sqrt(d);
o[0] = (float)(sqrt3d(-q + t) + sqrt3d(-q - t) - a);
o[0] = float(sqrt3d(-q + t) + sqrt3d(-q - t) - a);
if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
if ((o[0] >= float(SMALL)) && (o[0] <= 1.000001f)) {
return 1;
}
return 0;
@@ -1509,14 +1509,14 @@ static int solve_cubic(double c0, double c1, double c2, double c3, float *o)
if (d == 0.0) {
t = sqrt3d(-q);
o[0] = (float)(2 * t - a);
o[0] = float(2 * t - a);
if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
if ((o[0] >= float(SMALL)) && (o[0] <= 1.000001f)) {
nr++;
}
o[nr] = (float)(-t - a);
o[nr] = float(-t - a);
if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) {
if ((o[nr] >= float(SMALL)) && (o[nr] <= 1.000001f)) {
return nr + 1;
}
return nr;
@@ -1526,19 +1526,19 @@ static int solve_cubic(double c0, double c1, double c2, double c3, float *o)
t = sqrt(-p);
p = cos(phi / 3);
q = sqrt(3 - 3 * p * p);
o[0] = (float)(2 * t * p - a);
o[0] = float(2 * t * p - a);
if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
if ((o[0] >= float(SMALL)) && (o[0] <= 1.000001f)) {
nr++;
}
o[nr] = (float)(-t * (p + q) - a);
o[nr] = float(-t * (p + q) - a);
if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) {
if ((o[nr] >= float(SMALL)) && (o[nr] <= 1.000001f)) {
nr++;
}
o[nr] = (float)(-t * (p - q) - a);
o[nr] = float(-t * (p - q) - a);
if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) {
if ((o[nr] >= float(SMALL)) && (o[nr] <= 1.000001f)) {
return nr + 1;
}
return nr;
@@ -1553,22 +1553,22 @@ static int solve_cubic(double c0, double c1, double c2, double c3, float *o)
if (p > 0) {
p = sqrt(p);
o[0] = (float)((-b - p) / (2 * a));
o[0] = float((-b - p) / (2 * a));
if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
if ((o[0] >= float(SMALL)) && (o[0] <= 1.000001f)) {
nr++;
}
o[nr] = (float)((-b + p) / (2 * a));
o[nr] = float((-b + p) / (2 * a));
if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) {
if ((o[nr] >= float(SMALL)) && (o[nr] <= 1.000001f)) {
return nr + 1;
}
return nr;
}
if (p == 0) {
o[0] = (float)(-b / (2 * a));
if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
o[0] = float(-b / (2 * a));
if ((o[0] >= float(SMALL)) && (o[0] <= 1.000001f)) {
return 1;
}
}
@@ -1577,9 +1577,9 @@ static int solve_cubic(double c0, double c1, double c2, double c3, float *o)
}
if (b != 0.0) {
o[0] = (float)(-c / b);
o[0] = float(-c / b);
if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
if ((o[0] >= float(SMALL)) && (o[0] <= 1.000001f)) {
return 1;
}
return 0;
@@ -1843,7 +1843,7 @@ void BKE_fcurve_merge_duplicate_keys(FCurve *fcu, const int sel_flag, const bool
/* Compute the average values for each retained keyframe */
LISTBASE_FOREACH (tRetainedKeyframe *, rk, &retained_keys) {
rk->val = rk->val / (float)rk->tot_count;
rk->val = rk->val / float(rk->tot_count);
}
/* 2) Delete all keyframes duplicating the "retained keys" found above
@@ -2303,7 +2303,7 @@ static float fcurve_eval_samples(const FCurve *fcu, const FPoint *fpts, float ev
float t = fabsf(evaltime - floorf(evaltime));
/* Find the one on the right frame (assume that these are spaced on 1-frame intervals). */
const FPoint *fpt = prevfpt + ((int)evaltime - (int)prevfpt->vec[0]);
const FPoint *fpt = prevfpt + (int(evaltime) - int(prevfpt->vec[0]));
/* If not exactly on the frame, perform linear interpolation with the next one. */
if (t != 0.0f && t < 1.0f) {
@@ -105,7 +105,7 @@ struct FCurvePathCache *BKE_fcurve_pathcache_create(ListBase *list)
}
struct FCurvePathCache *fcache = static_cast<FCurvePathCache *>(
MEM_callocN(sizeof(struct FCurvePathCache), __func__));
MEM_callocN(sizeof(FCurvePathCache), __func__));
fcache->fcurve_array = fcurve_array;
fcache->fcurve_array_len = fcurve_array_len;
fcache->span_table = span_table;
@@ -164,7 +164,7 @@ int BKE_fcurve_pathcache_find_array(struct FCurvePathCache *fcache,
const uint len = span->len;
for (int i = 0; i < len; i++) {
/* As these are sorted, early exit. */
if ((uint)fcurve[i]->array_index > (uint)fcurve_result_len) {
if (uint(fcurve[i]->array_index) > uint(fcurve_result_len)) {
break;
}
fcurve_result[fcurve[i]->array_index] = fcurve[i];
@@ -213,10 +213,10 @@ static float dtar_get_prop_val(const AnimationEvalContext *anim_eval_context,
switch (RNA_property_type(value_prop)) {
case PROP_BOOLEAN:
value = (float)RNA_property_boolean_get_index(&value_ptr, value_prop, index);
value = float(RNA_property_boolean_get_index(&value_ptr, value_prop, index));
break;
case PROP_INT:
value = (float)RNA_property_int_get_index(&value_ptr, value_prop, index);
value = float(RNA_property_int_get_index(&value_ptr, value_prop, index));
break;
case PROP_FLOAT:
value = RNA_property_float_get_index(&value_ptr, value_prop, index);
@@ -229,16 +229,16 @@ static float dtar_get_prop_val(const AnimationEvalContext *anim_eval_context,
/* Not an array. */
switch (RNA_property_type(value_prop)) {
case PROP_BOOLEAN:
value = (float)RNA_property_boolean_get(&value_ptr, value_prop);
value = float(RNA_property_boolean_get(&value_ptr, value_prop));
break;
case PROP_INT:
value = (float)RNA_property_int_get(&value_ptr, value_prop);
value = float(RNA_property_int_get(&value_ptr, value_prop));
break;
case PROP_FLOAT:
value = RNA_property_float_get(&value_ptr, value_prop);
break;
case PROP_ENUM:
value = (float)RNA_property_enum_get(&value_ptr, value_prop);
value = float(RNA_property_enum_get(&value_ptr, value_prop));
break;
default:
break;
@@ -411,7 +411,7 @@ static float dvar_eval_rotDiff(const AnimationEvalContext * /*anim_eval_context*
angle = 2.0f * saacos(quat[0]);
angle = fabsf(angle);
return (angle > (float)M_PI) ? (float)((2.0f * (float)M_PI) - angle) : (float)(angle);
return (angle > float(M_PI)) ? float((2.0f * float(M_PI)) - angle) : float(angle);
}
/**
@@ -1094,7 +1094,7 @@ static bool driver_evaluate_simple_expr(const AnimationEvalContext *anim_eval_co
switch (status) {
case EXPR_PYLIKE_SUCCESS:
if (isfinite(result_val)) {
*result = (float)result_val;
*result = float(result_val);
}
return true;
@@ -1271,7 +1271,7 @@ static void evaluate_driver_sum(const AnimationEvalContext *anim_eval_context,
/* Perform operations on the total if appropriate. */
if (driver->type == DRIVER_TYPE_AVERAGE) {
driver->curval = tot ? (value / (float)tot) : 0.0f;
driver->curval = tot ? (value / float(tot)) : 0.0f;
}
else {
driver->curval = value;
+10 -10
View File
@@ -211,7 +211,7 @@ static void fcm_generator_evaluate(
/* For each coefficient pair,
* solve for that bracket before accumulating in value by multiplying. */
for (cp = data->coefficients, i = 0; (cp) && (i < (uint)data->poly_order); cp += 2, i++) {
for (cp = data->coefficients, i = 0; (cp) && (i < uint(data->poly_order)); cp += 2, i++) {
value *= (cp[0] * evaltime + cp[1]);
}
@@ -348,7 +348,7 @@ static void fcm_fn_generator_evaluate(
/* execute function callback to set value if appropriate */
if (fn) {
float value = (float)(data->amplitude * (float)fn(arg) + data->value_offset);
float value = float(data->amplitude * float(fn(arg)) + data->value_offset);
if (data->flag & FCM_GENERATOR_ADDITIVE) {
*cvalue += value;
@@ -692,7 +692,7 @@ static float fcm_cycles_time(
}
/* calculate the 'number' of the cycle */
const float cycle = ((float)side * (evaltime - ofs) / cycdx);
const float cycle = (float(side) * (evaltime - ofs) / cycdx);
/* calculate the time inside the cycle */
const float cyct = fmod(evaltime - ofs, cycdx);
@@ -713,10 +713,10 @@ static float fcm_cycles_time(
/* check if 'cyclic extrapolation', and thus calculate y-offset for this cycle */
if (mode == FCM_EXTRAPOLATE_CYCLIC_OFFSET) {
if (side < 0) {
cycyofs = (float)floor((evaltime - ofs) / cycdx);
cycyofs = float(floor((evaltime - ofs) / cycdx));
}
else {
cycyofs = (float)ceil((evaltime - ofs) / cycdx);
cycyofs = float(ceil((evaltime - ofs) / cycdx));
}
cycyofs *= cycdy;
}
@@ -725,12 +725,12 @@ static float fcm_cycles_time(
if (cyct == 0.0f) {
evaltime = (side == 1 ? lastkey[0] : prevkey[0]);
if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)cycle % 2)) {
if ((mode == FCM_EXTRAPOLATE_MIRROR) && (int(cycle) % 2)) {
evaltime = (side == 1 ? prevkey[0] : lastkey[0]);
}
}
/* calculate where in the cycle we are (overwrite evaltime to reflect this) */
else if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle + 1) % 2)) {
else if ((mode == FCM_EXTRAPOLATE_MIRROR) && (int(cycle + 1) % 2)) {
/* When 'mirror' option is used and cycle number is odd, this cycle is played in reverse
* - for 'before' extrapolation, we need to flip in a different way, otherwise values past
* then end of the curve get referenced
@@ -986,12 +986,12 @@ static float fcm_stepped_time(
* after the start offset has been discarded
* - i.e. round down
*/
snapblock = (int)((evaltime - data->offset) / data->step_size);
snapblock = int((evaltime - data->offset) / data->step_size);
/* reapply the offset, and multiple the snapblock by the size of the steps to get
* the new time to evaluate at
*/
return ((float)snapblock * data->step_size) + data->offset;
return (float(snapblock) * data->step_size) + data->offset;
}
static FModifierTypeInfo FMI_STEPPED = {
@@ -1024,7 +1024,7 @@ static FModifierTypeInfo *fmodifiersTypeInfo[FMODIFIER_NUM_TYPES];
static short FMI_INIT = 1; /* when non-zero, the list needs to be updated */
/** This function only gets called when #FMI_INIT is non-zero. */
static void fmods_init_typeinfo(void)
static void fmods_init_typeinfo()
{
fmodifiersTypeInfo[0] = nullptr; /* 'Null' F-Curve Modifier */
fmodifiersTypeInfo[1] = &FMI_GENERATOR; /* Generator F-Curve Modifier */
@@ -107,7 +107,7 @@ static void copy_lineset(FreestyleLineSet *new_lineset, FreestyleLineSet *linese
}
}
static FreestyleModuleConfig *alloc_module(void)
static FreestyleModuleConfig *alloc_module()
{
return (FreestyleModuleConfig *)MEM_callocN(sizeof(FreestyleModuleConfig),
"style module configuration");
@@ -155,7 +155,7 @@ void BKE_freestyle_lineset_unique_name(FreestyleConfig *config, FreestyleLineSet
sizeof(lineset->name));
}
static FreestyleLineSet *alloc_lineset(void)
static FreestyleLineSet *alloc_lineset()
{
return (FreestyleLineSet *)MEM_callocN(sizeof(FreestyleLineSet), "Freestyle line set");
}
@@ -180,7 +180,7 @@ static void gpencil_add_new_points(bGPDstroke *gps,
{
BLI_assert(totpoints > 0);
const float step = 1.0f / ((float)totpoints - 1.0f);
const float step = 1.0f / (float(totpoints) - 1.0f);
float factor = 0.0f;
for (int i = 0; i < totpoints; i++) {
bGPDspoint *pt = &gps->points[i + init];
@@ -379,7 +379,7 @@ static void gpencil_convert_spline(Main *bmain,
int inext = (s + 1) % nu->pntsu;
BezTriple *prevbezt = &nu->bezt[s];
BezTriple *bezt = &nu->bezt[inext];
bool last = (bool)(s == segments - 1);
bool last = bool(s == segments - 1);
float *coord_array = static_cast<float *>(
MEM_callocN(sizeof(float[3]) * resolu, __func__));
@@ -566,7 +566,7 @@ static bGPDcurve *gpencil_stroke_editcurve_generate_edgecases(bGPDstroke *gps,
for (int j = 0; j < 3; j++) {
copy_v3_v3(tmp_vec, &pt->x);
/* Move handles along the x-axis away from the control point */
tmp_vec[0] += (float)(j - 1) * offset;
tmp_vec[0] += float(j - 1) * offset;
copy_v3_v3(bezt->vec[j], tmp_vec);
}
@@ -600,7 +600,7 @@ static bGPDcurve *gpencil_stroke_editcurve_generate_edgecases(bGPDstroke *gps,
float tmp_vec[3];
for (int j = 0; j < 3; j++) {
copy_v3_v3(tmp_vec, dir);
normalize_v3_length(tmp_vec, (float)(j - 1) * offset);
normalize_v3_length(tmp_vec, float(j - 1) * offset);
add_v3_v3v3(bezt->vec[j], &pt->x, tmp_vec);
}
@@ -853,7 +853,7 @@ static void gpencil_interpolate_fl_from_to(
/* smooth interpolation */
float *r = point_offset;
for (int i = 0; i <= it; i++) {
float fac = (float)i / (float)it;
float fac = float(i) / float(it);
fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; /* Smooth. */
*r = interpf(to, from, fac);
r = static_cast<float *>(POINTER_OFFSET(r, stride));
@@ -866,7 +866,7 @@ static void gpencil_interpolate_v4_from_to(
/* smooth interpolation */
float *r = point_offset;
for (int i = 0; i <= it; i++) {
float fac = (float)i / (float)it;
float fac = float(i) / float(it);
fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; /* Smooth. */
interp_v4_v4v4(r, from, to, fac);
r = static_cast<float *>(POINTER_OFFSET(r, stride));
@@ -898,7 +898,7 @@ static void gpencil_calculate_stroke_points_curve_segment(
cpt_next->bezt.vec[0][axis],
cpt_next->bezt.vec[1][axis],
static_cast<float *>(POINTER_OFFSET(points_offset, sizeof(float) * axis)),
(int)resolu,
int(resolu),
stride);
}
@@ -942,7 +942,7 @@ static float *gpencil_stroke_points_from_editcurve_adaptive_resolu(
bGPDcurve_point *cpt = &curve_point_array[i];
bGPDcurve_point *cpt_next = &curve_point_array[i + 1];
float arclen = gpencil_approximate_curve_segment_arclength(cpt, cpt_next);
int segment_resolu = (int)floorf(arclen * resolution);
int segment_resolu = int(floorf(arclen * resolution));
CLAMP_MIN(segment_resolu, 1);
segment_point_lengths[i] = segment_resolu;
@@ -953,7 +953,7 @@ static float *gpencil_stroke_points_from_editcurve_adaptive_resolu(
bGPDcurve_point *cpt = &curve_point_array[cpt_last];
bGPDcurve_point *cpt_next = &curve_point_array[0];
float arclen = gpencil_approximate_curve_segment_arclength(cpt, cpt_next);
int segment_resolu = (int)floorf(arclen * resolution);
int segment_resolu = int(floorf(arclen * resolution));
CLAMP_MIN(segment_resolu, 1);
segment_point_lengths[cpt_last] = segment_resolu;
@@ -1331,7 +1331,7 @@ void BKE_gpencil_editcurve_subdivide(bGPDstroke *gps, const int cuts)
void BKE_gpencil_strokes_selected_update_editcurve(bGPdata *gpd)
{
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
const bool is_multiedit = bool(GPENCIL_MULTIEDIT_SESSIONS_ON(gpd));
/* For all selected strokes, update edit curve. */
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
if (!BKE_gpencil_layer_is_editable(gpl)) {
@@ -1371,7 +1371,7 @@ void BKE_gpencil_strokes_selected_update_editcurve(bGPdata *gpd)
void BKE_gpencil_strokes_selected_sync_selection_editcurve(bGPdata *gpd)
{
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
const bool is_multiedit = bool(GPENCIL_MULTIEDIT_SESSIONS_ON(gpd));
/* Sync selection for all strokes with editcurve. */
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
if (!BKE_gpencil_layer_is_editable(gpl)) {
@@ -1938,13 +1938,13 @@ float BKE_gpencil_multiframe_falloff_calc(
/* frames to the right of the active frame */
if (gpf->framenum < actnum) {
fnum = (float)(gpf->framenum - f_init) / (actnum - f_init);
fnum = float(gpf->framenum - f_init) / (actnum - f_init);
fnum *= 0.5f;
value = BKE_curvemapping_evaluateF(cur_falloff, 0, fnum);
}
/* frames to the left of the active frame */
else if (gpf->framenum > actnum) {
fnum = (float)(gpf->framenum - actnum) / (f_end - actnum);
fnum = float(gpf->framenum - actnum) / (f_end - actnum);
fnum *= 0.5f;
value = BKE_curvemapping_evaluateF(cur_falloff, 0, fnum + 0.5f);
}
@@ -1988,7 +1988,7 @@ bool BKE_gpencil_material_index_used(bGPdata *gpd, int index)
void BKE_gpencil_material_remap(bGPdata *gpd, const uint *remap, uint remap_len)
{
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) { \
@@ -2877,7 +2877,7 @@ int BKE_gpencil_material_find_index_by_name_prefix(Object *ob, const char *name_
void BKE_gpencil_frame_selected_hash(bGPdata *gpd, GHash *r_list)
{
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
const bool is_multiedit = bool(GPENCIL_MULTIEDIT_SESSIONS_ON(gpd));
bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
LISTBASE_FOREACH (bGPDlayer *, gpl_iter, &gpd->layers) {
@@ -314,7 +314,7 @@ int BKE_gpencil_time_modifier_cfra(Depsgraph *depsgraph,
void BKE_gpencil_frame_active_set(Depsgraph *depsgraph, bGPdata *gpd)
{
DEG_debug_print_eval(depsgraph, __func__, gpd->id.name, gpd);
int ctime = (int)DEG_get_ctime(depsgraph);
int ctime = int(DEG_get_ctime(depsgraph));
/* update active frame */
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
@@ -334,7 +334,7 @@ void BKE_gpencil_frame_active_set(Depsgraph *depsgraph, bGPdata *gpd)
}
}
void BKE_gpencil_modifier_init(void)
void BKE_gpencil_modifier_init()
{
/* Initialize modifier types */
gpencil_modifier_type_init(modifier_gpencil_types); /* MOD_gpencil_legacy_util.c */
@@ -609,9 +609,9 @@ GpencilModifierData *BKE_gpencil_modifiers_findby_name(Object *ob, const char *n
*/
static int gpencil_remap_time_get(Depsgraph *depsgraph, Scene *scene, Object *ob, bGPDlayer *gpl)
{
const bool is_render = (bool)(DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
const bool is_render = bool(DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
const bool time_remap = BKE_gpencil_has_time_modifiers(ob);
int cfra_eval = (int)DEG_get_ctime(depsgraph);
int cfra_eval = int(DEG_get_ctime(depsgraph));
int remap_cfra = cfra_eval;
if (time_remap) {
@@ -764,11 +764,11 @@ void BKE_gpencil_prepare_eval_data(Depsgraph *depsgraph, Scene *scene, Object *o
ob->data = gpd_eval;
}
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_orig);
const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd_orig);
const bool do_modifiers = (bool)((!is_multiedit) && (!is_curve_edit) &&
(ob_orig->greasepencil_modifiers.first != nullptr) &&
!GPENCIL_SIMPLIFY_MODIF(scene));
const bool is_multiedit = bool(GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_orig));
const bool is_curve_edit = bool(GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd_orig));
const bool do_modifiers = bool((!is_multiedit) && (!is_curve_edit) &&
(ob_orig->greasepencil_modifiers.first != nullptr) &&
!GPENCIL_SIMPLIFY_MODIF(scene));
if ((!do_modifiers) && (!do_parent) && (!do_transform)) {
BLI_assert(ob->data != nullptr);
return;
@@ -793,12 +793,12 @@ void BKE_gpencil_modifiers_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
bGPdata *gpd = (bGPdata *)ob->data;
const bool is_edit = GPENCIL_ANY_EDIT_MODE(gpd);
const bool is_render = (bool)(DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
const bool is_curve_edit = (bool)(GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd) && !is_render);
const bool is_multiedit = (bool)(GPENCIL_MULTIEDIT_SESSIONS_ON(gpd) && !is_render);
const bool do_modifiers = (bool)((!is_multiedit) && (!is_curve_edit) &&
(ob->greasepencil_modifiers.first != nullptr) &&
!GPENCIL_SIMPLIFY_MODIF(scene));
const bool is_render = bool(DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
const bool is_curve_edit = bool(GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd) && !is_render);
const bool is_multiedit = bool(GPENCIL_MULTIEDIT_SESSIONS_ON(gpd) && !is_render);
const bool do_modifiers = bool((!is_multiedit) && (!is_curve_edit) &&
(ob->greasepencil_modifiers.first != nullptr) &&
!GPENCIL_SIMPLIFY_MODIF(scene));
if (!do_modifiers) {
return;
}
@@ -44,7 +44,7 @@ static void tri_fill_smooth(int x, int x_end, int y, void *user_data)
{
struct UserRasterInfo *data = static_cast<UserRasterInfo *>(user_data);
uint *p = &data->rect[(y * data->rect_size[1]) + x];
float pt_step_fl[2] = {(float)x, (float)y};
float pt_step_fl[2] = {float(x), float(y)};
while (x++ != x_end) {
float w[3];
barycentric_weights_v2_clamped(UNPACK3(data->smooth.pt_fl), pt_step_fl, w);
@@ -52,17 +52,17 @@ static void tri_fill_smooth(int x, int x_end, int y, void *user_data)
uint col_u[4] = {0, 0, 0, 0};
for (uint corner = 0; corner < 3; corner++) {
for (uint chan = 0; chan < 4; chan++) {
col_u[chan] += data->smooth.color_u[corner][chan] * (uint)(w[corner] * 255.0f);
col_u[chan] += data->smooth.color_u[corner][chan] * uint(w[corner] * 255.0f);
}
}
union {
uint as_u32;
uchar as_bytes[4];
} col;
col.as_bytes[0] = (uchar)(col_u[0] / 255);
col.as_bytes[1] = (uchar)(col_u[1] / 255);
col.as_bytes[2] = (uchar)(col_u[2] / 255);
col.as_bytes[3] = (uchar)(col_u[3] / 255);
col.as_bytes[0] = uchar(col_u[0] / 255);
col.as_bytes[1] = uchar(col_u[1] / 255);
col.as_bytes[2] = uchar(col_u[2] / 255);
col.as_bytes[3] = uchar(col_u[3] / 255);
*p++ = col.as_u32;
pt_step_fl[0] += 1.0f;
@@ -78,9 +78,9 @@ ImBuf *BKE_icon_geom_rasterize(const struct Icon_Geom *geom, const uint size_x,
/* TODO(@ideasman42): Currently rasterizes to fixed size, then scales.
* Should rasterize to double size for eg instead. */
const int rect_size[2] = {max_ii(256, (int)size_x * 2), max_ii(256, (int)size_y * 2)};
const int rect_size[2] = {max_ii(256, int(size_x) * 2), max_ii(256, int(size_y) * 2)};
ImBuf *ibuf = IMB_allocImBuf((uint)rect_size[0], (uint)rect_size[1], 32, IB_rect);
ImBuf *ibuf = IMB_allocImBuf(uint(rect_size[0]), uint(rect_size[1]), 32, IB_rect);
struct UserRasterInfo data;
@@ -93,15 +93,15 @@ ImBuf *BKE_icon_geom_rasterize(const struct Icon_Geom *geom, const uint size_x,
const bool use_scale = (rect_size[0] != 256) || (rect_size[1] != 256);
if (use_scale) {
scale[0] = ((float)rect_size[0] / 256.0f);
scale[1] = ((float)rect_size[1] / 256.0f);
scale[0] = float(rect_size[0]) / 256.0f;
scale[1] = float(rect_size[1]) / 256.0f;
}
for (int t = 0; t < coords_len; t += 1, pos += 3, col += 3) {
if (use_scale) {
ARRAY_SET_ITEMS(data.pt[0], (int)(pos[0][0] * scale[0]), (int)(pos[0][1] * scale[1]));
ARRAY_SET_ITEMS(data.pt[1], (int)(pos[1][0] * scale[0]), (int)(pos[1][1] * scale[1]));
ARRAY_SET_ITEMS(data.pt[2], (int)(pos[2][0] * scale[0]), (int)(pos[2][1] * scale[1]));
ARRAY_SET_ITEMS(data.pt[0], int(pos[0][0] * scale[0]), int(pos[0][1] * scale[1]));
ARRAY_SET_ITEMS(data.pt[1], int(pos[1][0] * scale[0]), int(pos[1][1] * scale[1]));
ARRAY_SET_ITEMS(data.pt[2], int(pos[2][0] * scale[0]), int(pos[2][1] * scale[1]));
}
else {
ARRAY_SET_ITEMS(data.pt[0], UNPACK2(pos[0]));
+23 -23
View File
@@ -178,7 +178,7 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
*/
int newsize = newlen;
newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
prop->data.pointer = MEM_recallocN(prop->data.pointer, sizeof(IDProperty) * (size_t)newsize);
prop->data.pointer = MEM_recallocN(prop->data.pointer, sizeof(IDProperty) * size_t(newsize));
prop->len = newlen;
prop->totallen = newsize;
}
@@ -237,7 +237,7 @@ void IDP_ResizeArray(IDProperty *prop, int newlen)
}
prop->data.pointer = MEM_recallocN(prop->data.pointer,
idp_size_table[(int)prop->subtype] * (size_t)newsize);
idp_size_table[int(prop->subtype)] * size_t(newsize));
if (is_grow == true) {
idp_resize_group_array(prop, newlen, prop->data.pointer);
@@ -357,16 +357,16 @@ IDProperty *IDP_NewStringMaxSize(const char *st, const char *name, int maxncpy)
}
else {
/* include null terminator '\0' */
int stlen = (int)strlen(st) + 1;
int stlen = int(strlen(st)) + 1;
if ((maxncpy > 0) && (maxncpy < stlen)) {
stlen = maxncpy;
}
prop->data.pointer = MEM_mallocN((size_t)stlen, "id property string 2");
prop->data.pointer = MEM_mallocN(size_t(stlen), "id property string 2");
prop->len = prop->totallen = stlen;
if (stlen > 0) {
memcpy(prop->data.pointer, st, (size_t)stlen);
memcpy(prop->data.pointer, st, size_t(stlen));
IDP_String(prop)[stlen - 1] = '\0';
}
}
@@ -401,13 +401,13 @@ void IDP_AssignStringMaxSize(IDProperty *prop, const char *st, int maxncpy)
{
BLI_assert(prop->type == IDP_STRING);
const bool is_byte = prop->subtype == IDP_STRING_SUB_BYTE;
int stlen = (int)strlen(st) + (is_byte ? 0 : 1);
int stlen = int(strlen(st)) + (is_byte ? 0 : 1);
if ((maxncpy > 0) && (maxncpy < stlen)) {
stlen = maxncpy;
}
IDP_ResizeArray(prop, stlen);
if (stlen > 0) {
memcpy(prop->data.pointer, st, (size_t)stlen);
memcpy(prop->data.pointer, st, size_t(stlen));
if (is_byte == false) {
IDP_String(prop)[stlen - 1] = '\0';
}
@@ -708,11 +708,11 @@ int IDP_coerce_to_int_or_zero(const IDProperty *prop)
case IDP_INT:
return IDP_Int(prop);
case IDP_DOUBLE:
return (int)IDP_Double(prop);
return int(IDP_Double(prop));
case IDP_FLOAT:
return (int)IDP_Float(prop);
return int(IDP_Float(prop));
case IDP_BOOLEAN:
return (int)IDP_Bool(prop);
return int(IDP_Bool(prop));
default:
return 0;
}
@@ -724,11 +724,11 @@ double IDP_coerce_to_double_or_zero(const IDProperty *prop)
case IDP_DOUBLE:
return IDP_Double(prop);
case IDP_FLOAT:
return (double)IDP_Float(prop);
return double(IDP_Float(prop));
case IDP_INT:
return (double)IDP_Int(prop);
return double(IDP_Int(prop));
case IDP_BOOLEAN:
return (double)IDP_Bool(prop);
return double(IDP_Bool(prop));
default:
return 0.0;
}
@@ -740,11 +740,11 @@ float IDP_coerce_to_float_or_zero(const IDProperty *prop)
case IDP_FLOAT:
return IDP_Float(prop);
case IDP_DOUBLE:
return (float)IDP_Double(prop);
return float(IDP_Double(prop));
case IDP_INT:
return (float)IDP_Int(prop);
return float(IDP_Int(prop));
case IDP_BOOLEAN:
return (float)IDP_Bool(prop);
return float(IDP_Bool(prop));
default:
return 0.0f;
}
@@ -841,13 +841,13 @@ bool IDP_EqualsProperties_ex(const IDProperty *prop1,
return (IDP_Bool(prop1) == IDP_Bool(prop2));
case IDP_STRING: {
return ((prop1->len == prop2->len) &&
STREQLEN(IDP_String(prop1), IDP_String(prop2), (size_t)prop1->len));
STREQLEN(IDP_String(prop1), IDP_String(prop2), size_t(prop1->len)));
}
case IDP_ARRAY:
if (prop1->len == prop2->len && prop1->subtype == prop2->subtype) {
return (memcmp(IDP_Array(prop1),
IDP_Array(prop2),
idp_size_table[(int)prop1->subtype] * (size_t)prop1->len) == 0);
idp_size_table[int(prop1->subtype)] * (size_t)prop1->len) == 0);
}
return false;
case IDP_GROUP: {
@@ -914,7 +914,7 @@ IDProperty *IDP_New(const char type, const IDPropertyTemplate *val, const char *
break;
case IDP_BOOLEAN:
prop = static_cast<IDProperty *>(MEM_callocN(sizeof(IDProperty), "IDProperty boolean"));
prop->data.val = (bool)val->i;
prop->data.val = bool(val->i);
break;
case IDP_ARRAY: {
if (ELEM(val->array.type, IDP_FLOAT, IDP_INT, IDP_DOUBLE, IDP_GROUP, IDP_BOOLEAN)) {
@@ -958,7 +958,7 @@ IDProperty *IDP_New(const char type, const IDPropertyTemplate *val, const char *
prop->len = 1;
}
else {
BLI_assert((int)val->string.len <= (int)strlen(st) + 1);
BLI_assert(int(val->string.len) <= int(strlen(st)) + 1);
prop->data.pointer = MEM_mallocN((size_t)val->string.len, "id property string 3");
memcpy(prop->data.pointer, st, (size_t)val->string.len - 1);
IDP_String(prop)[val->string.len - 1] = '\0';
@@ -1197,7 +1197,7 @@ static void write_ui_data(const IDProperty *prop, BlendWriter *writer)
IDPropertyUIDataInt *ui_data_int = (IDPropertyUIDataInt *)ui_data;
if (prop->type == IDP_ARRAY) {
BLO_write_int32_array(
writer, (uint)ui_data_int->default_array_len, (int32_t *)ui_data_int->default_array);
writer, uint(ui_data_int->default_array_len), (int32_t *)ui_data_int->default_array);
}
BLO_write_struct(writer, IDPropertyUIDataInt, ui_data);
break;
@@ -1206,7 +1206,7 @@ static void write_ui_data(const IDProperty *prop, BlendWriter *writer)
IDPropertyUIDataBool *ui_data_bool = (IDPropertyUIDataBool *)ui_data;
if (prop->type == IDP_ARRAY) {
BLO_write_int8_array(writer,
(uint)ui_data_bool->default_array_len,
uint(ui_data_bool->default_array_len),
(const int8_t *)ui_data_bool->default_array);
}
BLO_write_struct(writer, IDPropertyUIDataBool, ui_data);
@@ -1216,7 +1216,7 @@ static void write_ui_data(const IDProperty *prop, BlendWriter *writer)
IDPropertyUIDataFloat *ui_data_float = (IDPropertyUIDataFloat *)ui_data;
if (prop->type == IDP_ARRAY) {
BLO_write_double_array(
writer, (uint)ui_data_float->default_array_len, ui_data_float->default_array);
writer, uint(ui_data_float->default_array_len), ui_data_float->default_array);
}
BLO_write_struct(writer, IDPropertyUIDataFloat, ui_data);
break;
@@ -69,7 +69,7 @@ static void idp_str_append_escape(struct ReprState *state,
state->str_append_fn(state->user_data, str + i_prev, i - i_prev);
}
char buf[5];
uint len = (uint)SNPRINTF_RLEN(buf, "\\x%02x", c);
uint len = uint(SNPRINTF_RLEN(buf, "\\x%02x", c));
BLI_assert(len == 4);
state->str_append_fn(state->user_data, buf, len);
i_prev = i + 1;
@@ -85,18 +85,18 @@ static void idp_str_append_escape(struct ReprState *state,
static void idp_repr_fn_recursive(struct ReprState *state, const IDProperty *prop)
{
/* NOTE: 'strlen' will be calculated at compile time for literals. */
#define STR_APPEND_STR(str) state->str_append_fn(state->user_data, str, (uint)strlen(str))
#define STR_APPEND_STR(str) state->str_append_fn(state->user_data, str, uint(strlen(str)))
#define STR_APPEND_STR_QUOTE(str) idp_str_append_escape(state, str, (uint)strlen(str), true)
#define STR_APPEND_STR_QUOTE(str) idp_str_append_escape(state, str, uint(strlen(str)), true)
#define STR_APPEND_STR_LEN_QUOTE(str, str_len) idp_str_append_escape(state, str, str_len, true)
#define STR_APPEND_FMT(format, ...) \
state->str_append_fn( \
state->user_data, state->buf, (uint)SNPRINTF_RLEN(state->buf, format, __VA_ARGS__))
state->user_data, state->buf, uint(SNPRINTF_RLEN(state->buf, format, __VA_ARGS__)))
switch (prop->type) {
case IDP_STRING: {
STR_APPEND_STR_LEN_QUOTE(IDP_String(prop), (uint)MAX2(0, prop->len - 1));
STR_APPEND_STR_LEN_QUOTE(IDP_String(prop), uint(MAX2(0, prop->len - 1)));
break;
}
case IDP_INT: {
@@ -104,7 +104,7 @@ static void idp_repr_fn_recursive(struct ReprState *state, const IDProperty *pro
break;
}
case IDP_FLOAT: {
STR_APPEND_FMT("%g", (double)IDP_Float(prop));
STR_APPEND_FMT("%g", double(IDP_Float(prop)));
break;
}
case IDP_DOUBLE: {
@@ -138,7 +138,7 @@ static void idp_repr_fn_recursive(struct ReprState *state, const IDProperty *pro
if (v != prop->data.pointer) {
STR_APPEND_STR(", ");
}
STR_APPEND_FMT("%g", (double)*v);
STR_APPEND_FMT("%g", double(*v));
}
break;
case IDP_DOUBLE:
@@ -235,7 +235,7 @@ void IDP_repr_fn(const IDProperty *prop,
static void repr_str(void *user_data, const char *str, uint len)
{
BLI_dynstr_nappend(static_cast<DynStr *>(user_data), str, (int)len);
BLI_dynstr_nappend(static_cast<DynStr *>(user_data), str, int(len));
}
char *IDP_reprN(const IDProperty *prop, uint *r_len)
@@ -244,7 +244,7 @@ char *IDP_reprN(const IDProperty *prop, uint *r_len)
IDP_repr_fn(prop, repr_str, ds);
char *cstring = BLI_dynstr_get_cstring(ds);
if (r_len != nullptr) {
*r_len = (uint)BLI_dynstr_get_len(ds);
*r_len = uint(BLI_dynstr_get_len(ds));
}
BLI_dynstr_free(ds);
return cstring;
+4 -4
View File
@@ -33,8 +33,8 @@ uint BKE_idtype_cache_key_hash(const void *key_v)
{
const IDCacheKey *key = static_cast<const IDCacheKey *>(key_v);
size_t hash = BLI_ghashutil_uinthash(key->id_session_uuid);
hash = BLI_ghashutil_combine_hash(hash, BLI_ghashutil_uinthash((uint)key->offset_in_ID));
return (uint)hash;
hash = BLI_ghashutil_combine_hash(hash, BLI_ghashutil_uinthash(uint(key->offset_in_ID)));
return uint(hash);
}
bool BKE_idtype_cache_key_cmp(const void *key_a_v, const void *key_b_v)
@@ -47,7 +47,7 @@ bool BKE_idtype_cache_key_cmp(const void *key_a_v, const void *key_b_v)
static IDTypeInfo *id_types[INDEX_ID_MAX] = {nullptr};
static void id_type_init(void)
static void id_type_init()
{
#define INIT_TYPE(_id_code) \
{ \
@@ -104,7 +104,7 @@ static void id_type_init(void)
#undef INIT_TYPE
}
void BKE_idtype_init(void)
void BKE_idtype_init()
{
/* Initialize data-block types. */
id_type_init();
+19 -19
View File
@@ -61,7 +61,7 @@ static void image_buf_fill_color_thread_do(void *data_v, int scanline)
{
FillColorThreadData *data = (FillColorThreadData *)data_v;
const int num_scanlines = 1;
size_t offset = ((size_t)scanline) * data->width * 4;
size_t offset = (size_t(scanline)) * data->width * 4;
uchar *rect = (data->rect != nullptr) ? (data->rect + offset) : nullptr;
float *rect_float = (data->rect_float != nullptr) ? (data->rect_float + offset) : nullptr;
image_buf_fill_color_slice(rect, rect_float, data->width, num_scanlines, data->color);
@@ -70,7 +70,7 @@ static void image_buf_fill_color_thread_do(void *data_v, int scanline)
void BKE_image_buf_fill_color(
uchar *rect, float *rect_float, int width, int height, const float color[4])
{
if (((size_t)width) * height < 64 * 64) {
if ((size_t(width)) * height < 64 * 64) {
image_buf_fill_color_slice(rect, rect_float, width, height, color);
}
else {
@@ -158,9 +158,9 @@ static void image_buf_fill_checker_slice(
hsv_to_rgb_v(hsv, rgb);
if (rect) {
rect[0] = (char)(rgb[0] * 255.0f);
rect[1] = (char)(rgb[1] * 255.0f);
rect[2] = (char)(rgb[2] * 255.0f);
rect[0] = char(rgb[0] * 255.0f);
rect[1] = char(rgb[1] * 255.0f);
rect[2] = char(rgb[2] * 255.0f);
rect[3] = 255;
}
@@ -190,7 +190,7 @@ struct FillCheckerThreadData {
static void image_buf_fill_checker_thread_do(void *data_v, int scanline)
{
FillCheckerThreadData *data = (FillCheckerThreadData *)data_v;
size_t offset = ((size_t)scanline) * data->width * 4;
size_t offset = (size_t(scanline)) * data->width * 4;
const int num_scanlines = 1;
uchar *rect = (data->rect != nullptr) ? (data->rect + offset) : nullptr;
float *rect_float = (data->rect_float != nullptr) ? (data->rect_float + offset) : nullptr;
@@ -199,7 +199,7 @@ static void image_buf_fill_checker_thread_do(void *data_v, int scanline)
void BKE_image_buf_fill_checker(uchar *rect, float *rect_float, int width, int height)
{
if (((size_t)width) * height < 64 * 64) {
if ((size_t(width)) * height < 64 * 64) {
image_buf_fill_checker_slice(rect, rect_float, width, height, 0);
}
else {
@@ -215,7 +215,7 @@ void BKE_image_buf_fill_checker(uchar *rect, float *rect_float, int width, int h
#define BLEND_FLOAT(real, add) (real + add <= 1.0f) ? (real + add) : 1.0f
#define BLEND_CHAR(real, add) \
((real + (char)(add * 255.0f)) <= 255) ? (real + (char)(add * 255.0f)) : 255
((real + char(add * 255.0f)) <= 255) ? (real + char(add * 255.0f)) : 255
static void checker_board_color_fill(
uchar *rect, float *rect_float, int width, int height, int offset, int total_height)
@@ -235,13 +235,13 @@ static void checker_board_color_fill(
hsv[2] = 0.1 + (y * (0.4 / total_height));
for (x = 0; x < width; x++) {
hsv[0] = (float)((double)(x / hue_step) * 1.0 / width * hue_step);
hsv[0] = float(double(x / hue_step) * 1.0 / width * hue_step);
hsv_to_rgb_v(hsv, rgb);
if (rect) {
rect[0] = (char)(rgb[0] * 255.0f);
rect[1] = (char)(rgb[1] * 255.0f);
rect[2] = (char)(rgb[2] * 255.0f);
rect[0] = char(rgb[0] * 255.0f);
rect[1] = char(rgb[1] * 255.0f);
rect[2] = char(rgb[2] * 255.0f);
rect[3] = 255;
rect += 4;
@@ -270,9 +270,9 @@ static void checker_board_color_tint(
if (((y / size) % 2 == 1 && (x / size) % 2 == 1) ||
((y / size) % 2 == 0 && (x / size) % 2 == 0)) {
if (rect) {
rect[0] = (char)BLEND_CHAR(rect[0], blend);
rect[1] = (char)BLEND_CHAR(rect[1], blend);
rect[2] = (char)BLEND_CHAR(rect[2], blend);
rect[0] = char(BLEND_CHAR(rect[0], blend));
rect[1] = char(BLEND_CHAR(rect[1], blend));
rect[2] = char(BLEND_CHAR(rect[2], blend));
rect[3] = 255;
rect += 4;
@@ -288,9 +288,9 @@ static void checker_board_color_tint(
}
else {
if (rect) {
rect[0] = (char)BLEND_CHAR(rect[0], blend_half);
rect[1] = (char)BLEND_CHAR(rect[1], blend_half);
rect[2] = (char)BLEND_CHAR(rect[2], blend_half);
rect[0] = char(BLEND_CHAR(rect[0], blend_half));
rect[1] = char(BLEND_CHAR(rect[1], blend_half));
rect[2] = char(BLEND_CHAR(rect[2], blend_half));
rect[3] = 255;
rect += 4;
@@ -445,7 +445,7 @@ static void checker_board_color_prepare_thread_do(void *data_v, int scanline)
void BKE_image_buf_fill_checker_color(uchar *rect, float *rect_float, int width, int height)
{
if (((size_t)width) * height < 64 * 64) {
if ((size_t(width)) * height < 64 * 64) {
checker_board_color_prepare_slice(rect, rect_float, width, height, 0, height);
}
else {
+3 -3
View File
@@ -1542,7 +1542,7 @@ static void icu_to_fcurves(ID *id,
}
/* correct values, by checking if the flag of interest is set */
if ((int)(dst->vec[1][1]) & (abp->bit)) {
if (int(dst->vec[1][1]) & (abp->bit)) {
dst->vec[0][1] = dst->vec[1][1] = dst->vec[2][1] = 1.0f;
}
else {
@@ -1617,7 +1617,7 @@ static void icu_to_fcurves(ID *id,
if (((icu->blocktype == ID_OB) && ELEM(icu->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) ||
((icu->blocktype == ID_PO) && ELEM(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z)))
{
const float fac = (float)M_PI / 18.0f; /* 10.0f * M_PI/180.0f; */
const float fac = float(M_PI) / 18.0f; /* 10.0f * M_PI/180.0f; */
dst->vec[0][1] *= fac;
dst->vec[1][1] *= fac;
@@ -1649,7 +1649,7 @@ static void icu_to_fcurves(ID *id,
if (ELEM(dtar->transChan, DTAR_TRANSCHAN_ROTX, DTAR_TRANSCHAN_ROTY, DTAR_TRANSCHAN_ROTZ))
{
const float fac = (float)M_PI / 18.0f;
const float fac = float(M_PI) / 18.0f;
dst->vec[0][0] *= fac;
dst->vec[1][0] *= fac;
@@ -14,7 +14,7 @@
void BKE_kelvinlet_init_params(
KelvinletParams *params, float radius, float force, float shear_modulus, float poisson_ratio)
{
params->a = 1.0f / (4.0f * (float)M_PI * shear_modulus);
params->a = 1.0f / (4.0f * float(M_PI) * shear_modulus);
params->b = params->a / (4.0f * (1.0f - poisson_ratio));
params->c = 2 * (3.0f * params->a - 2.0f * params->b);
@@ -92,13 +92,13 @@ void BKE_keyconfig_pref_type_remove(const wmKeyConfigPrefType_Runtime *kpt_rt)
BLI_ghash_remove(global_keyconfigpreftype_hash, kpt_rt->idname, nullptr, MEM_freeN);
}
void BKE_keyconfig_pref_type_init(void)
void BKE_keyconfig_pref_type_init()
{
BLI_assert(global_keyconfigpreftype_hash == nullptr);
global_keyconfigpreftype_hash = BLI_ghash_str_new(__func__);
}
void BKE_keyconfig_pref_type_free(void)
void BKE_keyconfig_pref_type_free()
{
BLI_ghash_free(global_keyconfigpreftype_hash, nullptr, MEM_freeN);
global_keyconfigpreftype_hash = nullptr;
+4 -4
View File
@@ -417,13 +417,13 @@ void outside_lattice(Lattice *lt)
bp = lt->def;
if (lt->pntsu > 1) {
du = 1.0f / ((float)lt->pntsu - 1);
du = 1.0f / float(lt->pntsu - 1);
}
if (lt->pntsv > 1) {
dv = 1.0f / ((float)lt->pntsv - 1);
dv = 1.0f / float(lt->pntsv - 1);
}
if (lt->pntsw > 1) {
dw = 1.0f / ((float)lt->pntsw - 1);
dw = 1.0f / float(lt->pntsw - 1);
}
for (w = 0; w < lt->pntsw; w++) {
@@ -617,7 +617,7 @@ void BKE_lattice_center_median(Lattice *lt, float cent[3])
add_v3_v3(cent, lt->def[i].vec);
}
mul_v3_fl(cent, 1.0f / (float)numVerts);
mul_v3_fl(cent, 1.0f / float(numVerts));
}
static void boundbox_lattice(Object *ob)
@@ -166,7 +166,7 @@ void BKE_lattice_deform_data_eval_co(LatticeDeformData *lattice_deform_data,
if (lt->pntsu > 1) {
u = (vec[0] - lt->fu) / lt->du;
ui = (int)floor(u);
ui = int(floor(u));
u -= ui;
key_curve_position_weights(u, tu, lt->typeu);
}
@@ -178,7 +178,7 @@ void BKE_lattice_deform_data_eval_co(LatticeDeformData *lattice_deform_data,
if (lt->pntsv > 1) {
v = (vec[1] - lt->fv) / lt->dv;
vi = (int)floor(v);
vi = int(floor(v));
v -= vi;
key_curve_position_weights(v, tv, lt->typev);
}
@@ -190,7 +190,7 @@ void BKE_lattice_deform_data_eval_co(LatticeDeformData *lattice_deform_data,
if (lt->pntsw > 1) {
w = (vec[2] - lt->fw) / lt->dw;
wi = (int)floor(w);
wi = int(floor(w));
w -= wi;
key_curve_position_weights(w, tw, lt->typew);
}
+5 -5
View File
@@ -782,8 +782,8 @@ ID *BKE_id_copy_for_use_in_bmain(Main *bmain, const ID *id)
static void id_embedded_swap(ID **embedded_id_a,
ID **embedded_id_b,
const bool do_full_id,
struct IDRemapper *remapper_id_a,
struct IDRemapper *remapper_id_b);
IDRemapper *remapper_id_a,
IDRemapper *remapper_id_b);
/**
* Does a mere memory swap over the whole IDs data (including type-specific memory).
@@ -1404,7 +1404,7 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int ori
const size_t id_len = BKE_libblock_get_alloc_info(GS(new_id->name), nullptr);
const size_t id_offset = sizeof(ID);
if ((int)id_len - (int)id_offset > 0) { /* signed to allow neg result */ /* XXX ????? */
if (int(id_len) - int(id_offset) > 0) { /* signed to allow neg result */ /* XXX ????? */
const char *cp = (const char *)id;
char *cpn = (char *)new_id;
@@ -1659,7 +1659,7 @@ static int id_refcount_recompute_callback(LibraryIDLinkCallbackData *cb_data)
{
ID **id_pointer = cb_data->id_pointer;
const int cb_flag = cb_data->cb_flag;
const bool do_linked_only = (bool)POINTER_AS_INT(cb_data->user_data);
const bool do_linked_only = bool(POINTER_AS_INT(cb_data->user_data));
if (*id_pointer == nullptr) {
return IDWALK_RET_NOP;
@@ -1705,7 +1705,7 @@ void BKE_main_id_refcount_recompute(Main *bmain, const bool do_linked_only)
BKE_library_foreach_ID_link(bmain,
id,
id_refcount_recompute_callback,
POINTER_FROM_INT((int)do_linked_only),
POINTER_FROM_INT(int(do_linked_only)),
IDWALK_READONLY | IDWALK_INCLUDE_UI);
}
FOREACH_MAIN_ID_END;
+3 -3
View File
@@ -30,7 +30,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
Main *BKE_main_new(void)
Main *BKE_main_new()
{
Main *bmain = static_cast<Main *>(MEM_callocN(sizeof(Main), "new main"));
bmain->lock = static_cast<MainLock *>(MEM_mallocN(sizeof(SpinLock), "main lock"));
@@ -492,7 +492,7 @@ ImBuf *BKE_main_thumbnail_to_imbuf(Main *bmain, BlendThumbnail *data)
if (data) {
img = IMB_allocFromBuffer(
(const uint8_t *)data->rect, nullptr, (uint)data->width, (uint)data->height, 4);
(const uint8_t *)data->rect, nullptr, uint(data->width), uint(data->height), 4);
}
return img;
@@ -513,7 +513,7 @@ const char *BKE_main_blendfile_path(const Main *bmain)
return bmain->filepath;
}
const char *BKE_main_blendfile_path_from_global(void)
const char *BKE_main_blendfile_path_from_global()
{
return BKE_main_blendfile_path(G_MAIN);
}
@@ -221,7 +221,7 @@ ID *BKE_main_idmap_lookup_name(struct IDNameLib_Map *id_map,
if (type_map->map == nullptr) {
if (id_map->type_maps_keys_pool == nullptr) {
id_map->type_maps_keys_pool = BLI_mempool_create(
sizeof(struct IDNameLib_Key), 1024, 1024, BLI_MEMPOOL_NOP);
sizeof(IDNameLib_Key), 1024, 1024, BLI_MEMPOOL_NOP);
}
GHash *map = type_map->map = BLI_ghash_new(idkey_hash, idkey_cmp, __func__);
@@ -1058,8 +1058,8 @@ static void real_ibuf_size(
break;
case MCLIP_PROXY_RENDER_SIZE_75:
*width = ((float)*width) * 4.0f / 3.0f;
*height = ((float)*height) * 4.0f / 3.0f;
*width = float(*width) * 4.0f / 3.0f;
*height = float(*height) * 4.0f / 3.0f;
break;
}
}
@@ -1561,8 +1561,8 @@ void BKE_movieclip_get_size_fl(MovieClip *clip, const MovieClipUser *user, float
int width, height;
BKE_movieclip_get_size(clip, user, &width, &height);
size[0] = (float)width;
size[1] = (float)height;
size[0] = float(width);
size[1] = float(height);
}
int BKE_movieclip_get_duration(MovieClip *clip)
@@ -1586,7 +1586,7 @@ float BKE_movieclip_get_fps(MovieClip *clip)
short frs_sec;
float frs_sec_base;
if (IMB_anim_get_fps(clip->anim, &frs_sec, &frs_sec_base, true)) {
return (float)frs_sec / frs_sec_base;
return float(frs_sec) / frs_sec_base;
}
return 0.0f;
}
@@ -1802,10 +1802,10 @@ static void movieclip_build_proxy_ibuf(
scaleibuf = IMB_dupImBuf(ibuf);
if (threaded) {
IMB_scaleImBuf_threaded(scaleibuf, (short)rectx, (short)recty);
IMB_scaleImBuf_threaded(scaleibuf, short(rectx), short(recty));
}
else {
IMB_scaleImBuf(scaleibuf, (short)rectx, (short)recty);
IMB_scaleImBuf(scaleibuf, short(rectx), short(recty));
}
quality = clip->proxy.quality;
@@ -1910,12 +1910,12 @@ bool BKE_movieclip_proxy_enabled(MovieClip *clip)
float BKE_movieclip_remap_scene_to_clip_frame(const MovieClip *clip, const float framenr)
{
return framenr - (float)clip->start_frame + 1.0f;
return framenr - float(clip->start_frame) + 1.0f;
}
float BKE_movieclip_remap_clip_to_scene_frame(const MovieClip *clip, const float framenr)
{
return framenr + (float)clip->start_frame - 1.0f;
return framenr + float(clip->start_frame) - 1.0f;
}
void BKE_movieclip_filepath_for_frame(MovieClip *clip, const MovieClipUser *user, char *filepath)
+3 -3
View File
@@ -337,7 +337,7 @@ void BKE_nla_tracks_copy_from_adt(Main *bmain,
/* Adding ------------------------------------------- */
NlaTrack *BKE_nlatrack_new(void)
NlaTrack *BKE_nlatrack_new()
{
/* allocate new track */
NlaTrack *nlt = static_cast<NlaTrack *>(MEM_callocN(sizeof(NlaTrack), "NlaTrack"));
@@ -541,7 +541,7 @@ NlaStrip *BKE_nla_add_soundstrip(Main *bmain, Scene *scene, Speaker *speaker)
if (speaker->sound) {
SoundInfo info;
if (BKE_sound_info_get(bmain, speaker->sound, &info)) {
strip->end = (float)ceil((double)info.length * FPS);
strip->end = float(ceil(double(info.length) * FPS));
}
}
else
@@ -636,7 +636,7 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short
return (strip->end + (strip->actstart * scale - cframe)) / scale;
}
/* if (mode == NLATIME_CONVERT_EVAL) */
if (IS_EQF((float)cframe, strip->end) && IS_EQF(strip->repeat, floorf(strip->repeat))) {
if (IS_EQF(float(cframe), strip->end) && IS_EQF(strip->repeat, floorf(strip->repeat))) {
/* This case prevents the motion snapping back to the first frame at the end of the strip
* by catching the case where repeats is a whole number, which means that the end of the
* strip could also be interpreted as the end of the start of a repeat. */
+1 -1
View File
@@ -3127,7 +3127,7 @@ bNodePreview *node_preview_verify(bNodeInstanceHash *previews,
}
/* sanity checks & initialize */
const uint size[2] = {(uint)xsize, (uint)ysize};
const uint size[2] = {uint(xsize), uint(ysize)};
IMB_rect_size_set(preview->ibuf, size);
if (preview->ibuf->byte_buffer.data == nullptr) {
imb_addrectImBuf(preview->ibuf);
@@ -474,7 +474,7 @@ void BKE_object_defgroup_index_map_apply(MDeformVert *dvert,
int totweight = dv->totweight;
for (int j = 0; j < totweight; j++) {
int def_nr = dv->dw[j].def_nr;
if ((uint)def_nr < (uint)map_len && map[def_nr] != -1) {
if (uint(def_nr) < uint(map_len) && map[def_nr] != -1) {
dv->dw[j].def_nr = map[def_nr];
}
else {
+33 -33
View File
@@ -56,8 +56,8 @@ static float gaussRand(RNG *rng)
float length2;
do {
x = (float)nextfr(rng, -1, 1);
y = (float)nextfr(rng, -1, 1);
x = float(nextfr(rng, -1, 1));
y = float(nextfr(rng, -1, 1));
length2 = x * x + y * y;
} while (length2 >= 1 || length2 == 0);
@@ -141,8 +141,8 @@ static void add_comlex_c(fftw_complex res, const fftw_complex cmpl1, const fftw_
static void mul_complex_f(fftw_complex res, const fftw_complex cmpl, float f)
{
res[0] = cmpl[0] * (double)f;
res[1] = cmpl[1] * (double)f;
res[0] = cmpl[0] * double(f);
res[1] = cmpl[1] * double(f);
}
static void mul_complex_c(fftw_complex res, const fftw_complex cmpl1, const fftw_complex cmpl2)
@@ -207,8 +207,8 @@ void BKE_ocean_eval_uv(Ocean *oc, OceanResult *ocr, float u, float v)
uu = u * oc->_M;
vv = v * oc->_N;
i0 = (int)floor(uu);
j0 = (int)floor(vv);
i0 = int(floor(uu));
j0 = int(floor(vv));
i1 = (i0 + 1);
j1 = (j0 + 1);
@@ -278,8 +278,8 @@ void BKE_ocean_eval_uv_catrom(Ocean *oc, OceanResult *ocr, float u, float v)
uu = u * oc->_M;
vv = v * oc->_N;
i1 = (int)floor(uu);
j1 = (int)floor(vv);
i1 = int(floor(uu));
j1 = int(floor(vv));
i2 = (i1 + 1);
j2 = (j1 + 1);
@@ -370,7 +370,7 @@ void BKE_ocean_eval_ij(Ocean *oc, OceanResult *ocr, int i, int j)
i = abs(i) % oc->_M;
j = abs(j) % oc->_N;
ocr->disp[1] = oc->_do_disp_y ? (float)oc->_disp_y[i * oc->_N + j] : 0.0f;
ocr->disp[1] = oc->_do_disp_y ? float(oc->_disp_y[i * oc->_N + j]) : 0.0f;
if (oc->_do_chop) {
ocr->disp[0] = oc->_disp_x[i * oc->_N + j];
@@ -732,7 +732,7 @@ static void set_height_normalize_factor(Ocean *oc)
oc->normalize_factor = res;
}
Ocean *BKE_ocean_add(void)
Ocean *BKE_ocean_add()
{
Ocean *oc = static_cast<Ocean *>(MEM_callocN(sizeof(Ocean), "ocean sim data"));
@@ -846,9 +846,9 @@ bool BKE_ocean_init(Ocean *o,
/* NOTE: most modifiers don't account for failure to allocate.
* In this case however a large resolution can easily perform large allocations that fail,
* support early exiting in this case. */
if ((o->_k = (float *)MEM_mallocN(sizeof(float) * (size_t)M * (1 + N / 2), "ocean_k")) &&
(o->_h0 = (fftw_complex *)MEM_mallocN(sizeof(fftw_complex) * (size_t)M * N, "ocean_h0")) &&
(o->_h0_minus = (fftw_complex *)MEM_mallocN(sizeof(fftw_complex) * (size_t)M * N,
if ((o->_k = (float *)MEM_mallocN(sizeof(float) * size_t(M) * (1 + N / 2), "ocean_k")) &&
(o->_h0 = (fftw_complex *)MEM_mallocN(sizeof(fftw_complex) * size_t(M) * N, "ocean_h0")) &&
(o->_h0_minus = (fftw_complex *)MEM_mallocN(sizeof(fftw_complex) * size_t(M) * N,
"ocean_h0_minus")) &&
(o->_kx = (float *)MEM_mallocN(sizeof(float) * o->_M, "ocean_kx")) &&
(o->_kz = (float *)MEM_mallocN(sizeof(float) * o->_N, "ocean_kz")))
@@ -883,28 +883,28 @@ bool BKE_ocean_init(Ocean *o,
/* The +VE components and DC. */
for (i = 0; i <= o->_M / 2; i++) {
o->_kx[i] = 2.0f * (float)M_PI * i / o->_Lx;
o->_kx[i] = 2.0f * float(M_PI) * i / o->_Lx;
}
/* The -VE components. */
for (i = o->_M - 1, ii = 0; i > o->_M / 2; i--, ii++) {
o->_kx[i] = -2.0f * (float)M_PI * ii / o->_Lx;
o->_kx[i] = -2.0f * float(M_PI) * ii / o->_Lx;
}
/* The +VE components and DC. */
for (i = 0; i <= o->_N / 2; i++) {
o->_kz[i] = 2.0f * (float)M_PI * i / o->_Lz;
o->_kz[i] = 2.0f * float(M_PI) * i / o->_Lz;
}
/* The -VE components. */
for (i = o->_N - 1, ii = 0; i > o->_N / 2; i--, ii++) {
o->_kz[i] = -2.0f * (float)M_PI * ii / o->_Lz;
o->_kz[i] = -2.0f * float(M_PI) * ii / o->_Lz;
}
/* pre-calculate the k matrix */
for (i = 0; i < o->_M; i++) {
for (j = 0; j <= o->_N / 2; j++) {
o->_k[(size_t)i * (1 + o->_N / 2) + j] = sqrt(o->_kx[i] * o->_kx[i] + o->_kz[j] * o->_kz[j]);
o->_k[size_t(i) * (1 + o->_N / 2) + j] = sqrt(o->_kx[i] * o->_kx[i] + o->_kz[j] * o->_kz[j]);
}
}
@@ -930,37 +930,37 @@ bool BKE_ocean_init(Ocean *o,
case MOD_OCEAN_SPECTRUM_JONSWAP:
mul_complex_f(o->_h0[i * o->_N + j],
r1r2,
(float)sqrt(BLI_ocean_spectrum_jonswap(o, o->_kx[i], o->_kz[j]) / 2.0f));
float(sqrt(BLI_ocean_spectrum_jonswap(o, o->_kx[i], o->_kz[j]) / 2.0f)));
mul_complex_f(o->_h0_minus[i * o->_N + j],
r1r2,
(float)sqrt(BLI_ocean_spectrum_jonswap(o, -o->_kx[i], -o->_kz[j]) / 2.0f));
float(sqrt(BLI_ocean_spectrum_jonswap(o, -o->_kx[i], -o->_kz[j]) / 2.0f)));
break;
case MOD_OCEAN_SPECTRUM_TEXEL_MARSEN_ARSLOE:
mul_complex_f(
o->_h0[i * o->_N + j],
r1r2,
(float)sqrt(BLI_ocean_spectrum_texelmarsenarsloe(o, o->_kx[i], o->_kz[j]) / 2.0f));
float(sqrt(BLI_ocean_spectrum_texelmarsenarsloe(o, o->_kx[i], o->_kz[j]) / 2.0f)));
mul_complex_f(
o->_h0_minus[i * o->_N + j],
r1r2,
(float)sqrt(BLI_ocean_spectrum_texelmarsenarsloe(o, -o->_kx[i], -o->_kz[j]) / 2.0f));
float(sqrt(BLI_ocean_spectrum_texelmarsenarsloe(o, -o->_kx[i], -o->_kz[j]) / 2.0f)));
break;
case MOD_OCEAN_SPECTRUM_PIERSON_MOSKOWITZ:
mul_complex_f(
o->_h0[i * o->_N + j],
r1r2,
(float)sqrt(BLI_ocean_spectrum_piersonmoskowitz(o, o->_kx[i], o->_kz[j]) / 2.0f));
float(sqrt(BLI_ocean_spectrum_piersonmoskowitz(o, o->_kx[i], o->_kz[j]) / 2.0f)));
mul_complex_f(
o->_h0_minus[i * o->_N + j],
r1r2,
(float)sqrt(BLI_ocean_spectrum_piersonmoskowitz(o, -o->_kx[i], -o->_kz[j]) / 2.0f));
float(sqrt(BLI_ocean_spectrum_piersonmoskowitz(o, -o->_kx[i], -o->_kz[j]) / 2.0f)));
break;
default:
mul_complex_f(
o->_h0[i * o->_N + j], r1r2, (float)sqrt(Ph(o, o->_kx[i], o->_kz[j]) / 2.0f));
o->_h0[i * o->_N + j], r1r2, float(sqrt(Ph(o, o->_kx[i], o->_kz[j]) / 2.0f)));
mul_complex_f(o->_h0_minus[i * o->_N + j],
r1r2,
(float)sqrt(Ph(o, -o->_kx[i], -o->_kz[j]) / 2.0f));
float(sqrt(Ph(o, -o->_kx[i], -o->_kz[j]) / 2.0f)));
break;
}
}
@@ -1242,28 +1242,28 @@ void BKE_ocean_cache_eval_uv(OceanCache *och, OceanResult *ocr, int f, float u,
}
if (och->ibufs_disp[f]) {
ibuf_sample(och->ibufs_disp[f], u, v, (1.0f / (float)res_x), (1.0f / (float)res_y), result);
ibuf_sample(och->ibufs_disp[f], u, v, (1.0f / float(res_x)), (1.0f / float(res_y)), result);
copy_v3_v3(ocr->disp, result);
}
if (och->ibufs_foam[f]) {
ibuf_sample(och->ibufs_foam[f], u, v, (1.0f / (float)res_x), (1.0f / (float)res_y), result);
ibuf_sample(och->ibufs_foam[f], u, v, (1.0f / float(res_x)), (1.0f / float(res_y)), result);
ocr->foam = result[0];
}
if (och->ibufs_spray[f]) {
ibuf_sample(och->ibufs_spray[f], u, v, (1.0f / (float)res_x), (1.0f / (float)res_y), result);
ibuf_sample(och->ibufs_spray[f], u, v, (1.0f / float(res_x)), (1.0f / float(res_y)), result);
copy_v3_v3(ocr->Eplus, result);
}
if (och->ibufs_spray_inverse[f]) {
ibuf_sample(
och->ibufs_spray_inverse[f], u, v, (1.0f / (float)res_x), (1.0f / (float)res_y), result);
och->ibufs_spray_inverse[f], u, v, (1.0f / float(res_x)), (1.0f / float(res_y)), result);
copy_v3_v3(ocr->Eminus, result);
}
if (och->ibufs_norm[f]) {
ibuf_sample(och->ibufs_norm[f], u, v, (1.0f / (float)res_x), (1.0f / (float)res_y), result);
ibuf_sample(och->ibufs_norm[f], u, v, (1.0f / float(res_x)), (1.0f / float(res_y)), result);
copy_v3_v3(ocr->normal, result);
}
}
@@ -1535,7 +1535,7 @@ void BKE_ocean_bake(Ocean *o,
IMB_freeImBuf(ibuf_spray);
IMB_freeImBuf(ibuf_spray_inverse);
progress = (f - och->start) / (float)och->duration;
progress = (f - och->start) / float(och->duration);
update_cb(update_cb_data, progress, &cancel);
@@ -1599,7 +1599,7 @@ void BKE_ocean_simulate(struct Ocean * /*o*/, float /*t*/, float /*scale*/, floa
{
}
struct Ocean *BKE_ocean_add(void)
struct Ocean *BKE_ocean_add()
{
Ocean *oc = static_cast<Ocean *>(MEM_callocN(sizeof(Ocean), "ocean sim data"));
@@ -38,7 +38,7 @@ static void psys_path_iter_get(ParticlePathIterator *iter,
iter->key = keys + index;
iter->index = index;
iter->time = (float)index / (float)(totkeys - 1);
iter->time = float(index) / float(totkeys - 1);
if (parent) {
iter->parent_key = parent + index;
@@ -80,15 +80,15 @@ static void do_kink_spiral_deform(ParticleKey *state,
* and goes up to the Golden Spiral for 1.0
* https://en.wikipedia.org/wiki/Golden_spiral
*/
const float b = shape * (1.0f + sqrtf(5.0f)) / (float)M_PI * 0.25f;
const float b = shape * (1.0f + sqrtf(5.0f)) / float(M_PI) * 0.25f;
/* angle of the spiral against the curve (rotated opposite to make a smooth transition) */
const float start_angle = ((b != 0.0f) ? atanf(1.0f / b) : (float)-M_PI_2) +
(b > 0.0f ? -(float)M_PI_2 : (float)M_PI_2);
const float start_angle = ((b != 0.0f) ? atanf(1.0f / b) : float(-M_PI_2)) +
(b > 0.0f ? -float(M_PI_2) : float(M_PI_2));
float spiral_axis[3], rot[3][3];
float vec[3];
float theta = freq * time * 2.0f * (float)M_PI;
float theta = freq * time * 2.0f * float(M_PI);
float radius = amplitude * expf(b * theta);
/* a bit more intuitive than using negative frequency for this */
@@ -127,7 +127,7 @@ static void do_kink_spiral(ParticleThreadContext *ctx,
float *r_max_length)
{
ParticleSettings *part = ctx->sim.psys->part;
const int seed = ctx->sim.psys->child_seed + (int)(cpa - ctx->sim.psys->child);
const int seed = ctx->sim.psys->child_seed + int(cpa - ctx->sim.psys->child);
const int totkeys = ctx->segments + 1;
const int extrakeys = ctx->extra_segments;
@@ -160,14 +160,14 @@ static void do_kink_spiral(ParticleThreadContext *ctx,
zero_v3(spiral_start);
for (k = 0, key = keys; k < totkeys - 1; k++, key++) {
if ((float)(k + 1) >= cut_time) {
float fac = cut_time - (float)k;
if (float(k + 1) >= cut_time) {
float fac = cut_time - float(k);
ParticleCacheKey *par = parent_keys + k;
start_index = k + 1;
end_index = start_index + extrakeys;
spiral_start_time = ((float)k + fac) / (float)(totkeys - 1);
spiral_start_time = (float(k) + fac) / float(totkeys - 1);
interp_v3_v3v3(spiral_start, key->co, (key + 1)->co, fac);
interp_v3_v3v3(spiral_par_co, par->co, (par + 1)->co, fac);
@@ -202,13 +202,13 @@ static void do_kink_spiral(ParticleThreadContext *ctx,
sub_v3_v3v3(dir, (key + 1)->co, key->co);
normalize_v3(dir);
par_time = (float)k / (float)(totkeys - 1);
par_time = float(k) / float(totkeys - 1);
par_co = parent_keys[k].co;
par_vel = parent_keys[k].vel;
par_rot = parent_keys[k].rot;
}
else {
float spiral_time = (float)(k - start_index) / (float)(extrakeys - 1);
float spiral_time = float(k - start_index) / float(extrakeys - 1);
float kink[3], tmp[3];
/* use same time value for every point on the spiral */
@@ -223,7 +223,7 @@ static void do_kink_spiral(ParticleThreadContext *ctx,
if (kink_axis_random > 0.0f) {
float a = kink_axis_random * (psys_frand(ctx->sim.psys, 7112 + seed) * 2.0f - 1.0f) *
(float)M_PI;
float(M_PI);
float rot[3][3];
axis_angle_normalized_to_mat3(rot, dir, a);
@@ -339,7 +339,7 @@ void psys_apply_child_modifiers(ParticleThreadContext *ctx,
}
{
const float step_length = 1.0f / (float)(totkeys - 1);
const float step_length = 1.0f / float(totkeys - 1);
float cur_length = 0.0f;
if (max_length <= 0.0f) {
@@ -405,19 +405,19 @@ void do_kink(ParticleKey *state,
if (shape != 0.0f && !ELEM(type, PART_KINK_BRAID)) {
if (shape < 0.0f) {
time = (float)pow(time, 1.0f + shape);
time = float(pow(time, 1.0f + shape));
}
else {
time = (float)pow(time, 1.0f / (1.0f - shape));
time = float(pow(time, 1.0f / (1.0f - shape)));
}
}
t = time * freq * (float)M_PI;
t = time * freq * float(M_PI);
if (smooth_start) {
dt = fabsf(t);
/* smooth the beginning of kink */
CLAMP(dt, 0.0f, (float)M_PI);
CLAMP(dt, 0.0f, float(M_PI));
dt = sinf(dt / 2.0f);
}
@@ -505,18 +505,18 @@ void do_kink(ParticleKey *state,
mul_v3_fl(z_vec, amplitude / 2.0f * sinf(2.0f * t));
}
else if (inp_z > 0.0f) {
mul_v3_v3fl(state_co, z_vec, sinf((float)M_PI / 3.0f));
mul_v3_v3fl(state_co, z_vec, sinf(float(M_PI) / 3.0f));
madd_v3_v3fl(state_co, y_vec, -0.5f);
mul_v3_fl(y_vec, -amplitude * cosf(t + (float)M_PI / 3.0f));
mul_v3_fl(z_vec, amplitude / 2.0f * cosf(2.0f * t + (float)M_PI / 6.0f));
mul_v3_fl(y_vec, -amplitude * cosf(t + float(M_PI) / 3.0f));
mul_v3_fl(z_vec, amplitude / 2.0f * cosf(2.0f * t + float(M_PI) / 6.0f));
}
else {
mul_v3_v3fl(state_co, z_vec, -sinf((float)M_PI / 3.0f));
mul_v3_v3fl(state_co, z_vec, -sinf(float(M_PI) / 3.0f));
madd_v3_v3fl(state_co, y_vec, -0.5f);
mul_v3_fl(y_vec, amplitude * -sinf(t + (float)M_PI / 6.0f));
mul_v3_fl(z_vec, amplitude / 2.0f * -sinf(2.0f * t + (float)M_PI / 3.0f));
mul_v3_fl(y_vec, amplitude * -sinf(t + float(M_PI) / 6.0f));
mul_v3_fl(z_vec, amplitude / 2.0f * -sinf(2.0f * t + float(M_PI) / 3.0f));
}
mul_v3_fl(state_co, amplitude);
@@ -530,11 +530,11 @@ void do_kink(ParticleKey *state,
add_v3_v3(state_co, z_vec);
add_v3_v3(state_co, par_vec);
shape = 2.0f * (float)M_PI * (1.0f + shape);
shape = 2.0f * float(M_PI) * (1.0f + shape);
if (t < shape) {
shape = t / shape;
shape = (float)sqrt((double)shape);
shape = float(sqrt(double(shape)));
interp_v3_v3v3(result, result, state_co, shape);
}
else {
@@ -581,10 +581,10 @@ static float do_clump_level(float result[3],
}
if (clumpfac < 0.0f) { /* clump roots instead of tips */
clump = -clumpfac * pa_clump * (float)pow(1.0 - (double)time, (double)cpow);
clump = -clumpfac * pa_clump * float(pow(1.0 - double(time), double(cpow)));
}
else {
clump = clumpfac * pa_clump * (float)pow((double)time, (double)cpow);
clump = clumpfac * pa_clump * float(pow(double(time), double(cpow)));
}
interp_v3_v3v3(result, co, par_co, clump);
@@ -636,7 +636,7 @@ static void do_rough(const float loc[3],
float rco[3];
if (thres != 0.0f) {
if (fabsf((float)(-1.5f + loc[0] + loc[1] + loc[2])) < 1.5f * thres) {
if (fabsf(float(-1.5f + loc[0] + loc[1] + loc[2])) < 1.5f * thres) {
return;
}
}
@@ -658,7 +658,7 @@ static void do_rough_end(
float rough[2];
float roughfac;
roughfac = fac * (float)pow((double)t, shape);
roughfac = fac * float(pow(double(t), shape));
copy_v2_v2(rough, loc);
rough[0] = -1.0f + 2.0f * rough[0];
rough[1] = -1.0f + 2.0f * rough[1];
@@ -121,11 +121,11 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys)
/* determine major axis */
axis = axis_dominant_v3_single(delta);
d = delta[axis] / (float)res;
d = delta[axis] / float(res);
size[axis] = res;
size[(axis + 1) % 3] = (int)ceil(delta[(axis + 1) % 3] / d);
size[(axis + 2) % 3] = (int)ceil(delta[(axis + 2) % 3] / d);
size[(axis + 1) % 3] = int(ceil(delta[(axis + 1) % 3] / d));
size[(axis + 2) % 3] = int(ceil(delta[(axis + 2) % 3] / d));
/* float errors grrr. */
size[(axis + 1) % 3] = MIN2(size[(axis + 1) % 3], res);
@@ -143,9 +143,9 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys)
for (i = 0, p = 0, pa = psys->particles; i < res; i++) {
for (j = 0; j < res; j++) {
for (k = 0; k < res; k++, p++, pa++) {
pa->fuv[0] = min[0] + (float)i * d;
pa->fuv[1] = min[1] + (float)j * d;
pa->fuv[2] = min[2] + (float)k * d;
pa->fuv[0] = min[0] + float(i) * d;
pa->fuv[1] = min[1] + float(j) * d;
pa->fuv[2] = min[2] + float(k) * d;
pa->flag |= PARS_UNEXIST;
pa->hair_index = 0; /* abused in volume calculation */
}
@@ -167,8 +167,8 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys)
vec[0] /= delta[0];
vec[1] /= delta[1];
vec[2] /= delta[2];
pa[((int)(vec[0] * (size[0] - 1)) * res + (int)(vec[1] * (size[1] - 1))) * res +
(int)(vec[2] * (size[2] - 1))]
pa[(int(vec[0] * (size[0] - 1)) * res + int(vec[1] * (size[1] - 1))) * res +
int(vec[2] * (size[2] - 1))]
.flag &= ~PARS_UNEXIST;
}
}
@@ -228,14 +228,14 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys)
bool intersects_tri = isect_ray_tri_watertight_v3(
co1, &isect_precalc, v1, v2, v3, &lambda, nullptr);
if (intersects_tri) {
pa1 = (pa + (int)(lambda * size[a]) * a0mul);
pa1 = (pa + int(lambda * size[a]) * a0mul);
}
if (mface->v4 && (!intersects_tri || from == PART_FROM_VOLUME)) {
copy_v3_v3(v4, positions[mface->v4]);
if (isect_ray_tri_watertight_v3(co1, &isect_precalc, v1, v3, v4, &lambda, nullptr)) {
pa2 = (pa + (int)(lambda * size[a]) * a0mul);
pa2 = (pa + int(lambda * size[a]) * a0mul);
}
}
@@ -328,14 +328,14 @@ static void hammersley_create(float *out, int n, int seed, float amount)
double ofs[2], t;
rng = BLI_rng_new(31415926 + n + seed);
ofs[0] = BLI_rng_get_double(rng) + (double)amount;
ofs[1] = BLI_rng_get_double(rng) + (double)amount;
ofs[0] = BLI_rng_get_double(rng) + double(amount);
ofs[1] = BLI_rng_get_double(rng) + double(amount);
BLI_rng_free(rng);
for (int k = 0; k < n; k++) {
BLI_hammersley_1d(k, &t);
out[2 * k + 0] = fmod((double)k / (double)n + ofs[0], 1.0);
out[2 * k + 0] = fmod(double(k) / double(n) + ofs[0], 1.0);
out[2 * k + 1] = fmod(t + ofs[1], 1.0);
}
}
@@ -351,9 +351,9 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount)
return;
}
rad1 = (float)(1.0f / sqrtf((float)num));
rad2 = (float)(1.0f / ((float)num));
rad3 = (float)sqrtf((float)num) / ((float)num);
rad1 = float(1.0f / sqrtf(float(num)));
rad2 = float(1.0f / (float(num)));
rad3 = float(sqrtf(float(num)) / (float(num)));
rng = BLI_rng_new(31415926 + num + seed2);
x = 0;
@@ -363,11 +363,11 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount)
jit[i] = x + amount * rad1 * (0.5f - BLI_rng_get_float(rng));
jit[i + 1] = i / (2.0f * num) + amount * rad1 * (0.5f - BLI_rng_get_float(rng));
jit[i] -= (float)floor(jit[i]);
jit[i + 1] -= (float)floor(jit[i + 1]);
jit[i] -= float(floor(jit[i]));
jit[i + 1] -= float(floor(jit[i + 1]));
x += rad3;
x -= (float)floor(x);
x -= float(floor(x));
}
jit2 = static_cast<float *>(MEM_mallocN(12 + sizeof(float[2]) * num, "initjit"));
@@ -545,10 +545,10 @@ static void distribute_from_faces_exec(ParticleTask *thread, ParticleData *pa, i
}
}
else {
float offset = fmod(ctx->jitoff[i] + (float)p, (float)ctx->jitlevel);
float offset = fmod(ctx->jitoff[i] + float(p), float(ctx->jitlevel));
if (!isnan(offset)) {
psys_uv_to_w(
ctx->jit[2 * (int)offset], ctx->jit[2 * (int)offset + 1], mface->v4, pa->fuv);
ctx->jit[2 * int(offset)], ctx->jit[2 * int(offset) + 1], mface->v4, pa->fuv);
}
}
break;
@@ -597,10 +597,10 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa,
}
}
else {
float offset = fmod(ctx->jitoff[i] + (float)p, (float)ctx->jitlevel);
float offset = fmod(ctx->jitoff[i] + float(p), float(ctx->jitlevel));
if (!isnan(offset)) {
psys_uv_to_w(
ctx->jit[2 * (int)offset], ctx->jit[2 * (int)offset + 1], mface->v4, pa->fuv);
ctx->jit[2 * int(offset)], ctx->jit[2 * int(offset) + 1], mface->v4, pa->fuv);
}
}
break;
@@ -734,7 +734,7 @@ static void distribute_children_exec(ParticleTask *thread, ChildParticle *cpa, i
/* the weights here could be done better */
for (w = 0; w < maxw; w++) {
parent[w] = ptn[w].index;
pweight[w] = (float)pow(2.0, (double)(-6.0f * ptn[w].dist / maxd));
pweight[w] = float(pow(2.0, double(-6.0f * ptn[w].dist / maxd)));
}
for (; w < 10; w++) {
parent[w] = -1;
@@ -1100,7 +1100,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
maxweight /= totarea;
}
else {
float min = 1.0f / (float)MIN2(totelem, totpart);
float min = 1.0f / float(MIN2(totelem, totpart));
for (i = 0; i < totelem; i++) {
element_weight[i] = min;
}
@@ -1207,7 +1207,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
else {
double step, pos;
step = (totpart < 2) ? 0.5 : 1.0 / (double)totpart;
step = (totpart < 2) ? 0.5 : 1.0 / double(totpart);
/* This is to address tricky issues with vertex-emitting when user tries
* (and expects) exact 1-1 vert/part distribution (see #47983 and its two example files).
* It allows us to consider pos as 'midpoint between v and v+1'
@@ -1215,11 +1215,11 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
* and avoid stumbling over float impression in element_sum.
* NOTE: moved face and volume distribution to this as well (instead of starting at zero),
* for the same reasons, see #52682. */
pos = (totpart < totmapped) ? 0.5 / (double)totmapped :
pos = (totpart < totmapped) ? 0.5 / double(totmapped) :
step * 0.5; /* We choose the smaller step. */
for (i = 0, p = 0; p < totpart; p++, pos += step) {
for (; (i < totmapped - 1) && (pos > (double)element_sum[i]); i++) {
for (; (i < totmapped - 1) && (pos > double(element_sum[i])); i++) {
/* pass */
}
@@ -584,7 +584,7 @@ static void init_particle_texture(ParticleSimulationData *sim, ParticleData *pa,
void init_particle(ParticleSimulationData *sim, ParticleData *pa)
{
ParticleSettings *part = sim->psys->part;
float birth_time = (float)(pa - sim->psys->particles) / (float)sim->psys->totpart;
float birth_time = float(pa - sim->psys->particles) / float(sim->psys->totpart);
pa->flag &= ~PARS_UNEXIST;
pa->time = part->sta + (part->end - part->sta) * birth_time;
@@ -775,8 +775,8 @@ void psys_get_birth_coords(
#else
float phase = 0.0f;
#endif
mul_v3_fl(vtan, -cosf((float)M_PI * (part->tanphase + phase)));
fac = -sinf((float)M_PI * (part->tanphase + phase));
mul_v3_fl(vtan, -cosf(float(M_PI) * (part->tanphase + phase)));
fac = -sinf(float(M_PI) * (part->tanphase + phase));
madd_v3_v3fl(vtan, utan, fac);
mul_mat3_m4_v3(ob->object_to_world, vtan);
@@ -1020,7 +1020,7 @@ void psys_get_birth_coords(
if (part->randphasefac != 0.0f) {
phasefac += part->randphasefac * psys_frand(psys, p + 20);
}
axis_angle_to_quat(q_phase, x_vec, phasefac * (float)M_PI);
axis_angle_to_quat(q_phase, x_vec, phasefac * float(M_PI));
/* combine base rotation & phase */
mul_qt_qtqt(state->rot, rot, q_phase);
@@ -1260,7 +1260,7 @@ static void set_keyed_keys(ParticleSimulationData *sim)
}
}
else if (totkeys > 1) {
key->time = pa->time + (float)k / (float)(totkeys - 1) * pa->lifetime;
key->time = pa->time + float(k) / float(totkeys - 1) * pa->lifetime;
}
else {
key->time = pa->time;
@@ -1306,8 +1306,8 @@ void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra
{
ParticleSettings *part = psys->part;
*sfra = max_ii(1, (int)part->sta);
*efra = min_ii((int)(part->end + part->lifetime + 1.0f), max_ii(scene->r.pefra, scene->r.efra));
*sfra = max_ii(1, int(part->sta));
*efra = min_ii(int(part->end + part->lifetime + 1.0f), max_ii(scene->r.pefra, scene->r.efra));
}
/* BVH tree balancing inside a mutex lock must be run in isolation. Balancing
@@ -1929,7 +1929,7 @@ static void sphclassical_density_accum_cb(void *userdata,
SPHRangeData *pfr = (SPHRangeData *)userdata;
ParticleData *npa = pfr->npsys->particles + index;
float q;
float qfac = 21.0f / (256.0f * (float)M_PI);
float qfac = 21.0f / (256.0f * float(M_PI));
float rij, rij_h;
float vec[3];
@@ -2018,7 +2018,7 @@ static void sphclassical_force_cb(void *sphdata_v,
int i;
float qfac2 = 42.0f / (256.0f * (float)M_PI);
float qfac2 = 42.0f / (256.0f * float(M_PI));
float rij_h;
/* 4.0 here is to be consistent with previous formulation/interface */
@@ -3662,7 +3662,7 @@ static void update_courant_num(
}
static float get_base_time_step(ParticleSettings *part)
{
return 1.0f / (float)(part->subframes + 1);
return 1.0f / float(part->subframes + 1);
}
/* Update time step size to suit current conditions. */
static void update_timestep(ParticleSystem *psys, ParticleSimulationData *sim)
@@ -3874,7 +3874,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
}
/* for now do both, boids us 'rng' */
sim->rng = BLI_rng_new_srandom(31415926 + (int)cfra + psys->seed);
sim->rng = BLI_rng_new_srandom(31415926 + int(cfra) + psys->seed);
psys_update_effectors(sim);
@@ -4293,8 +4293,8 @@ static void particles_fluid_step(ParticleSimulationData *sim,
realloc_particles(sim, part->totpart);
/* Set some randomness when choosing which particles to display. */
sim->rng = BLI_rng_new_srandom(31415926 + (int)cfra + psys->seed);
double r, dispProb = (double)part->disp / 100.0;
sim->rng = BLI_rng_new_srandom(31415926 + int(cfra) + psys->seed);
double r, dispProb = double(part->disp) / 100.0;
/* Loop over *all* particles. Will break out of loop before tottypepart amount exceeded. */
for (p = 0, pa = psys->particles; p < totpart; p++) {
@@ -4309,9 +4309,9 @@ static void particles_fluid_step(ParticleSimulationData *sim,
if (part->type == PART_FLUID_FLIP) {
flagActivePart = manta_liquid_get_flip_particle_flag_at(fds->fluid, p);
resX = (float)manta_get_res_x(fds->fluid);
resY = (float)manta_get_res_y(fds->fluid);
resZ = (float)manta_get_res_z(fds->fluid);
resX = float(manta_get_res_x(fds->fluid));
resY = float(manta_get_res_y(fds->fluid));
resZ = float(manta_get_res_z(fds->fluid));
upres = 1;
@@ -4328,9 +4328,9 @@ static void particles_fluid_step(ParticleSimulationData *sim,
{
flagActivePart = manta_liquid_get_snd_particle_flag_at(fds->fluid, p);
resX = (float)manta_liquid_get_particle_res_x(fds->fluid);
resY = (float)manta_liquid_get_particle_res_y(fds->fluid);
resZ = (float)manta_liquid_get_particle_res_z(fds->fluid);
resX = float(manta_liquid_get_particle_res_x(fds->fluid));
resY = float(manta_liquid_get_particle_res_y(fds->fluid));
resZ = float(manta_liquid_get_particle_res_z(fds->fluid));
upres = manta_liquid_get_particle_upres(fds->fluid);
@@ -4396,7 +4396,7 @@ printf("system type is %d and particle type is %d\n", part->type, flagActivePart
sub_v3_v3v3(size, max, min);
/* Biggest dimension will be used for up-scaling. */
max_size = MAX3(size[0] / (float)upres, size[1] / (float)upres, size[2] / (float)upres);
max_size = MAX3(size[0] / float(upres), size[1] / float(upres), size[2] / float(upres));
/* Set particle position. */
const float posParticle[3] = {posX, posY, posZ};
@@ -4550,10 +4550,10 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
update_children(sim, use_render_params);
psys_update_path_cache(sim, cfra, use_render_params);
BKE_ptcache_validate(cache, (int)cache_cfra);
BKE_ptcache_validate(cache, int(cache_cfra));
if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) {
BKE_ptcache_write(pid, (int)cache_cfra);
BKE_ptcache_write(pid, int(cache_cfra));
}
return;
@@ -4564,7 +4564,7 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
return;
}
if (cache_result == PTCACHE_READ_OLD) {
psys->cfra = (float)cache->simframe;
psys->cfra = float(cache->simframe);
cached_step(sim, psys->cfra, use_render_params);
}
@@ -4597,15 +4597,15 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
/* handle negative frame start at the first frame by doing
* all the steps before the first frame */
if ((int)cfra == startframe && part->sta < startframe) {
totframesback = (startframe - (int)part->sta);
if (int(cfra) == startframe && part->sta < startframe) {
totframesback = startframe - int(part->sta);
}
if (!(part->time_flag & PART_TIME_AUTOSF)) {
/* Constant time step */
psys->dt_frac = get_base_time_step(part);
}
else if ((int)cfra == startframe) {
else if (int(cfra) == startframe) {
/* Variable time step; initialize to sub-frames. */
psys->dt_frac = get_base_time_step(part);
}
@@ -4633,9 +4633,9 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
/* 4. only write cache starting from second frame */
if (pid) {
BKE_ptcache_validate(cache, (int)cache_cfra);
if ((int)cache_cfra != startframe) {
BKE_ptcache_write(pid, (int)cache_cfra);
BKE_ptcache_validate(cache, int(cache_cfra));
if (int(cache_cfra) != startframe) {
BKE_ptcache_write(pid, int(cache_cfra));
}
}
@@ -4870,7 +4870,7 @@ void particle_system_update(Depsgraph *depsgraph,
}
for (i = 0; i <= part->hair_step; i++) {
hcfra = 100.0f * (float)i / (float)psys->part->hair_step;
hcfra = 100.0f * float(i) / float(psys->part->hair_step);
if ((part->flag & PART_HAIR_REGROW) == 0) {
const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
depsgraph, hcfra);
@@ -4903,7 +4903,7 @@ void particle_system_update(Depsgraph *depsgraph,
particles_has_bubble(part->type) || particles_has_foam(part->type) ||
particles_has_tracer(part->type))
{
particles_fluid_step(&sim, (int)cfra, use_render_params);
particles_fluid_step(&sim, int(cfra), use_render_params);
}
else {
switch (part->phystype) {
@@ -4956,7 +4956,7 @@ void particle_system_update(Depsgraph *depsgraph,
if (part->phystype == PART_PHYS_KEYED) {
psys_count_keyed_targets(&sim);
set_keyed_keys(&sim);
psys_update_path_cache(&sim, (int)cfra, use_render_params);
psys_update_path_cache(&sim, int(cfra), use_render_params);
}
break;
}
+27 -28
View File
@@ -284,8 +284,8 @@ static int ptcache_particle_write(int index, void *psys_v, void **data, int cfra
}
else {
/* Inclusive ranges for particle lifetime (`dietime - 1` for an inclusive end-frame). */
const int pa_sfra = (int)pa->time - step;
const int pa_efra = ((int)pa->dietime - 1) + step;
const int pa_sfra = int(pa->time) - step;
const int pa_efra = (int(pa->dietime) - 1) + step;
if (!(cfra >= pa_sfra && cfra <= pa_efra)) {
return 0;
}
@@ -400,8 +400,8 @@ static void ptcache_particle_interpolate(int index,
pa = psys->particles + index;
/* Inclusive ranges for particle lifetime (`dietime - 1` for an inclusive end-frame). */
const int pa_sfra = (int)pa->time - psys->pointcache->step;
const int pa_efra = ((int)pa->dietime - 1) + psys->pointcache->step;
const int pa_sfra = int(pa->time) - psys->pointcache->step;
const int pa_efra = (int(pa->dietime) - 1) + psys->pointcache->step;
/* Particle wasn't read from first cache so can't interpolate. */
if (!(cfra1 >= pa_sfra && cfra1 <= pa_efra)) {
@@ -485,15 +485,15 @@ static int ptcache_particle_totwrite(void *psys_v, int cfra)
if (psys->part->flag & PART_DIED) {
/* Also store dead particles when they are displayed. */
for (p = 0; p < psys->totpart; p++, pa++) {
const int pa_sfra = (int)pa->time - step;
const int pa_sfra = int(pa->time) - step;
totwrite += (cfra >= pa_sfra);
}
}
else {
for (p = 0; p < psys->totpart; p++, pa++) {
/* Inclusive ranges for particle lifetime (`dietime - 1` for an inclusive end-frame). */
const int pa_sfra = (int)pa->time - step;
const int pa_efra = ((int)pa->dietime - 1) + step;
const int pa_sfra = int(pa->time) - step;
const int pa_efra = (int(pa->dietime) - 1) + step;
totwrite += (cfra >= pa_sfra) && (cfra <= pa_efra);
}
}
@@ -1431,8 +1431,7 @@ static int ptcache_filepath(PTCacheID *pid,
/* convert chars to hex so they are always a valid filename */
while ('\0' != *idname) {
/* Always 2 unless there isn't enough room in the string. */
const int temp = BLI_snprintf_rlen(
newname, MAX_PTCACHE_FILE - len, "%02X", (uint)(*idname++));
const int temp = BLI_snprintf_rlen(newname, MAX_PTCACHE_FILE - len, "%02X", uint(*idname++));
newname += temp;
len += temp;
}
@@ -1444,7 +1443,7 @@ static int ptcache_filepath(PTCacheID *pid,
}
if (do_ext) {
len += ptcache_filepath_ext_append(pid, filepath, (size_t)len, true, cfra);
len += ptcache_filepath_ext_append(pid, filepath, size_t(len), true, cfra);
}
return len; /* make sure the above string is always 16 chars */
@@ -1520,7 +1519,7 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, uchar *result, uint len
if (compressed) {
uint size;
ptcache_file_read(pf, &size, 1, sizeof(uint));
in_len = (size_t)size;
in_len = size_t(size);
if (in_len == 0) {
/* do nothing */
}
@@ -1537,7 +1536,7 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, uchar *result, uint len
size_t sizeOfIt;
size_t leni = in_len, leno = len;
ptcache_file_read(pf, &size, 1, sizeof(uint));
sizeOfIt = (size_t)size;
sizeOfIt = size_t(size);
ptcache_file_read(pf, props, sizeOfIt, sizeof(uchar));
r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt);
}
@@ -1584,7 +1583,7 @@ static int ptcache_file_compressed_write(
r = LzmaCompress(out,
&out_len,
in,
in_len, /* assume sizeof(char)==1.... */
in_len, /* Assume `sizeof(char) == 1`. */
props,
&sizeOfIt,
5,
@@ -2206,13 +2205,13 @@ static int ptcache_read(PTCacheID *pid, int cfra)
index = static_cast<int *>(cur[BPHYS_DATA_INDEX]);
}
pid->read_point(*index, pid->calldata, cur, (float)pm->frame, nullptr);
pid->read_point(*index, pid->calldata, cur, float(pm->frame), nullptr);
BKE_ptcache_mem_pointers_incr(cur);
}
if (pid->read_extra_data && pm->extradata.first) {
pid->read_extra_data(pid->calldata, pm, (float)pm->frame);
pid->read_extra_data(pid->calldata, pm, float(pm->frame));
}
/* clean up temporary memory cache */
@@ -2247,7 +2246,7 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2)
int totpoint = pm->totpoint;
if ((pid->data_types & (1 << BPHYS_DATA_INDEX)) == 0) {
int pid_totpoint = pid->totpoint(pid->calldata, (int)cfra);
int pid_totpoint = pid->totpoint(pid->calldata, int(cfra));
if (totpoint != pid_totpoint) {
pid->error(pid->owner_id, pid->calldata, "Number of points in cache does not match mesh");
@@ -2264,12 +2263,12 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2)
}
pid->interpolate_point(
*index, pid->calldata, cur, cfra, (float)cfra1, (float)cfra2, nullptr);
*index, pid->calldata, cur, cfra, float(cfra1), float(cfra2), nullptr);
BKE_ptcache_mem_pointers_incr(cur);
}
if (pid->interpolate_extra_data && pm->extradata.first) {
pid->interpolate_extra_data(pid->calldata, pm, cfra, (float)cfra1, (float)cfra2);
pid->interpolate_extra_data(pid->calldata, pm, cfra, float(cfra1), float(cfra2));
}
/* clean up temporary memory cache */
@@ -2284,7 +2283,7 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2)
int BKE_ptcache_read(PTCacheID *pid, float cfra, bool no_extrapolate_old)
{
int cfrai = (int)floor(cfra), cfra1 = 0, cfra2 = 0;
int cfrai = int(floor(cfra)), cfra1 = 0, cfra2 = 0;
int ret = 0;
/* nothing to read to */
@@ -2298,7 +2297,7 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra, bool no_extrapolate_old)
}
/* first check if we have the actual frame cached */
if (cfra == (float)cfrai && BKE_ptcache_id_exist(pid, cfrai)) {
if (cfra == float(cfrai) && BKE_ptcache_id_exist(pid, cfrai)) {
cfra1 = cfrai;
}
@@ -2362,7 +2361,7 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra, bool no_extrapolate_old)
pid->cache->simframe = cfra2;
}
cfrai = (int)cfra;
cfrai = int(cfra);
/* clear invalid cache frames so that better stuff can be simulated */
if (pid->cache->flag & PTCACHE_OUTDATED) {
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfrai);
@@ -2839,7 +2838,7 @@ void BKE_ptcache_id_time(
ptcache_path(pid, path);
len = ptcache_filepath(pid, filepath, (int)cfra, 0, 0); /* no path */
len = ptcache_filepath(pid, filepath, int(cfra), 0, 0); /* no path */
dir = opendir(path);
if (dir == nullptr) {
@@ -3153,16 +3152,16 @@ static void ptcache_dt_to_str(char *str, size_t str_maxncpy, double dtime)
BLI_snprintf(str,
str_maxncpy,
"%ih %im %is",
(int)(dtime / 3600),
(int)(dtime / 60) % 60,
((int)dtime) % 60);
int(dtime / 3600),
int(dtime / 60) % 60,
int(dtime) % 60);
}
else {
BLI_snprintf(str, str_maxncpy, "%im %is", (int)(dtime / 60) % 60, ((int)dtime) % 60);
BLI_snprintf(str, str_maxncpy, "%im %is", int(dtime / 60) % 60, (int(dtime)) % 60);
}
}
else {
BLI_snprintf(str, str_maxncpy, "%is", ((int)dtime) % 60);
BLI_snprintf(str, str_maxncpy, "%is", (int(dtime)) % 60);
}
}
@@ -3306,7 +3305,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
BKE_scene_graph_update_for_newframe(depsgraph);
if (baker->update_progress) {
float progress = ((float)(scene->r.cfra - startframe) / (float)(endframe - startframe));
float progress = (float(scene->r.cfra - startframe) / float(endframe - startframe));
baker->update_progress(baker->bake_job, progress, &cancel);
}
@@ -657,17 +657,17 @@ void BKE_rigidbody_calc_volume(Object *ob, float *r_vol)
break;
case RB_SHAPE_SPHERE:
volume = 4.0f / 3.0f * (float)M_PI * radius * radius * radius;
volume = 4.0f / 3.0f * float(M_PI) * radius * radius * radius;
break;
/* for now, assume that capsule is close enough to a cylinder... */
case RB_SHAPE_CAPSULE:
case RB_SHAPE_CYLINDER:
volume = (float)M_PI * radius * radius * height;
volume = float(M_PI) * radius * radius * height;
break;
case RB_SHAPE_CONE:
volume = (float)M_PI / 3.0f * radius * radius * height;
volume = float(M_PI) / 3.0f * radius * radius * height;
break;
case RB_SHAPE_CONVEXH:
@@ -2285,7 +2285,7 @@ void BKE_rigidbody_rebuild_world(Depsgraph *depsgraph, Scene *scene, float ctime
if (cache->flag & PTCACHE_OUTDATED) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
rigidbody_update_simulation(depsgraph, scene, rbw, true);
BKE_ptcache_validate(cache, (int)ctime);
BKE_ptcache_validate(cache, int(ctime));
cache->last_exact = 0;
cache->flag &= ~PTCACHE_REDO_NEEDED;
}
@@ -2325,7 +2325,7 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime
bool can_simulate = (ctime == rbw->ltime + 1) && !(cache->flag & PTCACHE_BAKED);
if (BKE_ptcache_read(&pid, ctime, can_simulate) == PTCACHE_READ_EXACT) {
BKE_ptcache_validate(cache, (int)ctime);
BKE_ptcache_validate(cache, int(ctime));
rbw->ltime = ctime;
return;
}
@@ -2345,7 +2345,7 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime
const float frame_diff = ctime - rbw->ltime;
/* calculate how much time elapsed since last step in seconds */
const float timestep = 1.0f / (float)FPS * frame_diff * rbw->time_scale;
const float timestep = 1.0f / float(FPS) * frame_diff * rbw->time_scale;
const float substep = timestep / rbw->substeps_per_frame;
@@ -2369,8 +2369,8 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime
rigidbody_update_simulation_post_step(depsgraph, rbw);
/* write cache for current frame */
BKE_ptcache_validate(cache, (int)ctime);
BKE_ptcache_write(&pid, (uint)ctime);
BKE_ptcache_validate(cache, int(ctime));
BKE_ptcache_write(&pid, uint(ctime));
rbw->ltime = ctime;
}
+10 -10
View File
@@ -447,7 +447,7 @@ static void spacetype_free(SpaceType *st)
BLI_freelistN(&st->regiontypes);
}
void BKE_spacetypes_free(void)
void BKE_spacetypes_free()
{
LISTBASE_FOREACH (SpaceType *, st, &spacetypes) {
spacetype_free(st);
@@ -489,7 +489,7 @@ ARegionType *BKE_regiontype_from_id(const SpaceType *st, int regionid)
return nullptr;
}
const ListBase *BKE_spacetypes_list(void)
const ListBase *BKE_spacetypes_list()
{
return &spacetypes;
}
@@ -676,9 +676,9 @@ void BKE_spacedata_id_unref(ScrArea *area, SpaceLink *sl, ID *id)
/**
* Avoid bad-level calls to #WM_gizmomap_tag_refresh.
*/
static void (*region_refresh_tag_gizmomap_callback)(struct wmGizmoMap *) = nullptr;
static void (*region_refresh_tag_gizmomap_callback)(wmGizmoMap *) = nullptr;
void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizmoMap *))
void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(wmGizmoMap *))
{
region_refresh_tag_gizmomap_callback = callback;
}
@@ -701,9 +701,9 @@ void BKE_screen_gizmo_tag_refresh(bScreen *screen)
/**
* Avoid bad-level calls to #WM_gizmomap_delete.
*/
static void (*region_free_gizmomap_callback)(struct wmGizmoMap *) = nullptr;
static void (*region_free_gizmomap_callback)(wmGizmoMap *) = nullptr;
void BKE_region_callback_free_gizmomap_set(void (*callback)(struct wmGizmoMap *))
void BKE_region_callback_free_gizmomap_set(void (*callback)(wmGizmoMap *))
{
region_free_gizmomap_callback = callback;
}
@@ -1136,12 +1136,12 @@ ARegion *BKE_screen_find_main_region_at_xy(bScreen *screen, const int space_type
float BKE_screen_view3d_zoom_to_fac(float camzoom)
{
return powf(((float)M_SQRT2 + camzoom / 50.0f), 2.0f) / 4.0f;
return powf((float(M_SQRT2) + camzoom / 50.0f), 2.0f) / 4.0f;
}
float BKE_screen_view3d_zoom_from_fac(float zoomfac)
{
return ((sqrtf(4.0f * zoomfac) - (float)M_SQRT2) * 50.0f);
return ((sqrtf(4.0f * zoomfac) - float(M_SQRT2)) * 50.0f);
}
bool BKE_screen_is_fullscreen_area(const bScreen *screen)
@@ -1376,8 +1376,8 @@ void BKE_screen_view3d_do_versions_250(View3D *v3d, ListBase *regions)
rv3d = static_cast<RegionView3D *>(
region->regiondata = MEM_callocN(sizeof(RegionView3D), "region v3d patch"));
rv3d->persp = (char)v3d->persp;
rv3d->view = (char)v3d->view;
rv3d->persp = char(v3d->persp);
rv3d->view = char(v3d->view);
rv3d->dist = v3d->dist;
copy_v3_v3(rv3d->ofs, v3d->ofs);
copy_qt_qt(rv3d->viewquat, v3d->viewquat);
@@ -55,7 +55,7 @@ bool BKE_shaderfx_has_gpencil(const Object *ob)
return false;
}
void BKE_shaderfx_init(void)
void BKE_shaderfx_init()
{
/* Initialize shaders */
shaderfx_type_init(shader_fx_types); /* FX_shader_util.c */
+11 -11
View File
@@ -354,7 +354,7 @@ void BKE_sound_force_device(const char *device)
force_device = device;
}
void BKE_sound_init_once(void)
void BKE_sound_init_once()
{
AUD_initOnce();
atexit(BKE_sound_exit_once);
@@ -362,7 +362,7 @@ void BKE_sound_init_once(void)
static AUD_Device *sound_device = nullptr;
void *BKE_sound_get_device(void)
void *BKE_sound_get_device()
{
return sound_device;
}
@@ -432,13 +432,13 @@ void BKE_sound_init_main(Main *bmain)
# endif
}
void BKE_sound_exit(void)
void BKE_sound_exit()
{
AUD_exit(sound_device);
sound_device = nullptr;
}
void BKE_sound_exit_once(void)
void BKE_sound_exit_once()
{
AUD_exit(sound_device);
sound_device = nullptr;
@@ -679,12 +679,12 @@ void BKE_sound_destroy_scene(Scene *scene)
}
}
void BKE_sound_lock(void)
void BKE_sound_lock()
{
AUD_Device_lock(sound_device);
}
void BKE_sound_unlock(void)
void BKE_sound_unlock()
{
AUD_Device_unlock(sound_device);
}
@@ -902,7 +902,7 @@ static double get_cur_time(Scene *scene)
/* We divide by the current framelen to take into account time remapping.
* Otherwise we will get the wrong starting time which will break A/V sync.
* See #74111 for further details. */
return FRA2TIME((scene->r.cfra + scene->r.subframe) / (double)scene->r.framelen);
return FRA2TIME((scene->r.cfra + scene->r.subframe) / double(scene->r.framelen));
}
void BKE_sound_play_scene(Scene *scene)
@@ -1155,7 +1155,7 @@ static void sound_update_base(Scene *scene, Object *object, void *new_set)
if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) {
if (speaker->sound) {
AUD_SequenceEntry_move(strip->speaker_handle, (double)strip->start / FPS, FLT_MAX, 0);
AUD_SequenceEntry_move(strip->speaker_handle, double(strip->start) / FPS, FLT_MAX, 0);
}
else {
AUD_Sequence_remove(scene->sound_scene, strip->speaker_handle);
@@ -1166,7 +1166,7 @@ static void sound_update_base(Scene *scene, Object *object, void *new_set)
if (speaker->sound) {
strip->speaker_handle = AUD_Sequence_add(scene->sound_scene,
speaker->sound->playback_handle,
(double)strip->start / FPS,
double(strip->start) / FPS,
FLT_MAX,
0);
AUD_SequenceEntry_setRelative(strip->speaker_handle, 0);
@@ -1255,7 +1255,7 @@ float BKE_sound_get_length(Main *bmain, bSound *sound)
return info.length;
}
char **BKE_sound_get_device_names(void)
char **BKE_sound_get_device_names()
{
if (audio_device_names == nullptr) {
audio_device_names = AUD_getDeviceNames();
@@ -1428,7 +1428,7 @@ float BKE_sound_get_length(struct Main * /*bmain*/, bSound * /*sound*/)
{
return 0;
}
char **BKE_sound_get_device_names(void)
char **BKE_sound_get_device_names()
{
static char *names[1] = {nullptr};
return names;
@@ -779,7 +779,7 @@ static float studiolight_spherical_harmonics_lambda_get(float *sh, float max_lap
table_b[0] = 0.0f;
int index = 1;
for (int level = 1; level < STUDIOLIGHT_SH_BANDS; level++) {
table_l[level] = (float)(square_i(level) * square_i(level + 1));
table_l[level] = float(square_i(level) * square_i(level + 1));
float b = 0.0f;
for (int m = -1; m <= level; m++) {
@@ -1263,7 +1263,7 @@ static uint alpha_circle_mask(float u, float v, float inner_edge, float outer_ed
const float co[2] = {u - 0.5f, v - 0.5f};
float dist = len_v2(co);
float alpha = 1.0f + (inner_edge - dist) / (outer_edge - inner_edge);
uint mask = (uint)floorf(255.0f * min_ff(max_ff(alpha, 0.0f), 1.0f));
uint mask = uint(floorf(255.0f * min_ff(max_ff(alpha, 0.0f), 1.0f)));
return mask << 24;
}
@@ -1429,7 +1429,7 @@ void BKE_studiolight_default(SolidLight lights[4], float light_ambient[3])
lights[3].vec[2] = -0.542269f;
}
void BKE_studiolight_init(void)
void BKE_studiolight_init()
{
/* Add default studio light */
StudioLight *sl = studiolight_create(
@@ -1470,7 +1470,7 @@ void BKE_studiolight_init(void)
BKE_studiolight_default(sl->light, sl->light_ambient);
}
void BKE_studiolight_free(void)
void BKE_studiolight_free()
{
StudioLight *sl;
while ((sl = static_cast<StudioLight *>(BLI_pophead(&studiolights)))) {
@@ -1530,7 +1530,7 @@ StudioLight *BKE_studiolight_findindex(int index, int flag)
return BKE_studiolight_find_default(flag);
}
ListBase *BKE_studiolight_listbase(void)
ListBase *BKE_studiolight_listbase()
{
return &studiolights;
}
@@ -1634,7 +1634,7 @@ StudioLight *BKE_studiolight_create(const char *filepath,
return sl;
}
StudioLight *BKE_studiolight_studio_edit_get(void)
StudioLight *BKE_studiolight_studio_edit_get()
{
static StudioLight sl = {0};
sl.flag = STUDIOLIGHT_TYPE_STUDIO | STUDIOLIGHT_SPECULAR_HIGHLIGHT_PASS;
@@ -1645,7 +1645,7 @@ StudioLight *BKE_studiolight_studio_edit_get(void)
return &sl;
}
void BKE_studiolight_refresh(void)
void BKE_studiolight_refresh()
{
BKE_studiolight_free();
BKE_studiolight_init();
+6 -6
View File
@@ -216,7 +216,7 @@ static void text_blend_read_data(BlendDataReader *reader, ID *id)
BLO_read_data_address(reader, &ln->line);
ln->format = nullptr;
if (ln->len != (int)strlen(ln->line)) {
if (ln->len != int(strlen(ln->line))) {
printf("Error loading text, line lengths differ\n");
ln->len = strlen(ln->line);
}
@@ -1116,8 +1116,8 @@ void txt_move_to(Text *text, uint line, uint ch, const bool sel)
break;
}
}
if (ch > (uint)((*linep)->len)) {
ch = (uint)((*linep)->len);
if (ch > uint((*linep)->len)) {
ch = uint((*linep)->len);
}
*charp = ch;
@@ -1634,7 +1634,7 @@ int txt_find_string(Text *text, const char *findstr, int wrap, int match_case)
if (s) {
int newl = txt_get_span(static_cast<TextLine *>(text->lines.first), tl);
int newc = (int)(s - tl->line);
int newc = int(s - tl->line);
txt_move_to(text, newl, newc, 0);
txt_move_to(text, newl, newc + strlen(findstr), 1);
return 1;
@@ -2357,12 +2357,12 @@ bool text_check_identifier_nodigit(const char ch)
#ifndef WITH_PYTHON
int text_check_identifier_unicode(const uint ch)
{
return (ch < 255 && text_check_identifier((uint)ch));
return (ch < 255 && text_check_identifier(uint(ch)));
}
int text_check_identifier_nodigit_unicode(const uint ch)
{
return (ch < 255 && text_check_identifier_nodigit((char)ch));
return (ch < 255 && text_check_identifier_nodigit(char(ch)));
}
#endif /* WITH_PYTHON */
@@ -27,7 +27,7 @@ static SuggList suggestions = {nullptr, nullptr, nullptr, nullptr, nullptr};
static char *documentation = nullptr;
// static int doc_lines = 0;
static void txttl_free_suggest(void)
static void txttl_free_suggest()
{
SuggItem *item, *prev;
for (item = suggestions.last; item; item = prev) {
@@ -40,7 +40,7 @@ static void txttl_free_suggest(void)
suggestions.top = 0;
}
static void txttl_free_docs(void)
static void txttl_free_docs()
{
MEM_SAFE_FREE(documentation);
}
@@ -49,7 +49,7 @@ static void txttl_free_docs(void)
/* General tool functions */
/**************************/
void free_texttools(void)
void free_texttools()
{
txttl_free_suggest();
txttl_free_docs();
@@ -64,7 +64,7 @@ void texttool_text_set_active(Text *text)
activeToolText = text;
}
void texttool_text_clear(void)
void texttool_text_clear()
{
free_texttools();
activeToolText = nullptr;
@@ -178,17 +178,17 @@ void texttool_suggest_prefix(const char *prefix, const int prefix_len)
}
}
void texttool_suggest_clear(void)
void texttool_suggest_clear()
{
txttl_free_suggest();
}
SuggItem *texttool_suggest_first(void)
SuggItem *texttool_suggest_first()
{
return suggestions.firstmatch;
}
SuggItem *texttool_suggest_last(void)
SuggItem *texttool_suggest_last()
{
return suggestions.lastmatch;
}
@@ -198,12 +198,12 @@ void texttool_suggest_select(SuggItem *sel)
suggestions.selected = sel;
}
SuggItem *texttool_suggest_selected(void)
SuggItem *texttool_suggest_selected()
{
return suggestions.selected;
}
int *texttool_suggest_top(void)
int *texttool_suggest_top()
{
return &suggestions.top;
}
+9 -9
View File
@@ -816,7 +816,7 @@ static bool unit_distribute_negatives(char *str, const int str_maxncpy)
while ((remaining_str = const_cast<char *>(find_next_negative(str, remaining_str))) != nullptr) {
int remaining_str_maxncpy;
/* Exit early in the unlikely situation that we've run out of length to add the parentheses. */
remaining_str_maxncpy = str_maxncpy - (int)(remaining_str - str);
remaining_str_maxncpy = str_maxncpy - int(remaining_str - str);
if (remaining_str_maxncpy <= 2) {
return changed;
}
@@ -829,7 +829,7 @@ static bool unit_distribute_negatives(char *str, const int str_maxncpy)
/* Add the ')' before the next operation or at the end. */
remaining_str = find_next_op(str, remaining_str + 1, remaining_str_maxncpy);
remaining_str_maxncpy = str_maxncpy - (int)(remaining_str - str);
remaining_str_maxncpy = str_maxncpy - int(remaining_str - str);
memmove(remaining_str + 1, remaining_str, remaining_str_maxncpy - 2);
*remaining_str = ')';
@@ -889,7 +889,7 @@ static int unit_scale_str(char *str,
return 0;
}
int found_ofs = (int)(str_found - str);
int found_ofs = int(str_found - str);
int len = strlen(str);
@@ -1153,7 +1153,7 @@ void BKE_unit_name_to_alt(char *str, int str_maxncpy, const char *orig_str, int
const bool case_sensitive = (unit->flag & B_UNIT_DEF_CASE_SENSITIVE) != 0;
const char *found = unit_find_str(orig_str, unit->name_short, case_sensitive);
if (found) {
int offset = (int)(found - orig_str);
int offset = int(found - orig_str);
int len_name = 0;
/* Copy everything before the unit. */
@@ -1245,19 +1245,19 @@ int BKE_unit_base_of_type_get(int system, int type)
const char *BKE_unit_name_get(const void *usys_pt, int index)
{
const bUnitCollection *usys = static_cast<const bUnitCollection *>(usys_pt);
BLI_assert((uint)index < (uint)usys->length);
BLI_assert(uint(index) < uint(usys->length));
return usys->units[index].name;
}
const char *BKE_unit_display_name_get(const void *usys_pt, int index)
{
const bUnitCollection *usys = static_cast<const bUnitCollection *>(usys_pt);
BLI_assert((uint)index < (uint)usys->length);
BLI_assert(uint(index) < uint(usys->length));
return usys->units[index].name_display;
}
const char *BKE_unit_identifier_get(const void *usys_pt, int index)
{
const bUnitCollection *usys = static_cast<const bUnitCollection *>(usys_pt);
BLI_assert((uint)index < (uint)usys->length);
BLI_assert(uint(index) < uint(usys->length));
const bUnitDef *unit = &usys->units[index];
if (unit->identifier == nullptr) {
BLI_assert_msg(0, "identifier for this unit is not specified yet");
@@ -1268,13 +1268,13 @@ const char *BKE_unit_identifier_get(const void *usys_pt, int index)
double BKE_unit_scalar_get(const void *usys_pt, int index)
{
const bUnitCollection *usys = static_cast<const bUnitCollection *>(usys_pt);
BLI_assert((uint)index < (uint)usys->length);
BLI_assert(uint(index) < uint(usys->length));
return usys->units[index].scalar;
}
bool BKE_unit_is_suppressed(const void *usys_pt, int index)
{
const bUnitCollection *usys = static_cast<const bUnitCollection *>(usys_pt);
BLI_assert((uint)index < (uint)usys->length);
BLI_assert(uint(index) < uint(usys->length));
return (usys->units[index].flag & B_UNIT_DEF_SUPPRESS) != 0;
}
+3 -3
View File
@@ -54,7 +54,7 @@ static int append_stub(void * /*context_v*/,
return 0;
}
static void *context_create_stub(void)
static void *context_create_stub()
{
return nullptr;
}
@@ -206,7 +206,7 @@ static int start_avi(void *context_v,
y = recty;
quality = rd->im_format.quality;
framerate = (double)rd->frs_sec / (double)rd->frs_sec_base;
framerate = double(rd->frs_sec) / double(rd->frs_sec_base);
if (rd->im_format.imtype != R_IMF_IMTYPE_AVIJPEG) {
format = AVI_FORMAT_AVI_RGB;
@@ -288,7 +288,7 @@ static void end_avi(void *context_v)
AVI_close_compress(avi);
}
static void *context_create_avi(void)
static void *context_create_avi()
{
AviMovie *avi = static_cast<AviMovie *>(MEM_mallocN(sizeof(AviMovie), "avimovie"));
return avi;
+1 -1
View File
@@ -993,7 +993,7 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot)
static int hide_pose_bone_fn(Object *ob, Bone *bone, void *ptr)
{
bArmature *arm = static_cast<bArmature *>(ob->data);
const bool hide_select = (bool)POINTER_AS_INT(ptr);
const bool hide_select = bool(POINTER_AS_INT(ptr));
int count = 0;
if (arm->layer & bone->layer) {
if (((bone->flag & BONE_SELECTED) != 0) == hide_select) {
@@ -990,7 +990,7 @@ static eContextResult screen_ctx_editable_gpencil_strokes(const bContext *C,
Object *obact = BKE_view_layer_active_object_get(view_layer);
bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
const bool is_multiedit = bool(GPENCIL_MULTIEDIT_SESSIONS_ON(gpd));
if (gpd == nullptr) {
return CTX_RESULT_NO_DATA;
@@ -1259,11 +1259,11 @@ static void btw_smooth_allocate_operator_data(tGraphSliderOp *gso,
operator_data->coefficients = ED_anim_allocate_butterworth_coefficients(filter_order);
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
ANIM_animdata_filter(
&gso->ac, &anim_data, OPERATOR_DATA_FILTER, gso->ac.data, eAnimCont_Types(gso->ac.datatype));
ListBase segment_links = {NULL, NULL};
ListBase segment_links = {nullptr, nullptr};
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
FCurve *fcu = (FCurve *)ale->key_data;
ListBase fcu_segments = find_fcurve_segments(fcu);
@@ -1346,7 +1346,7 @@ static void btw_smooth_modal_update(bContext *C, wmOperator *op)
}
ANIM_animdata_update(&ac, &operator_data->anim_data);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
}
static int btw_smooth_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -1386,7 +1386,7 @@ static void btw_smooth_graph_keys(bAnimContext *ac,
const int filter_order,
const int samples_per_frame)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
ANIM_animdata_filter(
ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, eAnimCont_Types(ac->datatype));
@@ -1441,7 +1441,7 @@ static int btw_smooth_exec(bContext *C, wmOperator *op)
&ac, blend, blend_in_out, cutoff_frequency, filter_order, samples_per_frame);
/* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@@ -117,7 +117,7 @@ static void push_preview_job_audio_task(struct TaskPool *__restrict task_pool,
/* Only this runs inside thread. */
static void preview_startjob(void *data, bool *stop, bool *do_update, float *progress)
{
TaskPool *task_pool = BLI_task_pool_create(NULL, TASK_PRIORITY_LOW);
TaskPool *task_pool = BLI_task_pool_create(nullptr, TASK_PRIORITY_LOW);
PreviewJob *pj = static_cast<PreviewJob *>(data);
while (true) {
@@ -695,7 +695,7 @@ static void createTransGPencil(bContext *C, TransInfo *t)
const int cfra_scene = scene->r.cfra;
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
const bool is_multiedit = bool(GPENCIL_MULTIEDIT_SESSIONS_ON(gpd));
const bool use_multiframe_falloff = (ts->gp_sculpt.flag & GP_SCULPT_SETT_FLAG_FRAME_FALLOFF) !=
0;
@@ -704,7 +704,7 @@ static void createTransGPencil(bContext *C, TransInfo *t)
const bool is_scale_thickness = ((t->mode == TFM_GPENCIL_SHRINKFATTEN) ||
(ts->gp_sculpt.flag & GP_SCULPT_SETT_FLAG_SCALE_THICKNESS));
const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
const bool is_curve_edit = bool(GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd));
/* initialize falloff curve */
if (is_multiedit) {
@@ -752,7 +752,7 @@ static void recalcData_gpencil_strokes(TransInfo *t)
TransData *td = tc->data;
bGPdata *gpd = static_cast<bGPdata *>(td->ob->data);
const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
const bool is_curve_edit = bool(GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd));
for (int i = 0; i < tc->data_len; i++, td++) {
bGPDstroke *gps = static_cast<bGPDstroke *>(td->extra);
@@ -61,7 +61,7 @@ static void applyGPOpacity(TransInfo *t, const int[2] /*mval*/)
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
bGPdata *gpd = static_cast<bGPdata *>(td->ob->data);
const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
const bool is_curve_edit = bool(GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd));
/* Only recalculate data when in curve edit mode. */
if (is_curve_edit) {
recalc = true;
@@ -61,7 +61,7 @@ static void applyGPShrinkFatten(TransInfo *t, const int[2] /*mval*/)
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
bGPdata *gpd = static_cast<bGPdata *>(td->ob->data);
const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
const bool is_curve_edit = bool(GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd));
/* Only recalculate data when in curve edit mode. */
if (is_curve_edit) {
recalc = true;
@@ -360,7 +360,7 @@ static void rna_ByteIntAttributeValue_set(PointerRNA *ptr, const int new_value)
*value = INT8_MIN;
}
else {
*value = (int8_t)new_value;
*value = int8_t(new_value);
}
}
@@ -1214,7 +1214,7 @@ static void rna_GpencilCurvePoint_BezTriple_ctrlpoint_select_set(PointerRNA *ptr
static bool rna_GpencilCurvePoint_BezTriple_hide_get(PointerRNA *ptr)
{
bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
return (bool)cpt->bezt.hide;
return bool(cpt->bezt.hide);
}
static void rna_GpencilCurvePoint_BezTriple_hide_set(PointerRNA *ptr, const bool value)