News for hackers. Stuff that matters.
Re:Smallpt: Global Illumination in 99 lines of C++ (with no ... by jcl on Thursday January 14, 2010 @09:39AM (#1052663)
I love that they modeled the walls of the room with giant spheres... a wonderful hack to avoid having to support plane primitives while still producing something that looks like a Cornell box.
Re:Smallpt: Global Illumination in 99 lines of C++ (with no ... by profquail on Wednesday January 13, 2010 @08:00PM (#1051647)
Re:Smallpt: Global Illumination in 99 lines of C++ (with no ... by adamtj on Wednesday January 13, 2010 @07:52PM (#1051633)
It could be 1 line. sloc doesn't mean much for C++ unless the code is sanely formatted. E.g. an if/else should be at least 2 lines, usually 4.

Edit: That said, I'm still impressed.

Re:Smallpt: Global Illumination in 99 lines of C++ (with no ... by houseabsolute on Thursday January 14, 2010 @12:42AM (#1052025)
This is a sight more readable than some much more sanely formatted C++ programs I've read. What I've learned from this that it's often the simplicity of the program that's more important than the formatting. (Although formatting is of course still important and anyone who inflicts code like this on their coworkers doesn't reach my standard of "decent human being.")
Re:Smallpt: Global Illumination in 99 lines of C++ (with no ... by Luc on Thursday January 14, 2010 @03:23AM (#1052198)
The listing is contrained to 72 columns width, so it really couldn't be one line.
Re:Smallpt: Global Illumination in 99 lines of C++ (with no ... by jrockway on Thursday January 14, 2010 @12:43AM (#1052027)
Readable!
Re:Smallpt: Global Illumination in 99 lines of C++ (with no ... by lutorm on Wednesday January 13, 2010 @07:29PM (#1051598)
Nice. Though all of the 99 lines are >75 characters. With a more readable formatting it would be twice as long... ;-)
Re:Smallpt: Global Illumination in 99 lines of C++ (with no ... by benhoyt on Wednesday January 13, 2010 @09:01PM (#1051733)
Actually, all of the lines are <75 characters. But yeah, it'd be at least twice that long with a normal coding standard.
Re:Smallpt: Global Illumination in 99 lines of C++ (with no ... by coliveira on Wednesday January 13, 2010 @10:01PM (#1051811)
Actually, I think that this style is readable. The problem, though, it that it is hard to modify. Which would be a real trouble for code that needs to be maintained.
Re:Smallpt: Global Illumination in 99 lines of C++ (with no ... by miratom on Wednesday January 13, 2010 @08:26PM (#1051689)
Yes, this would be tons more philanthropic and if it were just readable. Just some simple line breaks and variable names that meant something. It's not impressive that you can just cram stuff into 99 lines.
Re:Smallpt: Global Illumination in 99 lines of C++ (with no ... by yason on Thursday January 14, 2010 @03:45AM (#1052219)
Actually, the code seemed to be a mess but was quite readable. I read it through. You could almost see all the code in once glance which is when you pretty much don't need formatting anymore, just some time to initially absorb the code.
Re:Smallpt: Global Illumination in 99 lines of C++ (with no ... by palish on Wednesday January 13, 2010 @09:20PM (#1051760)
I wish the source code was cross-platform. It doesn't build in Visual Studio.

  'erand48': identifier not found
  'M_PI' : undeclared identifier
Obviously #define M_PI 3.1415926 should do the trick, but I need to track down an erand48 replacement.
Re:Smallpt: Global Illumination in 99 lines of C++ (with no ... by romland on Wednesday January 13, 2010 @11:34PM (#1051913)
Re:Smallpt: Global Illumination in 99 lines of C++ (with no ... by jey on Wednesday January 13, 2010 @11:41PM (#1051923)
erand48 returns random doubles from [0.0, 1.0). The argument to erand48() is just a state vector (instead of the usual unsafe convention of having the RNG store its state internally). You can replace it with a call to any other equivalent random number generator.

http://www.opengroup.org/onlinepubs/000095399/functions/eran...