void FNiagaraCompiler_VectorVM::TransformVector_Internal(TArray<TNiagaraExprPtr>& InputExpressions, TArray<TNiagaraExprPtr>& OutputExpressions) { TNiagaraExprPtr MatrixExpr = InputExpressions[0]; check(MatrixExpr->SourceExpressions.Num() == 4); TNiagaraExprPtr Row0 = MatrixExpr->GetSourceExpression(0); TNiagaraExprPtr Row1 = MatrixExpr->GetSourceExpression(1); TNiagaraExprPtr Row2 = MatrixExpr->GetSourceExpression(2); TNiagaraExprPtr Row3 = MatrixExpr->GetSourceExpression(3); TNiagaraExprPtr VectorExpr = InputExpressions[1]; TArray<TNiagaraExprPtr> Temp; Temp.Add(Expression_VMNative(VectorVM::EOp::splatx, VectorExpr)); Temp.Add(Expression_VMNative(VectorVM::EOp::splaty, VectorExpr)); Temp.Add(Expression_VMNative(VectorVM::EOp::splatz, VectorExpr)); Temp.Add(Expression_VMNative(VectorVM::EOp::splatw, VectorExpr)); Temp[0] = Expression_VMNative(VectorVM::EOp::mul, MatrixExpr->GetSourceExpression(0), Temp[0]); Temp[1] = Expression_VMNative(VectorVM::EOp::mul, MatrixExpr->GetSourceExpression(1), Temp[1]); Temp[2] = Expression_VMNative(VectorVM::EOp::mul, MatrixExpr->GetSourceExpression(2), Temp[2]); Temp[3] = Expression_VMNative(VectorVM::EOp::mul, MatrixExpr->GetSourceExpression(3), Temp[3]); Temp[0] = Expression_VMNative(VectorVM::EOp::add, Temp[0], Temp[1]); Temp[1] = Expression_VMNative(VectorVM::EOp::add, Temp[2], Temp[3]); OutputExpressions.Add(Expression_VMNative(VectorVM::EOp::add, Temp[0], Temp[1])); }
void FNiagaraCompiler_VectorVM::Transpose_Internal(TArray<TNiagaraExprPtr>& InputExpressions, TArray<TNiagaraExprPtr>& OutputExpressions) { TNiagaraExprPtr MatrixExpr = InputExpressions[0]; check(MatrixExpr->SourceExpressions.Num() == 4); TNiagaraExprPtr Row0 = MatrixExpr->GetSourceExpression(0); TNiagaraExprPtr Row1 = MatrixExpr->GetSourceExpression(1); TNiagaraExprPtr Row2 = MatrixExpr->GetSourceExpression(2); TNiagaraExprPtr Row3 = MatrixExpr->GetSourceExpression(3); //TODO: can probably make this faster if I provide direct shuffle ops in the VM rather than using the flexible, catch-all op compose. //Maybe don't want to make that externally usable though? Maybe for power users... TArray<TNiagaraExprPtr> Columns; Columns.Add(Expression_VMNative(VectorVM::EOp::composex, Row0, Row1, Row2, Row3)); Columns.Add(Expression_VMNative(VectorVM::EOp::composey, Row0, Row1, Row2, Row3)); Columns.Add(Expression_VMNative(VectorVM::EOp::composez, Row0, Row1, Row2, Row3)); Columns.Add(Expression_VMNative(VectorVM::EOp::composew, Row0, Row1, Row2, Row3)); Matrix_Internal(Columns, OutputExpressions); }