-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[rcamera] Added missing CAMERA_CUSTOM check in UpdateCamera(Camera *camera, int mode)
function
#3938
Conversation
…ode)` Signed-off-by: Tomas Fabrizio Orsi <[email protected]>
You don't need to call |
Hi @justgo97 ! If I am not mistaken, the header file that I pointed to in the PR states that if Wouldn't that mean that calling
|
Yes you are correct about the comment in the header not matching how the actual code works, Your PR would fix that.
|
Oh; okey noted! I see what you mean! As an aside; do yo have any comments regarding the patch? I know it isn't much! 😅 |
I don't know much about the coding style conventions in this repo so probably a maintainer can comment on this.
but again this is just a preference, it will still get the job done in it's current format. |
@lima-limon-inc Thanks for the patch! Personally I prefer that approach than an early return, I try to minimize/avoid early-returns in raylib as much as possible. |
Hello @raysan5 ! Thank you very much! As I side note, may I ask why you chose against them? Do they complicate compiler optimizations? Is it a style decision? Side note 2: Raylib is a joy to use! Thank you so much for all of your work! |
It's just a style and organization decision, I prefer to know that all function return at the end (despite I use some early returns in some functions, mostly for security checks). |
Great! Thanks for the insight. I made a follow up PR regarding the "PS2" I made. It only changes the comments in Here's the PR: #3942 Have a good day! |
rcamera.h
states that ifUpdateCamera()
is passed CAMERA_CUSTOM as an argument; the function will do nothing. Source: https://github.com/raysan5/raylib/blob/master/src/rcamera.h#L120However, the implementation of
UpdateCamera()
, has no checks to see if the mode passed is CAMERA_CUSTOM.https://github.com/raysan5/raylib/blob/master/src/rcamera.h#L438C6-L464
If
UpdateCamera
receives CAMERA_CUSTOM as argument; it will execute all the camera updating functions from lines 458 to 463.This has the following effect:
https://github.com/raysan5/raylib/assets/65001595/a853549f-bb17-47af-b79b-ef2021d2ef12
After the patch is applied; this behavior changes:
https://github.com/raysan5/raylib/assets/65001595/121953c7-779c-4e41-9cbe-89f61abd9b00
Now
UpdateCamera()
won't modify the camera regardless of Mouse movement or keyboard movement (Which, is the intended behavior; right?)This is the code that is used in the video:
PS: I am not mistaken; this would be the only/first use of CAMERA_CUSTOM in raylib.
PS2: There's a difference in the comments in between
raylib.h
andrcamera.h
. Is this intentional? Should I add another commit making them the same?Rcamera (comment is slightly more verbose): https://github.com/raysan5/raylib/blob/master/src/rcamera.h#L120
Raylib (comment is more bare bones): https://github.com/raysan5/raylib/blob/master/src/raylib.h#L916