summaryrefslogtreecommitdiffstats
path: root/core/math/vector2.h
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* Merge pull request #90582 from Repiteo/core/remove-macro-_NO_DISCARD_Rémi Verschelde2024-06-251-1/+1
|\ | | | | | | Core: Replace `_NO_DISCARD_` macro with `[[nodiscard]]`
| * Core: Replace `_NO_DISCARD_` macro with attributeThaddeus Crews2024-04-121-1/+1
| |
* | [Core] Add scalar versions of `Vector*` `min/max/clamp/snap(ped)`A Thousand Ships2024-05-021-0/+10
|/ | | | Convenience for a number of cases operating on single values
* [Core] Codestyle improvements to math typesA Thousand Ships2024-03-041-46/+46
|
* 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".
* Refactor interpolating functions in some classes to use Math classSilc Renew2022-11-241-21/+8
|
* Refactor Curve3D::_bake() methodYaohua Xiong2022-11-241-0/+13
| | | | | | | | | | The main change is to caculate tangent directly from bezier curve, without going through discretized polyline, avoiding pitfalls of discretization. Other changes are: 1. Add an bezier_derivative() method for Vector3, Vector2, and Math; 2. Add an tesselate_even_length() method to Curve3D, which tesselate bezier curve to even length segments adaptively; 3. Cache the tangent vectors in baked_tangent_vector_cache;
* Add `is_finite` method for checking built-in typesHaoyu Qiu2022-10-081-0/+1
|
* Remove set_all methods from Vector2/3/4Aaron Franke2022-09-191-4/+0
|
* Add `is_zero_approx` methods to `Vector2`, `3`, and `4`Jonathan Nicholl2022-09-021-0/+1
|
* Make `cubic_interpolate()` consider key time in animationSilc Renew2022-08-191-0/+8
|
* Refactor bezier interpolation functionsHendrik Brucker2022-06-271-1/+23
|
* Protection for array operator for Vector2 / 3 in DEV buildslawnjelly2022-03-071-0/+3
| | | | | | A previous PR had changed the array operator to give unbounded access. This could cause crashes where old code depended on this previous safe behaviour. This PR adds DEV_ASSERT macros for out of bound access to DEV builds, allowing us to quickly identify bugs in calling code, without affecting performance in release or release_debug editor builds.
* Float literals - fix main primitives to use .flawnjelly2022-02-101-1/+1
| | | | Converts float literals from double format (e.g. 0.0) to float format (e.g. 0.0f) where appropriate for 32 bit calculations.
* Fix Vector2 and Vector2i coord access via operator[]Bartłomiej T. Listwon2022-02-091-2/+2
|
* Fix integer vector mul/div operators and bindings.reduz2022-02-061-16/+19
| | | | | | | * Vector2i and Vector3i mul/div by a float results in Vector2 and Vector3 respectively. * Create specializations to allow proper bindings. This fixes #44408 and supersedes #44441 and keeps the same rule of int <op> float returnig float, like with scalars.
* Core: Move Vector2i to its own `vector2i.h` headerRémi Verschelde2022-02-041-110/+2
| | | | Also reduce interdependencies and clean up a bit.
* Add nodiscard to core math classes to catch c++ errors.lawnjelly2022-01-201-2/+2
| | | | A common source of errors is to call functions (such as round()) expecting them to work in place, but them actually being designed only to return the processed value. Not using the return value in this case in indicative of a bug, and can be flagged as a warning by using the [[nodiscard]] attribute.
* Merge pull request #53618 from aaronfranke/signed-angle-vec3iRémi Verschelde2022-01-071-0/+3
|\ | | | | Add length and length_squared to Vector2i/3i
| * Add length and length_squared to Vector2i/3iAaron Franke2022-01-061-0/+3
| |
* | Allow Vector2/3 slerp values to have any lengthAaron Franke2022-01-061-5/+10
|/
* Update copyright statements to 2022Rémi Verschelde2022-01-031-2/+2
| | | | Happy new year to the wonderful Godot community!
* Expose max_axis_index and max_axis_index for Vector2(i)Aaron Franke2021-12-021-8/+8
| | | | Some cleanup with Vector3(i)'s methods so that it is consistent with Vector2, for example it returns enums internally (GDScript still gets ints).
* 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).
* Add Vector2.from_angle() methodkobewi2021-08-311-0/+1
|
* Add constant to vector function parameters that don't actually modify their ↵Ricard Rovira Cubeles2021-08-151-15/+15
| | | | | input. Add more overloads of vector multiplication, required by templates to compile with float=64.
* Add min_axis and max_axis to Vector2iGilles Roudière2021-07-211-0/+8
|
* Reformat structure string operatorsAaron Franke2021-06-111-2/+2
| | | | | | 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/+2
|
* Rename Vector2 clamped to limit_length and add limit_length to Vector3Aaron Franke2021-06-031-2/+1
|
* Dynamic BVH broadphase in 2D & 3D Godot PhysicsPouleyKetchoupp2021-05-101-6/+26
| | | | | | | | | | | | | | Port lawnjelly's dynamic BVH implementation from 3.x to be used in both 2D and 3D broadphases. Removed alternative broadphase implementations which are not meant to be used anymore since they are much slower. Includes changes in Rect2, Vector2, Vector3 that help with the template implementation of the dynamic BVH by uniformizing the interface between 2D and 3D math. Co-authored-by: lawnjelly <lawnjelly@gmail.com>
* Rework the TileSet resource and TileMap nodes:Gilles Roudière2021-05-071-0/+8
| | | | | | | | | | - Move most properties from TileMap to TileSet, - Make TileSet more flexible, supporting more feature (several collision layers, etc...), - Fusion both the TileMap and TileSet editor, - Implement TileSetSources, and thus a new way to index tiles in the TileSet, - Rework the TileSet and TileMap editors completely, - Implement an editor zoom widget (and use it in several places)
* Define GDNative sizes using sizeof(godot_real_t) and sizeof(int32_t)Aaron Franke2021-01-251-15/+15
|
* 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 🎆
* Merge pull request #44149 from madmiraal/rename-tangent-orthogonalRémi Verschelde2020-12-281-1/+1
|\ | | | | Rename Vector2.tangent() to Vector2.orthogonal()
| * Rename Vector2.tangent() to Vector2.orthogonal()Marcel Admiraal2020-12-061-1/+1
| |
* | Improve argument names for core typesAaron Franke2020-12-071-13/+13
|/
* Reorganized core/ directory, it was too fatty alreadyreduz2020-11-071-1/+1
| | | | | | -Removed FuncRef, since Callable makes it obsolete -Removed int_types.h as its obsolete in c++11+ -Changed color names code
* Refactored Variant Operators.reduz2020-11-061-2/+4
| | | | | -Using classes to call and a table -For typed code (GDS or GDNative), can obtain functions to call prevalidated or ptr.
* Implement GPU Particle Collisionsreduz2020-10-091-0/+8
| | | | | | | | | | -Sphere Attractor -Box Attractor -Vector Field -Sphere Collider -Box Collider -Baked SDF Collider -Heightmap Collider
* Allow commutative multiplication in VariantGeorge Marques2020-09-171-1/+29
| | | | Also allow quaternions to be multiplied by integers.
* Change inequality comparison operators to use exact equalityAaron Franke2020-09-081-4/+4
|
* 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-20/+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.
* Port member initialization from constructor to declaration (C++11)Rémi Verschelde2020-05-141-9/+7
| | | | | | | | | | Using `clang-tidy`'s `modernize-use-default-member-init` check and manual review of the changes, and some extra manual changes that `clang-tidy` failed to do. Also went manually through all of `core` to find occurrences that `clang-tidy` couldn't handle, especially all initializations done in a constructor without using initializer lists.
* [Core] Rename linear_interpolate to lerpAaron Franke2020-04-291-13/+2
|
* Improve the Vector2 rotated codeAaron Franke2020-04-211-6/+0
|