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-07-09 12:23:01 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-07-09 12:23:01 +0400
commit86546ca42d5cf2373d756b49a5a91fccfeaaefac (patch)
tree5afd77128f4f141f5aef74583b3e44ec70f774b2 /source/blender/blenkernel/intern/mball.c
parent139754894b995310cf018d789f7ffcda4487233d (diff)
Fixed more threading issues with metaballs
This time issue was caused by static variables used in BKE_scene_base_iter_next function. Change is not so much ultimate actually, but didn't find more clear solution for now. So the changes are: - Wrap almost all the static variables into own context- like structure, which is owned by the callee function and getting passed to the iteration function. - Recursion detection wasn't possible with such approach, so recursion detection still uses static in_next_object variable, but which is now stored in thread local storage (TLS, or thread variable if this names are more clear for you). This makes code thread-safe, but for sure final solution shall be completely different. Ideally, dependency graph shall be possible to answer on question "which object is a motherball for this metaball". This will avoid iterating via all the bases, objects and duplis just to get needed motherball. Further, metaball evaluation ideally will use the same kind of depsgraph filtering, which will get result for question like "which objects belongs to this group of metaballs". But this ideal things are to be solved in Joshua's and mind GSoC projects. Tested on linux (gcc and clang) and windows (msvc2008), hopefully no compilation error will happen. Thanks to Brecht for reviewing the change and getting feedback for other possible ways we've dicussed!
Diffstat (limited to 'source/blender/blenkernel/intern/mball.c')
-rw-r--r--source/blender/blenkernel/intern/mball.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 31212c3a6b7..55b1a65a73e 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -485,14 +485,15 @@ void BKE_mball_properties_copy(Scene *scene, Object *active_object)
MetaBall *active_mball = (MetaBall *)active_object->data;
int basisnr, obnr;
char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
-
+ SceneBaseIter iter;
+
BLI_split_name_num(basisname, &basisnr, active_object->id.name + 2, '.');
/* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */
- if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL))
+ if (F_ERROR == BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL))
return;
- while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) {
+ while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &ob)) {
if (ob->type == OB_MBALL) {
if (ob != active_object) {
BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
@@ -529,14 +530,15 @@ Object *BKE_mball_basis_find(Scene *scene, Object *basis)
Object *ob, *bob = basis;
int basisnr, obnr;
char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
+ SceneBaseIter iter;
BLI_split_name_num(basisname, &basisnr, basis->id.name + 2, '.');
/* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */
- if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL))
+ if (F_ERROR == BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL))
return NULL;
- while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) {
+ while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &ob)) {
if (ob->type == OB_MBALL) {
if (ob != bob) {
BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
@@ -1655,7 +1657,8 @@ static float init_meta(PROCESS *process, Scene *scene, Object *ob) /* return
//float max = 0.0f;
int a, obnr, zero_size = 0;
char obname[MAX_ID_NAME];
-
+ SceneBaseIter iter;
+
copy_m4_m4(obmat, ob->obmat); /* to cope with duplicators from BKE_scene_base_iter_next */
invert_m4_m4(obinv, ob->obmat);
a = 0;
@@ -1663,8 +1666,8 @@ static float init_meta(PROCESS *process, Scene *scene, Object *ob) /* return
BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
/* make main array */
- BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL);
- while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &bob)) {
+ BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL);
+ while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &bob)) {
if (bob->type == OB_MBALL) {
zero_size = 0;
@@ -2225,15 +2228,16 @@ static void mball_count(PROCESS *process, Scene *scene, Object *basis)
MetaElem *ml = NULL;
int basisnr, obnr;
char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
+ SceneBaseIter iter;
BLI_split_name_num(basisname, &basisnr, basis->id.name + 2, '.');
process->totelem = 0;
/* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */
- if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL))
+ if (F_ERROR == BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL))
return;
- while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) {
+ while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &ob)) {
if (ob->type == OB_MBALL) {
if (ob == bob) {
MetaBall *mb = ob->data;