Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion vsgvr/include/vsgvr/app/Viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,15 @@ namespace vsgvr {
/// **must** call releaseFrame() once after rendering, even if this method returns false.
///
/// @return Whether the application should render.
bool advanceToNextFrame();

#if VSG_VERSION_MAJOR >= 1 && VSG_VERSION_MINOR >= 1
/// hint for setting the FrameStamp::simulationTime to time since start_point()
static constexpr double UseTimeSinceStartPoint = std::numeric_limits<double>::max();

bool advanceToNextFrame(double simulationTime = UseTimeSinceStartPoint);
#else
bool advanceToNextFrame();
#endif
/// Submit rendering tasks to Vulkan
void recordAndSubmit();

Expand Down Expand Up @@ -167,6 +174,7 @@ namespace vsgvr {
XrFrameState _frameState;
vsg::ref_ptr<vsg::FrameStamp> _frameStamp;
std::vector<XrCompositionLayerBaseHeader*> _layers;
vsg::clock::time_point _start_time_point;
};
}

Expand Down
13 changes: 12 additions & 1 deletion vsgvr/src/vsgvr/app/CompositionLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,22 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <vsgvr/xr/Session.h>
#include <vsgvr/xr/GraphicsBindingVulkan.h>

#include <vsg/core/Version.h>
// see https://github.com/vsg-dev/VulkanSceneGraph/issues/1184
#define VSG_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
#define VSG_VERSION VSG_VERSION_CHECK(VSG_VERSION_MAJOR, VSG_VERSION_MINOR, VSG_VERSION_PATCH)

#include <vsg/app/View.h>
#include <vsg/app/RenderGraph.h>
#include <vsg/commands/PipelineBarrier.h>

#if VSG_VERSION >= VSG_VERSION_CHECK(1, 1, 3)
#include <vsg/lighting/Light.h>
#else
#include <vsg/nodes/Light.h>
#endif
#include <vsg/ui/FrameStamp.h>
#include <vsg/vk/SubmitCommands.h>
#include <vsg/commands/PipelineBarrier.h>

#include "../xr/Macros.cpp"

Expand Down
4 changes: 2 additions & 2 deletions vsgvr/src/vsgvr/app/UserOrigin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace vsgvr
{
UserOrigin::UserOrigin() {}

UserOrigin::UserOrigin(vsg::dmat4 matrix)
: Inherit(matrix)
UserOrigin::UserOrigin(vsg::dmat4 _matrix)
: Inherit(_matrix)
{}

UserOrigin::UserOrigin(vsg::dvec3 position, vsg::dquat orientation, vsg::dvec3 scale)
Expand Down
20 changes: 20 additions & 0 deletions vsgvr/src/vsgvr/app/Viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ namespace vsgvr
return PollEventsResult::RunningDontRender;
}

#if VSG_VERSION_MAJOR >= 1 && VSG_VERSION_MINOR >= 1
bool Viewer::advanceToNextFrame(double simulationTime)
#else
bool Viewer::advanceToNextFrame()
#endif
{
// Viewer::acquireNextFrame
_frameState = XrFrameState();
Expand All @@ -128,12 +132,28 @@ namespace vsgvr
if (!_frameStamp)
{
// first frame, initialize to frame count and indices to 0
#if VSG_VERSION_MAJOR >= 1 && VSG_VERSION_MINOR >= 1

_start_time_point = t;

if (simulationTime == UseTimeSinceStartPoint) simulationTime = 0.0;
_frameStamp = vsg::FrameStamp::create(t, 0, simulationTime);
#else
_frameStamp = vsg::FrameStamp::create(t, 0);
#endif
}
else
{
// after first frame so increment frame count and indices
#if VSG_VERSION_MAJOR >= 1 && VSG_VERSION_MINOR >= 1
if (simulationTime == UseTimeSinceStartPoint)
{
simulationTime = std::chrono::duration<double, std::chrono::seconds::period>(t - _start_time_point).count();
}
_frameStamp = vsg::FrameStamp::create(t, _frameStamp->frameCount + 1, simulationTime);
#else
_frameStamp = vsg::FrameStamp::create(t, _frameStamp->frameCount + 1);
#endif
}

for (auto& layer : compositionLayers)
Expand Down