diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2012-09-26 18:53:41 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2012-09-26 18:53:41 +0400 |
commit | c112e1b796d4f0f5d481da056c3298fdf05f671c (patch) | |
tree | e11513f65e1a7ec3f8f95cf3b33b58a601a86293 /source/blender/collada | |
parent | 4e39a8f939fff178d320c88c290e927bddd98571 (diff) | |
parent | 433816ea9be382244ce2ca79686f242ef1d65c0b (diff) |
merge with trunk -r50910
Diffstat (limited to 'source/blender/collada')
-rw-r--r-- | source/blender/collada/AnimationImporter.cpp | 7 | ||||
-rw-r--r-- | source/blender/collada/DocumentExporter.cpp | 3 | ||||
-rw-r--r-- | source/blender/collada/DocumentImporter.cpp | 12 | ||||
-rw-r--r-- | source/blender/collada/GeometryExporter.cpp | 19 | ||||
-rw-r--r-- | source/blender/collada/ImageExporter.cpp | 23 | ||||
-rw-r--r-- | source/blender/collada/MeshImporter.cpp | 2 | ||||
-rw-r--r-- | source/blender/collada/collada.cpp | 1 |
7 files changed, 38 insertions, 29 deletions
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 926574d7395..e525b810f46 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -683,12 +683,11 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId& listid for (unsigned int i = 0; i < fcu->totvert; i++) { double input_fov = fcu->bezt[i].vec[1][1]; - double xfov = (fov_type == CAMERA_YFOV) ? aspect * input_fov : input_fov; - // fov is in degrees, cam->lens is in millimiters - double fov = fov_to_focallength(DEG2RADF(input_fov), cam->sensor_x); + // NOTE: Needs more testing (As we curretnly have no official test data for this) + double xfov = (fov_type == CAMERA_YFOV) ? (2.0f * atanf(aspect * tanf(DEG2RADF(input_fov) * 0.5f))) : DEG2RADF(input_fov); - fcu->bezt[i].vec[1][1] = fov; + fcu->bezt[i].vec[1][1] = fov_to_focallength(xfov, cam->sensor_x); } BLI_addtail(AnimCurves, fcu); diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index d0d3c358613..3c9c99b1d0a 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -99,7 +99,6 @@ extern char build_rev[]; #include "BKE_action.h" // pose functions #include "BKE_armature.h" #include "BKE_image.h" -#include "BKE_utildefines.h" #include "BKE_object.h" #include "BLI_math.h" @@ -165,6 +164,8 @@ void DocumentExporter::exportCurrentScene(Scene *sce) COLLADABU::NativeString(std::string(this->export_settings->filepath)); COLLADASW::StreamWriter sw(native_filename); + fprintf(stdout, "Collada export: %s\n", this->export_settings->filepath); + // open <collada> sw.startDocument(); diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 77f97e54fc5..034b9584e63 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -62,13 +62,13 @@ extern "C" { #include "BKE_texture.h" #include "BKE_fcurve.h" #include "BKE_depsgraph.h" -#include "BLI_path_util.h" #include "BKE_scene.h" #include "BKE_global.h" #include "BKE_material.h" -#include "BKE_utildefines.h" #include "BKE_image.h" +#include "BLI_path_util.h" + #include "DNA_camera_types.h" #include "DNA_lamp_types.h" @@ -882,9 +882,11 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) { double yfov = camera->getYFov().getValue(); double aspect = camera->getAspectRatio().getValue(); - double xfov = aspect * yfov; - // xfov is in degrees, cam->lens is in millimiters - cam->lens = fov_to_focallength(DEG2RADF(xfov), cam->sensor_x); + + // NOTE: Needs more testing (As we curretnly have no official test data for this) + + double xfov = 2.0f * atanf(aspect * tanf(DEG2RADF(yfov) * 0.5f)); + cam->lens = fov_to_focallength(xfov, cam->sensor_x); } break; } diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index c2542958c3f..c43d400b88e 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -131,14 +131,17 @@ void GeometryExporter::operator()(Object *ob) createLooseEdgeList(ob, me, geom_id, norind); - // XXX slow - if (ob->totcol) { - for (int a = 0; a < ob->totcol; a++) { - createPolylist(a, has_uvs, has_color, ob, me, geom_id, norind); + // Only create Polylists if number of faces > 0 + if (me->totface > 0) { + // XXX slow + if (ob->totcol) { + for (int a = 0; a < ob->totcol; a++) { + createPolylist(a, has_uvs, has_color, ob, me, geom_id, norind); + } + } + else { + createPolylist(0, has_uvs, has_color, ob, me, geom_id, norind); } - } - else { - createPolylist(0, has_uvs, has_color, ob, me, geom_id, norind); } closeMesh(); @@ -322,7 +325,7 @@ void GeometryExporter::createPolylist(short material_index, // no faces using this material if (faces_in_polylist == 0) { - fprintf(stderr, "%s: no faces use material %d\n", id_name(ob).c_str(), material_index); + fprintf(stderr, "%s: material with index %d is not used.\n", id_name(ob).c_str(), material_index); return; } diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index 66dcec7d8e4..a15dadda8cf 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -39,7 +39,6 @@ extern "C" { #include "BKE_image.h" #include "BKE_main.h" #include "BKE_mesh.h" -#include "BKE_utildefines.h" #include "BLI_fileops.h" #include "BLI_path_util.h" #include "BLI_string.h" @@ -75,6 +74,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) short image_source = image->source; bool is_generated = image_source == IMA_SRC_GENERATED; + bool is_packed = image->packedfile != NULL; char export_path[FILE_MAX]; char source_path[FILE_MAX]; @@ -84,7 +84,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) // Destination folder for exported assets BLI_split_dir_part(this->export_settings->filepath, export_dir, sizeof(export_dir)); - if (is_generated || is_dirty || use_copies) { + if (is_generated || is_dirty || use_copies || is_packed) { // make absolute destination path @@ -97,7 +97,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) BLI_make_existing_file(export_path); } - if (is_generated || is_dirty) { + if (is_generated || is_dirty || is_packed) { // 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, @@ -120,12 +120,15 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) // This image is already located on the file system. // But we want to create copies here. - // To avoid overwroting images with same file name but - // differenet source locations - - 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; + // 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 (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; + } } BLI_strncpy(export_path, export_file, sizeof(export_path)); @@ -133,7 +136,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) } else { - // Do not make any vopies, but use the source path directly as reference + // 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)); diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index b9a4c092552..209bfa84727 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -570,7 +570,7 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me) if (loose_edge_count > 0) { unsigned int face_edge_count = me->totedge; - unsigned int total_edge_count = loose_edge_count + face_edge_count; + /* unsigned int total_edge_count = loose_edge_count + face_edge_count; */ /* UNUSED */ mesh_add_edges(me, loose_edge_count); MEdge *med = me->medge + face_edge_count; diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index f7e0f75ec5c..fbb18887d1b 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -76,6 +76,7 @@ int collada_export(Scene *sce, if (!BLI_exists(filepath)) { BLI_make_existing_file(filepath); /* makes the dir if its not there */ if (BLI_file_touch(filepath) == 0) { + fprintf(stdout, "Collada export: Can not create: %s\n", filepath); return 0; } } |