From e810879d5fd939be5915cdc6ffd2103a681beec8 Mon Sep 17 00:00:00 2001 From: w1z7ard Date: Wed, 5 Sep 2007 04:28:16 +0000 Subject: [PATCH] almost finished with copy safe q variables git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@403 6778bc44-b910-0410-a7a0-be141de4315d --- src/projectM-engine/CustomShape.cpp | 43 ++++++++++++++++++++++++++- src/projectM-engine/CustomShape.hpp | 9 ++++++ src/projectM-engine/CustomWave.cpp | 41 +++++++++++++++++++++++++ src/projectM-engine/CustomWave.hpp | 12 ++++++++ src/projectM-engine/InitCondUtils.hpp | 12 ++++---- src/projectM-engine/Parser.cpp | 4 +-- src/projectM-engine/Preset.cpp | 2 ++ 7 files changed, 114 insertions(+), 9 deletions(-) diff --git a/src/projectM-engine/CustomShape.cpp b/src/projectM-engine/CustomShape.cpp index 5c1500401..78850bfb9 100755 --- a/src/projectM-engine/CustomShape.cpp +++ b/src/projectM-engine/CustomShape.cpp @@ -169,6 +169,7 @@ CustomShape::CustomShape ( int id ) : imageUrl("") { DWRITE ( "%s\n", "failed to insert param!" ); } + param = Param::new_param_float ( "t1", P_FLAG_TVAR, &this->t1, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) { @@ -210,6 +211,47 @@ CustomShape::CustomShape ( int id ) : imageUrl("") DWRITE ( "%s\n", "failed to insert param!" ); } + param = Param::new_param_float ( "q1", P_FLAG_QVAR, &this->q1, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_float ( "q2", P_FLAG_QVAR, &this->q2, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_float ( "q3", P_FLAG_QVAR, &this->q3, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_float ( "q4", P_FLAG_QVAR, &this->q4, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_float ( "q5", P_FLAG_QVAR, &this->q5, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_float ( "q6", P_FLAG_QVAR, &this->q6, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_float ( "q7", P_FLAG_QVAR, &this->q7, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_float ( "q8", P_FLAG_QVAR, &this->q8, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_string ( "imageurl", P_FLAG_NONE, &this->imageUrl); if ( ParamUtils::insert ( param, &this->text_properties_tree ) < 0 ) { @@ -235,7 +277,6 @@ void CustomShape::loadUnspecInitConds() // NOTE: This is verified to be same behavior as trunk InitCondUtils::LoadUnspecInitCond fun ( this->init_cond_tree, this->per_frame_init_eqn_tree ); - traverse ( param_tree, fun ); } diff --git a/src/projectM-engine/CustomShape.hpp b/src/projectM-engine/CustomShape.hpp index 8aa526a2c..38acda447 100755 --- a/src/projectM-engine/CustomShape.hpp +++ b/src/projectM-engine/CustomShape.hpp @@ -87,6 +87,15 @@ public: float t7; float t8; + /* stupider q variables */ + float q1; + float q2; + float q3; + float q4; + float q5; + float q6; + float q7; + float q8; // projectM exclusive parameter to load textures over a shape std::string imageUrl; diff --git a/src/projectM-engine/CustomWave.cpp b/src/projectM-engine/CustomWave.cpp index b414db079..df481e2c4 100755 --- a/src/projectM-engine/CustomWave.cpp +++ b/src/projectM-engine/CustomWave.cpp @@ -426,6 +426,47 @@ CustomWave::CustomWave(int _id): abort(); } + + param = Param::new_param_float ( "q1", P_FLAG_QVAR, &this->q1, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_float ( "q2", P_FLAG_QVAR, &this->q2, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_float ( "q3", P_FLAG_QVAR, &this->q3, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_float ( "q4", P_FLAG_QVAR, &this->q4, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_float ( "q5", P_FLAG_QVAR, &this->q5, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_float ( "q6", P_FLAG_QVAR, &this->q6, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_float ( "q7", P_FLAG_QVAR, &this->q7, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } + param = Param::new_param_float ( "q8", P_FLAG_QVAR, &this->q8, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); + if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + { + DWRITE ( "%s\n", "failed to insert param!" ); + } /* End of parameter loading. Note that the read only parameters associated with custom waves (ie, sample) are variables stored in PresetFrameIO.hpp, and not specific to the custom wave datastructure. */ diff --git a/src/projectM-engine/CustomWave.hpp b/src/projectM-engine/CustomWave.hpp index bea6bf2e1..7c41a5bb1 100755 --- a/src/projectM-engine/CustomWave.hpp +++ b/src/projectM-engine/CustomWave.hpp @@ -107,6 +107,18 @@ public: float t6; float t7; float t8; + + + /* stupider q variables */ + float q1; + float q2; + float q3; + float q4; + float q5; + float q6; + float q7; + float q8; + float v1,v2; /* Data structures to hold per frame and per point equations */ diff --git a/src/projectM-engine/InitCondUtils.hpp b/src/projectM-engine/InitCondUtils.hpp index cefdd9825..b81bb7f91 100644 --- a/src/projectM-engine/InitCondUtils.hpp +++ b/src/projectM-engine/InitCondUtils.hpp @@ -30,12 +30,12 @@ inline void LoadUnspecInitCond::operator() (Param * param) { /* Don't count these parameters as initial conditions */ if (param->flags & P_FLAG_READONLY) return; - if (param->flags & P_FLAG_QVAR) - return; - if (param->flags & P_FLAG_TVAR) - return; - if (param->flags & P_FLAG_USERDEF) - return; +// if (param->flags & P_FLAG_QVAR) +// return; +// if (param->flags & P_FLAG_TVAR) + // return; + // if (param->flags & P_FLAG_USERDEF) + // return; /* If initial condition was not defined by the preset file, force a default one with the following code */ diff --git a/src/projectM-engine/Parser.cpp b/src/projectM-engine/Parser.cpp index e770f5786..6215c226b 100755 --- a/src/projectM-engine/Parser.cpp +++ b/src/projectM-engine/Parser.cpp @@ -2162,7 +2162,7 @@ int Parser::parse_shape_per_frame_init_eqn(std::istream & fs, CustomShape * cus return PROJECTM_SUCCESS; } -int Parser::parse_shape_per_frame_eqn(std::istream & fs, CustomShape * custom_shape, Preset * preset) { +int Parser::parse_shape_per_frame_eqn(std::istream & fs, CustomShape * custom_shape, Preset * preset) { Param * param; GenExpr * gen_expr; @@ -2187,7 +2187,7 @@ if (PARSE_DEBUG) printf("parse_shape (per_frame): [start] (custom shape id = %d) /* Make sure parameter is writable */ if (param->flags & P_FLAG_READONLY) { if (PARSE_DEBUG) printf("parse_shape (per_frame): parameter %s is marked as read only (LINE %d)\n", param->name.c_str(), line_count); - return PROJECTM_FAILURE; + return PROJECTM_PARSE_ERROR; } /* Parse right side of equation as an expression */ diff --git a/src/projectM-engine/Preset.cpp b/src/projectM-engine/Preset.cpp index 1bafeedf7..460417308 100755 --- a/src/projectM-engine/Preset.cpp +++ b/src/projectM-engine/Preset.cpp @@ -223,6 +223,7 @@ void Preset::evalCustomShapePerFrameEquations() assert(_pos->second); _pos->second->evaluate(); } + std::map & per_frame_eqn_tree = (*pos)->per_frame_eqn_tree; for (std::map::iterator _pos = per_frame_eqn_tree.begin(); _pos != per_frame_eqn_tree.end(); ++_pos) { @@ -339,6 +340,7 @@ void Preset::loadBuiltinParamsUnspecInitConds() { InitCondUtils::LoadUnspecInitCond loadUnspecInitCond(this->init_cond_tree, this->per_frame_init_eqn_tree); this->builtinParams.traverse(loadUnspecInitCond); + Algorithms::traverse(user_param_tree, loadUnspecInitCond); }