diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index f92b3cf7a07..69e87fc2495 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -1327,14 +1327,22 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id) /* link metastack, slight abuse of structs here, * have to restore pointer to internal part in struct */ { - Sequence temp; void *seqbase_poin; void *channels_poin; - intptr_t seqbase_offset; - intptr_t channels_offset; - - seqbase_offset = intptr_t(&(temp).seqbase) - intptr_t(&temp); - channels_offset = intptr_t(&(temp).channels) - intptr_t(&temp); + /* This whole thing with seqbasep offsets is really not good + * and prevents changes to the Sequence struct. A more correct approach + * would be to calculate offset using sDNA from the file (NOT from the + * current Blender). Even better would be having some sort of dedicated + * map of seqbase pointers to avoid this offset magic. */ + constexpr intptr_t seqbase_offset = offsetof(Sequence, seqbase); + constexpr intptr_t channels_offset = offsetof(Sequence, channels); +#if ARCH_CPU_64_BITS + static_assert(seqbase_offset == 264, "Sequence seqbase member offset cannot be changed"); + static_assert(channels_offset == 280, "Sequence channels member offset cannot be changed"); +#else + static_assert(seqbase_offset == 204, "Sequence seqbase member offset cannot be changed"); + static_assert(channels_offset == 212, "Sequence channels member offset cannot be changed"); +#endif /* seqbase root pointer */ if (ed->seqbasep == old_seqbasep) { diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index ac6058a96fd..ca955f60368 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -231,6 +231,11 @@ typedef struct Sequence { /* pointers for effects: */ struct Sequence *seq1, *seq2; + /* This strange padding is needed due to how seqbasep deserialization is + * done right now in #scene_blend_read_data. */ + void *_pad7; + int _pad8[2]; + /** List of strips for meta-strips. */ ListBase seqbase; ListBase channels; /* SeqTimelineChannel */ @@ -289,6 +294,7 @@ typedef struct Sequence { float speed_factor; struct SeqRetimingKey *retiming_keys; + void *_pad5; int retiming_keys_num; char _pad6[4];