So, I've got a subclass of ModelVisual3D that generates a 3d mesh, normals and triangle indices for a cylinder with subtractive voids and am doing some "low hanging fruits" optimizations.
One item I want to address is that the mesh is currently always generated twice (or more), unless it uses 100% default geometry values, because in order to guarantee the mesh is created before being shown on screen, I have to generate the default values before leaving the constructor.
I'd like to figure out a non-hack pattern to make the objects instantiate no more than once per time they are displayed on screen.
Thus far, I have implemented ISupportInitialize so that I can change multiple values without re-generating at each change, but that doesn't get rid of the initial generate in the constructor if it isn't needed.
Ideally, there would be some way I could execute code just before the ViewPort3D object tries to render it to lazily generate the mesh/indices just prior to rendering, thus guaranteeing a single generation per render. ModelVisual3D doesn't seem to have any hookable events or overridable events to do this. Ideas?
One item I want to address is that the mesh is currently always generated twice (or more), unless it uses 100% default geometry values, because in order to guarantee the mesh is created before being shown on screen, I have to generate the default values before leaving the constructor.
I'd like to figure out a non-hack pattern to make the objects instantiate no more than once per time they are displayed on screen.
Thus far, I have implemented ISupportInitialize so that I can change multiple values without re-generating at each change, but that doesn't get rid of the initial generate in the constructor if it isn't needed.
Ideally, there would be some way I could execute code just before the ViewPort3D object tries to render it to lazily generate the mesh/indices just prior to rendering, thus guaranteeing a single generation per render. ModelVisual3D doesn't seem to have any hookable events or overridable events to do this. Ideas?