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:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/collada/DocumentExporter.cpp
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (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/DocumentExporter.cpp')
-rw-r--r--source/blender/collada/DocumentExporter.cpp342
1 files changed, 176 insertions, 166 deletions
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp
index 42056a7d984..71c0d6c155e 100644
--- a/source/blender/collada/DocumentExporter.cpp
+++ b/source/blender/collada/DocumentExporter.cpp
@@ -22,7 +22,7 @@
#include <stdio.h>
#include <math.h>
#include <vector>
-#include <algorithm> // std::find
+#include <algorithm> // std::find
#include "COLLADASWCamera.h"
#include "COLLADASWAsset.h"
@@ -56,8 +56,7 @@
#include "COLLADASWInstanceNode.h"
#include "COLLADASWBaseInputElement.h"
-extern "C"
-{
+extern "C" {
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_collection_types.h"
@@ -79,7 +78,7 @@ extern "C"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
-#include "BKE_action.h" // pose functions
+#include "BKE_action.h" // pose functions
#include "BKE_animsys.h"
#include "BKE_armature.h"
#include "BKE_blender_version.h"
@@ -130,44 +129,47 @@ extern bool bc_has_object_type(LinkNode *export_set, short obtype);
char *bc_CustomData_get_layer_name(const struct CustomData *data, int type, int n)
{
- int layer_index = CustomData_get_layer_index(data, type);
- if (layer_index < 0) return NULL;
+ int layer_index = CustomData_get_layer_index(data, type);
+ if (layer_index < 0)
+ return NULL;
- return data->layers[layer_index + n].name;
+ return data->layers[layer_index + n].name;
}
char *bc_CustomData_get_active_layer_name(const CustomData *data, int type)
{
- /* get the layer index of the active layer of type */
- int layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index < 0) return NULL;
+ /* get the layer index of the active layer of type */
+ int layer_index = CustomData_get_active_layer_index(data, type);
+ if (layer_index < 0)
+ return NULL;
- return data->layers[layer_index].name;
+ return data->layers[layer_index].name;
}
-DocumentExporter::DocumentExporter(BlenderContext &blender_context, const ExportSettings *export_settings) :
- blender_context(blender_context),
- export_settings(export_settings) {
+DocumentExporter::DocumentExporter(BlenderContext &blender_context,
+ const ExportSettings *export_settings)
+ : blender_context(blender_context), export_settings(export_settings)
+{
}
static COLLADABU::NativeString make_temp_filepath(const char *name, const char *extension)
{
- char tempfile[FILE_MAX];
- const char *tempdir = BKE_tempdir_session();
+ char tempfile[FILE_MAX];
+ const char *tempdir = BKE_tempdir_session();
- if (name == NULL) {
- name = "untitled";
- }
+ if (name == NULL) {
+ name = "untitled";
+ }
- BLI_make_file_string(NULL, tempfile, tempdir, name);
+ BLI_make_file_string(NULL, tempfile, tempdir, name);
- if (extension) {
- BLI_path_extension_ensure(tempfile, FILE_MAX, extension);
- }
+ if (extension) {
+ BLI_path_extension_ensure(tempfile, FILE_MAX, extension);
+ }
- COLLADABU::NativeString native_filename =
- COLLADABU::NativeString(tempfile, COLLADABU::NativeString::ENCODING_UTF8);
- return native_filename;
+ COLLADABU::NativeString native_filename = COLLADABU::NativeString(
+ tempfile, COLLADABU::NativeString::ENCODING_UTF8);
+ return native_filename;
}
// TODO: it would be better to instantiate animations rather than create a new one per object
@@ -176,149 +178,157 @@ static COLLADABU::NativeString make_temp_filepath(const char *name, const char *
int DocumentExporter::exportCurrentScene()
{
- Scene *sce = blender_context.get_scene();
- bContext *C = blender_context.get_context();
-
- PointerRNA sceneptr, unit_settings;
- PropertyRNA *system; /* unused , *scale; */
-
- clear_global_id_map();
-
- COLLADABU::NativeString native_filename = make_temp_filepath(NULL, ".dae");
- COLLADASW::StreamWriter *writer = new COLLADASW::StreamWriter(native_filename);
-
- // open <collada>
- writer->startDocument();
-
- // <asset>
- COLLADASW::Asset asset(writer);
-
- RNA_id_pointer_create(&(sce->id), &sceneptr);
- unit_settings = RNA_pointer_get(&sceneptr, "unit_settings");
- system = RNA_struct_find_property(&unit_settings, "system");
- //scale = RNA_struct_find_property(&unit_settings, "scale_length");
-
- std::string unitname = "meter";
- float linearmeasure = RNA_float_get(&unit_settings, "scale_length");
-
- switch (RNA_property_enum_get(&unit_settings, system)) {
- case USER_UNIT_NONE:
- case USER_UNIT_METRIC:
- if (linearmeasure == 0.001f) {
- unitname = "millimeter";
- }
- else if (linearmeasure == 0.01f) {
- unitname = "centimeter";
- }
- else if (linearmeasure == 0.1f) {
- unitname = "decimeter";
- }
- else if (linearmeasure == 1.0f) {
- unitname = "meter";
- }
- else if (linearmeasure == 1000.0f) {
- unitname = "kilometer";
- }
- break;
- case USER_UNIT_IMPERIAL:
- if (linearmeasure == 0.0254f) {
- unitname = "inch";
- }
- else if (linearmeasure == 0.3048f) {
- unitname = "foot";
- }
- else if (linearmeasure == 0.9144f) {
- unitname = "yard";
- }
- break;
- default:
- break;
- }
-
- asset.setUnit(unitname, linearmeasure);
- asset.setUpAxisType(COLLADASW::Asset::Z_UP);
- asset.getContributor().mAuthor = "Blender User";
- char version_buf[128];
+ Scene *sce = blender_context.get_scene();
+ bContext *C = blender_context.get_context();
+
+ PointerRNA sceneptr, unit_settings;
+ PropertyRNA *system; /* unused , *scale; */
+
+ clear_global_id_map();
+
+ COLLADABU::NativeString native_filename = make_temp_filepath(NULL, ".dae");
+ COLLADASW::StreamWriter *writer = new COLLADASW::StreamWriter(native_filename);
+
+ // open <collada>
+ writer->startDocument();
+
+ // <asset>
+ COLLADASW::Asset asset(writer);
+
+ RNA_id_pointer_create(&(sce->id), &sceneptr);
+ unit_settings = RNA_pointer_get(&sceneptr, "unit_settings");
+ system = RNA_struct_find_property(&unit_settings, "system");
+ //scale = RNA_struct_find_property(&unit_settings, "scale_length");
+
+ std::string unitname = "meter";
+ float linearmeasure = RNA_float_get(&unit_settings, "scale_length");
+
+ switch (RNA_property_enum_get(&unit_settings, system)) {
+ case USER_UNIT_NONE:
+ case USER_UNIT_METRIC:
+ if (linearmeasure == 0.001f) {
+ unitname = "millimeter";
+ }
+ else if (linearmeasure == 0.01f) {
+ unitname = "centimeter";
+ }
+ else if (linearmeasure == 0.1f) {
+ unitname = "decimeter";
+ }
+ else if (linearmeasure == 1.0f) {
+ unitname = "meter";
+ }
+ else if (linearmeasure == 1000.0f) {
+ unitname = "kilometer";
+ }
+ break;
+ case USER_UNIT_IMPERIAL:
+ if (linearmeasure == 0.0254f) {
+ unitname = "inch";
+ }
+ else if (linearmeasure == 0.3048f) {
+ unitname = "foot";
+ }
+ else if (linearmeasure == 0.9144f) {
+ unitname = "yard";
+ }
+ break;
+ default:
+ break;
+ }
+
+ asset.setUnit(unitname, linearmeasure);
+ asset.setUpAxisType(COLLADASW::Asset::Z_UP);
+ asset.getContributor().mAuthor = "Blender User";
+ char version_buf[128];
#ifdef WITH_BUILDINFO
- BLI_snprintf(version_buf, sizeof(version_buf), "Blender %d.%02d.%d commit date:%s, commit time:%s, hash:%s",
- BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION,
- build_commit_date, build_commit_time, build_hash);
+ BLI_snprintf(version_buf,
+ sizeof(version_buf),
+ "Blender %d.%02d.%d commit date:%s, commit time:%s, hash:%s",
+ BLENDER_VERSION / 100,
+ BLENDER_VERSION % 100,
+ BLENDER_SUBVERSION,
+ build_commit_date,
+ build_commit_time,
+ build_hash);
#else
- BLI_snprintf(version_buf, sizeof(version_buf), "Blender %d.%02d.%d",
- BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION);
+ BLI_snprintf(version_buf,
+ sizeof(version_buf),
+ "Blender %d.%02d.%d",
+ BLENDER_VERSION / 100,
+ BLENDER_VERSION % 100,
+ BLENDER_SUBVERSION);
#endif
- asset.getContributor().mAuthoringTool = version_buf;
- asset.add();
-
- LinkNode *export_set = this->export_settings->export_set;
- // <library_cameras>
- if (bc_has_object_type(export_set, OB_CAMERA)) {
- CamerasExporter ce(writer, this->export_settings);
- ce.exportCameras(sce);
- }
-
- // <library_lights>
- if (bc_has_object_type(export_set, OB_LAMP)) {
- LightsExporter le(writer, this->export_settings);
- le.exportLights(sce);
- }
-
- // <library_effects>
- EffectsExporter ee(writer, this->export_settings, key_image_map);
- ee.exportEffects(C, sce);
-
- // <library_images>
- ImagesExporter ie(writer, this->export_settings, key_image_map);
- ie.exportImages(sce);
-
- // <library_materials>
- MaterialsExporter me(writer, this->export_settings);
- me.exportMaterials(sce);
-
- // <library_geometries>
- if (bc_has_object_type(export_set, OB_MESH)) {
- GeometryExporter ge(blender_context, writer, this->export_settings);
- ge.exportGeom();
- }
-
- // <library_controllers>
- ArmatureExporter arm_exporter(blender_context, writer, this->export_settings);
- ControllerExporter controller_exporter(blender_context, writer, this->export_settings);
- if (bc_has_object_type(export_set, OB_ARMATURE) || this->export_settings->include_shapekeys)
- {
- controller_exporter.export_controllers();
- }
-
- // <library_visual_scenes>
-
- SceneExporter se(blender_context, writer, &arm_exporter, this->export_settings);
-
- if (this->export_settings->include_animations) {
- // <library_animations>
- AnimationExporter ae(blender_context, writer, this->export_settings);
- ae.exportAnimations();
- }
-
- se.exportScene();
-
- // <scene>
- std::string scene_name(translate_id(id_name(sce)));
- COLLADASW::Scene scene(writer, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING,
- scene_name));
- scene.add();
-
- // close <Collada>
- writer->endDocument();
- delete writer;
-
- // Finally move the created document into place
- fprintf(stdout, "Collada export to: %s\n", this->export_settings->filepath);
- int status = BLI_rename(native_filename.c_str(), this->export_settings->filepath);
- if (status != 0) {
- status = BLI_copy(native_filename.c_str(), this->export_settings->filepath);
- BLI_delete(native_filename.c_str(), false, false);
- }
- return status;
+ asset.getContributor().mAuthoringTool = version_buf;
+ asset.add();
+
+ LinkNode *export_set = this->export_settings->export_set;
+ // <library_cameras>
+ if (bc_has_object_type(export_set, OB_CAMERA)) {
+ CamerasExporter ce(writer, this->export_settings);
+ ce.exportCameras(sce);
+ }
+
+ // <library_lights>
+ if (bc_has_object_type(export_set, OB_LAMP)) {
+ LightsExporter le(writer, this->export_settings);
+ le.exportLights(sce);
+ }
+
+ // <library_effects>
+ EffectsExporter ee(writer, this->export_settings, key_image_map);
+ ee.exportEffects(C, sce);
+
+ // <library_images>
+ ImagesExporter ie(writer, this->export_settings, key_image_map);
+ ie.exportImages(sce);
+
+ // <library_materials>
+ MaterialsExporter me(writer, this->export_settings);
+ me.exportMaterials(sce);
+
+ // <library_geometries>
+ if (bc_has_object_type(export_set, OB_MESH)) {
+ GeometryExporter ge(blender_context, writer, this->export_settings);
+ ge.exportGeom();
+ }
+
+ // <library_controllers>
+ ArmatureExporter arm_exporter(blender_context, writer, this->export_settings);
+ ControllerExporter controller_exporter(blender_context, writer, this->export_settings);
+ if (bc_has_object_type(export_set, OB_ARMATURE) || this->export_settings->include_shapekeys) {
+ controller_exporter.export_controllers();
+ }
+
+ // <library_visual_scenes>
+
+ SceneExporter se(blender_context, writer, &arm_exporter, this->export_settings);
+
+ if (this->export_settings->include_animations) {
+ // <library_animations>
+ AnimationExporter ae(blender_context, writer, this->export_settings);
+ ae.exportAnimations();
+ }
+
+ se.exportScene();
+
+ // <scene>
+ std::string scene_name(translate_id(id_name(sce)));
+ COLLADASW::Scene scene(writer, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, scene_name));
+ scene.add();
+
+ // close <Collada>
+ writer->endDocument();
+ delete writer;
+
+ // Finally move the created document into place
+ fprintf(stdout, "Collada export to: %s\n", this->export_settings->filepath);
+ int status = BLI_rename(native_filename.c_str(), this->export_settings->filepath);
+ if (status != 0) {
+ status = BLI_copy(native_filename.c_str(), this->export_settings->filepath);
+ BLI_delete(native_filename.c_str(), false, false);
+ }
+ return status;
}
void DocumentExporter::exportScenes(const char *filename)