mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 20:58:34 +01:00
Exposed Camera's RoundPosition
This commit is contained in:
parent
08bd443c36
commit
b271518956
2 changed files with 11 additions and 4 deletions
|
@ -13,6 +13,9 @@ Additions
|
||||||
- Added GenericFont SplitStringSeparate which differentiates between existing newline characters and splits due to maximum width
|
- Added GenericFont SplitStringSeparate which differentiates between existing newline characters and splits due to maximum width
|
||||||
- Added StaticSpriteBatch class
|
- Added StaticSpriteBatch class
|
||||||
|
|
||||||
|
Improvements
|
||||||
|
- Exposed Camera's RoundPosition
|
||||||
|
|
||||||
### MLEM.Ui
|
### MLEM.Ui
|
||||||
Additions
|
Additions
|
||||||
- Allow specifying a maximum amount of characters for a TextField
|
- Allow specifying a maximum amount of characters for a TextField
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace MLEM.Cameras {
|
||||||
get {
|
get {
|
||||||
var sc = this.ActualScale;
|
var sc = this.ActualScale;
|
||||||
var pos = -this.Position * sc;
|
var pos = -this.Position * sc;
|
||||||
if (this.roundPosition)
|
if (this.RoundPosition)
|
||||||
pos = pos.FloorCopy();
|
pos = pos.FloorCopy();
|
||||||
return Matrix.CreateScale(sc, sc, 1) * Matrix.CreateTranslation(new Vector3(pos, 0));
|
return Matrix.CreateScale(sc, sc, 1) * Matrix.CreateTranslation(new Vector3(pos, 0));
|
||||||
}
|
}
|
||||||
|
@ -82,9 +82,13 @@ namespace MLEM.Cameras {
|
||||||
/// The viewport of this camera, based on the game's <see cref="GraphicsDevice.Viewport"/> and this camera's <see cref="ActualScale"/>
|
/// The viewport of this camera, based on the game's <see cref="GraphicsDevice.Viewport"/> and this camera's <see cref="ActualScale"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector2 ScaledViewport => new Vector2(this.Viewport.Width, this.Viewport.Height) / this.ActualScale;
|
public Vector2 ScaledViewport => new Vector2(this.Viewport.Width, this.Viewport.Height) / this.ActualScale;
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the camera's <see cref="Position"/> should be rounded to full integers when calculating the <see cref="ViewMatrix"/>.
|
||||||
|
/// If this value is true, the occurence of rendering fragments due to floating point rounding might be reduced.
|
||||||
|
/// </summary>
|
||||||
|
public bool RoundPosition;
|
||||||
|
|
||||||
private Rectangle Viewport => this.graphicsDevice.Viewport.Bounds;
|
private Rectangle Viewport => this.graphicsDevice.Viewport.Bounds;
|
||||||
private readonly bool roundPosition;
|
|
||||||
private readonly GraphicsDevice graphicsDevice;
|
private readonly GraphicsDevice graphicsDevice;
|
||||||
private float scale = 1;
|
private float scale = 1;
|
||||||
|
|
||||||
|
@ -92,11 +96,11 @@ namespace MLEM.Cameras {
|
||||||
/// Creates a new camera.
|
/// Creates a new camera.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="graphicsDevice">The game's graphics device</param>
|
/// <param name="graphicsDevice">The game's graphics device</param>
|
||||||
/// <param name="roundPosition">If this is true, the camera's <see cref="Position"/> and related properties will be rounded to full integers.</param>
|
/// <param name="roundPosition">Whether the camera's <see cref="Position"/> should be rounded to full integers when calculating the <see cref="ViewMatrix"/></param>
|
||||||
public Camera(GraphicsDevice graphicsDevice, bool roundPosition = true) {
|
public Camera(GraphicsDevice graphicsDevice, bool roundPosition = true) {
|
||||||
this.graphicsDevice = graphicsDevice;
|
this.graphicsDevice = graphicsDevice;
|
||||||
this.AutoScaleReferenceSize = this.Viewport.Size;
|
this.AutoScaleReferenceSize = this.Viewport.Size;
|
||||||
this.roundPosition = roundPosition;
|
this.RoundPosition = roundPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue