You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Place a hard limit on the max_contacts_reported property
This commit is contained in:
@@ -181,6 +181,7 @@ public:
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void set_max_contacts_reported(int p_size) {
|
||||
ERR_FAIL_INDEX(p_size, MAX_CONTACTS_REPORTED_2D_MAX);
|
||||
contacts.resize(p_size);
|
||||
contact_count = 0;
|
||||
if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC && p_size) {
|
||||
|
||||
@@ -175,6 +175,7 @@ public:
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void set_max_contacts_reported(int p_size) {
|
||||
ERR_FAIL_INDEX(p_size, MAX_CONTACTS_REPORTED_3D_MAX);
|
||||
contacts.resize(p_size);
|
||||
contact_count = 0;
|
||||
if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC && p_size) {
|
||||
|
||||
@@ -881,7 +881,7 @@ void JoltBody3D::set_center_of_mass_custom(const Vector3 &p_center_of_mass) {
|
||||
}
|
||||
|
||||
void JoltBody3D::set_max_contacts_reported(int p_count) {
|
||||
ERR_FAIL_COND(p_count < 0);
|
||||
ERR_FAIL_INDEX(p_count, MAX_CONTACTS_REPORTED_3D_MAX);
|
||||
|
||||
if (unlikely((int)contacts.size() == p_count)) {
|
||||
return;
|
||||
|
||||
@@ -498,6 +498,7 @@ bool RigidBody2D::is_sleeping() const {
|
||||
}
|
||||
|
||||
void RigidBody2D::set_max_contacts_reported(int p_amount) {
|
||||
ERR_FAIL_INDEX_MSG(p_amount, MAX_CONTACTS_REPORTED_2D_MAX, "Max contacts reported allocates memory (about 100 bytes each), and therefore must not be set too high.");
|
||||
max_contacts_reported = p_amount;
|
||||
PhysicsServer2D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
|
||||
}
|
||||
|
||||
@@ -521,6 +521,7 @@ bool RigidBody3D::is_sleeping() const {
|
||||
}
|
||||
|
||||
void RigidBody3D::set_max_contacts_reported(int p_amount) {
|
||||
ERR_FAIL_INDEX_MSG(p_amount, MAX_CONTACTS_REPORTED_3D_MAX, "Max contacts reported allocates memory (about 80 bytes each), and therefore must not be set too high.");
|
||||
max_contacts_reported = p_amount;
|
||||
PhysicsServer3D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include "core/object/class_db.h"
|
||||
#include "core/object/ref_counted.h"
|
||||
|
||||
constexpr int MAX_CONTACTS_REPORTED_2D_MAX = 4096;
|
||||
|
||||
class PhysicsDirectSpaceState2D;
|
||||
template <typename T>
|
||||
class TypedArray;
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include "core/io/resource.h"
|
||||
#include "core/object/gdvirtual.gen.inc"
|
||||
|
||||
constexpr int MAX_CONTACTS_REPORTED_3D_MAX = 4096;
|
||||
|
||||
class PhysicsDirectSpaceState3D;
|
||||
template <typename T>
|
||||
class TypedArray;
|
||||
|
||||
Reference in New Issue
Block a user