Avara3D 0.2.0
C++ API reference
InputContext.h
1//
2// InputContext.h
3// avara3d
4//
5// Created by Morgan Davis on 10/9/17.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_INPUT_INPUTCONTEXT_H
10#define AVARA3D_INPUT_INPUTCONTEXT_H
11
12#include <cstdint>
13#include <functional>
14
15namespace a3d {
16
17 class RenderContext;
18 class Scene;
19
28
29 public:
30 // [Public Types]
31
33 struct UpdateInfo {
34
35 // zero-based enclosing host-update index
36 std::uint64_t updateIndex {0};
37
38 // monotonic seconds since the host update loop started,
39 // measured at the beginning of this input update
40 double elapsedTime {0.0};
41
42 // monotonic seconds since the beginning of the previous
43 // host update; zero during the first update
44 double deltaTime {0.0};
45 };
46
48 using DidUpdateCallback = std::function<void(InputContext& inputContext, const UpdateInfo& info)>;
49
50 // [Public Lifecycle Functions]
51
54
55 InputContext(const InputContext&) = delete;
56 InputContext& operator=(const InputContext&) = delete;
57
58 InputContext(InputContext&&) = delete;
59 InputContext& operator=(InputContext&&) = delete;
60
61 virtual ~InputContext();
62
63 // [Public Member Functions]
64
67
70
71 // [Internal Member Functions]
72
73 virtual void update(const UpdateInfo& info) = 0;
74 virtual void attachedToScene(Scene& scene) = 0;
75 virtual void visualWorldAttachedToScene(Scene& scene) = 0;
76
77 private:
78 // [Private Member Variables]
79
80 DidUpdateCallback _didUpdateCallback;
81 };
82
83}
84
85#endif // AVARA3D_INPUT_INPUTCONTEXT_H
Base interface for Scene input state updated once per Runner host update.
Definition: InputContext.h:27
std::function< void(InputContext &inputContext, const UpdateInfo &info)> DidUpdateCallback
Callback invoked after input state has been updated for the current Runner host update.
Definition: InputContext.h:48
InputContext()
Creates an InputContext with no did-update callback.
DidUpdateCallback didUpdateCallback() const
Returns the callback invoked after each input update.
void didUpdateCallback(DidUpdateCallback callback)
Sets the did-update callback; an empty callback disables it.
Owns a scene graph and the worlds used to simulate and render it.
Definition: Scene.h:44
Timing information for one input update.
Definition: InputContext.h:33
std::uint64_t updateIndex
Zero-based index of the enclosing Runner host update.
Definition: InputContext.h:36
double deltaTime
Time since the preceding host update, in seconds; zero on the first update.
Definition: InputContext.h:44
double elapsedTime
Elapsed host-loop time at this input update, in seconds.
Definition: InputContext.h:40