1 //****************************************************************************** 2 /// 3 /// @file core/scene/tracethreaddata.h 4 /// 5 /// @todo What's in here? 6 /// 7 /// @copyright 8 /// @parblock 9 /// 10 /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. 11 /// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd. 12 /// 13 /// POV-Ray is free software: you can redistribute it and/or modify 14 /// it under the terms of the GNU Affero General Public License as 15 /// published by the Free Software Foundation, either version 3 of the 16 /// License, or (at your option) any later version. 17 /// 18 /// POV-Ray is distributed in the hope that it will be useful, 19 /// but WITHOUT ANY WARRANTY; without even the implied warranty of 20 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 /// GNU Affero General Public License for more details. 22 /// 23 /// You should have received a copy of the GNU Affero General Public License 24 /// along with this program. If not, see <http://www.gnu.org/licenses/>. 25 /// 26 /// ---------------------------------------------------------------------------- 27 /// 28 /// POV-Ray is based on the popular DKB raytracer version 2.12. 29 /// DKBTrace was originally written by David K. Buck. 30 /// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. 31 /// 32 /// @endparblock 33 /// 34 //****************************************************************************** 35 36 #ifndef POVRAY_CORE_TRACETHREADDATA_H 37 #define POVRAY_CORE_TRACETHREADDATA_H 38 39 // Module config header file must be the first file included within POV-Ray unit header files 40 #include "core/configcore.h" 41 42 #include <vector> 43 #include <stack> 44 45 #include "base/types.h" 46 47 #include "core/coretypes.h" 48 #include "core/bounding/boundingcylinder.h" 49 #include "core/bounding/bsptree.h" 50 #include "core/material/pattern.h" 51 #include "core/math/randomsequence.h" 52 #include "core/shape/mesh.h" 53 #include "core/support/statistics.h" 54 55 namespace pov 56 { 57 58 //############################################################################## 59 /// 60 /// @addtogroup PovCore 61 /// 62 /// @{ 63 64 using namespace pov_base; 65 66 class SceneData; 67 struct ISO_ThreadData; 68 69 class PhotonMap; 70 struct Blob_Interval_Struct; 71 72 /// Class holding parser thread specific data. 73 class TraceThreadData : public ThreadData 74 { 75 friend class Scene; 76 friend class Trace; 77 friend class View; // TODO FIXME - needed only to access TraceThreadData for CheckCameraHollowObject() 78 79 public: 80 81 /// Create thread local data. 82 /// @param sd Scene data defining scene attributes. 83 /// @param seed Seed for the stochastic random number generator; 84 /// should be unique for each render. 85 TraceThreadData(shared_ptr<SceneData> sd, size_t seed); 86 87 /// Destructor. 88 ~TraceThreadData(); 89 90 /// Get the statistics. 91 /// @return Reference to statistic counters. Stats(void)92 RenderStatistics& Stats(void) { return renderStats; } 93 94 DBL *Fractal_IStack[4]; 95 BBoxPriorityQueue Mesh_Queue; 96 void **Blob_Queue; 97 unsigned int Max_Blob_Queue_Size; 98 DBL *Blob_Coefficients; 99 Blob_Interval_Struct *Blob_Intervals; 100 int Blob_Coefficient_Count; 101 int Blob_Interval_Count; 102 ISO_ThreadData *isosurfaceData; ///< @todo We may want to move this data block to the isosurface code as a local variable. 103 vector<BCYL_INT> BCyl_Intervals; 104 vector<BCYL_INT> BCyl_RInt; 105 vector<BCYL_INT> BCyl_HInt; 106 IStackPool stackPool; 107 vector<GenericFunctionContextPtr> functionContextPool; 108 int Facets_Last_Seed; 109 int Facets_CVC; 110 Vector3d Facets_Cube[81]; 111 112 /// Common random number generator for all stochastic stuff 113 SeedableDoubleGeneratorPtr stochasticRandomGenerator; 114 size_t stochasticRandomSeedBase; 115 116 // TODO FIXME - thread-local copy of lightsources. we need this 117 // because various parts of the lighting code seem to make changes 118 // to the lightsource object passed to them (this is not confined 119 // just to the area light shadow code). This code ought to be fixed 120 // to treat the lightsource as const, after which this can go away. 121 vector<LightSource *> lightSources; 122 123 // all of these are for photons 124 // most of them should be refactored into parameters, return values, or other objects 125 LightSource *photonSourceLight; 126 ObjectPtr photonTargetObject; 127 bool litObjectIgnoresPhotons; 128 MathColour GFilCol; 129 int hitObject; // did we hit the target object? (for autostop) 130 DBL photonSpread; // photon spread (in radians) 131 DBL photonDepth; // total distance from light to intersection 132 int passThruThis; // is this a pass-through object encountered before the target? 133 int passThruPrev; // was the previous object a pass-through object encountered before the target? 134 bool Light_Is_Global; // is the current light global? (not part of a light_group?) 135 PhotonMap* surfacePhotonMap; 136 PhotonMap* mediaPhotonMap; 137 138 CrackleCache mCrackleCache; 139 140 // data for waves and ripples pattern 141 unsigned int numberOfWaves; 142 vector<double> waveFrequencies; 143 vector<Vector3d> waveSources; 144 145 /// Called after a rectangle is finished. 146 /// Used for crackle cache expiry. 147 void AfterTile(); 148 149 /// Used by the crackle pattern to indicate age of cache entries. 150 /// @return The index of the current rectangle rendered. ProgressIndex()151 inline size_t ProgressIndex() const { return progress_index; } 152 153 enum TimeType 154 { 155 kUnknownTime, 156 kParseTime, 157 kBoundingTime, 158 kPhotonTime, 159 kRadiosityTime, 160 kRenderTime, 161 kMaxTimeType 162 }; 163 164 TimeType timeType; 165 POV_LONG cpuTime; 166 POV_LONG realTime; 167 QualityFlags qualityFlags; // TODO FIXME - remove again 168 GetSceneData()169 inline shared_ptr<const SceneData> GetSceneData() const { return sceneData; } 170 171 protected: 172 /// scene data 173 shared_ptr<SceneData> sceneData; 174 /// render statistics 175 RenderStatistics renderStats; 176 177 private: 178 /// not available 179 TraceThreadData(); 180 181 /// not available 182 TraceThreadData(const TraceThreadData&); 183 184 /// not available 185 TraceThreadData& operator=(const TraceThreadData&); 186 187 /// current number of Tiles to expire crackle cache entries after 188 size_t CrCache_MaxAge; 189 /// current tile index (for crackle cache expiry) 190 size_t progress_index; 191 }; 192 193 /// @} 194 /// 195 //############################################################################## 196 197 } 198 199 #endif // POVRAY_CORE_TRACETHREADDATA_H 200