As a follow up for this post, I have created a Qt3D project which is a modified version of a Qt3D example. I'm running my project with Qt 5.13.1 on openSUSE Linux with GCC-7
. On my project, I can use a time-delay between consecutive ray casts. I made some unexpected observations:
On main.cpp
file, when I run this line, the ray casting gets stuck at some point and cannot continue:
ConsecutiveRayCaster *consecutiveRayCaster = new ConsecutiveRayCaster(scene, TimeDelayStatus::NoDelay);
However, when I run this line, even when time-delay is set to 0 msec
, all the consecutive ray castings are done without any issue, :
ConsecutiveRayCaster *consecutiveRayCaster = new ConsecutiveRayCaster(scene, TimeDelayStatus::SomeDelay, 0 /* milliseconds */);
This switch makes the difference:
switch (m_timeDelayStatus) {
case NoDelay:
rayCaster->trigger(origin, direction, length);
break;
case SomeDelay:
QTimer::singleShot(m_timeDelayBetweenRayCasts, [rayCaster, origin, direction, length](){ rayCaster->trigger(origin, direction, length); });
break;
}
I wonder why?