Skip to content

Commit

Permalink
generator: fix statechunks in v150
Browse files Browse the repository at this point in the history
  • Loading branch information
bnnm committed Aug 15, 2024
1 parent f6a59f8 commit ca63e18
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 31 deletions.
2 changes: 1 addition & 1 deletion wwiser/generator/render/bnode_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _make_statechunk(self, nbase):

# during during calculations to make a final list
#for bsi in statechunk.get_states():
# self.fields.statechunk(bsi.nstategroupid, bsi.nstatevalueid, bsi.bstate.props)
# self.fields.statechunk(bsi.nstategroupid, bsi.nstatevalueid, bsi.props)

return statechunk

Expand Down
41 changes: 25 additions & 16 deletions wwiser/generator/render/bnode_statechunk.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import bnode_props

# STATECHUNK
#
Expand All @@ -14,8 +15,8 @@ def __init__(self):
self.nstatevalueid = None
self.group = None
self.value = None
self.ntid = None
self.bstate = None
#self.ntid = None
self.props = None

class AkStateChunk(object):
def __init__(self, node, builder):
Expand Down Expand Up @@ -57,11 +58,15 @@ def _build(self, node, builder):
if not nstatevalueid or not nstatevalueid.value():
continue #not possible to set "none" as value


nprops = nstate.find1(name='AkPropBundle')
if nprops: #includes props directly
for nprop in nprops:
# todo handle
pass
if nprops:
# state props are included directly (ex. Aster Tatariqus v150 58709424)
props = bnode_props.CAkProps(nstate)
if not props.valid:
continue

self.include_statechunk(nstategroupid, nstatevalueid, props)

else:
# uses a reference to a state object
Expand All @@ -75,16 +80,20 @@ def _build(self, node, builder):
if not bstate or not bstate.props:
continue

bsi = _AkStateInfo()
bsi.nstategroupid = nstategroupid
bsi.nstatevalueid = nstatevalueid
bsi.group = nstategroupid.value()
bsi.value = nstatevalueid.value()
bsi.ntid = nstateinstanceid
bsi.bstate = bstate
self.include_statechunk(nstategroupid, nstatevalueid, bstate.props)

def include_statechunk(self, nstategroupid, nstatevalueid, props):
bsi = _AkStateInfo()
bsi.nstategroupid = nstategroupid
bsi.nstatevalueid = nstatevalueid
bsi.group = nstategroupid.value()
bsi.value = nstatevalueid.value()
#bsi.ntid = nstateinstanceid
bsi.props = props

#TODO filter repeats
self._states.append(bsi)

#TODO filter repeats
self._states.append(bsi)

def get_bsi(self, group, value):
for bsi in self._states:
Expand All @@ -100,7 +109,7 @@ def get_usable_states(self, apply_bus):
if self._usables is None:
items = []
for bsi in self._states:
if bsi.bstate.props.is_usable(apply_bus):
if bsi.props.is_usable(apply_bus):
items.append(bsi)
self._usables = items
return self._usables
34 changes: 22 additions & 12 deletions wwiser/generator/render/wproperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ def _calculate(self, bnode):
# base node applies extra props that aren't inherited
self._is_base = self._bnode == bnode

self._apply_props(bnode)
self._apply_props(bnode.props)
self._apply_props_fx(bnode)

self._apply_statechunks(bnode)
self._apply_rtpclist(bnode)
Expand All @@ -263,12 +264,11 @@ def _calculate(self, bnode):
# -------------------------------------------------------------------------

# standard props
def _apply_props(self, bnode):
if not bnode.props: #events don't have props
def _apply_props(self, props):
if not props: #events don't have props
return

cfg = self._config
props = bnode.props

# behavior props: only on base node
# (props from statechunks/rtpcs are included, so must add to existing values)
Expand All @@ -289,14 +289,24 @@ def _apply_props(self, bnode):
cfg.gain += props.busvolume
cfg.gain += props.outputbusvolume

# standard props
def _apply_props_fx(self, bnode):
if not bnode:
return
if not self._include_fx:
return

cfg = self._config

# relative props: only add current if base node will output audio
if self._audible:
# fake a bit FX to include Wwise Gain (effects render a bit different but should be ok for typical usage)
# (may be on bus or node level)
if self._include_fx:
fxlist = self._get_fxlist(bnode)
if fxlist:
gain = fxlist.get_gain()
cfg.gain += gain
#TODO handle statechunks/rtpcs in the fxgain
fxlist = self._get_fxlist(bnode)
if fxlist:
gain = fxlist.get_gain()
cfg.gain += gain
#TODO handle statechunks/rtpcs in the fxgain

def _get_fxlist(self, bnode):
if not bnode:
Expand Down Expand Up @@ -343,12 +353,12 @@ def _apply_statechunks(self, bnode):
# find currently set states (may be N)
for state in ws.scparams.get_states():
bsi = bnode.statechunk.get_bsi(state.group, state.value)
if not bsi or not bsi.bstate:
if not bsi or not bsi.props:
continue

cfg.crossfaded = True
self._uses_vars = True
self._apply_props(bsi.bstate)
self._apply_props(bsi.props)
self._txtp.info.statechunk(state)

# -------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion wwiser/generator/txtp/wtxtp_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def get_gamevar_lines(self):
return self._get_fields_lines("GAMEVARS", self._rtpc_fields)

def report_statechunk(self, bsi):
self._statechunk_fields.statechunk(bsi.nstategroupid, bsi.nstatevalueid, bsi.bstate.props)
self._statechunk_fields.statechunk(bsi.nstategroupid, bsi.nstatevalueid, bsi.props)

def get_statechunk_lines(self):
return self._get_fields_lines("STATECHUNKS", self._statechunk_fields)
Expand Down
2 changes: 1 addition & 1 deletion wwiser/parser/wdefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
141, #0x8d Wwise 2021.1-B? [Overwatch (PC)]
144, #0x90 Wwise 2022.1-B (none known)
145, #0x91 Wwise 2022.1 [Sea of Stars (PC), Mortal Kombat 1 (PC)]
150, #0x96 Wwise 2023.1 (none known)
150, #0x96 Wwise 2023.1 [Aster Tatariqus (Android)-update]
152, #0x98 Wwise 2024.1-B (none known)
]

Expand Down

0 comments on commit ca63e18

Please sign in to comment.