Skip to content

Commit

Permalink
Add post-import script (closes #41, closes #47).
Browse files Browse the repository at this point in the history
  • Loading branch information
stechyo committed Apr 25, 2024
1 parent 928dfbf commit cc152e9
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
61 changes: 61 additions & 0 deletions project/addons/godot-steam-audio/src/post_import.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@tool
# Generates SteamAudioGeometry for imported scenes with hints.
class_name SteamAudioPostImport
extends EditorScenePostImport

var scene_root: Node
var STEAM_AUDIO_GEOM_PREFIX := "-sasg"
var STEAM_AUDIO_DYN_GEOM_PREFIX := "-sadg"

enum GeomType {
NONE = 0,
STATIC = 1,
DYNAMIC = 2
}

func _post_import(scene: Node):
self.scene_root = scene
iterate(scene)
return scene

func iterate(n: Node):
var typ := steam_audio_geom_type(n)
if typ != GeomType.NONE:
var g: Node
match typ:
GeomType.STATIC:
g = SteamAudioGeometry.new()
g.name = "SteamAudioGeometry"
GeomType.DYNAMIC:
g = SteamAudioDynamicGeometry.new()
g.name = "SteamAudioDynamicGeometry"
g.set_material(preload("res://addons/godot-steam-audio/materials/default_material.tres"))
n.add_child(g)
g.owner = self.scene_root


for child in n.get_children():
iterate(child)

func steam_audio_geom_type(n: Node) -> GeomType:
if n is MeshInstance3D:
if n.name.ends_with(STEAM_AUDIO_GEOM_PREFIX):
n.name = n.name.substr(0, n.name.length() - 5)
return GeomType.STATIC
elif n.name.ends_with(STEAM_AUDIO_DYN_GEOM_PREFIX):
n.name = n.name.substr(0, n.name.length() - 5)
return GeomType.DYNAMIC
return GeomType.NONE
if n is CollisionShape3D:
# check parent name because -colonly generates plain names
# for the collision shapes. we do not check the grandparents
# (for the -col case) because we've already generated a geometry for the mesh instance.
if n.get_parent().name.ends_with(STEAM_AUDIO_GEOM_PREFIX):
n.get_parent().name = n.get_parent().name.substr(0, n.get_parent().name.length() - 5)
return GeomType.STATIC
elif n.get_parent().name.ends_with(STEAM_AUDIO_DYN_GEOM_PREFIX):
n.get_parent().name = n.get_parent().name.substr(0, n.get_parent().name.length() - 5)
return GeomType.DYNAMIC
return GeomType.NONE
return GeomType.NONE

2 changes: 1 addition & 1 deletion src/lib/steamaudio
Submodule steamaudio updated 43 files
+1 −1 README.md
+2 −5 core/CMakeLists.txt
+1 −1 core/README.md
+5 −2 core/build/dependencies.json
+1 −1 core/doc/build-instructions.rst
+0 −2 core/doc/getting-started.rst
+7 −9 core/src/core/CMakeLists.txt
+1,310 −0 core/src/core/api_internal.cpp
+1 −1 core/src/core/api_validation_layer.cpp
+17 −17 core/src/core/avx_float8.h
+3 −3 core/src/core/delay.h
+8 −72 core/src/core/embree_scene.cpp
+0 −6 core/src/core/float8.h
+2 −2 core/src/core/float8_delay.cpp
+3 −3 core/src/core/float8_iir.cpp
+3 −3 core/src/core/float8_reverb_effect.cpp
+4 −4 core/src/core/iir.h
+0 −10 core/src/core/instanced_mesh.h
+0 −4 core/src/core/overlap_save_convolution_effect.cpp
+7 −13 core/src/core/phonon.h
+3 −3 core/src/core/phonon_version.h.in
+2 −2 core/src/core/reverb_effect.h
+27 −36 core/src/core/scene.cpp
+5 −10 core/src/core/simulation_manager.cpp
+1 −1 core/src/core/simulation_manager.h
+1 −1 fmod/CMakeLists.txt
+7 −13 fmod/include/phonon/phonon.h
+4 −4 fmod/include/phonon/phonon_version.h
+1 −1 fmod/setup.py
+1 −1 unity/CMakeLists.txt
+7 −13 unity/include/phonon/phonon.h
+4 −4 unity/include/phonon/phonon_version.h
+1 −1 unity/setup.py
+3 −12 unity/src/project/SteamAudioUnity/Assets/Plugins/SteamAudio/Scripts/Runtime/SteamAudioManager.cs
+1 −1 unreal/CMakeLists.txt
+1 −1 unreal/setup.py
+0 −1 unreal/src/SteamAudioUnreal/Plugins/SteamAudio/Source/SteamAudio/Private/SteamAudioGeometryComponent.cpp
+2 −2 unreal/src/SteamAudioUnreal/Plugins/SteamAudio/Source/SteamAudio/Private/SteamAudioSourceComponent.cpp
+1 −1 unreal/src/SteamAudioUnreal/Plugins/SteamAudio/Source/SteamAudio/Public/SteamAudioSourceComponent.h
+7 −13 unreal/src/SteamAudioUnreal/Plugins/SteamAudio/Source/SteamAudioSDK/include/phonon.h
+4 −4 unreal/src/SteamAudioUnreal/Plugins/SteamAudio/Source/SteamAudioSDK/include/phonon_version.h
+1 −1 unreal/src/SteamAudioUnreal/Plugins/SteamAudio/SteamAudio.uplugin
+1 −1 unreal/src/SteamAudioUnreal/Plugins/SteamAudioFMODStudio/SteamAudioFMODStudio.uplugin

0 comments on commit cc152e9

Please sign in to comment.