From 2da63a1ad7ad53fa0ee5aeb2645b093e03de6fda Mon Sep 17 00:00:00 2001 From: Johnny Matthews Date: Wed, 27 Jul 2005 18:48:08 +0000 Subject: [PATCH] Added Name flip for _L _l _R _r Also added if suffix == 001, do not re-add suffix. So allows the following procedure bone named Bone_R is copied, becomes Bone_R.001 Bone_R.001 is Flipped, becomes Bone_L Currently only works for 001, could be extended later --- source/blender/src/poseobject.c | 46 ++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/source/blender/src/poseobject.c b/source/blender/src/poseobject.c index ad28c6fca53..40b518492cd 100644 --- a/source/blender/src/poseobject.c +++ b/source/blender/src/poseobject.c @@ -532,7 +532,24 @@ static void flip_name (char *name) strcpy (suffix, index+2); } } - + /* check for an instance of _l */ + if (!index){ + index = strstr (prefix, "_l"); + if (index){ + *index=0; + strcpy (replace, "_r"); + strcpy (suffix, index+2); + } + } + /* check for an instance of _L */ + if (!index){ + index = strstr (prefix, "_L"); + if (index){ + *index=0; + strcpy (replace, "_R"); + strcpy (suffix, index+2); + } + } /* Checl for an instance of .R */ if (!index){ index = strstr (prefix, ".R"); @@ -552,8 +569,29 @@ static void flip_name (char *name) strcpy (suffix, index+2); } } - - sprintf (name, "%s%s%s", prefix, replace, suffix); + /* Checl for an instance of _r */ + if (!index){ + index = strstr (prefix, "_r"); + if (index){ + *index=0; + strcpy (replace, "_l"); + strcpy (suffix, index+2); + } + } + /* Check for an instance of _R */ + if (!index){ + index = strstr (prefix, "_R"); + if (index){ + *index=0; + strcpy (replace, "_L"); + strcpy (suffix, index+2); + } + } + if(strstr (suffix, "001")){ + sprintf (name, "%s%s", prefix, replace); + } else { + sprintf (name, "%s%s%s", prefix, replace, suffix); + } } void paste_posebuf (int flip) @@ -672,4 +710,4 @@ void pose_flip_names(void) allqueue(REDRAWOOPS, 0); BIF_undo_push("Flip names"); -} \ No newline at end of file +}