| 4236 | : VerifyApplication::Test(name,isa,VerifyApplication::TEST_SHOULD_PASS), sflags(sflags), tri_accel(tri_accel) {} |
| 4237 | |
| 4238 | VerifyApplication::TestReturnValue run(VerifyApplication* state, bool silent) |
| 4239 | { |
| 4240 | std::string cfg = state->rtcore + ",isa="+stringOfISA(isa) + ((tri_accel != "") ? ",tri_accel="+tri_accel : ""); |
| 4241 | //printf("run test %s\n", cfg.c_str()); |
| 4242 | RTCDeviceRef device = rtcNewDevice(cfg.c_str()); |
| 4243 | errorHandler(nullptr,rtcGetDeviceError(device)); |
| 4244 | |
| 4245 | RTCSceneRef scene = rtcNewScene(device); |
| 4246 | rtcSetSceneFlags(scene,sflags.sflags); |
| 4247 | rtcSetSceneBuildQuality(scene,sflags.qflags); |
| 4248 | |
| 4249 | RTCGeometry geom = rtcNewGeometry (device, RTC_GEOMETRY_TYPE_TRIANGLE); |
| 4250 | rtcSetGeometryBuildQuality(geom,sflags.qflags); |
| 4251 | |
| 4252 | Vec3f* vertices = (Vec3f*)rtcSetNewGeometryBuffer(geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, sizeof(Vec3f), 3*32); |
| 4253 | Triangle* triangles = (Triangle*)rtcSetNewGeometryBuffer(geom, RTC_BUFFER_TYPE_INDEX , 0, RTC_FORMAT_UINT3, sizeof(Triangle), 32); |
| 4254 | for (int i = 0; i < 32; ++i) { |
| 4255 | float xi = random_float(); |
| 4256 | vertices[3*i+0] = Vec3f(0.0f, 0.0f, (float)i); |
| 4257 | vertices[3*i+1] = Vec3f(1.0f + 5.f*xi, 0.0f, (float)i); |
| 4258 | vertices[3*i+2] = Vec3f(0.0f, 1.0f + 5.f*xi, (float)i); |
| 4259 | triangles[i] = Triangle(3*i+0, 3*i+1, 3*i+2); |
| 4260 | }; |
| 4261 | |
| 4262 | rtcCommitGeometry(geom); |
| 4263 | rtcAttachGeometry(scene,geom); |
| 4264 | rtcReleaseGeometry(geom); |
| 4265 | rtcCommitScene (scene); |
| 4266 | AssertNoError(device); |
| 4267 | |
| 4268 | struct UserData |
| 4269 | { |
| 4270 | Vec3f* vertices; |
| 4271 | Triangle* triangles; |
| 4272 | Vec3f result; |
| 4273 | unsigned int primID = RTC_INVALID_GEOMETRY_ID; |
| 4274 | }; |
| 4275 | |
| 4276 | for (int i = 0; i < 64; ++i) |
| 4277 | { |
| 4278 | RTCPointQuery query; |
| 4279 | query.x = 0.25f; |
| 4280 | query.y = 0.75f; |
| 4281 | query.z = -0.25f + i * 0.5f; |
| 4282 | query.time = 0.f; |
| 4283 | query.radius = inf; |
| 4284 | |
| 4285 | UserData data; |
| 4286 | data.vertices = vertices; |
| 4287 | data.triangles = triangles; |
| 4288 | |
| 4289 | RTCPointQueryContext context; |
| 4290 | rtcInitPointQueryContext(&context); |
| 4291 | rtcPointQuery(scene, &query, &context, [](RTCPointQueryFunctionArguments* args) -> bool |
| 4292 | { |
| 4293 | UserData* data = (UserData*)args->userPtr; |
| 4294 | // get triangle info |
| 4295 | Triangle const& t = data->triangles[args->primID]; |
nothing calls this directly
no test coverage detected