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.UI;
using DotRecast.Recast.DemoTool;
using Silk.NET.GLFW;
using static DotRecast.Core.RcMath;
using MouseButton = Silk.NET.Input.MouseButton;
using Window = Silk.NET.Windowing.Window;
namespace DotRecast.Recast.Demo;
@ -240,7 +242,7 @@ public class RecastDemo
if (!_mouseOverMenu)
{
processHitTest = true;
processHitTestShift = _modState != 0 ? true : false;
processHitTestShift = 0 != (_modState & KeyModState.Shift);
}
}
else if (button == MouseButton.Middle)
@ -389,7 +391,7 @@ public class RecastDemo
var renderGl = _gl.GetStringS(GLEnum.Renderer);
var glslString = _gl.GetStringS(GLEnum.ShadingLanguageVersion);
var workingDirectory = Directory.GetCurrentDirectory();
Logger.Information($"working directory - {workingDirectory}");
Logger.Information($"ImGui.Net version - {ImGui.GetVersion()}");
@ -402,7 +404,7 @@ public class RecastDemo
private void UpdateKeyboard(float dt)
{
_modState = 0;
// keyboard input
foreach (var keyboard in _input.Keyboards)
{
@ -415,7 +417,9 @@ public class RecastDemo
var tempMoveAccel = keyboard.IsKeyPressed(Key.ShiftLeft) || keyboard.IsKeyPressed(Key.ShiftRight) ? 1.0f : -1f;
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}");
_moveFront = Clamp(_moveFront + tempMoveFront * 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)
{
float hitTime = hit.Value;
if (0 != _modState)
if (0 != (_modState & KeyModState.Control))
{
// Marker
markerPositionSet = true;
@ -681,7 +685,7 @@ public class RecastDemo
}
else
{
if (0 != _modState)
if (0 != (_modState & KeyModState.Control))
{
// Marker
markerPositionSet = false;
@ -785,7 +789,7 @@ public class RecastDemo
_canvas.Draw(dt);
_mouseOverMenu = _canvas.IsMouseOver();
_imgui.Render();
window.SwapBuffers();

View File

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