Results 1 to 6 of 6

Thread: Epiphany

  1. #1
    Join Date
    Dec 2006
    Location
    Netherlands
    Posts
    983

    Default Epiphany

    anyone who has coded knows how frustrating bugs can be... especially if your code was working fine but you just had to make it nicer, better, future proof, name whatever reason you had.
    Last weekend I was having a little coding session, cleaning up and finalizing the form of the 3D engine. Integers were bugging me all the time so all processing needed to be done in doubles to avoid casts everywhere. One additional change: the final switch to a different frame of reference (OpenGL standard) and VOILA, Zoof's engine running stronger, smoother and better.

    Right......, until I noticed silly little lines going in the wrong direction every now and then. A little bug managed to sneak into the code. It is something to do with far- and near-plane clipping but it is very irregular and unpredictable. Too many changes implemented in one go, so going back on my track is not going to work (of course I did try). I know where to look but I'm clueless to how exactly the exception is generated. Usually I'm pretty good at finding exceptions, variables tend to go to zero or to infinity but this time no such luck.
    Every evening of the past week I spent finding the little bug until I decided last night to let it go and stop ruining my life.

    Now, sitting at my desk: Epiphany, there it is: crystal clear and obvious, even without having my code here to look at. Three lines of obsolete code need to be removed - they used to serve as an extra check but now they mess up the return value of the clipping function in the special case where the clipping point coincides with the original point...... It is a matter of "<" versus "=<"... d*amn.

    This is just so typical of the laser habit, once you think you can relax and back off a bit, something will make you go back at it harder than you were. I'm sure this little success is will have me floating around high on photons the coming weekend.

  2. #2
    Join Date
    Dec 2008
    Location
    Austin, TX
    Posts
    61

    Default

    Awesome work! I'm always amazed when I manage to squash an annoying bug - it seems like chance can play a role - your eyes just happen to fall on the right bit of code at the right time, you fix it, and everything falls into place.

    OpenGL is a natural for lasers, isn't it? I'm using OpenGL extensively in my little laser software project as well. Even low end GL cards these days have insanely power chips that can serve us as DSPs.

  3. #3
    Join Date
    Dec 2006
    Location
    Netherlands
    Posts
    983

    Default

    That is exactly why I was switching to the OGL reference frame, so it can be sent to a graphics card for processing or to any other (HW/SW) graphics processing unit.

    The need for that is not so high since the main limitation of the system is the point rate of the scanner. 1500 visible points in a scene is already a lot for 30k scanners and your average computer can easily handle that.

    When (if) I want to deal with true 3D graphics, consisting of polygons and surfaces instead of just points (like the ILDA format), it will probably make sense to use the graphics card for processing - no experience there yet.

  4. #4
    Join Date
    Sep 2007
    Location
    Omaha, NE
    Posts
    769

    Default

    Great to hear! I think that sometimes it turns into a battle of the conscious vs the unconsious mind (for me anyway). I notice that if I am coding in a 51+% conscious approach, it feels "forced". If I am relaxed and lucid while coding, like 51+% unconscious, the code just seems to write itself! Some of this 3D code- especially clipping is pretty heady stuff- I think you are doing some great things that I would be frightened to science out. More pics! More Vids!
    -Mike


  5. #5
    Join Date
    Dec 2006
    Location
    Pflugerville, TX, USA
    Posts
    1,977

    Default

    I create 3 bugs for every new enhancement.

    I'm using DirectX for same reasons you are using OpenGL, most likely.

  6. #6
    Join Date
    Dec 2006
    Location
    Netherlands
    Posts
    983

    Default

    I've done the clipping in 3D coordinates, so the line intersections need to be computed for the 6 clipping planes. Rather straight forward once you have the solution down - sometimes it is better to clear out all previous code and re-implement the solution after having learned how to do it.

    Actually I'm not using openGL at all but I decided that the implementation of my code should be similar to openGL conventions for possible future merging. Basically this comes down to following the openGL definition of a matrix, which different than standard c++ definition and the choice of reference frame.

    I don;t like the standard openGl reference frame for modeling and object/vehicle dynamic. An engineering approach to vehicle (aircraft) dynamics usually uses: x:forward, y:right and z:down approach.
    I like x to be forward but when modeling a world, the z-down causes the xy plane to be mirrored when simply flipping the z value. Therefore I defined the the x:forward, y:left, z:up reference frame best.

    Just to make sure the compatibility I implemented a reference frame conversion matrix that allow the programmer to use any right hand reference frame. Internally it is converted to the openGl standard for projection.

    I'm glad I got that all done now, now I'm optimizing and fixating the engine, and it is finally time form more visible creative work

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •