Page MenuHome

Blend file: Fix T45471: Bad old_addr handling in mesh's customdata writing.
ClosedPublic

Authored by Bastien Montagne (mont29) on Jul 20 2015, 9:13 PM.

Details

Summary

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.

Diff Detail

Repository
rB Blender
Branch
arcpatch-D1425

Event Timeline

Bastien Montagne (mont29) retitled this revision from to Blend file: Fix T45471: Bad old_addr handling in mesh's customdata writing..
Bastien Montagne (mont29) updated this object.
Bastien Montagne (mont29) set the repository for this revision to rB Blender.
Campbell Barton (campbellbarton) requested changes to this revision.Jul 21 2015, 10:10 AM
Campbell Barton (campbellbarton) edited edge metadata.
Campbell Barton (campbellbarton) added inline comments.
source/blender/blenkernel/intern/customdata.c
3217

Is this 128 linking to the one in writefile.c? - could make define and put in header instead.

source/blender/blenloader/intern/writefile.c
1973–1978

not C89 compat, (layers_size should be a define)

1996–2000

slight preference for doxygen comments, if text formatting used at all. - for dot-points, we use same for rst... though this is very picky & not really important.

http://www.stack.nl/~dimitri/doxygen/manual/lists.html

This revision now requires changes to proceed.Jul 21 2015, 10:11 AM
Bastien Montagne (mont29) edited edge metadata.

Minor tweaks and fixes from review.

Bastien Montagne (mont29) marked 3 inline comments as done.Jul 21 2015, 10:29 AM
Campbell Barton (campbellbarton) edited edge metadata.

Asside from updates to writing legacy format, seems fine.

source/blender/blenkernel/intern/customdata.c
3207–3211

For doxy use /** at block start, also can use \warning, \return *r_write_layers can be \param r_write_layers.

This revision is now accepted and ready to land.Jul 21 2015, 10:58 AM
This revision was automatically updated to reflect the committed changes.