public void DrawScene(RenderTask task, RenderTarget output, RenderBuffers buffers, ref RenderView view, ViewFlags flags, ViewMode mode, List <Actor> customActors = null, ActorsSources actorsSource = ActorsSources.ScenesAndCustomActors, HashSet <PostProcessEffect> customPostFx = null) { #if UNIT_TEST_COMPILANT throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set."); #else // Get unmanaged actors var actors = GetActors(customActors, out int actorsCount); // Get unmanaged postFx var postFx = GetPostFx(customPostFx, out int postFxCount); Internal_DrawScene(unmanagedPtr, GetUnmanagedPtr(task), GetUnmanagedPtr(output), GetUnmanagedPtr(buffers), ref view, flags, mode, actors, actorsCount, actorsSource, postFx, postFxCount); #endif }
/// <summary> /// Executes the draw calls. /// </summary> /// <param name="context">The GPU command context.</param> /// <param name="task">The render task.</param> /// <param name="output">The output texture.</param> /// <param name="pass">The rendering pass mode.</param> public void ExecuteDrawCalls(GPUContext context, RenderTask task, RenderTarget output, RenderPass pass) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (task == null) { throw new ArgumentNullException(nameof(task)); } if (output == null) { throw new ArgumentNullException(nameof(output)); } GPUContext.Internal_ExecuteDrawCalls(context.unmanagedPtr, task.unmanagedPtr, output.unmanagedPtr, DrawCalls, pass); }
public void DrawScene(RenderTask task, RenderTarget output, RenderBuffers buffers, RenderView view, ViewFlags flags, ViewMode mode, Actor[] customActors = null, ActorsSources actorsSource = ActorsSources.ScenesAndCustomActors, HashSet <PostProcessEffect> customPostFx = null) { #if UNIT_TEST_COMPILANT throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set."); #else // Get unmanaged actors IntPtr[] actors = null; if (customActors != null) { actors = new IntPtr[customActors.Length]; for (int i = 0; i < customActors.Length; i++) { actors[i] = GetUnmanagedPtr(customActors[i]); } } // Get unmanaged postFx IntPtr[] postFx = null; if (customPostFx != null) { var postFxList = new List <IntPtr>(customPostFx.Count); foreach (var e in customPostFx) { if (e && e.CanRender) { postFxList.Add(e.unmanagedPtr); } } if (postFxList.Count > 0) { postFx = postFxList.ToArray(); } } Internal_DrawScene(unmanagedPtr, GetUnmanagedPtr(task), GetUnmanagedPtr(output), GetUnmanagedPtr(buffers), ref view, flags, mode, actors, actorsSource, postFx); #endif }
/// <summary> /// Adds the draw calls. Calculates target mesh level of detail and picks a proper meshes to draw. /// </summary> /// <param name="model">The model mesh to render. Cannot be null.</param> /// <param name="material">The material to apply during rendering. Cannot be null.</param> /// <param name="bounds">The bounds of the model instance that is being drawn (model instance bounds).</param> /// <param name="world">The world matrix used to transform mesh geometry during rendering. Use <see cref="Matrix.Identity"/> to render mesh 'as is'.</param> /// <param name="flags">The static flags. Used to describe type of the geometry.</param> /// <param name="receiveDecals">True if rendered geometry can receive decals, otherwise false.</param> public void AddDrawCall(Model model, MaterialBase material, ref BoundingSphere bounds, ref Matrix world, StaticFlags flags = StaticFlags.None, bool receiveDecals = true) { if (model == null) { throw new ArgumentNullException(nameof(model)); } // Pick a proper LOD int lodIndex = RenderTask.Internal_ComputeModelLOD(model.unmanagedPtr, ref bounds, IntPtr.Zero); var lods = model.LODs; if (lods == null || lods.Length < lodIndex || lodIndex < 0) { return; } var lod = lods[lodIndex]; // Draw meshes for (int i = 0; i < lod.Meshes.Length; i++) { AddDrawCall(lod.Meshes[i], material, ref world, flags); } }
public void DrawScene(RenderTask task, RenderTarget output, RenderBuffers buffers, RenderView view, ViewFlags flags, ViewMode mode, Actor[] customActors = null, ActorsSources actorsSource = ActorsSources.ScenesAndCustomActors, HashSet <PostProcessEffect> customPostFx = null) { #if UNIT_TEST_COMPILANT throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set."); #else // Get unmanaged actors IntPtr[] actors = null; int actorsCount = 0; if (customActors != null) { actorsCount = customActors.Length; if (_cachedActors == null || _cachedActors.Length < actorsCount) { _cachedActors = new IntPtr[Mathf.NextPowerOfTwo(actorsCount)]; } actors = _cachedActors; for (int i = 0; i < actorsCount; i++) { _cachedActors[i] = GetUnmanagedPtr(customActors[i]); } } // Get unmanaged postFx IntPtr[] postFx = null; int postFxCount = 0; if (customPostFx != null && customPostFx.Count > 0) { if (_cachedPostFxA == null) { _cachedPostFxA = new List <PostProcessEffect>(); } _cachedPostFxA.Capacity = Mathf.Max(_cachedPostFxA.Capacity, Mathf.NextPowerOfTwo(customPostFx.Count)); foreach (var e in customPostFx) { if (e && e.CanRender) { _cachedPostFxA.Add(e); } } _cachedPostFxA.Sort(ComparePostFx); postFxCount = _cachedPostFxA.Count; if (_cachedPostFxB == null || _cachedPostFxB.Length < postFxCount) { _cachedPostFxB = new IntPtr[_cachedPostFxA.Capacity]; } postFx = _cachedPostFxB; for (int i = 0; i < postFxCount; i++) { _cachedPostFxB[i] = GetUnmanagedPtr(_cachedPostFxA[i]); } _cachedPostFxA.Clear(); } Internal_DrawScene(unmanagedPtr, GetUnmanagedPtr(task), GetUnmanagedPtr(output), GetUnmanagedPtr(buffers), ref view, flags, mode, actors, actorsCount, actorsSource, postFx, postFxCount); #endif }