Skip to content

Refactor/client callbacks #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
May 9, 2024
Merged

Refactor/client callbacks #82

merged 15 commits into from
May 9, 2024

Conversation

dmin12
Copy link
Contributor

@dmin12 dmin12 commented May 7, 2024

Refactored the client class to streamline structure & logic.

Previously, the client class had static callback functions, which referenced static flags and variables. These static methods and variables were converted into member variables of Client. As a workaround for GLFWwindow requiring static function callbacks, all of the member callback functions are bound to a lambda, which essentially just wraps around the Client callback functions. These lambdas reference a GLFW user pointer through glfwGetWindowUserPointer(window), and this user pointer is bound to an instance of Client.

Client::idleCallback() was refactored by removing the call to Client::handleKeys(), instead moving that logic to the Client::keyCallback(). The proposed structure for input handling is as follows: for inputs that are continuous (i.e. movement, jumping), keyCallback() will set a flag, which is separately handled in idleCallback(), and for inputs that are press/release or single press (i.e. left shift for sprint), the event is sent directly in the keyCallback(), which avoids using flags for checking if events were already sent.

Also fixed some bugs with camera movement logic and added a simple window resize callback.

Added documentation for client.hpp and camera.hpp.

Base automatically changed from dev to main May 8, 2024 18:38
@dmin12 dmin12 changed the base branch from main to dev May 8, 2024 18:39
@dmin12 dmin12 marked this pull request as draft May 8, 2024 23:29
@dmin12 dmin12 marked this pull request as ready for review May 8, 2024 23:46
Copy link
Contributor

@Tyler-Lentz Tyler-Lentz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like all these changes, thanks for grinding these out

@dmin12 dmin12 merged commit dfc2390 into dev May 9, 2024
11 checks passed
@dmin12 dmin12 deleted the refactor/client_callbacks branch May 9, 2024 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants