Live data from Hacker News

A time-travelling door bug in Half Life 2

mastodon.gamedev.place

31–40 of 88 posts

Re: A time-travelling door bug in Half Life 2

#31
>But on the SSE version, a whole bunch of tiny precisions are very slightly different, and a combination of the friction on the floor and the mass of the objects means the guard still rotates from the collision, but now he rotates very slightly less far.

Insanity. The values were just right. Just wow.

Re: A time-travelling door bug in Half Life 2

#32

It's a goal of mine to get Valve using Nix. (I hope our in-progress Windows support would make this especially compelling.) One advantage of this is that it will become very easy to not only build the original source of the game, but also build it with the original toolchain and dependencies, the toolchains for those dependencies, etc. etc., all the way down. Hopefully something like that at your finger trips would h…

> It's a goal of mine to get Valve using Nix

They’re using Arch Linux. Let’s call it a win and move on lol.

Re: A time-travelling door bug in Half Life 2

#33
post #22

>a big innovation of HL2 was the extensive use of a real physics engine. The door and the guard are both physical objects, both have momentum, they impart an impulse on each other, and although the door hinge is frictionless, the guard's boots have some amount of friction with the floor. It's been a while since I've played HL2 but this isn't exactly how I remember it. While a lot of things were physics objects I thou…

Just did some quick testing - the doors definitely have physics and can get stuck on objects and can impart forces. But unimpeded yes, they smoothly open/close.

I stuck a tire in a door frame and tried to close it, the tire emitted a bunch of dust clouds as the two objects fought before the door finally ejected the tire at high speed.

Re: A time-travelling door bug in Half Life 2

#34
post #27

I wonder how on earth stuff like x86->ARM translation works so well if games break even after switching from x87 registers to SSE preserving all the logic otherwise...

Rosetta uses software emulation for x87 floating point. That's slow, but in practice that doesn't matter much. Mac software never had a reason to use x87 FP, every Intel Mac had at least SSE3 support.

There was at least one reason...

    long double x87me(long double a, long double b) {
        return a+b;
    }

    pushq %rbp
    movq %rsp, %rbp
    fldt 32(%rbp)
    fldt 16(%rbp)
    faddp %st(1)
    popq %rbp
    retq

Re: A time-travelling door bug in Half Life 2

#35
post #30

> The door and the guard are both physical objects, both have momentum, they impart an impulse on each other I wonder if the term "impulse" here has any connection to the various impulse commands available in the source engine. I remember using "impulse 101" and causing havok in the opening plaza area. Spawning zombies on the roofs, sending them after the combine, etc. https://developer.valvesoftware.com/wiki/Impulse

Impulse is change in momentum: https://en.wikipedia.org/wiki/Impulse_(physics)

Re: A time-travelling door bug in Half Life 2

#36

This reminds me of an old bug in simdjson - any usage of it breaks std::unordered_map in unrelated parts of the code due to an unintentional modification of FPU flags: https://github.com/simdjson/simdjson/issues/169

Beautiful, and by that, I mean completely and utterly horrific.

Re: A time-travelling door bug in Half Life 2

#37
post #18

It seems to be typical - some calculations break while switching from x87 to SSE. The same happened with TF2 too - it's ammo calculation code worked slightly differently on GNU/Linux build of the game, because it was built with SSE instructions (Windows version still used x87).

I’m surprised to hear the ammo calculation code would use floats.

The game has ammo pickups that refill 20% and 50% of whatever your max ammo is, so floats have to be involved in there somewhere.

Re: A time-travelling door bug in Half Life 2

#38
post #37
post #18

Earlier quoted context omitted.

I’m surprised to hear the ammo calculation code would use floats.

The game has ammo pickups that refill 20% and 50% of whatever your max ammo is, so floats have to be involved in there somewhere.

Dividing by 5 or 2, respectively, are integers, if the game developers wanted them to be. More so because the actual units of ammo need to be integers if they are to render as full bullets each

Re: A time-travelling door bug in Half Life 2

#40
post #14

I wonder how on earth stuff like x86->ARM translation works so well if games break even after switching from x87 registers to SSE preserving all the logic otherwise...

I think x87 fpu is the only 'weird' floating point units left. I think if you stick with 64-bit double precision floats or 32-bit single precision floats, where the registers are also 64 or 32 bits, all the modern stuff behaves the same. x87 is just weird because registers are 80-bits ... the idea was to have more accurate results from more precision, but it ends up weird because if you run out of registers and have…

What about arm, with software floats its compiler depending?
Post reply on HN