-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSceneState.h
More file actions
46 lines (37 loc) · 1.27 KB
/
Copy pathSceneState.h
File metadata and controls
46 lines (37 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include "raylib.h"
#include <functional>
#include <limits>
/** Represent the scene state */
struct SceneState
{
/** 3D Camera used in the scene */
Camera * camera;
/** Reset the handler candidate for this loop */
void startUpdate();
/** Attempt to capture the mouse, the handler is decided after all objects
* have been updated based on who's closest to the camera.
*
* The \param notify callback will be called if the \param source can take
* hold of the mouse at the end of update.
*
* It should return true if the source want to hold onto the mouse for the
* next frames */
void attemptMouseCapture(void * source, float distance, std::function<bool()> notify);
/** True if \param source holds the mouse at this time */
bool hasMouse(void * source);
/** Release the mouse, only has an effect if \param source currently holds the mouse */
void releaseMouse(void * source);
/** Notify the candidate that the mouse has been capture */
void endUpdate();
private:
/** Point to the current handler of mouse motions */
void * mouseHandler_ = nullptr;
struct Candidate
{
void * candidate = nullptr;
float distance = std::numeric_limits<float>::infinity();
std::function<bool()> notify;
};
Candidate candidate_;
};