Enable setting of collision iterations in Physics2DServer

This allows fine-tuning of collision iterations for more
accurate collision physics with a performance cost.
This commit is contained in:
Rhathe 2020-05-01 03:33:00 -04:00
parent 78f0cf40cb
commit 768f4e684c
6 changed files with 20 additions and 0 deletions

View File

@ -1002,6 +1002,15 @@
Activates or deactivates the 2D physics engine.
</description>
</method>
<method name="set_collision_iterations">
<return type="void">
</return>
<argument index="0" name="iterations" type="int">
</argument>
<description>
Sets the amount of iterations for calculating velocities of colliding bodies. The greater the amount, the more accurate the collisions, but with a performance loss.
</description>
</method>
<method name="shape_get_data" qualifiers="const">
<return type="Variant">
</return>

View File

@ -1315,6 +1315,10 @@ void Physics2DServerSW::set_active(bool p_active) {
active = p_active;
};
void Physics2DServerSW::set_collision_iterations(int p_iterations) {
iterations = p_iterations;
};
void Physics2DServerSW::init() {
doing_sync = false;

View File

@ -284,6 +284,8 @@ public:
virtual void end_sync();
virtual void finish();
virtual void set_collision_iterations(int p_iterations);
virtual bool is_flushing_queries() const { return flushing_queries; }
int get_process_info(ProcessInfo p_info);

View File

@ -304,6 +304,7 @@ public:
FUNC1(free, RID);
FUNC1(set_active, bool);
FUNC1(set_collision_iterations, int);
virtual void init();
virtual void step(real_t p_step);

View File

@ -684,6 +684,8 @@ void Physics2DServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_active", "active"), &Physics2DServer::set_active);
ClassDB::bind_method(D_METHOD("set_collision_iterations", "iterations"), &Physics2DServer::set_collision_iterations);
ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &Physics2DServer::get_process_info);
BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS);

View File

@ -593,6 +593,8 @@ public:
virtual bool is_flushing_queries() const = 0;
virtual void set_collision_iterations(int iterations) = 0;
enum ProcessInfo {
INFO_ACTIVE_OBJECTS,