POV-Ray : Newsgroups : povray.programming : Mapping warps+transformation bug (job000212) Server Time
23 Dec 2024 11:30:14 EST (-0500)
  Mapping warps+transformation bug (job000212) (Message 1 to 1 of 1)  
From: Massimo Valentini
Subject: Mapping warps+transformation bug (job000212)
Date: 8 Nov 2002 12:34:09
Message: <3dcbf591@news.povray.org>
This is a known bug (taken from
http://www.povray.org/download/3.5-bugs.php    

in particular from
http://news.povray.org/Xns9190F27EBFE9Bcsbhccse@204.213.191.226 )

and is related to the fact that, in the function UnWarp_Normal
(in the file warps.cpp), when there are more transforms, you are 
applying them in the wrong order. They have to be applied in the
reverse order respect to the Warp_Normal function.

Here is a provisional solution that make use of a fixed size,
local stack of pointer. It's only useful to see where is the 
problem.

(patch against warps.cpp of the linux sources, version povray-3.50a)

HTH Massimo

--- src/warps.cpp.ex 2002-11-08 18:07:46.000000000 +0000
+++ src/warps.cpp 2002-11-08 18:08:03.000000000 +0000
@@ -344,10 +344,12 @@
   }
 }
 
+#define MAX_TRANSFORM 10
+
 void UnWarp_Normal (VECTOR TNorm, VECTOR ENorm, TPATTERN *TPat, int DontScaleBumps)
 {
-   WARP *Warp=TPat->Warps;
-   TRANS *Tr;
+  TRANSFORM*  trans_stack[MAX_TRANSFORM];
+  int         n_trans = 0;
 
   if(!DontScaleBumps)
   {
@@ -358,25 +360,26 @@
     Assign_Vector(TNorm,ENorm);
   }
 
-   while (Warp != NULL)
+  for (WARP *Warp=TPat->Warps; Warp; Warp = Warp->Next_Warp)
    {
-      switch(Warp->Warp_Type)
+    if (Warp->Warp_Type == TRANSFORM_WARP)
       {
-        case NO_WARP:
-          break;
-
-        case TRANSFORM_WARP:
-          Tr=(TRANS *)Warp;
-          MTransNormal(TNorm, TNorm, &(Tr->Trans));
-          break;
-          
-        /*
-        default:
-          Error("Warp type %d not yet implemented",Warp->Warp_Type);
-        */
+      if (n_trans < MAX_TRANSFORM)
+      {
+        trans_stack[n_trans++] = &((TRANS *)Warp)->Trans;
+      }
+      else 
+      {
+        Error("UnWarp_Normal: reached transform stack limit.");
+      }
       }
-      Warp=Warp->Next_Warp;
    }
+
+  while (n_trans--)
+  {
+    MTransNormal(TNorm, TNorm, trans_stack[n_trans]);
+  }
+
   if(!DontScaleBumps)
   {
    VNormalizeEq(TNorm);


Post a reply to this message

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