Page MenuHome

Make .blend file thumbnail reading simpler and more coherent, read/store them when reading in background mode, and allow user to define custom thumbnails.
ClosedPublic

Authored by Bastien Montagne (mont29) on Aug 17 2015, 5:41 PM.

Details

Summary

Primary goal of this commit is to fix an annoying issue - when processing and saving .blend
files in background mode you lose their thumbnails, since it can only be generated with
an OpenGL context.

Solution to that is to read .blend thumbnail while reading .blend file (only done in background
mode currently), and store it in Main struct.

Also, this lead to removing .blend file reading code from thumb_blend (no need to have doublons,
and always hated that piece of unreadable geeky code there anyway). We now have a small
interface in regular reading code area, which keeps it reasonbaly light by only reading/parsing
header info, and first few BHead blocks.

This makes code reading .blend thumbnail about 3 to 4 times slower than previous highly specialized
one in blend_thumb.c, but overall thumbnail generation of a big .blend files folder only grows
of about 1%, think we can bare with it.

Finally, since thumbnail is now optionally stored in Main struct, it makes it easy to allow user
to define their own custom one (instead of auto-generated one), either by generating it from a
specific scene, or giving it a raw array of pixels.

Diff Detail

Repository
rB Blender

Event Timeline

Bastien Montagne (mont29) retitled this revision from to Make .blend file thumbnail reading simpler and more coherent, read/store them when reading in background mode, and allow user to define custom thumbnails..
Bastien Montagne (mont29) updated this object.

Updated from latest master...

Updated against latest master...

Updated against latest master...

  • Remove RNA thumbnails API for now - we have to rethink a bit 'metadata' access for .blend file.
  • Change file thumbnail into a struct (we pack pixel data after the struct).
source/blender/blenkernel/BKE_library.h
41

*picky*, should be BlendThumbnail, since we have BlendHandle, BlendFileData... etc?

source/blender/blenkernel/BKE_main.h
57

would add char pixels[0], for nicer access. Avoids weirdo memcpy offsets later on.

source/blender/blenloader/BLO_readfile.h
285–286

Convention within blender/source is to use backslash for doxy (even a few lines above...)

Bastien Montagne (mont29) marked 3 inline comments as done.Aug 27 2015, 3:51 PM

Thanks for review, points addressed. :)

  • Some minor cleanup & enhancements from Campbell's review, thanks.
This revision was automatically updated to reflect the committed changes.