bugfix - shift key not working in demo

This commit is contained in:
ikpil 2023-06-28 22:41:12 +09:00
parent cfe0f4d60c
commit 1cb7bbb7a1
3 changed files with 25 additions and 8 deletions

View File

@ -0,0 +1,12 @@
namespace DotRecast.Recast.Demo;
public static class KeyModState
{
public const int None = 0;
public const int Shift = 1;
public const int Control = 2;
public const int Alt = 4;
public const int Super = 8;
public const int CapsLock = 16;
public const int NumLock = 32;
}

View File

@ -41,7 +41,9 @@ using DotRecast.Recast.DemoTool.Geom;
using DotRecast.Recast.Demo.Tools; using DotRecast.Recast.Demo.Tools;
using DotRecast.Recast.Demo.UI; using DotRecast.Recast.Demo.UI;
using DotRecast.Recast.DemoTool; using DotRecast.Recast.DemoTool;
using Silk.NET.GLFW;
using static DotRecast.Core.RcMath; using static DotRecast.Core.RcMath;
using MouseButton = Silk.NET.Input.MouseButton;
using Window = Silk.NET.Windowing.Window; using Window = Silk.NET.Windowing.Window;
namespace DotRecast.Recast.Demo; namespace DotRecast.Recast.Demo;
@ -240,7 +242,7 @@ public class RecastDemo
if (!_mouseOverMenu) if (!_mouseOverMenu)
{ {
processHitTest = true; processHitTest = true;
processHitTestShift = _modState != 0 ? true : false; processHitTestShift = 0 != (_modState & KeyModState.Shift);
} }
} }
else if (button == MouseButton.Middle) else if (button == MouseButton.Middle)
@ -415,7 +417,9 @@ public class RecastDemo
var tempMoveAccel = keyboard.IsKeyPressed(Key.ShiftLeft) || keyboard.IsKeyPressed(Key.ShiftRight) ? 1.0f : -1f; var tempMoveAccel = keyboard.IsKeyPressed(Key.ShiftLeft) || keyboard.IsKeyPressed(Key.ShiftRight) ? 1.0f : -1f;
var tempControl = keyboard.IsKeyPressed(Key.ControlLeft) || keyboard.IsKeyPressed(Key.ControlRight); var tempControl = keyboard.IsKeyPressed(Key.ControlLeft) || keyboard.IsKeyPressed(Key.ControlRight);
_modState |= tempControl || 0 < tempMoveAccel ? 1 : 0; _modState |= tempControl ? (int)KeyModState.Control : (int)KeyModState.None;
_modState |= 0 < tempMoveAccel ? (int)KeyModState.Shift : (int)KeyModState.None;
//Logger.Information($"{_modState}"); //Logger.Information($"{_modState}");
_moveFront = Clamp(_moveFront + tempMoveFront * dt * 4.0f, 0, 2.0f); _moveFront = Clamp(_moveFront + tempMoveFront * dt * 4.0f, 0, 2.0f);
_moveLeft = Clamp(_moveLeft + tempMoveLeft * dt * 4.0f, 0, 2.0f); _moveLeft = Clamp(_moveLeft + tempMoveLeft * dt * 4.0f, 0, 2.0f);
@ -658,7 +662,7 @@ public class RecastDemo
if (hit.HasValue) if (hit.HasValue)
{ {
float hitTime = hit.Value; float hitTime = hit.Value;
if (0 != _modState) if (0 != (_modState & KeyModState.Control))
{ {
// Marker // Marker
markerPositionSet = true; markerPositionSet = true;
@ -681,7 +685,7 @@ public class RecastDemo
} }
else else
{ {
if (0 != _modState) if (0 != (_modState & KeyModState.Control))
{ {
// Marker // Marker
markerPositionSet = false; markerPositionSet = false;

View File

@ -2,12 +2,13 @@
{ {
public class OffMeshConnectionToolImpl : ISampleTool public class OffMeshConnectionToolImpl : ISampleTool
{ {
private Sample _sample;
public string GetName() public string GetName()
{ {
return "Create Off-Mesh Links"; return "Create Off-Mesh Links";
} }
private Sample _sample;
public void SetSample(Sample sample) public void SetSample(Sample sample)
{ {
_sample = sample; _sample = sample;