[instancer/L4] Implement an optimization
This commit is contained in:
parent
17761cc616
commit
10bc7a804a
@ -153,16 +153,47 @@ def _solve(tent, axisLimit, negative=False):
|
|||||||
out.append((scalar1 - gain, loc1))
|
out.append((scalar1 - gain, loc1))
|
||||||
out.append((scalar2 - gain, loc2))
|
out.append((scalar2 - gain, loc2))
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Special-case if peak is at axisMax.
|
||||||
|
if axisMax == peak:
|
||||||
|
upper = peak
|
||||||
|
|
||||||
|
# Case pre3:
|
||||||
|
# we keep deltas as is and only scale the axis upper to achieve
|
||||||
|
# the desired new tent if feasible.
|
||||||
|
#
|
||||||
|
# | peak |
|
||||||
|
# 1.........|............o...|..................
|
||||||
|
# | /x\ |
|
||||||
|
# | /xxx\ |
|
||||||
|
# | /xxxxx\|
|
||||||
|
# | /xxxxxxx+
|
||||||
|
# | /xxxxxxxx|\
|
||||||
|
# 0---|-----|------oxxxxxxxxx|xo---------------1
|
||||||
|
# axisMin | lower | upper
|
||||||
|
# | |
|
||||||
|
# axisDef axisMax
|
||||||
|
#
|
||||||
|
newUpper = peak + (1 - gain) * (upper - peak)
|
||||||
|
if axisMax <= newUpper and newUpper <= axisDef + (axisMax - axisDef) * 2:
|
||||||
|
upper = newUpper
|
||||||
|
if not negative and axisDef + (axisMax - axisDef) * MAX_F2DOT14 < upper:
|
||||||
|
# we clamp +2.0 to the max F2Dot14 (~1.99994) for convenience
|
||||||
|
upper = axisDef + (axisMax - axisDef) * MAX_F2DOT14
|
||||||
|
assert peak < upper
|
||||||
|
|
||||||
|
loc = (max(axisDef, lower), peak, upper)
|
||||||
|
scalar = 1
|
||||||
|
|
||||||
|
out.append((scalar - gain, loc))
|
||||||
|
|
||||||
# Case 3: Outermost limit still fits within F2Dot14 bounds;
|
# Case 3: Outermost limit still fits within F2Dot14 bounds;
|
||||||
# we keep deltas as is and only scale the axes bounds. Deltas beyond -1.0
|
# We keep axis bound as is. Deltas beyond -1.0 or +1.0 will never be
|
||||||
# or +1.0 will never be applied as implementations must clamp to that range.
|
# applied as implementations must clamp to that range.
|
||||||
#
|
#
|
||||||
# A second tent is needed for cases when gain is positive, though we add it
|
# A second tent is needed for cases when gain is positive, though we add it
|
||||||
# unconditionally and it will be dropped because scalar ends up 0.
|
# unconditionally and it will be dropped because scalar ends up 0.
|
||||||
#
|
#
|
||||||
# TODO: See if we can just move upper closer to adjust the slope, instead of
|
|
||||||
# second tent.
|
|
||||||
#
|
|
||||||
# | peak |
|
# | peak |
|
||||||
# 1.........|............o...|..................
|
# 1.........|............o...|..................
|
||||||
# | /x\ |
|
# | /x\ |
|
||||||
@ -181,10 +212,6 @@ def _solve(tent, axisLimit, negative=False):
|
|||||||
upper = axisDef + (axisMax - axisDef) * MAX_F2DOT14
|
upper = axisDef + (axisMax - axisDef) * MAX_F2DOT14
|
||||||
assert peak < upper
|
assert peak < upper
|
||||||
|
|
||||||
# Special-case if peak is at axisMax.
|
|
||||||
if axisMax == peak:
|
|
||||||
upper = peak
|
|
||||||
|
|
||||||
loc1 = (max(axisDef, lower), peak, upper)
|
loc1 = (max(axisDef, lower), peak, upper)
|
||||||
scalar1 = 1
|
scalar1 = 1
|
||||||
|
|
||||||
|
@ -137,8 +137,7 @@ class RebaseTentTest(object):
|
|||||||
(0.25, 0.25, 0.75),
|
(0.25, 0.25, 0.75),
|
||||||
[
|
[
|
||||||
(0.5, None),
|
(0.5, None),
|
||||||
(0.5, (0, 0.5, 1.5)),
|
(0.5, (0, 0.5, 1.0)),
|
||||||
(-0.5, (0.5, 1.5, 1.5)),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
# Case 1neg
|
# Case 1neg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user