[Bf-blender-cvs] [af5d2e38f78] master: Cleanup: Scene: New IDTypeInfo, and remove unused API from BKE.

Bastien Montagne noreply at git.blender.org
Fri Mar 6 11:28:09 CET 2020


Commit: af5d2e38f7825d80e941b1bb91c443a29340b6f1
Author: Bastien Montagne
Date:   Fri Mar 6 11:10:10 2020 +0100
Branches: master
https://developer.blender.org/rBaf5d2e38f7825d80e941b1bb91c443a29340b6f1

Cleanup: Scene: New IDTypeInfo, and remove unused API from BKE.

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

M	source/blender/blenkernel/BKE_idtype.h
M	source/blender/blenkernel/BKE_scene.h
M	source/blender/blenkernel/intern/idtype.c
M	source/blender/blenkernel/intern/lib_id.c
M	source/blender/blenkernel/intern/lib_id_delete.c
M	source/blender/blenkernel/intern/scene.c

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

diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h
index ba0cf04dfc6..84412942e9a 100644
--- a/source/blender/blenkernel/BKE_idtype.h
+++ b/source/blender/blenkernel/BKE_idtype.h
@@ -124,6 +124,7 @@ typedef struct IDTypeInfo {
 /* ********** Declaration of each IDTypeInfo. ********** */
 
 /* Those are defined in the respective BKE files. */
+extern IDTypeInfo IDType_ID_SCE;
 extern IDTypeInfo IDType_ID_OB;
 
 /* ********** Helpers/Utils API. ********** */
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 45de2388ba8..90e5459b599 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -70,9 +70,6 @@ struct Base *_setlooper_base_step(struct Scene **sce_iter,
 
 void free_avicodecdata(struct AviCodecData *acd);
 
-void BKE_scene_free_ex(struct Scene *sce, const bool do_id_user);
-void BKE_scene_free(struct Scene *sce);
-void BKE_scene_init(struct Scene *sce);
 struct Scene *BKE_scene_add(struct Main *bmain, const char *name);
 
 void BKE_scene_remove_rigidbody_object(struct Main *bmain,
@@ -110,15 +107,9 @@ struct Scene *BKE_scene_set_name(struct Main *bmain, const char *name);
 struct ToolSettings *BKE_toolsettings_copy(struct ToolSettings *toolsettings, const int flag);
 void BKE_toolsettings_free(struct ToolSettings *toolsettings);
 
-void BKE_scene_copy_data(struct Main *bmain,
-                         struct Scene *sce_dst,
-                         const struct Scene *sce_src,
-                         const int flag);
 struct Scene *BKE_scene_copy(struct Main *bmain, struct Scene *sce, int type);
 void BKE_scene_groups_relink(struct Scene *sce);
 
-void BKE_scene_make_local(struct Main *bmain, struct Scene *sce, const int flags);
-
 struct Scene *BKE_scene_find_from_collection(const struct Main *bmain,
                                              const struct Collection *collection);
 
diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c
index 494d83535b4..6161e41db4e 100644
--- a/source/blender/blenkernel/intern/idtype.c
+++ b/source/blender/blenkernel/intern/idtype.c
@@ -51,6 +51,7 @@ static void id_type_init(void)
   } \
   (void)0
 
+  INIT_TYPE(ID_SCE);
   INIT_TYPE(ID_OB);
 
 #undef INIT_TYPE
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index 92e9a7c6c79..0a0673b0d46 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -467,9 +467,7 @@ bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const int flags
 
   switch ((ID_Type)GS(id->name)) {
     case ID_SCE:
-      if (!test) {
-        BKE_scene_make_local(bmain, (Scene *)id, flags);
-      }
+      BLI_assert(0);
       return true;
     case ID_OB:
       if (!test) {
@@ -730,7 +728,7 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
 
     switch ((ID_Type)GS(id->name)) {
       case ID_SCE:
-        BKE_scene_copy_data(bmain, (Scene *)*r_newid, (Scene *)id, flag);
+        BLI_assert(0);
         break;
       case ID_OB:
         BKE_object_copy_data(bmain, (Object *)*r_newid, (Object *)id, flag);
@@ -1348,7 +1346,7 @@ void BKE_libblock_init_empty(ID *id)
   /* Note that only ID types that are not valid when filled of zero should have a callback here. */
   switch ((ID_Type)GS(id->name)) {
     case ID_SCE:
-      BKE_scene_init((Scene *)id);
+      BLI_assert(0);
       break;
     case ID_LI:
       /* Nothing to do. */
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index d47510ea9af..e7f5de1d334 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -137,7 +137,7 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
   const short type = GS(id->name);
   switch (type) {
     case ID_SCE:
-      BKE_scene_free_ex((Scene *)id, false);
+      BLI_assert(0);
       break;
     case ID_LI:
       BKE_library_free((Library *)id);
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 740db64e887..a88f5a4daa4 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -71,6 +71,7 @@
 #include "BKE_gpencil.h"
 #include "BKE_icons.h"
 #include "BKE_idprop.h"
+#include "BKE_idtype.h"
 #include "BKE_image.h"
 #include "BKE_layer.h"
 #include "BKE_lib_id.h"
@@ -107,6 +108,393 @@
 
 #include "bmesh.h"
 
+static void scene_init_data(ID *id)
+{
+  Scene *scene = (Scene *)id;
+  const char *colorspace_name;
+  SceneRenderView *srv;
+  CurveMapping *mblur_shutter_curve;
+
+  BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(scene, id));
+
+  MEMCPY_STRUCT_AFTER(scene, DNA_struct_default_get(Scene), id);
+
+  BLI_strncpy(scene->r.bake.filepath, U.renderdir, sizeof(scene->r.bake.filepath));
+
+  mblur_shutter_curve = &scene->r.mblur_shutter_curve;
+  BKE_curvemapping_set_defaults(mblur_shutter_curve, 1, 0.0f, 0.0f, 1.0f, 1.0f);
+  BKE_curvemapping_initialize(mblur_shutter_curve);
+  BKE_curvemap_reset(mblur_shutter_curve->cm,
+                     &mblur_shutter_curve->clipr,
+                     CURVE_PRESET_MAX,
+                     CURVEMAP_SLOPE_POS_NEG);
+
+  scene->toolsettings = DNA_struct_default_alloc(ToolSettings);
+
+  scene->toolsettings->autokey_mode = (uchar)U.autokey_mode;
+
+  /* grease pencil multiframe falloff curve */
+  scene->toolsettings->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+  CurveMapping *gp_falloff_curve = scene->toolsettings->gp_sculpt.cur_falloff;
+  BKE_curvemapping_initialize(gp_falloff_curve);
+  BKE_curvemap_reset(
+      gp_falloff_curve->cm, &gp_falloff_curve->clipr, CURVE_PRESET_GAUSS, CURVEMAP_SLOPE_POSITIVE);
+
+  scene->toolsettings->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+  CurveMapping *gp_primitive_curve = scene->toolsettings->gp_sculpt.cur_primitive;
+  BKE_curvemapping_initialize(gp_primitive_curve);
+  BKE_curvemap_reset(gp_primitive_curve->cm,
+                     &gp_primitive_curve->clipr,
+                     CURVE_PRESET_BELL,
+                     CURVEMAP_SLOPE_POSITIVE);
+
+  scene->unit.system = USER_UNIT_METRIC;
+  scene->unit.scale_length = 1.0f;
+  scene->unit.length_unit = (uchar)bUnit_GetBaseUnitOfType(USER_UNIT_METRIC, B_UNIT_LENGTH);
+  scene->unit.mass_unit = (uchar)bUnit_GetBaseUnitOfType(USER_UNIT_METRIC, B_UNIT_MASS);
+  scene->unit.time_unit = (uchar)bUnit_GetBaseUnitOfType(USER_UNIT_METRIC, B_UNIT_TIME);
+
+  {
+    ParticleEditSettings *pset;
+    pset = &scene->toolsettings->particle;
+    for (size_t i = 1; i < ARRAY_SIZE(pset->brush); i++) {
+      pset->brush[i] = pset->brush[0];
+    }
+    pset->brush[PE_BRUSH_CUT].strength = 1.0f;
+  }
+
+  BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
+
+  BLI_strncpy(scene->r.pic, U.renderdir, sizeof(scene->r.pic));
+
+  /* Note; in header_info.c the scene copy happens...,
+   * if you add more to renderdata it has to be checked there. */
+
+  /* multiview - stereo */
+  BKE_scene_add_render_view(scene, STEREO_LEFT_NAME);
+  srv = scene->r.views.first;
+  BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix));
+
+  BKE_scene_add_render_view(scene, STEREO_RIGHT_NAME);
+  srv = scene->r.views.last;
+  BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
+
+  BKE_sound_reset_scene_runtime(scene);
+
+  /* color management */
+  colorspace_name = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_SEQUENCER);
+
+  BKE_color_managed_display_settings_init(&scene->display_settings);
+  BKE_color_managed_view_settings_init_render(
+      &scene->view_settings, &scene->display_settings, "Filmic");
+  BLI_strncpy(scene->sequencer_colorspace_settings.name,
+              colorspace_name,
+              sizeof(scene->sequencer_colorspace_settings.name));
+
+  /* Those next two sets (render and baking settings) are not currently in use,
+   * but are exposed to RNA API and hence must have valid data. */
+  BKE_color_managed_display_settings_init(&scene->r.im_format.display_settings);
+  BKE_color_managed_view_settings_init_render(
+      &scene->r.im_format.view_settings, &scene->r.im_format.display_settings, "Filmic");
+
+  BKE_color_managed_display_settings_init(&scene->r.bake.im_format.display_settings);
+  BKE_color_managed_view_settings_init_render(
+      &scene->r.bake.im_format.view_settings, &scene->r.bake.im_format.display_settings, "Filmic");
+
+  /* GP Sculpt brushes */
+  {
+    GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
+    GP_Sculpt_Data *gp_brush;
+    float curcolor_add[3], curcolor_sub[3];
+    ARRAY_SET_ITEMS(curcolor_add, 1.0f, 0.6f, 0.6f);
+    ARRAY_SET_ITEMS(curcolor_sub, 0.6f, 0.6f, 1.0f);
+
+    gp_brush = &gset->brush[GP_SCULPT_TYPE_SMOOTH];
+    gp_brush->size = 25;
+    gp_brush->strength = 0.3f;
+    gp_brush->flag = GP_SCULPT_FLAG_USE_FALLOFF | GP_SCULPT_FLAG_SMOOTH_PRESSURE |
+                     GP_SCULPT_FLAG_ENABLE_CURSOR;
+    copy_v3_v3(gp_brush->curcolor_add, curcolor_add);
+    copy_v3_v3(gp_brush->curcolor_sub, curcolor_sub);
+
+    gp_brush = &gset->brush[GP_SCULPT_TYPE_THICKNESS];
+    gp_brush->size = 25;
+    gp_brush->strength = 0.5f;
+    gp_brush->flag = GP_SCULPT_FLAG_USE_FALLOFF | GP_SCULPT_FLAG_ENABLE_CURSOR;
+    copy_v3_v3(gp_brush->curcolor_add, curcolor_add);
+    copy_v3_v3(gp_brush->curcolor_sub, curcolor_sub);
+
+    gp_brush = &gset->brush[GP_SCULPT_TYPE_STRENGTH];
+    gp_brush->size = 25;
+    gp_brush->strength = 0.5f;
+    gp_brush->flag = GP_SCULPT_FLAG_USE_FALLOFF | GP_SCULPT_FLAG_ENABLE_CURSOR;
+    copy_v3_v3(gp_brush->curcolor_add, curcolor_add);
+    copy_v3_v3(gp_brush->curcolor_sub, curcolor_sub);
+
+    gp_brush = &gset->brush[GP_SCULPT_TYPE_GRAB];
+    gp_brush->size = 50;
+    gp_brush->strength = 0.3f;
+    gp_brush->flag = GP_SCULPT_FLAG_USE_FALLOFF | GP_SCULPT_FLAG_ENABLE_CURSOR;
+    copy_v3_v3(gp_brush->curcolor_add, curcolor_add);
+    copy_v3_v3(gp_brush->curcolor_sub, curcolor_sub);
+
+    gp_brush = &gset->bru

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list