Skip to content

Commit

Permalink
Fixed regression when hovering over free mode line
Browse files Browse the repository at this point in the history
  • Loading branch information
ioan-chera committed Jul 9, 2024
1 parent 0fba394 commit 2b2d2ca
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelogs/2.0.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@

* Fixed a crash happening when deleting all things from the map.
* Fixed a crash happening when deleting a group of linedefs.
* Fixed a bug where the linedef splitting hint wouldn't show up when in FREE grid mode (introduced
by 2.0.0).
2 changes: 1 addition & 1 deletion src/e_linedef.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ void linemod::moveCoordOntoLinedef(const Document &doc, int ld, v2double_t &v)

v2double_t dv = v2 - v1;

double len_squared = dv.hypot();
double len_squared = pow(dv.hypot(), 2);

SYS_ASSERT(len_squared > 0);

Expand Down
10 changes: 10 additions & 0 deletions src/e_linedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,19 @@
#ifndef __EUREKA_E_LINEDEF_H__
#define __EUREKA_E_LINEDEF_H__

#include "Side.h"
#include "DocumentModule.h"
#include "sys_type.h"
#include <vector>

class EditOperation;
class FFixedPoint;
class LineDef;
class Objid;
class selection_c;
class SString;
struct v2double_t;
struct SideDef;

namespace linemod
{
Expand Down
5 changes: 3 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ list(FILTER fltk_libs INCLUDE REGEX fltk)
# eurekasrc files

add_library(
testutils
STATIC
testutils
STATIC
testUtils/FatalHandler.cpp
testUtils/FatalHandler.hpp
testUtils/TempDirContext.cpp
Expand Down Expand Up @@ -53,6 +53,7 @@ add_executable(
e_checks_test.cpp
e_commands_test.cpp
e_cutpaste_test.cpp
e_linedef_test.cpp
e_objects_test.cpp
FixedPointTest.cpp
im_color_test.cpp
Expand Down
48 changes: 48 additions & 0 deletions test/e_linedef_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//------------------------------------------------------------------------
//
// Eureka DOOM Editor
//
// Copyright (C) 2024 Ioan Chera
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//------------------------------------------------------------------------

#include "e_linedef.h"
#include "Instance.h"
#include "gtest/gtest.h"

TEST(ELinedef, MoveCoordOntoLinedef)
{
Instance inst;
Vertex* vertex;
vertex = new Vertex;
vertex->raw_x = FFixedPoint(0);
vertex->raw_y = FFixedPoint(0);
inst.level.vertices.push_back(std::shared_ptr<Vertex>(vertex));
vertex = new Vertex;
vertex->raw_x = FFixedPoint(64);
vertex->raw_y = FFixedPoint(64);
inst.level.vertices.push_back(std::shared_ptr<Vertex>(vertex));


inst.level.linedefs.push_back(std::make_shared<LineDef>());
auto& L = inst.level.linedefs.back();
L->start = 0;
L->end = 1;

v2double_t v = { 32, 16 };

linemod::moveCoordOntoLinedef(inst.level, 0, v);

ASSERT_DOUBLE_EQ(v.x, 24.0);
ASSERT_DOUBLE_EQ(v.y, 24.0);
}

0 comments on commit 2b2d2ca

Please sign in to comment.