POV-Ray : Newsgroups : povray.general : Minimum Distance Function : Re: Minimum Distance Function Server Time
10 May 2024 04:24:51 EDT (-0400)
  Re: Minimum Distance Function  
From: jceddy
Date: 13 Jul 2022 16:45:00
Message: <web.62cf2e1a6fb4e448864166f75d51d79c@news.povray.org>
>      There is something fundamentally wrong with your approach: the
> closest approach is not necessarily on a face that includes the closest
> vertex. If you look at the image I posted to p.b.i, when searching for
> the closest point to the cross in the bottom, the closest vertex is the
> red one, but the closest face is the orange one, which doesn't include

>

Yeah, I figured that out. :)

I am now finding the nearest vertex, then creating a bounding box around the
sample point that is large enough to contain the nearest vertex (plus a small
tolerance factor). Then I traverse the bounding box tree for the mesh and find
all leaves that overlap the sample bounding box, and calculate the minimum
distance for each leaf's triangle. The minimum of all of those is the minimum
distance to the mesh.

It performs fairly well (actually best performance of all my methods so far,
although still slows down quite a bit around detailed portions of the mesh where
it ends up sampling more triangles), and the output is great.

The output actually looks really good even if I turn max_gradient way down on
the isosurface (the actual max gradient is like 451, but I was turning it down
to 4 to get quick test renders).

Going to post some example outputs soon, then turn my attention to cleaning up
the code.

My current plan is to add a virtual method to object (probably called
"proximity") with a default behavior of ray sampling, or even just spitting out
a "not implemented for this object type" error, and then start overriding it for
the various object types.

Then will wire up an internal proximity function (I like proximity better than
"minimum distance"), and a proximity pattern type, as well, I think.

Oh, I also want to tinker around with doing an inverse translation on the sample
point and then translating the result vector back to measure it...I think it
might work the way I want now that I am not sampling the wrong set of triangles,
and if I can get it to work properly will allow me to remove a bunch of code I
added to Mesh to generate transformed versions of the vertex data and bounding
box tree.


Post a reply to this message

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