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:
authorgaiaclary <gaia.clary@machinimatrix.org>2014-02-03 16:04:51 +0400
committergaiaclary <gaia.clary@machinimatrix.org>2014-02-03 16:04:51 +0400
commit89a846df51224ff829b8683dad93024e0b230319 (patch)
treea402b644ac5f373dd6e23bc4430316cd01d3ef61 /source/blender/collada
parent4bd6423b7efdb3a4d1c18d15af3cdc9d7f2e41b7 (diff)
Add compatibility for older Collada files
The Fix in 273 creates a backward incompatibility: Collada files that have been created with an older Blender version will contain the spotlight_size in Radians where Collada wants this value to be in DEGREE. This fix adds a check for the Blender Version that was used to create the Collada file. If the Collada file was made by an older version of Blender then the importer will assume that spotlight_size is specified in RADIANS. Reviewers: campbellbarton, sauraedron Reviewed By: sauraedron CC: jesterking Differential Revision: https://developer.blender.org/D279
Diffstat (limited to 'source/blender/collada')
-rw-r--r--source/blender/collada/AnimationImporter.cpp17
-rw-r--r--source/blender/collada/AnimationImporter.h3
-rw-r--r--source/blender/collada/DocumentImporter.cpp33
-rw-r--r--source/blender/collada/DocumentImporter.h2
4 files changed, 50 insertions, 5 deletions
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index 66312f7299f..d27795b0ab2 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -648,12 +648,17 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list
//Add the curves of the current animation to the object
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
- /* All anim_types whose values are to be converted from Degree to Radians can be ORed here
- *XXX What About " rotation " ? */
- if (BLI_strcaseeq("spot_size", anim_type)) {
- /* Convert current values to Radians */
+ /* All anim_types whose values are to be converted from Degree to Radians can be ORed here */
+ if (strcmp("spot_size", anim_type)==0) {
+ /* NOTE: Do NOT convert if imported file was made by blender <= 2.69.10
+ * Reason: old blender versions stored spot_size in radians (was a bug)
+ */
+ if (this->import_from_version == "" || BLI_natstrcmp(this->import_from_version.c_str(), "2.69.10") != -1) {
fcurve_deg_to_rad(fcu);
+ }
}
+ /** XXX What About animtype "rotation" ? */
+
BLI_addtail(AnimCurves, fcu);
}
}
@@ -2011,3 +2016,7 @@ void AnimationImporter::add_bezt(FCurve *fcu, float fra, float value)
calchandles_fcurve(fcu);
}
+void AnimationImporter::set_import_from_version(std::string import_from_version)
+{
+ this->import_from_version = import_from_version;
+}
diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h
index 61c220e4bbe..565fe183d02 100644
--- a/source/blender/collada/AnimationImporter.h
+++ b/source/blender/collada/AnimationImporter.h
@@ -89,6 +89,8 @@ private:
int typeFlag;
+ std::string import_from_version;
+
enum lightAnim
{
// INANIMATE = 0,
@@ -137,6 +139,7 @@ public:
~AnimationImporter();
+ void set_import_from_version(std::string import_from_version);
bool write_animation(const COLLADAFW::Animation* anim);
// called on post-process stage after writeVisualScenes
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index f8fc035f620..ea0f6cf0049 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -326,12 +326,43 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW
}
}
+/**
+ * If the imported file was made with Blender, return the Blender version used,
+ * otherwise return an empty std::string
+ */
+std::string DocumentImporter::get_import_version(const COLLADAFW::FileInfo *asset)
+{
+ const char AUTORING_TOOL[] = "authoring_tool";
+ const std::string BLENDER("Blender ");
+ const COLLADAFW::FileInfo::ValuePairPointerArray &valuePairs = asset->getValuePairArray();
+ for ( size_t i = 0, count = valuePairs.getCount(); i < count; ++i)
+ {
+ const COLLADAFW::FileInfo::ValuePair* valuePair = valuePairs[i];
+ const COLLADAFW::String& key = valuePair->first;
+ const COLLADAFW::String& value = valuePair->second;
+ if ( key == AUTORING_TOOL )
+ {
+ if (value.compare(0, BLENDER.length(), BLENDER) == 0)
+ {
+ // Was made with Blender, now get version string
+ std::string v = value.substr(BLENDER.length());
+ std::string::size_type n = v.find(" ");
+ if (n > 0) {
+ return v.substr(0,n);
+ }
+ }
+ }
+ }
+ return "";
+}
+
/** When this method is called, the writer must write the global document asset.
* \return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeGlobalAsset(const COLLADAFW::FileInfo *asset)
{
unit_converter.read_asset(asset);
-
+ import_from_version = get_import_version(asset);
+ anim_importer.set_import_from_version(import_from_version);
return true;
}
diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h
index ff0cbd44043..96aa7eb4578 100644
--- a/source/blender/collada/DocumentImporter.h
+++ b/source/blender/collada/DocumentImporter.h
@@ -97,6 +97,7 @@ public:
void finish();
bool writeGlobalAsset(const COLLADAFW::FileInfo*);
+ std::string get_import_version(const COLLADAFW::FileInfo *asset);
bool writeScene(const COLLADAFW::Scene*);
@@ -169,6 +170,7 @@ private:
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> root_map; // find root joint by child joint uid, for bone tree evaluation during resampling
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map;
+ std::string import_from_version;
};
#endif