Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
MeshRenderExtensions.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 
5 namespace SiliconStudio.Paradox.Effects
6 {
7  internal static class MeshRenderExtensions
8  {
9  internal static ModelRendererState GetModelRendererState(this RenderPass pass)
10  {
11  return GetOrCreateModelRendererState(pass, false);
12  }
13 
14  internal static ModelRendererState GetOrCreateModelRendererState(this RenderPass pass, bool createMeshStateIfNotFound = true)
15  {
16  var pipeline = pass.Pipeline;
17  if (pipeline == null)
18  {
19  throw new ArgumentException("RenderPass is not associated with a RenderPipeline", "pass");
20  }
21  var pipelineState = pipeline.Tags.Get(ModelRendererState.Key);
22  if (createMeshStateIfNotFound && pipelineState == null)
23  {
24  pipelineState = new ModelRendererState();
25  pipeline.Tags.Set(ModelRendererState.Key, pipelineState);
26  }
27  return pipelineState;
28  }
29  }
30 }