1 Reply Latest reply on Oct 22, 2010 1:12 PM by MicahVillmow

    Memory management : is it allowed ?

    spectral

      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);