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

Method Initialize

trinity/TriValueBinding.cpp:322–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322void TriValueBinding::Initialize()
323{
324 m_source = NULL;
325 m_destination = NULL;
326 m_copyFunc = NULL;
327 m_notifyPtr = nullptr;
328
329 IRoot* sourceObject = GetCurrentSourceObject();
330 IRoot* destinationObject = GetCurrentDestinationObject();
331
332 if( !sourceObject || !destinationObject )
333 {
334 // No point doing anything yet - all copy functions need a source and destination object
335 return;
336 }
337
338 if( !m_copyValueCallable && ( m_sourceAttribute.empty() || m_destinationAttribute.empty() ) )
339 {
340 // All copy functions except the Python callback require a source and destination attribute
341 return;
342 }
343
344 const Be::ClassInfo* srcClassInfo = sourceObject->ClassType();
345 const Be::ClassInfo* dstClassInfo = destinationObject->ClassType();
346
347 size_t dataSize = 0;
348
349 m_sourceItemOffset = 0;
350 bool sourceFloatArrayAsFloat = false;
351
352 std::string sourceAttr = m_sourceAttribute;
353 size_t sourceDot = sourceAttr.find( '.' );
354 if( sourceDot != std::string::npos )
355 {
356 std::string sourceItem = sourceAttr.substr( sourceDot + 1 );
357 if( auto offset = GetItemOffset( sourceItem ) )
358 {
359 sourceFloatArrayAsFloat = true;
360 m_sourceItemOffset = *offset * sizeof( float );
361 }
362 sourceAttr = sourceAttr.substr( 0, sourceDot );
363 }
364
365 m_destItemOffset = 0;
366 bool destFloatArrayAsFloat = false;
367
368 std::string destAttr = m_destinationAttribute.c_str();
369 size_t destDot = destAttr.find( '.' );
370 if( destDot != std::string::npos )
371 {
372 std::string destItem = destAttr.substr( destDot + 1 );
373 if( auto offset = GetItemOffset( destItem ) )
374 {
375 destFloatArrayAsFloat = true;
376 m_destItemOffset = *offset * sizeof( float );
377 }
378 destAttr = destAttr.substr( 0, destDot );
379 }

Callers

nothing calls this directly

Calls 5

GetItemOffsetFunction · 0.85
emptyMethod · 0.80
FindEntryFunction · 0.70
RegisterBindingMethod · 0.45
GetDestinationMethod · 0.45

Tested by

no test coverage detected