spectral

Memory management : is it allowed ?

Discussion created by spectral on Oct 22, 2010
Latest reply on Oct 22, 2010 by MicahVillmow

Hi,

 

//---- Definitions

typedef struct
{
Spectrum kd;
} BxDFParam_Lambert;

typedef struct
{
Spectrum ks;
FresnelParam fresnel;
} BxDFParam_Specular;

 

typedef struct
{
   union
   {
      BxDFParam_Lambert lambert;
      BxDFParam_Specular specular;
   } param;
} BSDF;



//---- Copy parameters from buffer

void* buffer = ...

if (reference->materialId == BSDF_DIFFUSE)
   param.diffuse = *((BxDFParam_Lambert)buffer);
else if (reference->materialId == BSDF_SPECULAR)
   param.specular = *((BxDFParam_Specular)buffer);



Outcomes