mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Fold vector/rotation/list expressions into constants.
This commit is contained in:
parent
4f7933aa3b
commit
33440f5dd4
1 changed files with 10 additions and 1 deletions
|
@ -157,9 +157,18 @@ class optimizer(object):
|
|||
return
|
||||
|
||||
if code0 in ('VECTOR', 'ROTATION', 'LIST'):
|
||||
isconst = True
|
||||
for x in code[:1:-1]:
|
||||
self.FoldTree(x)
|
||||
# TODO: Fold into constant if possible.
|
||||
if x[0] != CONSTANT:
|
||||
isconst = False
|
||||
if isconst:
|
||||
value = [x[2] for x in code[2:]]
|
||||
if code0 == 'VECTOR':
|
||||
value = lslfuncs.Vector([lslfuncs.ff(x) for x in value])
|
||||
elif code0 == 'ROTATION':
|
||||
value = lslfuncs.Quaternion([lslfuncs.ff(x) for x in value])
|
||||
code[:] = [CONSTANT, code[1], value]
|
||||
return
|
||||
|
||||
if code0 == 'FIELD':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue