| 90 | } |
| 91 | |
| 92 | void ReflectionSimulator::simulate(const IScene& scene, |
| 93 | int numSources, |
| 94 | const CoordinateSpace3f* sources, |
| 95 | int numListeners, |
| 96 | const CoordinateSpace3f* listeners, |
| 97 | const Directivity* directivities, |
| 98 | int numRays, |
| 99 | int numBounces, |
| 100 | float duration, |
| 101 | int order, |
| 102 | float irradianceMinDistance, |
| 103 | Array<float, 2>& image, |
| 104 | JobGraph& jobGraph) |
| 105 | { |
| 106 | PROFILE_FUNCTION(); |
| 107 | |
| 108 | assert(numListeners == 1); |
| 109 | |
| 110 | // If we've been asked to simulate more sources than the max number we were initialized with, don't process the |
| 111 | // extra ones. |
| 112 | if (numSources > mMaxNumSources) |
| 113 | { |
| 114 | gLog().message(MessageSeverity::Warning, |
| 115 | "Simulating reflections for %d sources, which is more than the max (%d). Some sources will be ignored.", |
| 116 | numSources, mMaxNumSources); |
| 117 | |
| 118 | numSources = mMaxNumSources; |
| 119 | } |
| 120 | |
| 121 | mNumSources = numSources; |
| 122 | mSources = sources; |
| 123 | mListener = &listeners[0]; |
| 124 | mDirectivities = directivities; |
| 125 | mNumRays = numRays; |
| 126 | mNumBounces = numBounces; |
| 127 | mDuration = duration; |
| 128 | mOrder = order; |
| 129 | mIrradianceMinDistance = irradianceMinDistance; |
| 130 | |
| 131 | image.zero(); |
| 132 | |
| 133 | for (auto i = 0; i < numRays; i += kRayBatchSize) |
| 134 | { |
| 135 | auto start = i; |
| 136 | auto end = std::min(numRays, i + kRayBatchSize); |
| 137 | |
| 138 | jobGraph.addJob([this, &scene, &image, start, end](int threadId, std::atomic<bool>& cancel) |
| 139 | { |
| 140 | simulateJob(scene, image, start, end, threadId); |
| 141 | }); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | void ReflectionSimulator::simulate(const IScene& scene, |
| 146 | int numSources, |