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:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-08-19 14:14:22 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-08-19 14:14:22 +0400
commit36ffc7accde82eb1d1930ed8758e315339fac8bc (patch)
treef57a6786aa363babf64db3dcaa0320469224cc67 /source/blender/blenkernel/intern/armature.c
parentc46cbc602e1007a15c6d9824ec34c41f124faeaa (diff)
Made armatures evaluation safe for threading
Apparently, some routines in armature deformation code were using static arrays. This is probably just an optimization thing, but it's very bad for threading. Now made it so bbone matrices array is allocating in callee function stack. This required exposing MAX_BBONE_SUBDIV to an external API, This is not so much crappy from code side, and it shall be the same fast as before. -- svn merge -r58278:58279 ^/branches/soc-2013-depsgraph_mt
Diffstat (limited to 'source/blender/blenkernel/intern/armature.c')
-rw-r--r--source/blender/blenkernel/intern/armature.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index dbe3c39af97..6b2b782717d 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -381,8 +381,6 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a
/* ************* B-Bone support ******************* */
-#define MAX_BBONE_SUBDIV 32
-
/* data has MAX_BBONE_SUBDIV+1 interpolated points, will become desired amount with equal distances */
static void equalize_bezier(float *data, int desired)
{
@@ -426,11 +424,8 @@ static void equalize_bezier(float *data, int desired)
/* returns pointer to static array, filled with desired amount of bone->segments elements */
/* this calculation is done within unit bone space */
-Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
+void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BBONE_SUBDIV])
{
- static Mat4 bbone_array[MAX_BBONE_SUBDIV];
- static Mat4 bbone_rest_array[MAX_BBONE_SUBDIV];
- Mat4 *result_array = (rest) ? bbone_rest_array : bbone_array;
bPoseChannel *next, *prev;
Bone *bone = pchan->bone;
float h1[3], h2[3], scale[3], length, hlength1, hlength2, roll1 = 0.0f, roll2;
@@ -587,8 +582,6 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
mul_serie_m4(result_array[a].mat, iscalemat, result_array[a].mat, scalemat, NULL, NULL, NULL, NULL, NULL);
}
}
-
- return result_array;
}
/* ************ Armature Deform ******************* */
@@ -602,13 +595,15 @@ typedef struct bPoseChanDeform {
static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info, int use_quaternion)
{
Bone *bone = pchan->bone;
- Mat4 *b_bone = b_bone_spline_setup(pchan, 0);
- Mat4 *b_bone_rest = b_bone_spline_setup(pchan, 1);
+ Mat4 b_bone[MAX_BBONE_SUBDIV], b_bone_rest[MAX_BBONE_SUBDIV];
Mat4 *b_bone_mats;
DualQuat *b_bone_dual_quats = NULL;
float tmat[4][4] = MAT4_UNITY;
int a;
+ b_bone_spline_setup(pchan, 0, b_bone);
+ b_bone_spline_setup(pchan, 1, b_bone_rest);
+
/* allocate b_bone matrices and dual quats */
b_bone_mats = MEM_mallocN((1 + bone->segments) * sizeof(Mat4), "BBone defmats");
pdef_info->b_bone_mats = b_bone_mats;