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

@@@ -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);
@@@ -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;
@@@ -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;
@@@ -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);
  
@@@ -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;
@@@ -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;
  
@@@ -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;
  
@@@ -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);
@@@ -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;
  }