Blender Git Commit Log

Git Commits -> Revision ff3d535

Revision ff3d535 by Bastien Montagne (master)
July 21, 2015, 10:02 (GMT)
Fix T45471: Blend file: Bad old_addr handling in mesh's customdata writing.

Issue is rather well explained in T45471: our current customdata writing code easily generates several different blocks in blend file with same 'old' address. This is bad, because those addresses are used as 'uid' during reading process (it kind of work in Blender's own reading process, by mere luck mostly, but breaks the file specs).

Solution (suggested by Campbell, thanks) implemented by this patch is to avoid duplicating everything, and instead just overwrite what we needs to skip some cdlayers on write:
* the CustomData's `totlayer` number;
* the CustomData's `layers` array of CustomDataLayer (keeping its original address using the `writestruct_at_address` helper).

New design allows us to get completely rid of the no_free flag stuff in `write_customdata()`.

Note that this implies written data is **not** directly valid from Blend PoV, since its written typemap does not match written layers (this is not an issue because typemap is rebuilt on read anyway - and it's easy to fix this if really needed).

Also, the backward compatibility saving of mface data remains an issue here, see comment in code.

Reviewers: sergey, campbellbarton

Projects: #bf_blender

Maniphest Tasks: T45471

Differential Revision: https://developer.blender.org/D1425

Commit Details:

Full Hash: ff3d535bc2a63092357533acbe7289556af956a0
Parent Commit: b91d64a
Lines Changed: +121, -58

4 Modified Paths:

/source/blender/blenkernel/BKE_customdata.h (+3, -0) (Diff)
/source/blender/blenkernel/intern/customdata.c (+50, -0) (Diff)
/source/blender/blenloader/intern/writefile.c (+66, -58) (Diff)
/source/blender/makesdna/DNA_customdata_types.h (+2, -0) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021