From a93d7cb51d8d2a7bbeb0132ec56ba853c93f94bf Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn Date: Sun, 12 Sep 2021 20:09:07 -0400 Subject: [PATCH 1/6] Add Local Only Adds the "Local Only/kIsLocalOnly" property to sound emitters. Dependent on the kPropIsLocalOnly attribute, which still needs to be added to libHSPlasma. --- korman/properties/modifiers/sound.py | 6 ++++++ korman/ui/modifiers/sound.py | 1 + 2 files changed, 7 insertions(+) diff --git a/korman/properties/modifiers/sound.py b/korman/properties/modifiers/sound.py index 65c427e..3cefd7f 100644 --- a/korman/properties/modifiers/sound.py +++ b/korman/properties/modifiers/sound.py @@ -243,6 +243,10 @@ class PlasmaSound(idprops.IDPropMixin, bpy.types.PropertyGroup): description="Loop the sound", default=False, options=set()) + local_only = BoolProperty(name"Local Only", + description="Sounds only plays for local avatar", + default=False, + options=set()) inner_cone = FloatProperty(name="Inner Angle", description="Angle of the inner cone from the negative Z-axis", @@ -368,6 +372,8 @@ class PlasmaSound(idprops.IDPropMixin, bpy.types.PropertyGroup): sound.properties |= plSound.kPropLooping if self.incidental: sound.properties |= plSound.kPropIncidental + if self.local_only: + sound.properties |= plSound.kPropIsLocalOnly sound.dataBuffer = self._find_sound_buffer(exporter, so, wavHeader, dataSize, channel) # Cone effect diff --git a/korman/ui/modifiers/sound.py b/korman/ui/modifiers/sound.py index 95a7826..13d7a34 100644 --- a/korman/ui/modifiers/sound.py +++ b/korman/ui/modifiers/sound.py @@ -110,6 +110,7 @@ def soundemit(modifier, layout, context): col.prop(sound, "auto_start") col.prop(sound, "incidental") col.prop(sound, "loop") + col.prop(sound, "local_only") col.separator() _draw_fade_ui(sound.fade_in, col, "Fade In:") From 568ccbeea01f61894d178d79490b91918418c1bc Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn Date: Mon, 13 Sep 2021 13:56:05 -0400 Subject: [PATCH 2/6] Fix Property Name Uses the proper kPropLocalOnly. --- korman/properties/modifiers/sound.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/korman/properties/modifiers/sound.py b/korman/properties/modifiers/sound.py index 3cefd7f..f885694 100644 --- a/korman/properties/modifiers/sound.py +++ b/korman/properties/modifiers/sound.py @@ -373,7 +373,7 @@ class PlasmaSound(idprops.IDPropMixin, bpy.types.PropertyGroup): if self.incidental: sound.properties |= plSound.kPropIncidental if self.local_only: - sound.properties |= plSound.kPropIsLocalOnly + sound.properties |= plSound.kPropLocalOnly sound.dataBuffer = self._find_sound_buffer(exporter, so, wavHeader, dataSize, channel) # Cone effect From 7f408659dfbe30620ad74de64e2066fc2bc8c860 Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn Date: Tue, 14 Sep 2021 08:59:35 -0400 Subject: [PATCH 3/6] Modify Sound Message Node Allow the sound node to check for Local Only conditions. --- korman/nodes/node_messages.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/korman/nodes/node_messages.py b/korman/nodes/node_messages.py index 1c2fa4d..fc2d1f3 100644 --- a/korman/nodes/node_messages.py +++ b/korman/nodes/node_messages.py @@ -804,6 +804,7 @@ class PlasmaSoundMsgNode(idprops.IDPropObjectMixin, PlasmaMessageWithCallbacksNo def _convert_random_sound_msg(self, exporter, so): # Yas, plAnimCmdMsg + soundemit = self.emitter_object.plasma_modifiers.soundemit msg = plAnimCmdMsg() msg.addReceiver(exporter.mgr.find_key(plRandomSoundMod, bl=self.emitter_object)) @@ -818,6 +819,10 @@ class PlasmaSoundMsgNode(idprops.IDPropObjectMixin, PlasmaMessageWithCallbacksNo # No, you are not imagining things... msg.setCmd(plAnimCmdMsg.kSetSpeed, True) msg.speed = self.volume_pct / 100.0 if self.volume == "CUSTOM" else 0.0 + # Checking for local only + for snd in soundemit.sounds: + if snd.local_only: + msg.setCmd(plAnimCmdMsg.kIsLocalOnly, True) yield msg @@ -858,6 +863,10 @@ class PlasmaSoundMsgNode(idprops.IDPropObjectMixin, PlasmaMessageWithCallbacksNo msg.setCmd(getattr(plSoundMsg, self.looping)) if self.action != "CURRENT": msg.setCmd(getattr(plSoundMsg, self.action)) + # Is the sound local? Let's check the modifier... + for snd in soundemit.sounds: + if snd.local_only: + msg.setCmd(plSoundMsg.kIsLocalOnly) # Because we might be giving two messages here... yield msg From 539e2743671012c2e1fbe07808ebcf3808e4af06 Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn Date: Mon, 14 Feb 2022 14:30:04 -0500 Subject: [PATCH 4/6] Add random sound check Random sound mods mixed with local only cause problems, so we raise an error message if that happens. --- korman/properties/modifiers/sound.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/korman/properties/modifiers/sound.py b/korman/properties/modifiers/sound.py index f885694..219ac6e 100644 --- a/korman/properties/modifiers/sound.py +++ b/korman/properties/modifiers/sound.py @@ -373,7 +373,12 @@ class PlasmaSound(idprops.IDPropMixin, bpy.types.PropertyGroup): if self.incidental: sound.properties |= plSound.kPropIncidental if self.local_only: - sound.properties |= plSound.kPropLocalOnly + # Local only and random sounds hate each other, so we must check for both + for i in bpy.data.objects: + if i.plasma_modifiers.random_sound: + raise ExportError("SoundEmitter '{}': cannot have local only sounds and a random sound mod.".format(self.id_data.name)) + else: + sound.properties |= plSound.kPropLocalOnly sound.dataBuffer = self._find_sound_buffer(exporter, so, wavHeader, dataSize, channel) # Cone effect From 3b13d2e3d246a6b16185dbc0035200ee1070930c Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn Date: Thu, 3 Mar 2022 08:40:42 -0500 Subject: [PATCH 5/6] Revert Random Sound Check Backtrack local only/random sound check --- korman/properties/modifiers/sound.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/korman/properties/modifiers/sound.py b/korman/properties/modifiers/sound.py index 219ac6e..f885694 100644 --- a/korman/properties/modifiers/sound.py +++ b/korman/properties/modifiers/sound.py @@ -373,12 +373,7 @@ class PlasmaSound(idprops.IDPropMixin, bpy.types.PropertyGroup): if self.incidental: sound.properties |= plSound.kPropIncidental if self.local_only: - # Local only and random sounds hate each other, so we must check for both - for i in bpy.data.objects: - if i.plasma_modifiers.random_sound: - raise ExportError("SoundEmitter '{}': cannot have local only sounds and a random sound mod.".format(self.id_data.name)) - else: - sound.properties |= plSound.kPropLocalOnly + sound.properties |= plSound.kPropLocalOnly sound.dataBuffer = self._find_sound_buffer(exporter, so, wavHeader, dataSize, channel) # Cone effect From 08d61e11c08015d10370fa7cde83f5163a4b2e49 Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn Date: Sat, 2 Apr 2022 19:30:10 -0400 Subject: [PATCH 6/6] Revert node_messages.py to remove LocalOnly references per Hoikas --- korman/nodes/node_messages.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/korman/nodes/node_messages.py b/korman/nodes/node_messages.py index fc2d1f3..1c2fa4d 100644 --- a/korman/nodes/node_messages.py +++ b/korman/nodes/node_messages.py @@ -804,7 +804,6 @@ class PlasmaSoundMsgNode(idprops.IDPropObjectMixin, PlasmaMessageWithCallbacksNo def _convert_random_sound_msg(self, exporter, so): # Yas, plAnimCmdMsg - soundemit = self.emitter_object.plasma_modifiers.soundemit msg = plAnimCmdMsg() msg.addReceiver(exporter.mgr.find_key(plRandomSoundMod, bl=self.emitter_object)) @@ -819,10 +818,6 @@ class PlasmaSoundMsgNode(idprops.IDPropObjectMixin, PlasmaMessageWithCallbacksNo # No, you are not imagining things... msg.setCmd(plAnimCmdMsg.kSetSpeed, True) msg.speed = self.volume_pct / 100.0 if self.volume == "CUSTOM" else 0.0 - # Checking for local only - for snd in soundemit.sounds: - if snd.local_only: - msg.setCmd(plAnimCmdMsg.kIsLocalOnly, True) yield msg @@ -863,10 +858,6 @@ class PlasmaSoundMsgNode(idprops.IDPropObjectMixin, PlasmaMessageWithCallbacksNo msg.setCmd(getattr(plSoundMsg, self.looping)) if self.action != "CURRENT": msg.setCmd(getattr(plSoundMsg, self.action)) - # Is the sound local? Let's check the modifier... - for snd in soundemit.sounds: - if snd.local_only: - msg.setCmd(plSoundMsg.kIsLocalOnly) # Because we might be giving two messages here... yield msg