gathers hits in a single pass */
| 144 | |
| 145 | /* gathers hits in a single pass */ |
| 146 | void single_pass(const TutorialData& data, const Ray& ray_i, HitList& hits_o, RandomSampler& sampler, RayStats& stats, const RTCFeatureFlags feature_mask) |
| 147 | { |
| 148 | /* trace ray to gather all hits */ |
| 149 | Ray ray = ray_i; |
| 150 | RayQueryContext context(data,hits_o); |
| 151 | rtcInitRayQueryContext(&context.context); |
| 152 | RTCIntersectArguments args; |
| 153 | rtcInitIntersectArguments(&args); |
| 154 | args.context = &context.context; |
| 155 | args.filter = gather_all_hits; |
| 156 | args.feature_mask = feature_mask; |
| 157 | args.flags = RTC_RAY_QUERY_FLAG_INVOKE_ARGUMENT_FILTER; // invoke filter for each geometry |
| 158 | rtcTraversableIntersect1(data.traversable,RTCRayHit_(ray),&args); |
| 159 | RayStats_addRay(stats); |
| 160 | |
| 161 | /* sort hits by extended order */ |
| 162 | //std::sort(&context.hits.hits[context.hits.begin],&context.hits.hits[context.hits.end]); |
| 163 | insertionsort_ascending(&context.hits.hits[context.hits.begin], context.hits.size()); |
| 164 | |
| 165 | /* ignore duplicated hits that can occur for tessellated primitives */ |
| 166 | if (hits_o.size()) |
| 167 | { |
| 168 | unsigned int i=0, j=1; |
| 169 | for (; j<hits_o.size(); j++) { |
| 170 | if (hits_o.hits[i] == hits_o.hits[j]) continue; |
| 171 | hits_o.hits[++i] = hits_o.hits[j]; |
| 172 | } |
| 173 | hits_o.end = i+1; |
| 174 | } |
| 175 | |
| 176 | /* drop hits in case we found too many */ |
| 177 | hits_o.end = std::min(hits_o.end, data.max_total_hits); |
| 178 | |
| 179 | /* shade all hits */ |
| 180 | if (data.enable_opacity) |
| 181 | { |
| 182 | for (unsigned int i=context.hits.begin; i<context.hits.end; i++) |
| 183 | { |
| 184 | /* roussion roulette ray termination */ |
| 185 | bool opaque = context.hits.hits[i].opaque; |
| 186 | if (RandomSampler_get1D(sampler) < data.curve_opacity) |
| 187 | opaque = true; |
| 188 | |
| 189 | if (opaque) { |
| 190 | hits_o.end = i+1; |
| 191 | return; |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | /* Filter callback function that gathers first N hits up to the first opaque surface */ |
| 198 | RTC_SYCL_INDIRECTLY_CALLABLE void gather_next_hits(const RTCFilterFunctionNArguments* args) |
no test coverage detected