Skip to content

Commit

Permalink
[#182]: Fix selecting objects in Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Jan 11, 2024
1 parent b355d79 commit 71eae31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ Editor::MouseButtonCallback(MouseButtonEvent& event)
if (!playGame_ && !EditorGUI::IsBlockingEvents() && levelLoaded_)
{
const auto mousePressed = event.action_ == GLFW_PRESS;
const auto mouseReleased = event.action_ == GLFW_RELEASE;
LMBPressedLastUpdate_ = mousePressed and event.button_ == GLFW_MOUSE_BUTTON_1;
RMBPressedLastUpdate_ = mousePressed and event.button_ == GLFW_MOUSE_BUTTON_2;

if (mousePressed)
if (mouseReleased and not mouseDrag_)
{
CheckIfObjectGotSelected(InputManager::GetMousePos(),
InputManager::CheckKeyPressed(GLFW_KEY_LEFT_CONTROL));
Expand Down
2 changes: 1 addition & 1 deletion engine/game/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ Level::GetTilesFromRectangle(const std::array< glm::vec2, 4 >& rect) const
const auto w =
static_cast< int32_t >(glm::floor(position.x / static_cast< float >(tileWidth)));
const auto h =
static_cast< int32_t >(glm::floor(position.y / static_cast< float >(tileWidth)));
static_cast< int32_t >(glm::ceil(position.y / static_cast< float >(tileWidth)));

return {glm::clamp(w, 0, (levelSize.x / static_cast< int32_t >(tileWidth)) - 1),
glm::clamp(h, 0, (levelSize.y / static_cast< int32_t >(tileWidth))) - 1};
Expand Down

0 comments on commit 71eae31

Please sign in to comment.