summaryrefslogtreecommitdiff
path: root/scene/resources/curve.cpp
AgeCommit message (Collapse)Author
2022-08-30Rename Curve/Curve2D/Curve3D/Gradient `interpolate()` to `sample()`Hugo Locurcio
"sampling" is a more accurate term than "interpolating" for what's happening when using that function.
2022-08-26Rename `str2var` to `str_to_var` and similarMicky
Affects the Math class, a good chunk of the audio code, and a lot of other miscellaneous classes, too. - `var2str` -> `var_to_str` - `str2var` -> `str_to_var` - `bytes2var` -> `bytes_to_var` - `bytes2var_with_objects` -> `bytes_to_var_with_objects` - `var2bytes` -> `var_to_bytes` - `var2bytes_with_objects` -> `var_to_bytes_with_objects` - `linear2db` -> `linear_to_db` - `db2linear` -> `db_to_linear` - `deg2rad` -> `deg_to_rad` - `rad2deg` -> `rad_to_deg` - `dict2inst` -> `dict_to_inst` - `inst2dict` -> `inst_to_dict`
2022-08-15Clarify the Line2D, Curve2D/3D documentation and fix parameter namesYuri Sizov
2022-08-08Add tests for empty/unnamed arguments to ClassDB, Variant, GDScriptYuri Sizov
2022-06-27Refactor bezier interpolation functionsHendrik Brucker
2022-06-23Fix Curve{2D,3D} notifying property list changedRaul Santos
Make `Curve2D` and `Curve3D` more consistent with `Curve` and avoid calling `notify_property_list_changed` when the list of points doesn't change.
2022-06-22Fixed dragging curve pointsVitika9
2022-05-17Expose Curve points in the inspectorRaul Santos
Exposes the Curve, Curve2D and Curve3D points as an array property.
2022-05-17Implement `mark_dirty` in Curve2D and Curve3DRaul Santos
Implements a method `mark_dirty` in Curve2D and Curve3D like the one that already exists in Curve, it's a convenient way to set `baked_cache_dirty` to `true` and also emit the `changed` signal.
2022-05-16Regression: Fix Curve2D/Curve3D bakingHendrik Brucker
2022-05-16Replace most uses of Map by HashMapreduz
* Map is unnecessary and inefficient in almost every case. * Replaced by the new HashMap. * Renamed Map to RBMap and Set to RBSet for cases that still make sense (order matters) but use is discouraged. There were very few cases where replacing by HashMap was undesired because keeping the key order was intended. I tried to keep those (as RBMap) as much as possible, but might have missed some. Review appreciated!
2022-05-12Fix Curve bake algorithmRaul Santos
2022-05-12Fix Curve idx calculation for baked tilts and up vectorsRaul Santos
2022-02-02Vectors: Use clear() and has().Anilforextra
Use clear() instead of resize(0). Use has() instead of "find(p_val) != -1".
2022-01-03Update copyright statements to 2022Rémi Verschelde
Happy new year to the wonderful Godot community!
2021-11-30Improve Curve with const and real_tAaron Franke
2021-11-23Rename `remove()` to `remove_at()` when removing by indexLightning_A
2021-11-03Rename `PROPERTY_USAGE_NOEDITOR` to `PROPERTY_USAGE_NO_EDITOR`Hugo Locurcio
This is consistent with other constants that include `NO`, such as `PROPERTY_HINT_COLOR_NO_ALPHA`.
2021-09-30Use range iterators for `Map`Lightning_A
2021-08-21Curve2D/Curve3D: exact linear interpolationJihyun Yu
While calculating interpolated points, intervals between two baked points has been assummed to be `baked_interval`. The assumption could cause significant error in some extreme cases (for example #7088). To improve accuracy, `baked_dist_cache` is introduced, which stores distance from starting point for each baked points. `interpolate_baked` now returns exact linear-interpolated position along baked points.
2021-08-09Some work on double supportAaron Franke
2021-07-25Use const references where possible for List range iteratorsRémi Verschelde
2021-07-23Use C++ iterators for Lists in many situationsAaron Franke
2021-07-18Optimize StringName usagereduz
* Added a new macro SNAME() that constructs and caches a local stringname. * Subsequent usages use the cached version. * Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time. * Replaced all theme usages by this new macro. * Replace all signal emission usages by this new macro. * Replace all call_deferred usages by this new macro. This is part of ongoing work to optimize GUI and the editor.
2021-04-30Implement Particle Trailsreduz
-Enable the trails and set the length in seconds -Provide a mesh with a skeleton and a skin -Or, alternatively use one of the built-in TubeTrailMesh/RibbonTrailMesh -Works deterministically -Fixed particle collisions (were broken) -Not working in 2D yet (that will happen next)
2021-02-09Initialize class variables with default values in scene/ [2/2]Rafał Mikrut
2021-01-01Update copyright statements to 2021Rémi Verschelde
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 🎆
2020-12-28Rename empty() to is_empty()Marcel Admiraal
2020-05-14Style: Enforce braces around if blocks and loopsRémi Verschelde
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2020-05-14Style: Enforce separation line between function definitionsRémi Verschelde
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.
2020-05-14Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde
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.
2020-05-10Revert "Renamed plane's d to distance"Rémi Verschelde
This reverts commit ec7b481170dcd6a7b4cf0e6c1221e204ff7945f3. This was wrong, `d` is not a distance but the `d` constant in the parametric equation `ax + by + cz = d` describing the plane.
2020-05-10Renamed plane's d to distanceMarcus Elg
2020-04-29[Core] Rename linear_interpolate to lerpAaron Franke
2020-03-17Style: Set clang-format Standard to Cpp11Rémi Verschelde
For us, it practically only changes the fact that `A<A<int>>` is now used instead of the C++03 compatible `A<A<int> >`. Note: clang-format 10+ changed the `Standard` arguments to fully specified `c++11`, `c++14`, etc. versions, but we can't use `c++17` now if we want to preserve compatibility with clang-format 8 and 9. `Cpp11` is still supported as deprecated alias for `Latest`.
2020-02-25Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.Juan Linietsky
- Renames PackedIntArray to PackedInt32Array. - Renames PackedFloatArray to PackedFloat32Array. - Adds PackedInt64Array and PackedFloat64Array. - Renames Variant::REAL to Variant::FLOAT for consistency. Packed arrays are for storing large amount of data and creating stuff like meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of memory. That said, many users requested the ability to have 64 bits packed arrays for their games, so this is just an optional added type. For Variant, the float datatype is always 64 bits, and exposed as `float`. We still have `real_t` which is the datatype that can change from 32 to 64 bits depending on a compile flag (not entirely working right now, but that's the idea). It affects math related datatypes and code only. Neither Variant nor PackedArray make use of real_t, which is only intended for math precision, so the term is removed from there to keep only float.
2020-02-18PoolVector is gone, replaced by VectorJuan Linietsky
Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are sugar for `Vector<Type>`.
2020-01-01Update copyright statements to 2020Rémi Verschelde
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.
2019-08-09Remove ERR_EXPLAIN from scene/* codeTomasz Chabora
2019-06-21Curve: Prevent forcing 1.0 min value to 0.99Rémi Verschelde
The setters are called when the property is first initialized, and before that its default min and max are 0.0 and 1.0 respectively. If you configured min_value to 1.0 and max_value to e.g. 3.0, since the min_value setter can be called before that of max_value (which thus still defaults to 1.0), the min will be set to 0.99. Same conflict could happen with a configured max_value of 0 if its setter is called before that of a valid, negative min value.
2019-05-01Fixing Curve2D/3D baked interpolated valuesMaxime Leroy
If bake interval is a multiple of the curve length, the curve would return NaN for some offset values (when `frac == 0.0`, it matches the start and end of the curve segment so `fmod == 0.0`, `frac` becomes NaN) ``` # Godot 3.1.1 var c = Curve3D.new() c.add_point(Vector3()) c.add_point(Vector3(0.5,0,0)) c.add_point(Vector3(1,0,0)) c.bake_interval = 0.5 c.interpolate_baked(0.5) == Vector3(NAN, NAN, NAN) ```
2019-04-08Small fixes, mostly dupicated codeqarmin
2019-01-16Appease some CppCheck warns for files in the "scene" directoryMichael Alexsander Silva Dias
2019-01-01Update copyright statements to 2019Rémi Verschelde
Happy new year to the wonderful Godot community!
2018-09-12Make core/ includes absolute, remove subfolders from include pathRémi Verschelde
This allows more consistency in the manner we include core headers, where previously there would be a mix of absolute, relative and include path-dependent includes.
2018-09-07Bind Curve::get_point_countmerumelu
2018-07-26Reduce unnecessary COW on Vector by make writing explicitHein-Pieter van Braam
This commit makes operator[] on Vector const and adds a write proxy to it. From now on writes to Vectors need to happen through the .write proxy. So for instance: Vector<int> vec; vec.push_back(10); std::cout << vec[0] << std::endl; vec.write[0] = 20; Failing to use the .write proxy will cause a compilation error. In addition COWable datatypes can now embed a CowData pointer to their data. This means that String, CharString, and VMap no longer use or derive from Vector. _ALWAYS_INLINE_ and _FORCE_INLINE_ are now equivalent for debug and non-debug builds. This is a lot faster for Vector in the editor and while running tests. The reason why this difference used to exist is because force-inlined methods used to give a bad debugging experience. After extensive testing with modern compilers this is no longer the case.
2018-07-06Support for CPU based particles, which aids compatibility with OpenGL ES 2.0Juan Linietsky
2018-05-20Up vector implementation and OrientedPathFollow.danilo2205
2018-05-01Added methods get_closest_point and get_closest_offset to both Curve2D and ↵danilo2205
Curve3D