Fix Viewport.own_world documentation

Also fixed the naming of the setter's parameter and made an `if` block
straightforward.
This commit is contained in:
Haoyu Qiu 2022-06-06 21:34:36 +08:00 committed by Relintai
parent 9a35bce6cb
commit 8002080311
3 changed files with 10 additions and 10 deletions

View File

@ -240,7 +240,7 @@
The multisample anti-aliasing mode. A higher number results in smoother edges at the cost of significantly worse performance. A value of 4 is best unless targeting very high-end systems.
</member>
<member name="own_world" type="bool" setter="set_use_own_world" getter="is_using_own_world" default="false">
If [code]true[/code], the viewport will use [World] defined in [code]world[/code] property.
If [code]true[/code], the viewport will use a unique copy of the [World] defined in [member world].
</member>
<member name="physics_object_picking" type="bool" setter="set_physics_object_picking" getter="get_physics_object_picking" default="false">
If [code]true[/code], the objects rendered by viewport become subjects of mouse picking process.

View File

@ -2888,8 +2888,8 @@ void Viewport::unhandled_input(const Ref<InputEvent> &p_event) {
}
}
void Viewport::set_use_own_world(bool p_world) {
if (p_world == own_world.is_valid()) {
void Viewport::set_use_own_world(bool p_use_own_world) {
if (p_use_own_world == own_world.is_valid()) {
return;
}
@ -2897,18 +2897,18 @@ void Viewport::set_use_own_world(bool p_world) {
_propagate_exit_world(this);
}
if (!p_world) {
own_world = Ref<World>();
if (world.is_valid()) {
world->disconnect(CoreStringNames::get_singleton()->changed, this, "_own_world_changed");
}
} else {
if (p_use_own_world) {
if (world.is_valid()) {
own_world = world->duplicate();
world->connect(CoreStringNames::get_singleton()->changed, this, "_own_world_changed");
} else {
own_world = Ref<World>(memnew(World));
}
} else {
own_world = Ref<World>();
if (world.is_valid()) {
world->disconnect(CoreStringNames::get_singleton()->changed, this, "_own_world_changed");
}
}
if (is_inside_tree()) {

View File

@ -523,7 +523,7 @@ public:
Vector2 get_camera_coords(const Vector2 &p_viewport_coords) const;
Vector2 get_camera_rect_size() const;
void set_use_own_world(bool p_world);
void set_use_own_world(bool p_use_own_world);
bool is_using_own_world() const;
void input(const Ref<InputEvent> &p_event);