google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.7k stars 1.87k forks source link

don't rely on FMaterialInstance having a default ctor #7781

Closed pixelflinger closed 5 months ago

pixelflinger commented 5 months ago

FMaterialInstance needed a default ctor because it is a field of FMaterial but cannot be initialized before FMaterial itself is initialized. So we had a defautl ctor and we'd finish the initialization later. Conceptually the default material instance should have been new'ed and a pointer to it stored instead.

That's basically what we do now, but to avoid the extra allocation, we in-place new and delete the default material instance into an aligned_storage inside FMaterial.