*** yuitimothy is back | 00:07 | |
*** FastLizard4 is now away: AWAY from keyboard | 00:28 | |
*** yuitimothy is now away: I've done some soul-searching and I still can't find it. | 01:58 | |
*** yuitimothy is back | 02: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 #bzflag | 02:48 | |
*** FastLizard4 is back | 03:07 | |
*** FastLizard4 is now away: AWAY from keyboard | 03:08 | |
*** FastLizard4 is back | 03:11 | |
*** FastLizard4 is now away: AWAY from keyboard | 03: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: offline | 06:59 | |
*** Cobra_Fast is back | 06:59 | |
*** Lantizia <Lantizia!~Lantizia@user/lantizia> has joined #bzflag | 07:47 | |
*** I_Died_Once <I_Died_Once!~I_Died_On@c-73-184-170-223.hsd1.ga.comcast.net> has joined #bzflag | 10:59 | |
*** FastLizard4 is back | 13:59 | |
BZNotify | 2.4 @ bzflag: atupone pushed 1 commit (https://github.com/BZFlag-Dev/bzflag/compare/9647e26d76e7...a6a10509463a): | 14:23 |
---|---|---|
BZNotify | 2.4 @ bzflag: atupone a6a105: Another divide by zero avoided (https://github.com/BZFlag-Dev/bzflag/commit/a6a10509463a42513e1f4e5f88abe3dfb4c4ceb3) | 14:23 |
Agatha | Again, 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 |
tupone | I believe you. I remove one case, where all values are 0. I know that there are other cases | 15:01 |
tupone | I think it will be better to centralize normalization and do all the test there | 15:03 |
tupone | actually 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 |
Agatha | I 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 |
tupone | but a plane with a,b,c == 0 ? | 15:12 |
Agatha | a=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 |
tupone | but if you put 0,0,1 what to do with w ? | 15:15 |
tupone | :/ | 15:15 |
* Agatha shrug | 15:15 | |
Agatha | Do 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 |
Agatha | And 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 |
tupone | I 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 shout | 15:18 |
tupone | Also looking at fast normalization if avoid these problems at a cost on precision | 15:21 |
*** FastLizard4 is now away: AWAY from keyboard | 15:28 | |
tupone | what do you think about : | 16:08 |
tupone | float 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 |
tupone | and then maybe personalize if AVX | 16:09 |
*** FastLizard4 is back | 16:33 | |
*** FastLizard4 is now away: AWAY from keyboard | 16: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 | |
Agatha | I 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 |
Agatha | For 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 |
Agatha | For 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 |
Agatha | If 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 back | 18:20 | |
*** FastLizard4 is now away: AWAY from keyboard | 18:55 | |
tupone | with AVX I meant using the fast-inverse-square-root available from the CPU with avx, That I guess uses a variation of the quake algorithm | 19:20 |
Agatha | The 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 back | 20:06 | |
BZNotify | 2.4 @ bzflag: atupone pushed 1 commit (https://github.com/BZFlag-Dev/bzflag/compare/a6a10509463a...c09eaa285ad7): | 20:15 |
BZNotify | 2.4 @ bzflag: atupone c09eaa: use bzInverseSqrt (https://github.com/BZFlag-Dev/bzflag/commit/c09eaa285ad7c2b5c2f86bceb6573cb5849af88a) | 20:15 |
tupone | I 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 intrinsics | 20:17 |
Agatha | Nice. Also note: -ffast-math will give you `rsqrtss` automatically with no code changes. | 20:21 |
*** FastLizard4 is now away: AWAY from keyboard | 20:25 | |
Agatha | What 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 |
Agatha | Personally 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 |
tupone | I'm already porting the entire code to use glm, even if here is not appreciated. | 20:33 |
Agatha | GLM would be an excellent upgrade to bz's math system, so FWIW I at least support you in that | 20:35 |
tupone | I could push my last version of it on my forked repo | 20:37 |
*** FastLizard4 is back | 21:10 | |
BZNotify | bzflag: 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 |
BZNotify | bzflag: atupone edited pull request #334 "Use glm" (https://github.com/BZFlag-Dev/bzflag/pull/334) | 21:24 |
tupone | That is. Time to sleep | 21:24 |
*** FastLizard4 is now away: AWAY from keyboard | 21:48 | |
*** FastLizard4 is back | 22:06 | |
*** FastLizard4 is now away: AWAY from keyboard | 22:15 | |
*** yuitimothy is now away: I've done some soul-searching and I still can't find it. | 23:32 | |
*** yuitimothy is back | 23:37 | |
*** Sgeo <Sgeo!~Sgeo@user/sgeo> has joined #bzflag | 23:39 |
Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!