MCPcopy Create free account
hub / github.com/carbonengine/trinity / EvaluateExpression

Method EvaluateExpression

trinity/Controllers/Actions/Tr2ActionBindRTPC.cpp:149–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149BlueStdResult Tr2ActionBindRTPC::EvaluateExpression( const char* expression, float& value ) const
150{
151 if( !m_controller )
152 {
153 return BlueStdResult( BLUE_STD_RESULT_RUNTIME_ERROR, "controller needs to be running when evaluating expressions" );
154 }
155 Tr2ControllerExpression expr;
156 auto error = expr.SetExpr( expression, *m_controller, s_extraFunctions );
157 if( !error.empty() )
158 {
159 return BlueStdResult( BLUE_STD_RESULT_VALUE_ERROR, error.c_str() );
160 }
161 float time = TimeAsFloat( m_lastSimTime - m_startTime );
162 ExtraBuffer buffer = { this, &time };
163 auto result = expr.Eval( &buffer );
164 if( !result.first )
165 {
166 return BlueStdResult( BLUE_STD_RESULT_RUNTIME_ERROR, "error evaluating expression" );
167 }
168 value = result.second;
169 return BlueStdResult();
170}
171
172float Tr2ActionBindRTPC::GetCurveValue( float time ) const
173{

Callers

nothing calls this directly

Calls 3

SetExprMethod · 0.80
emptyMethod · 0.80
EvalMethod · 0.80

Tested by

no test coverage detected