POV-Ray : Newsgroups : povray.programming : Yet another slight improvement (pattern.cpp - quilt_cubic) : Re: Yet another slight improvement (pattern.cpp - quilt_cubic) Server Time
8 Jul 2024 19:24:55 EDT (-0400)
  Re: Yet another slight improvement (pattern.cpp - quilt_cubic)  
From: Christopher James Huff
Date: 29 Dec 2002 22:19:47
Message: <chrishuff-BD1200.22152229122002@netplex.aussie.org>
In article <3e0faee1@news.povray.org>, "Tony[B]" <ben### [at] catholicorg> 
wrote:

> Came up with it today (Dec. 29). I know it's not a significant improvement,
> but at least it shouldn't hurt. With the current implementation, it takes 10
> multiplications and 3 additions/subtractions. My version shaves 3
> multiplications off the process... not to mention that it eliminates a bunch
> of temporaries, which I believe were only there for self-documentation, when
> instead you could simply spell it out in the comments.

A lot of the patterns are like that...I think they were there to help 
old compilers optimize somehow. They don't make much sense otherwise, my 
favorite example:
static DBL onion_pattern (VECTOR EPoint)
{
  /* The variable noise is not used as noise in this function */

  register DBL noise;

Writing a 50-some character comment instead of changing a 5 character 
variable name...I hope there was a really good reason to use the name 
"noise".
Some others are to prevent duplicated calculations when passed to macros 
like Sqr().

There are also inconsistencies and inefficiencies in the range 
clipping...the pattern code could be greatly improved.

While you are at it, the wood pattern takes the 3D length of a vector 
where 2D would suffice...you could save a multiplication and addition. 
There are "bigger fish to fry" though...making these patterns as fast as 
possible will only speed POV a little. An algorithm improvement 
elsewhere (like transparency calculation) could accomplish much more.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.