Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Sun, 3 Jun 2018 09:24:57 +0000 (11:24 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 3 Jun 2018 09:24:57 +0000 (11:24 +0200)
1  2 
source/blender/blenloader/intern/versioning_legacy.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/makesdna/DNA_action_types.h
source/blender/makesdna/DNA_space_types.h
source/blender/makesdna/DNA_view3d_types.h

index 9e0c3f3ccdc6012041b98845d4b98e4817a7d5b9,e2bfcad3f7ff581088c8c5ce0803b7ed20e21152..a450c487dd9f452ce5a7fa26560cb119e696d5e5
@@@ -45,6 -45,7 +45,6 @@@
  #define DNA_DEPRECATED_ALLOW
  
  #include "DNA_armature_types.h"
 -#include "DNA_actuator_types.h"
  #include "DNA_camera_types.h"
  #include "DNA_constraint_types.h"
  #include "DNA_effect_types.h"
  #include "DNA_node_types.h"
  #include "DNA_object_fluidsim_types.h"
  #include "DNA_object_types.h"
 -#include "DNA_property_types.h"
  #include "DNA_view3d_types.h"
  #include "DNA_screen_types.h"
 -#include "DNA_sensor_types.h"
  #include "DNA_sdna_types.h"
  #include "DNA_sequence_types.h"
  #include "DNA_sound_types.h"
@@@ -87,6 -90,7 +87,6 @@@
  #include "BKE_modifier.h"
  #include "BKE_particle.h"
  #include "BKE_pointcache.h"
 -#include "BKE_property.h" // for BKE_bproperty_object_get
  #include "BKE_scene.h"
  #include "BKE_sequencer.h"
  
@@@ -124,6 -128,38 +124,6 @@@ static void vcol_to_fcol(Mesh *me
        me->mcol = (MCol *)mcolmain;
  }
  
 -static int map_223_keybd_code_to_224_keybd_code(int code)
 -{
 -      switch (code) {
 -              case 312:
 -                      return 311; /* F12KEY */
 -              case 159:
 -                      return 161; /* PADSLASHKEY */
 -              case 161:
 -                      return 150; /* PAD0 */
 -              case 154:
 -                      return 151; /* PAD1 */
 -              case 150:
 -                      return 152; /* PAD2 */
 -              case 155:
 -                      return 153; /* PAD3 */
 -              case 151:
 -                      return 154; /* PAD4 */
 -              case 156:
 -                      return 155; /* PAD5 */
 -              case 152:
 -                      return 156; /* PAD6 */
 -              case 157:
 -                      return 157; /* PAD7 */
 -              case 153:
 -                      return 158; /* PAD8 */
 -              case 158:
 -                      return 159; /* PAD9 */
 -              default:
 -                      return code;
 -      }
 -}
 -
  static void do_version_bone_head_tail_237(Bone *bone)
  {
        Bone *child;
@@@ -212,6 -248,12 +212,6 @@@ static void ntree_version_242(bNodeTre
                        }
                }
        }
 -      else if (ntree->type == NTREE_SHADER) {
 -              for (node = ntree->nodes.first; node; node = node->next)
 -                      if (node->type == SH_NODE_GEOMETRY && node->storage == NULL)
 -                              node->storage = MEM_callocN(sizeof(NodeGeometry), "NodeGeometry");
 -      }
 -
  }
  
  static void ntree_version_245(FileData *fd, Library *lib, bNodeTree *ntree)
@@@ -277,6 -319,55 +277,6 @@@ static void idproperties_fix_group_leng
        }
  }
  
 -static void alphasort_version_246(FileData *fd, Library *lib, Mesh *me)
 -{
 -      Material *ma;
 -      MFace *mf;
 -      MTFace *tf;
 -      int a, b, texalpha;
 -
 -      /* verify we have a tface layer */
 -      for (b = 0; b < me->fdata.totlayer; b++)
 -              if (me->fdata.layers[b].type == CD_MTFACE)
 -                      break;
 -
 -      if (b == me->fdata.totlayer)
 -              return;
 -
 -      /* if we do, set alpha sort if the game engine did it before */
 -      for (a = 0, mf = me->mface; a < me->totface; a++, mf++) {
 -              if (mf->mat_nr < me->totcol) {
 -                      ma = blo_do_versions_newlibadr(fd, lib, me->mat[mf->mat_nr]);
 -                      texalpha = 0;
 -
 -                      /* we can't read from this if it comes from a library,
 -                       * because direct_link might not have happened on it,
 -                       * so ma->mtex is not pointing to valid memory yet */
 -                      if (ma && ma->id.lib)
 -                              ma = NULL;
 -
 -                      for (b = 0; ma && b < MAX_MTEX; b++)
 -                              if (ma->mtex[b] && ma->mtex[b]->mapto & MAP_ALPHA)
 -                                      texalpha = 1;
 -              }
 -              else {
 -                      ma = NULL;
 -                      texalpha = 0;
 -              }
 -
 -              for (b = 0; b < me->fdata.totlayer; b++) {
 -                      if (me->fdata.layers[b].type == CD_MTFACE) {
 -                              tf = ((MTFace*)me->fdata.layers[b].data) + a;
 -
 -                              tf->mode &= ~TF_ALPHASORT;
 -                              if (ma && (ma->mode & MA_ZTRANSP))
 -                                      if (ELEM(tf->transp, TF_ALPHA, TF_ADD) || (texalpha && (tf->transp != TF_CLIP)))
 -                                              tf->mode |= TF_ALPHASORT;
 -                      }
 -              }
 -      }
 -}
 -
  static void customdata_version_242(Mesh *me)
  {
        CustomDataLayer *layer;
                        for (a = 0; a < me->totface; a++, mtf++, tf++, mcol += 4) {
                                memcpy(mcol, tf->col, sizeof(tf->col));
                                memcpy(mtf->uv, tf->uv, sizeof(tf->uv));
 -
 -                              mtf->flag = tf->flag;
 -                              mtf->unwrap = tf->unwrap;
 -                              mtf->mode = tf->mode;
 -                              mtf->tile = tf->tile;
 -                              mtf->tpage = tf->tpage;
 -                              mtf->transp = tf->transp;
                        }
  
                        MEM_freeN(me->tface);
@@@ -519,6 -617,15 +519,6 @@@ void blo_do_versions_pre250(FileData *f
                }
        }
  
 -      if (main->versionfile <= 102) {
 -              /* init halo's at 1.0 */
 -              Material *ma = main->mat.first;
 -              while (ma) {
 -                      ma->add = 1.0;
 -                      ma = ma->id.next;
 -              }
 -      }
 -
        if (main->versionfile <= 103) {
                /* new variable in object: colbits */
                Object *ob = main->object.first;
  
        if (main->versionfile <= 107) {
                Object *ob;
 -              Scene *sce = main->scene.first;
 -              while (sce) {
 -                      sce->r.mode |= R_GAMMA;
 -                      sce = sce->id.next;
 -              }
                ob = main->object.first;
                while (ob) {
                        if (ob->dt == 0)
                }
        }
  
 -      if (main->versionfile <= 113) {
 -              Material *ma = main->mat.first;
 -              while (ma) {
 -                      if (ma->flaresize == 0.0f)
 -                              ma->flaresize = 1.0f;
 -                      ma->subsize = 1.0f;
 -                      ma->flareboost = 1.0f;
 -                      ma = ma->id.next;
 -              }
 -      }
 -
        if (main->versionfile <= 134) {
                Tex *tex = main->tex.first;
                while (tex) {
                }
        }
  
 -      if (main->versionfile <= 191) {
 -              Object *ob = main->object.first;
 -              Material *ma = main->mat.first;
 -
 -              /* let faces have default add factor of 0.0 */
 -              while (ma) {
 -                      if (!(ma->mode & MA_HALO))
 -                              ma->add = 0.0;
 -                      ma = ma->id.next;
 -              }
 -
 -              while (ob) {
 -                      ob->mass = 1.0f;
 -                      ob->damping = 0.1f;
 -                      /*ob->quat[1] = 1.0f;*/ /* quats arnt used yet */
 -                      ob = ob->id.next;
 -              }
 -      }
 -
 -      if (main->versionfile <= 193) {
 -              Object *ob = main->object.first;
 -              while (ob) {
 -                      ob->inertia = 1.0f;
 -                      ob->rdamping = 0.1f;
 -                      ob = ob->id.next;
 -              }
 -      }
 -
 -      if (main->versionfile <= 196) {
 -              Mesh *me = main->mesh.first;
 -              int a, b;
 -              while (me) {
 -                      if (me->tface) {
 -                              TFace *tface = me->tface;
 -                              for (a = 0; a < me->totface; a++, tface++) {
 -                                      for (b = 0; b < 4; b++) {
 -                                              tface->mode |= TF_DYNAMIC;
 -                                              tface->mode &= ~TF_INVISIBLE;
 -                                      }
 -                              }
 -                      }
 -                      me = me->id.next;
 -              }
 -      }
 -
 -      if (main->versionfile <= 200) {
 -              Object *ob = main->object.first;
 -              while (ob) {
 -                      ob->scaflag = ob->gameflag & (OB_DO_FH|OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS);
 -                              /* 64 is do_fh */
 -                      ob->gameflag &= ~(OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS);
 -                      ob = ob->id.next;
 -              }
 -      }
 -
 -      if (main->versionfile <= 201) {
 -              /* add-object + end-object are joined to edit-object actuator */
 -              Object *ob  = main->object.first;
 -              bProperty *prop;
 -              bActuator *act;
 -              bIpoActuator *ia;
 -              bEditObjectActuator *eoa;
 -              bAddObjectActuator *aoa;
 -              while (ob) {
 -                      act = ob->actuators.first;
 -                      while (act) {
 -                              if (act->type == ACT_IPO) {
 -                                      ia = act->data;
 -                                      prop = BKE_bproperty_object_get(ob, ia->name);
 -                                      if (prop) {
 -                                              ia->type = ACT_IPO_FROM_PROP;
 -                                      }
 -                              }
 -                              else if (act->type == ACT_ADD_OBJECT) {
 -                                      aoa = act->data;
 -                                      eoa = MEM_callocN(sizeof(bEditObjectActuator), "edit ob act");
 -                                      eoa->type = ACT_EDOB_ADD_OBJECT;
 -                                      eoa->ob = aoa->ob;
 -                                      eoa->time = aoa->time;
 -                                      MEM_freeN(aoa);
 -                                      act->data = eoa;
 -                                      act->type = act->otype = ACT_EDIT_OBJECT;
 -                              }
 -                              else if (act->type == ACT_END_OBJECT) {
 -                                      eoa = MEM_callocN(sizeof(bEditObjectActuator), "edit ob act");
 -                                      eoa->type = ACT_EDOB_END_OBJECT;
 -                                      act->data = eoa;
 -                                      act->type = act->otype = ACT_EDIT_OBJECT;
 -                              }
 -                              act = act->next;
 -                      }
 -                      ob = ob->id.next;
 -              }
 -      }
 -
 -      if (main->versionfile <= 202) {
 -              /* add-object and end-object are joined to edit-object
 -               * actuator */
 -              Object *ob = main->object.first;
 -              bActuator *act;
 -              bObjectActuator *oa;
 -              while (ob) {
 -                      act = ob->actuators.first;
 -                      while (act) {
 -                              if (act->type == ACT_OBJECT) {
 -                                      oa = act->data;
 -                                      oa->flag &= ~(ACT_TORQUE_LOCAL|ACT_DROT_LOCAL);         /* this actuator didn't do local/glob rot before */
 -                              }
 -                              act = act->next;
 -                      }
 -                      ob = ob->id.next;
 -              }
 -      }
 -
        if (main->versionfile <= 204) {
 -              /* patches for new physics */
 -              Object *ob = main->object.first;
 -              bActuator *act;
 -              bObjectActuator *oa;
                bSound *sound;
 -              while (ob) {
 -
 -                      /* please check this for demo20 files like
 -                       * original Egypt levels etc.  converted
 -                       * rotation factor of 50 is not workable */
 -                      act = ob->actuators.first;
 -                      while (act) {
 -                              if (act->type == ACT_OBJECT) {
 -                                      oa = act->data;
 -
 -                                      oa->forceloc[0] *= 25.0f;
 -                                      oa->forceloc[1] *= 25.0f;
 -                                      oa->forceloc[2] *= 25.0f;
 -
 -                                      oa->forcerot[0] *= 10.0f;
 -                                      oa->forcerot[1] *= 10.0f;
 -                                      oa->forcerot[2] *= 10.0f;
 -                              }
 -                              act = act->next;
 -                      }
 -                      ob = ob->id.next;
 -              }
  
                sound = main->sound.first;
                while (sound) {
                }
        }
  
 -      if (main->versionfile <= 205) {
 -              /* patches for new physics */
 -              Object *ob = main->object.first;
 -              bActuator *act;
 -              bSensor *sens;
 -              bEditObjectActuator *oa;
 -              bRaySensor *rs;
 -              bCollisionSensor *cs;
 -              while (ob) {
 -                      /* Set anisotropic friction off for old objects,
 -                       * values to 1.0.  */
 -                      ob->gameflag &= ~OB_ANISOTROPIC_FRICTION;
 -                      ob->anisotropicFriction[0] = 1.0;
 -                      ob->anisotropicFriction[1] = 1.0;
 -                      ob->anisotropicFriction[2] = 1.0;
 -
 -                      act = ob->actuators.first;
 -                      while (act) {
 -                              if (act->type == ACT_EDIT_OBJECT) {
 -                                      /* Zero initial velocity for newly
 -                                       * added objects */
 -                                      oa = act->data;
 -                                      oa->linVelocity[0] = 0.0;
 -                                      oa->linVelocity[1] = 0.0;
 -                                      oa->linVelocity[2] = 0.0;
 -                                      oa->localflag = 0;
 -                              }
 -                              act = act->next;
 -                      }
 -
 -                      sens = ob->sensors.first;
 -                      while (sens) {
 -                              /* Extra fields for radar sensors. */
 -                              if (sens->type == SENS_RADAR) {
 -                                      bRadarSensor *s = sens->data;
 -                                      s->range = 10000.0;
 -                              }
 -
 -                              /* Pulsing: defaults for new sensors. */
 -                              if (sens->type != SENS_ALWAYS) {
 -                                      sens->pulse = 0;
 -                                      sens->freq = 0;
 -                              }
 -                              else {
 -                                      sens->pulse = 1;
 -                              }
 -
 -                              /* Invert: off. */
 -                              sens->invert = 0;
 -
 -                              /* Collision and ray: default = trigger
 -                               * on property. The material field can
 -                               * remain empty. */
 -                              if (sens->type == SENS_COLLISION) {
 -                                      cs = (bCollisionSensor*) sens->data;
 -                                      cs->mode = 0;
 -                              }
 -                              if (sens->type == SENS_RAY) {
 -                                      rs = (bRaySensor*) sens->data;
 -                                      rs->mode = 0;
 -                              }
 -                              sens = sens->next;
 -                      }
 -                      ob = ob->id.next;
 -              }
 -              /* have to check the exact multiplier */
 -      }
 -
 -      if (main->versionfile <= 211) {
 -              /* Render setting: per scene, the applicable gamma value
 -               * can be set. Default is 1.0, which means no
 -               * correction.  */
 -              bActuator *act;
 -              bObjectActuator *oa;
 -              Object *ob;
 -
 -              /* added alpha in obcolor */
 -              ob = main->object.first;
 -              while (ob) {
 -                      ob->col[3] = 1.0;
 -                      ob = ob->id.next;
 -              }
 -
 -              /* added alpha in obcolor */
 -              ob = main->object.first;
 -              while (ob) {
 -                      act = ob->actuators.first;
 -                      while (act) {
 -                              if (act->type == ACT_OBJECT) {
 -                                      /* multiply velocity with 50 in old files */
 -                                      oa = act->data;
 -                                      if (fabsf(oa->linearvelocity[0]) >= 0.01f)
 -                                              oa->linearvelocity[0] *= 50.0f;
 -                                      if (fabsf(oa->linearvelocity[1]) >= 0.01f)
 -                                              oa->linearvelocity[1] *= 50.0f;
 -                                      if (fabsf(oa->linearvelocity[2]) >= 0.01f)
 -                                              oa->linearvelocity[2] *= 50.0f;
 -                                      if (fabsf(oa->angularvelocity[0]) >= 0.01f)
 -                                              oa->angularvelocity[0] *= 50.0f;
 -                                      if (fabsf(oa->angularvelocity[1]) >= 0.01f)
 -                                              oa->angularvelocity[1] *= 50.0f;
 -                                      if (fabsf(oa->angularvelocity[2]) >= 0.01f)
 -                                              oa->angularvelocity[2] *= 50.0f;
 -                              }
 -                              act = act->next;
 -                      }
 -                      ob = ob->id.next;
 -              }
 -      }
 -
        if (main->versionfile <= 212) {
                bSound *sound;
 -              bProperty *prop;
 -              Object *ob;
                Mesh *me;
  
                sound = main->sound.first;
                        sound = sound->id.next;
                }
  
 -              ob = main->object.first;
 -
 -              while (ob) {
 -                      prop = ob->prop.first;
 -                      while (prop) {
 -                              if (prop->type == GPROP_TIME) {
 -                                      // convert old GPROP_TIME values from int to float
 -                                      *((float *)&prop->data) = (float) prop->data;
 -                              }
 -
 -                              prop = prop->next;
 -                      }
 -                      ob = ob->id.next;
 -              }
 -
                /* me->subdiv changed to reflect the actual reparametization
                 * better, and smeshes were removed - if it was a smesh make
                 * it a subsurf, and reset the subdiv level because subsurf
        }
  
        if (main->versionfile <= 220) {
 -              Object *ob;
                Mesh *me;
  
 -              ob = main->object.first;
 -
 -              /* adapt form factor in order to get the 'old' physics
 -               * behavior back...
 -               */
 -
 -              while (ob) {
 -                      /* in future, distinguish between different
 -                       * object bounding shapes
 -                       */
 -                      ob->formfactor = 0.4f;
 -                      /* patch form factor, note that inertia equiv radius
 -                       * of a rotation symmetrical obj
 -                       */
 -                      if (ob->inertia != 1.0f) {
 -                              ob->formfactor /= ob->inertia * ob->inertia;
 -                      }
 -                      ob = ob->id.next;
 -              }
 -
                /* Began using alpha component of vertex colors, but
                 * old file vertex colors are undefined, reset them
                 * to be fully opaque. -zr
                }
        }
  
 -      if (main->versionfile <= 221) {
 -              Scene *sce = main->scene.first;
 -
 -              /* new variables for std-alone player and runtime */
 -              while (sce) {
 -                      sce->r.xplay = 640;
 -                      sce->r.yplay = 480;
 -                      sce->r.freqplay = 60;
 -
 -                      sce = sce->id.next;
 -              }
 -
 -      }
 -
 -      if (main->versionfile <= 222) {
 -              Scene *sce = main->scene.first;
 -
 -              /* new variables for std-alone player and runtime */
 -              while (sce) {
 -                      sce->r.depth = 32;
 -
 -                      sce = sce->id.next;
 -              }
 -      }
 -
        if (main->versionfile <= 223) {
                VFont *vf;
 -              Image *ima;
 -              Object *ob;
 -
                for (vf = main->vfont.first; vf; vf = vf->id.next) {
                        if (STREQ(vf->name + strlen(vf->name) - 6, ".Bfont")) {
                                strcpy(vf->name, FO_BUILTIN_NAME);
                        }
                }
 -
 -              /* Old textures animate at 25 FPS */
 -              for (ima = main->image.first; ima; ima = ima->id.next) {
 -                      ima->animspeed = 25;
 -              }
 -
 -              /* Zr remapped some keyboard codes to be linear (stupid zr) */
 -              for (ob = main->object.first; ob; ob = ob->id.next) {
 -                      bSensor *sens;
 -
 -                      for (sens = ob->sensors.first; sens; sens = sens->next) {
 -                              if (sens->type == SENS_KEYBOARD) {
 -                                      bKeyboardSensor *ks = sens->data;
 -
 -                                      ks->key = map_223_keybd_code_to_224_keybd_code(ks->key);
 -                                      ks->qual = map_223_keybd_code_to_224_keybd_code(ks->qual);
 -                                      ks->qual2 = map_223_keybd_code_to_224_keybd_code(ks->qual2);
 -                              }
 -                      }
 -              }
        }
  
        if (main->versionfile <= 224) {
                }
        }
  
 -      if (main->versionfile <= 225) {
 -              World *wo;
 -              /* Use Sumo for old games */
 -              for (wo = main->world.first; wo; wo = wo->id.next) {
 -                      wo->physicsEngine = 2;
 -              }
 -      }
 -
        if (main->versionfile <= 227) {
                Scene *sce;
 -              Material *ma;
                bScreen *sc;
                Object *ob;
  
                for (sce = main->scene.first; sce; sce = sce->id.next) {
                        sce->audio.mixrate = 48000;
                        sce->audio.flag |= AUDIO_SCRUB;
 -                      sce->r.mode |= R_ENVMAP;
 -              }
 -
 -              /* init new shader vars */
 -              for (ma = main->mat.first; ma; ma = ma->id.next) {
 -                      ma->refrac = 4.0f;
 -                      ma->roughness = 0.5f;
 -                      ma->param[0] = 0.5f;
 -                      ma->param[1] = 0.1f;
 -                      ma->param[2] = 0.1f;
 -                      ma->param[3] = 0.05f;
                }
  
                /* patch for old wrong max view2d settings, allows zooming out more */
        }
  
        if (main->versionfile <= 228) {
 -              Scene *sce;
                bScreen *sc;
                Object *ob;
  
                        ob = ob->id.next;
                }
  
 -              for (sce = main->scene.first; sce; sce = sce->id.next) {
 -                      sce->r.mode |= R_ENVMAP;
 -              }
 -
                /* convert old mainb values for new button panels */
                for (sc = main->screen.first; sc; sc = sc->id.next) {
                        ScrArea *sa;
                                                        sbuts->mainb = CONTEXT_SCENE;
                                                        //sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_RENDER;
                                                }
 -                                              else if (sbuts->mainb == BUTS_GAME) {
 -                                                      sbuts->mainb = CONTEXT_LOGIC;
 -                                              }
                                                else if (sbuts->mainb == BUTS_FPAINT) {
                                                        sbuts->mainb = CONTEXT_EDITING;
                                                }
                                SpaceLink *sl;
  
                                for (sl = sa->spacedata.first; sl; sl = sl->next) {
-                                       if (sl->blockscale == 0.0f)
-                                               sl->blockscale = 0.7f;
                                        /* added: 5x better zoom in for action */
                                        if (sl->spacetype == SPACE_ACTION) {
                                                SpaceAction *sac = (SpaceAction *)sl;
        }
  
        if (main->versionfile <= 231) {
 -              Material *ma = main->mat.first;
                bScreen *sc = main->screen.first;
 -              Scene *sce;
 -              Lamp *la;
 -              World *wrld;
 -
 -              /* introduction of raytrace */
 -              while (ma) {
 -                      if (ma->fresnel_tra_i == 0.0f)
 -                              ma->fresnel_tra_i = 1.25f;
 -                      if (ma->fresnel_mir_i == 0.0f)
 -                              ma->fresnel_mir_i = 1.25f;
 -
 -                      ma->ang = 1.0;
 -                      ma->ray_depth = 2;
 -                      ma->ray_depth_tra = 2;
 -                      ma->fresnel_tra = 0.0;
 -                      ma->fresnel_mir = 0.0;
 -
 -                      ma = ma->id.next;
 -              }
 -              sce = main->scene.first;
 -              while (sce) {
 -                      if (sce->r.gauss == 0.0f)
 -                              sce->r.gauss = 1.0f;
 -                      sce = sce->id.next;
 -              }
 -              la = main->lamp.first;
 -              while (la) {
 -                      if (la->k == 0.0f) la->k = 1.0;
 -                      if (la->ray_samp == 0)
 -                              la->ray_samp = 1;
 -                      if (la->ray_sampy == 0)
 -                              la->ray_sampy = 1;
 -                      if (la->ray_sampz == 0)
 -                              la->ray_sampz = 1;
 -                      if (la->area_size == 0.0f)
 -                              la->area_size = 1.0f;
 -                      if (la->area_sizey == 0.0f)
 -                              la->area_sizey = 1.0f;
 -                      if (la->area_sizez == 0.0f)
 -                              la->area_sizez = 1.0f;
 -                      la = la->id.next;
 -              }
 -              wrld = main->world.first;
 -              while (wrld) {
 -                      if (wrld->range == 0.0f) {
 -                              wrld->range = 1.0f / wrld->exposure;
 -                      }
 -                      wrld = wrld->id.next;
 -              }
  
                /* new bit flags for showing/hiding grid floor and axes */
  
                Tex *tex = main->tex.first;
                World *wrld = main->world.first;
                bScreen *sc;
 -              Scene *sce;
  
                while (tex) {
                        if ((tex->flag & (TEX_CHECKER_ODD+TEX_CHECKER_EVEN))==0) {
                while (wrld) {
                        if (wrld->aodist == 0.0f) {
                                wrld->aodist = 10.0f;
 -                              wrld->aobias = 0.05f;
                        }
 -                      if (wrld->aosamp == 0)
 -                              wrld->aosamp = 5;
                        if (wrld->aoenergy == 0.0f)
                                wrld->aoenergy = 1.0f;
                        wrld = wrld->id.next;
                        for (sa = sc->areabase.first; sa; sa = sa->next) {
                                SpaceLink *sl;
                                for (sl = sa->spacedata.first; sl; sl = sl->next) {
-                                       if (sl->blockscale == 0.0f)
-                                               sl->blockscale = 0.7f;
                                        /* added: 5x better zoom in for nla */
                                        if (sl->spacetype == SPACE_NLA) {
                                                SpaceNla *snla = (SpaceNla *) sl;
                                }
                        }
                }
 -              sce = main->scene.first;
 -              while (sce) {
 -                      if (sce->r.ocres == 0)
 -                              sce->r.ocres = 64;
 -                      sce = sce->id.next;
 -              }
 -
        }
  
        if (main->versionfile <= 233) {
                /* Object *ob = main->object.first; */
  
                while (ma) {
 -                      if (ma->rampfac_col == 0.0f)
 -                              ma->rampfac_col = 1.0;
 -                      if (ma->rampfac_spec == 0.0f)
 -                              ma->rampfac_spec = 1.0;
                        if (ma->pr_lamp == 0)
                                ma->pr_lamp = 3;
                        ma = ma->id.next;
        }
  
        if (main->versionfile <= 234) {
 -              World *wo;
                bScreen *sc;
  
 -              /* force sumo engine to be active */
 -              for (wo = main->world.first; wo; wo = wo->id.next) {
 -                      if (wo->physicsEngine == 0)
 -                              wo->physicsEngine = 2;
 -              }
 -
                for (sc = main->screen.first; sc; sc = sc->id.next) {
                        ScrArea *sa;
                        for (sa = sc->areabase.first; sa; sa = sa->next) {
        if (main->versionfile <= 236) {
                Object *ob;
                Camera *cam = main->camera.first;
 -              Material *ma;
 -              bScreen *sc;
  
                while (cam) {
                        if (cam->ortho_scale == 0.0f) {
                        }
                        cam = cam->id.next;
                }
 -              /* set manipulator type */
                /* force oops draw if depgraph was set*/
                /* set time line var */
 -              for (sc = main->screen.first; sc; sc = sc->id.next) {
 -                      ScrArea *sa;
 -                      for (sa = sc->areabase.first; sa; sa = sa->next) {
 -                              SpaceLink *sl;
 -                              for (sl = sa->spacedata.first; sl; sl = sl->next) {
 -                                      if (sl->spacetype == SPACE_VIEW3D) {
 -                                              View3D *v3d = (View3D *) sl;
 -                                              if (v3d->twtype == 0)
 -                                                      v3d->twtype = V3D_MANIP_TRANSLATE;
 -                                      }
 -                              }
 -                      }
 -              }
 -              /* init new shader vars */
 -              for (ma = main->mat.first; ma; ma = ma->id.next) {
 -                      if (ma->darkness == 0.0f) {
 -                              ma->rms = 0.1f;
 -                              ma->darkness = 1.0f;
 -                      }
 -              }
  
                /* softbody init new vars */
                for (ob = main->object.first; ob; ob = ob->id.next) {
                                        BKE_pose_tag_recalc(main, ob->pose);
  
                                /* cannot call stuff now (pointers!), done in setup_app_data */
 -                              ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
 +                              ob->id.recalc |= ID_RECALC_ALL;
  
                                /* new generic xray option */
                                arm = blo_do_versions_newlibadr(fd, lib, ob->data);
                Object *ob;
                Scene *sce = main->scene.first;
                Camera *cam = main->camera.first;
 -              Material *ma = main->mat.first;
                int set_passepartout = 0;
  
                /* deformflag is local in modifier now */
                                set_passepartout = 1;
                                sce->r.scemode &= ~R_PASSEPARTOUT;
                        }
 -                      /* gauss is filter variable now */
 -                      if (sce->r.mode & R_GAUSS) {
 -                              sce->r.filtertype = R_FILTER_GAUSS;
 -                              sce->r.mode &= ~R_GAUSS;
 -                      }
                }
  
                for (; cam; cam = cam->id.next) {
                        if (!(cam->passepartalpha))
                                cam->passepartalpha = 0.2f;
                }
 -
 -              for (; ma; ma = ma->id.next) {
 -                      if (ma->strand_sta == 0.0f) {
 -                              ma->strand_sta = ma->strand_end = 1.0f;
 -                              ma->mode |= MA_TANGENT_STR;
 -                      }
 -                      if (ma->mode & MA_TRACEBLE)
 -                              ma->mode |= MA_SHADBUF;
 -              }
        }
  
        if (main->versionfile <= 241) {
                Object *ob;
 -              Tex *tex;
                Scene *sce;
 -              World *wo;
                Lamp *la;
 -              Material *ma;
                bArmature *arm;
                bNodeTree *ntree;
  
 -              for (wo = main->world.first; wo; wo = wo->id.next) {
 -                      /* Migrate to Bullet for games, except for the NaN versions */
 -                      /* People can still explicitly choose for Sumo (after 2.42 is out) */
 -                      if (main->versionfile > 225)
 -                              wo->physicsEngine = WOPHY_BULLET;
 -                      if (WO_AODIST == wo->aomode)
 -                              wo->aocolor = WO_AOPLAIN;
 -              }
 -
                /* updating layers still */
                for (arm = main->armature.first; arm; arm = arm->id.next) {
                        bone_version_239(&arm->bonebase);
                        if (sce->audio.mixrate == 0)
                                sce->audio.mixrate = 48000;
  
 -                      if (sce->r.xparts <2 )
 -                              sce->r.xparts = 4;
 -                      if (sce->r.yparts < 2)
 -                              sce->r.yparts = 4;
 -
 -                      /* adds default layer */
 -                      if (BLI_listbase_is_empty(&sce->r.layers)) {
 -                              BKE_scene_add_render_layer(sce, NULL);
 -                      }
 -                      else {
 -                              SceneRenderLayer *srl;
 -                              /* new layer flag for sky, was default for solid */
 -                              for (srl = sce->r.layers.first; srl; srl = srl->next) {
 -                                      if (srl->layflag & SCE_LAY_SOLID)
 -                                              srl->layflag |= SCE_LAY_SKY;
 -                                      srl->passflag &= (SCE_PASS_COMBINED|SCE_PASS_Z|SCE_PASS_NORMAL|SCE_PASS_VECTOR);
 -                              }
 +                      /* We don't add default layer since blender2.8 because the layers
 +                       * are now in Scene->view_layers and a default layer is created in
 +                       * the doversion later on.
 +                       */
 +                      SceneRenderLayer *srl;
 +                      /* new layer flag for sky, was default for solid */
 +                      for (srl = sce->r.layers.first; srl; srl = srl->next) {
 +                              if (srl->layflag & SCE_LAY_SOLID)
 +                                      srl->layflag |= SCE_LAY_SKY;
 +                              srl->passflag &= (SCE_PASS_COMBINED|SCE_PASS_Z|SCE_PASS_NORMAL|SCE_PASS_VECTOR);
                        }
  
                        /* node version changes */
                                sce->toolsettings->uvcalc_flag = UVCALC_FILLHOLES;
                                sce->toolsettings->unwrapper = 1;
                        }
 -
 -                      if (sce->r.mode & R_PANORAMA) {
 -                              /* all these checks to ensure saved files between released versions keep working... */
 -                              if (sce->r.xsch < sce->r.ysch) {
 -                                      Object *obc = blo_do_versions_newlibadr(fd, lib, sce->camera);
 -                                      if (obc && obc->type == OB_CAMERA) {
 -                                              Camera *cam = blo_do_versions_newlibadr(fd, lib, obc->data);
 -                                              if (cam->lens >= 10.0f) {
 -                                                      sce->r.xsch *= sce->r.xparts;
 -                                                      cam->lens *= (float)sce->r.ysch / (float)sce->r.xsch;
 -                                              }
 -                                      }
 -                              }
 -                      }
                }
  
                for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
                        if (la->buffers == 0)
                                la->buffers = 1;
  
 -              for (tex = main->tex.first; tex; tex = tex->id.next) {
 -                      if (tex->env && tex->env->viewscale == 0.0f)
 -                              tex->env->viewscale = 1.0f;
 -                      //tex->imaflag |= TEX_GAUSS_MIP;
 -              }
 -
                /* for empty drawsize and drawtype */
                for (ob = main->object.first; ob; ob = ob->id.next) {
                        if (ob->empty_drawsize == 0.0f) {
                        }
                }
  
 -              for (ma = main->mat.first; ma; ma = ma->id.next) {
 -                      /* stucci returns intensity from now on */
 -                      int a;
 -                      for (a = 0; a < MAX_MTEX; a++) {
 -                              if (ma->mtex[a] && ma->mtex[a]->tex) {
 -                                      tex = blo_do_versions_newlibadr(fd, lib, ma->mtex[a]->tex);
 -                                      if (tex && tex->type == TEX_STUCCI)
 -                                              ma->mtex[a]->mapto &= ~(MAP_COL|MAP_SPEC|MAP_REF);
 -                              }
 -                      }
 -                      /* transmissivity defaults */
 -                      if (ma->tx_falloff == 0.0f)
 -                              ma->tx_falloff = 1.0f;
 -              }
 -
                /* during 2.41 images with this name were used for viewer node output, lets fix that */
                if (main->versionfile == 241) {
                        Image *ima;
                Curve *cu;
                Material *ma;
                Mesh *me;
 -              Group *group;
 +              Collection *collection;
                Nurb *nu;
                BezTriple *bezt;
                BPoint *bp;
                }
  
                for (ma = main->mat.first; ma; ma = ma->id.next) {
 -                      if (ma->shad_alpha == 0.0f)
 -                              ma->shad_alpha = 1.0f;
                        if (ma->nodetree)
                                ntree_version_242(ma->nodetree);
                }
                for (me = main->mesh.first; me; me = me->id.next)
                        customdata_version_242(me);
  
 -              for (group = main->group.first; group; group = group->id.next)
 -                      if (group->layer == 0)
 -                              group->layer = (1 << 20) - 1;
 +              for (collection = main->collection.first; collection; collection = collection->id.next)
 +                      if (collection->layer == 0)
 +                              collection->layer = (1 << 20) - 1;
  
                /* now, subversion control! */
                if (main->subversionfile < 3) {
                                for (sa = sc->areabase.first; sa; sa = sa->next) {
                                        SpaceLink *sl;
                                        for (sl = sa->spacedata.first; sl; sl = sl->next) {
 -                                              if (sl->spacetype == SPACE_IMAGE)
 +                                              if (sl->spacetype == SPACE_IMAGE) {
                                                        ((SpaceImage *)sl)->iuser.fie_ima = 2;
 -                                              else if (sl->spacetype == SPACE_VIEW3D) {
 -                                                      View3D *v3d = (View3D *)sl;
 -                                                      BGpic *bgpic;
 -                                                      for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next)
 -                                                              bgpic->iuser.fie_ima = 2;
                                                }
                                        }
                                }
                        for (sce = main->scene.first; sce; sce = sce->id.next) {
                                sce->r.bake_mode = 1;   /* prevent to include render stuff here */
                                sce->r.bake_filter = 16;
 -                              sce->r.bake_osa = 5;
                                sce->r.bake_flag = R_BAKE_CLEAR;
                        }
                }
  
        if (main->versionfile <= 243) {
                Object *ob = main->object.first;
 -              Material *ma;
 -
 -              for (ma = main->mat.first; ma; ma = ma->id.next) {
 -                      if (ma->sss_scale == 0.0f) {
 -                              ma->sss_radius[0] = 1.0f;
 -                              ma->sss_radius[1] = 1.0f;
 -                              ma->sss_radius[2] = 1.0f;
 -                              ma->sss_col[0] = 0.8f;
 -                              ma->sss_col[1] = 0.8f;
 -                              ma->sss_col[2] = 0.8f;
 -                              ma->sss_error = 0.05f;
 -                              ma->sss_scale = 0.1f;
 -                              ma->sss_ior = 1.3f;
 -                              ma->sss_colfac = 1.0f;
 -                              ma->sss_texfac = 0.0f;
 -                      }
 -                      if (ma->sss_front == 0 && ma->sss_back == 0) {
 -                              ma->sss_front = 1.0f;
 -                              ma->sss_back = 1.0f;
 -                      }
 -                      if (ma->sss_col[0] == 0 && ma->sss_col[1] == 0 && ma->sss_col[2] == 0) {
 -                              ma->sss_col[0] = ma->r;
 -                              ma->sss_col[1] = ma->g;
 -                              ma->sss_col[2] = ma->b;
 -                      }
 -              }
  
                for (; ob; ob = ob->id.next) {
                        bDeformGroup *curdef;
        }
  
        if (main->versionfile <= 244) {
 -              Scene *sce;
                bScreen *sc;
 -              Lamp *la;
 -              World *wrld;
  
                if (main->versionfile != 244 || main->subversionfile < 2) {
 -                      for (sce = main->scene.first; sce; sce = sce->id.next)
 -                              sce->r.mode |= R_SSS;
 -
                        /* correct older action editors - incorrect scrolling */
                        for (sc = main->screen.first; sc; sc = sc->id.next) {
                                ScrArea *sa;
                                }
                        }
                }
 -
 -              if (main->versionfile != 244 || main->subversionfile < 3) {
 -                      /* constraints recode version patch used to be here. Moved to 245 now... */
 -
 -                      for (wrld = main->world.first; wrld; wrld = wrld->id.next) {
 -                              if (wrld->mode & WO_AMB_OCC)
 -                                      wrld->ao_samp_method = WO_AOSAMP_CONSTANT;
 -                              else
 -                                      wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY;
 -
 -                              wrld->ao_adapt_thresh = 0.005f;
 -                      }
 -
 -                      for (la = main->lamp.first; la; la = la->id.next) {
 -                              if (la->type == LA_AREA)
 -                                      la->ray_samp_method = LA_SAMP_CONSTANT;
 -                              else
 -                                      la->ray_samp_method = LA_SAMP_HALTON;
 -
 -                              la->adapt_thresh = 0.001f;
 -                      }
 -              }
        }
  
        if (main->versionfile <= 245) {
                Lamp *la;
                Material *ma;
                ParticleSettings *part;
 -              World *wrld;
                Mesh *me;
                bNodeTree *ntree;
                Tex *tex;
  
                if (main->versionfile != 245 || main->subversionfile < 1) {
                        for (la = main->lamp.first; la; la = la->id.next) {
 -                              if (la->mode & LA_QUAD)
 -                                      la->falloff_type = LA_FALLOFF_SLIDERS;
 -                              else
 -                                      la->falloff_type = LA_FALLOFF_INVLINEAR;
 +                              la->falloff_type = LA_FALLOFF_INVLINEAR;
  
                                if (la->curfalloff == NULL) {
                                        la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
                }
  
                for (ma = main->mat.first; ma; ma = ma->id.next) {
 -                      if (ma->samp_gloss_mir == 0) {
 -                              ma->gloss_mir = ma->gloss_tra = 1.0f;
 -                              ma->aniso_gloss_mir = 1.0f;
 -                              ma->samp_gloss_mir = ma->samp_gloss_tra = 18;
 -                              ma->adapt_thresh_mir = ma->adapt_thresh_tra = 0.005f;
 -                              ma->dist_mir = 0.0f;
 -                              ma->fadeto_mir = MA_RAYMIR_FADETOSKY;
 +                      if (ma->gloss_mir == 0.0f) {
 +                              ma->gloss_mir = 1.0f;
                        }
 -
 -                      if (ma->strand_min == 0.0f)
 -                              ma->strand_min = 1.0f;
                }
  
                for (part = main->particle.first; part; part = part->id.next) {
                        if (part->ren_child_nbr == 0)
                                part->ren_child_nbr = part->child_nbr;
 -
 -                      if (part->simplify_refsize == 0) {
 -                              part->simplify_refsize = 1920;
 -                              part->simplify_rate = 1.0f;
 -                              part->simplify_transition = 0.1f;
 -                              part->simplify_viewport = 0.8f;
 -                      }
 -              }
 -
 -              for (wrld = main->world.first; wrld; wrld = wrld->id.next) {
 -                      if (wrld->ao_approx_error == 0.0f)
 -                              wrld->ao_approx_error = 0.25f;
                }
  
                for (sce = main->scene.first; sce; sce = sce->id.next) {
                        if (sce->nodetree)
                                ntree_version_245(fd, lib, sce->nodetree);
  
 -                      if (sce->r.simplify_shadowsamples == 0) {
 +                      if (sce->r.simplify_subsurf == 0) {
                                sce->r.simplify_subsurf = 6;
                                sce->r.simplify_particles = 1.0f;
 -                              sce->r.simplify_shadowsamples = 16;
 -                              sce->r.simplify_aosss = 1.0f;
 -                      }
 -
 -                      if (sce->r.cineongamma == 0) {
 -                              sce->r.cineonblack = 95;
 -                              sce->r.cineonwhite = 685;
 -                              sce->r.cineongamma = 1.7f;
                        }
                }
  
                }
        }
  
 -      /* sanity check for skgen */
 -      {
 -              Scene *sce;
 -              for (sce = main->scene.first; sce; sce = sce->id.next) {
 -                      if (sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[1] ||
 -                          sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[2] ||
 -                          sce->toolsettings->skgen_subdivisions[1] == sce->toolsettings->skgen_subdivisions[2])
 -                      {
 -                              sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
 -                              sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
 -                              sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
 -                      }
 -              }
 -      }
 -
 -
        if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 2)) {
                Image *ima;
  
                        }
                }
        }
 -      if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 9)) {
 -              Material *ma;
 -              int a;
 -
 -              for (ma = main->mat.first; ma; ma = ma->id.next)
 -                      if (ma->mode & MA_NORMAP_TANG)
 -                              for (a = 0; a < MAX_MTEX; a++)
 -                                      if (ma->mtex[a] && ma->mtex[a]->tex)
 -                                              ma->mtex[a]->normapspace = MTEX_NSPACE_TANGENT;
 -      }
  
        if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 10)) {
                Object *ob;
                idproperties_fix_group_lengths(main->vfont);
                idproperties_fix_group_lengths(main->text);
                idproperties_fix_group_lengths(main->sound);
 -              idproperties_fix_group_lengths(main->group);
 +              idproperties_fix_group_lengths(main->collection);
                idproperties_fix_group_lengths(main->armature);
                idproperties_fix_group_lengths(main->action);
                idproperties_fix_group_lengths(main->nodetree);
                idproperties_fix_group_lengths(main->particle);
        }
  
 -      /* sun/sky */
 -      if (main->versionfile < 246) {
 -              Object *ob;
 -              bActuator *act;
 -
 -              /* dRot actuator change direction in 2.46 */
 -              for (ob = main->object.first; ob; ob = ob->id.next) {
 -                      for (act = ob->actuators.first; act; act = act->next) {
 -                              if (act->type == ACT_OBJECT) {
 -                                      bObjectActuator *ba = act->data;
 -
 -                                      ba->drot[0] = -ba->drot[0];
 -                                      ba->drot[1] = -ba->drot[1];
 -                                      ba->drot[2] = -ba->drot[2];
 -                              }
 -                      }
 -              }
 -      }
 -
        /* convert fluids to modifier */
        if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) {
                Object *ob;
                }
        }
  
 -
 -      if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) {
 -              Mesh *me;
 -
 -              for (me = main->mesh.first; me; me = me->id.next)
 -                      alphasort_version_246(fd, lib, me);
 -      }
 -
        if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) {
                Object *ob;
                for (ob = main->object.first; ob; ob = ob->id.next) {
                }
        }
  
 -      if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 2)) {
 -              Object *ob;
 -              for (ob = main->object.first; ob; ob = ob->id.next) {
 -                      ob->gameflag |= OB_COLLISION;
 -                      ob->margin = 0.06f;
 -              }
 -      }
 -
 -      if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 3)) {
 -              Object *ob;
 -              for (ob = main->object.first; ob; ob = ob->id.next) {
 -                      /* Starting from subversion 3, ACTOR is a separate feature.
 -                       * Before it was conditioning all the other dynamic flags */
 -                      if (!(ob->gameflag & OB_ACTOR))
 -                              ob->gameflag &= ~(OB_GHOST|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION_RESPONSE);
 -                      /* suitable default for older files */
 -              }
 -      }
 -
 -      if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 5)) {
 -              Lamp *la = main->lamp.first;
 -              for (; la; la = la->id.next) {
 -                      la->skyblendtype = MA_RAMP_ADD;
 -                      la->skyblendfac = 1.0f;
 -              }
 -      }
 -
        /* set the curve radius interpolation to 2.47 default - easy */
        if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 6)) {
                Curve *cu;
                }
        }
  
 -      /* direction constraint actuators were always local in previous version */
 -      if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 7)) {
 -              bActuator *act;
 -              Object *ob;
 -
 -              for (ob = main->object.first; ob; ob = ob->id.next) {
 -                      for (act = ob->actuators.first; act; act = act->next) {
 -                              if (act->type == ACT_CONSTRAINT) {
 -                                      bConstraintActuator *coa = act->data;
 -                                      if (coa->type == ACT_CONST_TYPE_DIST) {
 -                                              coa->flag |= ACT_CONST_LOCAL;
 -                                      }
 -                              }
 -                      }
 -              }
 -      }
 -
 -      if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 9)) {
 -              Lamp *la = main->lamp.first;
 -              for (; la; la = la->id.next) {
 -                      la->sky_exposure = 1.0f;
 -              }
 -      }
 -
 -      /* BGE message actuators needed OB prefix, very confusing */
 -      if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 10)) {
 -              bActuator *act;
 -              Object *ob;
 -
 -              for (ob = main->object.first; ob; ob = ob->id.next) {
 -                      for (act = ob->actuators.first; act; act = act->next) {
 -                              if (act->type == ACT_MESSAGE) {
 -                                      bMessageActuator *msgAct = (bMessageActuator *) act->data;
 -
 -                                      if (BLI_strnlen(msgAct->toPropName, 3) > 2) {
 -                                              /* strip first 2 chars, would have only worked if these were OB anyway */
 -                                              memmove(msgAct->toPropName, msgAct->toPropName + 2, sizeof(msgAct->toPropName) - 2);
 -                                      }
 -                                      else {
 -                                              msgAct->toPropName[0] = '\0';
 -                                      }
 -                              }
 -                      }
 -              }
 -      }
 -
 -      if (main->versionfile < 248) {
 -              Lamp *la;
 -
 -              for (la = main->lamp.first; la; la = la->id.next) {
 -                      if (la->atm_turbidity == 0.0f) {
 -                              la->sun_effect_type = 0;
 -                              la->horizon_brightness = 1.0f;
 -                              la->spread = 1.0f;
 -                              la->sun_brightness = 1.0f;
 -                              la->sun_size = 1.0f;
 -                              la->backscattered_light = 1.0f;
 -                              la->atm_turbidity = 2.0f;
 -                              la->atm_inscattering_factor = 1.0f;
 -                              la->atm_extinction_factor = 1.0f;
 -                              la->atm_distance_factor = 1.0f;
 -                              la->sun_intensity = 1.0f;
 -                      }
 -              }
 -      }
 -
        if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 2)) {
                Scene *sce;
  
                for (sce = main->scene.first; sce; sce = sce->id.next) {
                        sce->toolsettings->imapaint.seam_bleed = 2;
                        sce->toolsettings->imapaint.normal_angle = 80;
 -
 -                      /* initialize skeleton generation toolsettings */
 -                      sce->toolsettings->skgen_resolution = 250;
 -                      sce->toolsettings->skgen_threshold_internal     = 0.1f;
 -                      sce->toolsettings->skgen_threshold_external     = 0.1f;
 -                      sce->toolsettings->skgen_angle_limit                    = 30.0f;
 -                      sce->toolsettings->skgen_length_ratio                   = 1.3f;
 -                      sce->toolsettings->skgen_length_limit                   = 1.5f;
 -                      sce->toolsettings->skgen_correlation_limit              = 0.98f;
 -                      sce->toolsettings->skgen_symmetry_limit                 = 0.1f;
 -                      sce->toolsettings->skgen_postpro = SKGEN_SMOOTH;
 -                      sce->toolsettings->skgen_postpro_passes = 3;
 -                      sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_FILTER_SMART|SKGEN_SUB_CORRELATION|SKGEN_HARMONIC;
 -                      sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
 -                      sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
 -                      sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
 -
 -
 -                      sce->toolsettings->skgen_retarget_angle_weight = 1.0f;
 -                      sce->toolsettings->skgen_retarget_length_weight = 1.0f;
 -                      sce->toolsettings->skgen_retarget_distance_weight = 1.0f;
 -
 -                      /* Skeleton Sketching */
 -                      sce->toolsettings->bone_sketching = 0;
 -                      sce->toolsettings->skgen_retarget_roll = SK_RETARGET_ROLL_VIEW;
                }
        }
  
                }
        }
  
 -      if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) {
 -              Object *ob;
 -
 -              /* Adjustments needed after Bullets update */
 -              for (ob = main->object.first; ob; ob = ob->id.next) {
 -                      ob->damping *= 0.635f;
 -                      ob->rdamping = 0.1f + (0.8f * ob->rdamping);
 -              }
 -      }
 -
 -      if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 4)) {
 -              Scene *sce;
 -              World *wrld;
 -
 -              /*  Dome (Fisheye) default parameters  */
 -              for (sce = main->scene.first; sce; sce = sce->id.next) {
 -                      sce->r.domeangle = 180;
 -                      sce->r.domemode = 1;
 -                      sce->r.domeres = 4;
 -                      sce->r.domeresbuf = 1.0f;
 -                      sce->r.dometilt = 0;
 -              }
 -              /* DBVT culling by default */
 -              for (wrld = main->world.first; wrld; wrld = wrld->id.next) {
 -                      wrld->mode |= WO_DBVT_CULLING;
 -                      wrld->occlusionRes = 128;
 -              }
 -      }
 -
 -      if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 5)) {
 -              Object *ob;
 -              World *wrld;
 -              for (ob = main->object.first; ob; ob = ob->id.next) {
 -                      if (ob->parent) {
 -                              /* check if top parent has compound shape set and if yes, set this object
 -                               * to compound shaper as well (was the behavior before, now it's optional) */
 -                              Object *parent = blo_do_versions_newlibadr(fd, lib, ob->parent);
 -                              while (parent && parent != ob && parent->parent != NULL) {
 -                                      parent = blo_do_versions_newlibadr(fd, lib, parent->parent);
 -                              }
 -                              if (parent) {
 -                                      if (parent->gameflag & OB_CHILD)
 -                                              ob->gameflag |= OB_CHILD;
 -                              }
 -                      }
 -              }
 -              for (wrld = main->world.first; wrld; wrld = wrld->id.next) {
 -                      wrld->ticrate = 60;
 -                      wrld->maxlogicstep = 5;
 -                      wrld->physubstep = 1;
 -                      wrld->maxphystep = 5;
 -              }
 -      }
 -
        /* correct introduce of seed for wind force */
        if (main->versionfile < 249 && main->subversionfile < 1) {
                Object *ob;
index bfb2568df71bec1b9cf9810699d671db851a33b6,d999b9fef0a41038c3c0ad7616c019d37bd33948..6a05f870e476621ea28e962cb379b482b0595ee3
  #include "BLI_utildefines.h"
  
  #include "BKE_context.h"
 -#include "BKE_depsgraph.h"
 +#include "BKE_curve.h"
  #include "BKE_icons.h"
 +#include "BKE_lattice.h"
  #include "BKE_library.h"
  #include "BKE_main.h"
 +#include "BKE_mball.h"
 +#include "BKE_mesh.h"
  #include "BKE_object.h"
  #include "BKE_scene.h"
  #include "BKE_screen.h"
 +#include "BKE_workspace.h"
  
  #include "ED_space_api.h"
  #include "ED_screen.h"
 +#include "ED_transform.h"
  
 -#include "GPU_compositing.h"
  #include "GPU_framebuffer.h"
  #include "GPU_material.h"
 +#include "GPU_viewport.h"
 +#include "GPU_matrix.h"
  
 -#include "BIF_gl.h"
 +#include "DRW_engine.h"
  
  #include "WM_api.h"
  #include "WM_types.h"
 +#include "WM_message.h"
 +#include "WM_toolsystem.h"
  
  #include "RE_engine.h"
  #include "RE_pipeline.h"
  
  #include "RNA_access.h"
  
 +#include "UI_interface.h"
  #include "UI_resources.h"
  
  #ifdef WITH_PYTHON
@@@ -115,18 -106,18 +115,18 @@@ ARegion *view3d_has_buttons_region(ScrA
  
  ARegion *view3d_has_tools_region(ScrArea *sa)
  {
 -      ARegion *ar, *artool = NULL, *arprops = NULL, *arhead;
 -      
 +      ARegion *ar, *artool = NULL, *arhead;
 +
        for (ar = sa->regionbase.first; ar; ar = ar->next) {
                if (ar->regiontype == RGN_TYPE_TOOLS)
                        artool = ar;
 -              if (ar->regiontype == RGN_TYPE_TOOL_PROPS)
 -                      arprops = ar;
        }
 -      
 +
        /* tool region hide/unhide also hides props */
 -      if (arprops && artool) return artool;
 -      
 +      if (artool) {
 +              return artool;
 +      }
 +
        if (artool == NULL) {
                /* add subdiv level; after header */
                for (arhead = sa->regionbase.first; arhead; arhead = arhead->next)
                artool->flag = RGN_FLAG_HIDDEN;
        }
  
 -      if (arprops == NULL) {
 -              /* add extra subdivided region for tool properties */
 -              arprops = MEM_callocN(sizeof(ARegion), "tool props for view3d");
 -              
 -              BLI_insertlinkafter(&sa->regionbase, artool, arprops);
 -              arprops->regiontype = RGN_TYPE_TOOL_PROPS;
 -              arprops->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
 -      }
 -      
        return artool;
  }
  
@@@ -250,7 -250,7 +250,7 @@@ void ED_view3d_init_mats_rv3d_gl(struc
        /* we have to multiply instead of loading viewmatob to make
         * it work with duplis using displists, otherwise it will
         * override the dupli-matrix */
 -      glMultMatrixf(ob->obmat);
 +      gpuMultMatrix(ob->obmat);
  }
  
  #ifdef DEBUG
@@@ -283,6 -283,8 +283,6 @@@ void ED_view3d_stop_render_preview(wmWi
                BPy_END_ALLOW_THREADS;
  #endif
  
 -              if (rv3d->render_engine->re)
 -                      RE_Database_Free(rv3d->render_engine->re);
                RE_engine_free(rv3d->render_engine);
                rv3d->render_engine = NULL;
        }
@@@ -304,15 -306,15 +304,14 @@@ void ED_view3d_shade_update(Main *bmain
  
  /* ******************** default callbacks for view3d space ***************** */
  
 -static SpaceLink *view3d_new(const bContext *C)
 +static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
  {
 -      Scene *scene = CTX_data_scene(C);
        ARegion *ar;
        View3D *v3d;
        RegionView3D *rv3d;
        
        v3d = MEM_callocN(sizeof(View3D), "initview3d");
        v3d->spacetype = SPACE_VIEW3D;
-       v3d->blockscale = 0.7f;
        v3d->lay = v3d->layact = 1;
        if (scene) {
                v3d->lay = v3d->layact = scene->lay;
        v3d->gridlines = 16;
        v3d->gridsubdiv = 10;
        v3d->drawtype = OB_SOLID;
 +      v3d->shading.flag = V3D_SHADING_SPECULAR_HIGHLIGHT;
 +      v3d->shading.light = V3D_LIGHTING_STUDIO;
 +      v3d->shading.shadow_intensity = 0.5f;
 +      v3d->shading.xray_alpha = 0.5f;
 +      copy_v3_fl(v3d->shading.single_color, 0.8f);
 +
 +      v3d->overlay.flag = V3D_OVERLAY_LOOK_DEV;
  
        v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR;
        
        v3d->flag = V3D_SELECT_OUTLINE;
        v3d->flag2 = V3D_SHOW_RECONSTRUCTION | V3D_SHOW_GPENCIL;
        
 -      v3d->lens = 35.0f;
 +      v3d->lens = 50.0f;
        v3d->near = 0.01f;
        v3d->far = 1000.0f;
  
 -      v3d->twflag |= U.tw_flag & V3D_USE_MANIPULATOR;
 -      v3d->twtype = V3D_MANIP_TRANSLATE;
 -      v3d->around = V3D_AROUND_CENTER_MEAN;
 -      
 +      v3d->twflag |= U.manipulator_flag & V3D_MANIPULATOR_DRAW;
 +
        v3d->bundle_size = 0.2f;
        v3d->bundle_drawtype = OB_PLAINAXES;
  
        
        BLI_addtail(&v3d->regionbase, ar);
        ar->regiontype = RGN_TYPE_HEADER;
 -      ar->alignment = RGN_ALIGN_BOTTOM;
 +      ar->alignment = RGN_ALIGN_TOP;
        
        /* tool shelf */
        ar = MEM_callocN(sizeof(ARegion), "toolshelf for view3d");
        ar->regiontype = RGN_TYPE_TOOLS;
        ar->alignment = RGN_ALIGN_LEFT;
        ar->flag = RGN_FLAG_HIDDEN;
 -      
 -      /* tool properties */
 -      ar = MEM_callocN(sizeof(ARegion), "tool properties for view3d");
 -      
 -      BLI_addtail(&v3d->regionbase, ar);
 -      ar->regiontype = RGN_TYPE_TOOL_PROPS;
 -      ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
 -      ar->flag = RGN_FLAG_HIDDEN;
 -      
 +
        /* buttons/list view */
        ar = MEM_callocN(sizeof(ARegion), "buttons for view3d");
        
  static void view3d_free(SpaceLink *sl)
  {
        View3D *vd = (View3D *) sl;
 -      BGpic *bgpic;
 -
 -      for (bgpic = vd->bgpicbase.first; bgpic; bgpic = bgpic->next) {
 -              if (bgpic->source == V3D_BGPIC_IMAGE) {
 -                      id_us_min((ID *)bgpic->ima);
 -              }
 -              else if (bgpic->source == V3D_BGPIC_MOVIE) {
 -                      id_us_min((ID *)bgpic->clip);
 -              }
 -      }
 -      BLI_freelistN(&vd->bgpicbase);
  
        if (vd->localvd) MEM_freeN(vd->localvd);
        
        if (vd->properties_storage) MEM_freeN(vd->properties_storage);
        
 -      /* matcap material, its preview rect gets freed via icons */
 -      if (vd->defmaterial) {
 -              if (vd->defmaterial->gpumaterial.first)
 -                      GPU_material_free(&vd->defmaterial->gpumaterial);
 -              BKE_previewimg_free(&vd->defmaterial->preview);
 -              MEM_freeN(vd->defmaterial);
 -      }
 -
        if (vd->fx_settings.ssao)
                MEM_freeN(vd->fx_settings.ssao);
        if (vd->fx_settings.dof)
@@@ -416,6 -440,7 +415,6 @@@ static SpaceLink *view3d_duplicate(Spac
  {
        View3D *v3do = (View3D *)sl;
        View3D *v3dn = MEM_dupallocN(sl);
 -      BGpic *bgpic;
        
        /* clear or remove stuff from old */
  
        
        /* copy or clear inside new stuff */
  
 -      v3dn->defmaterial = NULL;
 -
 -      BLI_duplicatelist(&v3dn->bgpicbase, &v3do->bgpicbase);
 -      for (bgpic = v3dn->bgpicbase.first; bgpic; bgpic = bgpic->next) {
 -              if (bgpic->source == V3D_BGPIC_IMAGE) {
 -                      id_us_plus((ID *)bgpic->ima);
 -              }
 -              else if (bgpic->source == V3D_BGPIC_MOVIE) {
 -                      id_us_plus((ID *)bgpic->clip);
 -              }
 -      }
 -
        v3dn->properties_storage = NULL;
        if (v3dn->fx_settings.dof)
                v3dn->fx_settings.dof = MEM_dupallocN(v3do->fx_settings.dof);
@@@ -445,13 -482,6 +444,13 @@@ static void view3d_main_region_init(wmW
        ListBase *lb;
        wmKeyMap *keymap;
  
 +      if (ar->manipulator_map == NULL) {
 +              ar->manipulator_map = WM_manipulatormap_new_from_type(
 +                      &(const struct wmManipulatorMapType_Params) {SPACE_VIEW3D, RGN_TYPE_WINDOW});
 +      }
 +
 +      WM_manipulatormap_add_handlers(ar, ar->manipulator_map);
 +
        /* object ops. */
        
        /* important to be before Pose keymap since they can both be enabled at once */
@@@ -542,6 -572,11 +541,6 @@@ static void view3d_main_region_exit(wmW
                GPU_offscreen_free(rv3d->gpuoffscreen);
                rv3d->gpuoffscreen = NULL;
        }
 -      
 -      if (rv3d->compositor) {
 -              GPU_fx_compositor_destroy(rv3d->compositor);
 -              rv3d->compositor = NULL;
 -      }
  }
  
  static int view3d_ob_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event))
        return 0;
  }
  
 -static int view3d_group_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event))
 +static int view3d_collection_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event))
  {
        if (drag->type == WM_DRAG_ID) {
                ID *id = drag->poin;
@@@ -629,7 -664,7 +628,7 @@@ static void view3d_ob_drop_copy(wmDrag 
        RNA_string_set(drop->ptr, "name", id->name + 2);
  }
  
 -static void view3d_group_drop_copy(wmDrag *drag, wmDropBox *drop)
 +static void view3d_collection_drop_copy(wmDrag *drag, wmDropBox *drop)
  {
        ID *id = drag->poin;
        
@@@ -669,32 -704,9 +668,32 @@@ static void view3d_dropboxes(void
        WM_dropbox_add(lb, "MESH_OT_drop_named_image", view3d_ima_mesh_drop_poll, view3d_id_path_drop_copy);
        WM_dropbox_add(lb, "OBJECT_OT_drop_named_image", view3d_ima_empty_drop_poll, view3d_id_path_drop_copy);
        WM_dropbox_add(lb, "VIEW3D_OT_background_image_add", view3d_ima_bg_drop_poll, view3d_id_path_drop_copy);
 -      WM_dropbox_add(lb, "OBJECT_OT_group_instance_add", view3d_group_drop_poll, view3d_group_drop_copy);     
 +      WM_dropbox_add(lb, "OBJECT_OT_collection_instance_add", view3d_collection_drop_poll, view3d_collection_drop_copy);
  }
  
 +static void view3d_widgets(void)
 +{
 +      wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(
 +              &(const struct wmManipulatorMapType_Params){SPACE_VIEW3D, RGN_TYPE_WINDOW});
 +
 +      WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_spot);
 +      WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_area);
 +      WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_target);
 +      WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_force_field);
 +      WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera);
 +      WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera_view);
 +      WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_empty_image);
 +      WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_armature_spline);
 +
 +      WM_manipulatorgrouptype_append(TRANSFORM_WGT_manipulator);
 +      WM_manipulatorgrouptype_append(VIEW3D_WGT_xform_cage);
 +
 +      WM_manipulatorgrouptype_append(VIEW3D_WGT_ruler);
 +      WM_manipulatortype_append(VIEW3D_WT_ruler_item);
 +
 +      WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_navigate);
 +      WM_manipulatortype_append(VIEW3D_WT_navigate_rotate);
 +}
  
  
  /* type callback, not region itself */
@@@ -719,6 -731,9 +718,6 @@@ static void view3d_main_region_free(ARe
                if (rv3d->gpuoffscreen) {
                        GPU_offscreen_free(rv3d->gpuoffscreen);
                }
 -              if (rv3d->compositor) {
 -                      GPU_fx_compositor_destroy(rv3d->compositor);
 -              }
  
                MEM_freeN(rv3d);
                ar->regiondata = NULL;
@@@ -742,21 -757,33 +741,21 @@@ static void *view3d_main_region_duplica
                new->render_engine = NULL;
                new->sms = NULL;
                new->smooth_timer = NULL;
 -              new->compositor = NULL;
                
                return new;
        }
        return NULL;
  }
  
 -static void view3d_recalc_used_layers(ARegion *ar, wmNotifier *wmn, Scene *scene)
 +static void view3d_recalc_used_layers(ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene))
  {
        wmWindow *win = wmn->wm->winactive;
 -      ScrArea *sa;
        unsigned int lay_used = 0;
 -      Base *base;
  
        if (!win) return;
  
 -      base = scene->base.first;
 -      while (base) {
 -              lay_used |= base->lay & ((1 << 20) - 1); /* ignore localview */
 -
 -              if (lay_used == (1 << 20) - 1)
 -                      break;
 -
 -              base = base->next;
 -      }
 -
 -      for (sa = win->screen->areabase.first; sa; sa = sa->next) {
 +      const bScreen *screen = WM_window_get_active_screen(win);
 +      for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
                if (sa->spacetype == SPACE_VIEW3D) {
                        if (BLI_findindex(&sa->regionbase, ar) != -1) {
                                View3D *v3d = sa->spacedata.first;
        }
  }
  
 -static void view3d_main_region_listener(bScreen *sc, ScrArea *sa, ARegion *ar, wmNotifier *wmn)
 +static void view3d_main_region_listener(
 +        bScreen *UNUSED(sc), ScrArea *sa, ARegion *ar,
 +        wmNotifier *wmn, const Scene *scene)
  {
 -      Scene *scene = sc->scene;
        View3D *v3d = sa->spacedata.first;
 -      
 +      RegionView3D *rv3d = ar->regiondata;
 +      wmManipulatorMap *mmap = ar->manipulator_map;
 +
        /* context changes */
        switch (wmn->category) {
 +              case NC_WM:
 +                      if (ELEM(wmn->data, ND_UNDO)) {
 +                              WM_manipulatormap_tag_refresh(mmap);
 +                      }
 +                      break;
                case NC_ANIMATION:
                        switch (wmn->data) {
                                case ND_KEYFRAME_PROP:
                        break;
                case NC_SCENE:
                        switch (wmn->data) {
 +                              case ND_SCENEBROWSE:
                                case ND_LAYER_CONTENT:
                                        if (wmn->reference)
                                                view3d_recalc_used_layers(ar, wmn, wmn->reference);
                                        ED_region_tag_redraw(ar);
 +                                      WM_manipulatormap_tag_refresh(mmap);
 +                                      break;
 +                              case ND_LAYER:
 +                                      if (wmn->reference) {
 +                                              BKE_screen_view3d_sync(v3d, wmn->reference);
 +                                      }
 +                                      ED_region_tag_redraw(ar);
 +                                      WM_manipulatormap_tag_refresh(mmap);
                                        break;
 -                              case ND_FRAME:
 -                              case ND_TRANSFORM:
                                case ND_OB_ACTIVE:
                                case ND_OB_SELECT:
 +                                      DEG_id_tag_update((ID *)&scene->id, DEG_TAG_SELECT_UPDATE);
 +                                      ATTR_FALLTHROUGH;
 +                              case ND_FRAME:
 +                              case ND_TRANSFORM:
                                case ND_OB_VISIBLE:
 -                              case ND_LAYER:
                                case ND_RENDER_OPTIONS:
                                case ND_MARKERS:
                                case ND_MODE:
                                        ED_region_tag_redraw(ar);
 +                                      WM_manipulatormap_tag_refresh(mmap);
                                        break;
                                case ND_WORLD:
                                        /* handled by space_view3d_listener() for v3d access */
                                case ND_DRAW_RENDER_VIEWPORT:
                                {
                                        if (v3d->camera && (scene == wmn->reference)) {
 -                                              RegionView3D *rv3d = ar->regiondata;
                                                if (rv3d->persp == RV3D_CAMOB) {
                                                        ED_region_tag_redraw(ar);
                                                }
                                case ND_POINTCACHE:
                                case ND_LOD:
                                        ED_region_tag_redraw(ar);
 +                                      WM_manipulatormap_tag_refresh(mmap);
                                        break;
                        }
                        switch (wmn->action) {
                        break;
                case NC_GEOM:
                        switch (wmn->data) {
 +                              case ND_SELECT:
 +                              {
 +                                      WM_manipulatormap_tag_refresh(mmap);
 +
 +                                      ID *ob_data = wmn->reference;
 +                                      if (ob_data == NULL) {
 +                                              BLI_assert(wmn->window); // Use `WM_event_add_notifier` instead of `WM_main_add_notifier`
 +                                              ViewLayer *view_layer = WM_window_get_active_view_layer(wmn->window);
 +                                              ob_data = OBEDIT_FROM_VIEW_LAYER(view_layer)->data;
 +                                      }
 +                                      if (ob_data) {
 +                                              BLI_assert(OB_DATA_SUPPORT_ID(GS(ob_data->name)));
 +                                              /* TODO(sergey): Notifiers shouldn't really be doing DEG tags. */
 +                                              DEG_id_tag_update(ob_data, DEG_TAG_SELECT_UPDATE);
 +                                      }
 +                                      ATTR_FALLTHROUGH;
 +                              }
                                case ND_DATA:
                                case ND_VERTEX_GROUP:
 -                              case ND_SELECT:
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
                                case ND_DRAW_RENDER_VIEWPORT:
                                {
                                        if (v3d->camera && (v3d->camera->data == wmn->reference)) {
 -                                              RegionView3D *rv3d = ar->regiondata;
                                                if (rv3d->persp == RV3D_CAMOB) {
                                                        ED_region_tag_redraw(ar);
                                                }
                        switch (wmn->data) {
                                case ND_SHADING:
                                case ND_NODES:
 -                              {
 -#ifdef WITH_LEGACY_DEPSGRAPH
 -                                      Object *ob = OBACT;
 -                                      if ((v3d->drawtype == OB_MATERIAL) ||
 -                                          (ob && (ob->mode == OB_MODE_TEXTURE_PAINT)) ||
 -                                          (v3d->drawtype == OB_TEXTURE &&
 -                                           (scene->gm.matmode == GAME_MAT_GLSL ||
 -                                            BKE_scene_use_new_shading_nodes(scene))) ||
 -                                          !DEG_depsgraph_use_legacy())
 -#endif
 -                                      {
 -                                              ED_region_tag_redraw(ar);
 -                                      }
 +                                      /* TODO(sergey) This is a bit too much updates, but needed to
 +                                       * have proper material drivers update in the viewport.
 +                                       *
 +                                       * How to solve?
 +                                       */
 +                                      ED_region_tag_redraw(ar);
                                        break;
 -                              }
                                case ND_SHADING_DRAW:
                                case ND_SHADING_LINKS:
                                        ED_region_tag_redraw(ar);
                                case ND_WORLD_DRAW:
                                        /* handled by space_view3d_listener() for v3d access */
                                        break;
 +                              case ND_WORLD:
 +                                      /* Needed for updating world materials */
 +                                      ED_region_tag_redraw(ar);
 +                                      break;
                        }
                        break;
                case NC_LAMP:
                        switch (wmn->data) {
                                case ND_LIGHTING:
 -                                      if ((v3d->drawtype == OB_MATERIAL) ||
 -                                          (v3d->drawtype == OB_TEXTURE && (scene->gm.matmode == GAME_MAT_GLSL)) ||
 -                                          !DEG_depsgraph_use_legacy())
 -                                      {
 -                                              ED_region_tag_redraw(ar);
 -                                      }
 +                                      /* TODO(sergey): This is a bit too much, but needed to
 +                                       * handle updates from new depsgraph.
 +                                       */
 +                                      ED_region_tag_redraw(ar);
                                        break;
                                case ND_LIGHTING_DRAW:
                                        ED_region_tag_redraw(ar);
 +                                      WM_manipulatormap_tag_refresh(mmap);
                                        break;
                        }
                        break;
                case NC_SPACE:
                        if (wmn->data == ND_SPACE_VIEW3D) {
                                if (wmn->subtype == NS_VIEW3D_GPU) {
 -                                      RegionView3D *rv3d = ar->regiondata;
                                        rv3d->rflag |= RV3D_GPULIGHT_UPDATE;
                                }
                                ED_region_tag_redraw(ar);
 +                              WM_manipulatormap_tag_refresh(mmap);
                        }
                        break;
                case NC_ID:
                                case ND_SKETCH:
                                        ED_region_tag_redraw(ar);
                                        break;
 -                              case ND_SCREENBROWSE:
 -                              case ND_SCREENDELETE:
 -                              case ND_SCREENSET:
 -                                      /* screen was changed, need to update used layers due to NC_SCENE|ND_LAYER_CONTENT */
 -                                      /* updates used layers only for View3D in active screen */
 -                                      if (wmn->reference) {
 -                                              bScreen *sc_ref = wmn->reference;
 -                                              view3d_recalc_used_layers(ar, wmn, sc_ref->scene);
 -                                      }
 +                              case ND_LAYOUTBROWSE:
 +                              case ND_LAYOUTDELETE:
 +                              case ND_LAYOUTSET:
 +                                      WM_manipulatormap_tag_refresh(mmap);
 +                                      ED_region_tag_redraw(ar);
 +                                      break;
 +                              case ND_LAYER:
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
        }
  }
  
 +static void view3d_main_region_message_subscribe(
 +        const struct bContext *C,
 +        struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene),
 +        struct bScreen *UNUSED(screen), struct ScrArea *sa, struct ARegion *ar,
 +        struct wmMsgBus *mbus)
 +{
 +      /* Developer note: there are many properties that impact 3D view drawing,
 +       * so instead of subscribing to individual properties, just subscribe to types
 +       * accepting some redundant redraws.
 +       *
 +       * For other space types we might try avoid this, keep the 3D view as an exceptional case! */
 +      wmMsgParams_RNA msg_key_params = {{{0}}};
 +
 +      /* Only subscribe to types. */
 +      StructRNA *type_array[] = {
 +              &RNA_Window,
 +
 +              /* These object have properties that impact drawing. */
 +              &RNA_AreaLamp,
 +              &RNA_Camera,
 +              &RNA_Lamp,
 +              &RNA_Speaker,
 +              &RNA_SunLamp,
 +
 +              /* General types the 3D view depends on. */
 +              &RNA_Object,
 +              &RNA_UnitSettings,  /* grid-floor */
 +
 +              &RNA_View3DOverlay,
 +              &RNA_View3DShading,
 +              &RNA_World,
 +      };
 +
 +      wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
 +              .owner = ar,
 +              .user_data = ar,
 +              .notify = ED_region_do_msg_notify_tag_redraw,
 +      };
 +
 +      for (int i = 0; i < ARRAY_SIZE(type_array); i++) {
 +              msg_key_params.ptr.type = type_array[i];
 +              WM_msg_subscribe_rna_params(
 +                      mbus,
 +                      &msg_key_params,
 +                      &msg_sub_value_region_tag_redraw,
 +                      __func__);
 +      }
 +
 +      /* Subscribe to a handful of other properties. */
 +      RegionView3D *rv3d = ar->regiondata;
 +
 +      WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, engine, &msg_sub_value_region_tag_redraw);
 +      WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_x, &msg_sub_value_region_tag_redraw);
 +      WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_y, &msg_sub_value_region_tag_redraw);
 +      WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_x, &msg_sub_value_region_tag_redraw);
 +      WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_y, &msg_sub_value_region_tag_redraw);
 +      if (rv3d->persp == RV3D_CAMOB) {
 +              WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, use_border, &msg_sub_value_region_tag_redraw);
 +      }
 +
 +      WM_msg_subscribe_rna_anon_type(mbus, SceneEEVEE, &msg_sub_value_region_tag_redraw);
 +      WM_msg_subscribe_rna_anon_type(mbus, SceneDisplay, &msg_sub_value_region_tag_redraw);
 +      WM_msg_subscribe_rna_anon_type(mbus, ObjectDisplay, &msg_sub_value_region_tag_redraw);
 +
 +      ViewLayer *view_layer = CTX_data_view_layer(C);
 +      Object *obact = OBACT(view_layer);
 +      if (obact != NULL) {
 +              switch (obact->mode) {
 +                      case OB_MODE_PARTICLE_EDIT:
 +                              WM_msg_subscribe_rna_anon_type(mbus, ParticleEdit, &msg_sub_value_region_tag_redraw);
 +                              break;
 +                      default:
 +                              break;
 +              }
 +      }
 +
 +      {
 +              wmMsgSubscribeValue msg_sub_value_region_tag_refresh = {
 +                      .owner = ar,
 +                      .user_data = sa,
 +                      .notify = WM_toolsystem_do_msg_notify_tag_refresh,
 +              };
 +              WM_msg_subscribe_rna_anon_prop(
 +                      mbus, Object, mode,
 +                      &msg_sub_value_region_tag_refresh);
 +      }
 +}
 +
 +static void view3d_tools_region_message_subscribe(
 +        const struct bContext *UNUSED(C),
 +        struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene),
 +        struct bScreen *UNUSED(screen), struct ScrArea *UNUSED(sa), struct ARegion *ar,
 +        struct wmMsgBus *mbus)
 +{
 +      wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
 +              .owner = ar,
 +              .user_data = ar,
 +              .notify = ED_region_do_msg_notify_tag_redraw,
 +      };
 +      WM_msg_subscribe_rna_anon_prop(mbus, WorkSpace, tools, &msg_sub_value_region_tag_redraw);
 +}
 +
  /* concept is to retrieve cursor type context-less */
 -static void view3d_main_region_cursor(wmWindow *win, ScrArea *UNUSED(sa), ARegion *UNUSED(ar))
 +static void view3d_main_region_cursor(wmWindow *win, ScrArea *sa, ARegion *ar)
  {
 -      Scene *scene = win->screen->scene;
 +      if (WM_cursor_set_from_tool(win, sa, ar)) {
 +              return;
 +      }
  
 -      if (scene->obedit) {
 +      ViewLayer *view_layer = WM_window_get_active_view_layer(win);
 +      Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
 +      if (obedit) {
                WM_cursor_set(win, CURSOR_EDIT);
        }
        else {
@@@ -1154,9 -1048,7 +1153,9 @@@ static void view3d_header_region_draw(c
        ED_region_header(C, ar);
  }
  
 -static void view3d_header_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
 +static void view3d_header_region_listener(
 +        bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
 +        wmNotifier *wmn, const Scene *UNUSED(scene))
  {
        /* context changes */
        switch (wmn->category) {
        }
  }
  
 +static void view3d_header_region_message_subscribe(
 +        const struct bContext *UNUSED(C),
 +        struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene),
 +        struct bScreen *UNUSED(screen), struct ScrArea *UNUSED(sa), struct ARegion *ar,
 +        struct wmMsgBus *mbus)
 +{
 +      wmMsgParams_RNA msg_key_params = {{{0}}};
 +
 +      /* Only subscribe to types. */
 +      StructRNA *type_array[] = {
 +              &RNA_View3DShading,
 +      };
 +
 +      wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
 +              .owner = ar,
 +              .user_data = ar,
 +              .notify = ED_region_do_msg_notify_tag_redraw,
 +      };
 +
 +      for (int i = 0; i < ARRAY_SIZE(type_array); i++) {
 +              msg_key_params.ptr.type = type_array[i];
 +              WM_msg_subscribe_rna_params(
 +                      mbus,
 +                      &msg_key_params,
 +                      &msg_sub_value_region_tag_redraw,
 +                      __func__);
 +      }
 +}
 +
 +
  /* add handlers, stuff you only do once or on area/region changes */
  static void view3d_buttons_region_init(wmWindowManager *wm, ARegion *ar)
  {
@@@ -1232,9 -1094,7 +1231,9 @@@ static void view3d_buttons_region_draw(
        ED_region_panels(C, ar, NULL, -1, true);
  }
  
 -static void view3d_buttons_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
 +static void view3d_buttons_region_listener(
 +        bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
 +        wmNotifier *wmn, const Scene *UNUSED(scene))
  {
        /* context changes */
        switch (wmn->category) {
        }
  }
  
 +static int view3d_tools_region_snap_size(const ARegion *ar, int size, int axis)
 +{
 +      if (axis == 0) {
 +              /* Note, this depends on the icon size: see #ICON_DEFAULT_HEIGHT_TOOLBAR. */
 +              const float snap_units[] = {3 + 0.25f, 5 + 0.25};
 +              const float aspect = BLI_rctf_size_x(&ar->v2d.cur) / (BLI_rcti_size_x(&ar->v2d.mask) + 1);
 +              int best_diff = INT_MAX;
 +              int best_size = size;
 +              for (uint i = 0; i < ARRAY_SIZE(snap_units); i += 1) {
 +                      const int test_size = (snap_units[i] * U.widget_unit) / (UI_DPI_FAC * aspect);
 +                      const int test_diff = ABS(test_size - size);
 +                      if (test_diff < best_diff) {
 +                              best_size = test_size;
 +                              best_diff = test_diff;
 +                      }
 +              }
 +              return best_size;
 +      }
 +      return size;
 +}
 +
  /* add handlers, stuff you only do once or on area/region changes */
  static void view3d_tools_region_init(wmWindowManager *wm, ARegion *ar)
  {
  
  static void view3d_tools_region_draw(const bContext *C, ARegion *ar)
  {
 -      ED_region_panels(C, ar, CTX_data_mode_string(C), -1, true);
 -}
 -
 -static void view3d_props_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
 -{
 -      /* context changes */
 -      switch (wmn->category) {
 -              case NC_WM:
 -                      if (wmn->data == ND_HISTORY)
 -                              ED_region_tag_redraw(ar);
 -                      break;
 -              case NC_SCENE:
 -                      if (wmn->data == ND_MODE)
 -                              ED_region_tag_redraw(ar);
 -                      break;
 -              case NC_SPACE:
 -                      if (wmn->data == ND_SPACE_VIEW3D)
 -                              ED_region_tag_redraw(ar);
 -                      break;
 -      }
 +      ED_region_panels(C, ar, (const char * []){CTX_data_mode_string(C), NULL}, -1, true);
  }
  
  /* area (not region) level listener */
 -static void space_view3d_listener(bScreen *UNUSED(sc), ScrArea *sa, struct wmNotifier *wmn)
 +static void space_view3d_listener(
 +        bScreen *UNUSED(sc), ScrArea *sa, struct wmNotifier *wmn, Scene *UNUSED(scene),
 +        WorkSpace *UNUSED(workspace))
  {
        View3D *v3d = sa->spacedata.first;
  
  }
  
  const char *view3d_context_dir[] = {
 -      "selected_objects", "selected_bases", "selected_editable_objects",
 -      "selected_editable_bases", "visible_objects", "visible_bases", "selectable_objects", "selectable_bases",
        "active_base", "active_object", NULL
  };
  
@@@ -1409,27 -1267,109 +1408,27 @@@ static int view3d_context(const bContex
        if (CTX_data_dir(member)) {
                CTX_data_dir_set(result, view3d_context_dir);
        }
 -      else if (CTX_data_equals(member, "selected_objects") || CTX_data_equals(member, "selected_bases")) {
 -              View3D *v3d = CTX_wm_view3d(C);
 -              Scene *scene = CTX_data_scene(C);
 -              const unsigned int lay = v3d ? v3d->lay : scene->lay;
 -              Base *base;
 -              const bool selected_objects = CTX_data_equals(member, "selected_objects");
 -
 -              for (base = scene->base.first; base; base = base->next) {
 -                      if ((base->flag & SELECT) && (base->lay & lay)) {
 -                              if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) {
 -                                      if (selected_objects)
 -                                              CTX_data_id_list_add(result, &base->object->id);
 -                                      else
 -                                              CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
 -                              }
 -                      }
 -              }
 -              CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
 -              return 1;
 -      }
 -      else if (CTX_data_equals(member, "selected_editable_objects") || CTX_data_equals(member, "selected_editable_bases")) {
 -              View3D *v3d = CTX_wm_view3d(C);
 -              Scene *scene = CTX_data_scene(C);
 -              const unsigned int lay = v3d ? v3d->lay : scene->lay;
 -              Base *base;
 -              const bool selected_editable_objects = CTX_data_equals(member, "selected_editable_objects");
 -
 -              for (base = scene->base.first; base; base = base->next) {
 -                      if ((base->flag & SELECT) && (base->lay & lay)) {
 -                              if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) {
 -                                      if (0 == BKE_object_is_libdata(base->object)) {
 -                                              if (selected_editable_objects)
 -                                                      CTX_data_id_list_add(result, &base->object->id);
 -                                              else
 -                                                      CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
 -                                      }
 -                              }
 -                      }
 -              }
 -              CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
 -              return 1;
 -      }
 -      else if (CTX_data_equals(member, "visible_objects") || CTX_data_equals(member, "visible_bases")) {
 -              View3D *v3d = CTX_wm_view3d(C);
 -              Scene *scene = CTX_data_scene(C);
 -              const unsigned int lay = v3d ? v3d->lay : scene->lay;
 -              Base *base;
 -              const bool visible_objects = CTX_data_equals(member, "visible_objects");
 -
 -              for (base = scene->base.first; base; base = base->next) {
 -                      if (base->lay & lay) {
 -                              if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) {
 -                                      if (visible_objects)
 -                                              CTX_data_id_list_add(result, &base->object->id);
 -                                      else
 -                                              CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
 -                              }
 -                      }
 -              }
 -              CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
 -              return 1;
 -      }
 -      else if (CTX_data_equals(member, "selectable_objects") || CTX_data_equals(member, "selectable_bases")) {
 -              View3D *v3d = CTX_wm_view3d(C);
 -              Scene *scene = CTX_data_scene(C);
 -              const unsigned int lay = v3d ? v3d->lay : scene->lay;
 -              Base *base;
 -              const bool selectable_objects = CTX_data_equals(member, "selectable_objects");
 -
 -              for (base = scene->base.first; base; base = base->next) {
 -                      if (base->lay & lay) {
 -                              if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0 && (base->object->restrictflag & OB_RESTRICT_SELECT) == 0) {
 -                                      if (selectable_objects)
 -                                              CTX_data_id_list_add(result, &base->object->id);
 -                                      else
 -                                              CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
 -                              }
 -                      }
 -              }
 -              CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
 -              return 1;
 -      }
        else if (CTX_data_equals(member, "active_base")) {
 -              View3D *v3d = CTX_wm_view3d(C);
                Scene *scene = CTX_data_scene(C);
 -              const unsigned int lay = v3d ? v3d->lay : scene->lay;
 -              if (scene->basact && (scene->basact->lay & lay)) {
 -                      Object *ob = scene->basact->object;
 +              ViewLayer *view_layer = CTX_data_view_layer(C);
 +              if (view_layer->basact) {
 +                      Object *ob = view_layer->basact->object;
                        /* if hidden but in edit mode, we still display, can happen with animation */
 -                      if ((ob->restrictflag & OB_RESTRICT_VIEW) == 0 || (ob->mode & OB_MODE_EDIT))
 -                              CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, scene->basact);
 +                      if ((view_layer->basact->flag & BASE_VISIBLED) != 0 || (ob->mode & OB_MODE_EDIT)) {
 +                              CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, view_layer->basact);
 +                      }
                }
                
                return 1;
        }
        else if (CTX_data_equals(member, "active_object")) {
 -              View3D *v3d = CTX_wm_view3d(C);
 -              Scene *scene = CTX_data_scene(C);
 -              const unsigned int lay = v3d ? v3d->lay : scene->lay;
 -              if (scene->basact && (scene->basact->lay & lay)) {
 -                      Object *ob = scene->basact->object;
 -                      if ((ob->restrictflag & OB_RESTRICT_VIEW) == 0 || (ob->mode & OB_MODE_EDIT))
 -                              CTX_data_id_pointer_set(result, &scene->basact->object->id);
 +              ViewLayer *view_layer = CTX_data_view_layer(C);
 +              if (view_layer->basact) {
 +                      Object *ob = view_layer->basact->object;
 +                      /* if hidden but in edit mode, we still display, can happen with animation */
 +                      if ((view_layer->basact->flag & BASE_VISIBLED) != 0 || (ob->mode & OB_MODE_EDIT) != 0) {
 +                              CTX_data_id_pointer_set(result, &ob->id);
 +                      }
                }
                
                return 1;
@@@ -1470,6 -1410,8 +1469,6 @@@ static void view3d_id_remap(ScrArea *sa
  
                /* Values in local-view aren't used, see: T52663 */
                if (is_local == false) {
 -                      /* Skip 'v3d->defmaterial', it's not library data.  */
 -
                        if ((ID *)v3d->ob_centre == old_id) {
                                v3d->ob_centre = (Object *)new_id;
                                /* Otherwise, bonename may remain valid... We could be smart and check this, too? */
                                        v3d->ob_centre_bone[0] = '\0';
                                }
                        }
 -
 -                      if (ELEM(GS(old_id->name), ID_IM, ID_MC)) {
 -                              for (BGpic *bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
 -                                      if ((ID *)bgpic->ima == old_id) {
 -                                              bgpic->ima = (Image *)new_id;
 -                                              id_us_min(old_id);
 -                                              id_us_plus(new_id);
 -                                      }
 -                                      if ((ID *)bgpic->clip == old_id) {
 -                                              bgpic->clip = (MovieClip *)new_id;
 -                                              id_us_min(old_id);
 -                                              id_us_plus(new_id);
 -                                      }
 -                              }
 -                      }
                }
  
                if (is_local) {
@@@ -1502,7 -1459,6 +1501,7 @@@ void ED_spacetype_view3d(void
        st->operatortypes = view3d_operatortypes;
        st->keymap = view3d_keymap;
        st->dropboxes = view3d_dropboxes;
 +      st->manipulators = view3d_widgets;
        st->context = view3d_context;
        st->id_remap = view3d_id_remap;
  
        art->free = view3d_main_region_free;
        art->duplicate = view3d_main_region_duplicate;
        art->listener = view3d_main_region_listener;
 +      art->message_subscribe = view3d_main_region_message_subscribe;
        art->cursor = view3d_main_region_cursor;
        art->lock = 1;   /* can become flag, see BKE_spacedata_draw_locks */
        BLI_addhead(&st->regiontypes, art);
        art->prefsizey = 50; /* XXX */
        art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
        art->listener = view3d_buttons_region_listener;
 +      art->message_subscribe = view3d_tools_region_message_subscribe;
 +      art->snap_size = view3d_tools_region_snap_size;
        art->init = view3d_tools_region_init;
        art->draw = view3d_tools_region_draw;
        BLI_addhead(&st->regiontypes, art);
        view3d_toolshelf_register(art);
  #endif
  
 -      /* regions: tool properties */
 -      art = MEM_callocN(sizeof(ARegionType), "spacetype view3d tool properties region");
 -      art->regionid = RGN_TYPE_TOOL_PROPS;
 -      art->prefsizex = 0;
 -      art->prefsizey = 120;
 -      art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
 -      art->listener = view3d_props_region_listener;
 -      art->init = view3d_tools_region_init;
 -      art->draw = view3d_tools_region_draw;
 -      BLI_addhead(&st->regiontypes, art);
 -      
 -      view3d_tool_props_register(art);
 -      
 -      
        /* regions: header */
        art = MEM_callocN(sizeof(ARegionType), "spacetype view3d header region");
        art->regionid = RGN_TYPE_HEADER;
        art->listener = view3d_header_region_listener;
        art->init = view3d_header_region_init;
        art->draw = view3d_header_region_draw;
 +      art->message_subscribe = view3d_header_region_message_subscribe;
        BLI_addhead(&st->regiontypes, art);
        
        BKE_spacetype_register(st);
  }
 -
index 0568af454fc2235a0297e387c594bab37e16aa99,0e13aff4d4420ba22e91ec730dfb29eb151b14d2..2266390d348912ca62b567ab03691a450719cab8
@@@ -43,7 -43,7 +43,7 @@@
  
  struct SpaceLink;
  struct Object;
 -struct Group;
 +struct Collection;
  struct GHash;
  
  /* ************************************************ */
@@@ -61,8 -61,7 +61,8 @@@ typedef struct bMotionPathVert 
  /* bMotionPathVert->flag */
  typedef enum eMotionPathVert_Flag {
        /* vert is selected */
 -      MOTIONPATH_VERT_SEL     = (1 << 0)
 +      MOTIONPATH_VERT_SEL     = (1 << 0),
 +      MOTIONPATH_VERT_KEY     = (1 << 1),
  } eMotionPathVert_Flag;
  
  /* ........ */
@@@ -80,12 -79,6 +80,12 @@@ typedef struct bMotionPath 
        float color[3];             /* optional custom color */
        int line_thickness;         /* line thickness */
        int flag;                   /* baking settings - eMotionPath_Flag */
 +
 +      /* Used for drawing. */
 +      struct Gwn_VertBuf *points_vbo;
 +      struct Gwn_Batch *batch_line;
 +      struct Gwn_Batch *batch_points;
 +      void *pad;
  } bMotionPath;
  
  /* bMotionPath->flag */
@@@ -187,18 -180,6 +187,18 @@@ typedef enum eMotionPaths_BakeFlag 
        MOTIONPATH_BAKE_HAS_PATHS       = (1 << 2)
  } eMotionPath_BakeFlag;
  
 +/* runtime */
 +#
 +#
 +typedef struct bPoseChannelDrawData {
 +      float solid_color[4];
 +      float wire_color[4];
 +
 +      int bbone_matrix_len;
 +      /* keep last */
 +      float bbone_matrix[0][4][4];
 +} bPoseChannelDrawData;
 +
  /* ************************************************ */
  /* Poses */
  
@@@ -257,8 -238,6 +257,8 @@@ typedef struct bPoseChannel 
        float chan_mat[4][4];           /* matrix result of loc/quat/size, and where we put deform in, see next line */
        float pose_mat[4][4];           /* constraints accumulate here. in the end, pose_mat = bone->arm_mat * chan_mat
                                         * this matrix is object space */
 +      float disp_mat[4][4];           /* for display, pose_mat with bone length applied */
 +      float disp_tail_mat[4][4];      /* for display, pose_mat with bone length applied and translated to tail*/
        float constinv[4][4];           /* inverse result of constraints.
                                         * doesn't include effect of restposition, parent, and local transform*/
        
        
        struct bPoseChannel *bbone_prev; /* next/prev bones to use as handle references when calculating bbones (optional) */
        struct bPoseChannel *bbone_next;
 -      
 +
        void        *temp;              /* use for outliner */
 +      /* Runtime data for color and bbone segment matrix. */
 +      bPoseChannelDrawData *draw_data;
 +
 +      /* Points to an original pose channel. */
 +      struct bPoseChannel *orig_pchan;
  } bPoseChannel;
  
  
@@@ -444,7 -418,8 +444,7 @@@ typedef enum ePose_Flags 
        POSE_RECALCPATHS = (1 << 4),
        /* set by BKE_pose_rebuild to give a chance to the IK solver to rebuild IK tree */
        POSE_WAS_REBUILT = (1 << 5),
 -      /* set by game_copy_pose to indicate that this pose is used in the game engine */
 -      POSE_GAME_ENGINE = (1 << 6),
 +      POSE_FLAG_DEPRECATED = (1 << 6), /* deprecated. */
        /* pose constraint flags needs to be updated */
        POSE_CONSTRAINTS_NEED_UPDATE_FLAGS = (1 << 7),
  } ePose_Flags;
@@@ -598,7 -573,7 +598,7 @@@ typedef struct bDopeSheet 
        ID      *source;            /* currently ID_SCE (for Dopesheet), and ID_SC (for Grease Pencil) */
        ListBase chanbase; /* cache for channels (only initialized when pinned) */           // XXX not used!
        
 -      struct Group *filter_grp;   /* object group for ADS_FILTER_ONLYOBGROUP filtering option */
 +      struct Collection *filter_grp;   /* object group for ADS_FILTER_ONLYOBGROUP filtering option */
        char searchstr[64];         /* string to search for in displayed names of F-Curves for ADS_FILTER_BY_FCU_NAME filtering option */
        
        int filterflag;             /* flags to use for filtering data */
@@@ -677,10 -652,10 +677,10 @@@ typedef enum eDopeSheet_Flag 
  typedef struct SpaceAction {
        struct SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       float blockscale;
-       short blockhandler[8];
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
  
        View2D v2d DNA_DEPRECATED;  /* copied to region */
        
        char mode, autosnap;        /* mode: editing context; autosnap: automatic keyframe snapping mode   */
        short flag;                 /* flag: bitmapped settings; */
        float timeslide;            /* for Time-Slide transform mode drawing - current frame? */
 +      
 +      int cache_display;          /* (eTimeline_Cache_Flag) */
 +      int pad;
  } SpaceAction;
  
  /* SpaceAction flag */
@@@ -737,8 -709,6 +737,8 @@@ typedef enum eAnimEdit_Context 
        SACTCONT_MASK = 4,
        /* cache file */
        SACTCONT_CACHEFILE = 5,
 +      /* timeline - replacement for the standalone "timeline editor" */
 +      SACTCONT_TIMELINE = 6,
  } eAnimEdit_Context;
  
  /* SpaceAction AutoSnap Settings (also used by other Animation Editors) */
@@@ -757,17 -727,6 +757,17 @@@ typedef enum eAnimEdit_AutoSnap 
        SACTSNAP_TSTEP = 5
  } eAnimEdit_AutoSnap;
  
 +/* SAction->cache_display */
 +typedef enum eTimeline_Cache_Flag {
 +      TIME_CACHE_DISPLAY       = (1 << 0),
 +      TIME_CACHE_SOFTBODY      = (1 << 1),
 +      TIME_CACHE_PARTICLES     = (1 << 2),
 +      TIME_CACHE_CLOTH         = (1 << 3),
 +      TIME_CACHE_SMOKE         = (1 << 4),
 +      TIME_CACHE_DYNAMICPAINT  = (1 << 5),
 +      TIME_CACHE_RIGIDBODY     = (1 << 6),
 +} eTimeline_Cache_Flag;
 +
  
  /* ************************************************ */
  /* Legacy Data */
index bbea3b168e3a32820d2738b82111bd091d424323,00575532d38f769c3a0923e50527c062504d891d..1b55a97754a1d5db8f5d8ac5b58f2fdd82fb9cd5
@@@ -67,11 -67,6 +67,11 @@@ struct MovieClipScopes
  struct Mask;
  struct BLI_mempool;
  
 +/* TODO 2.8: We don't write the global areas to files currently. Uncomment
 + * define to enable writing (should become the default in a bit). */
 +//#define WITH_GLOBAL_AREA_WRITING
 +
 +
  /* -------------------------------------------------------------------- */
  /** \name SpaceLink (Base)
   * \{ */
@@@ -84,9 -79,9 +84,9 @@@
  typedef struct SpaceLink {
        struct SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       float blockscale DNA_DEPRECATED;        /* XXX make deprecated */
-       short blockhandler[8]  DNA_DEPRECATED;  /* XXX make deprecated */
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
  } SpaceLink;
  
  /* -------------------------------------------------------------------- */
  typedef struct SpaceInfo {
        SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       float blockscale DNA_DEPRECATED;
-       short blockhandler[8]  DNA_DEPRECATED;      /* XXX make deprecated */
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
  
        char rpt_mask;
        char pad[7];
@@@ -124,21 -120,19 +125,21 @@@ typedef enum eSpaceInfo_RptMask 
  typedef struct SpaceButs {
        SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       float blockscale DNA_DEPRECATED;
-       short blockhandler[8]  DNA_DEPRECATED;
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
  
        View2D v2d DNA_DEPRECATED;                      /* deprecated, copied to region */
  
 +      /* For different kinds of property editors (exposed in the space type selector). */
 +      short space_subtype;
 +
        short mainb, mainbo, mainbuser; /* context tabs */
        short re_align, align;          /* align for panels */
        short preview;                  /* preview is signal to refresh */
 -      /* texture context selector (material, lamp, particles, world, other) */
 -      short texture_context, texture_context_prev;
 -      char flag, pad[7];
 +      char flag;
 +      char collection_context;
  
        void *path;                     /* runtime */
        int pathflag, dataicon;         /* runtime */
  #define CONTEXT_SHADING 3
  #define CONTEXT_EDITING 4
  // #define CONTEXT_SCRIPT  5
 -#define CONTEXT_LOGIC   6
 +// #define CONTEXT_LOGIC   6
  
  /* SpaceButs.mainb old (deprecated) */
  // #define BUTS_VIEW           0
  #define BUTS_WORLD          5
  #define BUTS_RENDER         6
  #define BUTS_EDIT           7
 -#define BUTS_GAME           8
 +// #define BUTS_GAME           8
  #define BUTS_FPAINT         9
  #define BUTS_RADIO          10
  #define BUTS_SCRIPT         11
@@@ -192,8 -186,7 +193,8 @@@ typedef enum eSpaceButtons_Context 
        BCONTEXT_MODIFIER = 10,
        BCONTEXT_CONSTRAINT = 11,
        BCONTEXT_BONE_CONSTRAINT = 12,
 -      BCONTEXT_RENDER_LAYER = 13,
 +      BCONTEXT_VIEW_LAYER = 13,
 +      BCONTEXT_WORKSPACE = 15,
  
        /* always as last... */
        BCONTEXT_TOT
@@@ -209,6 -202,16 +210,6 @@@ typedef enum eSpaceButtons_Flag 
        SB_SHADING_CONTEXT = (1 << 4),
  } eSpaceButtons_Flag;
  
 -/* SpaceButs.texture_context */
 -typedef enum eSpaceButtons_Texture_Context {
 -      SB_TEXC_MATERIAL = 0,
 -      SB_TEXC_WORLD = 1,
 -      SB_TEXC_LAMP = 2,
 -      SB_TEXC_PARTICLES = 3,
 -      SB_TEXC_OTHER = 4,
 -      SB_TEXC_LINESTYLE = 5,
 -} eSpaceButtons_Texture_Context;
 -
  /* SpaceButs.align */
  typedef enum eSpaceButtons_Align {
        BUT_FREE = 0,
        BUT_AUTO = 3,
  } eSpaceButtons_Align;
  
 -/* SpaceButs.scaflag */
 -#define BUTS_SENS_SEL           1
 -#define BUTS_SENS_ACT           2
 -#define BUTS_SENS_LINK          4
 -#define BUTS_CONT_SEL           8
 -#define BUTS_CONT_ACT           16
 -#define BUTS_CONT_LINK          32
 -#define BUTS_ACT_SEL            64
 -#define BUTS_ACT_ACT            128
 -#define BUTS_ACT_LINK           256
 -#define BUTS_SENS_STATE         512
 -#define BUTS_ACT_STATE          1024
 -#define BUTS_CONT_INIT_STATE    2048
 -
 +/* SpaceButs.flag */
 +typedef enum eSpaceButtons_SubType {
 +      SB_SUBTYPE_DATA = 0,
 +      SB_SUBTYPE_TOOL = 1,
 +} eSpaceButtons_SubType;
  
  /** \} */
  
  typedef struct SpaceOops {
        SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       float blockscale DNA_DEPRECATED;
-       short blockhandler[8]  DNA_DEPRECATED;
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
  
        View2D v2d DNA_DEPRECATED;  /* deprecated, copied to region */
  
        struct TreeStoreElem search_tse;
  
        short flag, outlinevis, storeflag, search_flags;
 +      int filter;
 +      char filter_state;
 +      char pad;
 +      short filter_id_type;
  
        /* pointers to treestore elements, grouped by (id, type, nr) in hashtable for faster searching */
        void *treehash;
@@@ -273,81 -282,31 +275,81 @@@ typedef enum eSpaceOutliner_Flag 
        SO_SKIP_SORT_ALPHA      = (1 << 4),
  } eSpaceOutliner_Flag;
  
 +/* SpaceOops.filter */
 +typedef enum eSpaceOutliner_Filter {
 +      SO_FILTER_SEARCH           = (1 << 0),
 +      /* SO_FILTER_ENABLE           = (1 << 1), */ /* Deprecated */
 +      SO_FILTER_NO_OBJECT        = (1 << 2),
 +      SO_FILTER_NO_OB_CONTENT    = (1 << 3), /* Not only mesh, but modifiers, constraints, ... */
 +      SO_FILTER_NO_CHILDREN      = (1 << 4),
 +
 +      /* SO_FILTER_OB_TYPE          = (1 << 5), */ /* Deprecated */
 +      SO_FILTER_NO_OB_MESH       = (1 << 6),
 +      SO_FILTER_NO_OB_ARMATURE   = (1 << 7),
 +      SO_FILTER_NO_OB_EMPTY      = (1 << 8),
 +      SO_FILTER_NO_OB_LAMP       = (1 << 9),
 +      SO_FILTER_NO_OB_CAMERA     = (1 << 10),
 +      SO_FILTER_NO_OB_OTHERS     = (1 << 11),
 +
 +      /* SO_FILTER_OB_STATE          = (1 << 12), */ /* Deprecated */
 +      SO_FILTER_OB_STATE_VISIBLE  = (1 << 13), /* Not set via DNA. */
 +      SO_FILTER_OB_STATE_SELECTED = (1 << 14), /* Not set via DNA. */
 +      SO_FILTER_OB_STATE_ACTIVE   = (1 << 15), /* Not set via DNA. */
 +      SO_FILTER_NO_COLLECTION     = (1 << 16),
 +
 +      SO_FILTER_ID_TYPE           = (1 << 17),
 +} eSpaceOutliner_Filter;
 +
 +#define SO_FILTER_OB_TYPE (SO_FILTER_NO_OB_MESH | \
 +                           SO_FILTER_NO_OB_ARMATURE | \
 +                           SO_FILTER_NO_OB_EMPTY | \
 +                           SO_FILTER_NO_OB_LAMP | \
 +                           SO_FILTER_NO_OB_CAMERA | \
 +                           SO_FILTER_NO_OB_OTHERS)
 +
 +#define SO_FILTER_OB_STATE (SO_FILTER_OB_STATE_VISIBLE | \
 +                            SO_FILTER_OB_STATE_SELECTED | \
 +                            SO_FILTER_OB_STATE_ACTIVE)
 +
 +#define SO_FILTER_ANY (SO_FILTER_NO_OB_CONTENT | \
 +                       SO_FILTER_NO_CHILDREN | \
 +                       SO_FILTER_OB_TYPE | \
 +                       SO_FILTER_OB_STATE | \
 +                       SO_FILTER_NO_COLLECTION)
 +
 +/* SpaceOops.filter_state */
 +typedef enum eSpaceOutliner_StateFilter {
 +      SO_FILTER_OB_ALL           = 0,
 +      SO_FILTER_OB_VISIBLE       = 1,
 +      SO_FILTER_OB_SELECTED      = 2,
 +      SO_FILTER_OB_ACTIVE        = 3,
 +} eSpaceOutliner_StateFilter;
 +
  /* SpaceOops.outlinevis */
  typedef enum eSpaceOutliner_Mode {
 -      SO_ALL_SCENES = 0,
 -      SO_CUR_SCENE = 1,
 -      SO_VISIBLE = 2,
 -      SO_SELECTED = 3,
 -      SO_ACTIVE = 4,
 -      SO_SAME_TYPE = 5,
 -      SO_GROUPS = 6,
 -      SO_LIBRARIES = 7,
 -      /* SO_VERSE_SESSION = 8, */  /* deprecated! */
 -      /* SO_VERSE_MS = 9, */       /* deprecated! */
 -      SO_SEQUENCE = 10,
 -      SO_DATABLOCKS = 11,
 -      SO_USERDEF = 12,
 -      /* SO_KEYMAP = 13, */        /* deprecated! */
 -      SO_ID_ORPHANS = 14,
 +      SO_SCENES            = 0,
 +      /* SO_CUR_SCENE      = 1, */  /* deprecated! */
 +      /* SO_VISIBLE        = 2, */  /* deprecated! */
 +      /* SO_SELECTED       = 3, */  /* deprecated! */
 +      /* SO_ACTIVE         = 4, */  /* deprecated! */
 +      /* SO_SAME_TYPE      = 5, */  /* deprecated! */
 +      /* SO_GROUPS         = 6, */  /* deprecated! */
 +      SO_LIBRARIES         = 7,
 +      /* SO_VERSE_SESSION  = 8, */  /* deprecated! */
 +      /* SO_VERSE_MS       = 9, */  /* deprecated! */
 +      SO_SEQUENCE          = 10,
 +      SO_DATA_API          = 11,
 +      /* SO_USERDEF        = 12, */  /* deprecated! */
 +      /* SO_KEYMAP         = 13, */  /* deprecated! */
 +      SO_ID_ORPHANS        = 14,
 +      SO_VIEW_LAYER        = 15,
  } eSpaceOutliner_Mode;
  
  /* SpaceOops.storeflag */
  typedef enum eSpaceOutliner_StoreFlag {
        /* cleanup tree */
        SO_TREESTORE_CLEANUP    = (1 << 0),
 -      /* if set, it allows redraws. gets set for some allqueue events */
 -      SO_TREESTORE_REDRAW     = (1 << 1),
 +      /* SO_TREESTORE_REDRAW     = (1 << 1), */ /* Deprecated */
        /* rebuild the tree, similar to cleanup,
         * but defer a call to BKE_outliner_treehash_rebuild_from_treestore instead */
        SO_TREESTORE_REBUILD    = (1 << 2),
@@@ -370,9 -329,10 +372,10 @@@ typedef enum eSpaceOutliner_Search_Flag
  typedef struct SpaceIpo {
        SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       float blockscale DNA_DEPRECATED;
-       short blockhandler[8]  DNA_DEPRECATED;
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
  
        View2D v2d DNA_DEPRECATED;  /* deprecated, copied to region */
  
@@@ -446,9 -406,10 +449,10 @@@ typedef enum eGraphEdit_Mode 
  typedef struct SpaceNla {
        struct SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       float blockscale DNA_DEPRECATED;
-       short blockhandler[8]  DNA_DEPRECATED;
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
  
        short autosnap;         /* this uses the same settings as autosnap for Action Editor */
        short flag;
@@@ -480,6 -441,43 +484,6 @@@ typedef enum eSpaceNla_Flag 
  /** \name Timeline
   * \{ */
  
 -/* Pointcache drawing data */
 -# /* Only store the data array in the cache to avoid constant reallocation. */
 -# /* No need to store when saved. */
 -typedef struct SpaceTimeCache {
 -      struct SpaceTimeCache *next, *prev;
 -      float *array;
 -} SpaceTimeCache;
 -
 -/* Timeline View */
 -typedef struct SpaceTime {
 -      SpaceLink *next, *prev;
 -      ListBase regionbase;        /* storage of regions for inactive spaces */
 -      char spacetype;
 -      char link_flag;
 -      char _pad0[6];
 -      /* End 'SpaceLink' header. */
 -
 -
 -      View2D v2d DNA_DEPRECATED;  /* deprecated, copied to region */
 -
 -      ListBase caches;
 -
 -      int cache_display;
 -      int flag;
 -} SpaceTime;
 -
 -
 -/* SpaceTime.flag */
 -typedef enum eTimeline_Flag {
 -      /* show timing in frames instead of in seconds */
 -      TIME_DRAWFRAMES    = (1 << 0),
 -      /* show time indicator box beside the frame number */
 -      TIME_CFRA_NUM      = (1 << 1),
 -      /* only keyframes from active/selected channels get shown */
 -      TIME_ONLYACTSEL    = (1 << 2),
 -} eTimeline_Flag;
 -
  /* SpaceTime.redraws (now bScreen.redraws_flag) */
  typedef enum eScreen_Redraws_Flag {
        TIME_REGION            = (1 << 0),
        TIME_FOLLOW            = (1 << 15),
  } eScreen_Redraws_Flag;
  
 -/* SpaceTime.cache */
 -typedef enum eTimeline_Cache_Flag {
 -      TIME_CACHE_DISPLAY       = (1 << 0),
 -      TIME_CACHE_SOFTBODY      = (1 << 1),
 -      TIME_CACHE_PARTICLES     = (1 << 2),
 -      TIME_CACHE_CLOTH         = (1 << 3),
 -      TIME_CACHE_SMOKE         = (1 << 4),
 -      TIME_CACHE_DYNAMICPAINT  = (1 << 5),
 -      TIME_CACHE_RIGIDBODY     = (1 << 6),
 -} eTimeline_Cache_Flag;
 -
  /** \} */
  
  /* -------------------------------------------------------------------- */
  typedef struct SpaceSeq {
        SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       float blockscale DNA_DEPRECATED;
-       short blockhandler[8]  DNA_DEPRECATED;
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
  
        View2D v2d DNA_DEPRECATED;  /* deprecated, copied to region */
  
@@@ -651,8 -660,12 +655,12 @@@ typedef struct FileSelectParams 
  typedef struct SpaceFile {
        SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
  
+       char _pad1[4];
        int scroll_offset;
  
        struct FileSelectParams *params; /* config and input for file select */
        short systemnr, system_bookmarknr;
  } SpaceFile;
  
 -/* FSMenuEntry's without paths indicate separators */
 -typedef struct FSMenuEntry {
 -      struct FSMenuEntry *next;
 -
 -      char *path;
 -      char name[256];  /* FILE_MAXFILE */
 -      short save;
 -      short valid;
 -      short pad[2];
 -} FSMenuEntry;
 -
  /* FileSelectParams.display */
  enum eFileDisplayType {
        FILE_DEFAULTDISPLAY = 0,
@@@ -727,7 -751,7 +735,7 @@@ typedef enum eFileSel_Params_Flag 
        FILE_LINK           = (1 << 2),
        FILE_HIDE_DOT       = (1 << 3),
        FILE_AUTOSELECT     = (1 << 4),
 -      FILE_ACTIVELAY      = (1 << 5),
 +      FILE_ACTIVE_COLLECTION = (1 << 5),
  /*  FILE_ATCURSOR       = (1 << 6), */ /* deprecated */
        FILE_DIRSEL_ONLY    = (1 << 7),
        FILE_FILTER         = (1 << 8),
@@@ -892,9 -916,10 +900,10 @@@ enum 
  typedef struct SpaceImage {
        SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       int flag;
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
  
        struct Image *image;
        struct ImageUser iuser;
  
        /* Filter settings when editor shows other object's UVs. */
        int other_uv_filter;
-       int pad2;
+       int flag;
  
        MaskSpaceInfo mask_info;
  } SpaceImage;
@@@ -960,7 -986,7 +970,7 @@@ typedef enum eSpaceImage_Sticky 
  /* SpaceImage.flag */
  typedef enum eSpaceImage_Flag {
  /*    SI_BE_SQUARE          = (1 << 0), */  /* deprecated */
 -      SI_EDITTILE           = (1 << 1),     /* XXX - not used but should be? */
 +/*    SI_EDITTILE           = (1 << 1), */  /* deprecated */
        SI_CLIP_UV            = (1 << 2),
  /*    SI_DRAWTOOL           = (1 << 3), */  /* deprecated */
        SI_NO_DRAWFACES       = (1 << 4),
@@@ -1017,9 -1043,10 +1027,10 @@@ typedef enum eSpaceImage_OtherUVFilter 
  typedef struct SpaceText {
        SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       float blockscale DNA_DEPRECATED;
-       short blockhandler[8]  DNA_DEPRECATED;
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
  
        struct Text *text;
  
@@@ -1100,8 -1127,11 +1111,11 @@@ typedef struct Script 
  typedef struct SpaceScript {
        SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       float blockscale DNA_DEPRECATED;
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
        struct Script *script;
  
        short flags, menunr;
@@@ -1130,9 -1160,10 +1144,10 @@@ typedef struct bNodeTreePath 
  typedef struct SpaceNode {
        SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       float blockscale DNA_DEPRECATED;
-       short blockhandler[8]  DNA_DEPRECATED;
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
  
        View2D v2d DNA_DEPRECATED;  /* deprecated, copied to region */
  
@@@ -1184,14 -1215,14 +1199,14 @@@ typedef enum eSpaceNode_Flag 
        SNODE_AUTO_RENDER    = (1 << 5),
  //    SNODE_SHOW_HIGHLIGHT = (1 << 6), DNA_DEPRECATED
  //    SNODE_USE_HIDDEN_PREVIEW = (1 << 10), DNA_DEPRECATED December2013
 -      SNODE_NEW_SHADERS    = (1 << 11),
 +//    SNODE_NEW_SHADERS    = (1 << 11), DNA_DEPRECATED
        SNODE_PIN            = (1 << 12),
        SNODE_SKIP_INSOFFSET = (1 << 13), /* automatically offset following nodes in a chain on insertion */
  } eSpaceNode_Flag;
  
  /* SpaceNode.texfrom */
  typedef enum eSpaceNode_TexFrom {
 -      SNODE_TEX_OBJECT   = 0,
 +      /* SNODE_TEX_OBJECT   = 0, */
        SNODE_TEX_WORLD    = 1,
        SNODE_TEX_BRUSH    = 2,
        SNODE_TEX_LINESTYLE = 3,
@@@ -1212,6 -1243,27 +1227,6 @@@ enum 
  
  /** \} */
  
 -/* -------------------------------------------------------------------- */
 -/** \name Game Logic Editor
 - * \{ */
 -
 -/* Logic Editor */
 -typedef struct SpaceLogic {
 -      SpaceLink *next, *prev;
 -      ListBase regionbase;        /* storage of regions for inactive spaces */
 -      char spacetype;
 -      char link_flag;
 -      char _pad0[6];
 -      /* End 'SpaceLink' header. */
 -
 -      short flag, scaflag;
 -      int pad;
 -
 -      struct bGPdata *gpd;        /* grease-pencil data */
 -} SpaceLogic;
 -
 -/** \} */
 -
  /* -------------------------------------------------------------------- */
  /** \name Console
   * \{ */
@@@ -1242,9 -1294,10 +1257,10 @@@ typedef enum eConsoleLine_Type 
  typedef struct SpaceConsole {
        SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       float blockscale DNA_DEPRECATED;            // XXX are these needed?
-       short blockhandler[8]  DNA_DEPRECATED;      // XXX are these needed?
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
  
        /* space vars */
        int lheight, pad;
  typedef struct SpaceUserPref {
        SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
  
-       char pad[3];
+       char _pad1[7];
        char filter_type;
        char filter[64];        /* search term for filtering in the UI */
  } SpaceUserPref;
  typedef struct SpaceClip {
        SpaceLink *next, *prev;
        ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
+       char _pad1[4];
  
        float xof, yof;             /* user defined offset, image is centered */
        float xlockof, ylockof;     /* user defined offset from locked position */
@@@ -1367,48 -1428,7 +1391,50 @@@ typedef enum eSpaceClip_GPencil_Source 
        SC_GPENCIL_SRC_TRACK = 1,
  } eSpaceClip_GPencil_Source;
  
 -/* **************** SPACE DEFINES ********************* */
 +
 +/** \} */
 +
 +/* -------------------------------------------------------------------- */
 +/** \name Top Bar
 + * \{ */
 +
 +/* These two lines with # tell makesdna this struct can be excluded.
 + * Should be: #ifndef WITH_GLOBAL_AREA_WRITING */
 +#
 +#
 +typedef struct SpaceTopBar {
 +      SpaceLink *next, *prev;
 +      ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       int pad;
++      char spacetype;
++      char link_flag;
++      char _pad0[6];
++      /* End 'SpaceLink' header. */
 +} SpaceTopBar;
 +
 +/** \} */
 +
 +/* -------------------------------------------------------------------- */
 +/** \name Status Bar
 + * \{ */
 +
 +/* These two lines with # tell makesdna this struct can be excluded.
 + * Should be: #ifndef WITH_GLOBAL_AREA_WRITING */
 +#
 +#
 +typedef struct SpaceStatusBar {
 +      SpaceLink *next, *prev;
 +      ListBase regionbase;        /* storage of regions for inactive spaces */
-       int spacetype;
-       int pad;
++      char spacetype;
++      char link_flag;
++      char _pad0[6];
++      /* End 'SpaceLink' header. */
 +} SpaceStatusBar;
 +
 +/** \} */
 +
 +/* -------------------------------------------------------------------- */
 +/** \name Space Type Definitions
 + * \{ */
  
  /* space types, moved from DNA_screen_types.h */
  /* Do NOT change order, append on end. types are hardcoded needed */
@@@ -1431,23 -1451,20 +1457,23 @@@ typedef enum eSpace_Type 
        SPACE_NLA      = 13,
        /* TODO: fully deprecate */
        SPACE_SCRIPT   = 14, /* Deprecated */
 -      SPACE_TIME     = 15,
 +      SPACE_TIME     = 15, /* Deprecated */
        SPACE_NODE     = 16,
 -      SPACE_LOGIC    = 17,
 +      SPACE_LOGIC    = 17, /* deprecated */
        SPACE_CONSOLE  = 18,
        SPACE_USERPREF = 19,
        SPACE_CLIP     = 20,
 +      SPACE_TOPBAR   = 21,
 +      SPACE_STATUSBAR = 22,
  
 -      SPACE_TYPE_LAST = SPACE_CLIP
 +      SPACE_TYPE_LAST = SPACE_STATUSBAR
  } eSpace_Type;
  
  /* use for function args */
  #define SPACE_TYPE_ANY -1
  
 -
  #define IMG_SIZE_FALLBACK 256
  
 +/** \} */
 +
  #endif  /* __DNA_SPACE_TYPES_H__ */
index 7bb2ce7af021f910571d344dc4eeb0cc1ac82663,f7e2a98f66b87a6ad195958859f297edf033d4b5..be980b4fead449bab15228589615b09e22e82de2
@@@ -44,7 -44,7 +44,7 @@@ struct bGPdata
  struct SmoothView3DStore;
  struct wmTimer;
  struct Material;
 -struct GPUFX;
 +struct GPUViewport;
  
  #include "DNA_defs.h"
  #include "DNA_listBase.h"
  #  undef far
  #endif
  
 -/* Background Picture in 3D-View */
 -typedef struct BGpic {
 -      struct BGpic *next, *prev;
 -
 -      struct Image *ima;
 -      struct ImageUser iuser;
 -      struct MovieClip *clip;
 -      struct MovieClipUser cuser;
 -      float xof, yof, size, blend, rotation;
 -      short view;
 -      short flag;
 -      short source;
 -      char pad[6];
 -} BGpic;
 -
 -/* ********************************* */
 -
  typedef struct RegionView3D {
        
        float winmat[4][4];                     /* GL_PROJECTION matrix */
        struct wmTimer *smooth_timer;
  
  
 -      /* transform widget matrix */
 +      /* transform manipulator matrix */
        float twmat[4][4];
 +      /* min/max dot product on twmat xyz axis. */
 +      float tw_axis_min[3], tw_axis_max[3];
 +      float tw_axis_matrix[3][3];
 +
 +      float gridview;
  
        float viewquat[4];                      /* view rotation, must be kept normalized */
        float dist;                                     /* distance from 'ofs' along -viewinv[2] vector, where result is negative as is 'ofs' */
        char pad[3];
        float ofs_lock[2];                      /* normalized offset for locked view: (-1, -1) bottom left, (1, 1) upper right */
  
 -      short twdrawflag;
 +      short twdrawflag; /* XXX can easily get rid of this (Julian) */
        short rflag;
  
  
        float lviewquat[4];
        short lpersp, lview; /* lpersp can never be set to 'RV3D_CAMOB' */
  
 -      float gridview;
 -      float tw_idot[3];  /* manipulator runtime: (1 - dot) product with view vector (used to check view alignment) */
 -
 -
        /* active rotation from NDOF or elsewhere */
        float rot_angle;
        float rot_axis[3];
 -
 -      struct GPUFX *compositor;
  } RegionView3D;
  
 +typedef struct View3DCursor {
 +      float location[3];
 +      float rotation[4];
 +      char _pad[4];
 +} View3DCursor;
 +
 +/* 3D Viewport Shading setings */
 +typedef struct View3DShading {
 +      short flag;
 +      short color_type;
 +
 +      short light;
 +      char pad[2];
 +      char studio_light[256]; /* FILE_MAXFILE */
 +
 +      float shadow_intensity;
 +      float single_color[3];
 +
 +      float studiolight_rot_z;
 +      float studiolight_background;
 +
 +      float object_outline_color[3];
 +      float xray_alpha;
 +} View3DShading;
 +
 +/* 3D Viewport Overlay setings */
 +typedef struct View3DOverlay {
 +      int flag;
 +
 +      /* Edit mode settings */
 +      int edit_flag;
 +      float normals_length;
 +      float backwire_opacity;
 +
 +      /* Paint mode settings */
 +      int paint_flag;
 +
 +      /* Armature edit/pose mode settings */
 +      int arm_flag;
 +} View3DOverlay;
 +
  /* 3D ViewPort Struct */
  typedef struct View3D {
        struct SpaceLink *next, *prev;
        ListBase regionbase;            /* storage of regions for inactive spaces */
-       int spacetype;
-       float blockscale;
-       short blockhandler[8];
+       char spacetype;
+       char link_flag;
+       char _pad0[6];
+       /* End 'SpaceLink' header. */
  
        float viewquat[4]  DNA_DEPRECATED;
        float dist         DNA_DEPRECATED;
        struct Object *camera, *ob_centre;
        rctf render_border;
  
 -      struct ListBase bgpicbase;
 -      struct BGpic *bgpic  DNA_DEPRECATED; /* deprecated, use bgpicbase, only kept for do_versions(...) */
 -
        struct View3D *localvd; /* allocated backup of its self while in localview */
        
        char ob_centre_bone[64];                /* optional string for armature bone to define center, MAXBONENAME */
        unsigned int lay;
        int layact;
        
 -      /**
 -       * The drawing mode for the 3d display. Set to OB_BOUNDBOX, OB_WIRE, OB_SOLID,
 -       * OB_TEXTURE, OB_MATERIAL or OB_RENDER */
 -      short drawtype;
        short ob_centre_cursor;         /* optional bool for 3d cursor to define center */
-       short scenelock, _pad0;
 -      short scenelock, around;
 -      short flag, flag2;
++      short scenelock, _pad1;
 +      short flag, flag2, pad2;
        
        float lens, grid;
        float near, far;
        float ofs[3]  DNA_DEPRECATED;                   /* XXX deprecated */
 -      float cursor[3];
 +
 +      View3DCursor cursor;
 +
 +      char _pad[4];
  
        short matcap_icon;                      /* icon id */
  
        short gridsubdiv;       /* Number of subdivisions in the grid between each highlighted grid line */
        char gridflag;
  
 -      /* transform widget info */
 -      char twtype, twmode, twflag;
 +      /* transform manipulator info */
 +      char twtype, _pad5, twflag;
        
        short flag3;
 -      
 -      /* afterdraw, for xray & transparent */
 -      struct ListBase afterdraw_transp;
 -      struct ListBase afterdraw_xray;
 -      struct ListBase afterdraw_xraytransp;
  
        /* drawflags, denoting state */
        char zbuf, transp, xray;
  
        char multiview_eye;                             /* multiview current eye - for internal use */
  
 -      /* built-in shader effects (eGPUFXFlags) */
        char pad3[4];
  
        /* note, 'fx_settings.dof' is currently _not_ allocated,
        struct GPUFXSettings fx_settings;
  
        void *properties_storage;               /* Nkey panel stores stuff here (runtime only!) */
 -      /* Allocated per view, not library data (used by matcap). */
 -      struct Material *defmaterial;
  
        /* XXX deprecated? */
        struct bGPdata *gpd  DNA_DEPRECATED;            /* Grease-Pencil Data (annotation layers) */
  
 -       /* multiview - stereo 3d */
 +      /* Stereoscopy settings */
        short stereo3d_flag;
        char stereo3d_camera;
        char pad4;
        float stereo3d_volume_alpha;
        float stereo3d_convergence_alpha;
  
 -      /* Previous viewport draw type.
 -       * Runtime-only, set in the rendered viewport toggle operator.
 -       */
 -      short prev_drawtype;
 -      short pad1;
 -      float pad2;
 +      /* Display settings */
 +      short drawtype;         /* Shading mode (OB_SOLID, OB_TEXTURE, ..) */
 +      short prev_drawtype;    /* Runtime, for toggle between rendered viewport. */
 +      int pad5;
 +
 +      View3DShading shading;
 +      View3DOverlay overlay;
  } View3D;
  
  
  #define V3D_S3D_DISPVOLUME            (1 << 2)
  
  /* View3D->flag (short) */
 -/*#define V3D_DISPIMAGE               1*/ /*UNUSED*/
 -#define V3D_DISPBGPICS                2
 +/*#define V3D_FLAG_DEPRECATED_1 (1 << 0) */ /*UNUSED */
 +/*#define V3D_FLAG_DEPRECATED_2 (1 << 1) */ /* UNUSED */
  #define V3D_HIDE_HELPLINES    4
  #define V3D_INVALID_BACKBUF   8
  
 -#define V3D_ALIGN                     1024
 +/* #define V3D_FLAG_DEPRECATED_10 (1 << 10) */ /* UNUSED */
  #define V3D_SELECT_OUTLINE    2048
  #define V3D_ZBUF_SELECT               4096
  #define V3D_GLOBAL_STATS      8192
  #define RV3D_CLIPPING                         4
  #define RV3D_NAVIGATING                               8
  #define RV3D_GPULIGHT_UPDATE          16
 -#define RV3D_IS_GAME_ENGINE                   32  /* runtime flag, used to check if LoD's should be used */
 +/*#define RV3D_IS_GAME_ENGINE                 32 *//* UNUSED */
  /**
   * Disable zbuffer offset, skip calls to #ED_view3d_polygon_offset.
   * Use when precise surface depth is needed and picking bias isn't, see T45434).
  #define V3D_SOLID_MATCAP              (1 << 12)       /* user flag */
  #define V3D_SHOW_SOLID_MATCAP (1 << 13)       /* runtime flag */
  #define V3D_OCCLUDE_WIRE              (1 << 14)
 -#define V3D_SHADELESS_TEX             (1 << 15)
 +#define V3D_SHOW_MODE_SHADE_OVERRIDE  (1 << 15)
  
  
  /* View3d->flag3 (short) */
  #define V3D_SHOW_WORLD                        (1 << 0)
  
 +/* View3DShading->light */
 +enum {
 +      V3D_LIGHTING_FLAT   = 0,
 +      V3D_LIGHTING_STUDIO = 1,
 +      V3D_LIGHTING_SCENE  = 2
 +};
 +
 +/* View3DShading->flag */
 +enum {
 +      V3D_SHADING_OBJECT_OUTLINE      = (1 << 0),
 +      V3D_SHADING_XRAY                = (1 << 1),
 +      V3D_SHADING_SHADOW              = (1 << 2),
 +      V3D_SHADING_SCENE_LIGHT         = (1 << 3),
 +      V3D_SHADING_SPECULAR_HIGHLIGHT  = (1 << 4),
 +};
 +
 +/* View3DShading->single_color_type */
 +enum {
 +      V3D_SHADING_MATERIAL_COLOR = 0,
 +      V3D_SHADING_RANDOM_COLOR   = 1,
 +      V3D_SHADING_SINGLE_COLOR   = 2,
 +};
 +
 +/* View3DOverlay->flag */
 +enum {
 +      V3D_OVERLAY_FACE_ORIENTATION  = (1 << 0),
 +      V3D_OVERLAY_HIDE_CURSOR       = (1 << 1),
 +      V3D_OVERLAY_BONE_SELECTION    = (1 << 2),
 +      V3D_OVERLAY_LOOK_DEV          = (1 << 3),
 +      V3D_OVERLAY_WIREFRAMES        = (1 << 4),
 +      V3D_OVERLAY_HIDE_TEXT         = (1 << 5),
 +      V3D_OVERLAY_HIDE_MOTION_PATHS = (1 << 6),
 +};
 +
 +/* View3DOverlay->edit_flag */
 +enum {
 +      V3D_OVERLAY_EDIT_VERT_NORMALS = (1 << 0),
 +      V3D_OVERLAY_EDIT_LOOP_NORMALS = (1 << 1),
 +      V3D_OVERLAY_EDIT_FACE_NORMALS = (1 << 2),
 +
 +      V3D_OVERLAY_EDIT_OCCLUDE_WIRE = (1 << 3),
 +
 +      V3D_OVERLAY_EDIT_WEIGHT       = (1 << 4),
 +};
 +
 +/* View3DOverlay->arm_flag */
 +enum {
 +      V3D_OVERLAY_ARM_TRANSP_BONES  = (1 << 0),
 +};
 +
 +/* View3DOverlay->paint_flag */
 +enum {
 +      V3D_OVERLAY_PAINT_WIRE        = (1 << 0),
 +};
 +
  /* View3D->around */
  enum {
        /* center of the bounding box */
  #define V3D_SHOW_Y                            4
  #define V3D_SHOW_Z                            8
  
 -/* View3d->twtype (bits, we can combine them) */
 -#define V3D_MANIP_TRANSLATE           1
 -#define V3D_MANIP_ROTATE              2
 -#define V3D_MANIP_SCALE                       4
 -
 -/* View3d->twmode */
 +/* Scene.orientation_type */
  #define V3D_MANIP_GLOBAL              0
  #define V3D_MANIP_LOCAL                       1
  #define V3D_MANIP_NORMAL              2
  #define V3D_MANIP_VIEW                        3
  #define V3D_MANIP_GIMBAL              4
 -#define V3D_MANIP_CUSTOM              5 /* anything of value 5 or higher is custom */
 +#define V3D_MANIP_CURSOR              5
 +#define V3D_MANIP_CUSTOM              1024
  
 -/* View3d->twflag */
 -   /* USE = user setting, DRAW = based on selection */
 -#define V3D_USE_MANIPULATOR           1
 -#define V3D_DRAW_MANIPULATOR  2
 -/* #define V3D_CALC_MANIPULATOR       4 */ /*UNUSED*/
 -
 -/* BGPic->flag */
 -/* may want to use 1 for select ? */
 +/* View3d->twflag (also) */
  enum {
 -      V3D_BGPIC_EXPANDED      = (1 << 1),
 -      V3D_BGPIC_CAMERACLIP    = (1 << 2),
 -      V3D_BGPIC_DISABLED      = (1 << 3),
 -      V3D_BGPIC_FOREGROUND    = (1 << 4),
 -
 -      /* Camera framing options */
 -      V3D_BGPIC_CAMERA_ASPECT = (1 << 5),  /* don't stretch to fit the camera view  */
 -      V3D_BGPIC_CAMERA_CROP   = (1 << 6),  /* crop out the image */
 -
 -      /* Axis flip options */
 -      V3D_BGPIC_FLIP_X        = (1 << 7),
 -      V3D_BGPIC_FLIP_Y        = (1 << 8),
 +      V3D_MANIPULATOR_DRAW        = (1 << 0),
  };
  
 -#define V3D_BGPIC_EXPANDED (V3D_BGPIC_EXPANDED | V3D_BGPIC_CAMERACLIP)
 -
 -/* BGPic->source */
 -/* may want to use 1 for select ?*/
 -#define V3D_BGPIC_IMAGE               0
 -#define V3D_BGPIC_MOVIE               1
 -
  #define RV3D_CAMZOOM_MIN -30
  #define RV3D_CAMZOOM_MAX 600