[Bf-blender-cvs] [b6a1af07b4d] soc-2019-fast-io: [Fast import/export] Small refactoring to consistently use size_t isntead of ulong
Hugo Sales
noreply at git.blender.org
Thu Jul 11 11:43:20 CEST 2019
Commit: b6a1af07b4dbd8836c0c0cfb3c7ec5e1be93001c
Author: Hugo Sales
Date: Thu Jul 11 10:31:35 2019 +0100
Branches: soc-2019-fast-io
https://developer.blender.org/rBb6a1af07b4dbd8836c0c0cfb3c7ec5e1be93001c
[Fast import/export] Small refactoring to consistently use size_t isntead of ulong
===================================================================
M source/blender/editors/io/intern/common.hpp
M source/blender/editors/io/intern/iterators.hpp
M source/blender/editors/io/intern/obj.cpp
===================================================================
diff --git a/source/blender/editors/io/intern/common.hpp b/source/blender/editors/io/intern/common.hpp
index 641f401452c..ed2ad4a9a27 100644
--- a/source/blender/editors/io/intern/common.hpp
+++ b/source/blender/editors/io/intern/common.hpp
@@ -55,7 +55,6 @@ extern "C" {
# include <iterator>
namespace common {
-using ulong = unsigned long;
// --- PROTOTYPES ---
@@ -127,9 +126,9 @@ template<typename key_t> using set_t = std::set<key_t, threshold_comparator>;
template<typename key_t> using set_mapping_t = std::vector<typename set_t<key_t>::iterator>;
// A pair of the two above, to tie them together
template<typename key_t> using dedup_pair_t = std::pair<set_t<key_t>, set_mapping_t<key_t>>;
-// The set key for UV and normal. ulong is the original index
-using uv_key_t = std::pair<std::array<float, 2>, ulong>;
-using no_key_t = std::pair<std::array<float, 3>, ulong>;
+// The set key for UV and normal. size_t is the original index
+using uv_key_t = std::pair<std::array<float, 2>, size_t>;
+using no_key_t = std::pair<std::array<float, 3>, size_t>;
// Construct a new deduplicated set for either normals or UVs, with the given similarity threshold
// C++14/17 would be useful here...
diff --git a/source/blender/editors/io/intern/iterators.hpp b/source/blender/editors/io/intern/iterators.hpp
index b716238076c..dc84a28d5c5 100644
--- a/source/blender/editors/io/intern/iterators.hpp
+++ b/source/blender/editors/io/intern/iterators.hpp
@@ -577,13 +577,13 @@ struct deduplicated_iterator {
using iterator_category = Tag;
deduplicated_iterator(const Mesh *const mesh,
dedup_pair_t<KeyT> &dp,
- ulong &total,
+ size_t &total,
SourceIter it)
: it(it), mesh(mesh), dedup_pair(dp), total(total)
{
}
deduplicated_iterator(
- const Mesh *const mesh, dedup_pair_t<KeyT> &dp, ulong &total, ulong reserve, SourceIter it)
+ const Mesh *const mesh, dedup_pair_t<KeyT> &dp, size_t &total, size_t reserve, SourceIter it)
: deduplicated_iterator(mesh, dp, total, it)
{
// Reserve space so we don't constantly allocate
@@ -643,13 +643,13 @@ struct deduplicated_iterator {
SourceIter it;
const Mesh *const mesh;
dedup_pair_t<KeyT> &dedup_pair;
- ulong &total;
+ size_t &total;
};
// Iterator to deduplicated normals (returns `const std::array<float, 3>`)
struct deduplicated_normal_iter : deduplicated_iterator<no_key_t, transformed_normal_iter> {
deduplicated_normal_iter(const Mesh *const mesh,
- ulong &total,
+ size_t &total,
dedup_pair_t<no_key_t> &dp,
const float (*mat)[4])
: deduplicated_iterator<no_key_t, transformed_normal_iter>(
diff --git a/source/blender/editors/io/intern/obj.cpp b/source/blender/editors/io/intern/obj.cpp
index b01ec8ff1ca..98679c63b75 100644
--- a/source/blender/editors/io/intern/obj.cpp
+++ b/source/blender/editors/io/intern/obj.cpp
@@ -4,13 +4,14 @@ extern "C" {
#include "BLI_math.h"
#include "BLT_translation.h"
+#include "BKE_context.h"
+#include "BKE_customdata.h"
+#include "BKE_global.h"
+#include "BKE_library.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_mapping.h"
#include "BKE_mesh_runtime.h"
-#include "BKE_global.h"
-#include "BKE_context.h"
#include "BKE_scene.h"
-#include "BKE_library.h"
-#include "BKE_customdata.h"
#include "DNA_curve_types.h"
#include "DNA_ID.h"
@@ -214,7 +215,7 @@ bool OBJ_export_curve(bContext *UNUSED(C),
totvert += num_points;
fprintf(file, "g %s\n", common::get_object_name(eob, cu).c_str());
- fprintf(file, "cstype bspline\ndeg %lu\n", deg_order_u);
+ fprintf(file, "cstype bspline\ndeg %zu\n", deg_order_u);
size_t real_num_points = num_points;
if (closed) {
@@ -343,13 +344,14 @@ bool OBJ_export_meshes(bContext *UNUSED(C),
no = me.no_offset + l.v + 1;
}
if (settings->export_uvs && settings->export_normals && me.mesh->mloopuv != nullptr)
- fprintf(file, " %lu/%lu/%lu", vx, uv, no);
+ fprintf(file, " %zu/%zu/%zu", vx, uv, no);
else if (settings->export_uvs && me.mesh->mloopuv != nullptr)
- fprintf(file, " %lu/%lu", vx, uv);
+ fprintf(file, " %zu/%zu", vx, uv);
else if (settings->export_normals)
- fprintf(file, " %lu//%lu", vx, no);
+ fprintf(file, " %zu//%zu", vx, no);
else
- fprintf(file, " %lu", vx);
+ fprintf(file, " %zu", vx);
+ ++li;
}
fputc('\n', file);
}
More information about the Bf-blender-cvs
mailing list