mirror of
https://github.com/ZDoom/Raze.git
synced 2025-05-31 17:31:00 +00:00
- added a 'Sum()' intrinsic to the vectors.
This commit is contained in:
parent
306db376d9
commit
cbf47b4dee
2 changed files with 20 additions and 1 deletions
|
@ -152,6 +152,7 @@ xx(stateinfo)
|
||||||
xx(DamageFunction)
|
xx(DamageFunction)
|
||||||
xx(Length)
|
xx(Length)
|
||||||
xx(LengthSquared)
|
xx(LengthSquared)
|
||||||
|
xx(Sum)
|
||||||
xx(Unit)
|
xx(Unit)
|
||||||
xx(Angle)
|
xx(Angle)
|
||||||
xx(PlusZ)
|
xx(PlusZ)
|
||||||
|
|
|
@ -8273,7 +8273,7 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
||||||
else if (Self->IsVector())
|
else if (Self->IsVector())
|
||||||
{
|
{
|
||||||
// handle builtins: Vectors got 5.
|
// handle builtins: Vectors got 5.
|
||||||
if (MethodName == NAME_Length || MethodName == NAME_LengthSquared || MethodName == NAME_Unit || MethodName == NAME_Angle)
|
if (MethodName == NAME_Length || MethodName == NAME_LengthSquared || MethodName == NAME_Sum || MethodName == NAME_Unit || MethodName == NAME_Angle)
|
||||||
{
|
{
|
||||||
if (ArgList.Size() > 0)
|
if (ArgList.Size() > 0)
|
||||||
{
|
{
|
||||||
|
@ -9280,6 +9280,7 @@ FxExpression *FxVectorBuiltin::Resolve(FCompileContext &ctx)
|
||||||
{
|
{
|
||||||
case NAME_Length:
|
case NAME_Length:
|
||||||
case NAME_LengthSquared:
|
case NAME_LengthSquared:
|
||||||
|
case NAME_Sum:
|
||||||
case NAME_Angle:
|
case NAME_Angle:
|
||||||
ValueType = TypeFloat64;
|
ValueType = TypeFloat64;
|
||||||
break;
|
break;
|
||||||
|
@ -9312,6 +9313,23 @@ ExpEmit FxVectorBuiltin::Emit(VMFunctionBuilder *build)
|
||||||
{
|
{
|
||||||
build->Emit(vecSize == 2 ? OP_DOTV2_RR : vecSize == 3 ? OP_DOTV3_RR : OP_DOTV4_RR, to.RegNum, op.RegNum, op.RegNum);
|
build->Emit(vecSize == 2 ? OP_DOTV2_RR : vecSize == 3 ? OP_DOTV3_RR : OP_DOTV4_RR, to.RegNum, op.RegNum, op.RegNum);
|
||||||
}
|
}
|
||||||
|
else if (Function == NAME_Sum)
|
||||||
|
{
|
||||||
|
ExpEmit temp(build, ValueType->GetRegType(), 1);
|
||||||
|
build->Emit(OP_FLOP, to.RegNum, op.RegNum, FLOP_ABS);
|
||||||
|
build->Emit(OP_FLOP, temp.RegNum, op.RegNum + 1, FLOP_ABS);
|
||||||
|
build->Emit(OP_ADDF_RR, to.RegNum, to.RegNum, temp.RegNum);
|
||||||
|
if (vecSize > 2)
|
||||||
|
{
|
||||||
|
build->Emit(OP_FLOP, temp.RegNum, op.RegNum + 2, FLOP_ABS);
|
||||||
|
build->Emit(OP_ADDF_RR, to.RegNum, to.RegNum, temp.RegNum);
|
||||||
|
}
|
||||||
|
if (vecSize > 3)
|
||||||
|
{
|
||||||
|
build->Emit(OP_FLOP, temp.RegNum, op.RegNum + 3, FLOP_ABS);
|
||||||
|
build->Emit(OP_ADDF_RR, to.RegNum, to.RegNum, temp.RegNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (Function == NAME_Unit)
|
else if (Function == NAME_Unit)
|
||||||
{
|
{
|
||||||
ExpEmit len(build, REGT_FLOAT);
|
ExpEmit len(build, REGT_FLOAT);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue