Revert to master - those changes are globally valid, but remain incomplete,
[blender.git] / source / blender / makesrna / intern / rna_main_api.c
index 5fedc233ff90cf35bef0d1a70604ec3004f0e291..5a0da0b76517fa9c2ac9f010d1c27c908703fabb 100644 (file)
@@ -35,6 +35,8 @@
 
 #include "DNA_ID.h"
 #include "DNA_modifier_types.h"
+#include "DNA_space_types.h"
+#include "DNA_object_types.h"
 
 #include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 #include "BKE_library.h"
 #include "BKE_object.h"
 #include "BKE_material.h"
+#include "BKE_icons.h"
 #include "BKE_image.h"
 #include "BKE_texture.h"
 #include "BKE_scene.h"
+#include "BKE_sound.h"
 #include "BKE_text.h"
 #include "BKE_action.h"
 #include "BKE_group.h"
@@ -69,6 +73,7 @@
 #include "BKE_mball.h"
 #include "BKE_world.h"
 #include "BKE_particle.h"
+#include "BKE_paint.h"
 #include "BKE_font.h"
 #include "BKE_node.h"
 #include "BKE_depsgraph.h"
@@ -84,8 +89,8 @@
 #include "DNA_lamp_types.h"
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
-#include "DNA_object_types.h"
 #include "DNA_speaker_types.h"
+#include "DNA_sound_types.h"
 #include "DNA_text_types.h"
 #include "DNA_texture_types.h"
 #include "DNA_group_types.h"
 
 #include "ED_screen.h"
 
-#include "BLF_translation.h"
+#include "BLT_translation.h"
 
 #ifdef WITH_PYTHON
 #  include "BPY_extern.h"
@@ -292,216 +297,19 @@ Mesh *rna_Main_meshes_new_from_object(
         Main *bmain, ReportList *reports, Scene *sce,
         Object *ob, int apply_modifiers, int settings, int calc_tessface, int calc_undeformed)
 {
-       Mesh *tmpmesh;
-       Curve *tmpcu = NULL, *copycu;
-       Object *tmpobj = NULL;
-       const bool use_render_resolution = (settings == eModifierMode_Render);
-       int i;
-       int cage = !apply_modifiers;
-
-       /* perform the mesh extraction based on type */
        switch (ob->type) {
                case OB_FONT:
                case OB_CURVE:
                case OB_SURF:
-               {
-                       ListBase dispbase = {NULL, NULL};
-                       DerivedMesh *derivedFinal = NULL;
-                       int uv_from_orco;
-
-                       /* copies object and modifiers (but not the data) */
-                       tmpobj = BKE_object_copy_ex(bmain, ob, TRUE);
-                       tmpcu = (Curve *)tmpobj->data;
-                       tmpcu->id.us--;
-
-                       /* if getting the original caged mesh, delete object modifiers */
-                       if (cage)
-                               BKE_object_free_modifiers(tmpobj);
-
-                       /* copies the data */
-                       copycu = tmpobj->data = BKE_curve_copy((Curve *) ob->data);
-
-                       /* temporarily set edit so we get updates from edit mode, but
-                        * also because for text datablocks copying it while in edit
-                        * mode gives invalid data structures */
-                       copycu->editfont = tmpcu->editfont;
-                       copycu->editnurb = tmpcu->editnurb;
-
-                       /* get updated display list, and convert to a mesh */
-                       BKE_displist_make_curveTypes_forRender(sce, tmpobj, &dispbase, &derivedFinal, false, use_render_resolution);
-
-                       copycu->editfont = NULL;
-                       copycu->editnurb = NULL;
-
-                       tmpobj->derivedFinal = derivedFinal;
-
-                       /* convert object type to mesh */
-                       uv_from_orco = (tmpcu->flag & CU_UV_ORCO) != 0;
-                       BKE_mesh_from_nurbs_displist(tmpobj, &dispbase, uv_from_orco);
-
-                       tmpmesh = tmpobj->data;
-
-                       BKE_displist_free(&dispbase);
-
-                       /* BKE_mesh_from_nurbs changes the type to a mesh, check it worked.
-                        * if it didn't the curve did not have any segments or otherwise 
-                        * would have generated an empty mesh */
-                       if (tmpobj->type != OB_MESH) {
-                               BKE_libblock_free_us(G.main, tmpobj);
-                               return NULL;
-                       }
-
-                       BKE_mesh_texspace_copy_from_object(tmpmesh, ob);
-
-                       BKE_libblock_free_us(bmain, tmpobj);
-                       break;
-               }
-
                case OB_MBALL:
-               {
-                       /* metaballs don't have modifiers, so just convert to mesh */
-                       Object *basis_ob = BKE_mball_basis_find(sce, ob);
-                       /* todo, re-generatre for render-res */
-                       /* metaball_polygonize(scene, ob) */
-
-                       if (ob != basis_ob)
-                               return NULL;  /* only do basis metaball */
-
-                       tmpmesh = BKE_mesh_add(bmain, "Mesh");
-                       /* BKE_mesh_add gives us a user count we don't need */
-                       tmpmesh->id.us--;
-
-                       if (use_render_resolution) {
-                               ListBase disp = {NULL, NULL};
-                               /* TODO(sergey): This is gonna to work for until EvaluationContext
-                                *               only contains for_render flag. As soon as CoW is
-                                *               implemented, this is to be rethinked.
-                                */
-                               EvaluationContext eval_ctx = {0};
-                               eval_ctx.for_render = use_render_resolution;
-                               BKE_displist_make_mball_forRender(&eval_ctx, sce, ob, &disp);
-                               BKE_mesh_from_metaball(&disp, tmpmesh);
-                               BKE_displist_free(&disp);
-                       }
-                       else {
-                               ListBase disp = {NULL, NULL};
-                               if (ob->curve_cache) {
-                                       disp = ob->curve_cache->disp;
-                               }
-                               BKE_mesh_from_metaball(&disp, tmpmesh);
-                       }
-
-                       BKE_mesh_texspace_copy_from_object(tmpmesh, ob);
-
-                       break;
-
-               }
                case OB_MESH:
-                       /* copies object and modifiers (but not the data) */
-                       if (cage) {
-                               /* copies the data */
-                               tmpmesh = BKE_mesh_copy_ex(bmain, ob->data);
-                               /* if not getting the original caged mesh, get final derived mesh */
-                       }
-                       else {
-                               /* Make a dummy mesh, saves copying */
-                               DerivedMesh *dm;
-                               /* CustomDataMask mask = CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL; */
-                               CustomDataMask mask = CD_MASK_MESH; /* this seems more suitable, exporter,
-                                                                * for example, needs CD_MASK_MDEFORMVERT */
-
-                               if (calc_undeformed)
-                                       mask |= CD_MASK_ORCO;
-
-                               /* Write the display mesh into the dummy mesh */
-                               if (use_render_resolution)
-                                       dm = mesh_create_derived_render(sce, ob, mask);
-                               else
-                                       dm = mesh_create_derived_view(sce, ob, mask);
-
-                               tmpmesh = BKE_mesh_add(bmain, "Mesh");
-                               DM_to_mesh(dm, tmpmesh, ob, mask);
-                               dm->release(dm);
-                       }
-
-                       /* BKE_mesh_add/copy gives us a user count we don't need */
-                       tmpmesh->id.us--;
-
                        break;
                default:
                        BKE_report(reports, RPT_ERROR, "Object does not have geometry data");
                        return NULL;
        }
 
-       /* Copy materials to new mesh */
-       switch (ob->type) {
-               case OB_SURF:
-               case OB_FONT:
-               case OB_CURVE:
-                       tmpmesh->totcol = tmpcu->totcol;
-
-                       /* free old material list (if it exists) and adjust user counts */
-                       if (tmpcu->mat) {
-                               for (i = tmpcu->totcol; i-- > 0; ) {
-                                       /* are we an object material or data based? */
-
-                                       tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : tmpcu->mat[i];
-
-                                       if (tmpmesh->mat[i]) {
-                                               tmpmesh->mat[i]->id.us++;
-                                       }
-                               }
-                       }
-                       break;
-
-#if 0
-               /* Crashes when assigning the new material, not sure why */
-               case OB_MBALL:
-                       tmpmb = (MetaBall *)ob->data;
-                       tmpmesh->totcol = tmpmb->totcol;
-
-                       /* free old material list (if it exists) and adjust user counts */
-                       if (tmpmb->mat) {
-                               for (i = tmpmb->totcol; i-- > 0; ) {
-                                       tmpmesh->mat[i] = tmpmb->mat[i]; /* CRASH HERE ??? */
-                                       if (tmpmesh->mat[i]) {
-                                               tmpmb->mat[i]->id.us++;
-                                       }
-                               }
-                       }
-                       break;
-#endif
-
-               case OB_MESH:
-                       if (!cage) {
-                               Mesh *origmesh = ob->data;
-                               tmpmesh->flag = origmesh->flag;
-                               tmpmesh->mat = MEM_dupallocN(origmesh->mat);
-                               tmpmesh->totcol = origmesh->totcol;
-                               tmpmesh->smoothresh = origmesh->smoothresh;
-                               if (origmesh->mat) {
-                                       for (i = origmesh->totcol; i-- > 0; ) {
-                                               /* are we an object material or data based? */
-                                               tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : origmesh->mat[i];
-
-                                               if (tmpmesh->mat[i]) {
-                                                       tmpmesh->mat[i]->id.us++;
-                                               }
-                                       }
-                               }
-                       }
-                       break;
-       } /* end copy materials */
-
-       if (calc_tessface) {
-               /* cycles and exporters rely on this still */
-               BKE_mesh_tessface_ensure(tmpmesh);
-       }
-
-       /* make sure materials get updated in objects */
-       test_object_materials(bmain, &tmpmesh->id);
-
-       return tmpmesh;
+       return BKE_mesh_new_from_object(bmain, sce, ob, apply_modifiers, settings, calc_tessface, calc_undeformed);
 }
 
 static void rna_Main_meshes_remove(Main *bmain, ReportList *reports, PointerRNA *mesh_ptr)
@@ -537,19 +345,24 @@ static void rna_Main_lamps_remove(Main *bmain, ReportList *reports, PointerRNA *
        }
 }
 
-static Image *rna_Main_images_new(Main *bmain, const char *name, int width, int height, int alpha, int float_buffer)
+static Image *rna_Main_images_new(Main *bmain, const char *name, int width, int height, int alpha, int float_buffer, int stereo3d)
 {
        float color[4] = {0.0, 0.0, 0.0, 1.0};
-       Image *image = BKE_image_add_generated(bmain, width, height, name, alpha ? 32 : 24, float_buffer, 0, color);
+       Image *image = BKE_image_add_generated(bmain, width, height, name, alpha ? 32 : 24, float_buffer, 0, color, stereo3d);
        id_us_min(&image->id);
        return image;
 }
-static Image *rna_Main_images_load(Main *bmain, ReportList *reports, const char *filepath)
+static Image *rna_Main_images_load(Main *bmain, ReportList *reports, const char *filepath, int check_existing)
 {
        Image *ima;
 
        errno = 0;
-       ima = BKE_image_load(bmain, filepath);
+       if (check_existing) {
+               ima = BKE_image_load_exists(filepath);
+       }
+       else {
+               ima = BKE_image_load(bmain, filepath);
+       }
 
        if (!ima) {
                BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath,
@@ -628,12 +441,17 @@ static void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, PointerR
        }
 }
 
-static VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepath)
+static VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepath, int check_existing)
 {
        VFont *font;
-
        errno = 0;
-       font = BKE_vfont_load(bmain, filepath);
+
+       if (check_existing) {
+               font = BKE_vfont_load_exists(bmain, filepath);
+       }
+       else {
+               font = BKE_vfont_load(bmain, filepath);
+       }
 
        if (!font)
                BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath,
@@ -657,8 +475,8 @@ static void rna_Main_fonts_remove(Main *bmain, ReportList *reports, PointerRNA *
 
 static Tex *rna_Main_textures_new(Main *bmain, const char *name, int type)
 {
-       Tex *tex = add_texture(bmain, name);
-       tex_set_type(tex, type);
+       Tex *tex = BKE_texture_add(bmain, name);
+       BKE_texture_type_set(tex, type);
        id_us_min(&tex->id);
        return tex;
 }
@@ -675,12 +493,13 @@ static void rna_Main_textures_remove(Main *bmain, ReportList *reports, PointerRN
        }
 }
 
-static Brush *rna_Main_brushes_new(Main *bmain, const char *name)
+static Brush *rna_Main_brushes_new(Main *bmain, const char *name, int mode)
 {
-       Brush *brush = BKE_brush_add(bmain, name);
+       Brush *brush = BKE_brush_add(bmain, name, mode);
        id_us_min(&brush->id);
        return brush;
 }
+
 static void rna_Main_brushes_remove(Main *bmain, ReportList *reports, PointerRNA *brush_ptr)
 {
        Brush *brush = brush_ptr->data;
@@ -744,6 +563,33 @@ static void rna_Main_speakers_remove(Main *bmain, ReportList *reports, PointerRN
        }
 }
 
+static bSound *rna_Main_sounds_load(Main *bmain, const char *name, int check_existing)
+{
+       bSound *sound;
+
+       if (check_existing) {
+               sound = BKE_sound_new_file_exists(bmain, name);
+       }
+       else {
+               sound = BKE_sound_new_file(bmain, name);
+       }
+
+       id_us_min(&sound->id);
+       return sound;
+}
+static void rna_Main_sounds_remove(Main *bmain, ReportList *reports, PointerRNA *sound_ptr)
+{
+       Speaker *sound = sound_ptr->data;
+       if (ID_REAL_USERS(sound) <= 0) {
+               BKE_libblock_free(bmain, sound);
+               RNA_POINTER_INVALIDATE(sound_ptr);
+       }
+       else {
+               BKE_reportf(reports, RPT_ERROR, "Sound '%s' must have zero users to be removed, found %d",
+                           sound->id.name + 2, ID_REAL_USERS(sound));
+       }
+}
+
 static Text *rna_Main_texts_new(Main *bmain, const char *name)
 {
        return BKE_text_add(bmain, name);
@@ -828,12 +674,37 @@ static void rna_Main_particles_remove(Main *bmain, ReportList *reports, PointerR
        }
 }
 
-static MovieClip *rna_Main_movieclip_load(Main *bmain, ReportList *reports, const char *filepath)
+static Palette *rna_Main_palettes_new(Main *bmain, const char *name)
+{
+       Palette *palette = BKE_palette_add(bmain, name);
+       id_us_min(&palette->id);
+       return (Palette *)palette;
+}
+static void rna_Main_palettes_remove(Main *bmain, ReportList *reports, PointerRNA *palette_ptr)
+{
+       Palette *palette = palette_ptr->data;
+       if (ID_REAL_USERS(palette) <= 0) {
+               BKE_libblock_free(bmain, palette);
+               RNA_POINTER_INVALIDATE(palette_ptr);
+       }
+       else {
+               BKE_reportf(reports, RPT_ERROR, "Palette settings '%s' must have zero users to be removed, found %d",
+                           palette->id.name + 2, ID_REAL_USERS(palette));
+       }
+}
+
+static MovieClip *rna_Main_movieclip_load(Main *bmain, ReportList *reports, const char *filepath, int check_existing)
 {
        MovieClip *clip;
 
        errno = 0;
-       clip = BKE_movieclip_file_add(bmain, filepath);
+
+       if (check_existing) {
+               clip = BKE_movieclip_file_add_exists(bmain, filepath);
+       }
+       else {
+               clip = BKE_movieclip_file_add(bmain, filepath);
+       }
 
        if (!clip)
                BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath,
@@ -880,14 +751,14 @@ static void rna_Main_grease_pencil_remove(Main *bmain, ReportList *reports, Poin
                            gpd->id.name + 2, ID_REAL_USERS(gpd));
 }
 
-FreestyleLineStyle *rna_Main_linestyles_new(Main *bmain, const char *name)
+static FreestyleLineStyle *rna_Main_linestyles_new(Main *bmain, const char *name)
 {
-       FreestyleLineStyle *linestyle = BKE_new_linestyle(name, bmain);
+       FreestyleLineStyle *linestyle = BKE_linestyle_new(bmain, name);
        id_us_min(&linestyle->id);
        return linestyle;
 }
 
-void rna_Main_linestyles_remove(Main *bmain, ReportList *reports, FreestyleLineStyle *linestyle)
+static void rna_Main_linestyles_remove(Main *bmain, ReportList *reports, FreestyleLineStyle *linestyle)
 {
        if (ID_REAL_USERS(linestyle) <= 0)
                BKE_libblock_free(bmain, linestyle);
@@ -926,45 +797,49 @@ static void rna_Main_sounds_tag(Main *bmain, int value) { BKE_main_id_tag_listba
 static void rna_Main_armatures_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->armature, value); }
 static void rna_Main_actions_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->action, value); }
 static void rna_Main_particles_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->particle, value); }
+static void rna_Main_palettes_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->palettes, value); }
 static void rna_Main_gpencil_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->gpencil, value); }
 static void rna_Main_movieclips_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->movieclip, value); }
 static void rna_Main_masks_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->mask, value); }
 static void rna_Main_linestyle_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->linestyle, value); }
 
-static int rna_Main_cameras_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CA); }
-static int rna_Main_scenes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SCE); }
-static int rna_Main_objects_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_OB); }
-static int rna_Main_materials_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_MA); }
-static int rna_Main_node_groups_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_NT); }
-static int rna_Main_meshes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_ME); }
-static int rna_Main_lamps_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LA); }
-static int rna_Main_libraries_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LI); }
-static int rna_Main_screens_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SCR); }
-static int rna_Main_window_managers_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_WM); }
-static int rna_Main_images_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_IM); }
-static int rna_Main_lattices_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LT); }
-static int rna_Main_curves_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CU); }
-static int rna_Main_metaballs_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_MB); }
-static int rna_Main_fonts_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_VF); }
-static int rna_Main_textures_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_TE); }
-static int rna_Main_brushes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_BR); }
-static int rna_Main_worlds_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_WO); }
-static int rna_Main_groups_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_GR); }
-static int rna_Main_texts_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_TXT); }
-static int rna_Main_speakers_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SPK); }
-static int rna_Main_sounds_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SO); }
-static int rna_Main_armatures_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_AR); }
-static int rna_Main_actions_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_AC); }
-static int rna_Main_particles_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_PA); }
-static int rna_Main_gpencil_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_GD); }
+static int rna_Main_cameras_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CA) != 0; }
+static int rna_Main_scenes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SCE) != 0; }
+static int rna_Main_objects_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_OB) != 0; }
+static int rna_Main_materials_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_MA) != 0; }
+static int rna_Main_node_groups_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_NT) != 0; }
+static int rna_Main_meshes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_ME) != 0; }
+static int rna_Main_lamps_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LA) != 0; }
+static int rna_Main_libraries_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LI) != 0; }
+static int rna_Main_screens_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SCR) != 0; }
+static int rna_Main_window_managers_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_WM) != 0; }
+static int rna_Main_images_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_IM) != 0; }
+static int rna_Main_lattices_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LT) != 0; }
+static int rna_Main_curves_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CU) != 0; }
+static int rna_Main_metaballs_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_MB) != 0; }
+static int rna_Main_fonts_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_VF) != 0; }
+static int rna_Main_textures_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_TE) != 0; }
+static int rna_Main_brushes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_BR) != 0; }
+static int rna_Main_worlds_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_WO) != 0; }
+static int rna_Main_groups_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_GR) != 0; }
+static int rna_Main_texts_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_TXT) != 0; }
+static int rna_Main_speakers_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SPK) != 0; }
+static int rna_Main_sounds_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SO) != 0; }
+static int rna_Main_armatures_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_AR) != 0; }
+static int rna_Main_actions_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_AC) != 0; }
+static int rna_Main_particles_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_PA) != 0; }
+static int rna_Main_palettes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_PAL) != 0; }
+static int rna_Main_gpencil_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_GD) != 0; }
+static int rna_Main_linestyle_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LS) != 0; }
 
 #else
 
-void RNA_api_main(StructRNA *srna)
+void RNA_api_main(StructRNA *UNUSED(srna))
 {
 #if 0
        FunctionRNA *func;
        PropertyRNA *parm;
+
        /* maybe we want to add functions in 'bpy.data' still?
         * for now they are all in collections bpy.data.images.new(...) */
        func = RNA_def_function(srna, "add_image", "rna_Main_add_image");
@@ -973,8 +848,6 @@ void RNA_api_main(StructRNA *srna)
        RNA_def_property_flag(parm, PROP_REQUIRED);
        parm = RNA_def_pointer(func, "image", "Image", "", "New image");
        RNA_def_function_return(func, parm);
-#else
-       (void)srna;
 #endif
 }
 
@@ -1348,6 +1221,7 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
        RNA_def_property_flag(parm, PROP_REQUIRED);
        RNA_def_boolean(func, "alpha", 0, "Alpha", "Use alpha channel");
        RNA_def_boolean(func, "float_buffer", 0, "Float Buffer", "Create an image with floating point color");
+       RNA_def_boolean(func, "stereo3d", 0, "Stereo 3D", "Create left and right views");
        /* return type */
        parm = RNA_def_pointer(func, "image", "Image", "", "New image datablock");
        RNA_def_function_return(func, parm);
@@ -1357,6 +1231,7 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
        RNA_def_function_ui_description(func, "Load a new image into the main database");
        parm = RNA_def_string_file_path(func, "filepath", "File Path", 0, "", "path of the file to load");
        RNA_def_property_flag(parm, PROP_REQUIRED);
+       RNA_def_boolean(func, "check_existing", false, "", "Using existing data-block if this file is already loaded");
        /* return type */
        parm = RNA_def_pointer(func, "image", "Image", "", "New image datablock");
        RNA_def_function_return(func, parm);
@@ -1501,6 +1376,7 @@ void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop)
        RNA_def_function_ui_description(func, "Load a new font into the main database");
        parm = RNA_def_string_file_path(func, "filepath", "File Path", 0, "", "path of the font to load");
        RNA_def_property_flag(parm, PROP_REQUIRED);
+       RNA_def_boolean(func, "check_existing", false, "", "Using existing data-block if this file is already loaded");
        /* return type */
        parm = RNA_def_pointer(func, "vfont", "VectorFont", "", "New font datablock");
        RNA_def_function_return(func, parm);
@@ -1573,6 +1449,7 @@ void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop)
        RNA_def_function_ui_description(func, "Add a new brush to the main database");
        parm = RNA_def_string(func, "name", "Brush", 0, "", "New name for the datablock");
        RNA_def_property_flag(parm, PROP_REQUIRED);
+       parm = RNA_def_enum(func, "mode", object_mode_items, OB_MODE_TEXTURE_PAINT, "", "Paint Mode for the new brush");
        /* return type */
        parm = RNA_def_pointer(func, "brush", "Brush", "", "New brush datablock");
        RNA_def_function_return(func, parm);
@@ -1758,7 +1635,22 @@ void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop)
        RNA_def_struct_sdna(srna, "Main");
        RNA_def_struct_ui_text(srna, "Main Sounds", "Collection of sounds");
 
-       /* TODO, 'load' */
+       /* load func */
+       func = RNA_def_function(srna, "load", "rna_Main_sounds_load");
+       RNA_def_function_ui_description(func, "Add a new sound to the main database from a file");
+       parm = RNA_def_string_file_path(func, "filepath", "Path", FILE_MAX, "", "path for the datablock");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       RNA_def_boolean(func, "check_existing", false, "", "Using existing data-block if this file is already loaded");
+       /* return type */
+       parm = RNA_def_pointer(func, "sound", "Sound", "", "New text datablock");
+       RNA_def_function_return(func, parm);
+
+       func = RNA_def_function(srna, "remove", "rna_Main_sounds_remove");
+       RNA_def_function_flag(func, FUNC_USE_REPORTS);
+       RNA_def_function_ui_description(func, "Remove a sound from the current blendfile");
+       parm = RNA_def_pointer(func, "sound", "Sound", "", "Sound to remove");
+       RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+       RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
 
        func = RNA_def_function(srna, "tag", "rna_Main_sounds_tag");
        parm = RNA_def_boolean(func, "value", 0, "Value", "");
@@ -1874,7 +1766,41 @@ void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop)
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_boolean_funcs(prop, "rna_Main_particles_is_updated_get", NULL);
 }
+void RNA_def_main_palettes(BlenderRNA *brna, PropertyRNA *cprop)
+{
+       StructRNA *srna;
+       FunctionRNA *func;
+       PropertyRNA *parm;
+       PropertyRNA *prop;
+
+       RNA_def_property_srna(cprop, "BlendDataPalettes");
+       srna = RNA_def_struct(brna, "BlendDataPalettes", NULL);
+       RNA_def_struct_sdna(srna, "Main");
+       RNA_def_struct_ui_text(srna, "Main Palettes", "Collection of palettes");
 
+       func = RNA_def_function(srna, "new", "rna_Main_palettes_new");
+       RNA_def_function_ui_description(func, "Add a new palette to the main database");
+       parm = RNA_def_string(func, "name", "Palette", 0, "", "New name for the datablock");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       /* return type */
+       parm = RNA_def_pointer(func, "palette", "Palette", "", "New palette datablock");
+       RNA_def_function_return(func, parm);
+
+       func = RNA_def_function(srna, "remove", "rna_Main_palettes_remove");
+       RNA_def_function_flag(func, FUNC_USE_REPORTS);
+       RNA_def_function_ui_description(func, "Remove a palette from the current blendfile");
+       parm = RNA_def_pointer(func, "palette", "Palette", "", "Palette to remove");
+       RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+       RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
+
+       func = RNA_def_function(srna, "tag", "rna_Main_palettes_tag");
+       parm = RNA_def_boolean(func, "value", 0, "Value", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+
+       prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_boolean_funcs(prop, "rna_Main_palettes_is_updated_get", NULL);
+}
 void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop)
 {
        StructRNA *srna;
@@ -1938,6 +1864,7 @@ void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop)
        RNA_def_function_ui_description(func, "Add a new movie clip to the main database from a file");
        parm = RNA_def_string_file_path(func, "filepath", "Path", FILE_MAX, "", "path for the datablock");
        RNA_def_property_flag(parm, PROP_REQUIRED);
+       RNA_def_boolean(func, "check_existing", false, "", "Using existing data-block if this file is already loaded");
        /* return type */
        parm = RNA_def_pointer(func, "clip", "MovieClip", "", "New movie clip datablock");
        RNA_def_function_return(func, parm);
@@ -1979,6 +1906,7 @@ void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop)
        StructRNA *srna;
        FunctionRNA *func;
        PropertyRNA *parm;
+       PropertyRNA *prop;
 
        RNA_def_property_srna(cprop, "BlendDataLineStyles");
        srna = RNA_def_struct(brna, "BlendDataLineStyles", NULL);
@@ -2002,6 +1930,10 @@ void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop)
        RNA_def_function_ui_description(func, "Remove a line style instance from the current blendfile");
        parm = RNA_def_pointer(func, "linestyle", "FreestyleLineStyle", "", "Line style to remove");
        RNA_def_property_flag(parm, PROP_REQUIRED);
+
+       prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_boolean_funcs(prop, "rna_Main_linestyle_is_updated_get", NULL);
 }
 
 #endif