[Bf-blender-cvs] [6c8f6d5c448] soc-2020-io-performance: Add float3 to string function to utilities.
Ankit Meel
noreply at git.blender.org
Sat Sep 5 14:14:37 CEST 2020
Commit: 6c8f6d5c448da1456bc80efff5691e1275c51b36
Author: Ankit Meel
Date: Fri Sep 4 01:50:18 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rB6c8f6d5c448da1456bc80efff5691e1275c51b36
Add float3 to string function to utilities.
Makes the MTL writer a bit compact. That change to be committed soon.
===================================================================
M source/blender/io/wavefront_obj/intern/string_utils.cc
M source/blender/io/wavefront_obj/intern/string_utils.hh
===================================================================
diff --git a/source/blender/io/wavefront_obj/intern/string_utils.cc b/source/blender/io/wavefront_obj/intern/string_utils.cc
index ca540f575a3..1aa4a522f18 100644
--- a/source/blender/io/wavefront_obj/intern/string_utils.cc
+++ b/source/blender/io/wavefront_obj/intern/string_utils.cc
@@ -19,6 +19,7 @@
#include <iostream>
#include <fstream>
+#include <sstream>
#include "BLI_float3.hh"
#include "BLI_span.hh"
@@ -212,4 +213,15 @@ std::string replace_all_occurences(StringRef original, StringRef to_remove, Stri
return clean;
}
+/**
+ * Converts float3 to space-separated number string with no leading or trailing space.
+ * Only to be used in NON performance-critical code.
+ */
+std::string float3_to_string(const float3 &numbers)
+{
+ std::ostringstream r_string;
+ r_string << numbers[0] << " " << numbers[1] << " " << numbers[2];
+ return r_string.str();
+};
+
} // namespace blender::io::obj
diff --git a/source/blender/io/wavefront_obj/intern/string_utils.hh b/source/blender/io/wavefront_obj/intern/string_utils.hh
index e0b9feb8e82..f8644a2bc50 100644
--- a/source/blender/io/wavefront_obj/intern/string_utils.hh
+++ b/source/blender/io/wavefront_obj/intern/string_utils.hh
@@ -29,5 +29,6 @@ void copy_string_to_float(Span<StringRef> src,
void copy_string_to_int(StringRef src, const int fallback_value, int &r_dst);
void copy_string_to_int(Span<StringRef> src, const int fallback_value, MutableSpan<int> r_dst);
std::string replace_all_occurences(StringRef original, StringRef to_remove, StringRef to_add);
+std::string float3_to_string(const float3 &numbers);
} // namespace blender::io::obj
More information about the Bf-blender-cvs
mailing list