2021-19-03

SM.Base:
~ Improved Keyboard.AreSpecificKeysPressed(int, int)
~ Made GenericTransformation.LastMaster's set public
~ Made the fixed update use the property "IsExiting" to determent if it should stop.
~ The MainFramebuffer of each RenderPipeline now has always a name.

SM2D:
~ Moved the checking code of Mouse2D.MouseOver into a own method.
This commit is contained in:
Michel Fedde 2021-03-19 09:31:36 +01:00
parent c8db1ce8bc
commit 71a22df8bd
7 changed files with 31 additions and 18 deletions

View file

@ -2,6 +2,7 @@
using OpenTK;
using SM.Base.Controls;
using SM.Base.Scene;
using SM.OGL.Mesh;
using SM2D.Scene;
using SM2D.Types;
@ -48,12 +49,11 @@ namespace SM2D.Controls
foreach (TObject item in checkingObjects)
{
Matrix4 worldPos = item.Transform.InWorldSpace;
item.Mesh.BoundingBox.GetBounds(worldPos, out Vector3 min, out Vector3 max);
if (mousePos.X > min.X && mousePos.X < max.X &&
mousePos.Y > min.Y && mousePos.Y < max.Y)
if (MouseOver(mousePos, item.Mesh.BoundingBox, item.Transform))
{
Matrix4 worldPos = item.Transform.InWorldSpace;
// if z is greater than distance
if (worldPos[3, 2] > distance)
{
@ -63,9 +63,24 @@ namespace SM2D.Controls
success = true;
}
}
return success;
}
public static bool MouseOver(Vector2 mousePos, BoundingBox boundingBox, Transformation transform)
{
Matrix4 worldPos = transform.InWorldSpace;
boundingBox.GetBounds(worldPos, out Vector3 min, out Vector3 max);
if (mousePos.X > min.X && mousePos.X < max.X &&
mousePos.Y > min.Y && mousePos.Y < max.Y)
{
return true;
}
return false;
}
}
}