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

Poll

Which names do you like the most?

Vector2f / Rectf / Vector2i / Recti
24 (58.5%)
Vector2F / RectF / Vector2I / RectI
2 (4.9%)
Vector2F / RectangleF / Vector2I / RectangleI
1 (2.4%)
FloatVector2 / FloatRect / IntVector2 / IntRect
2 (4.9%)
Don't change it please!
9 (22%)
I have something else to suggest
3 (7.3%)

Total Members Voted: 40

Voting closed: June 24, 2009, 06:22:05 pm

Author Topic: Vector2f vs FloatRect  (Read 18373 times)

0 Members and 1 Guest are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Vector2f vs FloatRect
« on: June 24, 2009, 06:22:05 pm »
Hi

It has already been discussed a long time ago, but... I still don't like the current naming convention for vectors and rectangles. I'd like to make it more consistent, while keeping it simple.

So please, tell me what you think :)
Laurent Gomila - SFML developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Vector2f vs FloatRect
« Reply #1 on: June 24, 2009, 06:41:02 pm »
First, I think there is no "everyone love it" solution. But I suggest this one :
Vector2f / Rectanglef / Vector2i / Rectanglei

Because :
-> I like Vector2 so it would stand to have Rectangle instead of Rect.
-> f instead of F because it's float and not Float.
-> the same goes for i and I.
-> Not Float/Int* because the most important part of the name is Vector/Rectangle and I prefer when it's in first position.
SFML / OS X developer

christoph

  • Full Member
  • ***
  • Posts: 102
    • View Profile
    • http://www.christoph-egger.org
Vector2f vs FloatRect
« Reply #2 on: June 24, 2009, 10:59:50 pm »
It's also rather like OpenGL which is (at least in my opinion) a good Idea here so I voted with Hiura.

Btw: quite common patern emerging: 2 guys voting they have some other suggestion but no other suggestion available :D

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Vector2f vs FloatRect
« Reply #3 on: June 24, 2009, 11:21:15 pm »
I'd suggest

IntVector2 / FloatVector2 / IntRectangle / FloatRectangle

I think it fits the SFML naming convention most (like RenderTarget, WindowSettings, VideoMode etc.).

The *f and *i seem stange without a number (like 2f).
What are "Rectanglei" and "Rectanglef"?

If you read
Code: [Select]

IntRectangle Rectangle;

you already know that it is a rectangle of integers;

If you read something like
Code: [Select]

Recti Rectangle;
Rectanglei Rectangle;

it would not be that obvious. (I would have to think for a short time if those were simple typedefs or types on their own or whatever...I hope you get what I mean to say.)

Naming the vector typedefs FloatVector2 and IntVector2 would only be consistent. (Even if I like Vector2f, it just doesn't feel right in SFML).

I'd also decide against the short forms "Vec" and "Rect" and go with the full names.

But it's up to you to decide.

Mr. X

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Vector2f vs FloatRect
« Reply #4 on: June 24, 2009, 11:50:22 pm »
What about "CoordinateF" and "CoordinateI" or "CoordF" and "CoordI" instead of "Vector2f" and "Vector2i"?
I know, that would be a radical change but because of the name "Vector" I often swap std::vector and sf::Vector2.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Vector2f vs FloatRect
« Reply #5 on: June 24, 2009, 11:53:47 pm »
Quote
What about "CoordinateF" and "CoordinateI" or "CoordF" and "CoordI" instead of "Vector2f" and "Vector2i"?

Because it's not only coordinates, it's also sizes and whatever which is defined by 2 or 3 components.

Quote
I know, that would be a radical change but because of the name "Vector" I often swap std::vector and sf::Vector2.

I think that std::vector is the one that would need renaming ;)
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Vector2f vs FloatRect
« Reply #6 on: June 25, 2009, 09:01:06 am »
We're not always talking about floats. Every class having GetWidth()/GetHeight() functions should actually have one GetSize() function returning a Vector2ui.

Same for rectangles, a lot of IntRects are used in SFML.
Laurent Gomila - SFML developer

eleinvisible

  • Newbie
  • *
  • Posts: 47
    • View Profile
Vector2f vs FloatRect
« Reply #7 on: June 25, 2009, 09:45:55 am »
Are they descended from common templates? If so the first option seems the most logical, as well as concise. At least in my opinion.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Vector2f vs FloatRect
« Reply #8 on: June 25, 2009, 10:06:02 am »
Yes, they are typedefs for Vector2<float>, Rect<float>, etc.
Laurent Gomila - SFML developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Vector2f vs FloatRect
« Reply #9 on: June 25, 2009, 10:14:38 am »
One another point to not chose FloatVector2 IMO is :
If we have FloatVector2 , we should have UnsignedIntVector2. Obviously it's too long.
SFML / OS X developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Vector2f vs FloatRect
« Reply #10 on: June 25, 2009, 10:37:11 am »
I think UintVector2 would be ok, just like the Uint32/16/8 typedefs are.
Laurent Gomila - SFML developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Vector2f vs FloatRect
« Reply #11 on: June 25, 2009, 11:12:24 am »
Laurent takes the point.  :P
SFML / OS X developer

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
Vector2f vs FloatRect
« Reply #12 on: June 25, 2009, 12:11:48 pm »
Quote from: "Avency"
I'd suggest

IntVector2 / FloatVector2 / IntRectangle / FloatRectangle

I think it fits the SFML naming convention most (like RenderTarget, WindowSettings, VideoMode etc.).

The *f and *i seem stange without a number (like 2f).
What are "Rectanglei" and "Rectanglef"?

If you read
Code: [Select]

IntRectangle Rectangle;

you already know that it is a rectangle of integers;

If you read something like
Code: [Select]

Recti Rectangle;
Rectanglei Rectangle;

it would not be that obvious. (I would have to think for a short time if those were simple typedefs or types on their own or whatever...I hope you get what I mean to say.)

Naming the vector typedefs FloatVector2 and IntVector2 would only be consistent. (Even if I like Vector2f, it just doesn't feel right in SFML).

I'd also decide against the short forms "Vec" and "Rect" and go with the full names.

But it's up to you to decide.


Totally agree.

I would stop using SFML if you changed to "Rectanglei" etc. ;) No but seriously I think it looks weird.

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Vector2f vs FloatRect
« Reply #13 on: June 25, 2009, 03:07:26 pm »
I like the current

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Vector2f vs FloatRect
« Reply #14 on: June 25, 2009, 03:13:37 pm »
Quote from: "Avency"

If you read
Code: [Select]

IntRectangle Rectangle;

you already know that it is a rectangle of integers;

If you read something like
Code: [Select]

Recti Rectangle;
Rectanglei Rectangle;

it would not be that obvious. (I would have to think for a short time if those were simple typedefs or types on their own or whatever...I hope you get what I mean to say.)

I actually don't really understand what would be the problem whenever Recti was a typedef of a "type on its own" ? Otherwise it's only a point of view. After having used OpenGL (glVertex2i, glVertex3i, glVertex3f...) I'm quite used to the "type{dimension}{type}" naming style.


Now here is what I wrote on the French forum :
If I could change everything, this is what I would use :
Point*i/Point*f
Sizei/Sizef
Recti/Rectf

Because I think there should be a distinction between points and sizes. A size should never be negative, whereas the members of a point could (and because to me "vector" is not enough explicit). I know explanations have been given about negative size (allows inverted object drawing) but I think this is short and simple solution, but absolutely not an intuitiv one.


If I had to stay with the current vectors, here is what I'd use :
Vec2f / Rectf / Vec2i / Recti

Keeping Vector/Rect is inconsistent and to me Vector/Rectangle is too long (but I agree this last point is quite discussable and is only a question of point of view).


P.S.: I've read some complaining that if Rect was to be used instead of Rectangle, the developer would not be able to determine whether it was a type or a variable (see here (french)). This actually depends on your naming conventions : I always use capital for the first letter of a type's name and a lowercase letter for variables.

And... I've just been noticing a major point :
Quote from: "Avency"
I think it fits the SFML naming convention most (like RenderTarget, WindowSettings, VideoMode etc.).

Recti & co does absolutely not follow this naming convention. Maybe the whole SFML naming convention should be updated (the question does not only concernes these little vectors :P ). I prefer OpenGL naming convention, thus if I was the only one to be asked, SFML would already follow this convention. But as I'm not, this should be discussed deeper, especially with the one developping SFML (hum... no.. really.. wonder what's his name :lol: ).
Want to play movies in your SFML application? Check out sfeMovie!