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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-10-07 19:49:47 +0300
committerHans Goudey <h.goudey@me.com>2022-10-07 19:49:47 +0300
commitb0fc4e5106a2821c2469a85361ae463ae1590f2f (patch)
tree82ef73e9a50dc95a955eb92e393f760b79cee6db /source/blender/blenkernel
parent701b6b8aab83361970c64e95439a08014681a59d (diff)
parent349091ce00d5ad0b8bca6c7e5ed7314ed1176c3b (diff)
Merge branch 'master' into node-add-asset-menu
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_mesh_mapping.h8
-rw-r--r--source/blender/blenkernel/CMakeLists.txt6
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c2
-rw-r--r--source/blender/blenkernel/intern/armature_deform.c18
-rw-r--r--source/blender/blenkernel/intern/blender_user_menu.c2
-rw-r--r--source/blender/blenkernel/intern/camera.c6
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c4
-rw-r--r--source/blender/blenkernel/intern/cloth.c2
-rw-r--r--source/blender/blenkernel/intern/collection.c6
-rw-r--r--source/blender/blenkernel/intern/colortools.c2
-rw-r--r--source/blender/blenkernel/intern/context.c2
-rw-r--r--source/blender/blenkernel/intern/cryptomatte.cc2
-rw-r--r--source/blender/blenkernel/intern/curve.cc8
-rw-r--r--source/blender/blenkernel/intern/curve_deform.c2
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c2
-rw-r--r--source/blender/blenkernel/intern/editmesh.cc2
-rw-r--r--source/blender/blenkernel/intern/effect.c2
-rw-r--r--source/blender/blenkernel/intern/fcurve_driver.c2
-rw-r--r--source/blender/blenkernel/intern/fluid.c6
-rw-r--r--source/blender/blenkernel/intern/gpencil.c40
-rw-r--r--source/blender/blenkernel/intern/gpencil_modifier.c8
-rw-r--r--source/blender/blenkernel/intern/image_format.cc2
-rw-r--r--source/blender/blenkernel/intern/image_save.cc2
-rw-r--r--source/blender/blenkernel/intern/ipo.c2
-rw-r--r--source/blender/blenkernel/intern/layer.c2
-rw-r--r--source/blender/blenkernel/intern/lib_override.cc2
-rw-r--r--source/blender/blenkernel/intern/mask_rasterize.c4
-rw-r--r--source/blender/blenkernel/intern/mball.cc2
-rw-r--r--source/blender/blenkernel/intern/mesh_fair.cc2
-rw-r--r--source/blender/blenkernel/intern/mesh_mapping.cc4
-rw-r--r--source/blender/blenkernel/intern/multires.cc17
-rw-r--r--source/blender/blenkernel/intern/nla.c3
-rw-r--r--source/blender/blenkernel/intern/object.cc2
-rw-r--r--source/blender/blenkernel/intern/object_dupli.cc4
-rw-r--r--source/blender/blenkernel/intern/ocean.c27
-rw-r--r--source/blender/blenkernel/intern/paint.cc1
-rw-r--r--source/blender/blenkernel/intern/particle.c7
-rw-r--r--source/blender/blenkernel/intern/particle_distribute.c2
-rw-r--r--source/blender/blenkernel/intern/particle_system.c8
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c2
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.cc (renamed from source/blender/blenkernel/intern/shrinkwrap.c)224
-rw-r--r--source/blender/blenkernel/intern/studiolight.c6
-rw-r--r--source/blender/blenkernel/intern/subdiv_ccg.cc (renamed from source/blender/blenkernel/intern/subdiv_ccg.c)274
-rw-r--r--source/blender/blenkernel/intern/subdiv_modifier.cc (renamed from source/blender/blenkernel/intern/subdiv_modifier.c)14
-rw-r--r--source/blender/blenkernel/intern/tracking.c4
-rw-r--r--source/blender/blenkernel/intern/vfont.c4
-rw-r--r--source/blender/blenkernel/intern/vfontdata_freetype.c122
47 files changed, 432 insertions, 443 deletions
diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h
index 350c4c4bb36..da8431d4f27 100644
--- a/source/blender/blenkernel/BKE_mesh_mapping.h
+++ b/source/blender/blenkernel/BKE_mesh_mapping.h
@@ -338,14 +338,14 @@ int *BKE_mesh_calc_smoothgroups(const struct MEdge *medge,
#ifdef __cplusplus
namespace blender::mesh_topology {
-Array<int> build_corner_to_poly_map(Span<MPoly> polys, int loops_num);
+Array<int> build_loop_to_poly_map(Span<MPoly> polys, int loops_num);
Array<Vector<int>> build_vert_to_edge_map(Span<MEdge> edges, int verts_num);
-Array<Vector<int>> build_vert_to_corner_map(Span<MLoop> loops, int verts_num);
+Array<Vector<int>> build_vert_to_loop_map(Span<MLoop> loops, int verts_num);
-inline int previous_poly_corner(const MPoly &poly, int corner_i)
+inline int previous_poly_loop(const MPoly &poly, int loop_i)
{
- return corner_i - 1 + (corner_i == poly.loopstart) * poly.totloop;
+ return loop_i - 1 + (loop_i == poly.loopstart) * poly.totloop;
}
} // namespace blender::mesh_topology
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 192acbf8338..97bdff217d0 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -259,14 +259,14 @@ set(SRC
intern/scene.cc
intern/screen.c
intern/shader_fx.c
- intern/shrinkwrap.c
+ intern/shrinkwrap.cc
intern/simulation.cc
intern/softbody.c
intern/sound.c
intern/speaker.c
intern/studiolight.c
intern/subdiv.c
- intern/subdiv_ccg.c
+ intern/subdiv_ccg.cc
intern/subdiv_ccg_mask.c
intern/subdiv_ccg_material.c
intern/subdiv_converter.c
@@ -277,7 +277,7 @@ set(SRC
intern/subdiv_eval.c
intern/subdiv_foreach.c
intern/subdiv_mesh.cc
- intern/subdiv_modifier.c
+ intern/subdiv_modifier.cc
intern/subdiv_stats.c
intern/subdiv_topology.c
intern/subsurf_ccg.c
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 85ce647fcab..928626ecc7b 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -3198,7 +3198,7 @@ static void animsys_create_action_track_strip(const AnimData *adt,
* (which making new strips doesn't do due to the troublesome nature of that). */
calc_action_range(r_action_strip->act, &r_action_strip->actstart, &r_action_strip->actend, 1);
r_action_strip->start = r_action_strip->actstart;
- r_action_strip->end = (IS_EQF(r_action_strip->actstart, r_action_strip->actend)) ?
+ r_action_strip->end = IS_EQF(r_action_strip->actstart, r_action_strip->actend) ?
(r_action_strip->actstart + 1.0f) :
(r_action_strip->actend);
diff --git a/source/blender/blenkernel/intern/armature_deform.c b/source/blender/blenkernel/intern/armature_deform.c
index 4acbcbfb13e..89afb886fc2 100644
--- a/source/blender/blenkernel/intern/armature_deform.c
+++ b/source/blender/blenkernel/intern/armature_deform.c
@@ -301,12 +301,22 @@ static void armature_vert_task_with_dvert(const ArmatureUserdata *data,
}
/* check if there's any point in calculating for this vert */
- if (armature_weight == 0.0f) {
- return;
+ if (vert_coords_prev) {
+ if (prevco_weight == 1.0f) {
+ return;
+ }
+
+ /* get the coord we work on */
+ co = vert_coords_prev[i];
}
+ else {
+ if (armature_weight == 0.0f) {
+ return;
+ }
- /* get the coord we work on */
- co = vert_coords_prev ? vert_coords_prev[i] : vert_coords[i];
+ /* get the coord we work on */
+ co = vert_coords[i];
+ }
/* Apply the object's matrix */
mul_m4_v3(data->premat, co);
diff --git a/source/blender/blenkernel/intern/blender_user_menu.c b/source/blender/blenkernel/intern/blender_user_menu.c
index 86dd31576dd..9db8df52487 100644
--- a/source/blender/blenkernel/intern/blender_user_menu.c
+++ b/source/blender/blenkernel/intern/blender_user_menu.c
@@ -25,7 +25,7 @@
bUserMenu *BKE_blender_user_menu_find(ListBase *lb, char space_type, const char *context)
{
LISTBASE_FOREACH (bUserMenu *, um, lb) {
- if ((space_type == um->space_type) && (STREQ(context, um->context))) {
+ if ((space_type == um->space_type) && STREQ(context, um->context)) {
return um;
}
}
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index e404c982d55..8608ce97397 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -713,10 +713,8 @@ static bool camera_frame_fit_calc_from_data(CameraParams *params,
plane_from_point_normal_v3(plane_tx[i], co, data->plane_tx[i]);
}
- if ((!isect_plane_plane_v3(
- plane_tx[Y_MIN], plane_tx[Y_MAX], plane_isect_1, plane_isect_1_no)) ||
- (!isect_plane_plane_v3(
- plane_tx[Z_MIN], plane_tx[Z_MAX], plane_isect_2, plane_isect_2_no))) {
+ if (!isect_plane_plane_v3(plane_tx[Y_MIN], plane_tx[Y_MAX], plane_isect_1, plane_isect_1_no) ||
+ !isect_plane_plane_v3(plane_tx[Z_MIN], plane_tx[Z_MAX], plane_isect_2, plane_isect_2_no)) {
return false;
}
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 1f97f8a848c..41993764c0c 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -198,7 +198,7 @@ static DerivedMesh *cdDM_from_mesh_ex(Mesh *mesh,
DM_TYPE_CDDM,
mesh->totvert,
mesh->totedge,
- 0 /* mesh->totface */,
+ 0 /* `mesh->totface` */,
mesh->totloop,
mesh->totpoly);
@@ -213,7 +213,7 @@ static DerivedMesh *cdDM_from_mesh_ex(Mesh *mesh,
&dm->faceData,
cddata_masks.fmask | CD_MASK_ORIGINDEX,
alloctype,
- 0 /* mesh->totface */);
+ 0 /* `mesh->totface` */);
CustomData_merge(&mesh->ldata, &dm->loopData, cddata_masks.lmask, alloctype, mesh->totloop);
CustomData_merge(&mesh->pdata, &dm->polyData, cddata_masks.pmask, alloctype, mesh->totpoly);
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 08c36177600..56de583e2db 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -1130,7 +1130,7 @@ static void cloth_update_springs(ClothModifierData *clmd)
* because implicit solver would need reset! */
/* Activate / Deactivate existing springs */
- if ((!(cloth->verts[spring->ij].flags & CLOTH_VERT_FLAG_PINNED)) &&
+ if (!(cloth->verts[spring->ij].flags & CLOTH_VERT_FLAG_PINNED) &&
(cloth->verts[spring->ij].goal > ALMOST_ZERO)) {
spring->flags &= ~CLOTH_SPRING_FLAG_DEACTIVATE;
}
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 82b358b77a1..751b5185e39 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -946,7 +946,7 @@ bool BKE_collection_has_object(Collection *collection, const Object *ob)
return false;
}
- return (BLI_findptr(&collection->gobject, ob, offsetof(CollectionObject, ob)));
+ return BLI_findptr(&collection->gobject, ob, offsetof(CollectionObject, ob));
}
bool BKE_collection_has_object_recursive(Collection *collection, Object *ob)
@@ -956,7 +956,7 @@ bool BKE_collection_has_object_recursive(Collection *collection, Object *ob)
}
const ListBase objects = BKE_collection_object_cache_get(collection);
- return (BLI_findptr(&objects, ob, offsetof(Base, object)));
+ return BLI_findptr(&objects, ob, offsetof(Base, object));
}
bool BKE_collection_has_object_recursive_instanced(Collection *collection, Object *ob)
@@ -966,7 +966,7 @@ bool BKE_collection_has_object_recursive_instanced(Collection *collection, Objec
}
const ListBase objects = BKE_collection_object_cache_instanced_get(collection);
- return (BLI_findptr(&objects, ob, offsetof(Base, object)));
+ return BLI_findptr(&objects, ob, offsetof(Base, object));
}
static Collection *collection_next_find(Main *bmain, Scene *scene, Collection *collection)
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index cc379ebb561..837eb892056 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -1629,7 +1629,7 @@ void BKE_scopes_update(Scopes *scopes,
}
/* hmmmm */
- if (!(ELEM(ibuf->channels, 3, 4))) {
+ if (!ELEM(ibuf->channels, 3, 4)) {
return;
}
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index ceb84d213c3..d7bd0038d3c 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -634,7 +634,7 @@ ListBase CTX_data_dir_get(const bContext *C)
bool CTX_data_equals(const char *member, const char *str)
{
- return (STREQ(member, str));
+ return STREQ(member, str);
}
bool CTX_data_dir(const char *member)
diff --git a/source/blender/blenkernel/intern/cryptomatte.cc b/source/blender/blenkernel/intern/cryptomatte.cc
index 5ba56946d8d..7c2e45d2f84 100644
--- a/source/blender/blenkernel/intern/cryptomatte.cc
+++ b/source/blender/blenkernel/intern/cryptomatte.cc
@@ -464,7 +464,7 @@ static std::string to_manifest(const CryptomatteLayer *layer)
else {
manifest << ",";
}
- manifest << quoted(item.key) << ":\"" << (item.value.hex_encoded()) << "\"";
+ manifest << quoted(item.key) << ":\"" << item.value.hex_encoded() << "\"";
}
manifest << "}";
return manifest.str();
diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc
index 86db46e6161..28961461819 100644
--- a/source/blender/blenkernel/intern/curve.cc
+++ b/source/blender/blenkernel/intern/curve.cc
@@ -1935,7 +1935,7 @@ static void calc_bevel_sin_cos(
t02 = M_PI_2;
}
else {
- t02 = (saacos(t02)) / 2.0f;
+ t02 = saacos(t02) / 2.0f;
}
t02 = sinf(t02);
@@ -4085,12 +4085,12 @@ void BKE_nurb_bezt_handle_test(BezTriple *bezt,
}
if (bezt->h1 == HD_VECT) {
- if ((!(flag & SEL_F1)) != (!(flag & SEL_F2))) {
+ if (!(flag & SEL_F1) != !(flag & SEL_F2)) {
bezt->h1 = HD_FREE;
}
}
if (bezt->h2 == HD_VECT) {
- if ((!(flag & SEL_F3)) != (!(flag & SEL_F2))) {
+ if (!(flag & SEL_F3) != !(flag & SEL_F2)) {
bezt->h2 = HD_FREE;
}
}
@@ -5101,7 +5101,7 @@ bool BKE_curve_minmax(Curve *cu, bool use_radius, float min[3], float max[3])
{
ListBase *nurb_lb = BKE_curve_nurbs_get(cu);
ListBase temp_nurb_lb = {nullptr, nullptr};
- const bool is_font = (BLI_listbase_is_empty(nurb_lb)) && (cu->len != 0);
+ const bool is_font = BLI_listbase_is_empty(nurb_lb) && (cu->len != 0);
/* For font curves we generate temp list of splines.
*
* This is likely to be fine, this function is not supposed to be called
diff --git a/source/blender/blenkernel/intern/curve_deform.c b/source/blender/blenkernel/intern/curve_deform.c
index fb082fccc0b..9a27ba91c2f 100644
--- a/source/blender/blenkernel/intern/curve_deform.c
+++ b/source/blender/blenkernel/intern/curve_deform.c
@@ -160,7 +160,7 @@ static bool calc_curve_deform(
/* Zero the axis which is not used,
* the big block of text above now applies to these 3 lines.
* The `upflag` argument may be a dummy, set so no rotation is done. */
- quat_apply_track(quat, axis, (ELEM(axis, 0, 2)) ? 1 : 0);
+ quat_apply_track(quat, axis, ELEM(axis, 0, 2) ? 1 : 0);
vec_apply_track(cent, axis);
cent[index] = 0.0f;
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 03358f50d40..e177250ae5a 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -121,7 +121,7 @@ BLI_INLINE void value_dissolve(float *r_value,
const float scale,
const bool is_log)
{
- *r_value = (is_log) ? (*r_value) * (powf(MIN_WETNESS, 1.0f / (1.2f * time / scale))) :
+ *r_value = (is_log) ? (*r_value) * powf(MIN_WETNESS, 1.0f / (1.2f * time / scale)) :
(*r_value) - 1.0f / time * scale;
}
diff --git a/source/blender/blenkernel/intern/editmesh.cc b/source/blender/blenkernel/intern/editmesh.cc
index fb4cfad0fb9..3a1dcd59f55 100644
--- a/source/blender/blenkernel/intern/editmesh.cc
+++ b/source/blender/blenkernel/intern/editmesh.cc
@@ -193,7 +193,7 @@ static void cage_mapped_verts_callback(void *userData,
{
CageUserData *data = static_cast<CageUserData *>(userData);
- if ((index >= 0 && index < data->totvert) && (!BLI_BITMAP_TEST(data->visit_bitmap, index))) {
+ if ((index >= 0 && index < data->totvert) && !BLI_BITMAP_TEST(data->visit_bitmap, index)) {
BLI_BITMAP_ENABLE(data->visit_bitmap, index);
copy_v3_v3(data->cos_cage[index], co);
}
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 6719590e7c0..42b38854248 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -79,7 +79,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;
diff --git a/source/blender/blenkernel/intern/fcurve_driver.c b/source/blender/blenkernel/intern/fcurve_driver.c
index aa33bef998f..9f63e2d3743 100644
--- a/source/blender/blenkernel/intern/fcurve_driver.c
+++ b/source/blender/blenkernel/intern/fcurve_driver.c
@@ -333,7 +333,7 @@ static float dvar_eval_rotDiff(ChannelDriver *driver, DriverVar *dvar)
invert_qt_normalized(q1);
mul_qt_qtqt(quat, q1, q2);
- angle = 2.0f * (saacos(quat[0]));
+ angle = 2.0f * saacos(quat[0]);
angle = fabsf(angle);
return (angle > (float)M_PI) ? (float)((2.0f * (float)M_PI) - angle) : (float)(angle);
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index 349614b93dd..0a39207184a 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -2204,9 +2204,9 @@ static void adaptive_domain_adjust(
/* add to total shift */
add_v3_v3(fds->shift_f, frame_shift_f);
/* convert to integer */
- total_shift[0] = (int)(floorf(fds->shift_f[0]));
- total_shift[1] = (int)(floorf(fds->shift_f[1]));
- total_shift[2] = (int)(floorf(fds->shift_f[2]));
+ total_shift[0] = (int)floorf(fds->shift_f[0]);
+ total_shift[1] = (int)floorf(fds->shift_f[1]);
+ total_shift[2] = (int)floorf(fds->shift_f[2]);
int temp_shift[3];
copy_v3_v3_int(temp_shift, fds->shift);
sub_v3_v3v3_int(new_shift, total_shift, fds->shift);
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index bfffd44e73d..45e56717d6a 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -83,8 +83,8 @@ static void greasepencil_copy_data(Main *UNUSED(bmain),
/* Apply local layer transform to all frames. Calc the active frame is not enough
* because onion skin can use more frames. This is more slow but required here. */
if (gpl_dst->actframe != NULL) {
- bool transformed = ((!is_zero_v3(gpl_dst->location)) || (!is_zero_v3(gpl_dst->rotation)) ||
- (!is_one_v3(gpl_dst->scale)));
+ bool transformed = (!is_zero_v3(gpl_dst->location) || !is_zero_v3(gpl_dst->rotation) ||
+ !is_one_v3(gpl_dst->scale));
if (transformed) {
loc_eul_size_to_mat4(
gpl_dst->layer_mat, gpl_dst->location, gpl_dst->rotation, gpl_dst->scale);
@@ -2013,7 +2013,7 @@ bool BKE_gpencil_merge_materials_table_get(Object *ob,
/* Read secondary material to compare with primary material. */
ma_secondary = BKE_gpencil_material(ob, idx_secondary + 1);
if ((ma_secondary == NULL) ||
- (BLI_ghash_haskey(r_mat_table, POINTER_FROM_INT(idx_secondary)))) {
+ BLI_ghash_haskey(r_mat_table, POINTER_FROM_INT(idx_secondary))) {
continue;
}
gp_style_primary = ma_primary->gp_style;
@@ -2063,17 +2063,17 @@ bool BKE_gpencil_merge_materials_table_get(Object *ob,
rgb_to_hsv_compat_v(col, f_hsv_b);
/* Check stroke and fill color. */
- if ((!compare_ff(s_hsv_a[0], s_hsv_b[0], hue_threshold)) ||
- (!compare_ff(s_hsv_a[1], s_hsv_b[1], sat_threshold)) ||
- (!compare_ff(s_hsv_a[2], s_hsv_b[2], val_threshold)) ||
- (!compare_ff(f_hsv_a[0], f_hsv_b[0], hue_threshold)) ||
- (!compare_ff(f_hsv_a[1], f_hsv_b[1], sat_threshold)) ||
- (!compare_ff(f_hsv_a[2], f_hsv_b[2], val_threshold)) ||
- (!compare_ff(gp_style_primary->stroke_rgba[3],
- gp_style_secondary->stroke_rgba[3],
- val_threshold)) ||
- (!compare_ff(
- gp_style_primary->fill_rgba[3], gp_style_secondary->fill_rgba[3], val_threshold))) {
+ if (!compare_ff(s_hsv_a[0], s_hsv_b[0], hue_threshold) ||
+ !compare_ff(s_hsv_a[1], s_hsv_b[1], sat_threshold) ||
+ !compare_ff(s_hsv_a[2], s_hsv_b[2], val_threshold) ||
+ !compare_ff(f_hsv_a[0], f_hsv_b[0], hue_threshold) ||
+ !compare_ff(f_hsv_a[1], f_hsv_b[1], sat_threshold) ||
+ !compare_ff(f_hsv_a[2], f_hsv_b[2], val_threshold) ||
+ !compare_ff(gp_style_primary->stroke_rgba[3],
+ gp_style_secondary->stroke_rgba[3],
+ val_threshold) ||
+ !compare_ff(
+ gp_style_primary->fill_rgba[3], gp_style_secondary->fill_rgba[3], val_threshold)) {
continue;
}
@@ -2337,7 +2337,7 @@ bool BKE_gpencil_from_image(
static bool gpencil_is_layer_mask(ViewLayer *view_layer, bGPdata *gpd, bGPDlayer *gpl_mask)
{
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
- if ((gpl->viewlayername[0] != '\0') && (!STREQ(view_layer->name, gpl->viewlayername))) {
+ if ((gpl->viewlayername[0] != '\0') && !STREQ(view_layer->name, gpl->viewlayername)) {
continue;
}
@@ -2412,7 +2412,7 @@ void BKE_gpencil_visible_stroke_advanced_iter(ViewLayer *view_layer,
int cfra)
{
bGPdata *gpd = (bGPdata *)ob->data;
- const bool is_multiedit = (GPENCIL_MULTIEDIT_SESSIONS_ON(gpd) && (!GPENCIL_PLAY_ON(gpd)));
+ const bool is_multiedit = (GPENCIL_MULTIEDIT_SESSIONS_ON(gpd) && !GPENCIL_PLAY_ON(gpd));
const bool is_onion = do_onion && ((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0);
const bool is_drawing = (gpd->runtime.sbuffer_used > 0);
@@ -2444,7 +2444,7 @@ void BKE_gpencil_visible_stroke_advanced_iter(ViewLayer *view_layer,
* generate renders, putting only selected GP layers for each View Layer.
* This is used only in final render and never in Viewport. */
if ((view_layer != NULL) && (gpl->viewlayername[0] != '\0') &&
- (!STREQ(view_layer->name, gpl->viewlayername))) {
+ !STREQ(view_layer->name, gpl->viewlayername)) {
/* Do not skip masks when rendering the view-layer so that it can still be used to clip
* other layers. Instead set their opacity to zero. */
if (gpencil_is_layer_mask(view_layer, gpd, gpl)) {
@@ -2786,8 +2786,8 @@ void BKE_gpencil_update_layer_transforms(const Depsgraph *depsgraph, Object *ob)
}
/* Calc local layer transform. Early out if we have non-animated zero transforms. */
- bool transformed = ((!is_zero_v3(gpl->location)) || (!is_zero_v3(gpl->rotation)) ||
- (!is_one_v3(gpl->scale)));
+ bool transformed = (!is_zero_v3(gpl->location) || !is_zero_v3(gpl->rotation) ||
+ !is_one_v3(gpl->scale));
float tmp_mat[4][4];
loc_eul_size_to_mat4(tmp_mat, gpl->location, gpl->rotation, gpl->scale);
transformed |= !equals_m4m4(gpl->layer_mat, tmp_mat);
@@ -2834,7 +2834,7 @@ int BKE_gpencil_material_find_index_by_name_prefix(Object *ob, const char *name_
for (int i = 0; i < ob->totcol; i++) {
Material *ma = BKE_object_material_get(ob, i + 1);
if ((ma != NULL) && (ma->gp_style != NULL) &&
- (STREQLEN(ma->id.name + 2, name_prefix, name_prefix_len))) {
+ STREQLEN(ma->id.name + 2, name_prefix, name_prefix_len)) {
return i;
}
}
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index 191231f2b43..c84ee2e4a56 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -722,8 +722,8 @@ void BKE_gpencil_prepare_eval_data(Depsgraph *depsgraph, Scene *scene, Object *o
}
/* Only do layer transformations for non-zero or animated transforms. */
- bool transformed = ((!is_zero_v3(gpl->location)) || (!is_zero_v3(gpl->rotation)) ||
- (!is_one_v3(gpl->scale)));
+ bool transformed = (!is_zero_v3(gpl->location) || !is_zero_v3(gpl->rotation) ||
+ !is_one_v3(gpl->scale));
float tmp_mat[4][4];
loc_eul_size_to_mat4(tmp_mat, gpl->location, gpl->rotation, gpl->scale);
transformed |= !equals_m4m4(gpl->layer_mat, tmp_mat);
@@ -752,7 +752,7 @@ void BKE_gpencil_prepare_eval_data(Depsgraph *depsgraph, Scene *scene, Object *o
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 != NULL) &&
- (!GPENCIL_SIMPLIFY_MODIF(scene)));
+ !GPENCIL_SIMPLIFY_MODIF(scene));
if ((!do_modifiers) && (!do_parent) && (!do_transform)) {
BLI_assert(ob->data != NULL);
return;
@@ -782,7 +782,7 @@ void BKE_gpencil_modifiers_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
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 != NULL) &&
- (!GPENCIL_SIMPLIFY_MODIF(scene)));
+ !GPENCIL_SIMPLIFY_MODIF(scene));
if (!do_modifiers) {
return;
}
diff --git a/source/blender/blenkernel/intern/image_format.cc b/source/blender/blenkernel/intern/image_format.cc
index 8bff6c376b3..8d1aeac76fb 100644
--- a/source/blender/blenkernel/intern/image_format.cc
+++ b/source/blender/blenkernel/intern/image_format.cc
@@ -520,7 +520,7 @@ static bool do_add_image_extension(char *string,
}
#endif
else { // R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90 etc
- if (!(BLI_path_extension_check_n(string, extension_test = ".jpg", ".jpeg", nullptr))) {
+ if (!BLI_path_extension_check_n(string, extension_test = ".jpg", ".jpeg", nullptr)) {
extension = extension_test;
}
}
diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc
index f145f5db624..e227f9cba5e 100644
--- a/source/blender/blenkernel/intern/image_save.cc
+++ b/source/blender/blenkernel/intern/image_save.cc
@@ -824,7 +824,7 @@ bool BKE_image_render_write_exr(ReportList *reports,
/* We only store RGBA passes as half float, for
* others precision loss can be problematic. */
- const bool pass_RGBA = (STR_ELEM(rp->chan_id, "RGB", "RGBA", "R", "G", "B", "A"));
+ const bool pass_RGBA = STR_ELEM(rp->chan_id, "RGB", "RGBA", "R", "G", "B", "A");
const bool pass_half_float = half_float && pass_RGBA;
/* Color-space conversion only happens on RGBA passes. */
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 6a8edde9c49..bd655caae2b 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -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 {
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index fe11dc99bac..fcb0adfde34 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -988,7 +988,7 @@ void BKE_main_view_layers_synced_ensure(const Main *bmain)
BKE_scene_view_layers_synced_ensure(scene);
}
- /* NOTE: This is not (yet?) covered by the dirty tag and deffered resync system */
+ /* NOTE: This is not (yet?) covered by the dirty tag and differed re-sync system */
BKE_layer_collection_local_sync_all(bmain);
}
diff --git a/source/blender/blenkernel/intern/lib_override.cc b/source/blender/blenkernel/intern/lib_override.cc
index 04679b72b2d..07eb4741b1f 100644
--- a/source/blender/blenkernel/intern/lib_override.cc
+++ b/source/blender/blenkernel/intern/lib_override.cc
@@ -1389,7 +1389,7 @@ bool BKE_lib_override_library_create(Main *bmain,
id_hierarchy_root_reference = id_root_reference;
}
- /* While in theory it _should_ be enough to ensure sync of given viewlayer (if any), or at least
+ /* While in theory it _should_ be enough to ensure sync of given view-layer (if any), or at least
* of given scene, think for now it's better to get a fully synced Main at this point, this code
* may do some very wide remapping/data access in some cases. */
BKE_main_view_layers_synced_ensure(bmain);
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index b9ea3eaba69..55834d5cf4e 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -1282,8 +1282,8 @@ BLI_INLINE uint layer_bucket_index_from_xy(MaskRasterLayer *layer, const float x
{
BLI_assert(BLI_rctf_isect_pt_v(&layer->bounds, xy));
- return ((uint)((xy[0] - layer->bounds.xmin) * layer->buckets_xy_scalar[0])) +
- (((uint)((xy[1] - layer->bounds.ymin) * layer->buckets_xy_scalar[1])) * layer->buckets_x);
+ return (uint)((xy[0] - layer->bounds.xmin) * layer->buckets_xy_scalar[0]) +
+ ((uint)((xy[1] - layer->bounds.ymin) * layer->buckets_xy_scalar[1]) * layer->buckets_x);
}
static float layer_bucket_depth_from_xy(MaskRasterLayer *layer, const float xy[2])
diff --git a/source/blender/blenkernel/intern/mball.cc b/source/blender/blenkernel/intern/mball.cc
index d9b08d4fe2d..6b1394f65ab 100644
--- a/source/blender/blenkernel/intern/mball.cc
+++ b/source/blender/blenkernel/intern/mball.cc
@@ -297,7 +297,7 @@ bool BKE_mball_is_basis(const Object *ob)
/* Just a quick test. */
const int len = strlen(ob->id.name);
- return (!isdigit(ob->id.name[len - 1]));
+ return !isdigit(ob->id.name[len - 1]);
}
bool BKE_mball_is_same_group(const Object *ob1, const Object *ob2)
diff --git a/source/blender/blenkernel/intern/mesh_fair.cc b/source/blender/blenkernel/intern/mesh_fair.cc
index 501f01e3368..5369bc782b6 100644
--- a/source/blender/blenkernel/intern/mesh_fair.cc
+++ b/source/blender/blenkernel/intern/mesh_fair.cc
@@ -221,7 +221,7 @@ class MeshFairingContext : public FairingContext {
}
}
- loop_to_poly_map_ = blender::mesh_topology::build_corner_to_poly_map(mpoly_, mloop_.size());
+ loop_to_poly_map_ = blender::mesh_topology::build_loop_to_poly_map(mpoly_, mloop_.size());
}
~MeshFairingContext() override
diff --git a/source/blender/blenkernel/intern/mesh_mapping.cc b/source/blender/blenkernel/intern/mesh_mapping.cc
index bb9f8274b72..667802d5f48 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.cc
+++ b/source/blender/blenkernel/intern/mesh_mapping.cc
@@ -555,7 +555,7 @@ void BKE_mesh_origindex_map_create_looptri(MeshElemMap **r_map,
namespace blender::mesh_topology {
-Array<int> build_corner_to_poly_map(const Span<MPoly> polys, const int loops_num)
+Array<int> build_loop_to_poly_map(const Span<MPoly> polys, const int loops_num)
{
Array<int> map(loops_num);
threading::parallel_for(polys.index_range(), 1024, [&](IndexRange range) {
@@ -577,7 +577,7 @@ Array<Vector<int>> build_vert_to_edge_map(const Span<MEdge> edges, const int ver
return map;
}
-Array<Vector<int>> build_vert_to_corner_map(const Span<MLoop> loops, const int verts_num)
+Array<Vector<int>> build_vert_to_loop_map(const Span<MLoop> loops, const int verts_num)
{
Array<Vector<int>> map(verts_num);
for (const int64_t i : loops.index_range()) {
diff --git a/source/blender/blenkernel/intern/multires.cc b/source/blender/blenkernel/intern/multires.cc
index 83189adfcdb..61cfe043927 100644
--- a/source/blender/blenkernel/intern/multires.cc
+++ b/source/blender/blenkernel/intern/multires.cc
@@ -69,8 +69,8 @@ void multires_customdata_delete(Mesh *me)
if (me->edit_mesh) {
BMEditMesh *em = me->edit_mesh;
/* CustomData_external_remove is used here only to mark layer
- * as non-external for further free-ing, so zero element count
- * looks safer than em->totface */
+ * as non-external for further freeing, so zero element count
+ * looks safer than `em->bm->totface`. */
CustomData_external_remove(&em->bm->ldata, &me->id, CD_MDISPS, 0);
if (CustomData_has_layer(&em->bm->ldata, CD_MDISPS)) {
@@ -1359,11 +1359,9 @@ static void multires_sync_levels(Scene *scene, Object *ob_src, Object *ob_dst)
MultiresModifierData *mmd_dst = get_multires_modifier(scene, ob_dst, true);
if (!mmd_src) {
- /* object could have MDISP even when there is no multires modifier
- * this could lead to troubles due to i've got no idea how mdisp could be
- * up-sampled correct without modifier data.
- * just remove mdisps if no multires present (nazgul) */
-
+ /* NOTE(@sergey): object could have MDISP even when there is no multires modifier
+ * this could lead to troubles due to I've got no idea how mdisp could be
+ * up-sampled correct without modifier data. Just remove mdisps if no multires present. */
multires_customdata_delete(static_cast<Mesh *>(ob_src->data));
}
@@ -1404,9 +1402,8 @@ static void multires_apply_smat(struct Depsgraph * /*depsgraph*/,
multires_apply_uniform_scale(object, scale);
}
else {
- /* TODO(sergey): This branch of code actually requires more work to
- * preserve all the details.
- */
+ /* TODO(@sergey): This branch of code actually requires more work to
+ * preserve all the details. */
const float scale = mat3_to_scale(smat);
multires_apply_uniform_scale(object, scale);
}
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index c0315dcc848..fd3580a7e88 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -431,8 +431,7 @@ NlaStrip *BKE_nlastrip_new(bAction *act)
BKE_action_get_frame_range(strip->act, &strip->actstart, &strip->actend);
strip->start = strip->actstart;
- strip->end = (IS_EQF(strip->actstart, strip->actend)) ? (strip->actstart + 1.0f) :
- (strip->actend);
+ strip->end = IS_EQF(strip->actstart, strip->actend) ? (strip->actstart + 1.0f) : strip->actend;
/* strip should be referenced as-is */
strip->scale = 1.0f;
diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc
index 75da9f92f49..9417d1afc7e 100644
--- a/source/blender/blenkernel/intern/object.cc
+++ b/source/blender/blenkernel/intern/object.cc
@@ -3352,7 +3352,7 @@ void BKE_object_get_parent_matrix(Object *ob, Object *par, float r_parentmat[4][
case PAROBJECT: {
bool ok = false;
if (par->type == OB_CURVES_LEGACY) {
- if ((((Curve *)par->data)->flag & CU_PATH) && (ob_parcurve(ob, par, tmat))) {
+ if ((((Curve *)par->data)->flag & CU_PATH) && ob_parcurve(ob, par, tmat)) {
ok = true;
}
}
diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc
index 1b315d29923..a56176b7d9b 100644
--- a/source/blender/blenkernel/intern/object_dupli.cc
+++ b/source/blender/blenkernel/intern/object_dupli.cc
@@ -1840,7 +1840,7 @@ static bool find_rna_property_rgba(PointerRNA *id_ptr, const char *name, float r
value = RNA_property_float_get(&ptr, prop);
}
else if (type == PROP_INT) {
- value = static_cast<float>(RNA_property_int_get(&ptr, prop));
+ value = float(RNA_property_int_get(&ptr, prop));
}
else if (type == PROP_BOOLEAN) {
value = RNA_property_boolean_get(&ptr, prop) ? 1.0f : 0.0f;
@@ -1863,7 +1863,7 @@ static bool find_rna_property_rgba(PointerRNA *id_ptr, const char *name, float r
int tmp[4] = {0, 0, 0, 1};
RNA_property_int_get_array(&ptr, prop, tmp);
for (int i = 0; i < 4; i++) {
- r_data[i] = static_cast<float>(tmp[i]);
+ r_data[i] = float(tmp[i]);
}
return true;
}
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index c142f096395..396c3443a73 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -55,8 +55,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);
@@ -930,40 +930,37 @@ bool BKE_ocean_init(struct 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)));
- 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));
+ 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));
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;
}
}
diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc
index 7b3ad170339..00535ea5528 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -2677,6 +2677,7 @@ SculptAttribute *BKE_sculpt_attribute_get(struct Object *ob,
attr = sculpt_alloc_attr(ss);
attr->used = true;
+ attr->domain = domain;
attr->proptype = proptype;
attr->data = cdata->layers[index].data;
attr->bmesh_cd_offset = cdata->layers[index].offset;
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 3675dea50e3..6d42d344b86 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -2463,7 +2463,7 @@ bool do_guides(Depsgraph *depsgraph,
if (guidetime != 0.0f) {
/* curve direction */
cross_v3_v3v3(temp, eff->guide_dir, guidedir);
- angle = dot_v3v3(eff->guide_dir, guidedir) / (len_v3(eff->guide_dir));
+ angle = dot_v3v3(eff->guide_dir, guidedir) / len_v3(eff->guide_dir);
angle = saacos(angle);
axis_angle_to_quat(rot2, temp, angle);
mul_qt_v3(rot2, vec_to_point);
@@ -2988,8 +2988,7 @@ static void psys_thread_create_path(ParticleTask *task,
* pa->num, pa->fuv,
* NULL);
*/
- cpa_num = (ELEM(pa->num_dmcache, DMCACHE_ISCHILD, DMCACHE_NOTFOUND)) ? pa->num :
- pa->num_dmcache;
+ cpa_num = ELEM(pa->num_dmcache, DMCACHE_ISCHILD, DMCACHE_NOTFOUND) ? pa->num : pa->num_dmcache;
/* XXX hack to avoid messed up particle num and subsequent crash (T40733) */
if (cpa_num > ctx->sim.psmd->mesh_final->totface) {
@@ -3850,7 +3849,7 @@ static void psys_face_mat(Object *ob, Mesh *mesh, ParticleData *pa, float mat[4]
MFace *mface;
const float(*orcodata)[3];
- int i = (ELEM(pa->num_dmcache, DMCACHE_ISCHILD, DMCACHE_NOTFOUND)) ? pa->num : pa->num_dmcache;
+ int i = ELEM(pa->num_dmcache, DMCACHE_ISCHILD, DMCACHE_NOTFOUND) ? pa->num : pa->num_dmcache;
if (i == -1 || i >= mesh->totface) {
unit_m4(mat);
return;
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index ce9fec6043d..4c56a8a9275 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -1093,7 +1093,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;
}
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 9608676a153..dec874caff4 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -603,7 +603,7 @@ static void initialize_all_particles(ParticleSimulationData *sim)
* UNEXIST flag.
*/
const bool emit_from_volume_grid = (part->distr == PART_DISTR_GRID) &&
- (!ELEM(part->from, PART_FROM_VERT, PART_FROM_CHILD));
+ !ELEM(part->from, PART_FROM_VERT, PART_FROM_CHILD);
PARTICLE_P;
LOOP_PARTICLES
{
@@ -4150,17 +4150,17 @@ static bool particles_has_tracer(short parttype)
static bool particles_has_spray(short parttype)
{
- return (ELEM(parttype, PART_FLUID_SPRAY, PART_FLUID_SPRAYFOAM, PART_FLUID_SPRAYFOAMBUBBLE));
+ return ELEM(parttype, PART_FLUID_SPRAY, PART_FLUID_SPRAYFOAM, PART_FLUID_SPRAYFOAMBUBBLE);
}
static bool particles_has_bubble(short parttype)
{
- return (ELEM(parttype, PART_FLUID_BUBBLE, PART_FLUID_FOAMBUBBLE, PART_FLUID_SPRAYFOAMBUBBLE));
+ return ELEM(parttype, PART_FLUID_BUBBLE, PART_FLUID_FOAMBUBBLE, PART_FLUID_SPRAYFOAMBUBBLE);
}
static bool particles_has_foam(short parttype)
{
- return (ELEM(parttype, PART_FLUID_FOAM, PART_FLUID_SPRAYFOAM, PART_FLUID_SPRAYFOAMBUBBLE));
+ return ELEM(parttype, PART_FLUID_FOAM, PART_FLUID_SPRAYFOAM, PART_FLUID_SPRAYFOAMBUBBLE);
}
static void particles_fluid_step(ParticleSimulationData *sim,
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index de908adac79..516e1fb4639 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -1884,7 +1884,7 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
pbvh->bm_log = log;
/* TODO: choose leaf limit better */
- pbvh->leaf_limit = 100;
+ pbvh->leaf_limit = 400;
BKE_pbvh_update_bmesh_offsets(pbvh, cd_vert_node_offset, cd_face_node_offset);
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.cc
index f94836551bb..703b012d170 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.cc
@@ -5,12 +5,12 @@
* \ingroup bke
*/
-#include <float.h>
-#include <math.h>
+#include <cfloat>
+#include <cmath>
+#include <cstdio>
+#include <cstring>
+#include <ctime>
#include <memory.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
#include "DNA_gpencil_modifier_types.h"
#include "DNA_mesh_types.h"
@@ -54,30 +54,31 @@
/* Util macros */
#define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n"))
-typedef struct ShrinkwrapCalcData {
+struct ShrinkwrapCalcData {
ShrinkwrapModifierData *smd; /* shrinkwrap modifier data */
- struct Object *ob; /* object we are applying shrinkwrap to */
+ Object *ob; /* object we are applying shrinkwrap to */
- struct MVert *vert; /* Array of verts being projected. */
+ MVert *vert; /* Array of verts being projected. */
const float (*vert_normals)[3];
- float (*vertexCos)[3]; /* vertexs being shrinkwraped */
+ /* Vertices being shrink-wrapped. */
+ float (*vertexCos)[3];
int numVerts;
- const struct MDeformVert *dvert; /* Pointer to mdeform array */
- int vgroup; /* Vertex group num */
- bool invert_vgroup; /* invert vertex group influence */
+ const MDeformVert *dvert; /* Pointer to mdeform array */
+ int vgroup; /* Vertex group num */
+ bool invert_vgroup; /* invert vertex group influence */
- struct Mesh *target; /* mesh we are shrinking to */
- struct SpaceTransform local2target; /* transform to move between local and target space */
- struct ShrinkwrapTreeData *tree; /* mesh BVH tree data */
+ Mesh *target; /* mesh we are shrinking to */
+ SpaceTransform local2target; /* transform to move between local and target space */
+ ShrinkwrapTreeData *tree; /* mesh BVH tree data */
- struct Object *aux_target;
+ Object *aux_target;
float keepDist; /* Distance to keep above target surface (units are in local space) */
-} ShrinkwrapCalcData;
+};
-typedef struct ShrinkwrapCalcCBData {
+struct ShrinkwrapCalcCBData {
ShrinkwrapCalcData *calc;
ShrinkwrapTreeData *tree;
@@ -85,7 +86,7 @@ typedef struct ShrinkwrapCalcCBData {
float *proj_axis;
SpaceTransform *local2aux;
-} ShrinkwrapCalcCBData;
+};
bool BKE_shrinkwrap_needs_normals(int shrinkType, int shrinkMode)
{
@@ -99,7 +100,7 @@ bool BKE_shrinkwrap_init_tree(
{
memset(data, 0, sizeof(*data));
- if (mesh == NULL) {
+ if (mesh == nullptr) {
return false;
}
@@ -118,7 +119,7 @@ bool BKE_shrinkwrap_init_tree(
if (shrinkType == MOD_SHRINKWRAP_NEAREST_VERTEX) {
data->bvh = BKE_bvhtree_from_mesh_get(&data->treeData, mesh, BVHTREE_FROM_VERTS, 2);
- return data->bvh != NULL;
+ return data->bvh != nullptr;
}
if (mesh->totpoly <= 0) {
@@ -127,14 +128,14 @@ bool BKE_shrinkwrap_init_tree(
data->bvh = BKE_bvhtree_from_mesh_get(&data->treeData, mesh, BVHTREE_FROM_LOOPTRI, 4);
- if (data->bvh == NULL) {
+ if (data->bvh == nullptr) {
return false;
}
if (force_normals || BKE_shrinkwrap_needs_normals(shrinkType, shrinkMode)) {
data->pnors = BKE_mesh_poly_normals_ensure(mesh);
if ((mesh->flag & ME_AUTOSMOOTH) != 0) {
- data->clnors = CustomData_get_layer(&mesh->ldata, CD_NORMAL);
+ data->clnors = static_cast<const float(*)[3]>(CustomData_get_layer(&mesh->ldata, CD_NORMAL));
}
}
@@ -150,11 +151,11 @@ void BKE_shrinkwrap_free_tree(ShrinkwrapTreeData *data)
free_bvhtree_from_mesh(&data->treeData);
}
-void BKE_shrinkwrap_discard_boundary_data(struct Mesh *mesh)
+void BKE_shrinkwrap_discard_boundary_data(Mesh *mesh)
{
- struct ShrinkwrapBoundaryData *data = mesh->runtime.shrinkwrap_data;
+ ShrinkwrapBoundaryData *data = mesh->runtime.shrinkwrap_data;
- if (data != NULL) {
+ if (data != nullptr) {
MEM_freeN((void *)data->edge_is_boundary);
MEM_freeN((void *)data->looptri_has_boundary);
MEM_freeN((void *)data->vert_boundary_id);
@@ -163,7 +164,7 @@ void BKE_shrinkwrap_discard_boundary_data(struct Mesh *mesh)
MEM_freeN(data);
}
- mesh->runtime.shrinkwrap_data = NULL;
+ mesh->runtime.shrinkwrap_data = nullptr;
}
/* Accumulate edge for average boundary edge direction. */
@@ -190,14 +191,15 @@ static void merge_vert_dir(ShrinkwrapBoundaryVertData *vdata,
status[index] = (status[index] == 0) ? side : -1;
}
-static ShrinkwrapBoundaryData *shrinkwrap_build_boundary_data(struct Mesh *mesh)
+static ShrinkwrapBoundaryData *shrinkwrap_build_boundary_data(Mesh *mesh)
{
const MVert *mvert = BKE_mesh_verts(mesh);
const MEdge *medge = BKE_mesh_edges(mesh);
const MLoop *mloop = BKE_mesh_loops(mesh);
/* Count faces per edge (up to 2). */
- char *edge_mode = MEM_calloc_arrayN((size_t)mesh->totedge, sizeof(char), __func__);
+ char *edge_mode = static_cast<char *>(
+ MEM_calloc_arrayN(size_t(mesh->totedge), sizeof(char), __func__));
for (int i = 0; i < mesh->totloop; i++) {
uint eidx = mloop[i].e;
@@ -221,16 +223,15 @@ static ShrinkwrapBoundaryData *shrinkwrap_build_boundary_data(struct Mesh *mesh)
}
}
- /* If no boundary, return NULL. */
+ /* If no boundary, return nullptr. */
if (num_boundary_edges == 0) {
MEM_freeN(edge_is_boundary);
MEM_freeN(edge_mode);
- return NULL;
+ return nullptr;
}
/* Allocate the data object. */
- ShrinkwrapBoundaryData *data = MEM_callocN(sizeof(ShrinkwrapBoundaryData),
- "ShrinkwrapBoundaryData");
+ ShrinkwrapBoundaryData *data = MEM_cnew<ShrinkwrapBoundaryData>(__func__);
data->edge_is_boundary = edge_is_boundary;
@@ -256,8 +257,8 @@ static ShrinkwrapBoundaryData *shrinkwrap_build_boundary_data(struct Mesh *mesh)
data->looptri_has_boundary = looptri_has_boundary;
/* Find boundary vertices and build a mapping table for compact storage of data. */
- int *vert_boundary_id = MEM_calloc_arrayN(
- (size_t)mesh->totvert, sizeof(int), "ShrinkwrapBoundaryData::vert_boundary_id");
+ int *vert_boundary_id = static_cast<int *>(
+ MEM_calloc_arrayN(size_t(mesh->totvert), sizeof(int), __func__));
for (int i = 0; i < mesh->totedge; i++) {
if (edge_mode[i]) {
@@ -271,17 +272,18 @@ static ShrinkwrapBoundaryData *shrinkwrap_build_boundary_data(struct Mesh *mesh)
uint num_boundary_verts = 0;
for (int i = 0; i < mesh->totvert; i++) {
- vert_boundary_id[i] = (vert_boundary_id[i] != 0) ? (int)num_boundary_verts++ : -1;
+ vert_boundary_id[i] = (vert_boundary_id[i] != 0) ? int(num_boundary_verts++) : -1;
}
data->vert_boundary_id = vert_boundary_id;
data->num_boundary_verts = num_boundary_verts;
/* Compute average directions. */
- ShrinkwrapBoundaryVertData *boundary_verts = MEM_calloc_arrayN(
- num_boundary_verts, sizeof(*boundary_verts), "ShrinkwrapBoundaryData::boundary_verts");
+ ShrinkwrapBoundaryVertData *boundary_verts = static_cast<ShrinkwrapBoundaryVertData *>(
+ MEM_calloc_arrayN(num_boundary_verts, sizeof(*boundary_verts), __func__));
- signed char *vert_status = MEM_calloc_arrayN(num_boundary_verts, sizeof(char), __func__);
+ signed char *vert_status = static_cast<signed char *>(
+ MEM_calloc_arrayN(num_boundary_verts, sizeof(char), __func__));
for (int i = 0; i < mesh->totedge; i++) {
if (edge_mode[i]) {
@@ -321,7 +323,7 @@ static ShrinkwrapBoundaryData *shrinkwrap_build_boundary_data(struct Mesh *mesh)
return data;
}
-void BKE_shrinkwrap_compute_boundary_data(struct Mesh *mesh)
+void BKE_shrinkwrap_compute_boundary_data(Mesh *mesh)
{
BKE_shrinkwrap_discard_boundary_data(mesh);
@@ -331,18 +333,18 @@ void BKE_shrinkwrap_compute_boundary_data(struct Mesh *mesh)
/**
* Shrink-wrap to the nearest vertex
*
- * it builds a #BVHTree of vertices we can attach to and then
- * for each vertex performs a nearest vertex search on the tree
+ * it builds a BVH-tree of vertices we can attach to and then
+ * for each vertex performs a nearest vertex search on the tree.
*/
static void shrinkwrap_calc_nearest_vertex_cb_ex(void *__restrict userdata,
const int i,
const TaskParallelTLS *__restrict tls)
{
- ShrinkwrapCalcCBData *data = userdata;
+ ShrinkwrapCalcCBData *data = static_cast<ShrinkwrapCalcCBData *>(userdata);
ShrinkwrapCalcData *calc = data->calc;
BVHTreeFromMesh *treeData = &data->tree->treeData;
- BVHTreeNearest *nearest = tls->userdata_chunk;
+ BVHTreeNearest *nearest = static_cast<BVHTreeNearest *>(tls->userdata_chunk);
float *co = calc->vertexCos[i];
float tmp_co[3];
@@ -404,10 +406,9 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
nearest.index = -1;
nearest.dist_sq = FLT_MAX;
- ShrinkwrapCalcCBData data = {
- .calc = calc,
- .tree = calc->tree,
- };
+ ShrinkwrapCalcCBData data{};
+ data.calc = calc;
+ data.tree = calc->tree;
TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (calc->numVerts > BKE_MESH_OMP_LIMIT);
@@ -496,7 +497,7 @@ static void shrinkwrap_calc_normal_projection_cb_ex(void *__restrict userdata,
const int i,
const TaskParallelTLS *__restrict tls)
{
- ShrinkwrapCalcCBData *data = userdata;
+ ShrinkwrapCalcCBData *data = static_cast<ShrinkwrapCalcCBData *>(userdata);
ShrinkwrapCalcData *calc = data->calc;
ShrinkwrapTreeData *tree = data->tree;
@@ -505,7 +506,7 @@ static void shrinkwrap_calc_normal_projection_cb_ex(void *__restrict userdata,
float *proj_axis = data->proj_axis;
SpaceTransform *local2aux = data->local2aux;
- BVHTreeRayHit *hit = tls->userdata_chunk;
+ BVHTreeRayHit *hit = static_cast<BVHTreeRayHit *>(tls->userdata_chunk);
const float proj_limit_squared = calc->smd->projLimit * calc->smd->projLimit;
float *co = calc->vertexCos[i];
@@ -520,7 +521,7 @@ static void shrinkwrap_calc_normal_projection_cb_ex(void *__restrict userdata,
return;
}
- if (calc->vert != NULL && calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
+ if (calc->vert != nullptr && calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
/* calc->vert contains verts from evaluated mesh. */
/* These coordinates are deformed by vertexCos only for normal projection
* (to get correct normals) for other cases calc->verts contains undeformed coordinates and
@@ -535,12 +536,12 @@ static void shrinkwrap_calc_normal_projection_cb_ex(void *__restrict userdata,
hit->index = -1;
- /* TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that */
+ /* TODO: we should use FLT_MAX here, but sweep-sphere code isn't prepared for that. */
hit->dist = BVH_RAYCAST_DIST_MAX;
bool is_aux = false;
- /* Project over positive direction of axis */
+ /* Project over positive direction of axis. */
if (calc->smd->shrinkOpts & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR) {
if (aux_tree) {
if (BKE_shrinkwrap_project_normal(0, tmp_co, tmp_no, 0.0, local2aux, aux_tree, hit)) {
@@ -627,8 +628,8 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
BVHTreeRayHit hit;
/* auxiliary target */
- Mesh *auxMesh = NULL;
- ShrinkwrapTreeData *aux_tree = NULL;
+ Mesh *auxMesh = nullptr;
+ ShrinkwrapTreeData *aux_tree = nullptr;
ShrinkwrapTreeData aux_tree_stack;
SpaceTransform local2aux;
@@ -641,7 +642,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
/* Prepare data to retrieve the direction in which we should project each vertex */
if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
- if (calc->vert == NULL) {
+ if (calc->vert == nullptr) {
return;
}
}
@@ -680,13 +681,12 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
}
/* After successfully build the trees, start projection vertices. */
- ShrinkwrapCalcCBData data = {
- .calc = calc,
- .tree = calc->tree,
- .aux_tree = aux_tree,
- .proj_axis = proj_axis,
- .local2aux = &local2aux,
- };
+ ShrinkwrapCalcCBData data{};
+ data.calc = calc;
+ data.tree = calc->tree;
+ data.aux_tree = aux_tree;
+ data.proj_axis = proj_axis;
+ data.local2aux = &local2aux;
TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (calc->numVerts > BKE_MESH_OMP_LIMIT);
@@ -717,7 +717,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
//#define TRACE_TARGET_PROJECT
-typedef struct TargetProjectTriData {
+struct TargetProjectTriData {
const float **vtri_co;
const float (*vtri_no)[3];
const float *point_co;
@@ -727,12 +727,12 @@ typedef struct TargetProjectTriData {
/* Current interpolated position and normal. */
float co_interp[3], no_interp[3];
-} TargetProjectTriData;
+};
/* Computes the deviation of the equation system from goal. */
static void target_project_tri_deviation(void *userdata, const float x[3], float r_delta[3])
{
- TargetProjectTriData *data = userdata;
+ TargetProjectTriData *data = static_cast<TargetProjectTriData *>(userdata);
const float w[3] = {x[0], x[1], 1.0f - x[0] - x[1]};
interp_v3_v3v3v3(data->co_interp, data->vtri_co[0], data->vtri_co[1], data->vtri_co[2], w);
@@ -745,7 +745,7 @@ static void target_project_tri_deviation(void *userdata, const float x[3], float
/* Computes the Jacobian matrix of the equation system. */
static void target_project_tri_jacobian(void *userdata, const float x[3], float r_jacobian[3][3])
{
- TargetProjectTriData *data = userdata;
+ TargetProjectTriData *data = static_cast<TargetProjectTriData *>(userdata);
madd_v3_v3v3fl(r_jacobian[0], data->c0_minus_c2, data->n0_minus_n2, x[2]);
madd_v3_v3v3fl(r_jacobian[1], data->c1_minus_c2, data->n1_minus_n2, x[2]);
@@ -771,7 +771,7 @@ static void target_project_tri_clamp(float x[3])
}
/* Correct the Newton's method step to keep the coordinates within the triangle. */
-static bool target_project_tri_correct(void *UNUSED(userdata),
+static bool target_project_tri_correct(void * /*userdata*/,
const float x[3],
float step[3],
float x_next[3])
@@ -792,11 +792,11 @@ static bool target_project_tri_correct(void *UNUSED(userdata),
float ldist = 1.0f - sum;
/* If already at the boundary, slide along it. */
- if (ldist < epsilon * (float)M_SQRT2) {
+ if (ldist < epsilon * float(M_SQRT2)) {
float step_len = len_v2(step);
/* Abort if the solution is clearly outside the domain. */
- if (step_len > epsilon && sstep > step_len * dir_epsilon * (float)M_SQRT2) {
+ if (step_len > epsilon && sstep > step_len * dir_epsilon * float(M_SQRT2)) {
return false;
}
@@ -867,11 +867,10 @@ static bool target_project_solve_point_tri(const float *vtri_co[3],
x[2] = (dot_v3v3(tmp, r_hit_no) < 0) ? -dist : dist;
/* Solve the equations iteratively. */
- TargetProjectTriData tri_data = {
- .vtri_co = vtri_co,
- .vtri_no = vtri_no,
- .point_co = point_co,
- };
+ TargetProjectTriData tri_data{};
+ tri_data.vtri_co = vtri_co;
+ tri_data.vtri_no = vtri_no;
+ tri_data.point_co = point_co;
sub_v3_v3v3(tri_data.n0_minus_n2, vtri_no[0], vtri_no[2]);
sub_v3_v3v3(tri_data.n1_minus_n2, vtri_no[1], vtri_no[2]);
@@ -988,7 +987,7 @@ static void target_project_edge(const ShrinkwrapTreeData *tree,
float hit_co[3], hit_no[3];
for (int i = (det > 0 ? 2 : 0); i >= 0; i -= 2) {
- float x = (-b + ((float)i - 1) * sdet) / (2 * a);
+ float x = (-b + (float(i) - 1) * sdet) / (2 * a);
if (x >= -epsilon && x <= 1.0f + epsilon) {
CLAMP(x, 0, 1);
@@ -1064,7 +1063,7 @@ static void mesh_looptri_target_project(void *userdata,
}
}
-void BKE_shrinkwrap_find_nearest_surface(struct ShrinkwrapTreeData *tree,
+void BKE_shrinkwrap_find_nearest_surface(ShrinkwrapTreeData *tree,
BVHTreeNearest *nearest,
float co[3],
int type)
@@ -1093,20 +1092,20 @@ void BKE_shrinkwrap_find_nearest_surface(struct ShrinkwrapTreeData *tree,
}
}
-/*
- * Shrinkwrap moving vertexs to the nearest surface point on the target
+/**
+ * Shrink-wrap moving vertices to the nearest surface point on the target.
*
- * it builds a BVHTree from the target mesh and then performs a
+ * It builds a #BVHTree from the target mesh and then performs a
* NN matches for each vertex
*/
static void shrinkwrap_calc_nearest_surface_point_cb_ex(void *__restrict userdata,
const int i,
const TaskParallelTLS *__restrict tls)
{
- ShrinkwrapCalcCBData *data = userdata;
+ ShrinkwrapCalcCBData *data = static_cast<ShrinkwrapCalcCBData *>(userdata);
ShrinkwrapCalcData *calc = data->calc;
- BVHTreeNearest *nearest = tls->userdata_chunk;
+ BVHTreeNearest *nearest = static_cast<BVHTreeNearest *>(tls->userdata_chunk);
float *co = calc->vertexCos[i];
float tmp_co[3];
@@ -1153,7 +1152,7 @@ static void shrinkwrap_calc_nearest_surface_point_cb_ex(void *__restrict userdat
/* Found the nearest vertex */
if (nearest->index != -1) {
BKE_shrinkwrap_snap_point_to_surface(data->tree,
- NULL,
+ nullptr,
calc->smd->shrinkMode,
nearest->index,
nearest->co,
@@ -1168,8 +1167,8 @@ static void shrinkwrap_calc_nearest_surface_point_cb_ex(void *__restrict userdat
}
}
-void BKE_shrinkwrap_compute_smooth_normal(const struct ShrinkwrapTreeData *tree,
- const struct SpaceTransform *transform,
+void BKE_shrinkwrap_compute_smooth_normal(const ShrinkwrapTreeData *tree,
+ const SpaceTransform *transform,
int looptri_idx,
const float hit_co[3],
const float hit_no[3],
@@ -1223,7 +1222,7 @@ void BKE_shrinkwrap_compute_smooth_normal(const struct ShrinkwrapTreeData *tree,
}
}
/* Use the polygon normal if flat. */
- else if (tree->pnors != NULL) {
+ else if (tree->pnors != nullptr) {
copy_v3_v3(r_no, tree->pnors[tri->poly]);
}
/* Finally fallback to the looptri normal. */
@@ -1286,8 +1285,8 @@ static void shrinkwrap_snap_with_side(float r_point_co[3],
}
}
-void BKE_shrinkwrap_snap_point_to_surface(const struct ShrinkwrapTreeData *tree,
- const struct SpaceTransform *transform,
+void BKE_shrinkwrap_snap_point_to_surface(const ShrinkwrapTreeData *tree,
+ const SpaceTransform *transform,
int mode,
int hit_idx,
const float hit_co[3],
@@ -1352,10 +1351,9 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
nearest.dist_sq = FLT_MAX;
/* Find the nearest vertex */
- ShrinkwrapCalcCBData data = {
- .calc = calc,
- .tree = calc->tree,
- };
+ ShrinkwrapCalcCBData data{};
+ data.calc = calc;
+ data.tree = calc->tree;
TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (calc->numVerts > BKE_MESH_OMP_LIMIT);
@@ -1367,7 +1365,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd,
const ModifierEvalContext *ctx,
- struct Scene *scene,
+ Scene *scene,
Object *ob,
Mesh *mesh,
const MDeformVert *dvert,
@@ -1376,15 +1374,15 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd,
int numVerts)
{
- DerivedMesh *ss_mesh = NULL;
+ DerivedMesh *ss_mesh = nullptr;
ShrinkwrapCalcData calc = NULL_ShrinkwrapCalcData;
/* remove loop dependencies on derived meshes (TODO should this be done elsewhere?) */
if (smd->target == ob) {
- smd->target = NULL;
+ smd->target = nullptr;
}
if (smd->auxTarget == ob) {
- smd->auxTarget = NULL;
+ smd->auxTarget = nullptr;
}
/* Configure Shrinkwrap calc data */
@@ -1396,7 +1394,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd,
calc.vgroup = defgrp_index;
calc.invert_vgroup = (smd->shrinkOpts & MOD_SHRINKWRAP_INVERT_VGROUP) != 0;
- if (smd->target != NULL) {
+ if (smd->target != nullptr) {
Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, smd->target);
calc.target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target);
@@ -1410,14 +1408,14 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd,
}
calc.aux_target = DEG_get_evaluated_object(ctx->depsgraph, smd->auxTarget);
- if (mesh != NULL && smd->shrinkType == MOD_SHRINKWRAP_PROJECT) {
- /* Setup arrays to get vertexs positions, normals and deform weights */
+ if (mesh != nullptr && smd->shrinkType == MOD_SHRINKWRAP_PROJECT) {
+ /* Setup arrays to get vertices position, normals and deform weights. */
calc.vert = BKE_mesh_verts_for_write(mesh);
calc.vert_normals = BKE_mesh_vertex_normals_ensure(mesh);
- /* Using vertexs positions/normals as if a subsurface was applied */
+ /* Using vertices positions/normals as if a subsurface was applied */
if (smd->subsurfLevels) {
- SubsurfModifierData ssmd = {{NULL}};
+ SubsurfModifierData ssmd = {{nullptr}};
ssmd.subdivType = ME_CC_SUBSURF; /* catmull clark */
ssmd.levels = smd->subsurfLevels; /* levels */
@@ -1425,10 +1423,14 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd,
DerivedMesh *dm = CDDM_from_mesh(mesh);
ss_mesh = subsurf_make_derived_from_derived(
- dm, &ssmd, scene, NULL, (ob->mode & OB_MODE_EDIT) ? SUBSURF_IN_EDIT_MODE : 0);
+ dm,
+ &ssmd,
+ scene,
+ nullptr,
+ (ob->mode & OB_MODE_EDIT) ? SUBSURF_IN_EDIT_MODE : SubsurfFlags(0));
if (ss_mesh) {
- calc.vert = ss_mesh->getVertDataArray(ss_mesh, CD_MVERT);
+ calc.vert = static_cast<MVert *>(ss_mesh->getVertDataArray(ss_mesh, CD_MVERT));
if (calc.vert) {
/* TRICKY: this code assumes subsurface will have the transformed original vertices
* in their original order at the end of the vert array. */
@@ -1437,8 +1439,8 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd,
}
/* Just to make sure we are not leaving any memory behind */
- BLI_assert(ssmd.emCache == NULL);
- BLI_assert(ssmd.mCache == NULL);
+ BLI_assert(ssmd.emCache == nullptr);
+ BLI_assert(ssmd.mCache == nullptr);
dm->release(dm);
}
@@ -1523,14 +1525,12 @@ void shrinkwrapGpencilModifier_deform(ShrinkwrapGpencilModifierData *mmd,
}
}
-void BKE_shrinkwrap_mesh_nearest_surface_deform(struct bContext *C,
- Object *ob_source,
- Object *ob_target)
+void BKE_shrinkwrap_mesh_nearest_surface_deform(bContext *C, Object *ob_source, Object *ob_target)
{
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- struct Scene *sce = CTX_data_scene(C);
+ Scene *sce = CTX_data_scene(C);
ShrinkwrapModifierData ssmd = {{0}};
- ModifierEvalContext ctx = {depsgraph, ob_source, 0};
+ ModifierEvalContext ctx = {depsgraph, ob_source, ModifierApplyFlag(0)};
int totvert;
ssmd.target = ob_target;
@@ -1538,10 +1538,10 @@ void BKE_shrinkwrap_mesh_nearest_surface_deform(struct bContext *C,
ssmd.shrinkMode = MOD_SHRINKWRAP_ON_SURFACE;
ssmd.keepDist = 0.0f;
- Mesh *src_me = ob_source->data;
+ Mesh *src_me = static_cast<Mesh *>(ob_source->data);
float(*vertexCos)[3] = BKE_mesh_vert_coords_alloc(src_me, &totvert);
- shrinkwrapModifier_deform(&ssmd, &ctx, sce, ob_source, src_me, NULL, -1, vertexCos, totvert);
+ shrinkwrapModifier_deform(&ssmd, &ctx, sce, ob_source, src_me, nullptr, -1, vertexCos, totvert);
BKE_mesh_vert_coords_apply(src_me, vertexCos);
diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c
index 9610443ef70..daad983f0bf 100644
--- a/source/blender/blenkernel/intern/studiolight.c
+++ b/source/blender/blenkernel/intern/studiolight.c
@@ -217,8 +217,8 @@ static void studiolight_load_solid_light(StudioLight *sl)
#undef READ_IVAL
#undef READ_FVAL
-#define WRITE_FVAL(str, id, val) (BLI_dynstr_appendf(str, id " %f\n", val))
-#define WRITE_IVAL(str, id, val) (BLI_dynstr_appendf(str, id " %d\n", val))
+#define WRITE_FVAL(str, id, val) BLI_dynstr_appendf(str, id " %f\n", val)
+#define WRITE_IVAL(str, id, val) BLI_dynstr_appendf(str, id " %d\n", val)
#define WRITE_VEC3(str, id, val) \
do { \
@@ -273,7 +273,7 @@ static void direction_to_equirect(float r[2], const float dir[3])
static void equirect_to_direction(float r[3], float u, float v)
{
- float phi = (-(M_PI * 2)) * u + M_PI;
+ float phi = -(M_PI * 2) * u + M_PI;
float theta = -M_PI * v + M_PI;
float sin_theta = sinf(theta);
r[0] = sin_theta * cosf(phi);
diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.cc
index e7f89a625b3..6f583f760ef 100644
--- a/source/blender/blenkernel/intern/subdiv_ccg.c
+++ b/source/blender/blenkernel/intern/subdiv_ccg.cc
@@ -38,7 +38,7 @@ static void subdiv_ccg_average_inner_face_grids(SubdivCCG *subdiv_ccg,
void subdiv_ccg_average_faces_boundaries_and_corners(SubdivCCG *subdiv_ccg,
CCGKey *key,
- struct CCGFace **effected_faces,
+ CCGFace **effected_faces,
int num_effected_faces);
/** \} */
@@ -126,20 +126,21 @@ static void subdiv_ccg_alloc_elements(SubdivCCG *subdiv_ccg, Subdiv *subdiv)
const int grid_area = grid_size * grid_size;
subdiv_ccg->grid_element_size = element_size;
subdiv_ccg->num_grids = num_grids;
- subdiv_ccg->grids = MEM_calloc_arrayN(num_grids, sizeof(CCGElem *), "subdiv ccg grids");
- subdiv_ccg->grids_storage = MEM_calloc_arrayN(
- num_grids, ((size_t)grid_area) * element_size, "subdiv ccg grids storage");
- const size_t grid_size_in_bytes = (size_t)grid_area * element_size;
+ subdiv_ccg->grids = static_cast<CCGElem **>(
+ MEM_calloc_arrayN(num_grids, sizeof(CCGElem *), "subdiv ccg grids"));
+ subdiv_ccg->grids_storage = static_cast<unsigned char *>(
+ MEM_calloc_arrayN(num_grids, size_t(grid_area) * element_size, "subdiv ccg grids storage"));
+ const size_t grid_size_in_bytes = size_t(grid_area) * element_size;
for (int grid_index = 0; grid_index < num_grids; grid_index++) {
const size_t grid_offset = grid_size_in_bytes * grid_index;
subdiv_ccg->grids[grid_index] = (CCGElem *)&subdiv_ccg->grids_storage[grid_offset];
}
/* Grid material flags. */
- subdiv_ccg->grid_flag_mats = MEM_calloc_arrayN(
- num_grids, sizeof(DMFlagMat), "ccg grid material flags");
+ subdiv_ccg->grid_flag_mats = static_cast<DMFlagMat *>(
+ MEM_calloc_arrayN(num_grids, sizeof(DMFlagMat), "ccg grid material flags"));
/* Grid hidden flags. */
- subdiv_ccg->grid_hidden = MEM_calloc_arrayN(
- num_grids, sizeof(BLI_bitmap *), "ccg grid material flags");
+ subdiv_ccg->grid_hidden = static_cast<BLI_bitmap **>(
+ MEM_calloc_arrayN(num_grids, sizeof(BLI_bitmap *), "ccg grid material flags"));
for (int grid_index = 0; grid_index < num_grids; grid_index++) {
subdiv_ccg->grid_hidden[grid_index] = BLI_BITMAP_NEW(grid_area, "ccg grid hidden");
}
@@ -147,9 +148,10 @@ static void subdiv_ccg_alloc_elements(SubdivCCG *subdiv_ccg, Subdiv *subdiv)
/* Allocate memory for faces. */
subdiv_ccg->num_faces = num_faces;
if (num_faces) {
- subdiv_ccg->faces = MEM_calloc_arrayN(num_faces, sizeof(SubdivCCGFace), "Subdiv CCG faces");
- subdiv_ccg->grid_faces = MEM_calloc_arrayN(
- num_grids, sizeof(SubdivCCGFace *), "Subdiv CCG grid faces");
+ subdiv_ccg->faces = static_cast<SubdivCCGFace *>(
+ MEM_calloc_arrayN(num_faces, sizeof(SubdivCCGFace), "Subdiv CCG faces"));
+ subdiv_ccg->grid_faces = static_cast<SubdivCCGFace **>(
+ MEM_calloc_arrayN(num_grids, sizeof(SubdivCCGFace *), "Subdiv CCG grid faces"));
}
}
@@ -159,13 +161,13 @@ static void subdiv_ccg_alloc_elements(SubdivCCG *subdiv_ccg, Subdiv *subdiv)
/** \name Grids evaluation
* \{ */
-typedef struct CCGEvalGridsData {
+struct CCGEvalGridsData {
SubdivCCG *subdiv_ccg;
Subdiv *subdiv;
int *face_ptex_offset;
SubdivCCGMaskEvaluator *mask_evaluator;
SubdivCCGMaterialFlagsEvaluator *material_flags_evaluator;
-} CCGEvalGridsData;
+};
static void subdiv_ccg_eval_grid_element_limit(CCGEvalGridsData *data,
const int ptex_face_index,
@@ -175,7 +177,7 @@ static void subdiv_ccg_eval_grid_element_limit(CCGEvalGridsData *data,
{
Subdiv *subdiv = data->subdiv;
SubdivCCG *subdiv_ccg = data->subdiv_ccg;
- if (subdiv->displacement_evaluator != NULL) {
+ if (subdiv->displacement_evaluator != nullptr) {
BKE_subdiv_eval_final_point(subdiv, ptex_face_index, u, v, (float *)element);
}
else if (subdiv_ccg->has_normal) {
@@ -202,7 +204,7 @@ static void subdiv_ccg_eval_grid_element_mask(CCGEvalGridsData *data,
return;
}
float *mask_value_ptr = (float *)(element + subdiv_ccg->mask_offset);
- if (data->mask_evaluator != NULL) {
+ if (data->mask_evaluator != nullptr) {
*mask_value_ptr = data->mask_evaluator->eval_mask(data->mask_evaluator, ptex_face_index, u, v);
}
else {
@@ -239,7 +241,7 @@ static void subdiv_ccg_eval_regular_grid(CCGEvalGridsData *data, const int face_
const float grid_u = x * grid_size_1_inv;
float u, v;
BKE_subdiv_rotate_grid_to_quad(corner, grid_u, grid_v, &u, &v);
- const size_t grid_element_index = (size_t)y * grid_size + x;
+ const size_t grid_element_index = size_t(y) * grid_size + x;
const size_t grid_element_offset = grid_element_index * element_size;
subdiv_ccg_eval_grid_element(data, ptex_face_index, u, v, &grid[grid_element_offset]);
}
@@ -269,7 +271,7 @@ static void subdiv_ccg_eval_special_grid(CCGEvalGridsData *data, const int face_
const float u = 1.0f - (y * grid_size_1_inv);
for (int x = 0; x < grid_size; x++) {
const float v = 1.0f - (x * grid_size_1_inv);
- const size_t grid_element_index = (size_t)y * grid_size + x;
+ const size_t grid_element_index = size_t(y) * grid_size + x;
const size_t grid_element_offset = grid_element_index * element_size;
subdiv_ccg_eval_grid_element(data, ptex_face_index, u, v, &grid[grid_element_offset]);
}
@@ -286,7 +288,7 @@ static void subdiv_ccg_eval_grids_task(void *__restrict userdata_v,
const int face_index,
const TaskParallelTLS *__restrict UNUSED(tls))
{
- CCGEvalGridsData *data = userdata_v;
+ CCGEvalGridsData *data = static_cast<CCGEvalGridsData *>(userdata_v);
SubdivCCG *subdiv_ccg = data->subdiv_ccg;
SubdivCCGFace *face = &subdiv_ccg->faces[face_index];
if (face->num_grids == 4) {
@@ -318,7 +320,7 @@ static bool subdiv_ccg_evaluate_grids(SubdivCCG *subdiv_ccg,
0, num_faces, &data, subdiv_ccg_eval_grids_task, &parallel_range_settings);
/* If displacement is used, need to calculate normals after all final
* coordinates are known. */
- if (subdiv->displacement_evaluator != NULL) {
+ if (subdiv->displacement_evaluator != nullptr) {
BKE_subdiv_ccg_recalc_normals(subdiv_ccg);
}
return true;
@@ -341,17 +343,17 @@ static void subdiv_ccg_init_faces(SubdivCCG *subdiv_ccg)
}
/* TODO(sergey): Consider making it generic enough to be fit into BLI. */
-typedef struct StaticOrHeapIntStorage {
+struct StaticOrHeapIntStorage {
int static_storage[64];
int static_storage_len;
int *heap_storage;
int heap_storage_len;
-} StaticOrHeapIntStorage;
+};
static void static_or_heap_storage_init(StaticOrHeapIntStorage *storage)
{
storage->static_storage_len = sizeof(storage->static_storage) / sizeof(*storage->static_storage);
- storage->heap_storage = NULL;
+ storage->heap_storage = nullptr;
storage->heap_storage_len = 0;
}
@@ -361,10 +363,11 @@ static int *static_or_heap_storage_get(StaticOrHeapIntStorage *storage, int heap
if (heap_len <= storage->static_storage_len) {
return storage->static_storage;
}
- /* Make sure heap ius big enough. */
+ /* Make sure heap is big enough. */
if (heap_len > storage->heap_storage_len) {
MEM_SAFE_FREE(storage->heap_storage);
- storage->heap_storage = MEM_malloc_arrayN(heap_len, sizeof(int), "int storage");
+ storage->heap_storage = static_cast<int *>(
+ MEM_malloc_arrayN(heap_len, sizeof(int), "int storage"));
storage->heap_storage_len = heap_len;
}
return storage->heap_storage;
@@ -378,13 +381,16 @@ static void static_or_heap_storage_free(StaticOrHeapIntStorage *storage)
static void subdiv_ccg_allocate_adjacent_edges(SubdivCCG *subdiv_ccg, const int num_edges)
{
subdiv_ccg->num_adjacent_edges = num_edges;
- subdiv_ccg->adjacent_edges = MEM_calloc_arrayN(
- subdiv_ccg->num_adjacent_edges, sizeof(*subdiv_ccg->adjacent_edges), "ccg adjacent edges");
+ subdiv_ccg->adjacent_edges = static_cast<SubdivCCGAdjacentEdge *>(MEM_calloc_arrayN(
+ subdiv_ccg->num_adjacent_edges, sizeof(*subdiv_ccg->adjacent_edges), "ccg adjacent edges"));
}
static SubdivCCGCoord subdiv_ccg_coord(int grid_index, int x, int y)
{
- SubdivCCGCoord coord = {.grid_index = grid_index, .x = x, .y = y};
+ SubdivCCGCoord coord{};
+ coord.grid_index = grid_index;
+ coord.x = x;
+ coord.y = y;
return coord;
}
@@ -403,11 +409,11 @@ static SubdivCCGCoord *subdiv_ccg_adjacent_edge_add_face(SubdivCCG *subdiv_ccg,
const int adjacent_face_index = adjacent_edge->num_adjacent_faces;
++adjacent_edge->num_adjacent_faces;
/* Allocate memory for the boundary elements. */
- adjacent_edge->boundary_coords = MEM_reallocN(adjacent_edge->boundary_coords,
- adjacent_edge->num_adjacent_faces *
- sizeof(*adjacent_edge->boundary_coords));
- adjacent_edge->boundary_coords[adjacent_face_index] = MEM_malloc_arrayN(
- grid_size * 2, sizeof(SubdivCCGCoord), "ccg adjacent boundary");
+ adjacent_edge->boundary_coords = static_cast<SubdivCCGCoord **>(
+ MEM_reallocN(adjacent_edge->boundary_coords,
+ adjacent_edge->num_adjacent_faces * sizeof(*adjacent_edge->boundary_coords)));
+ adjacent_edge->boundary_coords[adjacent_face_index] = static_cast<SubdivCCGCoord *>(
+ MEM_malloc_arrayN(grid_size * 2, sizeof(SubdivCCGCoord), "ccg adjacent boundary"));
return adjacent_edge->boundary_coords[adjacent_face_index];
}
@@ -487,9 +493,10 @@ static void subdiv_ccg_init_faces_edge_neighborhood(SubdivCCG *subdiv_ccg)
static void subdiv_ccg_allocate_adjacent_vertices(SubdivCCG *subdiv_ccg, const int num_vertices)
{
subdiv_ccg->num_adjacent_vertices = num_vertices;
- subdiv_ccg->adjacent_vertices = MEM_calloc_arrayN(subdiv_ccg->num_adjacent_vertices,
- sizeof(*subdiv_ccg->adjacent_vertices),
- "ccg adjacent vertices");
+ subdiv_ccg->adjacent_vertices = static_cast<SubdivCCGAdjacentVertex *>(
+ MEM_calloc_arrayN(subdiv_ccg->num_adjacent_vertices,
+ sizeof(*subdiv_ccg->adjacent_vertices),
+ "ccg adjacent vertices"));
}
/* Returns storage where corner elements are to be stored. This is a pointer
@@ -500,9 +507,9 @@ static SubdivCCGCoord *subdiv_ccg_adjacent_vertex_add_face(
const int adjacent_face_index = adjacent_vertex->num_adjacent_faces;
++adjacent_vertex->num_adjacent_faces;
/* Allocate memory for the boundary elements. */
- adjacent_vertex->corner_coords = MEM_reallocN(adjacent_vertex->corner_coords,
- adjacent_vertex->num_adjacent_faces *
- sizeof(*adjacent_vertex->corner_coords));
+ adjacent_vertex->corner_coords = static_cast<SubdivCCGCoord *>(
+ MEM_reallocN(adjacent_vertex->corner_coords,
+ adjacent_vertex->num_adjacent_faces * sizeof(*adjacent_vertex->corner_coords)));
return &adjacent_vertex->corner_coords[adjacent_face_index];
}
@@ -564,7 +571,7 @@ SubdivCCG *BKE_subdiv_to_ccg(Subdiv *subdiv,
SubdivCCGMaterialFlagsEvaluator *material_flags_evaluator)
{
BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_CCG);
- SubdivCCG *subdiv_ccg = MEM_callocN(sizeof(SubdivCCG), "subdiv ccg");
+ SubdivCCG *subdiv_ccg = MEM_cnew<SubdivCCG>(__func__);
subdiv_ccg->subdiv = subdiv;
subdiv_ccg->level = bitscan_forward_i(settings->resolution - 1);
subdiv_ccg->grid_size = BKE_subdiv_grid_size_from_level(subdiv_ccg->level);
@@ -575,7 +582,7 @@ SubdivCCG *BKE_subdiv_to_ccg(Subdiv *subdiv,
if (!subdiv_ccg_evaluate_grids(subdiv_ccg, subdiv, mask_evaluator, material_flags_evaluator)) {
BKE_subdiv_ccg_destroy(subdiv_ccg);
BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_CCG);
- return NULL;
+ return nullptr;
}
BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_CCG);
return subdiv_ccg;
@@ -588,9 +595,9 @@ Mesh *BKE_subdiv_to_ccg_mesh(Subdiv *subdiv,
/* Make sure evaluator is ready. */
BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_CCG);
if (!BKE_subdiv_eval_begin_from_mesh(
- subdiv, coarse_mesh, NULL, SUBDIV_EVALUATOR_TYPE_CPU, NULL)) {
+ subdiv, coarse_mesh, nullptr, SUBDIV_EVALUATOR_TYPE_CPU, nullptr)) {
if (coarse_mesh->totpoly) {
- return NULL;
+ return nullptr;
}
}
BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_CCG);
@@ -599,13 +606,13 @@ Mesh *BKE_subdiv_to_ccg_mesh(Subdiv *subdiv,
SubdivCCGMaterialFlagsEvaluator material_flags_evaluator;
BKE_subdiv_ccg_material_flags_init_from_mesh(&material_flags_evaluator, coarse_mesh);
SubdivCCG *subdiv_ccg = BKE_subdiv_to_ccg(
- subdiv, settings, has_mask ? &mask_evaluator : NULL, &material_flags_evaluator);
+ subdiv, settings, has_mask ? &mask_evaluator : nullptr, &material_flags_evaluator);
if (has_mask) {
mask_evaluator.free(&mask_evaluator);
}
material_flags_evaluator.free(&material_flags_evaluator);
- if (subdiv_ccg == NULL) {
- return NULL;
+ if (subdiv_ccg == nullptr) {
+ return nullptr;
}
Mesh *result = BKE_mesh_new_nomain_from_template(coarse_mesh, 0, 0, 0, 0, 0);
result->runtime.subdiv_ccg = subdiv_ccg;
@@ -620,13 +627,13 @@ void BKE_subdiv_ccg_destroy(SubdivCCG *subdiv_ccg)
MEM_SAFE_FREE(subdiv_ccg->edges);
MEM_SAFE_FREE(subdiv_ccg->vertices);
MEM_SAFE_FREE(subdiv_ccg->grid_flag_mats);
- if (subdiv_ccg->grid_hidden != NULL) {
+ if (subdiv_ccg->grid_hidden != nullptr) {
for (int grid_index = 0; grid_index < num_grids; grid_index++) {
MEM_SAFE_FREE(subdiv_ccg->grid_hidden[grid_index]);
}
MEM_SAFE_FREE(subdiv_ccg->grid_hidden);
}
- if (subdiv_ccg->subdiv != NULL) {
+ if (subdiv_ccg->subdiv != nullptr) {
BKE_subdiv_free(subdiv_ccg->subdiv);
}
MEM_SAFE_FREE(subdiv_ccg->faces);
@@ -676,14 +683,14 @@ void BKE_subdiv_ccg_key_top_level(CCGKey *key, const SubdivCCG *subdiv_ccg)
/** \name Normals
* \{ */
-typedef struct RecalcInnerNormalsData {
+struct RecalcInnerNormalsData {
SubdivCCG *subdiv_ccg;
CCGKey *key;
-} RecalcInnerNormalsData;
+};
-typedef struct RecalcInnerNormalsTLSData {
+struct RecalcInnerNormalsTLSData {
float (*face_normals)[3];
-} RecalcInnerNormalsTLSData;
+};
/* Evaluate high-res face normals, for faces which corresponds to grid elements
*
@@ -698,9 +705,9 @@ static void subdiv_ccg_recalc_inner_face_normals(SubdivCCG *subdiv_ccg,
const int grid_size = subdiv_ccg->grid_size;
const int grid_size_1 = grid_size - 1;
CCGElem *grid = subdiv_ccg->grids[grid_index];
- if (tls->face_normals == NULL) {
- tls->face_normals = MEM_malloc_arrayN(
- grid_size_1 * grid_size_1, sizeof(float[3]), "CCG TLS normals");
+ if (tls->face_normals == nullptr) {
+ tls->face_normals = static_cast<float(*)[3]>(
+ MEM_malloc_arrayN(grid_size_1 * grid_size_1, sizeof(float[3]), "CCG TLS normals"));
}
for (int y = 0; y < grid_size - 1; y++) {
for (int x = 0; x < grid_size - 1; x++) {
@@ -766,8 +773,8 @@ static void subdiv_ccg_recalc_inner_normal_task(void *__restrict userdata_v,
const int grid_index,
const TaskParallelTLS *__restrict tls_v)
{
- RecalcInnerNormalsData *data = userdata_v;
- RecalcInnerNormalsTLSData *tls = tls_v->userdata_chunk;
+ RecalcInnerNormalsData *data = static_cast<RecalcInnerNormalsData *>(userdata_v);
+ RecalcInnerNormalsTLSData *tls = static_cast<RecalcInnerNormalsTLSData *>(tls_v->userdata_chunk);
subdiv_ccg_recalc_inner_face_normals(data->subdiv_ccg, data->key, tls, grid_index);
subdiv_ccg_average_inner_face_normals(data->subdiv_ccg, data->key, tls, grid_index);
}
@@ -775,7 +782,7 @@ static void subdiv_ccg_recalc_inner_normal_task(void *__restrict userdata_v,
static void subdiv_ccg_recalc_inner_normal_free(const void *__restrict UNUSED(userdata),
void *__restrict tls_v)
{
- RecalcInnerNormalsTLSData *tls = tls_v;
+ RecalcInnerNormalsTLSData *tls = static_cast<RecalcInnerNormalsTLSData *>(tls_v);
MEM_SAFE_FREE(tls->face_normals);
}
@@ -784,11 +791,10 @@ static void subdiv_ccg_recalc_inner_grid_normals(SubdivCCG *subdiv_ccg)
{
CCGKey key;
BKE_subdiv_ccg_key_top_level(&key, subdiv_ccg);
- RecalcInnerNormalsData data = {
- .subdiv_ccg = subdiv_ccg,
- .key = &key,
- };
- RecalcInnerNormalsTLSData tls_data = {NULL};
+ RecalcInnerNormalsData data{};
+ data.subdiv_ccg = subdiv_ccg;
+ data.key = &key;
+ RecalcInnerNormalsTLSData tls_data = {nullptr};
TaskParallelSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
parallel_range_settings.userdata_chunk = &tls_data;
@@ -811,20 +817,20 @@ void BKE_subdiv_ccg_recalc_normals(SubdivCCG *subdiv_ccg)
BKE_subdiv_ccg_average_grids(subdiv_ccg);
}
-typedef struct RecalcModifiedInnerNormalsData {
+struct RecalcModifiedInnerNormalsData {
SubdivCCG *subdiv_ccg;
CCGKey *key;
SubdivCCGFace **effected_ccg_faces;
-} RecalcModifiedInnerNormalsData;
+};
static void subdiv_ccg_recalc_modified_inner_normal_task(void *__restrict userdata_v,
const int face_index,
const TaskParallelTLS *__restrict tls_v)
{
- RecalcModifiedInnerNormalsData *data = userdata_v;
+ RecalcModifiedInnerNormalsData *data = static_cast<RecalcModifiedInnerNormalsData *>(userdata_v);
SubdivCCG *subdiv_ccg = data->subdiv_ccg;
CCGKey *key = data->key;
- RecalcInnerNormalsTLSData *tls = tls_v->userdata_chunk;
+ RecalcInnerNormalsTLSData *tls = static_cast<RecalcInnerNormalsTLSData *>(tls_v->userdata_chunk);
SubdivCCGFace **faces = data->effected_ccg_faces;
SubdivCCGFace *face = faces[face_index];
const int num_face_grids = face->num_grids;
@@ -839,22 +845,21 @@ static void subdiv_ccg_recalc_modified_inner_normal_task(void *__restrict userda
static void subdiv_ccg_recalc_modified_inner_normal_free(const void *__restrict UNUSED(userdata),
void *__restrict tls_v)
{
- RecalcInnerNormalsTLSData *tls = tls_v;
+ RecalcInnerNormalsTLSData *tls = static_cast<RecalcInnerNormalsTLSData *>(tls_v);
MEM_SAFE_FREE(tls->face_normals);
}
static void subdiv_ccg_recalc_modified_inner_grid_normals(SubdivCCG *subdiv_ccg,
- struct CCGFace **effected_faces,
+ CCGFace **effected_faces,
int num_effected_faces)
{
CCGKey key;
BKE_subdiv_ccg_key_top_level(&key, subdiv_ccg);
- RecalcModifiedInnerNormalsData data = {
- .subdiv_ccg = subdiv_ccg,
- .key = &key,
- .effected_ccg_faces = (SubdivCCGFace **)effected_faces,
- };
- RecalcInnerNormalsTLSData tls_data = {NULL};
+ RecalcModifiedInnerNormalsData data{};
+ data.subdiv_ccg = subdiv_ccg;
+ data.key = &key;
+ data.effected_ccg_faces = (SubdivCCGFace **)effected_faces;
+ RecalcInnerNormalsTLSData tls_data = {nullptr};
TaskParallelSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
parallel_range_settings.userdata_chunk = &tls_data;
@@ -868,7 +873,7 @@ static void subdiv_ccg_recalc_modified_inner_grid_normals(SubdivCCG *subdiv_ccg,
}
void BKE_subdiv_ccg_update_normals(SubdivCCG *subdiv_ccg,
- struct CCGFace **effected_faces,
+ CCGFace **effected_faces,
int num_effected_faces)
{
if (!subdiv_ccg->has_normal) {
@@ -894,10 +899,10 @@ void BKE_subdiv_ccg_update_normals(SubdivCCG *subdiv_ccg,
/** \name Boundary averaging/stitching
* \{ */
-typedef struct AverageInnerGridsData {
+struct AverageInnerGridsData {
SubdivCCG *subdiv_ccg;
CCGKey *key;
-} AverageInnerGridsData;
+};
static void average_grid_element_value_v3(float a[3], float b[3])
{
@@ -926,11 +931,11 @@ static void average_grid_element(SubdivCCG *subdiv_ccg,
}
/* Accumulator to hold data during averaging. */
-typedef struct GridElementAccumulator {
+struct GridElementAccumulator {
float co[3];
float no[3];
float mask;
-} GridElementAccumulator;
+};
static void element_accumulator_init(GridElementAccumulator *accumulator)
{
@@ -1013,7 +1018,7 @@ static void subdiv_ccg_average_inner_grids_task(void *__restrict userdata_v,
const int face_index,
const TaskParallelTLS *__restrict UNUSED(tls_v))
{
- AverageInnerGridsData *data = userdata_v;
+ AverageInnerGridsData *data = static_cast<AverageInnerGridsData *>(userdata_v);
SubdivCCG *subdiv_ccg = data->subdiv_ccg;
CCGKey *key = data->key;
SubdivCCGFace *faces = subdiv_ccg->faces;
@@ -1021,17 +1026,17 @@ static void subdiv_ccg_average_inner_grids_task(void *__restrict userdata_v,
subdiv_ccg_average_inner_face_grids(subdiv_ccg, key, face);
}
-typedef struct AverageGridsBoundariesData {
+struct AverageGridsBoundariesData {
SubdivCCG *subdiv_ccg;
CCGKey *key;
/* Optional lookup table. Maps task index to index in `subdiv_ccg->adjacent_vertices`. */
const int *adjacent_edge_index_map;
-} AverageGridsBoundariesData;
+};
-typedef struct AverageGridsBoundariesTLSData {
+struct AverageGridsBoundariesTLSData {
GridElementAccumulator *accumulators;
-} AverageGridsBoundariesTLSData;
+};
static void subdiv_ccg_average_grids_boundary(SubdivCCG *subdiv_ccg,
CCGKey *key,
@@ -1044,9 +1049,9 @@ static void subdiv_ccg_average_grids_boundary(SubdivCCG *subdiv_ccg,
/* Nothing to average with. */
return;
}
- if (tls->accumulators == NULL) {
- tls->accumulators = MEM_calloc_arrayN(
- grid_size2, sizeof(GridElementAccumulator), "average accumulators");
+ if (tls->accumulators == nullptr) {
+ tls->accumulators = static_cast<GridElementAccumulator *>(
+ MEM_calloc_arrayN(grid_size2, sizeof(GridElementAccumulator), "average accumulators"));
}
else {
for (int i = 1; i < grid_size2 - 1; i++) {
@@ -1077,12 +1082,13 @@ static void subdiv_ccg_average_grids_boundaries_task(void *__restrict userdata_v
const int n,
const TaskParallelTLS *__restrict tls_v)
{
- AverageGridsBoundariesData *data = userdata_v;
+ AverageGridsBoundariesData *data = static_cast<AverageGridsBoundariesData *>(userdata_v);
const int adjacent_edge_index = data->adjacent_edge_index_map ?
data->adjacent_edge_index_map[n] :
n;
- AverageGridsBoundariesTLSData *tls = tls_v->userdata_chunk;
+ AverageGridsBoundariesTLSData *tls = static_cast<AverageGridsBoundariesTLSData *>(
+ tls_v->userdata_chunk);
SubdivCCG *subdiv_ccg = data->subdiv_ccg;
CCGKey *key = data->key;
SubdivCCGAdjacentEdge *adjacent_edge = &subdiv_ccg->adjacent_edges[adjacent_edge_index];
@@ -1092,17 +1098,17 @@ static void subdiv_ccg_average_grids_boundaries_task(void *__restrict userdata_v
static void subdiv_ccg_average_grids_boundaries_free(const void *__restrict UNUSED(userdata),
void *__restrict tls_v)
{
- AverageGridsBoundariesTLSData *tls = tls_v;
+ AverageGridsBoundariesTLSData *tls = static_cast<AverageGridsBoundariesTLSData *>(tls_v);
MEM_SAFE_FREE(tls->accumulators);
}
-typedef struct AverageGridsCornerData {
+struct AverageGridsCornerData {
SubdivCCG *subdiv_ccg;
CCGKey *key;
/* Optional lookup table. Maps task range index to index in `subdiv_ccg->adjacent_vertices`. */
const int *adjacent_vert_index_map;
-} AverageGridsCornerData;
+};
static void subdiv_ccg_average_grids_corners(SubdivCCG *subdiv_ccg,
CCGKey *key,
@@ -1133,7 +1139,7 @@ static void subdiv_ccg_average_grids_corners_task(void *__restrict userdata_v,
const int n,
const TaskParallelTLS *__restrict UNUSED(tls_v))
{
- AverageGridsCornerData *data = userdata_v;
+ AverageGridsCornerData *data = static_cast<AverageGridsCornerData *>(userdata_v);
const int adjacent_vertex_index = data->adjacent_vert_index_map ?
data->adjacent_vert_index_map[n] :
n;
@@ -1150,9 +1156,11 @@ static void subdiv_ccg_average_boundaries(SubdivCCG *subdiv_ccg,
{
TaskParallelSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
- AverageGridsBoundariesData boundaries_data = {
- .subdiv_ccg = subdiv_ccg, .key = key, .adjacent_edge_index_map = adjacent_edge_index_map};
- AverageGridsBoundariesTLSData tls_data = {NULL};
+ AverageGridsBoundariesData boundaries_data{};
+ boundaries_data.subdiv_ccg = subdiv_ccg;
+ boundaries_data.key = key;
+ boundaries_data.adjacent_edge_index_map = adjacent_edge_index_map;
+ AverageGridsBoundariesTLSData tls_data = {nullptr};
parallel_range_settings.userdata_chunk = &tls_data;
parallel_range_settings.userdata_chunk_size = sizeof(tls_data);
parallel_range_settings.func_free = subdiv_ccg_average_grids_boundaries_free;
@@ -1165,7 +1173,7 @@ static void subdiv_ccg_average_boundaries(SubdivCCG *subdiv_ccg,
static void subdiv_ccg_average_all_boundaries(SubdivCCG *subdiv_ccg, CCGKey *key)
{
- subdiv_ccg_average_boundaries(subdiv_ccg, key, NULL, subdiv_ccg->num_adjacent_edges);
+ subdiv_ccg_average_boundaries(subdiv_ccg, key, nullptr, subdiv_ccg->num_adjacent_edges);
}
static void subdiv_ccg_average_corners(SubdivCCG *subdiv_ccg,
@@ -1175,8 +1183,10 @@ static void subdiv_ccg_average_corners(SubdivCCG *subdiv_ccg,
{
TaskParallelSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
- AverageGridsCornerData corner_data = {
- .subdiv_ccg = subdiv_ccg, .key = key, .adjacent_vert_index_map = adjacent_vert_index_map};
+ AverageGridsCornerData corner_data{};
+ corner_data.subdiv_ccg = subdiv_ccg;
+ corner_data.key = key;
+ corner_data.adjacent_vert_index_map = adjacent_vert_index_map;
BLI_task_parallel_range(0,
num_adjacent_vertices,
&corner_data,
@@ -1185,7 +1195,7 @@ static void subdiv_ccg_average_corners(SubdivCCG *subdiv_ccg,
}
static void subdiv_ccg_average_all_corners(SubdivCCG *subdiv_ccg, CCGKey *key)
{
- subdiv_ccg_average_corners(subdiv_ccg, key, NULL, subdiv_ccg->num_adjacent_vertices);
+ subdiv_ccg_average_corners(subdiv_ccg, key, nullptr, subdiv_ccg->num_adjacent_vertices);
}
static void subdiv_ccg_average_all_boundaries_and_corners(SubdivCCG *subdiv_ccg, CCGKey *key)
@@ -1202,10 +1212,9 @@ void BKE_subdiv_ccg_average_grids(SubdivCCG *subdiv_ccg)
BLI_parallel_range_settings_defaults(&parallel_range_settings);
/* Average inner boundaries of grids (within one face), across faces
* from different face-corners. */
- AverageInnerGridsData inner_data = {
- .subdiv_ccg = subdiv_ccg,
- .key = &key,
- };
+ AverageInnerGridsData inner_data{};
+ inner_data.subdiv_ccg = subdiv_ccg;
+ inner_data.key = &key;
BLI_task_parallel_range(0,
subdiv_ccg->num_faces,
&inner_data,
@@ -1215,7 +1224,7 @@ void BKE_subdiv_ccg_average_grids(SubdivCCG *subdiv_ccg)
}
static void subdiv_ccg_affected_face_adjacency(SubdivCCG *subdiv_ccg,
- struct CCGFace **effected_faces,
+ CCGFace **effected_faces,
int num_effected_faces,
GSet *r_adjacent_vertices,
GSet *r_adjacent_edges)
@@ -1262,7 +1271,7 @@ static void subdiv_ccg_affected_face_adjacency(SubdivCCG *subdiv_ccg,
void subdiv_ccg_average_faces_boundaries_and_corners(SubdivCCG *subdiv_ccg,
CCGKey *key,
- struct CCGFace **effected_faces,
+ CCGFace **effected_faces,
int num_effected_faces)
{
GSet *adjacent_vertices = BLI_gset_ptr_new(__func__);
@@ -1284,7 +1293,8 @@ void subdiv_ccg_average_faces_boundaries_and_corners(SubdivCCG *subdiv_ccg,
adjacent_edge_index_map = static_or_heap_storage_get(&index_heap, BLI_gset_len(adjacent_edges));
GSET_ITER_INDEX (gi, adjacent_edges, i) {
- SubdivCCGAdjacentEdge *adjacent_edge = BLI_gsetIterator_getKey(&gi);
+ SubdivCCGAdjacentEdge *adjacent_edge = static_cast<SubdivCCGAdjacentEdge *>(
+ BLI_gsetIterator_getKey(&gi));
adjacent_edge_index_map[i] = adjacent_edge - subdiv_ccg->adjacent_edges;
}
subdiv_ccg_average_boundaries(
@@ -1295,48 +1305,48 @@ void subdiv_ccg_average_faces_boundaries_and_corners(SubdivCCG *subdiv_ccg,
adjacent_vertex_index_map = static_or_heap_storage_get(&index_heap,
BLI_gset_len(adjacent_vertices));
GSET_ITER_INDEX (gi, adjacent_vertices, i) {
- SubdivCCGAdjacentVertex *adjacent_vertex = BLI_gsetIterator_getKey(&gi);
+ SubdivCCGAdjacentVertex *adjacent_vertex = static_cast<SubdivCCGAdjacentVertex *>(
+ BLI_gsetIterator_getKey(&gi));
adjacent_vertex_index_map[i] = adjacent_vertex - subdiv_ccg->adjacent_vertices;
}
subdiv_ccg_average_corners(
subdiv_ccg, key, adjacent_vertex_index_map, BLI_gset_len(adjacent_vertices));
- BLI_gset_free(adjacent_vertices, NULL);
- BLI_gset_free(adjacent_edges, NULL);
+ BLI_gset_free(adjacent_vertices, nullptr);
+ BLI_gset_free(adjacent_edges, nullptr);
static_or_heap_storage_free(&index_heap);
}
-typedef struct StitchFacesInnerGridsData {
+struct StitchFacesInnerGridsData {
SubdivCCG *subdiv_ccg;
CCGKey *key;
- struct CCGFace **effected_ccg_faces;
-} StitchFacesInnerGridsData;
+ CCGFace **effected_ccg_faces;
+};
static void subdiv_ccg_stitch_face_inner_grids_task(
void *__restrict userdata_v,
const int face_index,
const TaskParallelTLS *__restrict UNUSED(tls_v))
{
- StitchFacesInnerGridsData *data = userdata_v;
+ StitchFacesInnerGridsData *data = static_cast<StitchFacesInnerGridsData *>(userdata_v);
SubdivCCG *subdiv_ccg = data->subdiv_ccg;
CCGKey *key = data->key;
- struct CCGFace **effected_ccg_faces = data->effected_ccg_faces;
- struct CCGFace *effected_ccg_face = effected_ccg_faces[face_index];
+ CCGFace **effected_ccg_faces = data->effected_ccg_faces;
+ CCGFace *effected_ccg_face = effected_ccg_faces[face_index];
SubdivCCGFace *face = (SubdivCCGFace *)effected_ccg_face;
subdiv_ccg_average_inner_face_grids(subdiv_ccg, key, face);
}
void BKE_subdiv_ccg_average_stitch_faces(SubdivCCG *subdiv_ccg,
- struct CCGFace **effected_faces,
+ CCGFace **effected_faces,
int num_effected_faces)
{
CCGKey key;
BKE_subdiv_ccg_key_top_level(&key, subdiv_ccg);
- StitchFacesInnerGridsData data = {
- .subdiv_ccg = subdiv_ccg,
- .key = &key,
- .effected_ccg_faces = effected_faces,
- };
+ StitchFacesInnerGridsData data{};
+ data.subdiv_ccg = subdiv_ccg;
+ data.key = &key;
+ data.effected_ccg_faces = effected_faces;
TaskParallelSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
BLI_task_parallel_range(0,
@@ -1402,8 +1412,8 @@ BLI_INLINE void subdiv_ccg_neighbors_init(SubdivCCGNeighbors *neighbors,
neighbors->coords = neighbors->coords_fixed;
}
else {
- neighbors->coords = MEM_mallocN(sizeof(*neighbors->coords) * size,
- "SubdivCCGNeighbors.coords");
+ neighbors->coords = static_cast<SubdivCCGCoord *>(
+ MEM_mallocN(sizeof(*neighbors->coords) * size, "SubdivCCGNeighbors.coords"));
}
}
@@ -1698,7 +1708,7 @@ static int adjacent_edge_point_index_from_coord(const SubdivCCG *subdiv_ccg,
directional_edge_vertex_index = edge_vertices_indices[1];
}
- /* Flip the index if the edde points opposite direction. */
+ /* Flip the index if the edge points opposite direction. */
if (adjacent_vertex_index != directional_edge_vertex_index) {
const int num_edge_points = subdiv_ccg->grid_size * 2;
adjacent_edge_point_index = num_edge_points - adjacent_edge_point_index - 1;
@@ -1946,17 +1956,17 @@ int BKE_subdiv_ccg_grid_to_face_index(const SubdivCCG *subdiv_ccg, const int gri
const int *BKE_subdiv_ccg_start_face_grid_index_ensure(SubdivCCG *subdiv_ccg)
{
- if (subdiv_ccg->cache_.start_face_grid_index == NULL) {
+ if (subdiv_ccg->cache_.start_face_grid_index == nullptr) {
const Subdiv *subdiv = subdiv_ccg->subdiv;
OpenSubdiv_TopologyRefiner *topology_refiner = subdiv->topology_refiner;
- if (topology_refiner == NULL) {
- return NULL;
+ if (topology_refiner == nullptr) {
+ return nullptr;
}
const int num_coarse_faces = topology_refiner->getNumFaces(topology_refiner);
- subdiv_ccg->cache_.start_face_grid_index = MEM_malloc_arrayN(
- num_coarse_faces, sizeof(int), "start_face_grid_index");
+ subdiv_ccg->cache_.start_face_grid_index = static_cast<int *>(
+ MEM_malloc_arrayN(num_coarse_faces, sizeof(int), "start_face_grid_index"));
int start_grid_index = 0;
for (int face_index = 0; face_index < num_coarse_faces; face_index++) {
@@ -2034,7 +2044,7 @@ SubdivCCGAdjacencyType BKE_subdiv_ccg_coarse_mesh_adjacency_info_get(const Subdi
void BKE_subdiv_ccg_grid_hidden_ensure(SubdivCCG *subdiv_ccg, int grid_index)
{
- if (subdiv_ccg->grid_hidden[grid_index] != NULL) {
+ if (subdiv_ccg->grid_hidden[grid_index] != nullptr) {
return;
}
diff --git a/source/blender/blenkernel/intern/subdiv_modifier.c b/source/blender/blenkernel/intern/subdiv_modifier.cc
index 2271fd90bda..a5529e9b8fa 100644
--- a/source/blender/blenkernel/intern/subdiv_modifier.c
+++ b/source/blender/blenkernel/intern/subdiv_modifier.cc
@@ -46,8 +46,8 @@ bool BKE_subsurf_modifier_runtime_init(SubsurfModifierData *smd, const bool use_
}
/* Allocate runtime data if it did not exist yet. */
- if (runtime_data == NULL) {
- runtime_data = MEM_callocN(sizeof(*runtime_data), "subsurf runtime");
+ if (runtime_data == nullptr) {
+ runtime_data = MEM_cnew<SubsurfRuntimeData>(__func__);
smd->modifier.runtime = runtime_data;
}
runtime_data->settings = settings;
@@ -58,7 +58,7 @@ static ModifierData *modifier_get_last_enabled_for_mode(const Scene *scene,
const Object *ob,
int required_mode)
{
- ModifierData *md = ob->modifiers.last;
+ ModifierData *md = static_cast<ModifierData *>(ob->modifiers.last);
while (md) {
if (BKE_modifier_is_enabled(scene, md, required_mode)) {
@@ -83,7 +83,7 @@ static bool subsurf_modifier_use_autosmooth_or_split_normals(const SubsurfModifi
return (mesh->flag & ME_AUTOSMOOTH) || BKE_subsurf_modifier_use_custom_loop_normals(smd, mesh);
}
-static bool is_subdivision_evaluation_possible_on_gpu(void)
+static bool is_subdivision_evaluation_possible_on_gpu()
{
/* Only OpenGL is supported for OpenSubdiv evaluation for now. */
if (GPU_backend_get_type() != GPU_BACKEND_OPENGL) {
@@ -147,7 +147,7 @@ bool BKE_subsurf_modifier_has_gpu_subdiv(const Mesh *mesh)
return runtime_data && runtime_data->has_gpu_subdiv;
}
-void (*BKE_subsurf_modifier_free_gpu_cache_cb)(Subdiv *subdiv) = NULL;
+void (*BKE_subsurf_modifier_free_gpu_cache_cb)(Subdiv *subdiv) = nullptr;
Subdiv *BKE_subsurf_modifier_subdiv_descriptor_ensure(SubsurfRuntimeData *runtime_data,
const Mesh *mesh,
@@ -155,7 +155,7 @@ Subdiv *BKE_subsurf_modifier_subdiv_descriptor_ensure(SubsurfRuntimeData *runtim
{
if (runtime_data->subdiv && runtime_data->set_by_draw_code != for_draw_code) {
BKE_subdiv_free(runtime_data->subdiv);
- runtime_data->subdiv = NULL;
+ runtime_data->subdiv = nullptr;
}
Subdiv *subdiv = BKE_subdiv_update_from_mesh(
runtime_data->subdiv, &runtime_data->settings, mesh);
@@ -170,5 +170,5 @@ int BKE_subsurf_modifier_eval_required_mode(bool is_final_render, bool is_edit_m
return eModifierMode_Render;
}
- return eModifierMode_Realtime | (is_edit_mode ? eModifierMode_Editmode : 0);
+ return eModifierMode_Realtime | (is_edit_mode ? int(eModifierMode_Editmode) : 0);
}
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index c6efe235172..3748c6a053c 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -2660,9 +2660,9 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width,
if (from_anchor) {
for (int a = 0; a < 5; a++) {
src_pixel_x[a] += (double)((track->offset[0] * frame_width) -
- ((int)(track->offset[0] * frame_width)));
+ (int)(track->offset[0] * frame_width));
src_pixel_y[a] += (double)((track->offset[1] * frame_height) -
- ((int)(track->offset[1] * frame_height)));
+ (int)(track->offset[1] * frame_height));
/* when offset is negative, rounding happens in opposite direction */
if (track->offset[0] < 0.0f) {
diff --git a/source/blender/blenkernel/intern/vfont.c b/source/blender/blenkernel/intern/vfont.c
index 0e04da246fc..7ace1a3aa3b 100644
--- a/source/blender/blenkernel/intern/vfont.c
+++ b/source/blender/blenkernel/intern/vfont.c
@@ -1044,7 +1044,7 @@ static bool vfont_to_curve(Object *ob,
CLAMP_MIN(maxlen, lineinfo[lnr].x_min);
- if ((tb_scale.h != 0.0f) && ((-(yof - tb_scale.y)) > (tb_scale.h - linedist) - yof_scale)) {
+ if ((tb_scale.h != 0.0f) && (-(yof - tb_scale.y) > (tb_scale.h - linedist) - yof_scale)) {
if (cu->totbox > (curbox + 1)) {
maxlen = 0;
curbox++;
@@ -1175,7 +1175,7 @@ static bool vfont_to_curve(Object *ob,
}
}
for (i = 0; i <= slen; i++) {
- for (j = i; (!ELEM(mem[j], '\0', '\n')) && (chartransdata[j].dobreak == 0) && (j < slen);
+ for (j = i; !ELEM(mem[j], '\0', '\n') && (chartransdata[j].dobreak == 0) && (j < slen);
j++) {
/* do nothing */
}
diff --git a/source/blender/blenkernel/intern/vfontdata_freetype.c b/source/blender/blenkernel/intern/vfontdata_freetype.c
index 91ca3100f8c..9fe83ce7aa0 100644
--- a/source/blender/blenkernel/intern/vfontdata_freetype.c
+++ b/source/blender/blenkernel/intern/vfontdata_freetype.c
@@ -34,10 +34,6 @@
#include "DNA_packedFile_types.h"
#include "DNA_vfont_types.h"
-/* local variables */
-static FT_Library library;
-static FT_Error err;
-
static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vfd)
{
const float scale = vfd->scale;
@@ -60,7 +56,7 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *
*
* Get the FT Glyph index and load the Glyph */
glyph_index = FT_Get_Char_Index(face, charcode);
- err = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP);
+ FT_Error err = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP);
/* If loading succeeded, convert the FT glyph to the internal format */
if (!err) {
@@ -240,7 +236,7 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *
return NULL;
}
-static VChar *objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode)
+static VChar *objchr_to_ftvfontdata(FT_Library library, VFont *vfont, FT_ULong charcode)
{
VChar *che;
@@ -249,13 +245,13 @@ static VChar *objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode)
/* Load the font to memory */
if (vfont->temp_pf) {
- err = FT_New_Memory_Face(library, vfont->temp_pf->data, vfont->temp_pf->size, 0, &face);
+ FT_Error err = FT_New_Memory_Face(
+ library, vfont->temp_pf->data, vfont->temp_pf->size, 0, &face);
if (err) {
return NULL;
}
}
else {
- err = true;
return NULL;
}
@@ -266,30 +262,22 @@ static VChar *objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode)
return che;
}
-static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
+static FT_Face vfont_face_load_from_packed_file(FT_Library library, PackedFile *pf)
{
- /* Variables */
- FT_Face face;
- VFontData *vfd;
-
- /* load the freetype font */
- err = FT_New_Memory_Face(library, pf->data, pf->size, 0, &face);
-
- if (err) {
+ FT_Face face = NULL;
+ FT_New_Memory_Face(library, pf->data, pf->size, 0, &face);
+ if (!face) {
return NULL;
}
- /* allocate blender font */
- vfd = MEM_callocN(sizeof(*vfd), "FTVFontData");
-
- /* Get the name. */
- if (face->family_name) {
- BLI_snprintf(vfd->name, sizeof(vfd->name), "%s %s", face->family_name, face->style_name);
- BLI_str_utf8_invalid_strip(vfd->name, strlen(vfd->name));
+ /* Font must contain vectors, not bitmaps. */
+ if (!(face->face_flags & FT_FACE_FLAG_SCALABLE)) {
+ FT_Done_Face(face);
+ return NULL;
}
/* Select a character map. */
- err = FT_Select_Charmap(face, FT_ENCODING_UNICODE);
+ FT_Error err = FT_Select_Charmap(face, FT_ENCODING_UNICODE);
if (err) {
err = FT_Select_Charmap(face, FT_ENCODING_APPLE_ROMAN);
}
@@ -298,10 +286,43 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
}
if (err) {
FT_Done_Face(face);
- MEM_freeN(vfd);
return NULL;
}
+ /* Test that we can load glyphs from this font. */
+ FT_UInt glyph_index = 0;
+ FT_Get_First_Char(face, &glyph_index);
+ if (!glyph_index ||
+ FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP) != FT_Err_Ok) {
+ FT_Done_Face(face);
+ return NULL;
+ }
+
+ return face;
+}
+
+VFontData *BKE_vfontdata_from_freetypefont(PackedFile *pf)
+{
+ FT_Library library = NULL;
+ if (FT_Init_FreeType(&library) != FT_Err_Ok) {
+ return NULL;
+ }
+
+ FT_Face face = vfont_face_load_from_packed_file(library, pf);
+ if (!face) {
+ FT_Done_FreeType(library);
+ return NULL;
+ }
+
+ /* allocate blender font */
+ VFontData *vfd = MEM_callocN(sizeof(*vfd), "FTVFontData");
+
+ /* Get the name. */
+ if (face->family_name) {
+ BLI_snprintf(vfd->name, sizeof(vfd->name), "%s %s", face->family_name, face->style_name);
+ BLI_str_utf8_invalid_strip(vfd->name, strlen(vfd->name));
+ }
+
/* Blender default BFont is not "complete". */
const bool complete_font = (face->ascender != 0) && (face->descender != 0) &&
(face->ascender != face->descender);
@@ -344,50 +365,6 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
freetypechar_to_vchar(face, charcode, vfd);
}
- return vfd;
-}
-
-static bool check_freetypefont(PackedFile *pf)
-{
- FT_Face face = NULL;
- FT_UInt glyph_index = 0;
- bool success = false;
-
- err = FT_New_Memory_Face(library, pf->data, pf->size, 0, &face);
- if (err) {
- return false;
- // XXX error("This is not a valid font");
- }
-
- FT_Get_First_Char(face, &glyph_index);
- if (glyph_index) {
- err = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP);
- if (!err) {
- success = (face->glyph->format == ft_glyph_format_outline);
- }
- }
-
- FT_Done_Face(face);
-
- return success;
-}
-
-VFontData *BKE_vfontdata_from_freetypefont(PackedFile *pf)
-{
- VFontData *vfd = NULL;
-
- /* init Freetype */
- err = FT_Init_FreeType(&library);
- if (err) {
- /* XXX error("Failed to load the Freetype font library"); */
- return NULL;
- }
-
- if (check_freetypefont(pf)) {
- vfd = objfnt_to_ftvfontdata(pf);
- }
-
- /* free Freetype */
FT_Done_FreeType(library);
return vfd;
@@ -419,14 +396,15 @@ VChar *BKE_vfontdata_char_from_freetypefont(VFont *vfont, ulong character)
}
/* Init Freetype */
- err = FT_Init_FreeType(&library);
+ FT_Library library = NULL;
+ FT_Error err = FT_Init_FreeType(&library);
if (err) {
/* XXX error("Failed to load the Freetype font library"); */
return NULL;
}
/* Load the character */
- che = objchr_to_ftvfontdata(vfont, character);
+ che = objchr_to_ftvfontdata(library, vfont, character);
/* Free Freetype */
FT_Done_FreeType(library);