Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
chaifoxes committed Feb 5, 2024
2 parents dbe0fc7 + f499d1b commit 156cbc0
Show file tree
Hide file tree
Showing 73 changed files with 2,746 additions and 574 deletions.
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

## [Unreleased]

## [v3.0.0-dev.1] - *05.02.2024*

### Added

- Added `RenderMask` as a replacement to camera filters to `Scene`, `Layer` and `Entity`.
- Added `Clear()` method to `ResourceBox`.
- Added `Offset()` method to linear dampers.
- Added `OnFrameStart`, `OnFrameFinish` and `OnAfterDraw` events to `GraphicsMgr`.
- Added `Pool` collection.
- Added `AccumulationBuffer` collection.
- Added `UnorderedList` collection.
- Added `GetArea()`, `GetSignedArea()`, `IsClockwise()` methods to `GameMath`.
- Added new collision system.
- Added new drawing methods.

### Changed

- **BREAKING CHANGE:** `ResourceInfoMgr` now accepts wildcards instead of directory names. For example, `ResourceInfoMgr.GetResourcePaths("Graphics/Trees");` should now be replaced with `ResourceInfoMgr.GetResourcePaths("Graphics/Trees/*");`
- **BREAKING CHANGE:** Renamed `GetSafeNormalize()` to `SafeNormalize()`.
- **BREAKING CHANGE:** Removed instances of `Width` and `Height` in `Sprite`, `Frame`, `WindowMgr`, `Camera`, `Surface`, and replaced them with `Size`.
- **BREAKING CHANGE:** Changed boolean `isOutline` to `ShapeFill` enum for shapes.

### Fixed

- Fixed `AddComponent<>()` not taking generic type into account.
- `DirectoryResourceBox` now ignores non-xnb files properly.
- Fixed division by zero in dampers.

### Removed

- **BREAKING CHANGE:** Removed camera layer filters.
- **BREAKING CHANGE:** Removed `Drawable` class and non-static shape fields and methods.

## [v2.2.0] - *17.09.2022*

Expand Down
4 changes: 2 additions & 2 deletions Installer/packInstaller.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@


!define APPNAME "Monofoxe"
!define APPVERSION "v2"
!define INSTALLERVERSION "2.2.0.0"
!define APPVERSION "v3-dev"
!define INSTALLERVERSION "3.0.0.0-dev.1"

!define MUI_ICON "pics\icon.ico"
!define MUI_UNICON "pics\icon.ico"
Expand Down
94 changes: 13 additions & 81 deletions Monofoxe/Monofoxe.Engine/Cameras/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public int Priority
/// <summary>
/// View size.
/// </summary>
public Vector2 Size => new Vector2(Surface.Width, Surface.Height);
public Vector2 Size => Surface.Size;

/// <summary>
/// Camera offset.
Expand Down Expand Up @@ -122,15 +122,10 @@ public int Priority
public Matrix View;
public Matrix Projection;


private Dictionary<string, HashSet<string>> _filter =
new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase);

/// <summary>
/// Mode for filtering out certain layers.
/// For a layer or a scene to be rendered, it has to match at least one bit of RenderMask.
/// </summary>
public FilterMode FilterMode = FilterMode.None;

public RenderMask RenderMask = RenderMask.Default;

/// <summary>
/// Shaders applied to the surface.
Expand All @@ -155,7 +150,7 @@ public PostprocessingMode PostprocessingMode

if (_postprocessingMode != PostprocessingMode.None)
{
_postprocessorBuffer = new Surface(Surface.Width, Surface.Height);
_postprocessorBuffer = new Surface(Surface.Size);
}
else
{
Expand All @@ -165,7 +160,7 @@ public PostprocessingMode PostprocessingMode

if (_postprocessingMode == PostprocessingMode.CameraAndLayers)
{
_postprocessorLayerBuffer = new Surface(Surface.Width, Surface.Height);
_postprocessorLayerBuffer = new Surface(Surface.Size);
}
else
{
Expand All @@ -182,24 +177,24 @@ public PostprocessingMode PostprocessingMode
internal Surface _postprocessorLayerBuffer;


public Camera(int w, int h, int priority = 0)
public Camera(Vector2 size, int priority = 0)
{
Surface = new Surface(w, h);
Surface = new Surface(size);

Priority = priority; // Also adds camera to camera list.
}

public event Action<int, int> OnResize;
public event Action<Vector2> OnResize;

/// <summary>
/// Resizes the view.
/// </summary>
public void Resize(int w, int h)
public void Resize(Vector2 size)
{
Surface.Resize(w, h);
_postprocessorBuffer?.Resize(w, h);
_postprocessorLayerBuffer?.Resize(w, h);
OnResize?.Invoke(w, h);
Surface.Resize(size);
_postprocessorBuffer?.Resize(size);
_postprocessorLayerBuffer?.Resize(size);
OnResize?.Invoke(size);
}

/// <summary>
Expand All @@ -223,69 +218,6 @@ public void Dispose()
/// Returns mouse position relative to the camera.
/// </summary>
public abstract Vector2 GetRelativeMousePosition();


public void AddFilterEntry(string sceneName, string layerName)
{
if (_filter.TryGetValue(sceneName, out HashSet<string> filterSet))
{
filterSet.Add(layerName);
}
else
{
var newSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
newSet.Add(layerName);
_filter.Add(sceneName, newSet);
}
}

public void RemoveFilterEntry(string sceneName, string layerName)
{
if (_filter.TryGetValue(sceneName, out HashSet<string> filterSet))
{
filterSet.Remove(layerName);
if (filterSet.Count == 0)
{
_filter.Remove(sceneName);
}
}
}

/// <summary>
/// Returns true, if given layer is filtered out.
/// </summary>
public bool Filter(string sceneName, string layerName)
{
if (FilterMode == FilterMode.None)
{
return false;
}

var result = false;

// NOTE: Here was a strange TO-DO with just said "fix this".
// Haven't found any bugs here, so just removed it. Probably
// was an already fixed bug with case-sensitivity. In case of any
// camera filter-related bugs, this place if the first suspect.
// Thanks, past me.

if (_filter.TryGetValue(sceneName, out HashSet<string> filterSet))
{
result = filterSet.Contains(layerName);
}

if (FilterMode == FilterMode.Inclusive)
{
return !result;
}
else
{
// NOTE: Add additional check here, if any other filter types will be created.
return result;
}

}



/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Monofoxe/Monofoxe.Engine/Cameras/Camera2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public Vector2 Position2D
}


public Camera2D(int w, int h, int priority = 0) : base(w, h, priority)
public Camera2D(Vector2 size, int priority = 0) : base(size, priority)
{
}

Expand Down
23 changes: 0 additions & 23 deletions Monofoxe/Monofoxe.Engine/Cameras/FilterMode.cs

This file was deleted.

43 changes: 43 additions & 0 deletions Monofoxe/Monofoxe.Engine/Cameras/RenderMask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;

namespace Monofoxe.Engine.Cameras
{
[Flags]
public enum RenderMask
{
None = 0x00000000,
Default = 0x00000001,
Mask1 = 0x00000001,
Mask2 = 0x00000002,
Mask3 = 0x00000004,
Mask4 = 0x00000008,
Mask5 = 0x00000010,
Mask6 = 0x00000020,
Mask7 = 0x00000040,
Mask8 = 0x00000080,
Mask9 = 0x00000100,
Mask10 = 0x00000200,
Mask11 = 0x00000400,
Mask12 = 0x00000800,
Mask13 = 0x00001000,
Mask14 = 0x00002000,
Mask15 = 0x00004000,
Mask16 = 0x00008000,
Mask17 = 0x00010000,
Mask18 = 0x00020000,
Mask19 = 0x00040000,
Mask20 = 0x00080000,
Mask21 = 0x00100000,
Mask22 = 0x00200000,
Mask23 = 0x00400000,
Mask24 = 0x00800000,
Mask25 = 0x01000000,
Mask26 = 0x02000000,
Mask27 = 0x04000000,
Mask28 = 0x08000000,
Mask29 = 0x10000000,
Mask30 = 0x20000000,
Mask31 = 0x40000000,
All = int.MaxValue,
}
}
Loading

0 comments on commit 156cbc0

Please sign in to comment.