I think understand that the bpy.context.space_data.clip_start value can impact performance if set too low on large scenes, and possibly cause artefacts if zoomed too far from meshes.
I was thinking I could automatically set this based on the darkest pixel of the material preview’s mist pass (even if not in material preview mode currently). So if you’re zoomed very close to an object the darkest pixel would be very dark so the clip start value would be very low, whereas if you zoom out far from all geometry, then all pixels would be quite bright, so the clip start could be set high.
the mist pass depth and clip end could be determined by the bouding box size of the scene.
What’s the best way to access the mist pass data without it actually being visible, or maybe there’s a more efficient way of generating the data?