| 160 | typedef ISPCInstanceArray* ISPCInstanceArrayPtr; |
| 161 | |
| 162 | unsigned int postIntersect(const TutorialData& data, const Ray& ray, DifferentialGeometry& dg) |
| 163 | { |
| 164 | AffineSpace3fa local2world = AffineSpace3fa::scale(Vec3fa(1)); |
| 165 | ISPCGeometry** geometries = data.ispc_scene->geometries; |
| 166 | |
| 167 | for (int i=0; i<RTC_MAX_INSTANCE_LEVEL_COUNT; i++) |
| 168 | { |
| 169 | const unsigned int instID = ray.instID[i]; |
| 170 | if (instID == -1) break; |
| 171 | |
| 172 | if (geometries[instID]->type == INSTANCE) { |
| 173 | ISPCInstance* instance = (ISPCInstancePtr) geometries[instID]; |
| 174 | local2world = local2world * calculate_interpolated_space(instance,ray.time()); |
| 175 | |
| 176 | assert(instance->child->type == GROUP); |
| 177 | geometries = ((ISPCGroup*)instance->child)->geometries; |
| 178 | } |
| 179 | #if defined(RTC_GEOMETRY_INSTANCE_ARRAY) |
| 180 | else if (geometries[instID]->type == INSTANCE_ARRAY) { |
| 181 | ISPCInstanceArray* instanceArray = (ISPCInstanceArrayPtr) geometries[instID]; |
| 182 | local2world = local2world * calculate_interpolated_space(instanceArray,ray.instPrimID[i],ray.time()); |
| 183 | assert(instanceArray->child->type == GROUP); |
| 184 | geometries = ((ISPCGroup*)instanceArray->child)->geometries; |
| 185 | } |
| 186 | #endif |
| 187 | } |
| 188 | |
| 189 | ISPCGeometry* mesh = geometries[ray.geomID]; |
| 190 | unsigned int materialID = mesh->materialID; |
| 191 | |
| 192 | dg.Ng = xfmVector(local2world,dg.Ng); |
| 193 | dg.Ns = xfmVector(local2world,dg.Ns); |
| 194 | |
| 195 | return materialID; |
| 196 | } |
| 197 | |
| 198 | inline Vec3fa face_forward(const Vec3fa& dir, const Vec3fa& _Ng) { |
| 199 | const Vec3fa Ng = _Ng; |
no test coverage detected