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

Author Topic: sf::Transform::Combine() result  (Read 1639 times)

0 Members and 1 Guest are viewing this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
sf::Transform::Combine() result
« on: February 18, 2012, 01:27:54 pm »
The function sf::Transform::Combine() is a little bit misleading in my opinion. It makes the impression as if the result is stored in *this, and not returned as an independent copy. Additionally, the documentation for Translate() says "Combine the current transform with a translation", where the term "combine" is used with semantics different from the Combine() method.

Other functions returning copies like GetInverse() are also named differently, maybe GetCombination()/GetCombined() would be more intuitive. Or you only provide Combine() which changes *this. Or a global function. Or you don't provide it at all, as the same functionality is already covered by operator* and operator*=.

I don't know what other users think about this, maybe I'm the only one. It was just something that took my attention.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::Transform::Combine() result
« Reply #1 on: February 18, 2012, 02:06:32 pm »
To be honest it caught my attention too, this week, when writing the .Net binding of sf::Transform.

Making Combine() modify *this would be consistent with other functions, so it seems to be the best solution to me. What do you think?
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
sf::Transform::Combine() result
« Reply #2 on: February 18, 2012, 10:00:38 pm »
Yes, I also like this solution.

Out of interest, do you provide Combine() in addition to the multiplication operator for expressivity?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::Transform::Combine() result
« Reply #3 on: February 18, 2012, 11:17:11 pm »
Yes. Providing only operators is ok for trivial stuff like addition between two vectors (nobody would ever use a Vector::Add function), but for transforms, where multiplication may not be clear for everyone, I think it's better to have a named equivalent.
Laurent Gomila - SFML developer

 

anything