Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/readfile.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_lightprobe_types.h" | #include "DNA_lightprobe_types.h" | ||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| #include "DNA_text_types.h" | #include "DNA_text_types.h" | ||||
| #include "DNA_view3d_types.h" | #include "DNA_view3d_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_sdna_types.h" | #include "DNA_sdna_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_sequence_types.h" | #include "DNA_sequence_types.h" | ||||
| #include "DNA_smoke_types.h" | #include "DNA_fluid_types.h" | ||||
| #include "DNA_speaker_types.h" | #include "DNA_speaker_types.h" | ||||
| #include "DNA_sound_types.h" | #include "DNA_sound_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_vfont_types.h" | #include "DNA_vfont_types.h" | ||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "DNA_movieclip_types.h" | #include "DNA_movieclip_types.h" | ||||
| #include "DNA_mask_types.h" | #include "DNA_mask_types.h" | ||||
| ▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | |||||
| # define DEBUG_PRINTF(...) printf(__VA_ARGS__) | # define DEBUG_PRINTF(...) printf(__VA_ARGS__) | ||||
| #else | #else | ||||
| # define DEBUG_PRINTF(...) | # define DEBUG_PRINTF(...) | ||||
| #endif | #endif | ||||
| /* local prototypes */ | /* local prototypes */ | ||||
| static void read_libraries(FileData *basefd, ListBase *mainlist); | static void read_libraries(FileData *basefd, ListBase *mainlist); | ||||
| static void *read_struct(FileData *fd, BHead *bh, const char *blockname); | static void *read_struct(FileData *fd, BHead *bh, const char *blockname); | ||||
| static void direct_link_modifiers(FileData *fd, ListBase *lb); | static void direct_link_modifiers(FileData *fd, ListBase *lb, const Object *ob); | ||||
| static BHead *find_bhead_from_code_name(FileData *fd, const short idcode, const char *name); | static BHead *find_bhead_from_code_name(FileData *fd, const short idcode, const char *name); | ||||
| static BHead *find_bhead_from_idname(FileData *fd, const char *idname); | static BHead *find_bhead_from_idname(FileData *fd, const char *idname); | ||||
| #ifdef USE_COLLECTION_COMPAT_28 | #ifdef USE_COLLECTION_COMPAT_28 | ||||
| static void expand_scene_collection(FileData *fd, Main *mainvar, SceneCollection *sc); | static void expand_scene_collection(FileData *fd, Main *mainvar, SceneCollection *sc); | ||||
| #endif | #endif | ||||
| static void direct_link_animdata(FileData *fd, AnimData *adt); | static void direct_link_animdata(FileData *fd, AnimData *adt); | ||||
| static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt); | static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt); | ||||
| ▲ Show 20 Lines • Show All 4,380 Lines • ▼ Show 20 Lines | if (part->id.tag & LIB_TAG_NEED_LINK) { | ||||
| IDP_LibLinkProperty(part->id.properties, fd); | IDP_LibLinkProperty(part->id.properties, fd); | ||||
| lib_link_animdata(fd, &part->id, part->adt); | lib_link_animdata(fd, &part->id, part->adt); | ||||
| part->ipo = newlibadr_us( | part->ipo = newlibadr_us( | ||||
| fd, part->id.lib, part->ipo); // XXX deprecated - old animation system | fd, part->id.lib, part->ipo); // XXX deprecated - old animation system | ||||
| part->instance_object = newlibadr(fd, part->id.lib, part->instance_object); | part->instance_object = newlibadr(fd, part->id.lib, part->instance_object); | ||||
| part->instance_collection = newlibadr_us(fd, part->id.lib, part->instance_collection); | part->instance_collection = newlibadr_us(fd, part->id.lib, part->instance_collection); | ||||
| part->eff_group = newlibadr(fd, part->id.lib, part->eff_group); | part->force_group = newlibadr(fd, part->id.lib, part->force_group); | ||||
| part->bb_ob = newlibadr(fd, part->id.lib, part->bb_ob); | part->bb_ob = newlibadr(fd, part->id.lib, part->bb_ob); | ||||
| part->collision_group = newlibadr(fd, part->id.lib, part->collision_group); | part->collision_group = newlibadr(fd, part->id.lib, part->collision_group); | ||||
| lib_link_partdeflect(fd, &part->id, part->pd); | lib_link_partdeflect(fd, &part->id, part->pd); | ||||
| lib_link_partdeflect(fd, &part->id, part->pd2); | lib_link_partdeflect(fd, &part->id, part->pd2); | ||||
| if (part->effector_weights) { | if (part->effector_weights) { | ||||
| part->effector_weights->group = newlibadr(fd, part->id.lib, part->effector_weights->group); | part->effector_weights->group = newlibadr(fd, part->id.lib, part->effector_weights->group); | ||||
| } | } | ||||
| else { | else { | ||||
| part->effector_weights = BKE_effector_add_weights(part->eff_group); | part->effector_weights = BKE_effector_add_weights(part->force_group); | ||||
| } | } | ||||
| if (part->instance_weights.first && part->instance_collection) { | if (part->instance_weights.first && part->instance_collection) { | ||||
| for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) { | for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) { | ||||
| dw->ob = newlibadr(fd, part->id.lib, dw->ob); | dw->ob = newlibadr(fd, part->id.lib, dw->ob); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | static void direct_link_particlesettings(FileData *fd, ParticleSettings *part) | ||||
| } | } | ||||
| part->twistcurve = newdataadr(fd, part->twistcurve); | part->twistcurve = newdataadr(fd, part->twistcurve); | ||||
| if (part->twistcurve) { | if (part->twistcurve) { | ||||
| direct_link_curvemapping(fd, part->twistcurve); | direct_link_curvemapping(fd, part->twistcurve); | ||||
| } | } | ||||
| part->effector_weights = newdataadr(fd, part->effector_weights); | part->effector_weights = newdataadr(fd, part->effector_weights); | ||||
| if (!part->effector_weights) { | if (!part->effector_weights) { | ||||
| part->effector_weights = BKE_effector_add_weights(part->eff_group); | part->effector_weights = BKE_effector_add_weights(part->force_group); | ||||
| } | } | ||||
| link_list(fd, &part->instance_weights); | link_list(fd, &part->instance_weights); | ||||
| part->boids = newdataadr(fd, part->boids); | part->boids = newdataadr(fd, part->boids); | ||||
| part->fluid = newdataadr(fd, part->fluid); | part->fluid = newdataadr(fd, part->fluid); | ||||
| if (part->boids) { | if (part->boids) { | ||||
| ▲ Show 20 Lines • Show All 626 Lines • ▼ Show 20 Lines | #endif | ||||
| if (fluidmd && fluidmd->fss) { | if (fluidmd && fluidmd->fss) { | ||||
| fluidmd->fss->ipo = newlibadr_us( | fluidmd->fss->ipo = newlibadr_us( | ||||
| fd, ob->id.lib, fluidmd->fss->ipo); // XXX deprecated - old animation system | fd, ob->id.lib, fluidmd->fss->ipo); // XXX deprecated - old animation system | ||||
| } | } | ||||
| } | } | ||||
| { | { | ||||
| SmokeModifierData *smd = (SmokeModifierData *)modifiers_findByType(ob, | FluidModifierData *mmd = (FluidModifierData *)modifiers_findByType(ob, | ||||
| eModifierType_Smoke); | eModifierType_Fluid); | ||||
| if (smd && (smd->type == MOD_SMOKE_TYPE_DOMAIN) && smd->domain) { | if (mmd && (mmd->type == MOD_FLUID_TYPE_DOMAIN) && mmd->domain) { | ||||
| /* Flag for refreshing the simulation after loading. */ | /* Flag for refreshing the simulation after loading */ | ||||
| smd->domain->flags |= MOD_SMOKE_FILE_LOAD; | mmd->domain->flags |= FLUID_DOMAIN_FILE_LOAD; | ||||
| } | } | ||||
| } | } | ||||
| /* texture field */ | /* texture field */ | ||||
| if (ob->pd) { | if (ob->pd) { | ||||
| lib_link_partdeflect(fd, &ob->id, ob->pd); | lib_link_partdeflect(fd, &ob->id, ob->pd); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { | ||||
| BKE_pose_channel_runtime_reset(&pchan->runtime); | BKE_pose_channel_runtime_reset(&pchan->runtime); | ||||
| } | } | ||||
| pose->ikdata = NULL; | pose->ikdata = NULL; | ||||
| if (pose->ikparam != NULL) { | if (pose->ikparam != NULL) { | ||||
| pose->ikparam = newdataadr(fd, pose->ikparam); | pose->ikparam = newdataadr(fd, pose->ikparam); | ||||
| } | } | ||||
| } | } | ||||
| static void direct_link_modifiers(FileData *fd, ListBase *lb) | static void direct_link_modifiers(FileData *fd, ListBase *lb, const Object *ob) | ||||
| { | { | ||||
| ModifierData *md; | ModifierData *md; | ||||
| link_list(fd, lb); | link_list(fd, lb); | ||||
| for (md = lb->first; md; md = md->next) { | for (md = lb->first; md; md = md->next) { | ||||
| md->error = NULL; | md->error = NULL; | ||||
| md->runtime = NULL; | md->runtime = NULL; | ||||
| if (md->type == eModifierType_Fluidsim) { | |||||
| blo_reportf_wrap( | |||||
| fd->reports, | |||||
| RPT_WARNING, | |||||
| TIP_( | |||||
| "Possible data loss when saving this file! %s modifier is deprecated (Object: %s)."), | |||||
| md->name, | |||||
| ob->id.name + 2); | |||||
| } | |||||
| else if (md->type == eModifierType_Smoke) { | |||||
| blo_reportf_wrap( | |||||
| fd->reports, | |||||
| RPT_WARNING, | |||||
| TIP_( | |||||
| "Possible data loss when saving this file! %s modifier is deprecated (Object: %s)."), | |||||
| md->name, | |||||
| ob->id.name + 2); | |||||
| } | |||||
| /* if modifiers disappear, or for upward compatibility */ | /* if modifiers disappear, or for upward compatibility */ | ||||
| if (NULL == modifierType_getInfo(md->type)) { | if (NULL == modifierType_getInfo(md->type)) { | ||||
| md->type = eModifierType_None; | md->type = eModifierType_None; | ||||
| } | } | ||||
| if (md->type == eModifierType_Subsurf) { | if (md->type == eModifierType_Subsurf) { | ||||
| SubsurfModifierData *smd = (SubsurfModifierData *)md; | SubsurfModifierData *smd = (SubsurfModifierData *)md; | ||||
| Show All 26 Lines | else if (md->type == eModifierType_Cloth) { | ||||
| if (!clmd->sim_parms->effector_weights) { | if (!clmd->sim_parms->effector_weights) { | ||||
| clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL); | clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL); | ||||
| } | } | ||||
| } | } | ||||
| clmd->solver_result = NULL; | clmd->solver_result = NULL; | ||||
| } | } | ||||
| else if (md->type == eModifierType_Fluidsim) { | else if (md->type == eModifierType_Fluid) { | ||||
| FluidsimModifierData *fluidmd = (FluidsimModifierData *)md; | |||||
| fluidmd->fss = newdataadr(fd, fluidmd->fss); | FluidModifierData *mmd = (FluidModifierData *)md; | ||||
| if (fluidmd->fss) { | |||||
| fluidmd->fss->fmd = fluidmd; | |||||
| fluidmd->fss->meshVelocities = NULL; | |||||
| } | |||||
| } | |||||
| else if (md->type == eModifierType_Smoke) { | |||||
| SmokeModifierData *smd = (SmokeModifierData *)md; | |||||
| if (smd->type == MOD_SMOKE_TYPE_DOMAIN) { | if (mmd->type == MOD_FLUID_TYPE_DOMAIN) { | ||||
| smd->flow = NULL; | mmd->flow = NULL; | ||||
| smd->coll = NULL; | mmd->effector = NULL; | ||||
| smd->domain = newdataadr(fd, smd->domain); | mmd->domain = newdataadr(fd, mmd->domain); | ||||
| smd->domain->smd = smd; | mmd->domain->mmd = mmd; | ||||
| smd->domain->fluid = NULL; | mmd->domain->fluid = NULL; | ||||
| smd->domain->fluid_mutex = BLI_rw_mutex_alloc(); | mmd->domain->fluid_mutex = BLI_rw_mutex_alloc(); | ||||
| smd->domain->wt = NULL; | mmd->domain->tex = NULL; | ||||
| smd->domain->shadow = NULL; | mmd->domain->tex_shadow = NULL; | ||||
| smd->domain->tex = NULL; | mmd->domain->tex_flame = NULL; | ||||
| smd->domain->tex_shadow = NULL; | mmd->domain->tex_flame_coba = NULL; | ||||
| smd->domain->tex_flame = NULL; | mmd->domain->tex_coba = NULL; | ||||
| smd->domain->tex_flame_coba = NULL; | mmd->domain->tex_field = NULL; | ||||
| smd->domain->tex_coba = NULL; | mmd->domain->tex_velocity_x = NULL; | ||||
| smd->domain->tex_field = NULL; | mmd->domain->tex_velocity_y = NULL; | ||||
| smd->domain->tex_velocity_x = NULL; | mmd->domain->tex_velocity_z = NULL; | ||||
| smd->domain->tex_velocity_y = NULL; | mmd->domain->tex_wt = NULL; | ||||
| smd->domain->tex_velocity_z = NULL; | mmd->domain->mesh_velocities = NULL; | ||||
| smd->domain->tex_wt = NULL; | mmd->domain->coba = newdataadr(fd, mmd->domain->coba); | ||||
| smd->domain->coba = newdataadr(fd, smd->domain->coba); | |||||
| mmd->domain->effector_weights = newdataadr(fd, mmd->domain->effector_weights); | |||||
| smd->domain->effector_weights = newdataadr(fd, smd->domain->effector_weights); | if (!mmd->domain->effector_weights) { | ||||
| if (!smd->domain->effector_weights) { | mmd->domain->effector_weights = BKE_effector_add_weights(NULL); | ||||
| smd->domain->effector_weights = BKE_effector_add_weights(NULL); | |||||
| } | } | ||||
| direct_link_pointcache_list( | direct_link_pointcache_list( | ||||
| fd, &(smd->domain->ptcaches[0]), &(smd->domain->point_cache[0]), 1); | fd, &(mmd->domain->ptcaches[0]), &(mmd->domain->point_cache[0]), 1); | ||||
| /* Smoke uses only one cache from now on, so store pointer convert */ | /* Manta sim uses only one cache from now on, so store pointer convert */ | ||||
| if (smd->domain->ptcaches[1].first || smd->domain->point_cache[1]) { | if (mmd->domain->ptcaches[1].first || mmd->domain->point_cache[1]) { | ||||
| if (smd->domain->point_cache[1]) { | if (mmd->domain->point_cache[1]) { | ||||
| PointCache *cache = newdataadr(fd, smd->domain->point_cache[1]); | PointCache *cache = newdataadr(fd, mmd->domain->point_cache[1]); | ||||
| if (cache->flag & PTCACHE_FAKE_SMOKE) { | if (cache->flag & PTCACHE_FAKE_SMOKE) { | ||||
| /* Smoke was already saved in "new format" and this cache is a fake one. */ | /* Mantasim / smoke was already saved in "new format" and this cache is a fake one. | ||||
| */ | |||||
| } | } | ||||
| else { | else { | ||||
| printf( | printf( | ||||
| "High resolution smoke cache not available due to pointcache update. Please " | "High resolution manta cache not available due to pointcache update. Please " | ||||
| "reset the simulation.\n"); | "reset the simulation.\n"); | ||||
| } | } | ||||
| BKE_ptcache_free(cache); | BKE_ptcache_free(cache); | ||||
| } | } | ||||
| BLI_listbase_clear(&smd->domain->ptcaches[1]); | BLI_listbase_clear(&mmd->domain->ptcaches[1]); | ||||
| smd->domain->point_cache[1] = NULL; | mmd->domain->point_cache[1] = NULL; | ||||
| } | } | ||||
| } | } | ||||
| else if (smd->type == MOD_SMOKE_TYPE_FLOW) { | else if (mmd->type == MOD_FLUID_TYPE_FLOW) { | ||||
| smd->domain = NULL; | mmd->domain = NULL; | ||||
| smd->coll = NULL; | mmd->effector = NULL; | ||||
| smd->flow = newdataadr(fd, smd->flow); | mmd->flow = newdataadr(fd, mmd->flow); | ||||
| smd->flow->smd = smd; | mmd->flow->mmd = mmd; | ||||
| smd->flow->mesh = NULL; | mmd->flow->mesh = NULL; | ||||
| smd->flow->verts_old = NULL; | mmd->flow->verts_old = NULL; | ||||
| smd->flow->numverts = 0; | mmd->flow->numverts = 0; | ||||
| smd->flow->psys = newdataadr(fd, smd->flow->psys); | mmd->flow->psys = newdataadr(fd, mmd->flow->psys); | ||||
| } | } | ||||
| else if (smd->type == MOD_SMOKE_TYPE_COLL) { | else if (mmd->type == MOD_FLUID_TYPE_EFFEC) { | ||||
| smd->flow = NULL; | mmd->flow = NULL; | ||||
| smd->domain = NULL; | mmd->domain = NULL; | ||||
| smd->coll = newdataadr(fd, smd->coll); | mmd->effector = newdataadr(fd, mmd->effector); | ||||
| if (smd->coll) { | if (mmd->effector) { | ||||
| smd->coll->smd = smd; | mmd->effector->mmd = mmd; | ||||
| smd->coll->verts_old = NULL; | mmd->effector->verts_old = NULL; | ||||
| smd->coll->numverts = 0; | mmd->effector->numverts = 0; | ||||
| smd->coll->mesh = NULL; | mmd->effector->mesh = NULL; | ||||
| } | } | ||||
| else { | else { | ||||
| smd->type = 0; | mmd->type = 0; | ||||
| smd->flow = NULL; | mmd->flow = NULL; | ||||
| smd->domain = NULL; | mmd->domain = NULL; | ||||
| smd->coll = NULL; | mmd->effector = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (md->type == eModifierType_DynamicPaint) { | else if (md->type == eModifierType_DynamicPaint) { | ||||
| DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; | DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; | ||||
| if (pmd->canvas) { | if (pmd->canvas) { | ||||
| pmd->canvas = newdataadr(fd, pmd->canvas); | pmd->canvas = newdataadr(fd, pmd->canvas); | ||||
| ▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | static void direct_link_object(FileData *fd, Object *ob) | ||||
| link_list(fd, &ob->constraintChannels); | link_list(fd, &ob->constraintChannels); | ||||
| // >>> XXX deprecated - old animation system | // >>> XXX deprecated - old animation system | ||||
| ob->mat = newdataadr(fd, ob->mat); | ob->mat = newdataadr(fd, ob->mat); | ||||
| test_pointer_array(fd, (void **)&ob->mat); | test_pointer_array(fd, (void **)&ob->mat); | ||||
| ob->matbits = newdataadr(fd, ob->matbits); | ob->matbits = newdataadr(fd, ob->matbits); | ||||
| /* do it here, below old data gets converted */ | /* do it here, below old data gets converted */ | ||||
| direct_link_modifiers(fd, &ob->modifiers); | direct_link_modifiers(fd, &ob->modifiers, ob); | ||||
| direct_link_gpencil_modifiers(fd, &ob->greasepencil_modifiers); | direct_link_gpencil_modifiers(fd, &ob->greasepencil_modifiers); | ||||
| direct_link_shaderfxs(fd, &ob->shader_fx); | direct_link_shaderfxs(fd, &ob->shader_fx); | ||||
| link_list(fd, &ob->effect); | link_list(fd, &ob->effect); | ||||
| paf = ob->effect.first; | paf = ob->effect.first; | ||||
| while (paf) { | while (paf) { | ||||
| if (paf->type == EFF_PARTICLE) { | if (paf->type == EFF_PARTICLE) { | ||||
| paf->keys = NULL; | paf->keys = NULL; | ||||
| ▲ Show 20 Lines • Show All 4,422 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSettings *part) | static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSettings *part) | ||||
| { | { | ||||
| int a; | int a; | ||||
| expand_doit(fd, mainvar, part->instance_object); | expand_doit(fd, mainvar, part->instance_object); | ||||
| expand_doit(fd, mainvar, part->instance_collection); | expand_doit(fd, mainvar, part->instance_collection); | ||||
| expand_doit(fd, mainvar, part->eff_group); | expand_doit(fd, mainvar, part->force_group); | ||||
| expand_doit(fd, mainvar, part->bb_ob); | expand_doit(fd, mainvar, part->bb_ob); | ||||
| expand_doit(fd, mainvar, part->collision_group); | expand_doit(fd, mainvar, part->collision_group); | ||||
| if (part->adt) { | if (part->adt) { | ||||
| expand_animdata(fd, mainvar, part->adt); | expand_animdata(fd, mainvar, part->adt); | ||||
| } | } | ||||
| for (a = 0; a < MAX_MTEX; a++) { | for (a = 0; a < MAX_MTEX; a++) { | ||||
| ▲ Show 20 Lines • Show All 1,691 Lines • Show Last 20 Lines | |||||