[Bf-blender-cvs] [b99246c613a] soc-2020-io-performance: Early return in a few places.
Ankit Meel
noreply at git.blender.org
Wed Sep 16 13:05:53 CEST 2020
Commit: b99246c613afe04fddc68af0fe938b4788690ebe
Author: Ankit Meel
Date: Wed Sep 16 11:33:24 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rBb99246c613afe04fddc68af0fe938b4788690ebe
Early return in a few places.
Fix two consecutive group name `g ...` lines by adding an `else`.
===================================================================
M source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc
M source/blender/io/wavefront_obj/intern/obj_export_mtl.cc
===================================================================
diff --git a/source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc b/source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc
index 8364674bac4..6bbe5e5422c 100644
--- a/source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc
+++ b/source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc
@@ -149,16 +149,18 @@ void OBJWriter::write_object_name(const OBJMesh &obj_mesh_data) const
{
const char *object_name = obj_mesh_data.get_object_name();
- if (export_params_.export_object_groups) {
+ if (!export_params_.export_object_groups) {
+ fprintf(outfile_, "o %s\n", object_name);
+ }
+ else {
const char *object_mesh_name = obj_mesh_data.get_object_mesh_name();
if (export_params_.export_materials && export_params_.export_material_groups) {
const char *object_material_name = obj_mesh_data.get_object_material_name(0);
fprintf(outfile_, "g %s_%s_%s\n", object_name, object_mesh_name, object_material_name);
}
- fprintf(outfile_, "g %s_%s\n", object_name, object_mesh_name);
- }
- else {
- fprintf(outfile_, "o %s\n", object_name);
+ else {
+ fprintf(outfile_, "g %s_%s\n", object_name, object_mesh_name);
+ }
}
}
diff --git a/source/blender/io/wavefront_obj/intern/obj_export_mtl.cc b/source/blender/io/wavefront_obj/intern/obj_export_mtl.cc
index 3154cca5f71..d440f63b109 100644
--- a/source/blender/io/wavefront_obj/intern/obj_export_mtl.cc
+++ b/source/blender/io/wavefront_obj/intern/obj_export_mtl.cc
@@ -136,26 +136,26 @@ static const bNode *get_node_of_type(Span<const nodes::OutputSocketRef *> socket
*/
static const char *get_image_filepath(const bNode *tex_node)
{
- if (tex_node) {
- Image *tex_image = reinterpret_cast<Image *>(tex_node->id);
- if (!tex_image || !BKE_image_has_filepath(tex_image)) {
- return nullptr;
- }
- const char *path = tex_image->filepath;
- if (BKE_image_has_packedfile(tex_image)) {
- /* Put image in the same directory as the MTL file. */
- path = BLI_path_slash_rfind(path) + 1;
- fprintf(stderr,
- "Packed image found:'%s'. Unpack and place the image in the same "
- "directory as the MTL file.\n",
- path);
- }
- if (path[0] == '/' && path[1] == '/') {
- path += 2;
- }
- return path;
+ if (!tex_node) {
+ return nullptr;
}
- return nullptr;
+ Image *tex_image = reinterpret_cast<Image *>(tex_node->id);
+ if (!tex_image || !BKE_image_has_filepath(tex_image)) {
+ return nullptr;
+ }
+ const char *path = tex_image->filepath;
+ if (BKE_image_has_packedfile(tex_image)) {
+ /* Put image in the same directory as the MTL file. */
+ path = BLI_path_slash_rfind(path) + 1;
+ fprintf(stderr,
+ "Packed image found:'%s'. Unpack and place the image in the same "
+ "directory as the MTL file.\n",
+ path);
+ }
+ if (path[0] == '/' && path[1] == '/') {
+ path += 2;
+ }
+ return path;
}
/**
@@ -282,6 +282,10 @@ void MaterialWrap::store_image_textures(MTLMaterial &r_mtl_mat) const
if (!tex_node) {
continue;
}
+ const char *tex_image_filepath = get_image_filepath(tex_node);
+ if (!tex_image_filepath) {
+ continue;
+ }
/* Find "Mapping" node if connected to texture node. */
linked_sockets_to_dest_id(linked_sockets, tex_node, node_tree, "Vector");
@@ -297,10 +301,6 @@ void MaterialWrap::store_image_textures(MTLMaterial &r_mtl_mat) const
}
copy_property_from_node({map_translation, 3}, SOCK_VECTOR, mapping, "Location");
copy_property_from_node({map_scale, 3}, SOCK_VECTOR, mapping, "Scale");
- const char *tex_image_filepath = get_image_filepath(tex_node);
- if (!tex_image_filepath) {
- continue;
- }
texture_map.value.scale = map_scale;
texture_map.value.translation = map_translation;
More information about the Bf-blender-cvs
mailing list