[no bug, just not nice]Comparative Operations On Position2d

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

[no bug, just not nice]Comparative Operations On Position2d

Post by kklouzal »

Hello, I'm not sure if this functionality is supposed to be present but it allowed me to do a comparison without compiler errors. Here is the problem, doing a comparison on irr::core::vector2d<irr::s32> weather it is < or > only compares the X value.
When doing the comparison:

Code: Select all

void Compare()
{
    irr::core::position2d<irr::s32> A(30, 50);
    irr::core::position2d<irr::s32> B(10, 60);
    
    if (A > B)
    {
        std::cout << "A > B" << std::endl;
    }
    else {
        std::cout << "A !> B" << std::endl;
    }
}
A.X is > B.X but A.Y !> B.Y but the output is that A > B
Dream Big Or Go Home.
Help Me Help You.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Comparative Operations On Position2d

Post by hendu »

Vector comparison is not usually defined except as a boolean vector. Irr uses the operator for sorting, due to C++ requirements. So this is not a bug, please open-code such comparisons in your app.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Comparative Operations On Position2d

Post by CuteAlien »

Yeah, that was badly solved (my fault at least partly). Not having those operators at all would have been better (that just needed a minor rewrite of sorting).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply