Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Sun, 2 Dec 2018 03:15:43 +0000 (14:15 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 2 Dec 2018 03:16:09 +0000 (14:16 +1100)
15 files changed:
1  2 
source/blender/blenkernel/BKE_effect.h
source/blender/blenkernel/intern/cloth.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/rigidbody.c
source/blender/blenkernel/intern/smoke.c
source/blender/blenkernel/intern/softbody.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_modifier.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_particle.c

index 3d4154c572b0cb61cc9e6bb5001fa7e90fdc5a3a,f12c55e762c8f2455efa9a175b928587e166d112..9ba1bbdee07f81aea6b274d0e80562f15d2f84cf
@@@ -44,11 -44,8 +44,10 @@@ struct Collection
  struct ParticleSimulationData;
  struct ParticleData;
  struct ParticleKey;
 +struct Depsgraph;
 +struct ViewLayer;
  
- struct EffectorWeights *BKE_add_effector_weights(struct Collection *collection);
- struct PartDeflect *object_add_collision_fields(int type);
 -struct EffectorWeights *BKE_effector_add_weights(struct Group *group);
++struct EffectorWeights *BKE_effector_add_weights(struct Collection *collection);
  
  /* Input to effector code */
  typedef struct EffectedPoint {
@@@ -112,35 -108,13 +111,37 @@@ typedef struct EffectorCache 
        int flag;
  } EffectorCache;
  
- void free_partdeflect(struct PartDeflect *pd);
 +typedef struct EffectorRelation {
 +      struct EffectorRelation *next, *prev;
 +
 +      struct Object *ob;
 +      struct ParticleSystem *psys;
 +      struct PartDeflect *pd;
 +} EffectorRelation;
 +
++
+ struct PartDeflect *BKE_partdeflect_new(int type);
+ void                BKE_partdeflect_free(struct PartDeflect *pd);
  
 -struct ListBase *pdInitEffectors(struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src, struct EffectorWeights *weights, bool for_simulation);
 -void            pdEndEffectors(struct ListBase **effectors);
 -void            pdPrecalculateEffectors(struct ListBase *effectors);
 -void            pdDoEffectors(struct ListBase *effectors, struct ListBase *colliders, struct EffectorWeights *weights, struct EffectedPoint *point, float *force, float *impulse);
 +struct ListBase *BKE_effector_relations_create(
 +        struct Depsgraph *depsgraph,
 +        struct ViewLayer *view_layer,
 +        struct Collection *collection);
 +void BKE_effector_relations_free(struct ListBase *lb);
 +
 +struct ListBase *BKE_effectors_create(
 +        struct Depsgraph *depsgraph,
 +        struct Object *ob_src,
 +        struct ParticleSystem *psys_src,
 +        struct EffectorWeights *weights);
 +void BKE_effectors_apply(
 +        struct ListBase *effectors,
 +        struct ListBase *colliders,
 +        struct EffectorWeights *weights,
 +        struct EffectedPoint *point,
 +        float *force,
 +        float *impulse);
 +void BKE_effectors_free(struct ListBase *lb);
  
  void pd_point_from_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, struct EffectedPoint *point);
  void pd_point_from_loc(struct Scene *scene, float *loc, float *vel, int index, struct EffectedPoint *point);
index e10cfc381640a72a9b6a3ae01cbeafb21785b678,9666b1ef68f02e80d9436398baba0db28c96afbd..cf5b3d3a51b77d4cf843ff74339a6ec4a9adaf8c
@@@ -143,10 -129,8 +143,10 @@@ void cloth_init(ClothModifierData *clm
  
        clmd->sim_parms->voxel_cell_size = 0.1f;
  
 +      clmd->sim_parms->bending_model = CLOTH_BENDING_ANGULAR;
 +
        if (!clmd->sim_parms->effector_weights)
-               clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL);
+               clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL);
  
        if (clmd->point_cache)
                clmd->point_cache->step = 1;
index f54082de153e3575612874edde34d5bd176a5b4e,0a2d3fff073a6bb05ee0bddac86394744bc58b83..0c8a47be4b4a064c4da76789debce606c6d6da10
@@@ -87,7 -82,7 +87,7 @@@
  #include <string.h>
  #endif // WITH_MOD_FLUID
  
- EffectorWeights *BKE_add_effector_weights(Collection *collection)
 -EffectorWeights *BKE_effector_add_weights(Group *group)
++EffectorWeights *BKE_effector_add_weights(Collection *collection)
  {
        EffectorWeights *weights = MEM_callocN(sizeof(EffectorWeights), "EffectorWeights");
        int i;
@@@ -138,9 -132,10 +138,9 @@@ PartDeflect *BKE_partdeflect_new(int ty
        return pd;
  }
  
 -/* ***************** PARTICLES ***************** */
 +/************************ PARTICLES ***************************/
  
- void free_partdeflect(PartDeflect *pd)
 -/* -------------------------- Effectors ------------------ */
+ void BKE_partdeflect_free(PartDeflect *pd)
  {
        if (!pd) {
                return;
index 67edcff49a68587708997e4de1b9bcfec57cdd5c,5a9ecaa7232d53645b8b329b6d12384ce627e110..3e2e890f54273694ecfa48c13316d4687fa2e0a4
@@@ -582,11 -430,24 +582,11 @@@ void BKE_object_free(Object *ob
  
        BKE_constraints_free_ex(&ob->constraints, false);
  
-       free_partdeflect(ob->pd);
+       BKE_partdeflect_free(ob->pd);
 -      BKE_rigidbody_free_object(ob);
 +      BKE_rigidbody_free_object(ob, NULL);
        BKE_rigidbody_free_constraint(ob);
  
 -      if (ob->soft) {
 -              sbFree(ob->soft);
 -              ob->soft = NULL;
 -      }
 -      if (ob->bsoft) {
 -              bsbFree(ob->bsoft);
 -              ob->bsoft = NULL;
 -      }
 -      GPU_lamp_free(ob);
 +      sbFree(ob);
  
        BKE_sculptsession_free(ob);
  
index 6ceae2fdc2d2d642bff49d68607885fe97e2e46e,e24602050ef04120e1f1a883222939903a3c266e..5a9722a867c5394d0e5e194a23d6f2e0ed9622b6
@@@ -3211,8 -3308,13 +3211,8 @@@ static void default_particle_settings(P
        part->color_vec_max = 1.f;
        part->draw_col = PART_DRAW_COL_MAT;
  
 -      part->simplify_refsize = 1920;
 -      part->simplify_rate = 1.0f;
 -      part->simplify_transition = 0.1f;
 -      part->simplify_viewport = 0.8;
 -
        if (!part->effector_weights)
-               part->effector_weights = BKE_add_effector_weights(NULL);
+               part->effector_weights = BKE_effector_add_weights(NULL);
  
        part->omat = 1;
        part->use_modifier_stack = false;
index 919a0c5fa02117bfd885b35b0b93e5c6eb163e37,f485233fe3c07198d48b7cc4b3e87af3ac8a60df..9ca8c834bb98a4b3a23a314aead805478ac8bc9c
@@@ -952,10 -947,9 +952,10 @@@ RigidBodyWorld *BKE_rigidbody_create_wo
  
        /* create a new sim world */
        rbw = MEM_callocN(sizeof(RigidBodyWorld), "RigidBodyWorld");
 +      rbw->shared = MEM_callocN(sizeof(*rbw->shared), "RigidBodyWorld_Shared");
  
        /* set default settings */
-       rbw->effector_weights = BKE_add_effector_weights(NULL);
+       rbw->effector_weights = BKE_effector_add_weights(NULL);
  
        rbw->ltime = PSFRA;
  
index 4c1555e9451cd27630fa3c6fdf8a64dab8088cf0,9bcff23e134e9cc5c4bb446d4d0b1cd37e45c8df..2707e4eebd7d0079d1803318f2a0c8d71a2d55f2
@@@ -3276,11 -3321,10 +3276,11 @@@ SoftBody *sbNew(Scene *scene
        sb->shearstiff = 1.0f;
        sb->solverflags |= SBSO_OLDERR;
  
 -      sb->pointcache = BKE_ptcache_add(&sb->ptcaches);
 +      sb->shared = MEM_callocN(sizeof(*sb->shared), "SoftBody_Shared");
 +      sb->shared->pointcache = BKE_ptcache_add(&sb->shared->ptcaches);
  
        if (!sb->effector_weights)
-               sb->effector_weights = BKE_add_effector_weights(NULL);
+               sb->effector_weights = BKE_effector_add_weights(NULL);
  
        sb->last_frame= MINFRAME-1;
  
index acf6ead7d962fc1d5e4a88e02c387bf4f1b69c55,36221b7c60f3655bcc179cdfa3b755fd81abe78d..076370c887743fc376d40b2f0d598430b6a5cf53
@@@ -5625,21 -5581,11 +5625,21 @@@ static void direct_link_object(FileDat
  
                sb->effector_weights = newdataadr(fd, sb->effector_weights);
                if (!sb->effector_weights)
-                       sb->effector_weights = BKE_add_effector_weights(NULL);
+                       sb->effector_weights = BKE_effector_add_weights(NULL);
  
 -              direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache, 0);
 +              sb->shared = newdataadr(fd, sb->shared);
 +              if (sb->shared == NULL) {
 +                      /* Link deprecated caches if they exist, so we can use them for versioning.
 +                       * We should only do this when sb->shared == NULL, because those pointers
 +                       * are always set (for compatibility with older Blenders). We mustn't link
 +                       * the same pointcache twice. */
 +                      direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache, false);
 +              }
 +              else {
 +                      /* link caches */
 +                      direct_link_pointcache_list(fd, &sb->shared->ptcaches, &sb->shared->pointcache, false);
 +              }
        }
 -      ob->bsoft = newdataadr(fd, ob->bsoft);
        ob->fluidsimSettings = newdataadr(fd, ob->fluidsimSettings); /* NT */
  
        ob->rigidbody_object = newdataadr(fd, ob->rigidbody_object);
@@@ -6516,7 -6257,14 +6516,7 @@@ static void direct_link_scene(FileData 
                /* set effector weights */
                rbw->effector_weights = newdataadr(fd, rbw->effector_weights);
                if (!rbw->effector_weights)
-                       rbw->effector_weights = BKE_add_effector_weights(NULL);
+                       rbw->effector_weights = BKE_effector_add_weights(NULL);
 -
 -              /* link cache */
 -              direct_link_pointcache_list(fd, &rbw->ptcaches, &rbw->pointcache, false);
 -              /* make sure simulation starts from the beginning after loading file */
 -              if (rbw->pointcache) {
 -                      rbw->ltime = (float)rbw->pointcache->startframe;
 -              }
        }
  
        sce->preview = direct_link_preview_image(fd, sce->preview);
index 8abef6f6793a8587baf836a6f33a80eaeb9c29aa,a05f40765fa23b3ca5bea1d40c9d1998558f7132..09948d719f03ee64996056b64285f37c72229fc8
@@@ -587,9 -534,9 +587,9 @@@ static int effector_add_exec(bContext *
                        ob->empty_drawtype = OB_SINGLE_ARROW;
        }
  
-       ob->pd = object_add_collision_fields(type);
+       ob->pd = BKE_partdeflect_new(type);
  
 -      DAG_relations_tag_update(CTX_data_main(C));
 +      DEG_relations_tag_update(CTX_data_main(C));
  
        return OPERATOR_FINISHED;
  }