This call is still needed when loading editmesh because some operations
are not creating CD layer for new loops (like crating new face) and
to prevent loosing all sculpted data when running disps correct
displacement maps should be allocated on loading edit mesh.
Changed the create_vert_poly_map function to return a more compact
structure. Memory saved will vary depending on the mesh, but typically
it should be about one third of the old size.
Renamed the multiresModifier_update() function to
multires_modifier_update_mdisps() and made it visible to subsurf_ccg.c
so it can be called directly. No functional change, just a bit simpler.
This is called when adding a multiries modifier. BMesh MDisps have
only one loop's displacements rather than a full face's, so don't
multiply by number of corners here.
Previously the function took 'invert' and 'add' parameters to indicate
what operation should be performed on the displacements, replaced
these with three named modes: APPLY_DISPLACEMENTS, CALC_DISPLACEMENTS,
and ADD_DISPLACEMENTS.
- Removed validate() callback for MDisps layer. It wouldn't actually work
correct from CustomData layer and all needed data might be validated from
BMesh interpolation level. Also this callback was never actually used in
BMesh, so can't see why we'll want to have it in structures.
- Removed layrInterp_mdisps callback. Interpolation now happens from
another level (bmesh_interp) and this callback isn't needed anymore.
- Removed all function from multires.c which were used by old interpolation
stuff and seems to be useless for other usages.
- multires_topology_changed is still marked as a TODO, Probably it's not
needed anymore, buy better to keep for now until it'll be 100% clear this
function isn't needed and all needed re-allocations happens in bmesh_interp.
Otherwise, it'll be needed to be ported to new system.
- some merges added lines in multiple times
- removed some NULL checks that were only in bmesh
- enable cycles by default (was disabled because it used not to work)
- make formatting match
this means use of deprecated struct members gives a warning.
- makesdna.c preprocessor skips this.
- DNA_DEPRECATED_ALLOW is used so readfile.c can do versioning without warnings.
- this exposes some use of deprecated struct members, will deal with this after.
Enabled by default and also enabled for older filesm so
there should be no regressions.
In some cases it's useful to not use subdivided uvs for multires.
Removed the DerivedMesh face iterators (they sucked).
This should make subsurf faster. Also sped up multires
a bit (not sure if it's strictly correct, need to look
at it later).
=======================
Added option to baked named "Bake From Multires" which is avaliable for
normals baking and displacement baking.
If this option is enabled, then no additional hi-res meshes and render
structures would be created . This saves plenty of memory and meshes
with millions of faces could be successfully baked in few minutes.
Baking happens from highest level against viewport subdivision level,
so workflow is following:
- Set viewport level to level at which texture would be applied
during final rendering.
- Choose Displacement/Normals baking.
- Enable "Bake From Multires" option.
- You're ready to bake.
Displacement baker had aditional option named "Low Resolution Mesh".
This option is used to set if you want texture for realtime (games)
usage.
Internally it does the following:
- If it's disabled, displacement is calculated from subdivided
viewport level, so texture looks "smooth" (it's how default
baked works).
- If it's enabled, dispalcement is calculated against unsubdivided
viewport levels. This leads to "scales". This isn;t useful for
offline renders much, but very useful for creating game textures.
Special thanks to Morten Mikkelsen (aka sparky) for all mathematics
and other work he've done fr this patch!
Face's totdisp was set to correct value, but memory hasn't been
allocated for disps. Handle this in multires_topology_changed(),
so the whole MDISPS layer wouldn't be totally re-allocated when
applying displacement.