diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/collada/ImageExporter.cpp | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/collada/ImageExporter.cpp')
-rw-r--r-- | source/blender/collada/ImageExporter.cpp | 171 |
1 files changed, 87 insertions, 84 deletions
diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index a36abc6165d..1a5c42aee52 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -18,7 +18,6 @@ * \ingroup collada */ - #include "COLLADABUURI.h" #include "COLLADASWImage.h" @@ -43,123 +42,127 @@ extern "C" { #include "ImageExporter.h" #include "MaterialExporter.h" - -ImagesExporter::ImagesExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings, KeyImageMap &key_image_map) : - COLLADASW::LibraryImages(sw), - export_settings(export_settings), - key_image_map(key_image_map) +ImagesExporter::ImagesExporter(COLLADASW::StreamWriter *sw, + const ExportSettings *export_settings, + KeyImageMap &key_image_map) + : COLLADASW::LibraryImages(sw), export_settings(export_settings), key_image_map(key_image_map) { - /* pass */ + /* pass */ } void ImagesExporter::export_UV_Image(Image *image, bool use_copies) { - std::string name(id_name(image)); - std::string translated_name(translate_id(name)); - - ImBuf *imbuf = BKE_image_acquire_ibuf(image, NULL, NULL); - if (!imbuf) { - fprintf(stderr, "Collada export: image does not exist:\n%s\n", image->name); - return; - } + std::string name(id_name(image)); + std::string translated_name(translate_id(name)); - bool is_dirty = (imbuf->userflags & IB_BITMAPDIRTY) != 0; + ImBuf *imbuf = BKE_image_acquire_ibuf(image, NULL, NULL); + if (!imbuf) { + fprintf(stderr, "Collada export: image does not exist:\n%s\n", image->name); + return; + } - ImageFormatData imageFormat; - BKE_imbuf_to_image_format(&imageFormat, imbuf); + bool is_dirty = (imbuf->userflags & IB_BITMAPDIRTY) != 0; - short image_source = image->source; - bool is_generated = image_source == IMA_SRC_GENERATED; - bool is_packed = BKE_image_has_packedfile(image); + ImageFormatData imageFormat; + BKE_imbuf_to_image_format(&imageFormat, imbuf); - char export_path[FILE_MAX]; - char source_path[FILE_MAX]; - char export_dir[FILE_MAX]; - char export_file[FILE_MAX]; + short image_source = image->source; + bool is_generated = image_source == IMA_SRC_GENERATED; + bool is_packed = BKE_image_has_packedfile(image); - // Destination folder for exported assets - BLI_split_dir_part(this->export_settings->filepath, export_dir, sizeof(export_dir)); + char export_path[FILE_MAX]; + char source_path[FILE_MAX]; + char export_dir[FILE_MAX]; + char export_file[FILE_MAX]; - if (is_generated || is_dirty || use_copies || is_packed) { + // Destination folder for exported assets + BLI_split_dir_part(this->export_settings->filepath, export_dir, sizeof(export_dir)); - // make absolute destination path + if (is_generated || is_dirty || use_copies || is_packed) { - BLI_strncpy(export_file, name.c_str(), sizeof(export_file)); - BKE_image_path_ensure_ext_from_imformat(export_file, &imageFormat); + // make absolute destination path - BLI_join_dirfile(export_path, sizeof(export_path), export_dir, export_file); + BLI_strncpy(export_file, name.c_str(), sizeof(export_file)); + BKE_image_path_ensure_ext_from_imformat(export_file, &imageFormat); - // make dest directory if it doesn't exist - BLI_make_existing_file(export_path); - } + BLI_join_dirfile(export_path, sizeof(export_path), export_dir, export_file); - if (is_generated || is_dirty || is_packed) { + // make dest directory if it doesn't exist + BLI_make_existing_file(export_path); + } - // This image in its current state only exists in Blender memory. - // So we have to export it. The export will keep the image state intact, - // so the exported file will not be associated with the image. + if (is_generated || is_dirty || is_packed) { - if (BKE_imbuf_write_as(imbuf, export_path, &imageFormat, true) == 0) { - fprintf(stderr, "Collada export: Cannot export image to:\n%s\n", export_path); - return; - } - BLI_strncpy(export_path, export_file, sizeof(export_path)); - } - else { + // This image in its current state only exists in Blender memory. + // So we have to export it. The export will keep the image state intact, + // so the exported file will not be associated with the image. - // make absolute source path - BLI_strncpy(source_path, image->name, sizeof(source_path)); - BLI_path_abs(source_path, BKE_main_blendfile_path_from_global()); - BLI_cleanup_path(NULL, source_path); + if (BKE_imbuf_write_as(imbuf, export_path, &imageFormat, true) == 0) { + fprintf(stderr, "Collada export: Cannot export image to:\n%s\n", export_path); + return; + } + BLI_strncpy(export_path, export_file, sizeof(export_path)); + } + else { - if (use_copies) { + // make absolute source path + BLI_strncpy(source_path, image->name, sizeof(source_path)); + BLI_path_abs(source_path, BKE_main_blendfile_path_from_global()); + BLI_cleanup_path(NULL, source_path); - // This image is already located on the file system. - // But we want to create copies here. - // To move images into the same export directory. - // Note: If an image is already located in the export folder, - // then skip the copy (as it would result in a file copy error). + if (use_copies) { - if (BLI_path_cmp(source_path, export_path) != 0) { - if (BLI_copy(source_path, export_path) != 0) { - fprintf(stderr, "Collada export: Cannot copy image:\n source:%s\ndest :%s\n", source_path, export_path); - return; - } - } + // This image is already located on the file system. + // But we want to create copies here. + // To move images into the same export directory. + // Note: If an image is already located in the export folder, + // then skip the copy (as it would result in a file copy error). - BLI_strncpy(export_path, export_file, sizeof(export_path)); + if (BLI_path_cmp(source_path, export_path) != 0) { + if (BLI_copy(source_path, export_path) != 0) { + fprintf(stderr, + "Collada export: Cannot copy image:\n source:%s\ndest :%s\n", + source_path, + export_path); + return; + } + } - } - else { + BLI_strncpy(export_path, export_file, sizeof(export_path)); + } + else { - // Do not make any copies, but use the source path directly as reference - // to the original image + // Do not make any copies, but use the source path directly as reference + // to the original image - BLI_strncpy(export_path, source_path, sizeof(export_path)); - } - } + BLI_strncpy(export_path, source_path, sizeof(export_path)); + } + } - COLLADASW::Image img(COLLADABU::URI(COLLADABU::URI::nativePathToUri(export_path)), translated_name, translated_name); /* set name also to mNameNC. This helps other viewers import files exported from Blender better */ - img.add(mSW); - fprintf(stdout, "Collada export: Added image: %s\n", export_file); + COLLADASW::Image img( + COLLADABU::URI(COLLADABU::URI::nativePathToUri(export_path)), + translated_name, + translated_name); /* set name also to mNameNC. This helps other viewers import files exported from Blender better */ + img.add(mSW); + fprintf(stdout, "Collada export: Added image: %s\n", export_file); - BKE_image_release_ibuf(image, imbuf, NULL); + BKE_image_release_ibuf(image, imbuf, NULL); } void ImagesExporter::exportImages(Scene *sce) { - bool use_texture_copies = this->export_settings->use_texture_copies; - openLibrary(); + bool use_texture_copies = this->export_settings->use_texture_copies; + openLibrary(); - KeyImageMap::iterator iter; - for (iter = key_image_map.begin(); iter != key_image_map.end(); iter++) { + KeyImageMap::iterator iter; + for (iter = key_image_map.begin(); iter != key_image_map.end(); iter++) { - Image *image = iter->second; - std::string uid(id_name(image)); - std::string key = translate_id(uid); + Image *image = iter->second; + std::string uid(id_name(image)); + std::string key = translate_id(uid); - export_UV_Image(image, use_texture_copies); - } + export_UV_Image(image, use_texture_copies); + } - closeLibrary(); + closeLibrary(); } |