POV-Ray : Newsgroups : povray.newusers : is this a bug? : is this a bug? Server Time
4 Sep 2024 18:16:32 EDT (-0400)
  is this a bug?  
From: Justin Smith
Date: 15 Oct 2002 01:30:05
Message: <web.3daba6a220f0896cad7bbeaa0@news.povray.org>
I got an "access violation exception" when I tried to use a macro I created.
The macro is called from within the function block of an isosurface object
(which is itself contained in another macro). Eventually, this macro will
be recursive so as to create the branching structure of a tree.

Here's the relevent part of the isosurface function definition. This isn't
where the actual problem is. I'm just pasting it to show that I've properly
declared my variables referred to later:

#macro broom_trunk(base_radius,Height,ramification,max_fork)
  isosurface
  {
    function
    {
      #declare Blob_Threshold = .05;
      #declare branchDepth = 0;
      #declare iter = array[6];
      #declare Seed = seed(12);
      #local currentCenterX = 0;
      #local currentCenterY = 0;
      #local currentCenterZ = 0;
      #local targetCenterX = 0;
      #local targetCenterY = 0;
      #local targetCenterZ = 0;
      #local width_numerator = -.2;
      #local width_denominator = 49;
      #local move_Y = Height/125;
      #local move_Y_units = Height/5;
      #local targetCenterY = move_Y * move_Y_units;
      (1+Blob_Threshold)
      gen_branch(branchDepth)
    }

Okay, so here is the macro that's causing the problem. I know this is the
one causing the problem because I've commented everything out, and then
progressively
uncommented stuff until I got an error.

#macro gen_branch(branch_depth)
  #declare iter[branch_depth]=0;
  #while(iter[branch_depth] < move_Y_units)

-pow(Blob_Threshold,f_torus(x/(1+(iter[branch_depth]*(width_numerator/width_denominator)))
- currentCenterX,
         y-(iter[branch_depth]/move_Y) - currentCenterY,
         z/(1+(iter[branch_depth]*(width_numerator/width_denominator))) -
currentCenterZ,
         base_radius/(1+branch_depth)),(base_radius/(1+branch_depth)/10)))
    #declare iter[branch_depth] = iter[branch_depth] + 1;
  #end /*

-pow(Blob_Threshold,f_sphere(x/(1+(iter[branch_depth]*(width_numerator/width_denominator)))
- currentCenterX,
       y-(iter[branch_depth]/move_Y) - currentCenterY,
       z/(1+(iter[branch_depth]*(width_numerator/width_denominator))) -
currentCenterZ,
       base_radius/(1+branch_depth)))
  #if(branch_depth < ramification)
    #local numbranches = 2 + rand(Seed)*(max_fork-2);
    #local branchiter = 0;
    #while(branchiter < numbranches)
      #local currentCenterX = targetCenterX +
(rand(Seed)*((base_radius/(1+branch_depth))/2));
      #local currentCenterZ = targetCenterZ +
sqrt(pow((base_radius/(1+branch_depth))/2,2) - pow(currentCenterX,2));
      #local currentCenterY = targetCenterY;
      #local targetCenterX = (Height/(branch_depth+1) );
      #local branchiter = branchiter + 1;
    #end
  #end */
#end

As I paste this now, you may see that a large portion of that is still
commented out. The problem is contained within the while-loop that uses
torus objects. It might be repeated in the 2nd while-loop as well since
they share similar numbers.

I know looking through all that to find a specific answer is probably a bit
much to ask for, and if it is, then even just a general idea of what causes
access violation exceptions might be helpful.

Thanks.


Post a reply to this message

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