mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-03 00:18: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
|
return
|
||||||
|
|
||||||
if code0 in ('VECTOR', 'ROTATION', 'LIST'):
|
if code0 in ('VECTOR', 'ROTATION', 'LIST'):
|
||||||
|
isconst = True
|
||||||
for x in code[:1:-1]:
|
for x in code[:1:-1]:
|
||||||
self.FoldTree(x)
|
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
|
return
|
||||||
|
|
||||||
if code0 == 'FIELD':
|
if code0 == 'FIELD':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue