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:
authorGaia Clary <gaia.clary@machinimatrix.org>2019-06-02 20:02:38 +0300
committerGaia Clary <gaia.clary@machinimatrix.org>2019-06-03 00:00:57 +0300
commit0731b88ddbbef2ca53c45b93e58c39d4ec1ce1b3 (patch)
treedd2abe4f3af80aa5732c9750ddf6e982db7417b8 /source/blender/collada
parent820e4d4303906020136b9a81ee0e878caee1f199 (diff)
refactor collada: Added utility functions bc_string_before() and bc_string_after()
Diffstat (limited to 'source/blender/collada')
-rw-r--r--source/blender/collada/BCAnimationCurve.cpp26
-rw-r--r--source/blender/collada/collada_utils.h23
2 files changed, 45 insertions, 4 deletions
diff --git a/source/blender/collada/BCAnimationCurve.cpp b/source/blender/collada/BCAnimationCurve.cpp
index 3ba2570ac42..57aa2f1bf29 100644
--- a/source/blender/collada/BCAnimationCurve.cpp
+++ b/source/blender/collada/BCAnimationCurve.cpp
@@ -132,7 +132,31 @@ const bool BCAnimationCurve::is_of_animation_type(BC_animation_type type) const
const std::string BCAnimationCurve::get_channel_target() const
{
const std::string path = curve_key.get_path();
- return bc_string_after(path, '.');
+
+ if (bc_startswith(path, "pose.bones")) {
+ return bc_string_after(path, "pose.bones");
+ }
+ return bc_string_after(path, ".");
+}
+
+const std::string BCAnimationCurve::get_channel_type() const
+{
+ const std::string channel = get_channel_target();
+ return bc_string_after(channel, ".");
+}
+
+const std::string BCAnimationCurve::get_channel_posebone() const
+{
+ const std::string channel = get_channel_target();
+ std::string pose_bone_name = bc_string_before(channel, ".");
+ if (pose_bone_name == channel) {
+ pose_bone_name = "";
+ }
+ else {
+ pose_bone_name = bc_string_after(pose_bone_name, "\"[");
+ pose_bone_name = bc_string_before(pose_bone_name, "]\"");
+ }
+ return pose_bone_name;
}
const std::string BCAnimationCurve::get_animation_name(Object *ob) const
diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h
index 2b74d8ee3ad..dca8f414e5a 100644
--- a/source/blender/collada/collada_utils.h
+++ b/source/blender/collada/collada_utils.h
@@ -160,11 +160,20 @@ extern int bc_get_active_UVLayer(Object *ob);
std::string bc_find_bonename_in_path(std::string path, std::string probe);
-inline std::string bc_string_after(const std::string &s, const char c)
+inline std::string bc_string_after(const std::string &s, const std::string probe)
{
- size_t i = s.rfind(c, s.length());
+ size_t i = s.rfind(probe);
if (i != std::string::npos) {
- return (s.substr(i + 1, s.length() - i));
+ return (s.substr(i + probe.length(), s.length() - i));
+ }
+ return (s);
+}
+
+inline std::string bc_string_before(const std::string &s, const std::string probe)
+{
+ size_t i = s.find(probe);
+ if (i != std::string::npos) {
+ return s.substr(0, i);
}
return (s);
}
@@ -177,6 +186,14 @@ inline bool bc_startswith(std::string const &value, std::string const &starting)
return (value.substr(0, starting.size()) == starting);
}
+inline bool bc_endswith(const std::string &value, const std::string &ending)
+{
+ if (ending.size() > value.size())
+ return false;
+
+ return value.compare(value.size() - ending.size(), ending.size(), ending) == 0;
+}
+
#if 0 /* UNUSED */
inline bool bc_endswith(std::string const &value, std::string const &ending)
{