Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesdna/intern/dna_genfile.c
| Show First 20 Lines • Show All 304 Lines • ▼ Show 20 Lines | |||||
| /* ************************* READ DNA ********************** */ | /* ************************* READ DNA ********************** */ | ||||
| BLI_INLINE const char *pad_up_4(const char *ptr) | BLI_INLINE const char *pad_up_4(const char *ptr) | ||||
| { | { | ||||
| return (const char *)((((uintptr_t)ptr) + 3) & ~3); | return (const char *)((((uintptr_t)ptr) + 3) & ~3); | ||||
| } | } | ||||
| /* Hack to handle doversion of 2.8 files created between October 2016 and November 2017. */ | |||||
| #define TEMPORARY_280_DOVERSION | |||||
| /** | /** | ||||
| * In sdna->data the data, now we convert that to something understandable | * In sdna->data the data, now we convert that to something understandable | ||||
| */ | */ | ||||
| static bool init_structDNA( | static bool init_structDNA( | ||||
| SDNA *sdna, bool do_endian_swap, | SDNA *sdna, bool do_endian_swap, | ||||
| const char **r_error_message) | const char **r_error_message) | ||||
| { | { | ||||
| int *data, *verg, gravity_fix = -1; | int *data, *verg, gravity_fix = -1; | ||||
| Show All 33 Lines | if (*data == *verg) { | ||||
| data++; | data++; | ||||
| sdna->names = MEM_callocN(sizeof(void *) * sdna->nr_names, "sdnanames"); | sdna->names = MEM_callocN(sizeof(void *) * sdna->nr_names, "sdnanames"); | ||||
| } | } | ||||
| else { | else { | ||||
| *r_error_message = "NAME error in SDNA file"; | *r_error_message = "NAME error in SDNA file"; | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* Temporary DNA doversion for files that were created with Blender 2.80 | |||||
| * between October 2016, and November 2017. */ | |||||
| const bool doversion_280 = DNA_struct_elem_find( | |||||
| sdna, | |||||
| "Scene", | |||||
| "ListBase", | |||||
| "render_layers"); | |||||
| cp = (char *)data; | cp = (char *)data; | ||||
| for (int nr = 0; nr < sdna->nr_names; nr++) { | for (int nr = 0; nr < sdna->nr_names; nr++) { | ||||
| sdna->names[nr] = cp; | sdna->names[nr] = cp; | ||||
| /* "float gravity [3]" was parsed wrong giving both "gravity" and | /* "float gravity [3]" was parsed wrong giving both "gravity" and | ||||
| * "[3]" members. we rename "[3]", and later set the type of | * "[3]" members. we rename "[3]", and later set the type of | ||||
| * "gravity" to "void" so the offsets work out correct */ | * "gravity" to "void" so the offsets work out correct */ | ||||
| if (*cp == '[' && strcmp(cp, "[3]") == 0) { | if (*cp == '[' && strcmp(cp, "[3]") == 0) { | ||||
| if (nr && strcmp(sdna->names[nr - 1], "Cvi") == 0) { | if (nr && strcmp(sdna->names[nr - 1], "Cvi") == 0) { | ||||
| sdna->names[nr] = "gravity[3]"; | sdna->names[nr] = "gravity[3]"; | ||||
| gravity_fix = nr; | gravity_fix = nr; | ||||
| } | } | ||||
| } | } | ||||
| else if (doversion_280) { | |||||
| if (strcmp(cp, "*render_layer") == 0) { | |||||
| /* WorkSpace. */ | |||||
| sdna->names[nr] = "*view_layer"; | |||||
| } | |||||
| else if (strcmp(cp, "*scene_layer") == 0) { | |||||
| /* ParticleEditSettings. */ | |||||
| sdna->names[nr] = "*view_layer"; | |||||
| } | |||||
| else if (strcmp(cp, "render_layers") == 0) { | |||||
| /* Scene. */ | |||||
| sdna->names[nr] = "view_layers"; | |||||
| } | |||||
| else if (strcmp(cp, "active_layer") == 0) { | |||||
| /* Scene. */ | |||||
| sdna->names[nr] = "active_view_layer"; | |||||
| } | |||||
| else if (strcmp(cp, "*cur_render_layer") == 0) { | |||||
| /* FileGlobal. */ | |||||
| sdna->names[nr] = "*cur_view_layer"; | |||||
| } | |||||
| } | |||||
| while (*cp) cp++; | while (*cp) cp++; | ||||
| cp++; | cp++; | ||||
| } | } | ||||
| cp = pad_up_4(cp); | cp = pad_up_4(cp); | ||||
| /* load type names array */ | /* load type names array */ | ||||
| Show All 21 Lines | for (int nr = 0; nr < sdna->nr_types; nr++) { | ||||
| /* this is a patch, to change struct names without a conflict with SDNA */ | /* this is a patch, to change struct names without a conflict with SDNA */ | ||||
| /* be careful to use it, in this case for a system-struct (opengl/X) */ | /* be careful to use it, in this case for a system-struct (opengl/X) */ | ||||
| if (*cp == 'b') { | if (*cp == 'b') { | ||||
| /* struct Screen was already used by X, 'bScreen' replaces the old IrisGL 'Screen' struct */ | /* struct Screen was already used by X, 'bScreen' replaces the old IrisGL 'Screen' struct */ | ||||
| if (strcmp("bScreen", cp) == 0) sdna->types[nr] = cp + 1; | if (strcmp("bScreen", cp) == 0) sdna->types[nr] = cp + 1; | ||||
| } | } | ||||
| else if (doversion_280) { | |||||
| if (strcmp(cp, "SceneLayer") == 0) { | |||||
| sdna->types[nr] = "ViewLayer"; | |||||
| } | |||||
| else if (strcmp(cp, "SceneLayerEngineData") == 0) { | |||||
| sdna->types[nr] = "ViewLayerEngineData"; | |||||
| } | |||||
| } | |||||
| while (*cp) cp++; | while (*cp) cp++; | ||||
| cp++; | cp++; | ||||
| } | } | ||||
| cp = pad_up_4(cp); | cp = pad_up_4(cp); | ||||
| /* load typelen array */ | /* load typelen array */ | ||||
| ▲ Show 20 Lines • Show All 922 Lines • Show Last 20 Lines | |||||