POV-Ray : Newsgroups : povray.programming : Lighting.cpp - Assign_Vector used to copy a COLOUR into an RGB : Re: Lighting.cpp - Assign_Vector used to copy a COLOUR into an RGB Server Time: 25 Sep 2017 15:07:50 GMT
  Re: Lighting.cpp - Assign_Vector used to copy a COLOUR into an RGB  
From: Thorsten Froehlich
Date: 16 Sep 2002 08:02:00
In article <3d81cb75$1@news.povray.org> , "Massimo Valentini" 
<six### [at] inwindit> wrote:

> Looking into the sources of Linux povray (from povuni_s.tgz - version
> 3.50a)(but the same is in the Win source) I saw two calls to
> Assign_Vector that appear to me wrong. On my platform a VECTOR (the size)
> occupies 24 bytes, an RGB (the destination) 12, and a COLOUR (the source)
> 20. Details follow the signature.
>
> If I'm wrong and the code is correct, I think a comment, in the source,
> explaining the thing would be useful.

No, you are correct.  These are indeed bugs.  I would suggest to replace the
Assign_xxx macros in frame.h with something like the inline statements below
to find the remaining cases of the same problem.  It will generate a few
errors when assigning tokens, but those errors are correct and can be fixed
by a simple cast.

    Thorsten


inline DBL *Assign_Vector(DBL *d, DBL *s)
 { return (DBL *)memcpy(d, s, sizeof(VECTOR)); }
inline VECTOR *Assign_Vector(VECTOR *d, VECTOR *s)
 { return (VECTOR *)memcpy(d, s, sizeof(VECTOR)); }

inline DBL *Assign_UV_Vect(DBL *d, DBL *s)
 { return (DBL *)memcpy(d, s, sizeof(UV_VECT)); }
inline UV_VECT *Assign_UV_Vect(UV_VECT *d, UV_VECT *s)
 { return (UV_VECT *)memcpy(d, s, sizeof(UV_VECT)); }

inline DBL *Assign_Vector_4D(DBL *d, DBL *s)
 { return (DBL *)memcpy(d, s, sizeof(VECTOR_4D)); }
inline VECTOR_4D *Assign_Vector_4D(VECTOR_4D *d, VECTOR_4D *s)
 { return (VECTOR_4D *)memcpy(d, s, sizeof(VECTOR_4D)); }

inline COLC *Assign_Colour(COLC *d, COLC *s)
 { return (COLC *)memcpy(d, s, sizeof(COLOUR)); }
inline COLOUR *Assign_Colour(COLOUR *d, COLOUR *s)
 { return (COLOUR *)memcpy(d, s, sizeof(COLOUR)); }

inline COLC *Assign_RGB(COLC *d, COLC *s)
 { return (COLC *)memcpy(d, s, sizeof(RGB)); }
inline RGB *Assign_RGB(RGB *d, RGB *s)
 { return (RGB *)memcpy(d, s, sizeof(RGB)); }


____________________________________________________
Thorsten Froehlich
e-mail: mac### [at] povrayorg

I am a member of the POV-Ray Team.
Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

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