summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorRhathe <rassinator@gmail.com>2021-05-19 02:19:58 -0400
committerRhathe <rassinator@gmail.com>2021-05-19 10:54:10 -0400
commit88b1802132eef6f16b88f841a9886dbb293cbebc (patch)
tree88c9b44f93ab599f9f7d68aedcd81b16dd95b7ce /servers
parentc340ed63943aa7c02064e536ff302de300a02ec2 (diff)
Enable setting of collision iterations in PhysicsServer2D
This allows fine-tuning of collision iterations for more accurate collision physics with a performance cost.
Diffstat (limited to 'servers')
-rw-r--r--servers/physics_2d/physics_server_2d_sw.cpp4
-rw-r--r--servers/physics_2d/physics_server_2d_sw.h2
-rw-r--r--servers/physics_2d/physics_server_2d_wrap_mt.h1
-rw-r--r--servers/physics_server_2d.cpp2
-rw-r--r--servers/physics_server_2d.h2
5 files changed, 11 insertions, 0 deletions
diff --git a/servers/physics_2d/physics_server_2d_sw.cpp b/servers/physics_2d/physics_server_2d_sw.cpp
index 425546e5ca..1c2dca0259 100644
--- a/servers/physics_2d/physics_server_2d_sw.cpp
+++ b/servers/physics_2d/physics_server_2d_sw.cpp
@@ -1237,6 +1237,10 @@ void PhysicsServer2DSW::set_active(bool p_active) {
active = p_active;
};
+void PhysicsServer2DSW::set_collision_iterations(int p_iterations) {
+ iterations = p_iterations;
+};
+
void PhysicsServer2DSW::init() {
doing_sync = false;
last_step = 0.001;
diff --git a/servers/physics_2d/physics_server_2d_sw.h b/servers/physics_2d/physics_server_2d_sw.h
index efa0784245..f1eb78a776 100644
--- a/servers/physics_2d/physics_server_2d_sw.h
+++ b/servers/physics_2d/physics_server_2d_sw.h
@@ -288,6 +288,8 @@ public:
virtual void end_sync() override;
virtual void finish() override;
+ virtual void set_collision_iterations(int p_iterations) override;
+
virtual bool is_flushing_queries() const override { return flushing_queries; }
int get_process_info(ProcessInfo p_info) override;
diff --git a/servers/physics_2d/physics_server_2d_wrap_mt.h b/servers/physics_2d/physics_server_2d_wrap_mt.h
index 88ac742e40..c776641699 100644
--- a/servers/physics_2d/physics_server_2d_wrap_mt.h
+++ b/servers/physics_2d/physics_server_2d_wrap_mt.h
@@ -303,6 +303,7 @@ public:
FUNC1(free, RID);
FUNC1(set_active, bool);
+ FUNC1(set_collision_iterations, int);
virtual void init() override;
virtual void step(real_t p_step) override;
diff --git a/servers/physics_server_2d.cpp b/servers/physics_server_2d.cpp
index 384179f2c3..7c5761cc61 100644
--- a/servers/physics_server_2d.cpp
+++ b/servers/physics_server_2d.cpp
@@ -675,6 +675,8 @@ void PhysicsServer2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_active", "active"), &PhysicsServer2D::set_active);
+ ClassDB::bind_method(D_METHOD("set_collision_iterations", "iterations"), &PhysicsServer2D::set_collision_iterations);
+
ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer2D::get_process_info);
BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS);
diff --git a/servers/physics_server_2d.h b/servers/physics_server_2d.h
index a5cf3f3a46..f2836961f2 100644
--- a/servers/physics_server_2d.h
+++ b/servers/physics_server_2d.h
@@ -589,6 +589,8 @@ public:
virtual bool is_flushing_queries() const = 0;
+ virtual void set_collision_iterations(int iterations) = 0;
+
enum ProcessInfo {
INFO_ACTIVE_OBJECTS,
INFO_COLLISION_PAIRS,