summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/bullet/godot_result_callbacks.cpp48
-rw-r--r--modules/bullet/godot_result_callbacks.h6
-rw-r--r--modules/gdscript/gdscript_function.h3
-rw-r--r--modules/gdscript/gdscript_parser.h3
-rw-r--r--modules/minimp3/audio_stream_mp3.cpp28
-rw-r--r--modules/minimp3/audio_stream_mp3.h2
-rw-r--r--modules/mono/editor/bindings_generator.h2
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs18
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs32
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs58
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs24
-rw-r--r--modules/mono/godotsharp_dirs.cpp3
-rw-r--r--modules/mono/mono_gc_handle.h3
-rw-r--r--modules/mono/mono_gd/gd_mono_log.cpp11
-rw-r--r--modules/navigation/navigation_mesh_generator.cpp62
-rw-r--r--modules/navigation/navigation_mesh_generator.h8
16 files changed, 171 insertions, 140 deletions
diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp
index 1f962772e7..edb2bcb4c7 100644
--- a/modules/bullet/godot_result_callbacks.cpp
+++ b/modules/bullet/godot_result_callbacks.cpp
@@ -107,7 +107,14 @@ btScalar GodotAllConvexResultCallback::addSingleResult(btCollisionWorld::LocalCo
PhysicsDirectSpaceState3D::ShapeResult &result = m_results[count];
- result.shape = convexResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is an odd name but contains the compound shape ID
+ // Triangle index is an odd name but contains the compound shape ID.
+ // A shape part of -1 indicates the index is a shape index and not a triangle index.
+ if (convexResult.m_localShapeInfo && convexResult.m_localShapeInfo->m_shapePart == -1) {
+ result.shape = convexResult.m_localShapeInfo->m_triangleIndex;
+ } else {
+ result.shape = 0;
+ }
+
result.rid = gObj->get_self();
result.collider_id = gObj->get_instance_id();
result.collider = result.collider_id.is_null() ? nullptr : ObjectDB::get_instance(result.collider_id);
@@ -171,11 +178,14 @@ bool GodotClosestConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0)
}
btScalar GodotClosestConvexResultCallback::addSingleResult(btCollisionWorld::LocalConvexResult &convexResult, bool normalInWorldSpace) {
- if (convexResult.m_localShapeInfo) {
- m_shapeId = convexResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is an odd name but contains the compound shape ID
+ // Triangle index is an odd name but contains the compound shape ID.
+ // A shape part of -1 indicates the index is a shape index and not a triangle index.
+ if (convexResult.m_localShapeInfo && convexResult.m_localShapeInfo->m_shapePart == -1) {
+ m_shapeId = convexResult.m_localShapeInfo->m_triangleIndex;
} else {
m_shapeId = 0;
}
+
return btCollisionWorld::ClosestConvexResultCallback::addSingleResult(convexResult, normalInWorldSpace);
}
@@ -219,10 +229,22 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con
CollisionObjectBullet *colObj;
if (m_self_object == colObj0Wrap->getCollisionObject()) {
colObj = static_cast<CollisionObjectBullet *>(colObj1Wrap->getCollisionObject()->getUserPointer());
- result.shape = cp.m_index1;
+ // Checking for compound shape because the index might be uninitialized otherwise.
+ // A partId of -1 indicates the index is a shape index and not a triangle index.
+ if (colObj1Wrap->getCollisionObject()->getCollisionShape()->isCompound() && cp.m_partId1 == -1) {
+ result.shape = cp.m_index1;
+ } else {
+ result.shape = 0;
+ }
} else {
colObj = static_cast<CollisionObjectBullet *>(colObj0Wrap->getCollisionObject()->getUserPointer());
- result.shape = cp.m_index0;
+ // Checking for compound shape because the index might be uninitialized otherwise.
+ // A partId of -1 indicates the index is a shape index and not a triangle index.
+ if (colObj0Wrap->getCollisionObject()->getCollisionShape()->isCompound() && cp.m_partId0 == -1) {
+ result.shape = cp.m_index0;
+ } else {
+ result.shape = 0;
+ }
}
result.collider_id = colObj->get_instance_id();
@@ -311,14 +333,26 @@ btScalar GodotRestInfoContactResultCallback::addSingleResult(btManifoldPoint &cp
CollisionObjectBullet *colObj;
if (m_self_object == colObj0Wrap->getCollisionObject()) {
colObj = static_cast<CollisionObjectBullet *>(colObj1Wrap->getCollisionObject()->getUserPointer());
- m_result->shape = cp.m_index1;
+ // Checking for compound shape because the index might be uninitialized otherwise.
+ // A partId of -1 indicates the index is a shape index and not a triangle index.
+ if (colObj1Wrap->getCollisionObject()->getCollisionShape()->isCompound() && cp.m_partId1 == -1) {
+ m_result->shape = cp.m_index1;
+ } else {
+ m_result->shape = 0;
+ }
B_TO_G(cp.getPositionWorldOnB(), m_result->point);
B_TO_G(cp.m_normalWorldOnB, m_result->normal);
m_rest_info_bt_point = cp.getPositionWorldOnB();
m_rest_info_collision_object = colObj1Wrap->getCollisionObject();
} else {
colObj = static_cast<CollisionObjectBullet *>(colObj0Wrap->getCollisionObject()->getUserPointer());
- m_result->shape = cp.m_index0;
+ // Checking for compound shape because the index might be uninitialized otherwise.
+ // A partId of -1 indicates the index is a shape index and not a triangle index.
+ if (colObj0Wrap->getCollisionObject()->getCollisionShape()->isCompound() && cp.m_partId0 == -1) {
+ m_result->shape = cp.m_index0;
+ } else {
+ m_result->shape = 0;
+ }
B_TO_G(cp.m_normalWorldOnB * -1, m_result->normal);
m_rest_info_bt_point = cp.getPositionWorldOnA();
m_rest_info_collision_object = colObj0Wrap->getCollisionObject();
diff --git a/modules/bullet/godot_result_callbacks.h b/modules/bullet/godot_result_callbacks.h
index 96a649d77a..3dfa21aec8 100644
--- a/modules/bullet/godot_result_callbacks.h
+++ b/modules/bullet/godot_result_callbacks.h
@@ -70,8 +70,10 @@ public:
virtual bool needsCollision(btBroadphaseProxy *proxy0) const;
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace) {
- if (rayResult.m_localShapeInfo) {
- m_shapeId = rayResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is a odd name but contains the compound shape ID
+ // Triangle index is an odd name but contains the compound shape ID.
+ // A shape part of -1 indicates the index is a shape index and not a triangle index.
+ if (rayResult.m_localShapeInfo && rayResult.m_localShapeInfo->m_shapePart == -1) {
+ m_shapeId = rayResult.m_localShapeInfo->m_triangleIndex;
} else {
m_shapeId = 0;
}
diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h
index 9d076a8e4c..e1ed71a268 100644
--- a/modules/gdscript/gdscript_function.h
+++ b/modules/gdscript/gdscript_function.h
@@ -192,7 +192,7 @@ public:
GDScriptDataType() = default;
- GDScriptDataType &operator=(const GDScriptDataType &p_other) {
+ void operator=(const GDScriptDataType &p_other) {
kind = p_other.kind;
has_type = p_other.has_type;
builtin_type = p_other.builtin_type;
@@ -203,7 +203,6 @@ public:
if (p_other.has_container_element_type()) {
set_container_element_type(p_other.get_container_element_type());
}
- return *this;
}
GDScriptDataType(const GDScriptDataType &p_other) {
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h
index af9b973ada..2f05b4b948 100644
--- a/modules/gdscript/gdscript_parser.h
+++ b/modules/gdscript/gdscript_parser.h
@@ -203,7 +203,7 @@ public:
return !(this->operator==(p_other));
}
- DataType &operator=(const DataType &p_other) {
+ void operator=(const DataType &p_other) {
kind = p_other.kind;
type_source = p_other.type_source;
is_constant = p_other.is_constant;
@@ -221,7 +221,6 @@ public:
if (p_other.has_container_element_type()) {
set_container_element_type(p_other.get_container_element_type());
}
- return *this;
}
DataType() = default;
diff --git a/modules/minimp3/audio_stream_mp3.cpp b/modules/minimp3/audio_stream_mp3.cpp
index 49e9f5f97e..a9c1f0bb9a 100644
--- a/modules/minimp3/audio_stream_mp3.cpp
+++ b/modules/minimp3/audio_stream_mp3.cpp
@@ -125,7 +125,7 @@ AudioStreamPlaybackMP3::~AudioStreamPlaybackMP3() {
Ref<AudioStreamPlayback> AudioStreamMP3::instance_playback() {
Ref<AudioStreamPlaybackMP3> mp3s;
- ERR_FAIL_COND_V_MSG(data == nullptr, mp3s,
+ ERR_FAIL_COND_V_MSG(data.is_empty(), mp3s,
"This AudioStreamMP3 does not have an audio file assigned "
"to it. AudioStreamMP3 should not be created from the "
"inspector or with `.new()`. Instead, load an audio file.");
@@ -134,7 +134,7 @@ Ref<AudioStreamPlayback> AudioStreamMP3::instance_playback() {
mp3s->mp3_stream = Ref<AudioStreamMP3>(this);
mp3s->mp3d = (mp3dec_ex_t *)memalloc(sizeof(mp3dec_ex_t));
- int errorcode = mp3dec_ex_open_buf(mp3s->mp3d, (const uint8_t *)data, data_len, MP3D_SEEK_TO_SAMPLE);
+ int errorcode = mp3dec_ex_open_buf(mp3s->mp3d, data.ptr(), data_len, MP3D_SEEK_TO_SAMPLE);
mp3s->frames_mixed = 0;
mp3s->active = false;
@@ -152,11 +152,7 @@ String AudioStreamMP3::get_stream_name() const {
}
void AudioStreamMP3::clear_data() {
- if (data) {
- memfree(data);
- data = nullptr;
- data_len = 0;
- }
+ data.clear();
}
void AudioStreamMP3::set_data(const Vector<uint8_t> &p_data) {
@@ -165,7 +161,7 @@ void AudioStreamMP3::set_data(const Vector<uint8_t> &p_data) {
mp3dec_ex_t mp3d;
int err = mp3dec_ex_open_buf(&mp3d, src_datar, src_data_len, MP3D_SEEK_TO_SAMPLE);
- ERR_FAIL_COND(err != 0);
+ ERR_FAIL_COND_MSG(err || mp3d.info.hz == 0, "Failed to decode mp3 file. Make sure it is a valid mp3 audio file.");
channels = mp3d.info.channels;
sample_rate = mp3d.info.hz;
@@ -175,23 +171,13 @@ void AudioStreamMP3::set_data(const Vector<uint8_t> &p_data) {
clear_data();
- data = memalloc(src_data_len);
- memcpy(data, src_datar, src_data_len);
+ data.resize(src_data_len);
+ memcpy(data.ptrw(), src_datar, src_data_len);
data_len = src_data_len;
}
Vector<uint8_t> AudioStreamMP3::get_data() const {
- Vector<uint8_t> vdata;
-
- if (data_len && data) {
- vdata.resize(data_len);
- {
- uint8_t *w = vdata.ptrw();
- memcpy(w, data, data_len);
- }
- }
-
- return vdata;
+ return data;
}
void AudioStreamMP3::set_loop(bool p_enable) {
diff --git a/modules/minimp3/audio_stream_mp3.h b/modules/minimp3/audio_stream_mp3.h
index 3c8bdd8c53..e3adfe683b 100644
--- a/modules/minimp3/audio_stream_mp3.h
+++ b/modules/minimp3/audio_stream_mp3.h
@@ -75,7 +75,7 @@ class AudioStreamMP3 : public AudioStream {
friend class AudioStreamPlaybackMP3;
- void *data = nullptr;
+ PackedByteArray data;
uint32_t data_len = 0;
float sample_rate = 1.0;
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h
index 51a27ee934..a7879e96c8 100644
--- a/modules/mono/editor/bindings_generator.h
+++ b/modules/mono/editor/bindings_generator.h
@@ -598,7 +598,7 @@ class BindingsGenerator {
private:
NameCache(const NameCache &);
- NameCache &operator=(const NameCache &);
+ void operator=(const NameCache &);
};
NameCache name_cache;
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
index 0c3331900a..30ecd22db7 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
@@ -184,13 +184,13 @@ namespace Godot
}
/// <summary>
- /// Returns the cross product of this vector and <paramref name="b"/>.
+ /// Returns the cross product of this vector and <paramref name="with"/>.
/// </summary>
- /// <param name="b">The other vector.</param>
+ /// <param name="with">The other vector.</param>
/// <returns>The cross product value.</returns>
- public real_t Cross(Vector2 b)
+ public real_t Cross(Vector2 with)
{
- return (x * b.y) - (y * b.x);
+ return (x * with.y) - (y * with.x);
}
/// <summary>
@@ -222,13 +222,13 @@ namespace Godot
}
/// <summary>
- /// Returns the normalized vector pointing from this vector to <paramref name="b"/>.
+ /// Returns the normalized vector pointing from this vector to <paramref name="to"/>.
/// </summary>
- /// <param name="b">The other vector to point towards.</param>
- /// <returns>The direction from this vector to <paramref name="b"/>.</returns>
- public Vector2 DirectionTo(Vector2 b)
+ /// <param name="to">The other vector to point towards.</param>
+ /// <returns>The direction from this vector to <paramref name="to"/>.</returns>
+ public Vector2 DirectionTo(Vector2 to)
{
- return new Vector2(b.x - x, b.y - y).Normalized();
+ return new Vector2(to.x - x, to.y - y).Normalized();
}
/// <summary>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs
index 6cac16d53b..3bbc2ae2ba 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs
@@ -149,45 +149,45 @@ namespace Godot
}
/// <summary>
- /// Returns the cross product of this vector and <paramref name="b"/>.
+ /// Returns the cross product of this vector and <paramref name="with"/>.
/// </summary>
- /// <param name="b">The other vector.</param>
+ /// <param name="with">The other vector.</param>
/// <returns>The cross product vector.</returns>
- public int Cross(Vector2i b)
+ public int Cross(Vector2i with)
{
- return x * b.y - y * b.x;
+ return x * with.y - y * with.x;
}
/// <summary>
- /// Returns the squared distance between this vector and <paramref name="b"/>.
+ /// Returns the squared distance between this vector and <paramref name="to"/>.
/// This method runs faster than <see cref="DistanceTo"/>, so prefer it if
/// you need to compare vectors or need the squared distance for some formula.
/// </summary>
- /// <param name="b">The other vector to use.</param>
+ /// <param name="to">The other vector to use.</param>
/// <returns>The squared distance between the two vectors.</returns>
- public int DistanceSquaredTo(Vector2i b)
+ public int DistanceSquaredTo(Vector2i to)
{
- return (b - this).LengthSquared();
+ return (to - this).LengthSquared();
}
/// <summary>
- /// Returns the distance between this vector and <paramref name="b"/>.
+ /// Returns the distance between this vector and <paramref name="to"/>.
/// </summary>
- /// <param name="b">The other vector to use.</param>
+ /// <param name="to">The other vector to use.</param>
/// <returns>The distance between the two vectors.</returns>
- public real_t DistanceTo(Vector2i b)
+ public real_t DistanceTo(Vector2i to)
{
- return (b - this).Length();
+ return (to - this).Length();
}
/// <summary>
- /// Returns the dot product of this vector and <paramref name="b"/>.
+ /// Returns the dot product of this vector and <paramref name="with"/>.
/// </summary>
- /// <param name="b">The other vector to use.</param>
+ /// <param name="with">The other vector to use.</param>
/// <returns>The dot product of the two vectors.</returns>
- public int Dot(Vector2i b)
+ public int Dot(Vector2i with)
{
- return x * b.x + y * b.y;
+ return x * with.x + y * with.y;
}
/// <summary>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
index 63d9be0a6d..15acf88f62 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
@@ -170,17 +170,17 @@ namespace Godot
}
/// <summary>
- /// Returns the cross product of this vector and <paramref name="b"/>.
+ /// Returns the cross product of this vector and <paramref name="with"/>.
/// </summary>
- /// <param name="b">The other vector.</param>
+ /// <param name="with">The other vector.</param>
/// <returns>The cross product vector.</returns>
- public Vector3 Cross(Vector3 b)
+ public Vector3 Cross(Vector3 with)
{
return new Vector3
(
- (y * b.z) - (z * b.y),
- (z * b.x) - (x * b.z),
- (x * b.y) - (y * b.x)
+ (y * with.z) - (z * with.y),
+ (z * with.x) - (x * with.z),
+ (x * with.y) - (y * with.x)
);
}
@@ -212,46 +212,46 @@ namespace Godot
}
/// <summary>
- /// Returns the normalized vector pointing from this vector to <paramref name="b"/>.
+ /// Returns the normalized vector pointing from this vector to <paramref name="to"/>.
/// </summary>
- /// <param name="b">The other vector to point towards.</param>
- /// <returns>The direction from this vector to <paramref name="b"/>.</returns>
- public Vector3 DirectionTo(Vector3 b)
+ /// <param name="to">The other vector to point towards.</param>
+ /// <returns>The direction from this vector to <paramref name="to"/>.</returns>
+ public Vector3 DirectionTo(Vector3 to)
{
- return new Vector3(b.x - x, b.y - y, b.z - z).Normalized();
+ return new Vector3(to.x - x, to.y - y, to.z - z).Normalized();
}
/// <summary>
- /// Returns the squared distance between this vector and <paramref name="b"/>.
+ /// Returns the squared distance between this vector and <paramref name="to"/>.
/// This method runs faster than <see cref="DistanceTo"/>, so prefer it if
/// you need to compare vectors or need the squared distance for some formula.
/// </summary>
- /// <param name="b">The other vector to use.</param>
+ /// <param name="to">The other vector to use.</param>
/// <returns>The squared distance between the two vectors.</returns>
- public real_t DistanceSquaredTo(Vector3 b)
+ public real_t DistanceSquaredTo(Vector3 to)
{
- return (b - this).LengthSquared();
+ return (to - this).LengthSquared();
}
/// <summary>
- /// Returns the distance between this vector and <paramref name="b"/>.
+ /// Returns the distance between this vector and <paramref name="to"/>.
/// </summary>
/// <seealso cref="DistanceSquaredTo(Vector3)"/>
- /// <param name="b">The other vector to use.</param>
+ /// <param name="to">The other vector to use.</param>
/// <returns>The distance between the two vectors.</returns>
- public real_t DistanceTo(Vector3 b)
+ public real_t DistanceTo(Vector3 to)
{
- return (b - this).Length();
+ return (to - this).Length();
}
/// <summary>
- /// Returns the dot product of this vector and <paramref name="b"/>.
+ /// Returns the dot product of this vector and <paramref name="with"/>.
/// </summary>
- /// <param name="b">The other vector to use.</param>
+ /// <param name="with">The other vector to use.</param>
/// <returns>The dot product of the two vectors.</returns>
- public real_t Dot(Vector3 b)
+ public real_t Dot(Vector3 with)
{
- return (x * b.x) + (y * b.y) + (z * b.z);
+ return (x * with.x) + (y * with.y) + (z * with.z);
}
/// <summary>
@@ -412,16 +412,16 @@ namespace Godot
}
/// <summary>
- /// Returns the outer product with <paramref name="b"/>.
+ /// Returns the outer product with <paramref name="with"/>.
/// </summary>
- /// <param name="b">The other vector.</param>
+ /// <param name="with">The other vector.</param>
/// <returns>A <see cref="Basis"/> representing the outer product matrix.</returns>
- public Basis Outer(Vector3 b)
+ public Basis Outer(Vector3 with)
{
return new Basis(
- x * b.x, x * b.y, x * b.z,
- y * b.x, y * b.y, y * b.z,
- z * b.x, z * b.y, z * b.z
+ x * with.x, x * with.y, x * with.z,
+ y * with.x, y * with.y, y * with.z,
+ z * with.x, z * with.y, z * with.z
);
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs
index 474876fc91..562f653fa8 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs
@@ -124,36 +124,36 @@ namespace Godot
}
/// <summary>
- /// Returns the squared distance between this vector and <paramref name="b"/>.
+ /// Returns the squared distance between this vector and <paramref name="to"/>.
/// This method runs faster than <see cref="DistanceTo"/>, so prefer it if
/// you need to compare vectors or need the squared distance for some formula.
/// </summary>
- /// <param name="b">The other vector to use.</param>
+ /// <param name="to">The other vector to use.</param>
/// <returns>The squared distance between the two vectors.</returns>
- public int DistanceSquaredTo(Vector3i b)
+ public int DistanceSquaredTo(Vector3i to)
{
- return (b - this).LengthSquared();
+ return (to - this).LengthSquared();
}
/// <summary>
- /// Returns the distance between this vector and <paramref name="b"/>.
+ /// Returns the distance between this vector and <paramref name="to"/>.
/// </summary>
/// <seealso cref="DistanceSquaredTo(Vector3i)"/>
- /// <param name="b">The other vector to use.</param>
+ /// <param name="to">The other vector to use.</param>
/// <returns>The distance between the two vectors.</returns>
- public real_t DistanceTo(Vector3i b)
+ public real_t DistanceTo(Vector3i to)
{
- return (b - this).Length();
+ return (to - this).Length();
}
/// <summary>
- /// Returns the dot product of this vector and <paramref name="b"/>.
+ /// Returns the dot product of this vector and <paramref name="with"/>.
/// </summary>
- /// <param name="b">The other vector to use.</param>
+ /// <param name="with">The other vector to use.</param>
/// <returns>The dot product of the two vectors.</returns>
- public int Dot(Vector3i b)
+ public int Dot(Vector3i with)
{
- return x * b.x + y * b.y + z * b.z;
+ return x * with.x + y * with.y + z * with.z;
}
/// <summary>
diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp
index 24bd1ed492..2b4cc7fcc3 100644
--- a/modules/mono/godotsharp_dirs.cpp
+++ b/modules/mono/godotsharp_dirs.cpp
@@ -229,9 +229,6 @@ private:
#endif
}
- _GodotSharpDirs(const _GodotSharpDirs &);
- _GodotSharpDirs &operator=(const _GodotSharpDirs &);
-
public:
static _GodotSharpDirs &get_singleton() {
static _GodotSharpDirs singleton;
diff --git a/modules/mono/mono_gc_handle.h b/modules/mono/mono_gc_handle.h
index d0e51d159f..a18a4ce646 100644
--- a/modules/mono/mono_gc_handle.h
+++ b/modules/mono/mono_gc_handle.h
@@ -56,13 +56,12 @@ struct MonoGCHandleData {
void release();
- MonoGCHandleData &operator=(const MonoGCHandleData &p_other) {
+ void operator=(const MonoGCHandleData &p_other) {
#ifdef DEBUG_ENABLED
CRASH_COND(!is_released());
#endif
handle = p_other.handle;
type = p_other.type;
- return *this;
}
MonoGCHandleData(const MonoGCHandleData &) = default;
diff --git a/modules/mono/mono_gd/gd_mono_log.cpp b/modules/mono/mono_gd/gd_mono_log.cpp
index 179bbfb40c..bcdcd6623b 100644
--- a/modules/mono/mono_gd/gd_mono_log.cpp
+++ b/modules/mono/mono_gd/gd_mono_log.cpp
@@ -121,12 +121,10 @@ void GDMonoLog::_delete_old_log_files(const String &p_logs_dir) {
ERR_FAIL_COND(da->list_dir_begin() != OK);
- String current;
- while ((current = da->get_next()).length()) {
- if (da->current_is_dir()) {
- continue;
- }
- if (!current.ends_with(".txt")) {
+ String current = da->get_next();
+ while (!current.is_empty()) {
+ if (da->current_is_dir() || !current.ends_with(".txt")) {
+ current = da->get_next();
continue;
}
@@ -135,6 +133,7 @@ void GDMonoLog::_delete_old_log_files(const String &p_logs_dir) {
if (OS::get_singleton()->get_unix_time() - modified_time > MAX_SECS) {
da->remove(current);
}
+ current = da->get_next();
}
da->list_dir_end();
diff --git a/modules/navigation/navigation_mesh_generator.cpp b/modules/navigation/navigation_mesh_generator.cpp
index 05e040b518..0bce0fc9f0 100644
--- a/modules/navigation/navigation_mesh_generator.cpp
+++ b/modules/navigation/navigation_mesh_generator.cpp
@@ -36,6 +36,7 @@
#include "core/os/thread.h"
#include "scene/3d/collision_shape_3d.h"
#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/multimesh_instance_3d.h"
#include "scene/3d/physics_body_3d.h"
#include "scene/resources/box_shape_3d.h"
#include "scene/resources/capsule_shape_3d.h"
@@ -63,17 +64,17 @@
NavigationMeshGenerator *NavigationMeshGenerator::singleton = nullptr;
-void NavigationMeshGenerator::_add_vertex(const Vector3 &p_vec3, Vector<float> &p_verticies) {
- p_verticies.push_back(p_vec3.x);
- p_verticies.push_back(p_vec3.y);
- p_verticies.push_back(p_vec3.z);
+void NavigationMeshGenerator::_add_vertex(const Vector3 &p_vec3, Vector<float> &p_vertices) {
+ p_vertices.push_back(p_vec3.x);
+ p_vertices.push_back(p_vec3.y);
+ p_vertices.push_back(p_vec3.z);
}
-void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform3D &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices) {
+void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform3D &p_xform, Vector<float> &p_vertices, Vector<int> &p_indices) {
int current_vertex_count;
for (int i = 0; i < p_mesh->get_surface_count(); i++) {
- current_vertex_count = p_verticies.size() / 3;
+ current_vertex_count = p_vertices.size() / 3;
if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) {
continue;
@@ -100,7 +101,7 @@ void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform
const int *ir = mesh_indices.ptr();
for (int j = 0; j < mesh_vertices.size(); j++) {
- _add_vertex(p_xform.xform(vr[j]), p_verticies);
+ _add_vertex(p_xform.xform(vr[j]), p_vertices);
}
for (int j = 0; j < face_count; j++) {
@@ -112,9 +113,9 @@ void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform
} else {
face_count = mesh_vertices.size() / 3;
for (int j = 0; j < face_count; j++) {
- _add_vertex(p_xform.xform(vr[j * 3 + 0]), p_verticies);
- _add_vertex(p_xform.xform(vr[j * 3 + 2]), p_verticies);
- _add_vertex(p_xform.xform(vr[j * 3 + 1]), p_verticies);
+ _add_vertex(p_xform.xform(vr[j * 3 + 0]), p_vertices);
+ _add_vertex(p_xform.xform(vr[j * 3 + 2]), p_vertices);
+ _add_vertex(p_xform.xform(vr[j * 3 + 1]), p_vertices);
p_indices.push_back(current_vertex_count + (j * 3 + 0));
p_indices.push_back(current_vertex_count + (j * 3 + 1));
@@ -124,14 +125,14 @@ void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform
}
}
-void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices) {
+void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform, Vector<float> &p_vertices, Vector<int> &p_indices) {
int face_count = p_faces.size() / 3;
- int current_vertex_count = p_verticies.size() / 3;
+ int current_vertex_count = p_vertices.size() / 3;
for (int j = 0; j < face_count; j++) {
- _add_vertex(p_xform.xform(p_faces[j * 3 + 0]), p_verticies);
- _add_vertex(p_xform.xform(p_faces[j * 3 + 1]), p_verticies);
- _add_vertex(p_xform.xform(p_faces[j * 3 + 2]), p_verticies);
+ _add_vertex(p_xform.xform(p_faces[j * 3 + 0]), p_vertices);
+ _add_vertex(p_xform.xform(p_faces[j * 3 + 1]), p_vertices);
+ _add_vertex(p_xform.xform(p_faces[j * 3 + 2]), p_vertices);
p_indices.push_back(current_vertex_count + (j * 3 + 0));
p_indices.push_back(current_vertex_count + (j * 3 + 2));
@@ -139,12 +140,27 @@ void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, cons
}
}
-void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, NavigationMesh::ParsedGeometryType p_generate_from, uint32_t p_collision_mask, bool p_recurse_children) {
+void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transform, Node *p_node, Vector<float> &p_vertices, Vector<int> &p_indices, NavigationMesh::ParsedGeometryType p_generate_from, uint32_t p_collision_mask, bool p_recurse_children) {
if (Object::cast_to<MeshInstance3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(p_node);
Ref<Mesh> mesh = mesh_instance->get_mesh();
if (mesh.is_valid()) {
- _add_mesh(mesh, p_accumulated_transform * mesh_instance->get_transform(), p_verticies, p_indices);
+ _add_mesh(mesh, p_accumulated_transform * mesh_instance->get_transform(), p_vertices, p_indices);
+ }
+ }
+
+ if (Object::cast_to<MultiMeshInstance3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
+ MultiMeshInstance3D *multimesh_instance = Object::cast_to<MultiMeshInstance3D>(p_node);
+ Ref<MultiMesh> multimesh = multimesh_instance->get_multimesh();
+ Ref<Mesh> mesh = multimesh->get_mesh();
+ if (mesh.is_valid()) {
+ int n = multimesh->get_visible_instance_count();
+ if (n == -1) {
+ n = multimesh->get_instance_count();
+ }
+ for (int i = 0; i < n; i++) {
+ _add_mesh(mesh, p_accumulated_transform * multimesh->get_instance_transform(i), p_vertices, p_indices);
+ }
}
}
@@ -155,7 +171,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
if (!meshes.is_empty()) {
Ref<Mesh> mesh = meshes[1];
if (mesh.is_valid()) {
- _add_mesh(mesh, p_accumulated_transform * csg_shape->get_transform(), p_verticies, p_indices);
+ _add_mesh(mesh, p_accumulated_transform * csg_shape->get_transform(), p_vertices, p_indices);
}
}
}
@@ -213,7 +229,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
ConcavePolygonShape3D *concave_polygon = Object::cast_to<ConcavePolygonShape3D>(*s);
if (concave_polygon) {
- _add_faces(concave_polygon->get_faces(), transform, p_verticies, p_indices);
+ _add_faces(concave_polygon->get_faces(), transform, p_vertices, p_indices);
}
ConvexPolygonShape3D *convex_polygon = Object::cast_to<ConvexPolygonShape3D>(*s);
@@ -236,12 +252,12 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
}
}
- _add_faces(faces, transform, p_verticies, p_indices);
+ _add_faces(faces, transform, p_vertices, p_indices);
}
}
if (mesh.is_valid()) {
- _add_mesh(mesh, transform, p_verticies, p_indices);
+ _add_mesh(mesh, transform, p_vertices, p_indices);
}
}
}
@@ -256,7 +272,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
for (int i = 0; i < meshes.size(); i += 2) {
Ref<Mesh> mesh = meshes[i + 1];
if (mesh.is_valid()) {
- _add_mesh(mesh, p_accumulated_transform * xform * (Transform3D)meshes[i], p_verticies, p_indices);
+ _add_mesh(mesh, p_accumulated_transform * xform * (Transform3D)meshes[i], p_vertices, p_indices);
}
}
}
@@ -269,7 +285,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
if (p_recurse_children) {
for (int i = 0; i < p_node->get_child_count(); i++) {
- _parse_geometry(p_accumulated_transform, p_node->get_child(i), p_verticies, p_indices, p_generate_from, p_collision_mask, p_recurse_children);
+ _parse_geometry(p_accumulated_transform, p_node->get_child(i), p_vertices, p_indices, p_generate_from, p_collision_mask, p_recurse_children);
}
}
}
diff --git a/modules/navigation/navigation_mesh_generator.h b/modules/navigation/navigation_mesh_generator.h
index 78f1329e3f..dac844c68e 100644
--- a/modules/navigation/navigation_mesh_generator.h
+++ b/modules/navigation/navigation_mesh_generator.h
@@ -49,10 +49,10 @@ class NavigationMeshGenerator : public Object {
protected:
static void _bind_methods();
- static void _add_vertex(const Vector3 &p_vec3, Vector<float> &p_verticies);
- static void _add_mesh(const Ref<Mesh> &p_mesh, const Transform3D &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices);
- static void _add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices);
- static void _parse_geometry(Transform3D p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, NavigationMesh::ParsedGeometryType p_generate_from, uint32_t p_collision_mask, bool p_recurse_children);
+ static void _add_vertex(const Vector3 &p_vec3, Vector<float> &p_vertices);
+ static void _add_mesh(const Ref<Mesh> &p_mesh, const Transform3D &p_xform, Vector<float> &p_vertices, Vector<int> &p_indices);
+ static void _add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform, Vector<float> &p_vertices, Vector<int> &p_indices);
+ static void _parse_geometry(Transform3D p_accumulated_transform, Node *p_node, Vector<float> &p_vertices, Vector<int> &p_indices, NavigationMesh::ParsedGeometryType p_generate_from, uint32_t p_collision_mask, bool p_recurse_children);
static void _convert_detail_mesh_to_native_navigation_mesh(const rcPolyMeshDetail *p_detail_mesh, Ref<NavigationMesh> p_nav_mesh);
static void _build_recast_navigation_mesh(