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 {
45 0.0};
46 };
47
49 using DidUpdateCallback = std::function<void(InputContext& inputContext, const UpdateInfo& info)>;
50
51 // [Public Lifecycle Functions]
52
55
56 InputContext(const InputContext&) = delete;
57 InputContext& operator=(const InputContext&) = delete;
58
59 InputContext(InputContext&&) = delete;
60 InputContext& operator=(InputContext&&) = delete;
61
62 virtual ~InputContext();
63
64 // [Public Member Functions]
65
68
71
72 // [Internal Member Functions]
73
74 virtual void update(const UpdateInfo& info) = 0;
75 virtual void attachedToScene(Scene& scene) = 0;
76 virtual void visualWorldAttachedToScene(Scene& scene) = 0;
77
78 private:
79 // [Private Member Variables]
80
81 DidUpdateCallback _didUpdateCallback;
82 };
83
84}
85
86#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:49
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