POV-Ray : Newsgroups : povray.general : Sparse Data : Re: Sparse Data Server Time
11 Aug 2024 13:21:24 EDT (-0400)
  Re: Sparse Data  
From: Nieminen Mika
Date: 9 Jul 1999 02:35:50
Message: <37859846@news.povray.org>
Chris Huff <Chr### [at] compuservecom> wrote:
:>Dynamic memory allocation is not possible in povray.

: Actually, it is, because POV-Ray is written in C, and the scene
: description language is interpreted. I believe it dynamically allocates
: the objects and variables (using pre-allocated memory for speed) as it
: parses them, doesn't it?

  I think that we are talking about different things here.

  You can't make a list structure with the povray script language. Arrays
are a bad substitute since you can't change their size after creation.

  I think that 'new' and 'delete' along with pointers may be a good idea
for the next povray version (perhaps pov4?).
  Something like:

#declare MyObject =
  sphere
  { 0,1 pigment { rgb 1 }
    MyObject* next;
  }

#declare ObjectList = null;

#declare Ind=0;
#while(Ind<100)
  #declare Obj = new MyObject;
  #declare Obj.next = ObjectList;
  #declare ObjectList = Obj;
  #declare Ind=Ind+1;
#end

#declare Obj = ObjectList;
#while(Obj != null)
  object { Obj translate x*Ind }
  #declare Obj = Obj.next;
#end


  It shouldn't be very difficult to achieve...

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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