Enable setting of collision iterations in PhysicsServer2D
This allows fine-tuning of collision iterations for more accurate collision physics with a performance cost.
This commit is contained in:
parent
c340ed6394
commit
88b1802132
@ -1018,6 +1018,15 @@
|
|||||||
Activates or deactivates the 2D physics engine.
|
Activates or deactivates the 2D physics engine.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</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">
|
<method name="shape_get_data" qualifiers="const">
|
||||||
<return type="Variant">
|
<return type="Variant">
|
||||||
</return>
|
</return>
|
||||||
|
@ -1237,6 +1237,10 @@ void PhysicsServer2DSW::set_active(bool p_active) {
|
|||||||
active = p_active;
|
active = p_active;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void PhysicsServer2DSW::set_collision_iterations(int p_iterations) {
|
||||||
|
iterations = p_iterations;
|
||||||
|
};
|
||||||
|
|
||||||
void PhysicsServer2DSW::init() {
|
void PhysicsServer2DSW::init() {
|
||||||
doing_sync = false;
|
doing_sync = false;
|
||||||
last_step = 0.001;
|
last_step = 0.001;
|
||||||
|
@ -288,6 +288,8 @@ public:
|
|||||||
virtual void end_sync() override;
|
virtual void end_sync() override;
|
||||||
virtual void finish() override;
|
virtual void finish() override;
|
||||||
|
|
||||||
|
virtual void set_collision_iterations(int p_iterations) override;
|
||||||
|
|
||||||
virtual bool is_flushing_queries() const override { return flushing_queries; }
|
virtual bool is_flushing_queries() const override { return flushing_queries; }
|
||||||
|
|
||||||
int get_process_info(ProcessInfo p_info) override;
|
int get_process_info(ProcessInfo p_info) override;
|
||||||
|
@ -303,6 +303,7 @@ public:
|
|||||||
|
|
||||||
FUNC1(free, RID);
|
FUNC1(free, RID);
|
||||||
FUNC1(set_active, bool);
|
FUNC1(set_active, bool);
|
||||||
|
FUNC1(set_collision_iterations, int);
|
||||||
|
|
||||||
virtual void init() override;
|
virtual void init() override;
|
||||||
virtual void step(real_t p_step) override;
|
virtual void step(real_t p_step) override;
|
||||||
|
@ -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_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);
|
ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer2D::get_process_info);
|
||||||
|
|
||||||
BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS);
|
BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS);
|
||||||
|
@ -589,6 +589,8 @@ public:
|
|||||||
|
|
||||||
virtual bool is_flushing_queries() const = 0;
|
virtual bool is_flushing_queries() const = 0;
|
||||||
|
|
||||||
|
virtual void set_collision_iterations(int iterations) = 0;
|
||||||
|
|
||||||
enum ProcessInfo {
|
enum ProcessInfo {
|
||||||
INFO_ACTIVE_OBJECTS,
|
INFO_ACTIVE_OBJECTS,
|
||||||
INFO_COLLISION_PAIRS,
|
INFO_COLLISION_PAIRS,
|
||||||
|
Loading…
Reference in New Issue
Block a user