From 42ceeb72bfbce6bb46a5e892b927e44ae7d2ab1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alessandro=20Fam=C3=A0?= Date: Tue, 5 Nov 2024 22:20:44 +0100 Subject: [PATCH] Fix AkRoom not detecting moving between rooms 1) We need to use Object::cast_to instead of static_cast in GDExtension 2) Object::get_instance_id is a uint64_t, so the room id in the AkEvent3D and AkListener3D needs to be the same --- addons/Wwise/native/src/scene/ak_event.cpp | 4 ++-- addons/Wwise/native/src/scene/ak_event.h | 10 +++++----- addons/Wwise/native/src/scene/ak_listener.cpp | 4 ++-- addons/Wwise/native/src/scene/ak_listener.h | 6 +++--- addons/Wwise/native/src/scene/ak_room.cpp | 8 ++++---- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/addons/Wwise/native/src/scene/ak_event.cpp b/addons/Wwise/native/src/scene/ak_event.cpp index 3f121c1e..52e21f3c 100644 --- a/addons/Wwise/native/src/scene/ak_event.cpp +++ b/addons/Wwise/native/src/scene/ak_event.cpp @@ -381,6 +381,6 @@ void AkEvent3D::set_is_environment_aware(bool is_environment_aware) bool AkEvent3D::get_is_environment_aware() const { return is_environment_aware; } -void AkEvent3D::set_room_id(int room_id) { this->room_id = room_id; } +void AkEvent3D::set_room_id(uint64_t room_id) { this->room_id = room_id; } -int AkEvent3D::get_room_id() const { return room_id; } \ No newline at end of file +uint64_t AkEvent3D::get_room_id() const { return room_id; } \ No newline at end of file diff --git a/addons/Wwise/native/src/scene/ak_event.h b/addons/Wwise/native/src/scene/ak_event.h index d2e73a73..e3dec5b4 100644 --- a/addons/Wwise/native/src/scene/ak_event.h +++ b/addons/Wwise/native/src/scene/ak_event.h @@ -1,15 +1,15 @@ #pragma once #include "AK/SoundEngine/Common/AkTypes.h" -#include "core/wwise_cookie.h" #include "core/ak_utils.h" #include "core/utils.h" +#include "core/wwise_cookie.h" #include "core/wwise_gdextension.h" +#include "scene/ak_environment_data.h" #include #include #include #include -#include "scene/ak_environment_data.h" using namespace godot; @@ -88,7 +88,7 @@ class AkEvent3D : public Node3D void check_signal_connections(); - int room_id = INVALID_ROOM_ID; + uint64_t room_id = INVALID_ROOM_ID; public: AkEnvironmentData* environment_data = nullptr; @@ -124,6 +124,6 @@ class AkEvent3D : public Node3D void set_is_environment_aware(bool is_environment_aware); bool get_is_environment_aware() const; - void set_room_id(int room_id); - int get_room_id() const; + void set_room_id(uint64_t room_id); + uint64_t get_room_id() const; }; \ No newline at end of file diff --git a/addons/Wwise/native/src/scene/ak_listener.cpp b/addons/Wwise/native/src/scene/ak_listener.cpp index 2179882b..73c9da0b 100644 --- a/addons/Wwise/native/src/scene/ak_listener.cpp +++ b/addons/Wwise/native/src/scene/ak_listener.cpp @@ -70,6 +70,6 @@ void AkListener3D::set_is_spatial(bool is_spatial) { this->is_spatial = is_spati bool AkListener3D::get_is_spatial() const { return is_spatial; } -void AkListener3D::set_room_id(int room_id) { this->room_id = room_id; } +void AkListener3D::set_room_id(uint64_t room_id) { this->room_id = room_id; } -int AkListener3D::get_room_id() const { return room_id; } \ No newline at end of file +uint64_t AkListener3D::get_room_id() const { return room_id; } \ No newline at end of file diff --git a/addons/Wwise/native/src/scene/ak_listener.h b/addons/Wwise/native/src/scene/ak_listener.h index 2453146f..f51d0028 100644 --- a/addons/Wwise/native/src/scene/ak_listener.h +++ b/addons/Wwise/native/src/scene/ak_listener.h @@ -28,7 +28,7 @@ class AkListener3D : public Node3D private: bool is_spatial{}; - int room_id = INVALID_ROOM_ID; + uint64_t room_id = INVALID_ROOM_ID; public: virtual void _enter_tree() override; @@ -37,6 +37,6 @@ class AkListener3D : public Node3D void set_is_spatial(bool is_spatial); bool get_is_spatial() const; - void set_room_id(int room_id); - int get_room_id() const; + void set_room_id(uint64_t room_id); + uint64_t get_room_id() const; }; \ No newline at end of file diff --git a/addons/Wwise/native/src/scene/ak_room.cpp b/addons/Wwise/native/src/scene/ak_room.cpp index d171ce36..deb16562 100644 --- a/addons/Wwise/native/src/scene/ak_room.cpp +++ b/addons/Wwise/native/src/scene/ak_room.cpp @@ -80,8 +80,8 @@ void AkRoom::_on_area_entered(const Area3D* area) { // If we have an AkListener3D or an AkEvent3D, keep track // of the room it's entering. - AkListener3D* listener = static_cast(parent); - AkEvent3D* event = static_cast(parent); + AkListener3D* listener = Object::cast_to(parent); + AkEvent3D* event = Object::cast_to(parent); if (listener) { listener->set_room_id(static_cast(this->get_instance_id())); @@ -124,8 +124,8 @@ void AkRoom::_on_area_exited(const Area3D* area) // to INVALID_ROOM_ID. bool isGoingOutside = false; - AkListener3D* listener = static_cast(parent); - AkEvent3D* event = static_cast(parent); + AkListener3D* listener = Object::cast_to(parent); + AkEvent3D* event = Object::cast_to(parent); if (listener) { isGoingOutside = listener->get_room_id() == static_cast(this->get_instance_id());