Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to check if a physics server is enabled #90412

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions doc/classes/PhysicsServer2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -893,13 +893,6 @@
Creates a 2D separation ray shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the shape's [code]length[/code] and [code]slide_on_slope[/code] properties.
</description>
</method>
<method name="set_active">
<return type="void" />
<param index="0" name="active" type="bool" />
<description>
Activates or deactivates the 2D physics server. If [param active] is [code]false[/code], then the physics server will not do anything in its physics step.
</description>
</method>
<method name="shape_get_data" qualifiers="const">
<return type="Variant" />
<param index="0" name="shape" type="RID" />
Expand Down Expand Up @@ -983,6 +976,11 @@
</description>
</method>
</methods>
<members>
<member name="active" type="bool" setter="set_active" getter="is_active">
If [code]true[/code], the server can be accessed and will update on each physics frame.
</member>
</members>
<constants>
<constant name="SPACE_PARAM_CONTACT_RECYCLE_RADIUS" value="0" enum="SpaceParameter">
Constant to set/get the maximum distance a pair of bodies has to move before their collision status has to be recalculated. The default value of this parameter is [member ProjectSettings.physics/2d/solver/contact_recycle_radius].
Expand Down
6 changes: 6 additions & 0 deletions doc/classes/PhysicsServer2DExtension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,12 @@
Overridable version of [PhysicsServer2D]'s internal [code]init[/code] method.
</description>
</method>
<method name="_is_active" qualifiers="virtual const">
<return type="bool" />
<description>
Overridable version of [method PhysicsServer2D.is_active].
</description>
</method>
<method name="_is_flushing_queries" qualifiers="virtual const">
<return type="bool" />
<description>
Expand Down
12 changes: 5 additions & 7 deletions doc/classes/PhysicsServer3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -973,13 +973,6 @@
<description>
</description>
</method>
<method name="set_active">
<return type="void" />
<param index="0" name="active" type="bool" />
<description>
Activates or deactivates the 3D physics engine.
</description>
</method>
<method name="shape_get_data" qualifiers="const">
<return type="Variant" />
<param index="0" name="shape" type="RID" />
Expand Down Expand Up @@ -1333,6 +1326,11 @@
</description>
</method>
</methods>
<members>
<member name="active" type="bool" setter="set_active" getter="is_active">
If [code]true[/code], the server can be accessed and will update on each physics frame.
</member>
</members>
<constants>
<constant name="JOINT_TYPE_PIN" value="0" enum="JointType">
The [Joint3D] is a [PinJoint3D].
Expand Down
5 changes: 5 additions & 0 deletions doc/classes/PhysicsServer3DExtension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,11 @@
<description>
</description>
</method>
<method name="_is_active" qualifiers="virtual const">
<return type="bool" />
<description>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<description>
<description>
Overridable version of [method PhysicsServer3D.is_active].

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some way that I can amend the commit with this change? The docs say that PRs should usually use just one commit...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just use git commit --amend and then push with git push -f

</description>
</method>
<method name="_is_flushing_queries" qualifiers="virtual const">
<return type="bool" />
<description>
Expand Down
1 change: 1 addition & 0 deletions servers/extensions/physics_server_2d_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ void PhysicsServer2DExtension::_bind_methods() {
GDVIRTUAL_BIND(_end_sync);
GDVIRTUAL_BIND(_finish);

GDVIRTUAL_BIND(_is_active);
GDVIRTUAL_BIND(_is_flushing_queries);
GDVIRTUAL_BIND(_get_process_info, "process_info");
}
Expand Down
1 change: 1 addition & 0 deletions servers/extensions/physics_server_2d_extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ class PhysicsServer2DExtension : public PhysicsServer2D {
EXBIND0(end_sync)
EXBIND0(finish)

EXBIND0RC(bool, is_active)
EXBIND0RC(bool, is_flushing_queries)
EXBIND1R(int, get_process_info, ProcessInfo)

Expand Down
1 change: 1 addition & 0 deletions servers/extensions/physics_server_3d_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ void PhysicsServer3DExtension::_bind_methods() {
GDVIRTUAL_BIND(_end_sync);
GDVIRTUAL_BIND(_finish);

GDVIRTUAL_BIND(_is_active);
GDVIRTUAL_BIND(_is_flushing_queries);
GDVIRTUAL_BIND(_get_process_info, "process_info");
}
Expand Down
1 change: 1 addition & 0 deletions servers/extensions/physics_server_3d_extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ class PhysicsServer3DExtension : public PhysicsServer3D {
EXBIND0(end_sync)
EXBIND0(finish)

EXBIND0RC(bool, is_active)
EXBIND0RC(bool, is_flushing_queries)
EXBIND1R(int, get_process_info, ProcessInfo)

Expand Down
1 change: 1 addition & 0 deletions servers/physics_2d/godot_physics_server_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ class GodotPhysicsServer2D : public PhysicsServer2D {
virtual void end_sync() override;
virtual void finish() override;

virtual bool is_active() const override { return active; }
virtual bool is_flushing_queries() const override { return flushing_queries; }

int get_process_info(ProcessInfo p_info) override;
Expand Down
1 change: 1 addition & 0 deletions servers/physics_3d/godot_physics_server_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ class GodotPhysicsServer3D : public PhysicsServer3D {
virtual void end_sync() override;
virtual void finish() override;

virtual bool is_active() const override { return active; }
virtual bool is_flushing_queries() const override { return flushing_queries; }

int get_process_info(ProcessInfo p_info) override;
Expand Down
3 changes: 3 additions & 0 deletions servers/physics_server_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,12 @@ void PhysicsServer2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("free_rid", "rid"), &PhysicsServer2D::free);

ClassDB::bind_method(D_METHOD("set_active", "active"), &PhysicsServer2D::set_active);
ClassDB::bind_method(D_METHOD("is_active"), &PhysicsServer2D::is_active);

ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer2D::get_process_info);

ADD_PROPERTY(PropertyInfo(Variant::BOOL, "active"), "set_active", "is_active");

BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS);
BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_MAX_SEPARATION);
BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION);
Expand Down
1 change: 1 addition & 0 deletions servers/physics_server_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ class PhysicsServer2D : public Object {
virtual void end_sync() = 0;
virtual void finish() = 0;

virtual bool is_active() const = 0;
virtual bool is_flushing_queries() const = 0;

enum ProcessInfo {
Expand Down
4 changes: 4 additions & 0 deletions servers/physics_server_2d_wrap_mt.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ class PhysicsServer2DWrapMT : public PhysicsServer2D {
virtual void flush_queries() override;
virtual void finish() override;

virtual bool is_active() const override {
return physics_server_2d->is_active();
}

virtual bool is_flushing_queries() const override {
return physics_server_2d->is_flushing_queries();
}
Expand Down
3 changes: 3 additions & 0 deletions servers/physics_server_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,9 +1029,12 @@ void PhysicsServer3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("free_rid", "rid"), &PhysicsServer3D::free);

ClassDB::bind_method(D_METHOD("set_active", "active"), &PhysicsServer3D::set_active);
ClassDB::bind_method(D_METHOD("is_active"), &PhysicsServer3D::is_active);

ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer3D::get_process_info);

ADD_PROPERTY(PropertyInfo(Variant::BOOL, "active"), "set_active", "is_active");

BIND_ENUM_CONSTANT(SHAPE_WORLD_BOUNDARY);
BIND_ENUM_CONSTANT(SHAPE_SEPARATION_RAY);
BIND_ENUM_CONSTANT(SHAPE_SPHERE);
Expand Down
1 change: 1 addition & 0 deletions servers/physics_server_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ class PhysicsServer3D : public Object {
virtual void end_sync() = 0;
virtual void finish() = 0;

virtual bool is_active() const = 0;
virtual bool is_flushing_queries() const = 0;

enum ProcessInfo {
Expand Down
4 changes: 4 additions & 0 deletions servers/physics_server_3d_wrap_mt.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ class PhysicsServer3DWrapMT : public PhysicsServer3D {
virtual void flush_queries() override;
virtual void finish() override;

virtual bool is_active() const override {
return physics_server_3d->is_active();
}

virtual bool is_flushing_queries() const override {
return physics_server_3d->is_flushing_queries();
}
Expand Down
Loading