[Bf-blender-cvs] [bc52869756e] soc-2020-io-performance: Cleanup: const, renames, remove single use variables.
Ankit Meel
noreply at git.blender.org
Wed Nov 11 15:37:39 CET 2020
Commit: bc52869756ed734ea7866abfd4e3e6254a5e2270
Author: Ankit Meel
Date: Tue Nov 10 20:06:41 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rBbc52869756ed734ea7866abfd4e3e6254a5e2270
Cleanup: const, renames, remove single use variables.
===================================================================
M source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc
M source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc
M source/blender/io/wavefront_obj/exporter/obj_export_mtl.hh
===================================================================
diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc
index 59fb1f56b44..b944f642837 100644
--- a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc
+++ b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc
@@ -353,7 +353,7 @@ void OBJWriter::write_poly_elements(const OBJMesh &obj_mesh_data)
int16_t last_poly_vertex_group = NEGATIVE_INIT;
int16_t last_poly_mat_nr = NEGATIVE_INIT;
- func_vert_uv_normal_indices poly_element_writer = get_poly_element_writer(obj_mesh_data);
+ const func_vert_uv_normal_indices poly_element_writer = get_poly_element_writer(obj_mesh_data);
/* Number of normals may not be equal to number of polygons due to smooth shading. */
int per_object_tot_normals = 0;
diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc
index c1cdec234d6..7ee2b0b6b44 100644
--- a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc
+++ b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc
@@ -92,6 +92,7 @@ static void linked_sockets_to_dest_id(const bNode *dest_node,
StringRefNull dest_socket_id,
Vector<const nodes::OutputSocketRef *> &r_linked_sockets)
{
+ r_linked_sockets.clear();
if (!dest_node) {
return;
}
@@ -109,21 +110,18 @@ static void linked_sockets_to_dest_id(const bNode *dest_node,
r_linked_sockets.resize(linked_sockets.size());
r_linked_sockets = linked_sockets;
}
- else {
- r_linked_sockets.clear();
- }
}
/**
* From a list of sockets, get the parent node which is of the given node type.
*/
static const bNode *get_node_of_type(Span<const nodes::OutputSocketRef *> sockets_list,
- const int sh_node_type)
+ const int node_type)
{
- for (const nodes::SocketRef *sock : sockets_list) {
- const bNode *curr_node = sock->bnode();
- if (curr_node->typeinfo->type == sh_node_type) {
- return curr_node;
+ for (const nodes::SocketRef *socket : sockets_list) {
+ const bNode *parent_node = socket->bnode();
+ if (parent_node->typeinfo->type == node_type) {
+ return parent_node;
}
}
return nullptr;
@@ -167,11 +165,10 @@ void MaterialWrap::init_bsdf_node(StringRefNull object_name)
fprintf(stderr,
"No Principled-BSDF node found in the shader node tree of: '%s'.\n",
object_name.c_str());
- bsdf_node_ = nullptr;
return;
}
ListBase *nodes = &export_mtl_->nodetree->nodes;
- LISTBASE_FOREACH (bNode *, curr_node, nodes) {
+ LISTBASE_FOREACH (const bNode *, curr_node, nodes) {
if (curr_node->typeinfo->type == SH_NODE_BSDF_PRINCIPLED) {
bsdf_node_ = curr_node;
return;
@@ -180,7 +177,6 @@ void MaterialWrap::init_bsdf_node(StringRefNull object_name)
fprintf(stderr,
"No Principled-BSDF node found in the shader node tree of: '%s'.\n",
object_name.c_str());
- bsdf_node_ = nullptr;
}
/**
@@ -302,21 +298,16 @@ void MaterialWrap::store_image_textures(MTLMaterial &r_mtl_mat) const
linked_sockets_to_dest_id(tex_node, node_tree, "Vector", linked_sockets);
const bNode *mapping = get_node_of_type(linked_sockets, SH_NODE_MAPPING);
- /* Texture transform options. Only translation (origin offset, "-o") and scale
- * ("-o") are supported. */
- float3 map_translation{0.0f};
- float3 map_scale{1.0f};
- float normal_map_strength = -1.0f;
if (normal_map_node) {
- copy_property_from_node(SOCK_FLOAT, normal_map_node, "Strength", {&normal_map_strength, 1});
+ copy_property_from_node(
+ SOCK_FLOAT, normal_map_node, "Strength", {&r_mtl_mat.map_Bump_strength, 1});
}
- copy_property_from_node(SOCK_VECTOR, mapping, "Location", {map_translation, 3});
- copy_property_from_node(SOCK_VECTOR, mapping, "Scale", {map_scale, 3});
+ /* Texture transform options. Only translation (origin offset, "-o") and scale
+ * ("-o") are supported. */
+ copy_property_from_node(SOCK_VECTOR, mapping, "Location", {texture_map.value.translation, 3});
+ copy_property_from_node(SOCK_VECTOR, mapping, "Scale", {texture_map.value.scale, 3});
- texture_map.value.scale = map_scale;
- texture_map.value.translation = map_translation;
texture_map.value.image_path = tex_image_filepath;
- r_mtl_mat.map_Bump_strength = normal_map_strength;
}
}
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 4b2648fbd53..89de626fb4b 100644
--- a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.hh
+++ b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.hh
@@ -104,7 +104,7 @@ class MaterialWrap {
/**
* First Principled-BSDF node encountered in the object's node tree.
*/
- bNode *bsdf_node_ = nullptr;
+ const bNode *bsdf_node_ = nullptr;
public:
Vector<MTLMaterial> fill_materials(const OBJMesh &obj_mesh_data);
More information about the Bf-blender-cvs
mailing list