Commit graph

74 commits

Author SHA1 Message Date
Rémi Verschelde e87687a6d0
Merge pull request #54486 from ibrahn/thread-work-pool-lazier 2021-11-08 13:39:39 +01:00
Ibrahn Sahir 151d2e34ca ThreadWorkPool no longer starts worker threads if given zero work. 2021-11-01 19:19:25 +00:00
Emmanuel Leblond f9ba2efe1e
Modify Dictionary::operator== to do real key/value comparison with recursive support (and add unittests) 2021-10-30 13:11:01 +02:00
Rémi Verschelde 3a6be64c12
clang-format: Various fixes to comments alignment from clang-format 13
All reviewed manually and occasionally rewritten to avoid bad auto formatting.
2021-10-28 15:43:36 +02:00
Pedro J. Estébanez f80e4e4f4c Fix HashMap element copy leaving hash as zero 2021-10-13 17:25:31 +02:00
Rémi Verschelde 6f1d2133bb
Merge pull request #52495 from kdiduk/issue-52491-fix-value-conversion-in-hashfuncs-header
#52491 Cosmetic: fix type cast so that it matches return value type
2021-10-12 22:38:39 +02:00
Pedro J. Estébanez 73697d4de6 Avoid the need for copy assignment in HashMap key/data types 2021-10-08 20:06:07 +02:00
Kirill Diduk 1f38b00242 #52491 Cosmetic: fix type cast and add comment with the algorithm source 2021-10-05 21:40:33 +02:00
Rémi Verschelde b32f84d473
Merge pull request #52850 from mashumafi/vector-bsearch 2021-10-01 07:52:51 +02:00
mashumafi 214bbfbefe Implement bsearch for Vector and Packed*Array 2021-09-30 23:57:26 +00:00
Hugo Locurcio ba65730cbf
Rename RID's getornull() to get_or_null() 2021-09-29 23:58:02 +02:00
Hugo Locurcio 6def32d643
Replace #pragma once by traditional include guards for consistency
`#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-24 02:33:15 +02:00
Grigoris Pavlakis abef2b7194 Fix placement new on zero-sized region warning on GCC 11.1
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-15 00:07:21 +03:00
Ellen Poe f5d9c7b487 Replace stb_vorbis with libogg+libvorbis 2021-09-09 19:39:04 -07:00
Hugo Locurcio ac7541c1b1
Merge pull request #52026 from Calinou/constiterator-fix-const
Fix ConstIterator to allow `for` range loops on Packed*Array
2021-09-01 14:25:01 +02:00
Juan Linietsky 6dab6e4136
Revert " Improve collision generation usability in the new 3D scene import workflow." 2021-08-30 11:30:36 -03:00
Camille Mohr-Daurat b60a51f023
Merge pull request #51985 from AndreaCatania/coll
Improve collision generation usability in the new 3D scene import workflow.
2021-08-30 07:25:51 -07:00
Ellen Poe 460e0ce314 Add a SafeList data structure for future audio server usage. 2021-08-27 10:26:18 -07:00
Gilles Roudière de0765b94a Fix LocalVector crash on insert. 2021-08-26 11:54:56 +02:00
reduz 65ca132a80 Expose RID creation utilities.
* Exposed as utility functions.
* Not very useful for script, but vital for creating servers using native extensions.
2021-08-23 21:55:45 -03:00
Hugo Locurcio 87b985a6aa
Fix ConstIterator to allow for range loops on Packed*Array 2021-08-23 19:00:33 +02:00
Aaron Franke ae1702bee5
Replace HTTP links with HTTPS for sites with HTTPS versions 2021-08-22 20:13:11 -05:00
AndreaCatania de0991d801 Fix Vector ConstIterator constructor.
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-22 18:19:04 +02:00
AndreaCatania c81cb64416 Add the possibility to initialize the classes allocated with the PagedAllocator
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-14 09:04:31 +02:00
AndreaCatania 98ceb60eb4 Refactors the memnew_placement.
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-08-13 10:18:34 +02:00
Raul Santos c8a94a621d Fix Set range iterator implementation 2021-07-27 02:48:28 +02:00
luz paz 3564c16cb8
Fix various typos with codespell
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-25 11:21:51 +02:00
Hugo Locurcio 4bd5e4fd9b
Use the standard C INFINITY and NAN constants directly
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-21 10:41:08 +02:00
Hugo Locurcio 523d6b2ae8
Merge pull request #47395 from sygi/shape_idx_collision
Add shape_idx to CollisionObject2D mouse_entered signal
2021-07-16 19:05:08 +02:00
Joan Fons cfec291978 Fix equality operators in List's ConstIterator 2021-07-15 10:47:20 +02:00
reduz a9c943bef9 Implement Range Iterators
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-08 23:27:27 -03:00
reduz c43f624d44 Unify material parameter update
* Unifies how material parameters are updated.
* Single function, easier to maintain.
* Updates materials properly when textures change.
2021-07-06 18:57:38 -03:00
sygi 6f3e7f7cb0 Add mouse_shape_entered and mouse_shape_exited signals to CollisionObject2D.
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
2021-07-02 20:50:27 +01:00
Rémi Verschelde 7b7ccf25b6
LocalVector: Don't error if from >= count
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-07-01 12:16:33 +02:00
reduz 64c925cca6 Improve RID_Owner memory usage
* 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
2021-06-29 12:28:08 -03:00
Ricard Rovira 14d5908057 Use unused from in local vector find function. 2021-06-29 13:37:02 +02:00
Rémi Verschelde f1bcc641dd
Merge pull request #49583 from timothyqiu/texture-crash
Fix crash when freeing GradientTexture and NoiseTexture
2021-06-24 09:40:42 +02:00
Lyuma c21aa9196e Consider a thread done if current_work is null 2021-06-17 05:22:43 -07:00
jfons 3a53ae5d9f Implement visibility range and dependencies.
This commit adds the following properties to GeometryInstance3D: `visibility_range_begin`,
`visibility_range_begin_margin`, `visibility_range_end`, `visibility_range_end_margin`.

Together they define a range in which the GeometryInstance3D will be visible from the camera,
taking hysteresis into account for state changes. A begin or end value of 0 will be ignored,
so the visibility range can be open-ended in both directions.

This commit also adds the `visibility_parent` property to 'Node3D'.
Which defines the visibility parents of the node and its subtree (until
another parent is defined).

Visual instances with a visibility parent will only be visible when the parent, and all of its
ancestors recursively, are hidden because they are closer to the camera than their respective
`visibility_range_begin` thresholds.

Combining visibility ranges and visibility parents users can set-up a quick HLOD system
that shows high detail meshes when close (i.e buildings, trees) and merged low detail meshes
for far away groups (i.e. cities, woods).
2021-06-14 12:17:11 +02:00
Haoyu Qiu 37db8d6184 Fix crash when freeing GradientTexture and NoiseTexture 2021-06-14 12:32:19 +08:00
reduz c66b2651a6 Refactor CommandQueueMT
* RingBuffer had no reason to be in this context
* A single buffer is used that can grow as much as the game needs.

This should make thread loading entirely reliable.
2021-06-09 13:10:49 -03:00
Rémi Verschelde c1c76850cb
Style: Cleanup uses of double spaces between words
Or after punctuation. Tried to leave third-party stuff alone, unless it has
been heavily modified for Godot.
2021-06-07 11:03:08 +02:00
Morris Tabor d1bc88d426 Replace QuickHull with Bullet's convex hull computer.
The code is based on the current version of thirdparty/vhacd and modified to use Godot's types and code style.

Additional changes:
- extended PagedAllocator to allow leaked objects
- applied patch from https://github.com/bulletphysics/bullet3/pull/3037
2021-05-22 22:35:42 +02:00
PouleyKetchoupp 3877ed73d0 Dynamic BVH broadphase in 2D & 3D Godot Physics
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>
2021-05-10 16:28:55 -07:00
Rémi Verschelde 9e9ac9f6ad
Merge pull request #46476 from DarknessCatt/master
Add fill method to Arrays and PackedArrays
2021-04-28 16:52:31 +02:00
Rémi Verschelde 8247667a3e
Core: Drop custom copymem/zeromem defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f6639.

There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.
2021-04-27 16:26:27 +02:00
Rémi Verschelde 3d46f28558
Add type_traits include for std::is_trivially_destructible 2021-04-22 16:23:55 +02:00
Matheus Lima Cunha efd27a63c1 Add fill method to Arrays and PackedArrays 2021-04-21 11:33:53 -03:00
Juan Linietsky 2b730cad90 Use multiple threads to import.
- For now everything imports multithreaded by default (should work I guess, let's test).
- Controllable per importer

Early test benchmark. 64 large textures (importing as lossless, _not_ as vram) on a mobile i7, 12 threads:
Importing goes down from 46 to 7 seconds.

For VRAM I will change the logic to use a compressing thread in a subsequent PR, as well as implementing Betsy.
2021-04-19 14:12:22 -03:00
Bartłomiej T. Listwon 1eaaf2f9a2 Separate set.h from map.h 2021-04-14 11:43:45 +02:00