Open Masclins opened 7 years ago
Jo tinc molts dubtes de que calgui fer servir angles (i per tant sinus i cosinus) per a tot això xD
Amb els canvis del commit 9310b0910bf5f7b83b633e48e41e74f0b6a5cc14 (sinus i cosinus precalculats) n'hi ha prou o creus que s'hi pot fer encara més?
Recordo que vaig veure algo als bounce que em semblava molt sospitós però no recordo què
Ui, molt més! Hi ha moltes divisions que es poden canviar per multiplicacions, sh'an de revisar les funcions que deia (no han canviat encara), buscar si és possible fer el mateix amb l'acos, veure si podem implementar el fast square root...
No ens val un fast inverse square root, no?
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
return y;
}
Això és del codi font del Quake original :D
Si que val. Però vaig intentar imprementar-lo i em petava... no sé si cal fer algún
Per cert, també s'hauria de mirar de canviar els angles a int. Amb el nou sistema hauria de ser totalment viable.
2017-06-01 18:51 GMT+02:00 kenan-rhoton notifications@github.com:
No ens val un fast inverse square root, no?
float Q_rsqrt( float number ) { long i; float x2, y; const float threehalfs = 1.5F;
x2 = number 0.5F; y = number; i = ( long ) &y; // evil floating point bit level hacking i = 0x5f3759df - ( i >> 1 ); // what the fuck? y = ( float ) &i; y = y ( threehalfs - ( x2 y y ) ); // 1st iteration // y = y ( threehalfs - ( x2 y * y ) ); // 2nd iteration, this can be removed
return y; }
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pernilsalat/one-bot-to-rule-them-all/issues/4#issuecomment-305553682, or mute the thread https://github.com/notifications/unsubscribe-auth/AG700g7lOsZZ3g3KHt1bXvaq89IScHdvks5r_uwRgaJpZM4NssOq .
Pots provar els canvis a la pull request #6? No els puc provar jo localment, però crec que hauria d'anar més ràpid aquesta implementació de la sqrt.
Com deia, no millora. He provat també de canviar els angles a int... No ho dec haver fet bé, perquè provoca que els Bots es quedin quiets xD
Per aquests casos és que va molt bé fer-ho en una branca apart i fer una Pull Request, així podem fer un review i potser @pernilsalat o jo ens inspirem i trobem l'error 😄
Cal intentar optimitzar el temps d'execució de les simulacions. Això implica revisar (sobretot): Pod::bounce() Pod::bounce_w_pod() Pod::get_angle() play()