POV-Ray : Newsgroups : povray.programming : Mesh code : Re: Mesh code Server Time
8 Jul 2024 19:10:45 EDT (-0400)
  Re: Mesh code  
From: Christopher James Huff
Date: 24 Dec 2002 13:35:44
Message: <chrishuff-FAED53.13305524122002@netplex.aussie.org>
In article <3e08a125$1@news.povray.org>,
 "Thorsten Froehlich" <tho### [at] trfde> wrote:

> In article <chr### [at] netplexaussieorg> , 
> Christopher James Huff <chr### [at] maccom>  wrote:
> 
> > this code has no effect other than screwing up my patch.
> 
> So it works as designed? ;-)

Heh...
Well, it actually does do something, but it does more work than it needs 
to. It swaps the vertices and then passes them to another function. I 
changed it to pass them in a different order, the code is cleaner IMO 
and slightly faster, though not in a place where it really matters.

Basically, replace the following in Compute_Mesh_Triangle():

    Assign_Vector(T1, P1);
    Assign_Vector(P1, P2);
    Assign_Vector(P2, T1);

    if (Smooth)
    {
      temp = Triangle->N2;
      Triangle->N2 = Triangle->N1;
      Triangle->N1 = temp;
    }
  }

  if (Smooth)
  {
  //  compute_smooth_triangle(Triangle, P1, P2, P3);
  Triangle->Smooth = true;
  }

    compute_smooth_triangle(Triangle, P1, P2, P3);

With this:
        if(Smooth)
        {
            temp = Triangle->N2;
            Triangle->N2 = Triangle->N1;
            Triangle->N1 = temp;
            Triangle->Smooth = true;
        }
        compute_smooth_triangle(Triangle, P2, P1, P3);
    }
    else
    {
        if(Smooth)
            Triangle->Smooth = true;
    
        compute_smooth_triangle(Triangle, P1, P2, P3);
    }

And get rid of the T1 variable. And if compute_smooth_triangle() really 
does something needed for flat triangles, that should probably be pulled 
out.

-- 
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.