summaryrefslogtreecommitdiff
path: root/core/templates
AgeCommit message (Collapse)Author
2022-02-05Remove RID_Owner.get_rid_by_indexreduz
* Implementing this function efficiently is not really possible. * Replaced by an option to get all RIDs into a buffer for performance.
2022-02-02Vectors: Use clear() and has().Anilforextra
Use clear() instead of resize(0). Use has() instead of "find(p_val) != -1".
2022-01-18Merge pull request #56668 from akien-mga/array-slice-nicer-bound-checksRémi Verschelde
2022-01-12Merge pull request #56492 from akien-mga/remove-author-docstringsRémi Verschelde
2022-01-10`Array`: Relax `slice` bound checks to properly handle negative indicesRémi Verschelde
The same is done for `Vector` (and thus `Packed*Array`). `begin` and `end` can now take any value and will be clamped to `[-size(), size()]`. Negative values are a shorthand for indexing the array from the last element upward. `end` is given a default `INT_MAX` value (which will be clamped to `size()`) so that the `end` parameter can be omitted to go from `begin` to the max size of the array. This makes `slice` works similarly to numpy's and JavaScript's.
2022-01-10Fix crash on importing FBX fileHaoyu Qiu
2022-01-05Add list initialization support for Vector & LocalVectorHaoyu Qiu
2022-01-04Style: Remove inconsistently used `@author` docstringsRémi Verschelde
Each file in Godot has had multiple contributors who co-authored it over the years, and the information of who was the original person to create that file is not very relevant, especially when used so inconsistently. `git blame` is a much better way to know who initially authored or later modified a given chunk of code, and most IDEs now have good integration to show this information.
2022-01-03Update copyright statements to 2022Rémi Verschelde
Happy new year to the wonderful Godot community!
2021-12-07Merge pull request #35901 from nathanfranke/pool-byte-array-subarray-exclusiveRémi Verschelde
2021-11-30Don't return reference on copy assignment operatorsRémi Verschelde
We prefer to prevent using chained assignment (`T a = b = c = T();`) as this can lead to confusing code and subtle bugs. According to https://en.wikipedia.org/wiki/Assignment_operator_(C%2B%2B), C++ allows any arbitrary return type, so this is standard compliant. This could be re-assessed if/when we have an actual need for a behavior more akin to that of the C++ STL, for now this PR simply changes a handful of cases which were inconsistent with the rest of the codebase (`void` return type was already the most common case prior to this commit).
2021-11-26PackedByteArray, Array slice end exclusive, rename subarray to sliceNathan Franke
2021-11-23Rename `remove()` to `remove_at()` when removing by indexLightning_A
2021-11-19Merge pull request #54499 from Faless/threads/4.x_work_pool_defaultRémi Verschelde
2021-11-08Merge pull request #54486 from ibrahn/thread-work-pool-lazierRémi Verschelde
2021-11-02[OS] Add ThreadWorkPool default size to OS.Fabio Alessandrelli
Some platforms (*cough* web *cough*) have hard limits on the number of threads that can be spawned. Currently, ThreadPoolWork (mostly used in rendering/physics servers) will spawn as many threads as CPUs available causing exception on machines with high CPU count. This commit adds a new overridable method to OS that returns the default thread pool size (still the CPU count by default), and overrides it for the JavaScript platform so it always allocate only one thread. We can likely improve the whole ThreadPoolWork in the future to always allocate X amount of threads, and assign jobs to them on the fly, but that will require some more architectural changes.
2021-11-01ThreadWorkPool no longer starts worker threads if given zero work.Ibrahn Sahir
2021-10-30Modify Dictionary::operator== to do real key/value comparison with recursive ↵Emmanuel Leblond
support (and add unittests)
2021-10-28clang-format: Various fixes to comments alignment from `clang-format` 13Rémi Verschelde
All reviewed manually and occasionally rewritten to avoid bad auto formatting.
2021-10-13Fix HashMap element copy leaving hash as zeroPedro J. Estébanez
2021-10-12Merge pull request #52495 from ↵Rémi Verschelde
kdiduk/issue-52491-fix-value-conversion-in-hashfuncs-header #52491 Cosmetic: fix type cast so that it matches return value type
2021-10-08Avoid the need for copy assignment in HashMap key/data typesPedro J. Estébanez
2021-10-05#52491 Cosmetic: fix type cast and add comment with the algorithm sourceKirill Diduk
2021-10-01Merge pull request #52850 from mashumafi/vector-bsearchRémi Verschelde
2021-09-30Implement bsearch for Vector and Packed*Arraymashumafi
2021-09-29Rename RID's `getornull()` to `get_or_null()`Hugo Locurcio
2021-09-24Replace `#pragma once` by traditional include guards for consistencyHugo Locurcio
`#pragma once` was used in a few files, yet we settled on using traditional include guards instead. The PooledList template comment was also moved to allow editors such as Visual Studio Code to display the comment when hovering PooledList. `app.h` was renamed to `app_uwp.h` to be less generic for the include guard.
2021-09-15Fix placement new on zero-sized region warning on GCC 11.1Grigoris Pavlakis
On latest (11.1 as of this commit) GCC, the following warning is continuously issued during build: warning: placement new constructing an object of type 'SafeNumeric<unsigned int>' and size '4' in a region of type 'uint32_t*' {aka 'unsigned int*'} and size '0' [-Wplacement-new=] This happens because on 98ceb60eb4 the new operator override used was dropped and replaced with standard placement new. GCC sees the subtraction from the pointer and complains as it thinks that the SafeNumeric is placed outside an allocation, not knowing that the address requested is already inside one. After suggestions, the false positive is silenced, with no other changes.
2021-09-09Replace stb_vorbis with libogg+libvorbisEllen Poe
2021-09-01Merge pull request #52026 from Calinou/constiterator-fix-constHugo Locurcio
Fix ConstIterator to allow `for` range loops on Packed*Array
2021-08-30Revert " Improve collision generation usability in the new 3D scene import ↵Juan Linietsky
workflow."
2021-08-30Merge pull request #51985 from AndreaCatania/collCamille Mohr-Daurat
Improve collision generation usability in the new 3D scene import workflow.
2021-08-27Add a SafeList data structure for future audio server usage.Ellen Poe
2021-08-26Fix LocalVector crash on insert.Gilles Roudière
2021-08-23Expose RID creation utilities.reduz
* Exposed as utility functions. * Not very useful for script, but vital for creating servers using native extensions.
2021-08-23Fix ConstIterator to allow `for` range loops on Packed*ArrayHugo Locurcio
2021-08-22Replace HTTP links with HTTPS for sites with HTTPS versionsAaron Franke
2021-08-22Fix Vector ConstIterator constructor.AndreaCatania
The constructor was expecting a mutable pointer, while the passed pointer was immutable ( returns a const pointer), so the compilation was failing when iterating a constant .
2021-08-14Add the possibility to initialize the classes allocated with the PagedAllocatorAndreaCatania
It uses the (`const T &&... p_args`) forward reference, to avoid copying the memory in case it's an rvalue, or pass a reference in case it's an lvalue. This is an example: ```c++ PagedAllocator<btShapeBox> box_allocator; btShapeBox* box = box_allocator.alloc( btVector3(1.0, 1.0, 1.0) ); ```
2021-08-13Refactors the memnew_placement.AndreaCatania
With this commit the macro `memnew_placement` uses the standard memory placement syntax: `new (mem) TheClass()`, and removes the outdated and not used syntax: ``` _ALWAYS_INLINE_ void *operator new(size_t p_size, void *p_pointer, size_t check, const char *p_description) { ``` Thanks to this change, the function `memnew_placement` call is compatible with any class, and can also initialize classes with non-empty constructor: ``` // This is valid, like before. memnew_placement(mem, Variant); // This works too: memnew_placement(mem, Variant(123)); ```
2021-07-27Fix Set range iterator implementationRaul Santos
2021-07-25Fix various typos with codespellluz paz
Found via `codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,fave,findn,hist,inout,leapyear,lod,nd,numer,ois,ony,paket,seeked,sinc,switchs,te,uint`
2021-07-21Use the standard C `INFINITY` and `NAN` constants directlyHugo Locurcio
The `Math_INF` and `Math_NAN` defines were just aliases for those constants, so we might as well use them directly. Some portions of the code were already using `INFINITY` directly.
2021-07-16Merge pull request #47395 from sygi/shape_idx_collisionHugo Locurcio
Add shape_idx to CollisionObject2D mouse_entered signal
2021-07-15Fix equality operators in List's ConstIteratorJoan Fons
2021-07-08Implement Range Iteratorsreduz
This PR implements range iterators in the base containers (Vector, Map, List, Pair Set). Given several of these data structures will be replaced by more efficient versions, having a common iterator API will make this simpler. Iterating can be done as follows (examples): ```C++ //Vector<String> for(const String& I: vector) { } //List<String> for(const String& I: list) { } //Map<String,int> for(const KeyValue<String,int>&I : map) { print_line("key: "+I.key+" value: "+itos(I.value)); } //if intending to write the elements, reference can be used //Map<String,int> for(KeyValue<String,int>& I: map) { I.value = 25; //this will fail because key is always const //I.key = "hello" } ``` The containers are (for now) not STL compatible, since this would mean changing how they work internally (STL uses a special head/tail allocation for end(), while Godot Map/Set/List do not). The idea is to change the Godot versions to be more compatible with STL, but this will happen after conversion to new iterators have taken place.
2021-07-06Unify material parameter updatereduz
* Unifies how material parameters are updated. * Single function, easier to maintain. * Updates materials properly when textures change.
2021-07-02Add mouse_shape_entered and mouse_shape_exited signals to CollisionObject2D.sygi
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
2021-07-01LocalVector: Don't error if `from` >= `count`Rémi Verschelde
Vector handles this silently by returning -1, and we should do the same here. Otherwise we get errors when calling `find()` on e.g. a LocalVector of size 0, while `find()` is expected to always work (if the parameters are invalid then it doesn't find anything, so -1). Fixup to #49925.
2021-06-29Improve RID_Owner memory usagereduz
* Ability to allocate empty objects in RID_Owner, so RID_PtrOwner is not needed in most cases. * Improves cache usage, as objects are now allocated together * Should improve performance in 2D rendering