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
parent e80dfb7b12
commit d043f91b79
3 changed files with 10 additions and 10 deletions

View file

@ -243,7 +243,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

@ -2895,8 +2895,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;
}
@ -2904,18 +2904,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

@ -527,7 +527,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);