* - Added ManagedRenderTarget to better handle RenderTarget2Ds. - Added a Graphics folder that contains the above. - Made all existing RenderTarget2Ds use the above instead. - Removed some old/reduntant loading code for metaballs. - Moved PrimitiveTrail to the new Graphics folder. * - Manually unload the event, as afaik TMod will not do this.
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using CalamityMod.Graphics;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
|
|
namespace CalamityMod.FluidSimulation
|
|
{
|
|
// Calculations for these are done primarily on the GPU in shaders for performance-sake.
|
|
public class FluidFieldState
|
|
{
|
|
public ManagedRenderTarget PreviousState;
|
|
|
|
public ManagedRenderTarget NextState;
|
|
|
|
public Queue<PixelQueueValue> PendingChanges = new();
|
|
|
|
public readonly int Size;
|
|
|
|
public readonly SurfaceFormat FieldContents;
|
|
|
|
public void SwapState() => Utils.Swap(ref PreviousState, ref NextState);
|
|
|
|
public RenderTarget2D FieldColorCreateCondition(int screen, int height) =>
|
|
new(Main.instance.GraphicsDevice, Size, Size, true, FieldContents, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents);
|
|
|
|
public FluidFieldState(int size, SurfaceFormat fieldContents = SurfaceFormat.Color)
|
|
{
|
|
if (Main.netMode == NetmodeID.Server)
|
|
return;
|
|
|
|
Size = size;
|
|
FieldContents = fieldContents;
|
|
|
|
PreviousState = new(false, FieldColorCreateCondition, false);
|
|
NextState = new(false, FieldColorCreateCondition, false);
|
|
}
|
|
}
|
|
}
|