Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c448897
Potree2Reader: can read more than one file at runtime
RedImp1470 Aug 10, 2022
9c5411d
Made sure point and mesh data is deleted when Dispose has been called…
RedImp1470 Aug 10, 2022
d0de6b9
Automatic code cleanup
RedImp1470 Aug 10, 2022
d8dd9b8
PointCloud: deleted IDisposable from all classes that do not own a ob…
RedImp1470 Aug 10, 2022
70d82a1
GPU Buffer disposal: moved calls out of "managed" section of Dispose()
RedImp1470 Aug 10, 2022
9f95fa0
Cleanup
RedImp1470 Aug 11, 2022
778bbe9
RenderCanvas: added EndOfFrame event
RedImp1470 Aug 11, 2022
aab3425
IDisposable refactoring
RedImp1470 Aug 11, 2022
0bd8254
PointCloudPotree2 ImGui: Load point cloud by exchanging the PointClou…
RedImp1470 Aug 11, 2022
474191d
StreamAssetProvider, GetAssetAsync: removed redundand close call
RedImp1470 Aug 11, 2022
8b88174
IDisposable refactoring
RedImp1470 Aug 11, 2022
ce478ed
RenderTests only render three frames instead of 60
RedImp1470 Aug 11, 2022
7ccc7cd
Linting
RedImp1470 Aug 11, 2022
6df0184
Merge branch 'develop' into feature/591-dispose-pointCloudComponent
RedImp1470 Aug 12, 2022
6e63bcd
Merge remote-tracking branch 'origin/develop' into feature/591-dispos…
RedImp1470 Aug 16, 2022
d24200a
Merge branch 'develop' into feature/591-dispose-pointCloudComponent
RedImp1470 Aug 17, 2022
2df2120
Moved IDisposable imp from effect sub classes to base class
RedImp1470 Aug 29, 2022
07e7027
Fixed IDisposable-related warnings
RedImp1470 Aug 29, 2022
70a00ce
Merge remote-tracking branch 'origin/develop' into feature/591-dispos…
RedImp1470 Aug 29, 2022
c55f1e0
Linting
RedImp1470 Aug 29, 2022
e685d79
Fixed IDisposable-related warnings
RedImp1470 Aug 29, 2022
a056154
Linting
RedImp1470 Aug 29, 2022
fd1e670
Removed resource manager cleanup from RenderContext.Render(mesh)
RedImp1470 Aug 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ namespace Fusee.Examples.FuseeImGui.Desktop
{
[FuseeApplication(Name = "FUSEE ImGui Example",
Description = "A very simple example how to use ImGui within a Fusee application.")]
public class Core : RenderCanvas
public class ImGuiApp : RenderCanvas
{
#region StaticBindingVars

private static bool _dockspaceOpen = true;
private static bool _isMouseInsideFuControl;

private CoreControl _fuControl;
private SceneToTexture _fuControl;

private Vector4 _rocketColor = Vector4.UnitW; // alpha 255
private bool _colorPickerOpen;
Expand All @@ -34,7 +34,7 @@ private async void Load()
{
SetImGuiDesign();

_fuControl = new CoreControl(RC);
_fuControl = new SceneToTexture(RC);
_fuControl.Init();

// reload last used cfg
Expand Down Expand Up @@ -66,7 +66,7 @@ public override void Resize(ResizeEventArgs e)
_fuControl.UpdateOriginalGameWindowDimensions(e.Width, e.Height);
}

public override async void RenderAFrame()
public override void RenderAFrame()
{
// Enable Dockspace
ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.DockingEnable;
Expand Down
2 changes: 1 addition & 1 deletion Examples/Complete/ImGui/Desktop/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static void Main()
AssetStorage.RegisterProvider(fap);

// no injection or shared base project, as we are currently limited to desktop only with ImGui.NET
var app = new Core();
var app = new ImGuiApp();

var icon = AssetStorage.Get<ImageData>("FuseeIconTop32.png");
app.CanvasImplementor = new Fusee.ImGuiImp.Desktop.ImGuiRenderCanvasImp(icon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal struct SceneElement
public string Value;
}

internal class CoreControl : FuseeControlToTexture, IDisposable
internal class SceneToTexture : FuseeSceneToTexture
{
private SceneContainer _rocketScene;
private SceneRendererForward _renderer;
Expand All @@ -40,10 +40,8 @@ internal class CoreControl : FuseeControlToTexture, IDisposable
private readonly float _fovy = M.PiOver4;

private Camera _cam;
private bool disposedValue;


public CoreControl(RenderContext ctx) : base(ctx)
public SceneToTexture(RenderContext ctx) : base(ctx)
{
_rc = ctx;
}
Expand Down Expand Up @@ -193,24 +191,5 @@ protected override void Resize(int width, int height)
_renderTexture = WritableMultisampleTexture.CreateAlbedoTex(Width, Height, 8);
_cam.RenderTexture = _renderTexture;
}

protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
_renderTexture?.Dispose();
}
disposedValue = true;
}
}

public void Dispose()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}
}
35 changes: 1 addition & 34 deletions Examples/Complete/PointCloudPotree2/Core/PtRenderParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Fusee.Examples.PointCloudPotree2.Core
public delegate void PointThresholdHandler(int val);
public delegate void ProjectedSizeModifierHandler(float val);

public sealed class PtRenderingParams : IDisposable
public sealed class PtRenderingParams
{
public static PtRenderingParams Instance { get; private set; } = new();

Expand Down Expand Up @@ -113,38 +113,5 @@ public int PointThreshold
PointThresholdHandler(_ptThreshold);
}
}

// Explicit static constructor to tell C# compiler
// not to mark type as beforefieldinit
static PtRenderingParams()
{
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

private bool _disposed;

void Dispose(bool disposing)
{
// Check to see if Dispose has already been called.
if (!_disposed)
{
if (Instance != null)
{
Instance = null;
}

// Note disposing has been done.
_disposed = true;
}
}
~PtRenderingParams()
{
Dispose(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@
using Fusee.Engine.Core.ShaderShards;
using Fusee.ImGuiImp.Desktop;
using Fusee.ImGuiImp.Desktop.Templates;
using Fusee.Math.Core;
using Fusee.PointCloud.Common;
using ImGuiNET;
using System;
using System.IO;
using System.Numerics;
using System.Threading.Tasks;

namespace Fusee.Examples.PointCloudPotree2.PotreeImGui
namespace Fusee.Examples.PointCloudPotree2.Gui
{
[FuseeApplication(Name = "FUSEE ImGui Example",
Description = "A very simple example how to use ImGui within a Fusee application.")]
public class Core : RenderCanvas
public class ImGuiApp : RenderCanvas
{

#region StaticBindingVars

private static bool _dockspaceOpen = true;
Expand All @@ -43,7 +41,7 @@ public class Core : RenderCanvas
private bool _wantsToShutdown;


private PointCloudControlCore _fuControl;
private PointCloudRendering _fuControl;
private ImGuiFilePicker _picker;

#endregion
Expand All @@ -52,7 +50,9 @@ public override async Task InitAsync()
{
SetImGuiDesign();

_fuControl = new PointCloudControlCore(RC);
_fuControl = new PointCloudRendering(RC);
ApplicationIsShuttingDown += OnShuttingDown;
EndOfFrame += _fuControl.OnLoadNewFile;
_fuControl.Init();
await base.InitAsync();

Expand All @@ -61,16 +61,13 @@ public override async Task InitAsync()
{
if (string.IsNullOrEmpty(file)) return;

PtRenderingParams.Instance.PathToOocFile = new FileInfo(file).Directory.FullName;
PointRenderingParams.Instance.PathToOocFile = new FileInfo(file).Directory.FullName;

if (_fuControl != null)
{
_fuControl.Dispose();
_fuControl = new PointCloudControlCore(RC);
_fuControl.Init();
_fuControl.RequestedNewFile = true;
_fuControl.UpdateOriginalGameWindowDimensions(Width, Height);
_fuControl.ResetCamera();
// reset color picker
_currentColorMode = 0;
}
};
Expand Down Expand Up @@ -158,15 +155,14 @@ public override void RenderAFrame()
ImGui.EndChild();
ImGui.End();

DrawGUI();
Draw();
DrawFilePickerDialog();

if (_wantsToShutdown)
CloseGameWindow();
}


internal void DrawGUI()
private void Draw()
{
ImGui.Begin("Settings");
ImGui.Text("Fusee PointCloud Rendering");
Expand Down Expand Up @@ -197,8 +193,8 @@ internal void DrawGUI()
ImGui.SliderFloat("Min. Projection Size Modifier", ref _fuseeViewportMinProj, 0f, 1f);


PtRenderingParams.Instance.PointThreshold = _threshold;
PtRenderingParams.Instance.ProjectedSizeModifier = _fuseeViewportMinProj;
PointRenderingParams.Instance.PointThreshold = _threshold;
PointRenderingParams.Instance.ProjectedSizeModifier = _fuseeViewportMinProj;

ImGui.EndGroup();

Expand All @@ -210,8 +206,8 @@ internal void DrawGUI()
ImGui.SliderInt("EDL Neighbor Px", ref _edlNeighbour, 0, 5);
ImGui.SliderFloat("EDL Strength", ref _edlStrength, 0.0f, 5f);

PtRenderingParams.Instance.EdlStrength = _edlStrength;
PtRenderingParams.Instance.EdlNoOfNeighbourPx = _edlNeighbour;
PointRenderingParams.Instance.EdlStrength = _edlStrength;
PointRenderingParams.Instance.EdlNoOfNeighbourPx = _edlNeighbour;

ImGui.EndGroup();

Expand All @@ -221,7 +217,7 @@ internal void DrawGUI()
ImGui.Text("Point Shape");
ImGui.Combo("PointShape", ref _currentPtShape, new string[] { "Paraboloid", "Rect", "Circle" }, 3);

PtRenderingParams.Instance.Shape = _currentPtShape switch
PointRenderingParams.Instance.Shape = _currentPtShape switch
{
0 => PointShape.Paraboloid,
1 => PointShape.Rect,
Expand All @@ -238,8 +234,8 @@ internal void DrawGUI()
ImGui.Combo("Point Size Method", ref _currentPtSizeMethod, new string[] { "FixedPixelSize", "FixedWorldSize" }, 2);
ImGui.SliderInt("Point Size", ref _ptSize, 1, 20);

PtRenderingParams.Instance.Size = _ptSize;
PtRenderingParams.Instance.PtMode = _currentPtSizeMethod switch
PointRenderingParams.Instance.Size = _ptSize;
PointRenderingParams.Instance.PtMode = _currentPtSizeMethod switch
{
0 => PointSizeMode.FixedPixelSize,
1 => PointSizeMode.FixedWorldSize,
Expand All @@ -255,7 +251,7 @@ internal void DrawGUI()

ImGui.Combo("Color mode", ref _currentColorMode, new string[] { "BaseColor", "VertexColor0", "VertexColor1", "VertexColor2" }, 4);

PtRenderingParams.Instance.ColorMode = _currentColorMode switch
PointRenderingParams.Instance.ColorMode = _currentColorMode switch
{
0 => ColorMode.BaseColor,
1 => ColorMode.VertexColor0,
Expand All @@ -280,7 +276,7 @@ internal void DrawGUI()
ImGui.ColorPicker4("Color", ref _ptColor);
ImGui.End();

PtRenderingParams.Instance.ColorPassEf.SurfaceInput.Albedo = _ptColor.ToFuseeVector();
PointRenderingParams.Instance.ColorPassEf.SurfaceInput.Albedo = _ptColor.ToFuseeVector();
}
ImGui.EndGroup();
}
Expand All @@ -289,8 +285,7 @@ internal void DrawGUI()
ImGui.End();
}


internal void DrawMainMenuBar()
private void DrawMainMenuBar()
{
if (ImGui.BeginMainMenuBar())
{
Expand All @@ -310,17 +305,20 @@ internal void DrawMainMenuBar()
ImGui.EndMainMenuBar();
}



private void DrawFilePickerDialog()
{
_picker.Draw(ref _spwanOpenFilePopup);
}

private void OnShuttingDown(object sender, EventArgs e)
{
_fuControl.ClosingRequested = true;
}

/// <summary>
/// Place all design/styles inside this method
/// </summary>
internal static void SetImGuiDesign()
private static void SetImGuiDesign()
{
var style = ImGui.GetStyle();
var colors = style.Colors;
Expand Down
12 changes: 12 additions & 0 deletions Examples/Complete/PointCloudPotree2/ImGui/LoadFileEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace Fusee.Examples.PointCloudPotree2.Gui
{
internal class LoadFileEventArgs : EventArgs
{
/// <summary>
/// Path to the new file.
/// </summary>
public string Path;
}
}
4 changes: 2 additions & 2 deletions Examples/Complete/PointCloudPotree2/ImGui/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.IO;
using System.Threading.Tasks;

namespace Fusee.Examples.PointCloudPotree2.PotreeImGui
namespace Fusee.Examples.PointCloudPotree2.Gui
{
public class PointCloudPotree2ImGui
{
Expand Down Expand Up @@ -56,7 +56,7 @@ public static void Main()
AssetStorage.RegisterProvider(fap);

// no injection or shared base project, as we are currently limited to desktop only with ImGui.NET
var app = new Core();
var app = new ImGuiApp();

var icon = AssetStorage.Get<ImageData>("FuseeIconTop32.png");
app.CanvasImplementor = new Fusee.ImGuiImp.Desktop.ImGuiRenderCanvasImp(icon);
Expand Down
Loading