From 98a0bcd4252e952fa5438e9d1b69b0204f8a8746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 27 Jun 2018 17:08:58 +0200 Subject: Prevent copying too much in the Rigid Body simulation To prevent the pointcache from being copied-on-write too (and requiring copying back), the cache is now shared between the original and evaluated scenes. Reading from the cache is always allowed; running the sim and writing to the cache is only allowed when the depsgraph is active. Some pointers have moved from RigidBodyWorld (RBO) to RigidBodyWorldShared (RBOS). writefile.c copies some pointers back from RBOS to RBO so that the file can still be opened on older Blenders without crashing on a segfault. The RigidBodyWorldShared struct is written to the blend file, because it refers to the PointCache ID block. The RigidObjectShared struct is runtime-only, and thus not saved to the blend file. An RNA getter-function is used to hide the new 'shared' pointer. As a result the Python API hasn't changed. Reviewed by: campbellbarton Differential Revision: https://developer.blender.org/D3508 --- source/blender/blenkernel/intern/pointcache.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern/pointcache.c') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 3e8e6a69dd8..a8c6091124a 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1295,8 +1295,8 @@ static int ptcache_rigidbody_write(int index, void *rb_v, void **data, int UNUS if (rbo->type == RBO_TYPE_ACTIVE) { #ifdef WITH_BULLET - RB_body_get_position(rbo->physics_object, rbo->pos); - RB_body_get_orientation(rbo->physics_object, rbo->orn); + RB_body_get_position(rbo->shared->physics_object, rbo->pos); + RB_body_get_orientation(rbo->shared->physics_object, rbo->orn); #endif PTCACHE_DATA_FROM(data, BPHYS_DATA_LOCATION, rbo->pos); PTCACHE_DATA_FROM(data, BPHYS_DATA_ROTATION, rbo->orn); @@ -1619,9 +1619,9 @@ void BKE_ptcache_id_from_rigidbody(PTCacheID *pid, Object *ob, RigidBodyWorld *r pid->ob= ob; pid->calldata= rbw; pid->type= PTCACHE_TYPE_RIGIDBODY; - pid->cache= rbw->pointcache; - pid->cache_ptr= &rbw->pointcache; - pid->ptcaches= &rbw->ptcaches; + pid->cache= rbw->shared->pointcache; + pid->cache_ptr= &rbw->shared->pointcache; + pid->ptcaches= &rbw->shared->ptcaches; pid->totpoint= pid->totwrite= ptcache_rigidbody_totpoint; pid->error = ptcache_rigidbody_error; -- cgit v1.2.3