POV-Ray : Newsgroups : povray.bugreports : 5D vector to color promotion bug Server Time
14 May 2024 13:39:29 EDT (-0400)
  5D vector to color promotion bug (Message 1 to 1 of 1)  
From: Thorsten Froehlich
Subject: 5D vector to color promotion bug
Date: 26 Nov 1999 17:57:15
Message: <383f104b@news.povray.org>
There is a bug in the treatment of COLOUR vs EXPRESS and various conversions
between those two. The default definition for the data below is (from
frame.h):

#define COLC float
#define DBL double

typedef COLC COLOUR [5];
typedef DBL EXPRESS [5];

#define Assign_Colour(d,s)  memcpy((d),(s),sizeof(COLOUR))


In function Parse_RValue in parse.c the following happens:

 // definition
 void **DataPtr; // treated as COLOUR*
 EXPRESS Local_Express;

   ...

   case 5:   // line 5019 in 3.1g source code
       *NumberPtr    = COLOUR_ID_TOKEN;
       Test_Redefine(Previous,NumberPtr,*DataPtr);
       *DataPtr      = (void *) Create_Colour();
       Assign_Colour(*DataPtr, Local_Express);
       break;


With the default definition of COLOUR and EXPRESS, the memcpy in
Assign_Colour will copy 5 * sizeof(float) bytes, but as usually
sizeof(double) != sizeof(float), the assignment does not work.


How to fix this problem:

#define Assign_Colour(d,s) (d)[RED] = (s)[RED]; (d)[GREEN] = (s)[GREEN];
(d)[BLUE] = (s)[BLUE]; (d)[FILTER] = (s)[FILTER]; (d)[TRANSM] = (s)[TRANSM];


    Thorsten


____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

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