IRC logs of Libera.Chat #BZFlag for Wednesday, 2024-05-01

*** yuitimothy is back00:07
*** FastLizard4 is now away: AWAY from keyboard00:28
*** yuitimothy is now away: I've done some soul-searching and I still can't find it.01:58
*** yuitimothy is back02:07
*** _I_Died_Once <_I_Died_Once!~I_Died_On@c-73-184-170-223.hsd1.ga.comcast.net> has quit IRC (Read error: Connection reset by peer)02:46
*** I_Died_Once <I_Died_Once!~I_Died_On@c-73-184-170-223.hsd1.ga.comcast.net> has joined #bzflag02:48
*** FastLizard4 is back03:07
*** FastLizard4 is now away: AWAY from keyboard03:08
*** FastLizard4 is back03:11
*** FastLizard4 is now away: AWAY from keyboard03:11
*** BZuser172 <BZuser172!~BZuser172@2.59.157.42> has quit IRC (Quit: Client closed)04:01
*** I_Died_Once <I_Died_Once!~I_Died_On@c-73-184-170-223.hsd1.ga.comcast.net> has quit IRC (Ping timeout: 260 seconds)04:21
*** Sgeo <Sgeo!~Sgeo@user/sgeo> has quit IRC (Read error: Connection reset by peer)05:46
*** Cobra_Fast is now away: offline06:59
*** Cobra_Fast is back06:59
*** Lantizia <Lantizia!~Lantizia@user/lantizia> has joined #bzflag07:47
*** I_Died_Once <I_Died_Once!~I_Died_On@c-73-184-170-223.hsd1.ga.comcast.net> has joined #bzflag10:59
*** FastLizard4 is back13:59
BZNotify2.4 @ bzflag: atupone pushed 1 commit (https://github.com/BZFlag-Dev/bzflag/compare/9647e26d76e7...a6a10509463a):14:23
BZNotify2.4 @ bzflag: atupone a6a105: Another divide by zero avoided (https://github.com/BZFlag-Dev/bzflag/commit/a6a10509463a42513e1f4e5f88abe3dfb4c4ceb3)14:23
AgathaAgain, this sort of thing doesn't even work. You *must* test by epsilons. Try your code with   plane[]={0,0,1e-23,0}   if you don't believe me. Your computed plane will be   {NaN,NaN,Inf,NaN}.14:59
tuponeI believe you. I remove one case, where all values are 0. I know that there are other cases15:01
tuponeI think  it will be better to centralize normalization  and do all the test there15:03
tuponeactually in this last case I don't know what to do. It is normalizing x, y, z and w? What to do on it ?15:06
AgathaI think I understand. Superficially, I expect the format to be   {a,b,c,d}   in the plane equation   ax+by+cz+d=0. The {a,b,c} can be interpreted as the plane's normal vector. You want to normalize it, so you can scale the whole LHS of the equation by the normalization factor, which doesn't change the plane.15:11
tuponebut a plane with a,b,c == 0 ?15:12
Agathaa=b=c = 0   would be, I guess, ℝ³ itself, not even a plane. Specifying it to the function is in my book an error, but if you want to make it robust to such input, I guess you could interpret it as 0,0,1 or something.15:13
tuponebut if you put 0,0,1 what to do with w ?15:15
tupone:/15:15
* Agatha shrug15:15
AgathaDo whatever you like. Set to 0, for example. The thing is it's not a plane anymore; there's no "right" answer to an incorrect situation.15:16
AgathaAnd yes, centralizing the normalization (ideally in some vector class, but at least in some function) seems like a great idea to me. As above, I suggest computing the squared length, and then only divide by its square-root if it's larger than some epsilon; else do some kind of error handling (numerical fallback, throw an exception, trip an assert, etc.).15:17
tuponeI do not know where these value come from. Maybe we need to investigate the source of the problem. I only know that my client detect it and shout15:18
tuponeAlso looking at fast normalization if avoid these problems at a cost on precision15:21
*** FastLizard4 is now away: AWAY from keyboard15:28
tuponewhat do you think about :16:08
tuponefloat bzInverseSqrt(float x)16:08
tupone{16:08
tupone    if (x <= 1.0E-6)16:08
tupone        return 1.0E6;16:08
tupone    return 1.0f / sqrtf(x);16:08
tupone}16:08
tuponeand then maybe personalize if AVX16:09
*** FastLizard4 is back16:33
*** FastLizard4 is now away: AWAY from keyboard16:53
*** FastLizard4 is now away: GONE - Screen Detached and Disconnected from IRC (I'm probably asleep, at work, or doing something in real life)17:23
AgathaI think maybe the inverse square-root shouldn't be the place that gets the functionality pulled out. Admittedly it probably isn't used anywhere except for computing the normalization factor for a vector.17:55
AgathaFor this function, note that 1/⎷1e-6 is 1e3. Also maybe invert the test to catch NaNs too:   if (!(x>1.0e-12f)) return 1.0e6f;17:55
AgathaFor the particular application of computing a normalization factor, worth noting that you probably don't save too much by doing one division and then three multiplies versus just three divisions. Division is of course way slower than multiplication, but the autovectorizer (or at least the ALU's pipelining) will make the divisions operate in parallel.17:58
AgathaIf this is really a performance bottleneck (profile!) you can use the three-multiplies approach with the near-legendary fast-inverse-square-root algorithm.17:59
*** FastLizard4 is back18:20
*** FastLizard4 is now away: AWAY from keyboard18:55
tuponewith AVX I meant using the fast-inverse-square-root available from the CPU with avx, That I guess uses a variation of the quake algorithm19:20
AgathaThe one of interest is for SSE 1 (access scalar with `_mm_rsqrt_ss(⋯)` or parallel with `*_ps`), which will be available more places anyway.20:03
*** FastLizard4 is back20:06
BZNotify2.4 @ bzflag: atupone pushed 1 commit (https://github.com/BZFlag-Dev/bzflag/compare/a6a10509463a...c09eaa285ad7):20:15
BZNotify2.4 @ bzflag: atupone c09eaa: use bzInverseSqrt (https://github.com/BZFlag-Dev/bzflag/commit/c09eaa285ad7c2b5c2f86bceb6573cb5849af88a)20:15
tuponeI did without SSE/AVX now. Will see if needed, and, In case, need to change the configure/Makefile to select variation, or add some library for intrinsics20:17
AgathaNice. Also note: -ffast-math will give you `rsqrtss` automatically with no code changes.20:21
*** FastLizard4 is now away: AWAY from keyboard20:25
AgathaWhat I was saying earlier about where you pull the functionality out—every one of these cases is normalizing by vector length, so I recommend you make that the abstraction point. E.g. just call   `bzNormalize(vec);`   or whatever instead of   `float rl=bzInverseSqrt(vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]); vec[0]*=rl; vec[1]*=rl; vec[2]*=rl;`,   etc. every single time. Much less code to maintain and far clearer what you're doing.20:27
AgathaPersonally I'd implement something like:20:33
Agatha    inline float vec_dot( Vec3f const& a, Vec3f const& b ) { return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; }20:33
Agatha    inline float vec_len_sq( Vec3f const& vec ) { return vec_dot(vec,vec); }20:33
Agatha    inline float vec_len   ( Vec3f const& vec ) { return std::sqrt(vec_len_sq(vec)); }20:33
Agatha    inline Vec3f vec_normalize     ( Vec3f const& vec ) { return vec/vec_len(vec); }20:33
Agatha    inline Vec3f vec_normalize_fast( Vec3f const& vec ) { return vec*rsqrt(vec_len_sq(vec)); }20:33
tuponeI'm already porting the entire code to use glm, even if here is not appreciated. 20:33
AgathaGLM would be an excellent upgrade to bz's math system, so FWIW I at least support you in that20:35
tuponeI could push my last version of it on my forked repo20:37
*** FastLizard4 is back21:10
BZNotifybzflag: atupone synchronized pull request #334 "Use glm instead of our vectors.h and vector_old.h" (https://github.com/BZFlag-Dev/bzflag/pull/334)21:23
BZNotifybzflag: atupone edited pull request #334 "Use glm" (https://github.com/BZFlag-Dev/bzflag/pull/334)21:24
tuponeThat is. Time to sleep21:24
*** FastLizard4 is now away: AWAY from keyboard21:48
*** FastLizard4 is back22:06
*** FastLizard4 is now away: AWAY from keyboard22:15
*** yuitimothy is now away: I've done some soul-searching and I still can't find it.23:32
*** yuitimothy is back23:37
*** Sgeo <Sgeo!~Sgeo@user/sgeo> has joined #bzflag23:39

Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!