forked from bartvdbraak/blender
Make object material drivers evaluation thread safe
Previously it was very easy to run into situation when two objects are sharing the same materials with drivers which will cause threading access issues. This actually only needed for the old depsgraph, but since it's still the one we're using by default we'd better solve this issue.
This commit is contained in:
parent
8540907d60
commit
61f9f508a4
@ -37,6 +37,7 @@
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_threads.h"
|
||||
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_armature.h"
|
||||
@ -65,6 +66,8 @@
|
||||
# define DEBUG_PRINT if (G.debug & G_DEBUG_DEPSGRAPH) printf
|
||||
#endif
|
||||
|
||||
static ThreadMutex material_lock = BLI_MUTEX_INITIALIZER;
|
||||
|
||||
void BKE_object_eval_local_transform(EvaluationContext *UNUSED(eval_ctx),
|
||||
Scene *UNUSED(scene),
|
||||
Object *ob)
|
||||
@ -239,12 +242,16 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
|
||||
*/
|
||||
if (ob->totcol) {
|
||||
int a;
|
||||
for (a = 1; a <= ob->totcol; a++) {
|
||||
Material *ma = give_current_material(ob, a);
|
||||
if (ma) {
|
||||
/* recursively update drivers for this material */
|
||||
material_drivers_update(scene, ma, ctime);
|
||||
if (ob->totcol != 0) {
|
||||
BLI_mutex_lock(&material_lock);
|
||||
for (a = 1; a <= ob->totcol; a++) {
|
||||
Material *ma = give_current_material(ob, a);
|
||||
if (ma) {
|
||||
/* recursively update drivers for this material */
|
||||
material_drivers_update(scene, ma, ctime);
|
||||
}
|
||||
}
|
||||
BLI_mutex_unlock(&material_lock);
|
||||
}
|
||||
}
|
||||
else if (ob->type == OB_LAMP)
|
||||
|
Loading…
Reference in New Issue
Block a user