#ifndef __PVSBASE_H #define __PVSBASE_H #include "common.h" #include "Containers.h" //using namespace std; namespace GtpVisibilityPreprocessor { //class Intersectable; /** Information stored with a PVS entry. Consists of the number the object was seen from the view cell. */ template struct PvsEntry { public: PvsEntry(): mObject(NULL), mData(0) {} PvsEntry(T sample): mObject(sample), mData(0) {} PvsEntry(T sample, const S &data): mObject(sample), mData(data) {} T mObject; S mData; template friend int operator< (const PvsEntry &a, const PvsEntry &b); template friend int operator== (const PvsEntry &a, const PvsEntry &b); }; template int operator< (const PvsEntry &a, const PvsEntry &b) { return a.mObject < b.mObject; } template int operator== (const PvsEntry &a, const PvsEntry &b) { return a.mObject == b.mObject; } template struct LtSample { bool operator()(const PvsEntry &a, const PvsEntry &b) const { return a.mObject < b.mObject; } }; template int equalSample (const PvsEntry &a, const PvsEntry &b) { return a.mObject == b.mObject; } /** Information stored with a PVS entry. Consists of the number the object was seen from the view cell. */ struct PvsData { public: PvsData() {} PvsData(const float sumPdf): mSumPdf(sumPdf) {} // $$JB in order to return meaningfull values // it assumes that the sum pdf has been normalized somehow!!! inline float GetVisibility() { return mSumPdf; } /// sum of probability density of visible sample rays float mSumPdf; }; class MailablePvsData { public: // sum of probability density of visible sample rays float mSumPdf; int mCounter; MailablePvsData() {} MailablePvsData(const float sumPdf): mSumPdf(sumPdf) {} // $$JB in order to return meaningfull values // it assumes that the sum pdf has been normalized somehow!!! float GetVisibility() { return mSumPdf; } /////////////// // Mailing stuff // last mail id -> warning not thread safe! // both mailId and mailbox should be unique for each thread!!! static int sMailId; static int sReservedMailboxes; static void NewMail(const int reserve = 1) { sMailId += sReservedMailboxes; sReservedMailboxes = reserve; } void Mail() { mMailbox = sMailId; } bool Mailed() const { return mMailbox == sMailId; } void Mail(const int mailbox) { mMailbox = sMailId + mailbox; } bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; } int IncMail() { return ++ mMailbox - sMailId; } ////////////////////////////////////////// protected: int mMailbox; }; } #endif