Fix floorPowerOfTwo

This commit is contained in:
Phillip Stephens 2022-03-02 23:50:07 -08:00
parent e9c0fe7a6e
commit 82a3a0def9
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
1 changed files with 1 additions and 6 deletions

View File

@ -190,12 +190,7 @@ CVector3f getBezierPoint(const CVector3f& a, const CVector3f& b, const CVector3f
int floorPowerOfTwo(int x) { int floorPowerOfTwo(int x) {
if (x == 0) if (x == 0)
return 0; return 0;
/* x = x | (x >> 1);
* we want to ensure that we always get the previous power,
* but if we have values like 256, we'll always get the same value,
* x-1 ensures that we always get the previous power.
*/
x = (x - 1) | (x >> 1);
x = x | (x >> 2); x = x | (x >> 2);
x = x | (x >> 4); x = x | (x >> 4);
x = x | (x >> 8); x = x | (x >> 8);