| 104 | |
| 105 | template<int N, int K, int types, bool robust, typename PrimitiveIntersectorK, bool single> |
| 106 | void BVHNIntersectorKHybrid<N, K, types, robust, PrimitiveIntersectorK, single>::intersect(vint<K>* __restrict__ valid_i, |
| 107 | Accel::Intersectors* __restrict__ This, |
| 108 | RayHitK<K>& __restrict__ ray, |
| 109 | RayQueryContext* __restrict__ context) |
| 110 | { |
| 111 | BVH* __restrict__ bvh = (BVH*)This->ptr; |
| 112 | |
| 113 | /* we may traverse an empty BVH in case all geometry was invalid */ |
| 114 | if (bvh->root == BVH::emptyNode) |
| 115 | return; |
| 116 | |
| 117 | #if ENABLE_FAST_COHERENT_CODEPATHS == 1 |
| 118 | assert(context); |
| 119 | if (unlikely(types == BVH_AN1 && context->user && context->isCoherent())) |
| 120 | { |
| 121 | intersectCoherent(valid_i, This, ray, context); |
| 122 | return; |
| 123 | } |
| 124 | #endif |
| 125 | |
| 126 | /* filter out invalid rays */ |
| 127 | vbool<K> valid = *valid_i == -1; |
| 128 | #if defined(EMBREE_IGNORE_INVALID_RAYS) |
| 129 | valid &= ray.valid(); |
| 130 | #endif |
| 131 | |
| 132 | /* return if there are no valid rays */ |
| 133 | size_t valid_bits = movemask(valid); |
| 134 | |
| 135 | #if defined(__AVX__) |
| 136 | STAT3(normal.trav_hit_boxes[popcnt(movemask(valid))], 1, 1, 1); |
| 137 | #endif |
| 138 | |
| 139 | if (unlikely(valid_bits == 0)) return; |
| 140 | |
| 141 | /* verify correct input */ |
| 142 | assert(all(valid, ray.valid())); |
| 143 | assert(all(valid, ray.tnear() >= 0.0f)); |
| 144 | assert(!(types & BVH_MB) || all(valid, (ray.time() >= 0.0f) & (ray.time() <= 1.0f))); |
| 145 | Precalculations pre(valid, ray); |
| 146 | |
| 147 | /* load ray */ |
| 148 | TravRayK<K, robust> tray(ray.org, ray.dir, single ? N : 0); |
| 149 | const vfloat<K> org_ray_tnear = max(ray.tnear(), 0.0f); |
| 150 | const vfloat<K> org_ray_tfar = max(ray.tfar , 0.0f); |
| 151 | |
| 152 | if (single) |
| 153 | { |
| 154 | tray.tnear = select(valid, org_ray_tnear, vfloat<K>(pos_inf)); |
| 155 | tray.tfar = select(valid, org_ray_tfar , vfloat<K>(neg_inf)); |
| 156 | |
| 157 | for (; valid_bits!=0; ) { |
| 158 | const size_t i = bscf(valid_bits); |
| 159 | intersect1(This, bvh, bvh->root, i, pre, ray, tray, context); |
| 160 | } |
| 161 | return; |
| 162 | } |
| 163 |
nothing calls this directly
no test coverage detected