Mark Sachs (ksleet) wrote,
Mark Sachs
ksleet

  • Mood:
  • Music:

Raytracer update.

For some reason today I decided to just roll up my sleeves and dig into the planetary raytracer and figure out why it runs so damn slow. I just went through the rendering loop step by step, excising pieces to see what effect it would have on final run speed. And wouldn't you know it -- it turns out that std::list is very, very slow when it comes to inserting items into the list or even creating one as a local variable in a function. I had been using std::list to maintain the list of items struck by the ray as it passes through the scene; I replaced it with a custom-designed data structure that never allocates any memory, but merely files struck objects into a preallocated list and hooks up pointers along the way to indicate the order they should appear in, and the program's speed jumped hugely.

It's not quite at the stage where you could use it in a realtime game (at least on a machine that runs like my wheezy old PC) but it's... close, closer than I thought it would ever get on this machine. That's not bad.

(Yeah, I know, in retrospect it shouldn't have been surprising about std::list, but I wasn't expecting it to be that slow. Anyway, though.)
Tags: raytracer
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 5 comments