POV-Ray : Newsgroups : povray.general : Differences with Large Unions : Re: Differences with Large Unions Server Time
8 Aug 2024 04:09:55 EDT (-0400)
  Re: Differences with Large Unions  
From: Francois Labreque
Date: 13 Mar 2001 08:19:50
Message: <3AAE1DCD.AF359EBD@videotron.ca>
Geoff Wedig wrote:
> 
> I have a union of many small, mostly disjoint objects, and now I need to do
> a difference with them.  From past experience, when I do an intersection
> with such a conglomeration, it turns it into a single large object that is
> only bounded at the largest extent, and slows down the render a lot.  I may
> not have the above correct, but it certainly slows the render down a lot.
> 
> Since the section I have to cut out is small, and doesn't intersect most of
> the objects, I'm wondering if there might be a better way.  I'm thinking
> doing a check to see if each individual object intersects the cutout, and if
> so, do a difference with it.  Otherwise, don't.  Take the union of all that.
> Most of the objects would not be affected.

You could turn off auto-bounding and manually bound your objects.

> 
> The only problem is how to determine if the cutout and the union object
> intersect.  Does anyone have any ideas how to do this?  Can we access the
> bounding boxes POV generates?

In MegaPOV, you can use the max_extent() and min_extent() functions to
do just that.

>  That would probably be ideal, since it's
> trivial to check if two boxes intersect, but is there another, faster way to
> do this (I'm somewhat concerned about trading the parse time for render
> time, though in this case, parse time will be cheap comparatively)
> 
> Also, has anyone considered automating such an algorithm?  It seems to me
> that POV could, when seeing code like:
> 
> difference
> {
>   union
>   {
>     smallobject1
>     smallobject2
>     smallobject3
>     smallobject4
>     .
>     .
>     .
>     smallobjectn
>   }
>   anotherobject
> }
> 
> it could turn it into:
> 
> union
> {
>   difference { smallobject1 anotherobject }
>   smallobject2
>   smallobject3
>   smallobject4
> }
> 
> assuming that only smo1 intersected ano's bounding box.  I would think this
> would speed things up.  Could work for intersections too.  Of course, some
> heuristics would need to be generated to determine when to do the level
> swapping, and I have no idea how to do that.

It would indeed appear to be feasible, but a b*tch to program as YOU
know that you want to cut out ano from smo1, but POV has no way of
knowing that this is what YOU want.  Unless your objects are randomly
placed at runtime (or move around in an animation), I think it's
probably better if you optimise your CSG-tree by hand.

-- 
Francois Labreque | And a four year old carelessly banging on a toy
    flabreque     | piano is not only 'music', it's probably the last
        @         | moment of 'artistic purity' they'll ever enjoy
   videotron.ca   | before outside influences start corrupting their
                  | expression.    - Chris R.


Post a reply to this message

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