From cd4f2f1dead7892c6c4c03432ef2f977b99a32c7 Mon Sep 17 00:00:00 2001 From: Russell Matney Date: Mon, 22 Jan 2024 08:56:38 -0500 Subject: [PATCH] chore: update phantom camera --- .../textures/2D/PhantomCamera2DSprite.png.import | 2 +- .../textures/2D/inventory_container.png.import | 2 +- .../textures/2D/level_spritesheet.png.import | 2 +- .../examples/textures/2D/sign_prompt.png.import | 2 +- addons/phantom_camera/plugin.cfg | 2 +- .../scripts/phantom_camera/phantom_camera_2D.gd | 4 ++-- .../scripts/phantom_camera/phantom_camera_3D.gd | 16 ++++++++++++++-- .../phantom_camera_host/phantom_camera_host.gd | 6 +++--- 8 files changed, 24 insertions(+), 12 deletions(-) diff --git a/addons/phantom_camera/examples/textures/2D/PhantomCamera2DSprite.png.import b/addons/phantom_camera/examples/textures/2D/PhantomCamera2DSprite.png.import index dfa938a0..3d0faa4a 100644 --- a/addons/phantom_camera/examples/textures/2D/PhantomCamera2DSprite.png.import +++ b/addons/phantom_camera/examples/textures/2D/PhantomCamera2DSprite.png.import @@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/PhantomCamera2DSprite.png-6bf2b757da36375026c [params] compress/mode=0 -compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 +compress/bptc_ldr=0 compress/normal_map=0 compress/channel_pack=0 mipmaps/generate=false diff --git a/addons/phantom_camera/examples/textures/2D/inventory_container.png.import b/addons/phantom_camera/examples/textures/2D/inventory_container.png.import index 72be1e5f..ac39935c 100644 --- a/addons/phantom_camera/examples/textures/2D/inventory_container.png.import +++ b/addons/phantom_camera/examples/textures/2D/inventory_container.png.import @@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/inventory_container.png-12241277f279bfc4bf7d5 [params] compress/mode=0 -compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 +compress/bptc_ldr=0 compress/normal_map=0 compress/channel_pack=0 mipmaps/generate=false diff --git a/addons/phantom_camera/examples/textures/2D/level_spritesheet.png.import b/addons/phantom_camera/examples/textures/2D/level_spritesheet.png.import index 520372a5..532792f4 100644 --- a/addons/phantom_camera/examples/textures/2D/level_spritesheet.png.import +++ b/addons/phantom_camera/examples/textures/2D/level_spritesheet.png.import @@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/level_spritesheet.png-26a44dd21a040a5480d5ccb [params] compress/mode=0 -compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 +compress/bptc_ldr=0 compress/normal_map=0 compress/channel_pack=0 mipmaps/generate=false diff --git a/addons/phantom_camera/examples/textures/2D/sign_prompt.png.import b/addons/phantom_camera/examples/textures/2D/sign_prompt.png.import index a5799d3f..3eeda2ba 100644 --- a/addons/phantom_camera/examples/textures/2D/sign_prompt.png.import +++ b/addons/phantom_camera/examples/textures/2D/sign_prompt.png.import @@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/sign_prompt.png-18d451127e1cd1a16367acd23cec4 [params] compress/mode=0 -compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 +compress/bptc_ldr=0 compress/normal_map=0 compress/channel_pack=0 mipmaps/generate=false diff --git a/addons/phantom_camera/plugin.cfg b/addons/phantom_camera/plugin.cfg index f76d3c5e..f54016fd 100644 --- a/addons/phantom_camera/plugin.cfg +++ b/addons/phantom_camera/plugin.cfg @@ -3,5 +3,5 @@ name="Phantom Camera" description="Control the movement and dynamically tween 2D & 3D cameras positions. Built for Godot 4. Inspired by Cinemachine." author="Marcus Skov" -version="0.6.2.1" +version="0.6.2.2" script="plugin.gd" diff --git a/addons/phantom_camera/scripts/phantom_camera/phantom_camera_2D.gd b/addons/phantom_camera/scripts/phantom_camera/phantom_camera_2D.gd index ae8f369b..911fd70c 100644 --- a/addons/phantom_camera/scripts/phantom_camera/phantom_camera_2D.gd +++ b/addons/phantom_camera/scripts/phantom_camera/phantom_camera_2D.gd @@ -447,8 +447,8 @@ func _enter_tree() -> void: update_limit_all_sides() func _exit_tree() -> void: - if Properties.pcam_host_owner: - Properties.pcam_host_owner.pcam_removed_from_scene(self) + if _has_valid_pcam_owner(): + get_pcam_host_owner().pcam_removed_from_scene(self) Properties.pcam_exit_tree(self) diff --git a/addons/phantom_camera/scripts/phantom_camera/phantom_camera_3D.gd b/addons/phantom_camera/scripts/phantom_camera/phantom_camera_3D.gd index 6ca2dea6..6531b1a5 100644 --- a/addons/phantom_camera/scripts/phantom_camera/phantom_camera_3D.gd +++ b/addons/phantom_camera/scripts/phantom_camera/phantom_camera_3D.gd @@ -315,6 +315,8 @@ func _set(property: StringName, value) -> bool: if property == LOOK_AT_TARGET_PROPERTY_NAME: _look_at_target_path = value var value_node_path: NodePath = value as NodePath + if not is_node_ready(): await ready + if not value_node_path.is_empty(): _should_look_at = true if has_node(_look_at_target_path): @@ -482,8 +484,8 @@ func _enter_tree() -> void: func _exit_tree() -> void: - if Properties.pcam_host_owner: - Properties.pcam_host_owner.pcam_removed_from_scene(self) + if _has_valid_pcam_owner(): + get_pcam_host_owner().pcam_removed_from_scene(self) Properties.pcam_exit_tree(self) @@ -718,6 +720,12 @@ func _get_raw_unprojected_position() -> Vector2: func _on_dead_zone_changed() -> void: set_global_position( _get_position_offset_distance() ) + +func _has_valid_pcam_owner() -> bool: + if not is_instance_valid(get_pcam_host_owner()): return false + if not is_instance_valid(get_pcam_host_owner().camera_3D): return false + return true + #endregion # TBD @@ -1075,6 +1083,7 @@ func set_camera_cull_mask(value: int) -> void: set_camera_3D_resource(null) # Clears resource from PCam instance else: _camera_3D_resouce_default.cull_mask = value + if is_active(): get_pcam_host_owner().camera_3D.cull_mask = value ## Gets the Camera3D fov value assigned this PhantomCamera. The duration value is in seconds. func get_camera_cull_mask() -> int: if get_camera_3D_resource(): @@ -1093,6 +1102,7 @@ func set_camera_h_offset(value: float) -> void: set_camera_3D_resource(null) # Clears resource from PCam instance else: _camera_3D_resouce_default.h_offset = value + if is_active(): get_pcam_host_owner().camera_3D.h_offset = value ## Gets the Camera3D fov value assigned this PhantomCamera. The duration value is in seconds. func get_camera_h_offset() -> float: if get_camera_3D_resource(): @@ -1111,6 +1121,7 @@ func set_camera_v_offset(value: float) -> void: set_camera_3D_resource(null) # Clears resource from PCam instance else: _camera_3D_resouce_default.v_offset = value + if is_active(): get_pcam_host_owner().camera_3D.v_offset = value ## Gets the Camera3D fov value assigned this PhantomCamera. The duration value is in seconds. func get_camera_v_offset() -> float: if get_camera_3D_resource(): @@ -1129,6 +1140,7 @@ func set_camera_fov(value: float) -> void: set_camera_3D_resource(null) # Clears resource from PCam instance else: _camera_3D_resouce_default.fov = value + if is_active(): get_pcam_host_owner().camera_3D.fov = value ## Gets the Camera3D fov value assigned this PhantomCamera. The duration value is in seconds. func get_camera_fov() -> float: if get_camera_3D_resource(): diff --git a/addons/phantom_camera/scripts/phantom_camera_host/phantom_camera_host.gd b/addons/phantom_camera/scripts/phantom_camera_host/phantom_camera_host.gd index d574984d..c351cf95 100644 --- a/addons/phantom_camera/scripts/phantom_camera_host/phantom_camera_host.gd +++ b/addons/phantom_camera/scripts/phantom_camera_host/phantom_camera_host.gd @@ -218,17 +218,17 @@ func _pcam_tween(delta: float) -> void: ) ) - if _prev_camera_fov != _active_pcam.get_camera_fov() and _active_pcam.get_camera_3D_resource(): + if _prev_camera_fov != _active_pcam.get_camera_fov(): camera_3D.set_fov( _tween_interpolate_value(_prev_camera_fov, _active_pcam.get_camera_fov()) ) - if _prev_camera_h_offset != _active_pcam.get_camera_h_offset() and _active_pcam.get_camera_3D_resource(): + if _prev_camera_h_offset != _active_pcam.get_camera_h_offset(): camera_3D.set_h_offset( _tween_interpolate_value(_prev_camera_h_offset, _active_pcam.get_camera_h_offset()) ) - if _prev_camera_v_offset != _active_pcam.get_camera_v_offset() and _active_pcam.get_camera_3D_resource(): + if _prev_camera_v_offset != _active_pcam.get_camera_v_offset(): camera_3D.set_v_offset( _tween_interpolate_value(_prev_camera_v_offset, _active_pcam.get_camera_v_offset()) )