[Bf-blender-cvs] [8268e687b04] soc-2020-io-performance: Fixed up the TODOs re materials left when making it compile again.
Howard Trickey
noreply at git.blender.org
Sun Mar 14 21:06:27 CET 2021
Commit: 8268e687b04a388379ffd3fc1f06f15b45c6e399
Author: Howard Trickey
Date: Sun Mar 14 16:05:02 2021 -0400
Branches: soc-2020-io-performance
https://developer.blender.org/rB8268e687b04a388379ffd3fc1f06f15b45c6e399
Fixed up the TODOs re materials left when making it compile again.
Also, fixed a place where a newline belonged in material output.
===================================================================
M source/blender/io/wavefront_obj/exporter/obj_export_io.hh
M source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
M source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
M source/blender/io/wavefront_obj/importer/obj_import_mtl.hh
===================================================================
diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_io.hh b/source/blender/io/wavefront_obj/exporter/obj_export_io.hh
index a51e94a38e5..a173fe4b268 100644
--- a/source/blender/io/wavefront_obj/exporter/obj_export_io.hh
+++ b/source/blender/io/wavefront_obj/exporter/obj_export_io.hh
@@ -222,7 +222,7 @@ syntax_elem_to_formatting(const eMTLSyntaxElement key)
return {"Ns %.6f\n", 1, is_type_float<T...>};
}
case eMTLSyntaxElement::illum: {
- return {"illum %d", 1, is_type_integral<T...>};
+ return {"illum %d\n", 1, is_type_integral<T...>};
}
case eMTLSyntaxElement::Ka: {
return {"Ka %.6f %.6f %.6f\n", 3, is_type_float<T...>};
@@ -287,7 +287,7 @@ template<eFileType filetype> class FileHandler : NonCopyable, NonMovable {
}
template<typename FileTypeTraits<filetype>::SyntaxType key, typename... T>
- constexpr void write(T &&... args) const
+ constexpr void write(T &&...args) const
{
constexpr Formatting<filetype> fmt_nargs_valid = syntax_elem_to_formatting<filetype, T...>(
key);
@@ -328,13 +328,13 @@ template<eFileType filetype> class FileHandler : NonCopyable, NonMovable {
template<int total_args, typename... T>
constexpr std::enable_if_t<(total_args != 0), void> write__impl(const char *fmt,
- T &&... args) const
+ T &&...args) const
{
std::fprintf(outfile_, fmt, string_to_primitive(std::forward<T>(args))...);
}
template<int total_args, typename... T>
constexpr std::enable_if_t<(total_args == 0), void> write__impl(const char *fmt,
- T &&... args) const
+ T &&...args) const
{
std::fputs(fmt, outfile_);
}
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
index 74950f8f34e..8e59d0cf119 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
@@ -550,13 +550,14 @@ void MTLParser::parse_and_store(Map<string, std::unique_ptr<MTLMaterial>> &r_mtl
/* Parse image textures. */
else if (line_key.find("map_") != StringRef::not_found) {
/* TODO howardt: fix this */
-#if 0
- if (!current_mtlmaterial->texture_maps.contains_as(string(line_key))) {
+ eMTLSyntaxElement line_key_enum = mtl_line_key_str_to_enum(line_key);
+ if (line_key_enum == eMTLSyntaxElement::string ||
+ !current_mtlmaterial->texture_maps.contains_as(line_key_enum)) {
/* No supported texture map found. */
std::cerr << "Texture map type not supported:'" << line_key << "'" << std::endl;
continue;
}
- tex_map_XX &tex_map = current_mtlmaterial->texture_maps.lookup(string(line_key));
+ tex_map_XX &tex_map = current_mtlmaterial->texture_maps.lookup(line_key_enum);
Vector<StringRef> str_map_xx_split;
split_by_char(rest_line, ' ', str_map_xx_split);
@@ -596,7 +597,6 @@ void MTLParser::parse_and_store(Map<string, std::unique_ptr<MTLMaterial>> &r_mtl
/* Skip all unsupported options and arguments. */
tex_map.image_path = string(skip_unsupported_options(rest_line));
tex_map.mtl_dir_path = mtl_dir_path_;
-#endif
}
}
}
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
index 87f217041d2..c143595da89 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
@@ -41,6 +41,7 @@
#include "bmesh_tools.h"
#include "DNA_customdata_types.h"
+#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
@@ -382,12 +383,9 @@ void MeshFromGeometry::create_materials(
const MTLMaterial &curr_mat = *materials.lookup_as(material_name);
ShaderNodetreeWrap mat_wrap{bmain, curr_mat};
-/* TODO howardt: fix this. */
-#if 0
mat->use_nodes = true;
mat->nodetree = mat_wrap.get_nodetree();
ntreeUpdateTree(bmain, mat->nodetree);
-#endif
}
}
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mtl.hh b/source/blender/io/wavefront_obj/importer/obj_import_mtl.hh
index e701cc85d25..c59b9c8d245 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_mtl.hh
+++ b/source/blender/io/wavefront_obj/importer/obj_import_mtl.hh
@@ -86,4 +86,30 @@ class ShaderNodetreeWrap {
void set_bsdf_socket_values();
void add_image_textures(Main *bmain);
};
-} // namespace blender::io::obj
+
+constexpr eMTLSyntaxElement mtl_line_key_str_to_enum(const std::string_view key_str)
+{
+ if (key_str == "map_Kd") {
+ return eMTLSyntaxElement::map_Kd;
+ }
+ if (key_str == "map_Ks") {
+ return eMTLSyntaxElement::map_Ks;
+ }
+ if (key_str == "map_Ns") {
+ return eMTLSyntaxElement::map_Ns;
+ }
+ if (key_str == "map_d") {
+ return eMTLSyntaxElement::map_d;
+ }
+ if (key_str == "refl" || key_str == "map_refl") {
+ return eMTLSyntaxElement::map_refl;
+ }
+ if (key_str == "map_Ke") {
+ return eMTLSyntaxElement::map_Ke;
+ }
+ if (key_str == "map_Bump" || key_str == "bump") {
+ return eMTLSyntaxElement::map_Bump;
+ }
+ return eMTLSyntaxElement::string;
+}
+} // namespace blender::io::obj
\ No newline at end of file
More information about the Bf-blender-cvs
mailing list