mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-01 00:21:35 +00:00
Add clamp() to DECORATE
This commit is contained in:
parent
7f57f68ce1
commit
fd78686679
2 changed files with 24 additions and 0 deletions
|
@ -332,6 +332,7 @@ xx(Radius)
|
||||||
xx(ReactionTime)
|
xx(ReactionTime)
|
||||||
xx(MeleeRange)
|
xx(MeleeRange)
|
||||||
xx(Speed)
|
xx(Speed)
|
||||||
|
xx(Clamp)
|
||||||
|
|
||||||
// Various actor names which are used internally
|
// Various actor names which are used internally
|
||||||
xx(MapSpot)
|
xx(MapSpot)
|
||||||
|
|
|
@ -57,6 +57,7 @@ static FxExpression *ParseRandomPick(FScanner &sc, FName identifier, PClassActor
|
||||||
static FxExpression *ParseRandom2(FScanner &sc, PClassActor *cls);
|
static FxExpression *ParseRandom2(FScanner &sc, PClassActor *cls);
|
||||||
static FxExpression *ParseAbs(FScanner &sc, PClassActor *cls);
|
static FxExpression *ParseAbs(FScanner &sc, PClassActor *cls);
|
||||||
static FxExpression *ParseMinMax(FScanner &sc, FName identifier, PClassActor *cls);
|
static FxExpression *ParseMinMax(FScanner &sc, FName identifier, PClassActor *cls);
|
||||||
|
static FxExpression *ParseClamp(FScanner &sc, PClassActor *cls);
|
||||||
|
|
||||||
//
|
//
|
||||||
// ParseExpression
|
// ParseExpression
|
||||||
|
@ -381,6 +382,8 @@ static FxExpression *ParseExpression0 (FScanner &sc, PClassActor *cls)
|
||||||
case NAME_Min:
|
case NAME_Min:
|
||||||
case NAME_Max:
|
case NAME_Max:
|
||||||
return ParseMinMax(sc, identifier, cls);
|
return ParseMinMax(sc, identifier, cls);
|
||||||
|
case NAME_Clamp:
|
||||||
|
return ParseClamp(sc, cls);
|
||||||
case NAME_Abs:
|
case NAME_Abs:
|
||||||
return ParseAbs(sc, cls);
|
return ParseAbs(sc, cls);
|
||||||
default:
|
default:
|
||||||
|
@ -521,3 +524,23 @@ static FxExpression *ParseMinMax(FScanner &sc, FName identifier, PClassActor *cl
|
||||||
}
|
}
|
||||||
return new FxMinMax(list, identifier, sc);
|
return new FxMinMax(list, identifier, sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FxExpression *ParseClamp(FScanner &sc, PClassActor *cls)
|
||||||
|
{
|
||||||
|
FxExpression *src = ParseExpressionM(sc, cls);
|
||||||
|
sc.MustGetToken(',');
|
||||||
|
FxExpression *min = ParseExpressionM(sc, cls);
|
||||||
|
sc.MustGetToken(',');
|
||||||
|
FxExpression *max = ParseExpressionM(sc, cls);
|
||||||
|
sc.MustGetToken(')');
|
||||||
|
|
||||||
|
// Build clamp(a,x,y) as min(max(a,x),y)
|
||||||
|
TArray<FxExpression *> list(2);
|
||||||
|
list.Reserve(2);
|
||||||
|
list[0] = src;
|
||||||
|
list[1] = min;
|
||||||
|
FxExpression *maxexpr = new FxMinMax(list, NAME_Max, sc);
|
||||||
|
list[0] = maxexpr;
|
||||||
|
list[1] = max;
|
||||||
|
return new FxMinMax(list, NAME_Min, sc);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue