Commit: 8fb93aebe76e48747a0bc96ba73386459921d439
Author: Dalai Felinto
Date:   Sun May 27 18:32:38 2018 +0200
Branches: temp-dynamic-overrides
https://developer.blender.org/rB8fb93aebe76e48747a0bc96ba73386459921d439

BKE_idtype_to_main_data

Function to map ID_Type to bmain-> listbases.

===================================================================

M       source/blender/blenkernel/BKE_idcode.h
M       source/blender/blenkernel/intern/idcode.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_idcode.h 
b/source/blender/blenkernel/BKE_idcode.h
index 964a49435f1..8cc05fcfd67 100644
--- a/source/blender/blenkernel/BKE_idcode.h
+++ b/source/blender/blenkernel/BKE_idcode.h
@@ -32,6 +32,11 @@
  *  \ingroup bke
  */
 
+struct ListBase;
+struct Main;
+
+struct ListBase *BKE_idtype_to_main_data(struct Main *bmain, short id_type);
+
 const char *BKE_idcode_to_name(short idcode);
 const char *BKE_idcode_to_name_plural(short idcode);
 const char *BKE_idcode_to_translation_context(short idcode);
diff --git a/source/blender/blenkernel/intern/idcode.c 
b/source/blender/blenkernel/intern/idcode.c
index 4860f5a896d..d3ef21363c0 100644
--- a/source/blender/blenkernel/intern/idcode.c
+++ b/source/blender/blenkernel/intern/idcode.c
@@ -40,6 +40,7 @@
 #include "BLT_translation.h"
 
 #include "BKE_library.h"
+#include "BKE_main.h"
 #include "BKE_idcode.h"
 
 typedef struct {
@@ -124,6 +125,86 @@ static IDType *idtype_from_code(short idcode)
        return NULL;
 }
 
+ListBase *BKE_idtype_to_main_data(Main *bmain, short id_type)
+{
+       switch (id_type)
+       {
+               case ID_SCE:
+                       return &bmain->scene;
+               case ID_LI:
+                       return &bmain->library;
+               case ID_OB:
+                       return &bmain->object;
+               case ID_ME:
+                       return &bmain->mesh;
+               case ID_CU:
+                       return &bmain->curve;
+               case ID_MB:
+                       return &bmain->mball;
+               case ID_MA:
+                       return &bmain->mat;
+               case ID_TE:
+                       return &bmain->tex;
+               case ID_IM:
+                       return &bmain->image;
+               case ID_LT:
+                       return &bmain->latt;
+               case ID_LA:
+                       return &bmain->lamp;
+               case ID_CA:
+                       return &bmain->camera;
+               case ID_IP:
+                       return &bmain->ipo;
+               case ID_KE:
+                       return &bmain->key;
+               case ID_WO:
+                       return &bmain->world;
+               case ID_SCR:
+                       return &bmain->screen;
+               case ID_VF:
+                       return &bmain->vfont;
+               case ID_TXT:
+                       return &bmain->text;
+               case ID_SPK:
+                       return &bmain->speaker;
+               case ID_SO:
+                       return &bmain->sound;
+               case ID_GR:
+                       return &bmain->collection;
+               case ID_AR:
+                       return &bmain->armature;
+               case ID_AC:
+                       return &bmain->action;
+               case ID_NT:
+                       return &bmain->nodetree;
+               case ID_BR:
+                       return &bmain->brush;
+               case ID_PA:
+                       return &bmain->particle;
+               case ID_GD:
+                       return &bmain->gpencil;
+               case ID_WM:
+                       return &bmain->wm;
+               case ID_MC:
+                       return &bmain->movieclip;
+               case ID_MSK:
+                       return &bmain->mask;
+               case ID_LS:
+                       return &bmain->linestyle;
+               case ID_PAL:
+                       return &bmain->palettes;
+               case ID_PC:
+                       return &bmain->paintcurves;
+               case ID_CF:
+                       return &bmain->cachefiles;
+               case ID_WS:
+                       return &bmain->workspaces;
+               case ID_LP:
+                       return &bmain->lightprobe;
+       }
+       return NULL;
+}
+
 /**
  * Return if the ID code is a valid ID code.
  *

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to