13 Followers
61 Following
95 Posts
Working on a Physics Engine

Got a pretty trippy vid when debugging.

#gamedev #indiedev #physics

My fluid sim can push rigid bodies around now.

#screenshotsaturday #gamedev #indiegame

6IT

6IT

Spent my holidays stacking imaginary boxes.

#physics #gamedev #graphics

My VR physics engine is slowly coming together

#screenshotsaturday #vr

clang and gcc are surprisingly bad at dividing by seven:

https://godbolt.org/z/vPqfeMeYe

Having upper bounds makes the problem a lot simpler, and there's a great 2011 post improving the general case: https://ridiculousfish.com/blog/posts/labor-of-division-episode-iii.html

But both compilers mostly just use the exact method from Hacker's Delight, regardless of the register size. It's not a big deal, but not somewhere I expected to see room for improvement.

Compiler Explorer - C++

// u8 uint32_t div_7_u8(uint8_t v) { return v / 7; } uint32_t div_7_u8_optimised(uint8_t v) { return (v * 0x125) >> 11; } uint32_t div_7_u8_optimised_mulh(uint8_t v) { // MULH is fast on Apple CPUs, but slow on some low-end Arm-designed CPUs return ((unsigned __int128)v * (0x125ull << (64-11))) >> 64; } // u16 uint32_t div_7_u16(uint16_t v) { return v / 7; } uint32_t div_7_u16_optimised(uint16_t v) { return ((uint64_t)v * 0x12493) >> 19; } // u32 uint32_t div_7_u32(uint32_t v) { return v / 7; } uint32_t div_7_u32_optimised(uint32_t v) { // MULH is fast on Apple CPUs, but slow on some low-end Arm-designed CPUs return ((__int128)v * 0x24924924a0000000) >> 64; } uint32_t div_7_u32_optimised_fish(uint32_t v) { // https://ridiculousfish.com/blog/posts/labor-of-division-episode-iii.html return ((v * (uint64_t)1227133513) + 1227133513) >> 33; } // u64 uint64_t div_7_u64(uint64_t v) { return v/7; } uint64_t div_7_u64_optimised(uint64_t v) { // https://ridiculousfish.com/blog/posts/labor-of-division-episode-iii.html if (v + 1) v += 1; // saturating add return ((unsigned __int128)v * 0x9249249249249249) >> (64+2); }

My engine is slowly beginning to resemble a game.
There could be 20 different things causing this.

Added some stabilization to my rigid body sim.

#physics