Instancing with geometry nodes uses just the evaluated Mesh, and ignores the
Object that it came from. That meant that it would try to look up the subsurf
modifier on the instancer object which does not have the subsurf modifier.
Instead of storing a session UUID and looking up the modifier data, store a
point to the subsurf modifier runtime data. Unlike the modifier data, this
runtime data is preserved across depsgraph CoW. It must be for the subdiv
descriptor contained in it to stay valid along with the draw cache.
As a bonus, this moves various Mesh_Runtime variables into the subsurf runtime
data, reducing memory usage for meshes not using subdivision surfaces.
This change is bigger than I would hope for 3.2.1, but I tried to carefully
keep existing behavior:
- mesh_wrapper_ensure_subdivision would call BKE_subsurf_modifier_ensure_runtime instead of just accessing the pointer. However we never need to allocate runtime data at this point, the subsurf mesh wrapper only gets setup after we have already allocated the runtime data in the subsurf modifier.
- calc_loop_normals and use_loop_normals are separate variables because they already were in the existing code. The former indicates if there is data mask asking for loop normals, and the latter if the subsurf modifier will interpolate them. Potentially we do not need to calc loop normals if they will not be interpolated, but leaving that unchanged for now.
- use_optimal_display now is affected by MOD_APPLY_TO_BASE_MESH, but this should make no difference as that's for applying modifiers and meshes generated for that purpose will not go to the draw code.