From 0d248236e794e2f2677af1e5df2efd557112966b Mon Sep 17 00:00:00 2001 From: Matthew Bellew Date: Thu, 10 May 2018 18:47:15 -0700 Subject: [PATCH] PrefunExprOne --- src/libprojectM/MilkdropPresetFactory/Expr.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/libprojectM/MilkdropPresetFactory/Expr.cpp b/src/libprojectM/MilkdropPresetFactory/Expr.cpp index 67f3f5585..2300f4e8f 100755 --- a/src/libprojectM/MilkdropPresetFactory/Expr.cpp +++ b/src/libprojectM/MilkdropPresetFactory/Expr.cpp @@ -68,6 +68,16 @@ float PrefunExpr::eval ( int mesh_i, int mesh_j ) } +class PrefunExprOne : public PrefunExpr +{ + float eval ( int mesh_i, int mesh_j ) + { + float val = expr_list[0]->eval ( mesh_i, mesh_j ); + return (func_ptr)(&val); + } +}; + + class ConstantExpr : public Expr { float constant; @@ -383,8 +393,10 @@ Expr * Expr::param_to_expr ( Param * param ) Expr * Expr::prefun_to_expr ( float ( *func_ptr ) ( void * ), Expr ** expr_list, int num_args ) { PrefunExpr * prefun_expr; - - prefun_expr = new PrefunExpr(); + if (num_args == 1) + prefun_expr = new PrefunExprOne(); + else + prefun_expr = new PrefunExpr(); prefun_expr->num_args = num_args; prefun_expr->func_ptr = ( float ( * ) ( void* ) ) func_ptr; prefun_expr->expr_list = expr_list;