Main Page | Class Hierarchy | Class List | File List | Class Members

lightcache.h

00001 /* ************************************************************************* 00002 lightcache.h - description 00003 ------------------- 00004 begin : Wed Oct 16 2002 00005 copyright : (C) 2002 by Micha Riser 00006 email : mriser@gmx.net 00007 00008 $Id: lightcache_8h-source.html,v 1.1 2005/02/04 21:02:27 micha Exp $ 00009 00010 ************************************************************************* */ 00011 00012 /* ************************************************************************* 00013 * * 00014 * This program is free software; you can redistribute it and/or modify * 00015 * it under the terms of the GNU General Public License as published by * 00016 * the Free Software Foundation; either version 2 of the License, or * 00017 * (at your option) any later version. * 00018 * * 00019 ************************************************************************* */ 00020 00021 #ifndef LIGHTCACHE_H 00022 #define LIGHTCACHE_H 00023 00024 #include "vector.h" 00025 #include "colour.h" 00026 #include "lightlist.h" 00027 #include "statistics.h" 00028 00029 class Scene; 00030 00034 class LightCache { 00035 00036 public: // Constructors and destructor 00037 LightCache(const Scene* s); 00038 00039 private: 00040 LightCache(const LightCache&); 00041 LightCache& operator=(const LightCache&); 00042 00043 public: // Public methods 00044 00047 void setType(int size); 00048 00055 LightList* lookup(const Vector3& location, CLR err, FLT& precision, FLT variance_keep_factor); 00056 00057 static int sampleCounts() { 00058 return Hash::insertstat.getEvalCount(); 00059 } 00060 00061 private: // Inner classes 00062 00065 class MapEntry { 00066 00067 public: // Public attributes 00068 Vector3f location; 00069 LightList* list; 00070 unsigned int hitcount; 00071 00072 public: // Constructor and destructor 00073 MapEntry(const Vector3f& l, LightList* data): 00074 location(l), list(data), hitcount(initialcount) {} 00075 00076 MapEntry(): list(0), hitcount(0) {} 00077 00078 ~MapEntry() {} 00079 00080 }; 00081 00082 00085 class Hash { 00086 00087 public: // Static members 00088 00091 static HitStatistics hitstat; 00094 static HitStatistics insertstat; 00095 00096 public: // Constructor and destructor 00097 Hash(); 00098 ~Hash(); 00099 private: 00100 Hash(const Hash&); 00101 Hash& operator=(const Hash&); 00102 00103 public: // Public methods 00104 void setSize(int size); 00105 bool get(const Vector3f& location, LightList*&); 00106 void put(const Vector3f& location, LightList* l); 00107 00108 private: // Private attributes 00109 int size, sondmod; 00110 MapEntry* data; 00111 00112 private: // Private methods 00113 unsigned int calcHashValue(unsigned int); 00114 unsigned int calcHashValueSond(unsigned int); 00115 00116 }; 00117 00118 00119 class VarianceMapEntry { 00120 public: 00121 Vector3f location; 00122 unsigned int gridsize; 00123 CLR variance; 00124 public: 00125 VarianceMapEntry(): location(0), gridsize(0), variance(0) {}; 00126 VarianceMapEntry(const Vector3f& l, unsigned int size, CLR var): 00127 location(l), gridsize(size), variance(var) {}; 00128 }; 00129 00130 00131 class VarianceHash { 00132 00133 public: 00134 static HitStatistics hitstat; 00135 VarianceHash(); 00136 ~VarianceHash(); 00137 private: 00138 VarianceHash(const VarianceHash&); 00139 VarianceHash& operator=(const VarianceHash&); 00140 00141 public: // Public methods 00142 void setSize(int size); 00143 bool get(const Vector3f& location, unsigned int gridsize, CLR& variance); 00144 void put(const Vector3f& location, unsigned int gridsize, CLR variance); 00145 00146 private: // Private attributes 00147 int size, sondmod; 00148 VarianceMapEntry* data; 00149 00150 }; 00151 00152 00153 private: // Constants 00154 // these constants are set quite arbitrarly, affect fine-tune of the cache 00155 static const int sondsize = 3; 00156 static const unsigned int hitbonus = 1000; 00157 static const unsigned int initialcount = 1000; 00158 00159 private: // Private methods 00160 LightList* sample(const Vector3f& p); 00161 00162 private: // Private attributes 00163 const Scene* scene; 00164 Hash map; 00165 VarianceHash varmap; 00166 00167 }; 00168 00169 #endif

Generated on Thu Jan 27 12:16:05 2005 for raytracer.kdevelop by doxygen 1.3.8