MCPcopy Create free account
hub / github.com/RenderKit/embree / doIntersectionTests

Method doIntersectionTests

tutorials/verify/verify.cpp:2978–3021  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2976 }
2977
2978 bool doIntersectionTests(RTCScene scene)
2979 {
2980 RayQueryContext ctx;
2981 rtcInitRayQueryContext(&ctx.context);
2982
2983 RTCIntersectArguments args;
2984 rtcInitIntersectArguments(&args);
2985 args.context = &ctx.context;
2986 args.filter = intersectFilter;
2987 args.flags = RTC_RAY_QUERY_FLAG_INVOKE_ARGUMENT_FILTER;
2988
2989 RTCRayHit rays[16];
2990 for (int i = 0; i < 16; ++i) {
2991 float dx = i * 5.f;
2992 rays[i] = makeRay(Vec3fa(dx,0.f,-2.0f),Vec3fa(0,0,1));
2993 rays[i].ray.id = i;
2994 ctx.numHits[i] = 0;
2995 }
2996
2997 IntersectWithMode(imode,ivariant,scene,rays,16,&args);
2998
2999 // first ray should have missed
3000 bool passed = (ctx.numHits[0] == 0);
3001 if (ivariant & VARIANT_INTERSECT) {
3002 passed &= (rays[0].hit.geomID == RTC_INVALID_GEOMETRY_ID);
3003 passed &= (rays[0].hit.instID[0] == RTC_INVALID_GEOMETRY_ID);
3004 } else {
3005 passed &= (rays[0].ray.tfar != (float)neg_inf);
3006 }
3007
3008 // remaining rays should have hit
3009 for (int i = 1; i < 16; ++i) {
3010 passed &= (ctx.numHits[i] > 0);
3011 RTCRayHit& ray = rays[i];
3012 if (ivariant & VARIANT_INTERSECT) {
3013 passed &= (ray.hit.geomID != RTC_INVALID_GEOMETRY_ID);
3014 passed &= (ray.hit.instID[0] == 0);
3015 passed &= (ray.hit.instPrimID[0] == (i-1));
3016 } else {
3017 passed &= (ray.ray.tfar == (float)neg_inf);
3018 }
3019 }
3020 return passed;
3021 }
3022
3023 VerifyApplication::TestReturnValue run(VerifyApplication* state, bool silent)
3024 {

Callers

nothing calls this directly

Calls 5

rtcInitRayQueryContextFunction · 0.85
makeRayFunction · 0.85
IntersectWithModeFunction · 0.85
Vec3faClass · 0.50

Tested by

no test coverage detected