Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Thu, 19 Apr 2018 10:53:21 +0000 (12:53 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 19 Apr 2018 10:53:21 +0000 (12:53 +0200)
1  2 
release/scripts/startup/bl_ui/properties_data_modifier.py
source/blender/blenkernel/intern/icons.c
source/blender/blenloader/intern/versioning_270.c
source/blender/editors/interface/interface_icons.c
source/blender/makesdna/DNA_modifier_types.h
source/blender/makesrna/intern/rna_modifier.c
source/blender/modifiers/intern/MOD_particleinstance.c

index b945965ce6a1c850a4bde5e59ddd8dd73c8a582b,ed57412c05c1effbb9e6767c307856ea33527cae..a33dcfc5ab6a6b02cc1b17a68d75e13f79e063cb
@@@ -874,11 -849,8 +874,11 @@@ void ui_icon_ensure_deferred(const bCon
                        switch (di->type) {
                                case ICON_TYPE_PREVIEW:
                                {
-                                       ID *id = (icon->type != 0) ? icon->obj : NULL;
+                                       ID *id = (icon->id_type != 0) ? icon->obj : NULL;
                                        PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) : icon->obj;
 +                                      /* Using jobs for screen previews crashes due to offscreen rendering.
 +                                       * XXX would be nicer if PreviewImage could store if it supports jobs */
 +                                      const bool use_jobs = !id || (GS(id->name) != ID_SCR);
  
                                        if (prv) {
                                                const int size = big ? ICON_SIZE_PREVIEW : ICON_SIZE_ICON;
@@@ -1232,12 -1119,12 +1232,12 @@@ static void icon_draw_size
  #endif
                if (!iimg->rect) return;  /* something has gone wrong! */
  
 -              glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 +              glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
                icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, is_preview);
 -              glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 +              glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
        }
        else if (di->type == ICON_TYPE_PREVIEW) {
-               PreviewImage *pi = (icon->type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : icon->obj;
+               PreviewImage *pi = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : icon->obj;
  
                if (pi) {
                        /* no create icon on this level in code */
index 99433ae3725f485cab7c6698a3e2c4060b11747b,f0b80cda447b37187cf1ccedc9d8be0dbab5c3b1..d7cb7fd8d941fccf13ae80f84dde479c35c30d83
  #include "BKE_particle.h"
  #include "BKE_pointcache.h"
  
 -#include "depsgraph_private.h"
  #include "DEG_depsgraph_build.h"
  
- #include "MOD_modifiertypes.h"
  static void initData(ModifierData *md)
  {
        ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md;
@@@ -154,16 -177,48 +162,48 @@@ static bool particle_skip(ParticleInsta
        }
  
        if (pa) {
-               if (pa->alive == PARS_UNBORN && (pimd->flag & eParticleInstanceFlag_Unborn) == 0) return 1;
-               if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0) return 1;
-               if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0) return 1;
+               if (pa->alive == PARS_UNBORN && (pimd->flag & eParticleInstanceFlag_Unborn) == 0) return true;
+               if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0) return true;
+               if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0) return true;
        }
  
-       return 0;
+       if (pimd->particle_amount == 1.0f) {
+               /* Early output, all particles are to be instanced. */
+               return false;
+       }
+       /* Randomly skip particles based on desired amount of visible particles. */
+       totpart = psys->totpart + psys->totchild;
+       /* TODO make randomization optional? */
+       randp = (int)(psys_frand(psys, 3578 + p) * totpart) % totpart;
+       minp = (int)(totpart * pimd->particle_offset) % (totpart+1);
+       maxp = (int)(totpart * (pimd->particle_offset + pimd->particle_amount)) % (totpart+1);
+       if (maxp > minp) {
+               return randp < minp || randp >= maxp;
+       }
+       else if (maxp < minp) {
+               return randp < minp && randp >= maxp;
+       }
+       else {
+               return true;
+       }
+       return false;
+ }
+ static void store_float_in_vcol(MLoopCol *vcol, float float_value)
+ {
+       const uchar value = FTOCHAR(float_value);
+       vcol->r = vcol->g = vcol->b = value;
+       vcol->a = 1.0f;
  }
  
 -static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
 -                                  DerivedMesh *derivedData,
 +static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
 +                                  Object *ob, DerivedMesh *derivedData,
                                    ModifierApplyFlag UNUSED(flag))
  {
        DerivedMesh *dm = derivedData, *result;
                return derivedData;
        }
  
-       if (pimd->flag & eParticleInstanceFlag_Parents)
-               totpart += psys->totpart;
-       if (pimd->flag & eParticleInstanceFlag_Children) {
-               if (totpart == 0)
-                       first_particle = psys->totpart;
-               totpart += psys->totchild;
-       }
+       part_start = use_parents ? 0 : psys->totpart;
+       part_end = 0;
+       if (use_parents)
+               part_end += psys->totpart;
+       if (use_children)
+               part_end += psys->totchild;
  
-       if (totpart == 0)
+       if (part_end == 0)
                return derivedData;
  
 +      sim.depsgraph = depsgraph;
        sim.scene = md->scene;
        sim.ob = pimd->ob;
        sim.psys = psys;
@@@ -437,9 -554,10 +540,9 @@@ ModifierTypeInfo modifierType_ParticleI
        /* applyModifier */     applyModifier,
        /* applyModifierEM */   NULL,
        /* initData */          initData,
-       /* requiredDataMask */  NULL,
+       /* requiredDataMask */  requiredDataMask,
        /* freeData */          NULL,
        /* isDisabled */        isDisabled,
 -      /* updateDepgraph */    updateDepgraph,
        /* updateDepsgraph */   updateDepsgraph,
        /* dependsOnTime */     NULL,
        /* dependsOnNormals */  NULL,