The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

st/oxr: Improve logging in xrLocateSpace

authored by

Jakob Bornecrantz and committed by
Jakob Bornecrantz
1fb56568 4fc02cf6

+48 -11
+48 -11
src/xrt/state_trackers/oxr/oxr_space.c
··· 368 368 } 369 369 370 370 static void 371 - print_space(const char *name, struct oxr_space *spc) 371 + print_vec3_slog(struct oxr_sink_logger *slog, const char *prefix, struct xrt_vec3 *v) 372 372 { 373 - if (!spc->sess->sys->inst->debug_spaces) { 374 - return; 375 - } 373 + oxr_slog(slog, "%s (%f, %f, %f)", prefix, v->x, v->y, v->z); 374 + } 376 375 376 + static void 377 + print_pose_slog(struct oxr_sink_logger *slog, const char *prefix, struct xrt_pose *pose) 378 + { 379 + struct xrt_vec3 *p = &pose->position; 380 + struct xrt_quat *q = &pose->orientation; 381 + 382 + oxr_slog(slog, "%s (%f, %f, %f) (%f, %f, %f, %f)", prefix, p->x, p->y, p->z, q->x, q->y, q->z, q->w); 383 + } 384 + 385 + static void 386 + print_space_slog(struct oxr_sink_logger *slog, const char *name, struct oxr_space *spc) 387 + { 377 388 const char *type_str = get_ref_space_type_short_str(spc); 378 - U_LOG_D("\t%s->type %s\n\t%s->pose", name, type_str, name); 379 - print_pose(spc->sess, "", &spc->pose); 389 + oxr_slog(slog, "\n\t%s->type: %s\n\t%s->pose: ", name, type_str, name); 390 + 391 + print_pose_slog(slog, "", &spc->pose); 380 392 } 381 393 382 394 XrSpaceLocationFlags ··· 418 430 oxr_space_locate( 419 431 struct oxr_logger *log, struct oxr_space *spc, struct oxr_space *baseSpc, XrTime time, XrSpaceLocation *location) 420 432 { 421 - if (spc->sess->sys->inst->debug_spaces) { 422 - U_LOG_D("%s", __func__); 433 + struct oxr_sink_logger slog = {0}; 434 + bool print = spc->sess->sys->inst->debug_spaces; 435 + if (print) { 436 + print_space_slog(&slog, "space", spc); 437 + print_space_slog(&slog, "baseSpace", baseSpc); 423 438 } 424 - print_space("space", spc); 425 - print_space("baseSpace", baseSpc); 426 439 427 440 // Get the pure space relation. 428 441 struct xrt_space_relation pure; ··· 442 455 vel->velocityFlags = 0; 443 456 U_ZERO(&vel->linearVelocity); 444 457 U_ZERO(&vel->angularVelocity); 458 + } 459 + 460 + if (print) { 461 + oxr_slog(&slog, "\n\tReturning invalid pose"); 462 + oxr_log_slog(log, &slog); 463 + } else { 464 + oxr_slog_abort(&slog); 445 465 } 446 466 447 467 return XR_SUCCESS; ··· 497 517 *(XrVector3f *)&result.angular_acceleration; 498 518 #endif 499 519 500 - print_pose(spc->sess, "\trelation->pose", (struct xrt_pose *)&location->pose); 520 + 521 + if (print) { 522 + print_pose_slog(&slog, "\n\tpure->pose", (struct xrt_pose *)&pure.pose); 523 + print_pose_slog(&slog, "\n\trelation->pose", (struct xrt_pose *)&location->pose); 524 + if (vel) { 525 + if ((vel->velocityFlags & XR_SPACE_VELOCITY_LINEAR_VALID_BIT) != 0) { 526 + print_vec3_slog(&slog, "\n\trelation->linearVelocity", 527 + (struct xrt_vec3 *)&vel->linearVelocity); 528 + } 529 + if ((vel->velocityFlags & XR_SPACE_VELOCITY_ANGULAR_VALID_BIT) != 0) { 530 + print_vec3_slog(&slog, "\n\trelation->angularVelocity", 531 + (struct xrt_vec3 *)&vel->angularVelocity); 532 + } 533 + } 534 + oxr_log_slog(log, &slog); 535 + } else { 536 + oxr_slog_abort(&slog); 537 + } 501 538 502 539 return oxr_session_success_result(spc->sess); 503 540 }