Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - blackwave

Pages: [1]
1
SFML projects / Re: 'Tiled' Tile-map Loader
« on: January 12, 2014, 01:46:32 am »
Hi,

This project looks awesome. I'm trying to compile it on Linux and having some trouble. Specifically, I get the following error;
Code: [Select]
src/MapObject.cpp:220:37: error: non-const lvalue reference to type
      'Vector2<[...]>' cannot bind to a temporary of type 'Vector2<[...]>'
        return Helpers::Vectors::Normalize(end - start);
                                           ^~~~~~~~~~~
/home/cole/Desktop/sfml-tmxloader/include/Helpers.h:70:47: note: passing
      argument to parameter 'source' here
                static sf::Vector2f Normalize(sf::Vector2f& source)
                                                            ^
1 error generated.

Which is associated with this function:
Code: [Select]
sf::Vector2f MapObject::CollisionNormal(const sf::Vector2f& start, const sf::Vector2f& end) const
{
Segment trajectory(start, end);
for(auto& s : m_polySegs)
{
if(trajectory.Intersects(s))
{
sf::Vector2f v = s.End - s.Start;
sf::Vector2f n(v.y, -v.x);
//invert normal if pointing in wrong direction
float tAngle = Helpers::Vectors::GetAngle(end - start);
float nAngle = Helpers::Vectors::GetAngle(n);
if(nAngle - tAngle > 90.f) n =- n;

return Helpers::Vectors::Normalize(n);
}
}
return Helpers::Vectors::Normalize(end - start);
}

I have limited experience with C++, and I don't know what this code is supposed to do, but I was able to make the code compile by changing the second return line to:
Code: [Select]
return sf::Vector2f(0,0);

The examples seem to work with this code (although it's probably doing something horrendous somewhere; I don't know).

Is this problem just on my end? Am I doing something incorrectly? Thanks.

Pages: [1]