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:
Diffstat (limited to 'source/blender/io/wavefront_obj/exporter/obj_export_mtl.hh')
-rw-r--r--source/blender/io/wavefront_obj/exporter/obj_export_mtl.hh46
1 files changed, 10 insertions, 36 deletions
diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.hh b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.hh
index f83b3b49bf5..d8eafff107b 100644
--- a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.hh
+++ b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.hh
@@ -6,36 +6,23 @@
#pragma once
-#include "BLI_map.hh"
#include "BLI_math_vec_types.hh"
#include "DNA_node_types.h"
-#include "obj_export_io.hh"
-
-namespace blender {
-template<> struct DefaultHash<io::obj::eMTLSyntaxElement> {
- uint64_t operator()(const io::obj::eMTLSyntaxElement value) const
- {
- return static_cast<uint64_t>(value);
- }
-};
-
-} // namespace blender
+struct Material;
namespace blender::io::obj {
-/**
- * Generic container for texture node properties.
- */
-struct tex_map_XX {
- tex_map_XX(StringRef to_socket_id) : dest_socket_id(to_socket_id){};
+enum class MTLTexMapType { Kd = 0, Ks, Ns, d, refl, Ke, bump, Count };
+extern const char *tex_map_type_to_socket_id[];
+
+struct MTLTexMap {
bool is_valid() const
{
return !image_path.empty();
}
/* Target socket which this texture node connects to. */
- const std::string dest_socket_id;
float3 translation{0.0f};
float3 scale{1.0f};
/* Only Flat and Sphere projections are supported. */
@@ -48,26 +35,13 @@ struct tex_map_XX {
* Container suited for storing Material data for/from a .MTL file.
*/
struct MTLMaterial {
- MTLMaterial()
- {
- texture_maps.add(eMTLSyntaxElement::map_Kd, tex_map_XX("Base Color"));
- texture_maps.add(eMTLSyntaxElement::map_Ks, tex_map_XX("Specular"));
- texture_maps.add(eMTLSyntaxElement::map_Ns, tex_map_XX("Roughness"));
- texture_maps.add(eMTLSyntaxElement::map_d, tex_map_XX("Alpha"));
- texture_maps.add(eMTLSyntaxElement::map_refl, tex_map_XX("Metallic"));
- texture_maps.add(eMTLSyntaxElement::map_Ke, tex_map_XX("Emission"));
- texture_maps.add(eMTLSyntaxElement::map_Bump, tex_map_XX("Normal"));
- }
-
- const tex_map_XX &tex_map_of_type(const eMTLSyntaxElement key) const
+ const MTLTexMap &tex_map_of_type(MTLTexMapType key) const
{
- BLI_assert(texture_maps.contains(key));
- return texture_maps.lookup(key);
+ return texture_maps[(int)key];
}
- tex_map_XX &tex_map_of_type(const eMTLSyntaxElement key)
+ MTLTexMap &tex_map_of_type(MTLTexMapType key)
{
- BLI_assert(texture_maps.contains(key));
- return texture_maps.lookup(key);
+ return texture_maps[(int)key];
}
std::string name;
@@ -81,7 +55,7 @@ struct MTLMaterial {
float Ni{-1.0f};
float d{-1.0f};
int illum{-1};
- Map<const eMTLSyntaxElement, tex_map_XX> texture_maps;
+ MTLTexMap texture_maps[(int)MTLTexMapType::Count];
/** Only used for Normal Map node: "map_Bump". */
float map_Bump_strength{-1.0f};
};