Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/BLO_readfile.h2
-rw-r--r--source/blender/blenloader/BLO_runtime.h53
-rw-r--r--source/blender/blenloader/BLO_writefile.h2
-rw-r--r--source/blender/blenloader/CMakeLists.txt2
-rw-r--r--source/blender/blenloader/intern/blend_validate.c2
-rw-r--r--source/blender/blenloader/intern/readfile.c316
-rw-r--r--source/blender/blenloader/intern/runtime.c141
-rw-r--r--source/blender/blenloader/intern/versioning_250.c18
-rw-r--r--source/blender/blenloader/intern/versioning_260.c4
-rw-r--r--source/blender/blenloader/intern/versioning_270.c85
-rw-r--r--source/blender/blenloader/intern/versioning_280.c286
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c67
-rw-r--r--source/blender/blenloader/intern/writefile.c127
13 files changed, 729 insertions, 376 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 1251424719a..9040405e537 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -143,8 +143,6 @@ void BLO_library_link_copypaste(struct Main *mainl, BlendHandle *bh);
void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
-BlendFileData *blo_read_blendafterruntime(int file, const char *name, int actualsize, struct ReportList *reports);
-
/* internal function but we need to expose it */
void blo_lib_link_restore(
struct Main *newmain, struct wmWindowManager *curwm,
diff --git a/source/blender/blenloader/BLO_runtime.h b/source/blender/blenloader/BLO_runtime.h
deleted file mode 100644
index 09f25bdca53..00000000000
--- a/source/blender/blenloader/BLO_runtime.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- *
- */
-
-#ifndef __BLO_RUNTIME_H__
-#define __BLO_RUNTIME_H__
-
-/** \file BLO_runtime.h
- * \ingroup blenloader
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct BlendFileData;
-struct Main;
-struct ReportList;
-
-int BLO_is_a_runtime(const char *file);
-struct BlendFileData *BLO_read_runtime(const char *file, struct ReportList *reports);
-
-bool BLO_main_validate_libraries(struct Main *bmain, struct ReportList *reports);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __BLO_RUNTIME_H__ */
diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h
index f6d0be6f5f0..d615514f081 100644
--- a/source/blender/blenloader/BLO_writefile.h
+++ b/source/blender/blenloader/BLO_writefile.h
@@ -44,4 +44,6 @@ extern bool BLO_write_file(
extern bool BLO_write_file_mem(
struct Main *mainvar, struct MemFile *compare, struct MemFile *current, int write_flags);
+bool BLO_main_validate_libraries(struct Main *bmain, struct ReportList *reports);
+
#endif
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index 72fa155553d..f2b7f35d353 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -52,7 +52,6 @@ set(SRC
intern/blend_validate.c
intern/readblenentry.c
intern/readfile.c
- intern/runtime.c
intern/undofile.c
intern/versioning_250.c
intern/versioning_260.c
@@ -64,7 +63,6 @@ set(SRC
BLO_blend_defs.h
BLO_readfile.h
- BLO_runtime.h
BLO_undofile.h
BLO_writefile.h
intern/readfile.h
diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c
index 4fb5d0e1286..1bc503719b4 100644
--- a/source/blender/blenloader/intern/blend_validate.c
+++ b/source/blender/blenloader/intern/blend_validate.c
@@ -47,7 +47,7 @@
#include "BKE_report.h"
#include "BLO_readfile.h"
-#include "BLO_runtime.h"
+#include "BLO_writefile.h"
#include "readfile.h"
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 96154e8f55a..9655d69ca4a 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -72,7 +72,9 @@
#include "DNA_genfile.h"
#include "DNA_group_types.h"
#include "DNA_gpencil_types.h"
+#include "DNA_gpencil_modifier_types.h"
#include "DNA_hair_types.h"
+#include "DNA_shader_fx_types.h"
#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
#include "DNA_lattice_types.h"
@@ -131,6 +133,8 @@
#include "BKE_effect.h"
#include "BKE_fcurve.h"
#include "BKE_global.h" // for G
+#include "BKE_gpencil.h"
+#include "BKE_gpencil_modifier.h"
#include "BKE_layer.h"
#include "BKE_library.h" // for which_libbase
#include "BKE_library_idmap.h"
@@ -154,6 +158,7 @@
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_sequencer.h"
+#include "BKE_shader_fx.h"
#include "BKE_outliner_treehash.h"
#include "BKE_sound.h"
#include "BKE_colortools.h"
@@ -267,6 +272,8 @@ static BHead *find_bhead_from_idname(FileData *fd, const char *idname);
#ifdef USE_COLLECTION_COMPAT_28
static void expand_scene_collection(FileData *fd, Main *mainvar, SceneCollection *sc);
#endif
+static void direct_link_animdata(FileData *fd, AnimData *adt);
+static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt);
/* this function ensures that reports are printed,
* in the case of libraray linking errors this is important!
@@ -334,6 +341,12 @@ static void oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void *newaddr,
if (oldaddr==NULL || newaddr==NULL) return;
+ for (int i = 0; i < onm->nentries; i++) {
+ if (onm->entries[i].old == oldaddr && onm->entries[i].newp != newaddr) {
+ abort();
+ }
+ }
+
if (UNLIKELY(onm->nentries == onm->entriessize)) {
onm->entriessize *= 2;
onm->entries = MEM_reallocN(onm->entries, sizeof(*onm->entries) * onm->entriessize);
@@ -1028,20 +1041,6 @@ static int *read_file_thumbnail(FileData *fd)
return blend_thumb;
}
-static int fd_read_from_file(FileData *filedata, void *buffer, unsigned int size)
-{
- int readsize = read(filedata->filedes, buffer, size);
-
- if (readsize < 0) {
- readsize = EOF;
- }
- else {
- filedata->seek += readsize;
- }
-
- return readsize;
-}
-
static int fd_read_gzip_from_file(FileData *filedata, void *buffer, unsigned int size)
{
int readsize = gzread(filedata->gzfiledes, buffer, size);
@@ -2369,6 +2368,7 @@ static void direct_link_curvemapping(FileData *fd, CurveMapping *cumap)
}
/* ************ READ Brush *************** */
+
/* library brush linking after fileread */
static void lib_link_brush(FileData *fd, Main *main)
{
@@ -2384,6 +2384,11 @@ static void lib_link_brush(FileData *fd, Main *main)
brush->toggle_brush = newlibadr(fd, brush->id.lib, brush->toggle_brush);
brush->paint_curve = newlibadr_us(fd, brush->id.lib, brush->paint_curve);
+ /* link default grease pencil palette */
+ if (brush->gpencil_settings != NULL) {
+ brush->gpencil_settings->material = newlibadr_us(fd, brush->id.lib, brush->gpencil_settings->material);
+ }
+
brush->id.tag &= ~LIB_TAG_NEED_LINK;
}
}
@@ -2395,6 +2400,7 @@ static void direct_link_brush(FileData *fd, Brush *brush)
/* fallof curve */
brush->curve = newdataadr(fd, brush->curve);
+
brush->gradient = newdataadr(fd, brush->gradient);
if (brush->curve)
@@ -2402,11 +2408,29 @@ static void direct_link_brush(FileData *fd, Brush *brush)
else
BKE_brush_curve_preset(brush, CURVE_PRESET_SHARP);
+ /* grease pencil */
+ brush->gpencil_settings = newdataadr(fd, brush->gpencil_settings);
+ if (brush->gpencil_settings != NULL) {
+ brush->gpencil_settings->curve_sensitivity = newdataadr(fd, brush->gpencil_settings->curve_sensitivity);
+ brush->gpencil_settings->curve_strength = newdataadr(fd, brush->gpencil_settings->curve_strength);
+ brush->gpencil_settings->curve_jitter = newdataadr(fd, brush->gpencil_settings->curve_jitter);
+
+ if (brush->gpencil_settings->curve_sensitivity)
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_sensitivity);
+
+ if (brush->gpencil_settings->curve_strength)
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_strength);
+
+ if (brush->gpencil_settings->curve_jitter)
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_jitter);
+ }
+
brush->preview = NULL;
brush->icon_imbuf = NULL;
}
/* ************ READ Palette *************** */
+
static void lib_link_palette(FileData *fd, Main *main)
{
/* only link ID pointers */
@@ -2421,6 +2445,7 @@ static void lib_link_palette(FileData *fd, Main *main)
static void direct_link_palette(FileData *fd, Palette *palette)
{
+
/* palette itself has been read */
link_list(fd, &palette->colors);
}
@@ -3344,6 +3369,10 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
direct_link_curvemapping(fd, node->storage);
else if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
((ImageUser *)node->storage)->ok = 1;
+ else if (node->type==CMP_NODE_CRYPTOMATTE) {
+ NodeCryptomatte *nc = (NodeCryptomatte *) node->storage;
+ nc->matte_id = newdataadr(fd, nc->matte_id);
+ }
}
else if ( ntree->type==NTREE_TEXTURE) {
if (node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME)
@@ -4144,6 +4173,17 @@ static void lib_link_material(FileData *fd, Main *main)
ma->nodetree->id.lib = ma->id.lib;
}
+ /* relink grease pencil settings */
+ if (ma->gp_style != NULL) {
+ MaterialGPencilStyle *gp_style = ma->gp_style;
+ if (gp_style->sima != NULL) {
+ gp_style->sima = newlibadr_us(fd, ma->id.lib, gp_style->sima);
+ }
+ if (gp_style->ima != NULL) {
+ gp_style->ima = newlibadr_us(fd, ma->id.lib, gp_style->ima);
+ }
+ }
+
ma->id.tag &= ~LIB_TAG_NEED_LINK;
}
}
@@ -4164,6 +4204,8 @@ static void direct_link_material(FileData *fd, Material *ma)
ma->preview = direct_link_preview_image(fd, ma->preview);
BLI_listbase_clear(&ma->gpumaterial);
+
+ ma->gp_style = newdataadr(fd, ma->gp_style);
}
/* ************ READ PARTICLE SETTINGS ***************** */
@@ -4799,7 +4841,7 @@ static void direct_link_latt(FileData *fd, Lattice *lt)
/* ************ READ OBJECT ***************** */
-static void lib_link_modifiers__linkModifiers(
+static void lib_link_modifiers_common(
void *userData, Object *ob, ID **idpoin, int cb_flag)
{
FileData *fd = userData;
@@ -4809,9 +4851,10 @@ static void lib_link_modifiers__linkModifiers(
id_us_plus_no_lib(*idpoin);
}
}
+
static void lib_link_modifiers(FileData *fd, Object *ob)
{
- modifiers_foreachIDLink(ob, lib_link_modifiers__linkModifiers, fd);
+ modifiers_foreachIDLink(ob, lib_link_modifiers_common, fd);
/* If linking from a library, clear 'local' static override flag. */
if (ob->id.lib != NULL) {
@@ -4822,6 +4865,30 @@ static void lib_link_modifiers(FileData *fd, Object *ob)
}
+static void lib_link_gpencil_modifiers(FileData *fd, Object *ob)
+{
+ BKE_gpencil_modifiers_foreachIDLink(ob, lib_link_modifiers_common, fd);
+
+ /* If linking from a library, clear 'local' static override flag. */
+ if (ob->id.lib != NULL) {
+ for (GpencilModifierData *mod = ob->greasepencil_modifiers.first; mod != NULL; mod = mod->next) {
+ mod->flag &= ~eGpencilModifierFlag_StaticOverride_Local;
+ }
+ }
+}
+
+static void lib_link_shaderfxs(FileData *fd, Object *ob)
+{
+ BKE_shaderfx_foreachIDLink(ob, lib_link_modifiers_common, fd);
+
+ /* If linking from a library, clear 'local' static override flag. */
+ if (ob->id.lib != NULL) {
+ for (ShaderFxData *fx = ob->shader_fx.first; fx != NULL; fx = fx->next) {
+ fx->flag &= ~eShaderFxFlag_StaticOverride_Local;
+ }
+ }
+}
+
static void lib_link_object(FileData *fd, Main *main)
{
bool warn = false;
@@ -4958,6 +5025,8 @@ static void lib_link_object(FileData *fd, Main *main)
lib_link_particlesystems(fd, ob, &ob->id, &ob->particlesystem);
lib_link_modifiers(fd, ob);
+ lib_link_gpencil_modifiers(fd, ob);
+ lib_link_shaderfxs(fd, ob);
if (ob->rigidbody_constraint) {
ob->rigidbody_constraint->ob1 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob1);
@@ -5120,6 +5189,9 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
smd->domain->tex = NULL;
smd->domain->tex_shadow = NULL;
smd->domain->tex_flame = NULL;
+ smd->domain->tex_velocity_x = NULL;
+ smd->domain->tex_velocity_y = NULL;
+ smd->domain->tex_velocity_z = NULL;
smd->domain->tex_wt = NULL;
smd->domain->coba = newdataadr(fd, smd->domain->coba);
@@ -5379,6 +5451,61 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
}
}
+static void direct_link_gpencil_modifiers(FileData *fd, ListBase *lb)
+{
+ GpencilModifierData *md;
+
+ link_list(fd, lb);
+
+ for (md = lb->first; md; md = md->next) {
+ md->error = NULL;
+
+ /* if modifiers disappear, or for upward compatibility */
+ if (NULL == BKE_gpencil_modifierType_getInfo(md->type))
+ md->type = eModifierType_None;
+
+ if (md->type == eGpencilModifierType_Lattice) {
+ LatticeGpencilModifierData *gpmd = (LatticeGpencilModifierData*)md;
+ gpmd->cache_data = NULL;
+ }
+ else if (md->type == eGpencilModifierType_Hook) {
+ HookGpencilModifierData *hmd = (HookGpencilModifierData *)md;
+
+ hmd->curfalloff = newdataadr(fd, hmd->curfalloff);
+ if (hmd->curfalloff) {
+ direct_link_curvemapping(fd, hmd->curfalloff);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Thick) {
+ ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md;
+
+ gpmd->curve_thickness = newdataadr(fd, gpmd->curve_thickness);
+ if (gpmd->curve_thickness) {
+ direct_link_curvemapping(fd, gpmd->curve_thickness);
+ /* initialize the curve. Maybe this could be moved to modififer logic */
+ curvemapping_initialize(gpmd->curve_thickness);
+ }
+ }
+
+ }
+}
+
+static void direct_link_shaderfxs(FileData *fd, ListBase *lb)
+{
+ ShaderFxData *fx;
+
+ link_list(fd, lb);
+
+ for (fx = lb->first; fx; fx = fx->next) {
+ fx->error = NULL;
+
+ /* if shader disappear, or for upward compatibility */
+ if (NULL == BKE_shaderfxType_getInfo(fx->type))
+ fx->type = eShaderFxType_None;
+
+ }
+}
+
static void direct_link_object(FileData *fd, Object *ob)
{
PartEff *paf;
@@ -5422,6 +5549,8 @@ static void direct_link_object(FileData *fd, Object *ob)
/* do it here, below old data gets converted */
direct_link_modifiers(fd, &ob->modifiers);
+ direct_link_gpencil_modifiers(fd, &ob->greasepencil_modifiers);
+ direct_link_shaderfxs(fd, &ob->shader_fx);
link_list(fd, &ob->effect);
paf= ob->effect.first;
@@ -5568,12 +5697,8 @@ static void direct_link_object(FileData *fd, Object *ob)
ob->derivedDeform = NULL;
ob->derivedFinal = NULL;
BKE_object_runtime_reset(ob);
- BLI_listbase_clear(&ob->gpulamp);
link_list(fd, &ob->pc_ids);
- /* Runtime curve data */
- ob->curve_cache = NULL;
-
/* in case this value changes in future, clamp else we get undefined behavior */
CLAMP(ob->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
@@ -5906,6 +6031,7 @@ static void lib_link_scene(FileData *fd, Main *main)
link_paint(fd, sce, &sce->toolsettings->wpaint->paint);
link_paint(fd, sce, &sce->toolsettings->imapaint.paint);
link_paint(fd, sce, &sce->toolsettings->uvsculpt->paint);
+ link_paint(fd, sce, &sce->toolsettings->gp_paint->paint);
if (sce->toolsettings->sculpt)
sce->toolsettings->sculpt->gravity_object =
@@ -6164,6 +6290,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
direct_link_paint_helper(fd, (Paint**)&sce->toolsettings->vpaint);
direct_link_paint_helper(fd, (Paint**)&sce->toolsettings->wpaint);
direct_link_paint_helper(fd, (Paint**)&sce->toolsettings->uvsculpt);
+ direct_link_paint_helper(fd, (Paint**)&sce->toolsettings->gp_paint);
direct_link_paint(fd, &sce->toolsettings->imapaint.paint);
@@ -6173,28 +6300,16 @@ static void direct_link_scene(FileData *fd, Scene *sce)
sce->toolsettings->particle.object = NULL;
sce->toolsettings->gp_sculpt.paintcursor = NULL;
- /* relink grease pencil drawing brushes */
- link_list(fd, &sce->toolsettings->gp_brushes);
- for (bGPDbrush *brush = sce->toolsettings->gp_brushes.first; brush; brush = brush->next) {
- brush->cur_sensitivity = newdataadr(fd, brush->cur_sensitivity);
- if (brush->cur_sensitivity) {
- direct_link_curvemapping(fd, brush->cur_sensitivity);
- }
- brush->cur_strength = newdataadr(fd, brush->cur_strength);
- if (brush->cur_strength) {
- direct_link_curvemapping(fd, brush->cur_strength);
- }
- brush->cur_jitter = newdataadr(fd, brush->cur_jitter);
- if (brush->cur_jitter) {
- direct_link_curvemapping(fd, brush->cur_jitter);
- }
- }
-
/* relink grease pencil interpolation curves */
sce->toolsettings->gp_interpolate.custom_ipo = newdataadr(fd, sce->toolsettings->gp_interpolate.custom_ipo);
if (sce->toolsettings->gp_interpolate.custom_ipo) {
direct_link_curvemapping(fd, sce->toolsettings->gp_interpolate.custom_ipo);
}
+ /* relink grease pencil multiframe falloff curve */
+ sce->toolsettings->gp_sculpt.cur_falloff = newdataadr(fd, sce->toolsettings->gp_sculpt.cur_falloff);
+ if (sce->toolsettings->gp_sculpt.cur_falloff) {
+ direct_link_curvemapping(fd, sce->toolsettings->gp_sculpt.cur_falloff);
+ }
}
if (sce->ed) {
@@ -6402,6 +6517,8 @@ static void direct_link_scene(FileData *fd, Scene *sce)
if (sce->master_collection) {
sce->master_collection = newdataadr(fd, sce->master_collection);
direct_link_collection(fd, sce->master_collection);
+ /* Needed because this is an ID outside of Main. */
+ sce->master_collection->id.py_instance = NULL;
}
/* insert into global old-new map for reading without UI (link_global accesses it again) */
@@ -6432,11 +6549,24 @@ static void direct_link_scene(FileData *fd, Scene *sce)
/* relink's grease pencil data's refs */
static void lib_link_gpencil(FileData *fd, Main *main)
{
+ /* Relink all datablock linked by GP datablock */
for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
if (gpd->id.tag & LIB_TAG_NEED_LINK) {
+ /* Layers */
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ /* Layer -> Parent References */
+ gpl->parent = newlibadr(fd, gpd->id.lib, gpl->parent);
+ }
+
+ /* Datablock Stuff */
IDP_LibLinkProperty(gpd->id.properties, fd);
lib_link_animdata(fd, &gpd->id, gpd->adt);
+ /* materials */
+ for (int a = 0; a < gpd->totcol; a++) {
+ gpd->mat[a] = newlibadr_us(fd, gpd->id.lib, gpd->mat[a]);
+ }
+
gpd->id.tag &= ~LIB_TAG_NEED_LINK;
}
}
@@ -6458,36 +6588,49 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
gpd->adt = newdataadr(fd, gpd->adt);
direct_link_animdata(fd, gpd->adt);
- /* relink palettes */
+ /* relink palettes (old palettes deprecated, only to convert old files) */
link_list(fd, &gpd->palettes);
- for (palette = gpd->palettes.first; palette; palette = palette->next) {
- link_list(fd, &palette->colors);
+ if (gpd->palettes.first != NULL) {
+ for (palette = gpd->palettes.first; palette; palette = palette->next) {
+ link_list(fd, &palette->colors);
+ }
}
+ /* clear drawing cache */
+ gpd->runtime.batch_cache_data = NULL;
+
+ /* materials */
+ gpd->mat = newdataadr(fd, gpd->mat);
+ test_pointer_array(fd, (void **)&gpd->mat);
+
/* relink layers */
link_list(fd, &gpd->layers);
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- /* parent */
- gpl->parent = newlibadr(fd, gpd->id.lib, gpl->parent);
/* relink frames */
link_list(fd, &gpl->frames);
+
gpl->actframe = newdataadr(fd, gpl->actframe);
+ gpl->runtime.derived_data = NULL;
+ gpl->runtime.icon_id = 0;
+
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
/* relink strokes (and their points) */
link_list(fd, &gpf->strokes);
for (gps = gpf->strokes.first; gps; gps = gps->next) {
+ /* relink stroke points array */
gps->points = newdataadr(fd, gps->points);
+ /* relink weight data */
+ gps->dvert = newdataadr(fd, gps->dvert);
+ direct_link_dverts(fd, gps->totpoints, gps->dvert);
+
/* the triangulation is not saved, so need to be recalculated */
gps->triangles = NULL;
gps->tot_triangles = 0;
gps->flag |= GP_STROKE_RECALC_CACHES;
- /* the color pointer is not saved, so need to be recalculated using the color name */
- gps->palcolor = NULL;
- gps->flag |= GP_STROKE_RECALC_COLOR;
}
}
}
@@ -6633,9 +6776,10 @@ static void direct_link_area(FileData *fd, ScrArea *area)
v3d->properties_storage = NULL;
/* render can be quite heavy, set to solid on load */
- if (v3d->drawtype == OB_RENDER)
- v3d->drawtype = OB_SOLID;
- v3d->prev_drawtype = OB_SOLID;
+ if (v3d->shading.type == OB_RENDER) {
+ v3d->shading.type = OB_SOLID;
+ }
+ v3d->shading.prev_type = OB_SOLID;
if (v3d->fx_settings.dof)
v3d->fx_settings.dof = newdataadr(fd, v3d->fx_settings.dof);
@@ -7044,7 +7188,7 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
direct_link_area_map(fd, &win->global_areas);
win->ghostwin = NULL;
- win->gwnctx = NULL;
+ win->gpuctx = NULL;
win->eventstate = NULL;
win->cursor_keymap_status = NULL;
win->tweak = NULL;
@@ -7729,6 +7873,7 @@ static void direct_link_speaker(FileData *fd, Speaker *spk)
static void direct_link_sound(FileData *fd, bSound *sound)
{
+ sound->tags = 0;
sound->handle = NULL;
sound->playback_handle = NULL;
@@ -7740,6 +7885,7 @@ static void direct_link_sound(FileData *fd, bSound *sound)
if (fd->soundmap) {
sound->waveform = newsoundadr(fd, sound->waveform);
+ sound->tags |= SOUND_TAGS_WAVEFORM_NO_RELOAD;
}
else {
sound->waveform = NULL;
@@ -7750,7 +7896,7 @@ static void direct_link_sound(FileData *fd, bSound *sound)
BLI_spin_init(sound->spinlock);
}
/* clear waveform loading flag */
- sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING;
+ sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING;
sound->packedfile = direct_link_packedfile(fd, sound->packedfile);
sound->newpackedfile = direct_link_packedfile(fd, sound->newpackedfile);
@@ -8642,6 +8788,11 @@ static void do_versions_userdef(FileData *fd, BlendFileData *bfd)
user->walk_navigation.jump_height = 0.4f; /* m */
user->walk_navigation.teleport_time = 0.2f; /* s */
}
+
+ /* grease pencil multisamples */
+ if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "short", "gpencil_multisamples")) {
+ user->gpencil_multisamples = 4;
+ }
}
static void do_versions(FileData *fd, Library *lib, Main *main)
@@ -8720,8 +8871,8 @@ static void lib_link_all(FileData *fd, Main *main)
lib_link_action(fd, main);
lib_link_vfont(fd, main);
lib_link_nodetree(fd, main); /* has to be done after scene/materials, this will verify group nodes */
- lib_link_brush(fd, main);
lib_link_palette(fd, main);
+ lib_link_brush(fd, main);
lib_link_paint_curve(fd, main);
lib_link_particlesettings(fd, main);
lib_link_movieclip(fd, main);
@@ -9458,6 +9609,9 @@ static void expand_brush(FileData *fd, Main *mainvar, Brush *brush)
expand_doit(fd, mainvar, brush->mask_mtex.tex);
expand_doit(fd, mainvar, brush->clone.image);
expand_doit(fd, mainvar, brush->paint_curve);
+ if (brush->gpencil_settings != NULL) {
+ expand_doit(fd, mainvar, brush->gpencil_settings->material);
+ }
}
static void expand_material(FileData *fd, Main *mainvar, Material *ma)
@@ -9469,6 +9623,12 @@ static void expand_material(FileData *fd, Main *mainvar, Material *ma)
if (ma->nodetree)
expand_nodetree(fd, mainvar, ma->nodetree);
+
+ if (ma->gp_style) {
+ MaterialGPencilStyle *gp_style = ma->gp_style;
+ expand_doit(fd, mainvar, gp_style->sima);
+ expand_doit(fd, mainvar, gp_style->ima);
+ }
}
static void expand_lamp(FileData *fd, Main *mainvar, Lamp *la)
@@ -9645,6 +9805,24 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
modifiers_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
}
+ /* expand_object_expandModifier() */
+ if (ob->greasepencil_modifiers.first) {
+ struct { FileData *fd; Main *mainvar; } data;
+ data.fd = fd;
+ data.mainvar = mainvar;
+
+ BKE_gpencil_modifiers_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
+ }
+
+ /* expand_object_expandShaderFx() */
+ if (ob->shader_fx.first) {
+ struct { FileData *fd; Main *mainvar; } data;
+ data.fd = fd;
+ data.mainvar = mainvar;
+
+ BKE_shaderfx_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
+ }
+
expand_pose(fd, mainvar, ob->pose);
expand_doit(fd, mainvar, ob->poselib);
expand_constraints(fd, mainvar, &ob->constraints);
@@ -9923,8 +10101,18 @@ static void expand_linestyle(FileData *fd, Main *mainvar, FreestyleLineStyle *li
static void expand_gpencil(FileData *fd, Main *mainvar, bGPdata *gpd)
{
- if (gpd->adt)
+ if (gpd->adt) {
expand_animdata(fd, mainvar, gpd->adt);
+ }
+
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ expand_doit(fd, mainvar, gpl->parent);
+ }
+
+ for (int a = 0; a < gpd->totcol; a++) {
+ expand_doit(fd, mainvar, gpd->mat[a]);
+ }
+
}
static void expand_workspace(FileData *fd, Main *mainvar, WorkSpace *workspace)
@@ -10816,27 +11004,3 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
BKE_main_free(main_newid);
}
-
-/* reading runtime */
-
-BlendFileData *blo_read_blendafterruntime(int file, const char *name, int actualsize, ReportList *reports)
-{
- BlendFileData *bfd = NULL;
- FileData *fd = filedata_new();
- fd->filedes = file;
- fd->buffersize = actualsize;
- fd->read = fd_read_from_file;
-
- /* needed for library_append and read_libraries */
- BLI_strncpy(fd->relabase, name, sizeof(fd->relabase));
-
- fd = blo_decode_and_check(fd, reports);
- if (!fd)
- return NULL;
-
- fd->reports = reports;
- bfd = blo_read_file_internal(fd, "");
- blo_freefiledata(fd);
-
- return bfd;
-}
diff --git a/source/blender/blenloader/intern/runtime.c b/source/blender/blenloader/intern/runtime.c
deleted file mode 100644
index 985e8169819..00000000000
--- a/source/blender/blenloader/intern/runtime.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- *
- */
-
-/**
- * \file runtime.c
- * \brief This file handles the loading of .blend files embedded in runtimes
- * \ingroup blenloader
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#ifdef WIN32
-# include <io.h> // read, open
-# include "BLI_winstuff.h"
-#else // ! WIN32
-# include <unistd.h> // read
-#endif
-
-#include "BLI_blenlib.h"
-#include "BLI_utildefines.h"
-
-#include "BLO_readfile.h"
-#include "BLO_runtime.h"
-
-#include "BKE_report.h"
-
-/* Runtime reading */
-
-static int handle_read_msb_int(int handle)
-{
- unsigned char buf[4];
-
- if (read(handle, buf, 4) != 4)
- return -1;
-
- return (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + (buf[3] << 0);
-}
-
-int BLO_is_a_runtime(const char *path)
-{
- int res = 0, fd = BLI_open(path, O_BINARY | O_RDONLY, 0);
- int datastart;
- char buf[8];
-
- if (fd == -1)
- goto cleanup;
-
- lseek(fd, -12, SEEK_END);
-
- datastart = handle_read_msb_int(fd);
-
- if (datastart == -1)
- goto cleanup;
- else if (read(fd, buf, 8) != 8)
- goto cleanup;
- else if (memcmp(buf, "BRUNTIME", 8) != 0)
- goto cleanup;
- else
- res = 1;
-
-cleanup:
- if (fd != -1)
- close(fd);
-
- return res;
-}
-
-BlendFileData *BLO_read_runtime(const char *path, ReportList *reports)
-{
- BlendFileData *bfd = NULL;
- size_t actualsize;
- int fd, datastart;
- char buf[8];
-
- fd = BLI_open(path, O_BINARY | O_RDONLY, 0);
-
- if (fd == -1) {
- BKE_reportf(reports, RPT_ERROR, "Unable to open '%s': %s", path, strerror(errno));
- goto cleanup;
- }
-
- actualsize = BLI_file_descriptor_size(fd);
-
- lseek(fd, -12, SEEK_END);
-
- datastart = handle_read_msb_int(fd);
-
- if (datastart == -1) {
- BKE_reportf(reports, RPT_ERROR, "Unable to read '%s' (problem seeking)", path);
- goto cleanup;
- }
- else if (read(fd, buf, 8) != 8) {
- BKE_reportf(reports, RPT_ERROR, "Unable to read '%s' (truncated header)", path);
- goto cleanup;
- }
- else if (memcmp(buf, "BRUNTIME", 8) != 0) {
- BKE_reportf(reports, RPT_ERROR, "Unable to read '%s' (not a blend file)", path);
- goto cleanup;
- }
- else {
- //printf("starting to read runtime from %s at datastart %d\n", path, datastart);
- lseek(fd, datastart, SEEK_SET);
- bfd = blo_read_blendafterruntime(fd, path, actualsize - datastart, reports);
- fd = -1; // file was closed in blo_read_blendafterruntime()
- }
-
-cleanup:
- if (fd != -1)
- close(fd);
-
- return bfd;
-}
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 973591c49da..4b628bf816a 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -545,20 +545,6 @@ static void do_version_constraints_radians_degrees_250(ListBase *lb)
}
}
-/* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already */
-static void do_versions_seq_unique_name_all_strips(Scene *sce, ListBase *seqbasep)
-{
- Sequence * seq = seqbasep->first;
-
- while (seq) {
- BKE_sequence_base_unique_name_recursive(&sce->ed->seqbase, seq);
- if (seq->seqbase.first) {
- do_versions_seq_unique_name_all_strips(sce, &seq->seqbase);
- }
- seq = seq->next;
- }
-}
-
static void do_version_bone_roll_256(Bone *bone)
{
Bone *child;
@@ -1029,10 +1015,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
if (sce->r.frame_step == 0)
sce->r.frame_step = 1;
- if (sce->ed && sce->ed->seqbase.first) {
- do_versions_seq_unique_name_all_strips(sce, &sce->ed->seqbase);
- }
-
sce = sce->id.next;
}
}
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 7a032dc3c90..f2f2e7d7881 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -1685,7 +1685,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
case SPACE_VIEW3D:
{
View3D *v3d = (View3D *)sl;
- v3d->flag2 |= V3D_SHOW_GPENCIL;
+ v3d->flag2 |= V3D_SHOW_ANNOTATION;
break;
}
case SPACE_SEQ:
@@ -1709,7 +1709,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
case SPACE_CLIP:
{
SpaceClip *sclip = (SpaceClip *)sl;
- sclip->flag |= SC_SHOW_GPENCIL;
+ sclip->flag |= SC_SHOW_ANNOTATION;
break;
}
}
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 7a106611e64..fadf332c850 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -76,6 +76,9 @@
#include "BLI_math.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
+#include "BLI_string_utils.h"
+
+#include "BLT_translation.h"
#include "BLO_readfile.h"
@@ -87,6 +90,64 @@
#include "MEM_guardedalloc.h"
+/* ************************************************** */
+/* GP Palettes API (Deprecated) */
+
+/* add a new gp-palette */
+static bGPDpalette *BKE_gpencil_palette_addnew(bGPdata *gpd, const char *name)
+{
+ bGPDpalette *palette;
+
+ /* check that list is ok */
+ if (gpd == NULL) {
+ return NULL;
+ }
+
+ /* allocate memory and add to end of list */
+ palette = MEM_callocN(sizeof(bGPDpalette), "bGPDpalette");
+
+ /* add to datablock */
+ BLI_addtail(&gpd->palettes, palette);
+
+ /* set basic settings */
+ /* auto-name */
+ BLI_strncpy(palette->info, name, sizeof(palette->info));
+ BLI_uniquename(&gpd->palettes, palette, DATA_("GP_Palette"), '.', offsetof(bGPDpalette, info),
+ sizeof(palette->info));
+
+ /* return palette */
+ return palette;
+}
+
+/* add a new gp-palettecolor */
+static bGPDpalettecolor *BKE_gpencil_palettecolor_addnew(bGPDpalette *palette, const char *name)
+{
+ bGPDpalettecolor *palcolor;
+
+ /* check that list is ok */
+ if (palette == NULL) {
+ return NULL;
+ }
+
+ /* allocate memory and add to end of list */
+ palcolor = MEM_callocN(sizeof(bGPDpalettecolor), "bGPDpalettecolor");
+
+ /* add to datablock */
+ BLI_addtail(&palette->colors, palcolor);
+
+ /* set basic settings */
+ copy_v4_v4(palcolor->color, U.gpencil_new_layer_col);
+ ARRAY_SET_ITEMS(palcolor->fill, 1.0f, 1.0f, 1.0f);
+
+ /* auto-name */
+ BLI_strncpy(palcolor->info, name, sizeof(palcolor->info));
+ BLI_uniquename(&palette->colors, palcolor, DATA_("Color"), '.', offsetof(bGPDpalettecolor, info),
+ sizeof(palcolor->info));
+
+ /* return palette color */
+ return palcolor;
+}
+
/**
* Setup rotation stabilization from ancient single track spec.
* Former Version of 2D stabilization used a single tracking marker to determine the rotation
@@ -1344,8 +1405,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
ToolSettings *ts = scene->toolsettings;
/* initialize use position for sculpt brushes */
ts->gp_sculpt.flag |= GP_BRUSHEDIT_FLAG_APPLY_POSITION;
- /* initialize selected vertices alpha factor */
- ts->gp_sculpt.alpha = 1.0f;
/* new strength sculpt brush */
if (ts->gp_sculpt.brush[0].size >= 11) {
@@ -1358,25 +1417,16 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
}
}
- /* create a default grease pencil drawing brushes set */
- if (!BLI_listbase_is_empty(&bmain->gpencil)) {
- for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
- ToolSettings *ts = scene->toolsettings;
- if (BLI_listbase_is_empty(&ts->gp_brushes)) {
- BKE_gpencil_brush_init_presets(ts);
- }
- }
- }
/* Convert Grease Pencil to new palettes/brushes
* Loop all strokes and create the palette and all colors
*/
for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
if (BLI_listbase_is_empty(&gpd->palettes)) {
/* create palette */
- bGPDpalette *palette = BKE_gpencil_palette_addnew(gpd, "GP_Palette", true);
+ bGPDpalette *palette = BKE_gpencil_palette_addnew(gpd, "GP_Palette");
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* create color using layer name */
- bGPDpalettecolor *palcolor = BKE_gpencil_palettecolor_addnew(palette, gpl->info, true);
+ bGPDpalettecolor *palcolor = BKE_gpencil_palettecolor_addnew(palette, gpl->info);
if (palcolor != NULL) {
/* set color attributes */
copy_v4_v4(palcolor->color, gpl->color);
@@ -1386,7 +1436,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (gpl->flag & GP_LAYER_LOCKED) palcolor->flag |= PC_COLOR_LOCKED;
if (gpl->flag & GP_LAYER_ONIONSKIN) palcolor->flag |= PC_COLOR_ONIONSKIN;
if (gpl->flag & GP_LAYER_VOLUMETRIC) palcolor->flag |= PC_COLOR_VOLUMETRIC;
- if (gpl->flag & GP_LAYER_HQ_FILL) palcolor->flag |= PC_COLOR_HQ_FILL;
/* set layer opacity to 1 */
gpl->opacity = 1.0f;
@@ -1399,8 +1448,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* set stroke to palette and force recalculation */
BLI_strncpy(gps->colorname, gpl->info, sizeof(gps->colorname));
- gps->palcolor = NULL;
- gps->flag |= GP_STROKE_RECALC_COLOR;
gps->thickness = gpl->thickness;
/* set alpha strength to 1 */
@@ -1410,13 +1457,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
-
- /* set thickness to 0 (now it is a factor to override stroke thickness) */
- gpl->thickness = 0.0f;
}
- /* set first color as active */
- if (palette->colors.first)
- BKE_gpencil_palettecolor_setactive(palette, palette->colors.first);
}
}
}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index b854438ed47..aed1fd8b416 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -54,24 +54,31 @@
#include "DNA_screen_types.h"
#include "DNA_view3d_types.h"
#include "DNA_genfile.h"
+#include "DNA_gpencil_types.h"
#include "DNA_workspace_types.h"
#include "BKE_collection.h"
#include "BKE_constraint.h"
#include "BKE_customdata.h"
+#include "BKE_colortools.h"
#include "BKE_freestyle.h"
#include "BKE_idprop.h"
#include "BKE_image.h"
#include "BKE_layer.h"
#include "BKE_main.h"
+#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_node.h"
#include "BKE_pointcache.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
+#include "BKE_sequencer.h"
#include "BKE_studiolight.h"
#include "BKE_workspace.h"
+#include "BKE_gpencil.h"
+#include "BKE_paint.h"
+#include "BKE_object.h"
#include "BLO_readfile.h"
#include "readfile.h"
@@ -111,6 +118,9 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
else {
workspace = BKE_workspace_add(bmain, screen->id.name + 2);
}
+ if (workspace == NULL) {
+ continue; /* Not much we can do.. */
+ }
BKE_workspace_layout_add(bmain, workspace, screen, screen->id.name + 2);
}
}
@@ -486,27 +496,15 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
nlc->flag |= LAYER_COLLECTION_EXCLUDE;
}
}
- else if ((scene->lay & srl->lay & ~(srl->lay_exclude) & (1 << layer)) ||
- (srl->lay_zmask & (scene->lay | srl->lay_exclude) & (1 << layer)))
- {
+ else {
if (srl->lay_zmask & (1 << layer)) {
have_override = true;
-
- BKE_override_layer_collection_boolean_add(
- lc,
- ID_OB,
- "cycles.is_holdout",
- true);
+ lc->flag |= LAYER_COLLECTION_HOLDOUT;
}
if ((srl->lay & (1 << layer)) == 0) {
have_override = true;
-
- BKE_override_layer_collection_boolean_add(
- lc,
- ID_OB,
- "cycles_visibility.camera",
- false);
+ lc->flag |= LAYER_COLLECTION_INDIRECT_ONLY;
}
}
}
@@ -751,6 +749,19 @@ void do_versions_after_linking_280(Main *bmain)
}
}
#endif
+
+}
+
+/* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already.
+ * But in 2.79 another case generating non-unique names was discovered (see T55668, involving Meta strips)... */
+static void do_versions_seq_unique_name_all_strips(Scene *sce, ListBase *seqbasep)
+{
+ for (Sequence *seq = seqbasep->first; seq != NULL; seq = seq->next) {
+ BKE_sequence_base_unique_name_recursive(&sce->ed->seqbase, seq);
+ if (seq->seqbase.first != NULL) {
+ do_versions_seq_unique_name_all_strips(sce, &seq->seqbase);
+ }
+ }
}
void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
@@ -804,10 +815,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "contact_dist")) {
for (Lamp *la = bmain->lamp.first; la; la = la->id.next) {
- la->contact_dist = 1.0f;
+ la->contact_dist = 0.2f;
la->contact_bias = 0.03f;
la->contact_spread = 0.2f;
- la->contact_thickness = 0.5f;
+ la->contact_thickness = 0.2f;
}
}
@@ -865,10 +876,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
} FOREACH_NODETREE_END
- if (error & NTREE_DOVERSION_NEED_OUTPUT) {
- BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
- printf("You need to connect Principled and Eevee Specular shader nodes to new material output nodes.\n");
- }
+ if (error & NTREE_DOVERSION_NEED_OUTPUT) {
+ BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
+ printf("You need to connect Principled and Eevee Specular shader nodes to new material output nodes.\n");
+ }
if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) {
BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
@@ -892,6 +903,68 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
#endif
+
+ {
+ /* Grease pencil sculpt and paint cursors */
+ if (!DNA_struct_elem_find(fd->filesdna, "GP_BrushEdit_Settings", "int", "weighttype")) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ /* sculpt brushes */
+ GP_BrushEdit_Settings *gset = &scene->toolsettings->gp_sculpt;
+ if (gset) {
+ gset->weighttype = GP_EDITBRUSH_TYPE_WEIGHT;
+ }
+ }
+ }
+
+ {
+ 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_EditBrush_Data *gp_brush;
+
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ ToolSettings *ts = scene->toolsettings;
+ /* sculpt brushes */
+ GP_BrushEdit_Settings *gset = &ts->gp_sculpt;
+ for (int i = 0; i < TOT_GP_EDITBRUSH_TYPES; ++i) {
+ gp_brush = &gset->brush[i];
+ gp_brush->flag |= GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
+ copy_v3_v3(gp_brush->curcolor_add, curcolor_add);
+ copy_v3_v3(gp_brush->curcolor_sub, curcolor_sub);
+ }
+ }
+ }
+
+ /* Init grease pencil edit line color */
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "float", "line_color[4]")) {
+ for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
+ ARRAY_SET_ITEMS(gpd->line_color, 0.6f, 0.6f, 0.6f, 0.5f);
+ }
+ }
+
+ /* Init grease pencil pixel size factor */
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPDdata", "int", "pixfactor")) {
+ for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
+ gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
+ }
+ }
+
+ /* Grease pencil multiframe falloff curve */
+ if (!DNA_struct_elem_find(fd->filesdna, "GP_BrushEdit_Settings", "CurveMapping", "cur_falloff")) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ /* sculpt brushes */
+ GP_BrushEdit_Settings *gset = &scene->toolsettings->gp_sculpt;
+ if ((gset) && (gset->cur_falloff == NULL)) {
+ gset->cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ curvemapping_initialize(gset->cur_falloff);
+ curvemap_reset(gset->cur_falloff->cm,
+ &gset->cur_falloff->clipr,
+ CURVE_PRESET_GAUSS,
+ CURVEMAP_SLOPE_POSITIVE);
+ }
+ }
+ }
+ }
}
#ifdef USE_COLLECTION_COMPAT_28
@@ -911,6 +984,26 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
#endif
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
+ /* init grease pencil grids and paper */
+ if (!DNA_struct_elem_find(fd->filesdna, "gp_paper_opacity", "float", "gpencil_paper_color[3]")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.gpencil_grid_scale = 1.0f; // Scale
+ v3d->overlay.gpencil_grid_lines = GP_DEFAULT_GRID_LINES; // NUmber of lines
+ v3d->overlay.gpencil_paper_opacity = 0.5f;
+ v3d->overlay.gpencil_grid_axis = V3D_GP_GRID_AXIS_Y;
+ v3d->overlay.gpencil_grid_opacity = 0.9f;
+ }
+ }
+ }
+ }
+ }
+ }
+
if (!MAIN_VERSION_ATLEAST(bmain, 280, 6)) {
if (DNA_struct_elem_find(fd->filesdna, "SpaceOops", "int", "filter") == false) {
bScreen *sc;
@@ -1013,6 +1106,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
tex->type = 0;
}
}
+
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 11)) {
@@ -1200,7 +1294,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
scene->eevee.flag =
SCE_EEVEE_VOLUMETRIC_LIGHTS |
- SCE_EEVEE_VOLUMETRIC_COLORED |
SCE_EEVEE_GTAO_BENT_NORMALS |
SCE_EEVEE_GTAO_BOUNCE |
SCE_EEVEE_TAA_REPROJECTION |
@@ -1258,7 +1351,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
EEVEE_GET_BOOL(props, volumetric_enable, SCE_EEVEE_VOLUMETRIC_ENABLED);
EEVEE_GET_BOOL(props, volumetric_lights, SCE_EEVEE_VOLUMETRIC_LIGHTS);
EEVEE_GET_BOOL(props, volumetric_shadows, SCE_EEVEE_VOLUMETRIC_SHADOWS);
- EEVEE_GET_BOOL(props, volumetric_colored_transmittance, SCE_EEVEE_VOLUMETRIC_COLORED);
EEVEE_GET_BOOL(props, gtao_enable, SCE_EEVEE_GTAO_ENABLED);
EEVEE_GET_BOOL(props, gtao_use_bent_normals, SCE_EEVEE_GTAO_BENT_NORMALS);
EEVEE_GET_BOOL(props, gtao_bounce, SCE_EEVEE_GTAO_BOUNCE);
@@ -1524,7 +1616,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
- {
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 21)) {
+ for (Scene *sce = bmain->scene.first; sce != NULL; sce = sce->id.next) {
+ if (sce->ed != NULL && sce->ed->seqbase.first != NULL) {
+ do_versions_seq_unique_name_all_strips(sce, &sce->ed->seqbase);
+ }
+ }
+
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "texture_paint_mode_opacity")) {
for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
@@ -1541,6 +1639,19 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShadeing", "short", "background_type")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ copy_v3_fl(v3d->shading.background_color, 0.05f);
+ }
+ }
+ }
+ }
+ }
+
if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "gi_cubemap_draw_size")) {
for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
scene->eevee.gi_irradiance_draw_size = 0.1f;
@@ -1599,5 +1710,132 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "short", "type")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ if (v3d->drawtype == OB_RENDER) {
+ v3d->drawtype = OB_SOLID;
+ }
+ v3d->shading.type = v3d->drawtype;
+ v3d->shading.prev_type = OB_SOLID;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "View3DShading", "shading")) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ BKE_screen_view3d_shading_init(&scene->display.shading);
+ }
+ }
+ /* initialize grease pencil view data */
+ if (!DNA_struct_elem_find(fd->filesdna, "SpaceView3D", "float", "vertex_opacity")) {
+ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->vertex_opacity = 1.0f;
+ v3d->gp_flag |= V3D_GP_SHOW_EDIT_LINES;
+ }
+ }
+ }
+ }
+ }
+
}
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 22)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "annotate_v3d_align")) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ scene->toolsettings->annotate_v3d_align = GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR;
+ scene->toolsettings->annotate_thickness = 3;
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPDlayer", "short", "line_change")) {
+ for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ gpl->line_change = gpl->thickness;
+ if ((gpl->thickness < 1) || (gpl->thickness > 10)) {
+ gpl->thickness = 3;
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_grid_scale")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.gpencil_grid_scale = 1.0f;
+ }
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_paper_opacity")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.gpencil_paper_opacity = 0.5f;
+ }
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_grid_opacity")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.gpencil_grid_opacity = 0.5f;
+ }
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "int", "gpencil_grid_axis")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.gpencil_grid_axis = V3D_GP_GRID_AXIS_Y;
+ }
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "int", "gpencil_grid_lines")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.gpencil_grid_lines = GP_DEFAULT_GRID_LINES;
+ }
+ }
+ }
+ }
+ }
+ /* default loc axis */
+ if (!DNA_struct_elem_find(fd->filesdna, "GP_BrushEdit_Settings", "int", "lock_axis")) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ /* lock axis */
+ GP_BrushEdit_Settings *gset = &scene->toolsettings->gp_sculpt;
+ if (gset) {
+ gset->lock_axis = GP_LOCKAXIS_Y;
+ }
+ }
+ }
+ }
+
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index bd7334516ca..c120eed695c 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -170,46 +170,77 @@ void BLO_update_defaults_startup_blend(Main *bmain)
if (ts->gp_sculpt.brush[0].size == 0) {
GP_BrushEdit_Settings *gset = &ts->gp_sculpt;
GP_EditBrush_Data *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);
+
+ /* default sculpt brush */
+ gset->brushtype = GP_EDITBRUSH_TYPE_PUSH;
+ /* default weight paint brush */
+ gset->weighttype = GP_EDITBRUSH_TYPE_WEIGHT;
brush = &gset->brush[GP_EDITBRUSH_TYPE_SMOOTH];
brush->size = 25;
brush->strength = 0.3f;
- brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE;
+ brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE | GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
+ copy_v3_v3(brush->curcolor_add, curcolor_add);
+ copy_v3_v3(brush->curcolor_sub, curcolor_sub);
brush = &gset->brush[GP_EDITBRUSH_TYPE_THICKNESS];
brush->size = 25;
brush->strength = 0.5f;
- brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
+ brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
+ copy_v3_v3(brush->curcolor_add, curcolor_add);
+ copy_v3_v3(brush->curcolor_sub, curcolor_sub);
brush = &gset->brush[GP_EDITBRUSH_TYPE_STRENGTH];
brush->size = 25;
brush->strength = 0.5f;
- brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
+ brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
+ copy_v3_v3(brush->curcolor_add, curcolor_add);
+ copy_v3_v3(brush->curcolor_sub, curcolor_sub);
brush = &gset->brush[GP_EDITBRUSH_TYPE_GRAB];
brush->size = 50;
brush->strength = 0.3f;
- brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
+ brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
+ copy_v3_v3(brush->curcolor_add, curcolor_add);
+ copy_v3_v3(brush->curcolor_sub, curcolor_sub);
brush = &gset->brush[GP_EDITBRUSH_TYPE_PUSH];
brush->size = 25;
brush->strength = 0.3f;
- brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
+ brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
+ copy_v3_v3(brush->curcolor_add, curcolor_add);
+ copy_v3_v3(brush->curcolor_sub, curcolor_sub);
brush = &gset->brush[GP_EDITBRUSH_TYPE_TWIST];
brush->size = 50;
brush->strength = 0.3f; // XXX?
- brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
+ brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
+ copy_v3_v3(brush->curcolor_add, curcolor_add);
+ copy_v3_v3(brush->curcolor_sub, curcolor_sub);
brush = &gset->brush[GP_EDITBRUSH_TYPE_PINCH];
brush->size = 50;
brush->strength = 0.5f; // XXX?
- brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
+ brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
+ copy_v3_v3(brush->curcolor_add, curcolor_add);
+ copy_v3_v3(brush->curcolor_sub, curcolor_sub);
brush = &gset->brush[GP_EDITBRUSH_TYPE_RANDOMIZE];
brush->size = 25;
brush->strength = 0.5f;
- brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
+ brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
+ copy_v3_v3(brush->curcolor_add, curcolor_add);
+ copy_v3_v3(brush->curcolor_sub, curcolor_sub);
+
+ brush = &gset->brush[GP_EDITBRUSH_TYPE_WEIGHT];
+ brush->size = 25;
+ brush->strength = 0.5f;
+ brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
+ copy_v3_v3(brush->curcolor_add, curcolor_add);
+ copy_v3_v3(brush->curcolor_sub, curcolor_sub);
}
ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE;
@@ -217,6 +248,9 @@ void BLO_update_defaults_startup_blend(Main *bmain)
ts->gpencil_seq_align = GP_PROJECT_VIEWSPACE;
ts->gpencil_ima_align = GP_PROJECT_VIEWSPACE;
+ ts->annotate_v3d_align = GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR;
+ ts->annotate_thickness = 3;
+
ParticleEditSettings *pset = &ts->particle;
for (int a = 0; a < ARRAY_SIZE(pset->brush); a++) {
pset->brush[a].strength = 0.5f;
@@ -408,4 +442,21 @@ void BLO_update_defaults_startup_blend(Main *bmain)
la->energy = 10.0;
}
}
+ /* default grease pencil settings */
+ {
+ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->gp_flag |= V3D_GP_SHOW_EDIT_LINES;
+ v3d->gp_flag |= V3D_GP_SHOW_MULTIEDIT_LINES;
+ v3d->gp_flag |= V3D_GP_SHOW_ONION_SKIN;
+ v3d->vertex_opacity = 0.9f;
+ break;
+ }
+ }
+ }
+ }
+ }
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 0467e59d63b..f5ee0bdb244 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -118,6 +118,8 @@
#include "DNA_genfile.h"
#include "DNA_group_types.h"
#include "DNA_gpencil_types.h"
+#include "DNA_gpencil_modifier_types.h"
+#include "DNA_shader_fx_types.h"
#include "DNA_fileglobal_types.h"
#include "DNA_hair_types.h"
#include "DNA_key_types.h"
@@ -166,6 +168,7 @@
#include "BKE_collection.h"
#include "BKE_constraint.h"
#include "BKE_global.h" // for G
+#include "BKE_gpencil_modifier.h"
#include "BKE_idcode.h"
#include "BKE_layer.h"
#include "BKE_library.h" // for set_listbasepointers
@@ -174,6 +177,7 @@
#include "BKE_node.h"
#include "BKE_report.h"
#include "BKE_sequencer.h"
+#include "BKE_shader_fx.h"
#include "BKE_subsurf.h"
#include "BKE_modifier.h"
#include "BKE_fcurve.h"
@@ -188,7 +192,6 @@
#include "BLO_writefile.h"
#include "BLO_readfile.h"
-#include "BLO_runtime.h"
#include "BLO_undofile.h"
#include "BLO_blend_defs.h"
@@ -1104,6 +1107,13 @@ static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree)
}
writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
}
+ else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_CRYPTOMATTE)) {
+ NodeCryptomatte *nc = (NodeCryptomatte *)node->storage;
+ if (nc->matte_id) {
+ writedata(wd, DATA, strlen(nc->matte_id) + 1, nc->matte_id);
+ }
+ writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
+ }
else {
writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
}
@@ -1141,7 +1151,7 @@ static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree)
*/
static void current_screen_compat(
Main *mainvar, bool use_active_win,
- bScreen **r_screen, Scene **r_scene, ViewLayer **r_render_layer)
+ bScreen **r_screen, Scene **r_scene, ViewLayer **r_view_layer)
{
wmWindowManager *wm;
wmWindow *window = NULL;
@@ -1171,7 +1181,7 @@ static void current_screen_compat(
*r_screen = (window) ? BKE_workspace_active_screen_get(window->workspace_hook) : NULL;
*r_scene = (window) ? window->scene : NULL;
- *r_render_layer = (window && *r_scene) ? BKE_view_layer_find(*r_scene, window->view_layer_name) : NULL;
+ *r_view_layer = (window && *r_scene) ? BKE_view_layer_find(*r_scene, window->view_layer_name) : NULL;
}
typedef struct RenderInfo {
@@ -1187,11 +1197,11 @@ static void write_renderinfo(WriteData *wd, Main *mainvar)
{
bScreen *curscreen;
Scene *sce, *curscene = NULL;
- ViewLayer *render_layer;
+ ViewLayer *view_layer;
RenderInfo data;
/* XXX in future, handle multiple windows with multiple screens? */
- current_screen_compat(mainvar, false, &curscreen, &curscene, &render_layer);
+ current_screen_compat(mainvar, false, &curscreen, &curscene, &view_layer);
for (sce = mainvar->scene.first; sce; sce = sce->id.next) {
if (sce->id.lib == NULL && (sce == curscene || (sce->r.scemode & R_BG_RENDER))) {
@@ -1806,6 +1816,57 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
}
}
+static void write_gpencil_modifiers(WriteData *wd, ListBase *modbase)
+{
+ GpencilModifierData *md;
+
+ if (modbase == NULL) {
+ return;
+ }
+
+ for (md = modbase->first; md; md = md->next) {
+ const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type);
+ if (mti == NULL) {
+ return;
+ }
+
+ writestruct_id(wd, DATA, mti->struct_name, 1, md);
+
+ if (md->type == eGpencilModifierType_Thick) {
+ ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md;
+
+ if (gpmd->curve_thickness) {
+ write_curvemapping(wd, gpmd->curve_thickness);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Hook) {
+ HookGpencilModifierData *gpmd = (HookGpencilModifierData *)md;
+
+ if (gpmd->curfalloff) {
+ write_curvemapping(wd, gpmd->curfalloff);
+ }
+ }
+ }
+}
+
+static void write_shaderfxs(WriteData *wd, ListBase *fxbase)
+{
+ ShaderFxData *fx;
+
+ if (fxbase == NULL) {
+ return;
+ }
+
+ for (fx = fxbase->first; fx; fx = fx->next) {
+ const ShaderFxTypeInfo *fxi = BKE_shaderfxType_getInfo(fx->type);
+ if (fxi == NULL) {
+ return;
+ }
+
+ writestruct_id(wd, DATA, fxi->struct_name, 1, fx);
+ }
+}
+
static void write_object(WriteData *wd, Object *ob)
{
if (ob->id.us > 0 || wd->use_memfile) {
@@ -1860,6 +1921,8 @@ static void write_object(WriteData *wd, Object *ob)
write_particlesystems(wd, &ob->particlesystem);
write_modifiers(wd, &ob->modifiers);
+ write_gpencil_modifiers(wd, &ob->greasepencil_modifiers);
+ write_shaderfxs(wd, &ob->shader_fx);
writelist(wd, DATA, LinkData, &ob->pc_ids);
writelist(wd, DATA, LodLevel, &ob->lodlevels);
@@ -2278,6 +2341,11 @@ static void write_material(WriteData *wd, Material *ma)
}
write_previews(wd, ma->preview);
+
+ /* grease pencil settings */
+ if (ma->gp_style) {
+ writestruct(wd, DATA, MaterialGPencilStyle, 1, ma->gp_style);
+ }
}
}
@@ -2481,24 +2549,18 @@ static void write_scene(WriteData *wd, Scene *sce)
writestruct(wd, DATA, UvSculpt, 1, tos->uvsculpt);
write_paint(wd, &tos->uvsculpt->paint);
}
- /* write grease-pencil drawing brushes to file */
- writelist(wd, DATA, bGPDbrush, &tos->gp_brushes);
- for (bGPDbrush *brush = tos->gp_brushes.first; brush; brush = brush->next) {
- if (brush->cur_sensitivity) {
- write_curvemapping(wd, brush->cur_sensitivity);
- }
- if (brush->cur_strength) {
- write_curvemapping(wd, brush->cur_strength);
- }
- if (brush->cur_jitter) {
- write_curvemapping(wd, brush->cur_jitter);
- }
+ if (tos->gp_paint) {
+ writestruct(wd, DATA, GpPaint, 1, tos->gp_paint);
+ write_paint(wd, &tos->gp_paint->paint);
}
/* write grease-pencil custom ipo curve to file */
if (tos->gp_interpolate.custom_ipo) {
write_curvemapping(wd, tos->gp_interpolate.custom_ipo);
}
-
+ /* write grease-pencil multiframe falloff curve to file */
+ if (tos->gp_sculpt.cur_falloff) {
+ write_curvemapping(wd, tos->gp_sculpt.cur_falloff);
+ }
write_paint(wd, &tos->imapaint.paint);
@@ -2672,6 +2734,8 @@ static void write_gpencil(WriteData *wd, bGPdata *gpd)
write_animdata(wd, gpd->adt);
}
+ writedata(wd, DATA, sizeof(void *) * gpd->totcol, gpd->mat);
+
/* write grease-pencil layers to file */
writelist(wd, DATA, bGPDlayer, &gpd->layers);
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -2682,15 +2746,10 @@ static void write_gpencil(WriteData *wd, bGPdata *gpd)
writelist(wd, DATA, bGPDstroke, &gpf->strokes);
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
writestruct(wd, DATA, bGPDspoint, gps->totpoints, gps->points);
+ write_dverts(wd, gps->totpoints, gps->dvert);
}
}
}
-
- /* write grease-pencil palettes */
- writelist(wd, DATA, bGPDpalette, &gpd->palettes);
- for (bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) {
- writelist(wd, DATA, bGPDpalettecolor, &palette->colors);
- }
}
}
@@ -3177,6 +3236,20 @@ static void write_brush(WriteData *wd, Brush *brush)
if (brush->curve) {
write_curvemapping(wd, brush->curve);
}
+
+ if (brush->gpencil_settings) {
+ writestruct(wd, DATA, BrushGpencilSettings, 1, brush->gpencil_settings);
+
+ if (brush->gpencil_settings->curve_sensitivity) {
+ write_curvemapping(wd, brush->gpencil_settings->curve_sensitivity);
+ }
+ if (brush->gpencil_settings->curve_strength) {
+ write_curvemapping(wd, brush->gpencil_settings->curve_strength);
+ }
+ if (brush->gpencil_settings->curve_jitter) {
+ write_curvemapping(wd, brush->gpencil_settings->curve_jitter);
+ }
+ }
if (brush->gradient) {
writestruct(wd, DATA, ColorBand, 1, brush->gradient);
}
@@ -3704,7 +3777,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
FileGlobal fg;
bScreen *screen;
Scene *scene;
- ViewLayer *render_layer;
+ ViewLayer *view_layer;
char subvstr[8];
/* prevent mem checkers from complaining */
@@ -3713,12 +3786,12 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
memset(fg.build_hash, 0, sizeof(fg.build_hash));
fg.pad1 = NULL;
- current_screen_compat(mainvar, is_undo, &screen, &scene, &render_layer);
+ current_screen_compat(mainvar, is_undo, &screen, &scene, &view_layer);
/* XXX still remap G */
fg.curscreen = screen;
fg.curscene = scene;
- fg.cur_view_layer = render_layer;
+ fg.cur_view_layer = view_layer;
/* prevent to save this, is not good convention, and feature with concerns... */
fg.fileflags = (fileflags & ~G_FILE_FLAGS_RUNTIME);