Skip to content
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

PR #1/5 Astolfo feature/builtin-scalar #65

Merged
merged 1 commit into from
Jan 22, 2023

Conversation

RealAstolfo
Copy link

No description provided.

@RealAstolfo
Copy link
Author

apologies for the mistake with the previous pr. this implements the scalar functions needed for Vector2,3 etc.

@Bromeon Bromeon added feature Adds functionality to the library c: core Core components labels Jan 16, 2023
@ttencate
Copy link
Contributor

Even in a precision=single build, the float type in Godot is still 64-bits. So most/all of these functions should probably work on f64.

@Bromeon
Copy link
Member

Bromeon commented Jan 17, 2023

Even in a precision=single build, the float type in Godot is still 64-bits. So most/all of these functions should probably work on f64.

Correct, f64 is also the type we use for FFI (Godot <-> Rust parameters and return types).

@Bromeon
Copy link
Member

Bromeon commented Jan 21, 2023

On the other hand, in gdnative we also use f32, so we might start with this.

Certain functions like lerp() will likely get their own trait over time, as they can be implemented for lots of different types (vectors, transforms, etc). So that would allow polymorphism on them.

For others, I'm not sure. I'm a bit hesitant to provide two versions of each function, so sticking to f64 might be better. Thoughts?

bors try

bors bot added a commit that referenced this pull request Jan 21, 2023
@bors
Copy link
Contributor

bors bot commented Jan 21, 2023

try

Build failed:

@Bromeon
Copy link
Member

Bromeon commented Jan 21, 2023

CI passed except for the license-guard:

ERROR the following files don't have a valid license header:
godot-core/src/builtin/math.rs

Once you fix this, we can merge this PR.

There are almost certainly going to be API changes later, but it's good to have a starting version that powers the geometric types 👍

@ttencate
Copy link
Contributor

For others, I'm not sure. I'm a bit hesitant to provide two versions of each function, so sticking to f64 might be better. Thoughts?

I would say, when in doubt, do as the engine does. Hunting down precision issues introduced by a port from GDScript to Rust does not sound like fun.

@RealAstolfo RealAstolfo force-pushed the astolfo-feature/builtin-scalar branch from 5eaf0af to 89aebad Compare January 22, 2023 20:41
@Bromeon
Copy link
Member

Bromeon commented Jan 22, 2023

I would say, when in doubt, do as the engine does. Hunting down precision issues introduced by a port from GDScript to Rust does not sound like fun.

Generally I agree, however we also need to consider ergonomics. If 95% of calls look like func(arg as f64) as f32, we're not doing ourselves a favor. Traits might possibly help, functions like lerp() are useful for other types, too.

For now I would like to merge this to unblock the dependent PRs. There's anyway a lot to be done as follow-up for this functionality, for example:

  • Align with gdnative::globalscope
  • Proper testing
  • Documentation
  • Consider ..= ranges in arguments
  • ...

bors r+

@bors
Copy link
Contributor

bors bot commented Jan 22, 2023

Build succeeded:

@bors bors bot merged commit 0984917 into godot-rust:master Jan 22, 2023
@Bromeon
Copy link
Member

Bromeon commented Jan 22, 2023

@RealAstolfo First PR merged, thank you! 🙂

@RealAstolfo RealAstolfo deleted the astolfo-feature/builtin-scalar branch February 5, 2023 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: core Core components feature Adds functionality to the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants