[Bf-blender-cvs] [85b12341072] soc-2020-io-performance: Minor fixes, clang-tidy warnings.
Ankit Meel
noreply at git.blender.org
Thu Sep 3 12:42:52 CEST 2020
Commit: 85b12341072742be5eb4d0b4f78bbe1938c07bb1
Author: Ankit Meel
Date: Thu Sep 3 16:07:21 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rB85b12341072742be5eb4d0b4f78bbe1938c07bb1
Minor fixes, clang-tidy warnings.
===================================================================
M source/blender/io/wavefront_obj/intern/mesh_utils.cc
M source/blender/io/wavefront_obj/intern/obj_import_mesh.cc
M source/blender/io/wavefront_obj/intern/obj_import_mtl.cc
M source/blender/io/wavefront_obj/intern/obj_import_mtl.hh
M source/blender/io/wavefront_obj/intern/obj_import_nurbs.cc
===================================================================
diff --git a/source/blender/io/wavefront_obj/intern/mesh_utils.cc b/source/blender/io/wavefront_obj/intern/mesh_utils.cc
index 98888d4914d..8e23c5c0d8a 100644
--- a/source/blender/io/wavefront_obj/intern/mesh_utils.cc
+++ b/source/blender/io/wavefront_obj/intern/mesh_utils.cc
@@ -38,7 +38,7 @@ namespace blender::io::obj {
static float manhatten_len(const float3 coord)
{
- return abs(coord[0]) + abs(coord[1]) + abs(coord[2]);
+ return std::abs(coord[0]) + std::abs(coord[1]) + std::abs(coord[2]);
}
struct vert_treplet {
@@ -101,7 +101,6 @@ static void tessellate_polygon(const Vector<Vector<float3>> &polyLineSeq,
int64_t totpoints = 0;
/* Display #ListBase. */
ListBase dispbase = {NULL, NULL};
- DispList *dl;
const int64_t len_polylines{polyLineSeq.size()};
for (int i = 0; i < len_polylines; i++) {
@@ -112,7 +111,7 @@ static void tessellate_polygon(const Vector<Vector<float3>> &polyLineSeq,
if (len_polypoints <= 0) { /* don't bother adding edges as polylines */
continue;
}
- dl = static_cast<DispList *>(MEM_callocN(sizeof(DispList), __func__));
+ DispList *dl = static_cast<DispList *>(MEM_callocN(sizeof(DispList), __func__));
BLI_addtail(&dispbase, dl);
dl->type = DL_INDEX3;
dl->nr = len_polypoints;
@@ -133,7 +132,7 @@ static void tessellate_polygon(const Vector<Vector<float3>> &polyLineSeq,
/* The faces are stored in a new DisplayList
* that's added to the head of the #ListBase. */
- dl = static_cast<DispList *>(dispbase.first);
+ const DispList *dl = static_cast<DispList *>(dispbase.first);
for (int index = 0, *dl_face = dl->index; index < dl->parts; index++, dl_face += 3) {
r_new_line_seq.append({dl_face[0], dl_face[1], dl_face[2]});
diff --git a/source/blender/io/wavefront_obj/intern/obj_import_mesh.cc b/source/blender/io/wavefront_obj/intern/obj_import_mesh.cc
index 4877afb34c3..893517f5b0e 100644
--- a/source/blender/io/wavefront_obj/intern/obj_import_mesh.cc
+++ b/source/blender/io/wavefront_obj/intern/obj_import_mesh.cc
@@ -377,9 +377,9 @@ void MeshFromGeometry::create_materials(
BKE_object_material_slot_add(bmain, mesh_object_.get());
Material *mat = BKE_material_add(bmain, material_name.data());
BKE_object_material_assign(
- bmain, mesh_object_.get(), mat, mesh_object_.get()->totcol, BKE_MAT_ASSIGN_USERPREF);
+ bmain, mesh_object_.get(), mat, mesh_object_->totcol, BKE_MAT_ASSIGN_USERPREF);
- const MTLMaterial &curr_mat = *materials.lookup_as(material_name).get();
+ const MTLMaterial &curr_mat = *materials.lookup_as(material_name);
ShaderNodetreeWrap mat_wrap{bmain, curr_mat};
mat->use_nodes = true;
mat->nodetree = mat_wrap.get_nodetree();
diff --git a/source/blender/io/wavefront_obj/intern/obj_import_mtl.cc b/source/blender/io/wavefront_obj/intern/obj_import_mtl.cc
index bb932a3cc85..27142e77a8f 100644
--- a/source/blender/io/wavefront_obj/intern/obj_import_mtl.cc
+++ b/source/blender/io/wavefront_obj/intern/obj_import_mtl.cc
@@ -181,7 +181,7 @@ bNode *ShaderNodetreeWrap::add_node_to_tree(const int node_type)
* Return x-y coordinates for a node where y is determined by other nodes present in
* the same vertical column.
*/
-std::tuple<float, float> ShaderNodetreeWrap::set_node_locations(const int pos_x)
+std::pair<float, float> ShaderNodetreeWrap::set_node_locations(const int pos_x)
{
int pos_y = 0;
bool found = false;
@@ -197,7 +197,7 @@ std::tuple<float, float> ShaderNodetreeWrap::set_node_locations(const int pos_x)
}
if (!found) {
node_locations.append({pos_x, pos_y});
- return std::make_tuple(pos_x * node_size, pos_y * node_size * 2 / 3);
+ return {pos_x * node_size_, pos_y * node_size_ * 2.0 / 3.0};
}
}
}
diff --git a/source/blender/io/wavefront_obj/intern/obj_import_mtl.hh b/source/blender/io/wavefront_obj/intern/obj_import_mtl.hh
index 9a38663ca97..2765e07c2a4 100644
--- a/source/blender/io/wavefront_obj/intern/obj_import_mtl.hh
+++ b/source/blender/io/wavefront_obj/intern/obj_import_mtl.hh
@@ -129,7 +129,7 @@ class ShaderNodetreeWrap {
private:
bNode *add_node_to_tree(const int node_type);
- std::tuple<float, float> set_node_locations(const int pos_x);
+ std::pair<float, float> set_node_locations(const int pos_x);
void link_sockets(unique_node_ptr from_node,
StringRef from_node_id,
bNode *to_node,
diff --git a/source/blender/io/wavefront_obj/intern/obj_import_nurbs.cc b/source/blender/io/wavefront_obj/intern/obj_import_nurbs.cc
index a02b5460133..904c2636732 100644
--- a/source/blender/io/wavefront_obj/intern/obj_import_nurbs.cc
+++ b/source/blender/io/wavefront_obj/intern/obj_import_nurbs.cc
@@ -83,7 +83,8 @@ void CurveFromGeometry::create_nurbs(const OBJImportParams &import_params)
nurb->pntsu = 0;
/* Total points = pntsu * pntsv. */
nurb->pntsv = 1;
- nurb->orderu = nurb->orderv = nurbs_geometry.degree + 1;
+ nurb->orderu = nurb->orderv = (nurbs_geometry.degree + 1 > SHRT_MAX) ? 4 :
+ nurbs_geometry.degree + 1;
nurb->resolu = nurb->resolv = blender_curve_->resolu;
const int64_t tot_vert{curve_geometry_.nurbs_elem().curv_indices.size()};
More information about the Bf-blender-cvs
mailing list