//TODO: @Investigate: What if multiple delegates are bound to the same event? public void InvokeVertexLayoutGeneration() { // Base vertex geometry VertexLayouts[0] = CallVertexLayoutGeneration.Invoke(); VertexPreEffectsLayouts[0] = CallVertexLayoutGeneration.Invoke(); // Instancing data i.e. position, view matrices var instancingEventKeys = InstancingEventHandlerKeys.GetKeys(); var flagIndex = InstancingDataFlags.GetArrayIndexForFlag(InstancingDataFlag); if (flagIndex >= 0) { var instancingEventKey = instancingEventKeys[flagIndex]; var instancingVertexInstanceDeletegate = (VertexInstanceLayoutGenerationList[instancingEventKey] as Func <VertexLayoutDescription>); VertexLayouts[flagIndex + 1] = instancingVertexInstanceDeletegate.Invoke(); } // Instancing effects data var preEffectsEventKeys = PreEffectEventHandlerKeys.GetKeys(); var preEffectsflagIndex = RenderFlags.GetPreEffectArrayIndexForFlag(PreEffectsInstancingFlag); if (preEffectsflagIndex >= 0) { var preEffectsEventKey = preEffectsEventKeys[preEffectsflagIndex]; var vertexInstanceDeletegate = (VertexPreEffectsInstanceLayoutGenerationList[preEffectsEventKey] as Func <VertexLayoutDescription>); VertexPreEffectsLayouts[preEffectsflagIndex + 1] = vertexInstanceDeletegate.Invoke(); } }
public void AddVertexInstanceDelegate(uint instancingFlag, Func <VertexLayoutDescription> vertexLayoutDelegate) { var flagIndex = InstancingDataFlags.GetArrayIndexForFlag(PreEffectsInstancingFlag); VertexInstanceLayoutGenerationList.AddHandler(InstancingEventHandlerKeys.GetKeys()[flagIndex], vertexLayoutDelegate); }