// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
using System;
using System.Collections.Generic;
namespace FlaxEngine
{
partial class RenderTask
{
///
/// The custom tag object value linked to the rendering task.
///
public object Tag;
}
partial class SceneRenderTask
{
///
/// Gets or sets the view flags (via property).
///
public ViewFlags ViewFlags
{
get => View.Flags;
set
{
var view = View;
view.Flags = value;
View = view;
}
}
///
/// Gets or sets the view mode (via property).
///
public ViewMode ViewMode
{
get => View.Mode;
set
{
var view = View;
view.Mode = value;
View = view;
}
}
///
/// The global custom post processing effects applied to all (applied to tasks that have turned on).
///
public static readonly HashSet GlobalCustomPostFx = new HashSet();
///
/// The custom post processing effects.
///
public readonly HashSet CustomPostFx = new HashSet();
///
/// True if allow using global custom PostFx when rendering this task.
///
public bool AllowGlobalCustomPostFx = true;
private static List _postFx;
private static IntPtr[] _postFxPtr;
private static Comparison _postFxComparison = (x, y) => x.Order - y.Order;
internal IntPtr[] GetPostFx(out int count)
{
if (_postFx == null)
_postFx = new List();
// Get custom post effects to render (registered ones and from the current camera)
foreach (var postFx in CustomPostFx)
{
if (postFx.CanRender)
_postFx.Add(postFx);
}
if (AllowGlobalCustomPostFx)
{
foreach (var postFx in GlobalCustomPostFx)
{
if (postFx.CanRender)
_postFx.Add(postFx);
}
}
var camera = Camera;
if (camera != null)
{
var perCameraPostFx = camera.GetScripts();
for (int i = 0; i < perCameraPostFx.Length; i++)
{
var postFx = perCameraPostFx[i];
if (postFx.CanRender)
_postFx.Add(postFx);
}
}
// Sort postFx
_postFx.Sort(_postFxComparison);
// Convert into unmanaged objects
count = _postFx.Count;
if (_postFxPtr == null || _postFxPtr.Length < count)
_postFxPtr = new IntPtr[_postFx.Capacity];
for (int i = 0; i < count; i++)
_postFxPtr[i] = GetUnmanagedPtr(_postFx[i]);
// Release references to managed objects
_postFx.Clear();
return _postFxPtr;
}
}
}