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>2019-05-27 12:45:33 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-05-29 11:44:11 +0300
commit2f7711962a69de8192d048514e5927e49a1a63a2 (patch)
tree7a91196fc710ec8e47bda75cd763d09386e43d8d /source/blender/blenkernel/intern/mesh_runtime.c
parentda7e5e861f54ae0ca9b7ec1c71432fb08f7a53fa (diff)
Fix T58251: Cycles ignores linked meshes when rendering
The idea is to share a mesh data-block as a result across all objects which are sharing same original mesh and have no effective modifiers. This mesh is owned by an original copy-on-written version of object data. Tricky part is to make sure it is only initialized once, and currently a silly mutex lock is used. In practice it only locks if the mesh is not already there. As an extra bonus, even viewport memory is also lower after this change. Reviewers: brecht, mont29 Reviewed By: brecht, mont29 Differential Revision: https://developer.blender.org/D4954
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_runtime.c')
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c
index 06abd80b86f..4c3761c7ffc 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.c
+++ b/source/blender/blenkernel/intern/mesh_runtime.c
@@ -33,6 +33,7 @@
#include "BLI_threads.h"
#include "BKE_bvhutils.h"
+#include "BKE_library.h"
#include "BKE_mesh.h"
#include "BKE_mesh_runtime.h"
#include "BKE_subdiv_ccg.h"
@@ -50,6 +51,8 @@ static ThreadRWMutex loops_cache_lock = PTHREAD_RWLOCK_INITIALIZER;
void BKE_mesh_runtime_reset(Mesh *mesh)
{
memset(&mesh->runtime, 0, sizeof(mesh->runtime));
+ mesh->runtime.eval_mutex = MEM_mallocN(sizeof(ThreadMutex), "mesh runtime eval_mutex");
+ BLI_mutex_init(mesh->runtime.eval_mutex);
}
/* Clear all pointers which we don't want to be shared on copying the datablock.
@@ -59,16 +62,30 @@ void BKE_mesh_runtime_reset_on_copy(Mesh *mesh, const int UNUSED(flag))
{
Mesh_Runtime *runtime = &mesh->runtime;
+ runtime->mesh_eval = NULL;
runtime->edit_data = NULL;
runtime->batch_cache = NULL;
runtime->subdiv_ccg = NULL;
memset(&runtime->looptris, 0, sizeof(runtime->looptris));
runtime->bvh_cache = NULL;
runtime->shrinkwrap_data = NULL;
+
+ mesh->runtime.eval_mutex = MEM_mallocN(sizeof(ThreadMutex), "mesh runtime eval_mutex");
+ BLI_mutex_init(mesh->runtime.eval_mutex);
}
void BKE_mesh_runtime_clear_cache(Mesh *mesh)
{
+ if (mesh->runtime.eval_mutex != NULL) {
+ BLI_mutex_end(mesh->runtime.eval_mutex);
+ MEM_freeN(mesh->runtime.eval_mutex);
+ mesh->runtime.eval_mutex = NULL;
+ }
+ if (mesh->runtime.mesh_eval != NULL) {
+ mesh->runtime.mesh_eval->edit_mesh = NULL;
+ BKE_id_free(NULL, mesh->runtime.mesh_eval);
+ mesh->runtime.mesh_eval = NULL;
+ }
BKE_mesh_runtime_clear_geometry(mesh);
BKE_mesh_batch_cache_free(mesh);
BKE_mesh_runtime_clear_edit_data(mesh);