POV-Ray : Newsgroups : povray.beta-test : Texture translation bug with Center_Trans() : Re: Texture translation bug with Center_Trans() Server Time
28 Jul 2024 18:12:16 EDT (-0400)
  Re: Texture translation bug with Center_Trans()  
From: Tom York
Date: 22 Feb 2008 20:55:01
Message: <web.47bf7c091751335e7d55e4a40@news.povray.org>
There doesn't seem to be any way yet to feed back proposed fixes for defects
except through the newsgroups, so:

I think I've found the problem using a minor simplification of Tim's scene and
the recently released Beta 3.7 source. In csg.cpp#40, in the 3.7.beta.25b
source archive, CSG::Transform is defined as:

void CSG::Transform(TRANSFORM *tr)
{
  for(vector<ObjectPtr>::iterator Current_Sib = children.begin(); Current_Sib !=
children.end(); Current_Sib++)
    (*Current_Sib)->Transform(tr);

  Recompute_BBox(&BBox, tr);
}

This is only called when you use a transform {} block with a CSG object.
Changing

(*Current_Sib)->Transform(tr);

to

Transform_Object (*Current_Sib, tr);

seems to fix the problem, because the former only sets up the transforms on the
child geometry (a cylinder in this case) whereas Transform_Object calls the
needful transformations on the textures as well (and some other stuff). The
latter also looks more like the implementation of CSG::Translate, CSG::Rotate
and CSG::Scale (which are called to handle your transforms when you don't use a
transform block).

For reference, the final minimal scene is included below. Both the red->blue
texture and the black->white texture should appear as smooth vertical gradients
following the fix. I can't guarantee that this fix does not cause unintended
regressions.

camera {
   location <0,1,-4>
   look_at <0,0,0>
   angle 30
}

light_source {
   <1,1,-1>*10 color rgb 1
}

union {
   cylinder {
      <0,0,0>, <0,1,0>, 0.1
      pigment {
         gradient y
         color_map {
            [0 color <1,0,0>]
            [1 color <0,0,1>]
         }
      }
   }
   transform {translate <0.25,-0.5,0>}// this transform misaligns texture
}

union {
   cylinder {
      <0,0,0>, <0,1,0>, 0.1
      pigment {
         gradient y
         color_map {
            [0 color <0,0,0>]
            [1 color <1,1,1>]
         }
      }
   }
   translate <-0.25,-0.5,0>// this transform doesn't misalign texture
}


Post a reply to this message

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