Layers: use IDProperty and override collection properties system
First this replace a custom data struct with IDProperty, and use IDProperty group merge and copying functions. Which means that a collection property setting is only created if necessary. This implements the "Layer Collection settings" override system, as suggested in the "Override Manifesto" document. The core is working, with Scene, LayerCollection and Object using a single IDProperty to store all the render settings data. Next step is to migrate this to depsgraph. Note: Clay engine "ssao_samples" was hardcoded to 32 for now. It will come back as part of "Workspace Settings" later. Many thanks for Bastien Montagne for the help with the UI template nightmare ;) Differential Revision: https://developer.blender.org/D2563
This commit is contained in:
@@ -3949,7 +3949,6 @@ static void lib_link_material(FileData *fd, Main *main)
|
||||
static void direct_link_material(FileData *fd, Material *ma)
|
||||
{
|
||||
int a;
|
||||
MaterialEngineSettings *mes;
|
||||
|
||||
ma->adt = newdataadr(fd, ma->adt);
|
||||
direct_link_animdata(fd, ma->adt);
|
||||
@@ -3970,11 +3969,6 @@ static void direct_link_material(FileData *fd, Material *ma)
|
||||
|
||||
ma->preview = direct_link_preview_image(fd, ma->preview);
|
||||
BLI_listbase_clear(&ma->gpumaterial);
|
||||
|
||||
link_list(fd, &ma->engines_settings);
|
||||
for (mes = ma->engines_settings.first; mes; mes = mes->next) {
|
||||
mes->data = newdataadr(fd, mes->data);
|
||||
}
|
||||
}
|
||||
|
||||
/* ************ READ PARTICLE SETTINGS ***************** */
|
||||
@@ -5592,7 +5586,6 @@ static void direct_link_object(FileData *fd, Object *ob)
|
||||
ob->bb = NULL;
|
||||
ob->derivedDeform = NULL;
|
||||
ob->derivedFinal = NULL;
|
||||
BLI_listbase_clear(&ob->collection_settings);
|
||||
BLI_listbase_clear(&ob->gpulamp);
|
||||
link_list(fd, &ob->pc_ids);
|
||||
|
||||
@@ -5610,6 +5603,9 @@ static void direct_link_object(FileData *fd, Object *ob)
|
||||
ob->currentlod = ob->lodlevels.first;
|
||||
|
||||
ob->preview = direct_link_preview_image(fd, ob->preview);
|
||||
|
||||
ob->collection_properties = newdataadr(fd, ob->collection_properties);
|
||||
IDP_DirectLinkGroup_OrFree(&ob->collection_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
|
||||
}
|
||||
|
||||
/* ************ READ SCENE ***************** */
|
||||
@@ -5961,14 +5957,6 @@ static void direct_link_scene_collection(FileData *fd, SceneCollection *sc)
|
||||
}
|
||||
}
|
||||
|
||||
static void direct_link_engine_settings(FileData *fd, ListBase *lb)
|
||||
{
|
||||
link_list(fd, lb);
|
||||
for (CollectionEngineSettings *ces = lb->first; ces; ces = ces->next) {
|
||||
link_list(fd, &ces->properties);
|
||||
}
|
||||
}
|
||||
|
||||
static void direct_link_layer_collections(FileData *fd, ListBase *lb)
|
||||
{
|
||||
link_list(fd, lb);
|
||||
@@ -5983,9 +5971,10 @@ static void direct_link_layer_collections(FileData *fd, ListBase *lb)
|
||||
|
||||
link_list(fd, &lc->overrides);
|
||||
|
||||
direct_link_engine_settings(fd, &lc->engine_settings);
|
||||
|
||||
direct_link_engine_settings(fd, &lc->mode_settings);
|
||||
if (lc->properties) {
|
||||
lc->properties = newdataadr(fd, lc->properties);
|
||||
IDP_DirectLinkGroup_OrFree(&lc->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
|
||||
}
|
||||
|
||||
direct_link_layer_collections(fd, &lc->layer_collections);
|
||||
}
|
||||
@@ -5999,7 +5988,6 @@ static void direct_link_scene(FileData *fd, Scene *sce)
|
||||
RigidBodyWorld *rbw;
|
||||
SceneLayer *sl;
|
||||
SceneRenderLayer *srl;
|
||||
RenderEngineSettings *res;
|
||||
|
||||
sce->theDag = NULL;
|
||||
sce->depsgraph = NULL;
|
||||
@@ -6266,10 +6254,8 @@ static void direct_link_scene(FileData *fd, Scene *sce)
|
||||
BKE_scene_layer_base_flag_recalculate(sl);
|
||||
}
|
||||
|
||||
link_list(fd, &sce->engines_settings);
|
||||
for (res = sce->engines_settings.first; res; res = res->next) {
|
||||
res->data = newdataadr(fd, res->data);
|
||||
}
|
||||
sce->collection_properties = newdataadr(fd, sce->collection_properties);
|
||||
IDP_DirectLinkGroup_OrFree(&sce->collection_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
|
||||
}
|
||||
|
||||
/* ************ READ WM ***************** */
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#include "BKE_blender.h"
|
||||
#include "BKE_collection.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_scene.h"
|
||||
@@ -211,11 +212,6 @@ void do_versions_after_linking_280(Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
static void blo_do_version_temporary(Main *main)
|
||||
{
|
||||
BKE_scene_layer_doversion_update(main);
|
||||
}
|
||||
|
||||
void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
|
||||
{
|
||||
if (!MAIN_VERSION_ATLEAST(main, 280, 0)) {
|
||||
@@ -227,7 +223,19 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
|
||||
}
|
||||
}
|
||||
|
||||
/* temporary validation of 280 files for layers */
|
||||
blo_do_version_temporary(main);
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "Scene", "IDProperty", "collection_properties")) {
|
||||
IDPropertyTemplate val = {0};
|
||||
for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
|
||||
scene->collection_properties = IDP_New(IDP_GROUP, &val, ROOT_PROP);
|
||||
BKE_layer_collection_engine_settings_create(scene->collection_properties);
|
||||
}
|
||||
}
|
||||
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "Object", "IDProperty", "collection_properties")) {
|
||||
IDPropertyTemplate val = {0};
|
||||
for (Object *ob = main->object.first; ob; ob = ob->id.next) {
|
||||
ob->collection_properties = IDP_New(IDP_GROUP, &val, ROOT_PROP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1921,6 +1921,10 @@ static void write_object(WriteData *wd, Object *ob)
|
||||
writelist(wd, DATA, LodLevel, &ob->lodlevels);
|
||||
|
||||
write_previews(wd, ob->preview);
|
||||
|
||||
if (ob->collection_properties) {
|
||||
IDP_WriteProperty(ob->collection_properties, wd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2402,21 +2406,6 @@ static void write_texture(WriteData *wd, Tex *tex)
|
||||
}
|
||||
}
|
||||
|
||||
static void write_material_engines_settings(WriteData *wd, ListBase *lb)
|
||||
{
|
||||
for (MaterialEngineSettings *res = lb->first; res; res = res->next) {
|
||||
writestruct(wd, DATA, MaterialEngineSettings, 1, res);
|
||||
|
||||
if (STREQ(res->name, RE_engine_id_BLENDER_CLAY)) {
|
||||
writestruct(wd, DATA, MaterialEngineSettingsClay, 1, res->data);
|
||||
}
|
||||
else {
|
||||
/* No engine matched */
|
||||
/* error: don't know how to write this file */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write_material(WriteData *wd, Material *ma)
|
||||
{
|
||||
if (ma->id.us > 0 || wd->current) {
|
||||
@@ -2448,8 +2437,6 @@ static void write_material(WriteData *wd, Material *ma)
|
||||
}
|
||||
|
||||
write_previews(wd, ma->preview);
|
||||
|
||||
write_material_engines_settings(wd, &ma->engines_settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2565,29 +2552,6 @@ static void write_scene_collection(WriteData *wd, SceneCollection *sc)
|
||||
}
|
||||
}
|
||||
|
||||
static void write_collection_engine_settings(WriteData *wd, ListBase *lb)
|
||||
{
|
||||
for (CollectionEngineSettings *ces = lb->first; ces; ces = ces->next) {
|
||||
writestruct(wd, DATA, CollectionEngineSettings, 1, ces);
|
||||
|
||||
for (CollectionEngineProperty *prop = ces->properties.first; prop; prop = prop->next) {
|
||||
switch (prop->type) {
|
||||
case COLLECTION_PROP_TYPE_FLOAT:
|
||||
writestruct(wd, DATA, CollectionEnginePropertyFloat, 1, prop);
|
||||
break;
|
||||
case COLLECTION_PROP_TYPE_INT:
|
||||
writestruct(wd, DATA, CollectionEnginePropertyInt, 1, prop);
|
||||
break;
|
||||
case COLLECTION_PROP_TYPE_BOOL:
|
||||
writestruct(wd, DATA, CollectionEnginePropertyBool, 1, prop);
|
||||
break;
|
||||
default:
|
||||
; /* error: don't know how to write this file */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write_layer_collections(WriteData *wd, ListBase *lb)
|
||||
{
|
||||
for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
|
||||
@@ -2596,29 +2560,14 @@ static void write_layer_collections(WriteData *wd, ListBase *lb)
|
||||
writelist(wd, DATA, LinkData, &lc->object_bases);
|
||||
writelist(wd, DATA, CollectionOverride, &lc->overrides);
|
||||
|
||||
write_collection_engine_settings(wd, &lc->engine_settings);
|
||||
|
||||
write_collection_engine_settings(wd, &lc->mode_settings);
|
||||
if (lc->properties) {
|
||||
IDP_WriteProperty(lc->properties, wd);
|
||||
}
|
||||
|
||||
write_layer_collections(wd, &lc->layer_collections);
|
||||
}
|
||||
}
|
||||
|
||||
static void write_render_engines_settings(WriteData *wd, ListBase *lb)
|
||||
{
|
||||
for (RenderEngineSettings *res = lb->first; res; res = res->next) {
|
||||
writestruct(wd, DATA, RenderEngineSettings, 1, res);
|
||||
|
||||
if (STREQ(res->name, RE_engine_id_BLENDER_CLAY)) {
|
||||
writestruct(wd, DATA, RenderEngineSettingsClay, 1, res->data);
|
||||
}
|
||||
else {
|
||||
/* No engine matched */
|
||||
/* error: don't know how to write this file */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write_scene(WriteData *wd, Scene *sce)
|
||||
{
|
||||
/* write LibData */
|
||||
@@ -2830,7 +2779,9 @@ static void write_scene(WriteData *wd, Scene *sce)
|
||||
write_layer_collections(wd, &sl->layer_collections);
|
||||
}
|
||||
|
||||
write_render_engines_settings(wd, &sce->engines_settings);
|
||||
if (sce->collection_properties) {
|
||||
IDP_WriteProperty(sce->collection_properties, wd);
|
||||
}
|
||||
}
|
||||
|
||||
static void write_gpencil(WriteData *wd, bGPdata *gpd)
|
||||
|
||||
Reference in New Issue
Block a user