mmp / pbrt-v2

Source code for the version of pbrt described in the second edition of "Physically Based Rendering"
http://pbrt.org
989 stars 343 forks source link

0 is incorrectly considered a power of 2 in function IsPowerOf2 #12

Closed GraphicsMe closed 10 years ago

GraphicsMe commented 11 years ago

In file /src/core/pbrt.h, fuction IsPowerOf2, 0 is considered a power of 2. The remedy is straight forward. Please check it out.

Humper commented 11 years ago

Wait, is zero not a power of two? When did they change that? ;)

Does this affect any actual renderings, or is this mostly for purity?

Humper commented 11 years ago

I just took a look at the places where we use IsPowerOf2; this fix shouldn't affect performance in any way. It's always used in places where 0 would be a nonsense value.

GraphicsMe commented 11 years ago

Of course this will not cause problem in PBRT, except that user accidentally provide nonsense parameter. Anyway, as a fan of PBRT, I often refer code from it and use it in other context. Just in case other people do that like me, IsPowerOf2 being correct itself is also important:)