Reduce the register pressure and branching in the switch() by using subclass and cast from void* to the base class. This ensures intersection functions are not inlined multiple times, bringing performance back. Alternative could be to avoid functions (they are quite large) but that only partially resolves the performance regression. Pull Request: https://projects.blender.org/blender/blender/pulls/136823