MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / onAdd

Method onAdd

Engine/source/ts/tsShapeConstruct.cpp:433–505  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

431
432//-----------------------------------------------------------------------------
433bool TSShapeConstructor::onAdd()
434{
435 if (!Parent::onAdd())
436 return false;
437
438 // Prevent multiple objects pointing at the same shape file
439 TSShapeConstructor* tss = findShapeConstructorByAssetId(getShapeAssetId());
440 if (tss)
441 {
442 Con::errorf("TSShapeConstructor::onAdd failed: %s is already referenced by "
443 "another TSShapeConstructor object (%s - %d)", getShapeAssetId(),
444 tss->getName(), tss->getId());
445 return false;
446 }
447
448 // Add to the TSShapeConstructor group (for lookups)
449 SimGroup* group;
450 if (!Sim::findObject("TSShapeConstructorGroup", group))
451 {
452 group = new SimGroup();
453 if (!group->registerObject("TSShapeConstructorGroup"))
454 {
455 SAFE_DELETE(group);
456
457 Con::errorf("TSShapeConstructor::onAdd failed: Could not register "
458 "TSShapeConstructorGroup");
459 return false;
460 }
461 Sim::getRootGroup()->addObject(group);
462 }
463 group->addObject(this);
464
465 // This is only here for backwards compatibility!
466 //
467 // If we have no sequences, it may be using the older sequence# syntax.
468 // Check for dynamic fields of that pattern and add them into the sequence vector.
469 /*if (mSequenceAssetIds.empty())
470 {
471 for ( U32 idx = 0; idx < MaxLegacySequences; idx++ )
472 {
473 String field = String::ToString( "sequence%d", idx );
474 const char *data = getDataField( StringTable->insert(field.c_str()), NULL );
475
476 // Break at first field not used
477 if ( !data || !data[0] )
478 break;
479
480 // By pushing the field thru Con::setData for TypeStringFilename
481 // we get the default filename expansion. If we didn't do this
482 // then we would have unexpanded ~/ in the file paths.
483 String expanded;
484 Con::setData( TypeStringFilename, &expanded, 0, 1, &data );
485 addSequenceFromField( this, NULL, expanded.c_str() );
486 }
487 }*/
488
489 // If an instance of this shape has already been loaded, call onLoad now
490 mShapeAsset = mShapeAssetId;

Callers

nothing calls this directly

Calls 11

getRootGroupFunction · 0.85
notNullMethod · 0.80
getShapeResourceMethod · 0.80
needsReinitMethod · 0.80
getIdMethod · 0.65
errorfFunction · 0.50
findObjectFunction · 0.50
getNameMethod · 0.45
registerObjectMethod · 0.45
addObjectMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected