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:
authorAlexander Gavrilov <angavrilov@gmail.com>2016-08-12 18:23:29 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2016-08-16 15:46:36 +0300
commit9368bdab016badba7c7eb4ba449acd8d0c165367 (patch)
tree65f14ee3fe2394602cb3e7e30eacb32c322af1a3 /source/blender/blenkernel/intern/collision.c
parenta74dab86ee3bad8cefff8d0fa3b7ab54c8e2158f (diff)
Fix depsgraph to compute more accurate links for collision & force.
Current implementation more or less indiscriminately links physics objects to colliders and forces, ignoring precise details of layer checks and collider groups. The new depsgraph seemed to lack some such links at all. The relevant code in modifiers suffers from a lot of duplication. Different physics simulations use independent implementations of collision and similar things, which results in a lot of variance: * Cloth collides with objects on same or visible layer with dupli. * Softbody collides with objects on same layer without dupli. * Non-hair particles collide on same layer with dupli. * Smoke uses same code as cloth, but needs different modifier. * Dynamic paint "collides" with brushes on any layer without dupli. Force fields with absorption also imply dependency on colliders: * For most systems, colliders are selected from same layer as field. * For non-hair particles, it uses the same exact set as the particles. As a special quirk, smoke ignores smoke flow force fields; on the other hand dependency on such field implies dependency on the smoke domain. This introduces two utility functions each for old and new depsgraph that are flexible enough to handle all these variations, and uses them to handle particles, cloth, smoke, softbody and dynpaint. One thing to watch out for is that depsgraph code shouldn't rely on any properties that don't cause a graph rebuild when changed. This was violated in the original code that was building force field links, while taking zero field weights into account. This change may cause new dependency cycles in cases where necessary dependencies were missing, but may also remove cycles in situations where unnecessary links were previously created. It's also now possible to solve some cycles by switching to explicit groups, since they are now properly taken into account for dependencies. Differential Revision: https://developer.blender.org/D2141
Diffstat (limited to 'source/blender/blenkernel/intern/collision.c')
-rw-r--r--source/blender/blenkernel/intern/collision.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 8cac856b560..35a7aafdbde 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -503,12 +503,13 @@ static void add_collision_object(Object ***objs, unsigned int *numobj, unsigned
// return all collision objects in scene
// collision object will exclude self
-Object **get_collisionobjects(Scene *scene, Object *self, Group *group, unsigned int *numcollobj, unsigned int modifier_type)
+Object **get_collisionobjects_ext(Scene *scene, Object *self, Group *group, int layer, unsigned int *numcollobj, unsigned int modifier_type, bool dupli)
{
Base *base;
Object **objs;
GroupObject *go;
unsigned int numobj= 0, maxobj= 100;
+ int level = dupli ? 0 : 1;
objs= MEM_callocN(sizeof(Object *)*maxobj, "CollisionObjectsArray");
@@ -516,16 +517,14 @@ Object **get_collisionobjects(Scene *scene, Object *self, Group *group, unsigned
if (group) {
/* use specified group */
for (go= group->gobject.first; go; go= go->next)
- add_collision_object(&objs, &numobj, &maxobj, go->ob, self, 0, modifier_type);
+ add_collision_object(&objs, &numobj, &maxobj, go->ob, self, level, modifier_type);
}
else {
Scene *sce_iter;
/* add objects in same layer in scene */
for (SETLOOPER(scene, sce_iter, base)) {
- /* Need to check for active layers, too.
- Otherwise this check fails if the objects are not on the same layer - DG */
- if ((base->lay & self->lay) || (base->lay & scene->lay))
- add_collision_object(&objs, &numobj, &maxobj, base->object, self, 0, modifier_type);
+ if ( base->lay & layer )
+ add_collision_object(&objs, &numobj, &maxobj, base->object, self, level, modifier_type);
}
}
@@ -535,6 +534,13 @@ Object **get_collisionobjects(Scene *scene, Object *self, Group *group, unsigned
return objs;
}
+Object **get_collisionobjects(Scene *scene, Object *self, Group *group, unsigned int *numcollobj, unsigned int modifier_type)
+{
+ /* Need to check for active layers, too.
+ Otherwise this check fails if the objects are not on the same layer - DG */
+ return get_collisionobjects_ext(scene, self, group, self->lay | scene->lay, numcollobj, modifier_type, true);
+}
+
static void add_collider_cache_object(ListBase **objs, Object *ob, Object *self, int level)
{
CollisionModifierData *cmd= NULL;