summaryrefslogtreecommitdiffstats
path: root/core/math/vector2.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge commit godotengine/godot@c6c464cf9ae56e8b68620af65125dd980d0e8122Spartan3222024-11-021-1/+1
|\
| * Always add decimal when printing floatkobewi2024-10-231-1/+1
| |
* | Fix copyright headers referring to GodotSpartan3222024-10-271-2/+2
| |
* | Rebrand preambles to RedotDubhghlas McLaughlin2024-10-111-0/+2
|/ | | | | | | | | | | | | | | | | | | | | | Credits: Co-authored-by: Skogi <skogi.b@gmail.com> Co-authored-by: Spartan322 <Megacake1234@gmail.com> Co-authored-by: swashberry <swashdev@pm.me> Co-authored-by: Christoffer Sundbom <christoffer_karlsson@live.se> Co-authored-by: Dubhghlas McLaughlin <103212704+mcdubhghlas@users.noreply.github.com> Co-authored-by: McDubh <103212704+mcdubhghlas@users.noreply.github.com> Co-authored-by: Dubhghlas McLaughlin <103212704+mcdubhghlas@users.noreply.github.com> Co-authored-by: radenthefolf <radenthefolf@gmail.com> Co-authored-by: John Knight <80524176+Tekisasu-JohnK@users.noreply.github.com> Co-authored-by: Adam Vondersaar <adam.vondersaar@uphold.com> Co-authored-by: decryptedchaos <nixgod@gmail.com> Co-authored-by: zaftnotameni <122100803+zaftnotameni@users.noreply.github.com> Co-authored-by: Aaron Benjamin <lifeartstudios@gmail.com> Co-authored-by: wesam <108880473+wesamdev@users.noreply.github.com> Co-authored-by: Mister Puma <MisterPuma80@gmail.com> Co-authored-by: Aaron Benjamin <lifeartstudios@gmail.com> Co-authored-by: SingleError <isaaconeoneone@gmail.com> Co-authored-by: Bioblaze Payne <BioblazePayne@gmail.com>
* [Core] Add scalar versions of `Vector*` `min/max/clamp/snap(ped)`A Thousand Ships2024-05-021-0/+12
| | | | Convenience for a number of cases operating on single values
* [Core] Codestyle improvements to math typesA Thousand Ships2024-03-041-5/+5
|
* Merge pull request #87688 from AThousandShips/what_is_thisRémi Verschelde2024-01-291-2/+2
|\ | | | | | | Remove unnecessary `this->` expressions
| * Remove unnecessary `this->` expressionsA Thousand Ships2024-01-291-2/+2
| |
* | Display values in vector/quaternion math function errorsHugo Locurcio2024-01-281-2/+2
|/ | | | This can help track down the source of the error more easily.
* One Copyright Update to rule them allRémi Verschelde2023-01-051-29/+29
| | | | | | | | | | | | | | | | | | | | As many open source projects have started doing it, we're removing the current year from the copyright notice, so that we don't need to bump it every year. It seems like only the first year of publication is technically relevant for copyright notices, and even that seems to be something that many companies stopped listing altogether (in a version controlled codebase, the commits are a much better source of date of publication than a hardcoded copyright statement). We also now list Godot Engine contributors first as we're collectively the current maintainers of the project, and we clarify that the "exclusive" copyright of the co-founders covers the timespan before opensourcing (their further contributions are included as part of Godot Engine contributors). Also fixed "cf." Frenchism - it's meant as "refer to / see".
* Add `is_finite` method for checking built-in typesHaoyu Qiu2022-10-081-0/+4
|
* Add `is_zero_approx` methods to `Vector2`, `3`, and `4`Jonathan Nicholl2022-09-021-0/+4
|
* Refactor bezier interpolation functionsHendrik Brucker2022-06-271-7/+0
|
* Float literals - fix main primitives to use real_t castinglawnjelly2022-02-241-1/+1
| | | | Uses (real_t) casting to ensure appropriate calculations are done in 32 bit where real_t is compiled as 32 bit.
* Implement cubic_interpolate() as MathFunc for refactoringSilc 'Tokage' Renew2022-02-121-16/+4
|
* Float literals - fix main primitives to use .flawnjelly2022-02-101-5/+5
| | | | Converts float literals from double format (e.g. 0.0) to float format (e.g. 0.0f) where appropriate for 32 bit calculations.
* Core: Move Vector2i to its own `vector2i.h` headerRémi Verschelde2022-02-041-87/+5
| | | | Also reduce interdependencies and clean up a bit.
* Add length and length_squared to Vector2i/3iAaron Franke2022-01-061-0/+8
|
* Update copyright statements to 2022Rémi Verschelde2022-01-031-2/+2
| | | | Happy new year to the wonderful Godot community!
* Rename built-in `SGN()` macro to `SIGN()`Hugo Locurcio2021-11-161-1/+1
| | | | | This matches the name of the GDScript function (except it's uppercase here).
* Fix Vector2.angle_to_point() being reversedTomasz Chabora2021-11-091-1/+1
|
* clang-format: Disable alignment of operands, too unreliableRémi Verschelde2021-10-281-4/+5
| | | | | | | | | Sets `AlignOperands` to `DontAlign`. `clang-format` developers seem to mostly care about space-based indentation and every other version of clang-format breaks the bad mismatch of tabs and spaces that it seems to use for operand alignment. So it's better without, so that it respects our two-tabs `ContinuationIndentWidth`.
* Use builtin Vector2 functions for calculation of angles.Anilforextra2021-09-071-1/+1
| | | | .
* Add Vector2.from_angle() methodkobewi2021-08-311-0/+4
|
* Add constant to vector function parameters that don't actually modify their ↵Ricard Rovira Cubeles2021-08-151-2/+2
| | | | | input. Add more overloads of vector multiplication, required by templates to compile with float=64.
* Reformat structure string operatorsAaron Franke2021-06-111-0/+8
| | | | | | The order of numbers is not changed except for Transform2D. All logic is done inside of their structures (and not in Variant). For the number of decimals printed, they now use String::num_real which works best with real_t, except for Color which is fixed at 4 decimals (this is a reliable number of float digits when converting from 16-bpc so it seems like a good choice)
* Allow clamping vectors and colorsAaron Franke2021-06-031-0/+12
|
* Rename Vector2 clamped to limit_length and add limit_length to Vector3Aaron Franke2021-06-031-2/+2
|
* Make is_equal_approx have explicit float and double versionsAaron Franke2021-05-201-1/+1
|
* Define GDNative sizes using sizeof(godot_real_t) and sizeof(int32_t)Aaron Franke2021-01-251-6/+6
|
* Update copyright statements to 2021Rémi Verschelde2021-01-011-2/+2
| | | | | | | | | | | | | | Happy new year to the wonderful Godot community! 2020 has been a tough year for most of us personally, but a good year for Godot development nonetheless with a huge amount of work done towards Godot 4.0 and great improvements backported to the long-lived 3.2 branch. We've had close to 400 contributors to engine code this year, authoring near 7,000 commit! (And that's only for the `master` branch and for the engine code, there's a lot more when counting docs, demos and other first-party repos.) Here's to a great year 2021 for all Godot users 🎆
* Rename Math::stepify to snappedMarcel Admiraal2020-12-281-3/+3
|
* Improve argument names for core typesAaron Franke2020-12-071-4/+4
|
* Refactored Variant Operators.reduz2020-11-061-0/+13
| | | | | -Using classes to call and a table -For typed code (GDS or GDNative), can obtain functions to call prevalidated or ptr.
* Style: Remove unnecessary semicolons from `core`Rémi Verschelde2020-05-191-6/+7
| | | | | | | | | | Semicolons are not necessary after function definitions or control flow blocks, and having some code use them makes things inconsistent (and occasionally can mess up `clang-format`'s formatting). Removing them is tedious work though, I had to do this manually (regex + manual review) as I couldn't find a tool for that. All other code folders would need to get the same treatment.
* Style: Enforce separation line between function definitionsRémi Verschelde2020-05-141-0/+4
| | | | | | | | | | | | | | | | | | | | | | | I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of #33027.
* Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde2020-05-141-33/+0
| | | | | | | | | | | | | | Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
* Improve the Vector2 rotated codeAaron Franke2020-04-211-5/+5
|
* Add explanations for errors related to Vector/Quat normalizationHugo Locurcio2020-01-241-2/+2
|
* Update copyright statements to 2020Rémi Verschelde2020-01-011-2/+2
| | | | | | | | | | | Happy new year to the wonderful Godot community! We're starting a new decade with a well-established, non-profit, free and open source game engine, and tons of further improvements in the pipeline from hundreds of contributors. Godot will keep getting better, and we're looking forward to all the games that the community will keep developing and releasing with it.
* Make is_equal_approx separate for structuresAaron Franke2019-10-141-0/+4
| | | | This commit adds exposed behavior for C#
* Add Vector2/3 sign and posmod functions, misc additionsAaron Franke2019-08-171-0/+13
| | | | Also make the docs more consistent, add Axis enum to Vector2, add > and >=. and C# also gets % and an override for vector-vector mod.
* Added move_toward functions for float, Vector2 and Vector3Giacom2019-05-281-0/+7
|
* Several fixes to make GLES2 on HTML5 work much better.Juan Linietsky2019-02-251-1/+1
| | | | Changed math class error reporting to be a bit less paranoid.
* Update copyright statements to 2019Rémi Verschelde2019-01-011-2/+2
| | | | Happy new year to the wonderful Godot community!
* Remove redundant "== false" codeAaron Franke2018-10-061-2/+2
| | | | | | Some of this code has been re-organized. f
* [Mono] Vector2/3 Project methodsAaron Franke2018-08-221-1/+1
|
* add project method to Vector2/3Thomas Herzog2018-08-161-5/+2
|
* [Core] Move Vector2i and Rect2i out of math_2d.hAaron Franke2018-08-111-0/+66
|
* [Core] Move Vector2 to its own fileAaron Franke2018-08-101-0/+187
Makes 2D math code easier to read and makes Vector2 consistent with Vector3. In the future, we may move other things out of math_2d as well.