richelbilderbeek / djog_unos_2018

Project by the Uno's at DJOG 2018-2019: Nature Zen
GNU General Public License v3.0
6 stars 2 forks source link

A tile constructor should behave as expected #522

Open richelbilderbeek opened 5 years ago

richelbilderbeek commented 5 years ago

Is your feature request related to a problem? Please describe.

When someone creates a tile with a certain x coordinat, this is a test most people expect to pass:

    const double x = 1.0;
    const tile a(x);
    assert(x == a.get_x());

Currently, however, this test fails, as the tile is rescaled during construction. I see why the tiles need to be rescaled, it just needs to be done elsewhere.

Describe the solution you'd like

Make the tile constructor behave as expected. Do the rescaling someplace else.

These tests should pass:

  //#define FIX_ISSUE_522
  #ifdef FIX_ISSUE_522
  //A tile behaves as expected
  {
    const double x{1.0};
    const double y{2.0};
    const double z{3.0};
    const double width{4.0};
    const double height{5.0};
    const double depth{6.0};
    const tile_type type{tile_type::arctic};
    const tile_id id{tile_id()};

    const tile a(x, y, z, width, height, depth, type, id);
    assert(std::abs(x - a.get_x()) < 0.001);
    assert(std::abs(y - a.get_y()) < 0.001);
    assert(std::abs(z - a.get_z()) < 0.001);
    assert(std::abs(width - a.get_width()) < 0.001);
    assert(std::abs(height - a.get_height()) < 0.001);
    assert(std::abs(depth - a.get_depth()) < 0.001);
    assert(type == a.get_type());
    assert(id.get() == a.get_id());
  }
  #endif // FIX_ISSUE_522

Describe alternatives you've considered

None.

Additional context

463 depends on this.

DynCoder commented 5 years ago

Assign myself as this is mega super ultra high priority