POV-Ray : Newsgroups : povray.binaries.animations : Uberpov persistent feature for animation of big scene : Re: Uberpov persistent feature for animation of big scene Server Time
23 Apr 2024 03:04:24 EDT (-0400)
  Re: Uberpov persistent feature for animation of big scene  
From: clipka
Date: 7 Jan 2018 04:39:47
Message: <5a51eae3$1@news.povray.org>
Am 07.01.2018 um 06:37 schrieb Kenneth:

> Uh... #define? I couldn't find that in the docs. A UNIX thing maybe??

A C/C++ thing. It's a miracle I'm not mixing it up with POV-Ray's
`#declare' more often.

> I was somehow thinking that the following kind of construct would work instead,
> and still be 'persistent' (although it's a strange example, I admit-- I wouldn't
> normally put #declares within a union)...
> 
> #ifndef(FOO)
> #persistent FOO =
> union{
> #declare TEX_1 = texture{...}
> #declare MY_BOX = box{0,1}
> object{MY_BOX texture{TEX_1}
> .....similar stuff...
> .....
> #end
> 
> object{FOO}
> 
> My guess is that the inner #declares are NOT 'persistent', even though they are
> wrapped in a #persistent block. (Assuming that my crazy union even works at
> all!!)

It should work fine as well.

The inner `#declare`s are indeed not persistent; however, their content
(or, more precisely, a copy thereof) is inserted into a union that /is/
persistent.

If it helps understand the concept, you might think of `#persistent` as
a "super-global" equivalent of `#declare`.

Take a look at the following macro, and compare it to your code:

    #macro MyMacro()
      #ifndef(FOO)
      #declare FOO =
        union {
          #local TEX_1 = texture{...}
          #local MY_BOX = box{0,1}
          object{MY_BOX texture{TEX_1}
          ...
        }
      #end
      object{FOO}
    #end

Note how this assembles a union from local variables (which "die" each
time the end of the macro is reached), and assigns the resulting object
to a global variable, which will still be "alive" if the macro is
invoked again later.

Now just like a macro's local variables "die" each time the end of the
macro is reached, but their contents can "survive" into the next macro
invocation if plugged into a global variable, so do global variables
"die" each time the "end of the frame" is reached, but their contents
can "survive" into the next frame if plugged into a persistent variable.


Post a reply to this message

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