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

Method _loadFile

Engine/source/T3D/prefab.cpp:336–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334}
335
336void Prefab::_loadFile( bool addFileNotify )
337{
338 AssertFatal( isServerObject(), "Prefab-bad" );
339
340 if ( mFilename == StringTable->EmptyString())
341 return;
342
343 if ( !Torque::FS::IsScriptFile( mFilename ) )
344 {
345 Con::errorf( "Prefab::_loadFile() - file %s was not found.", mFilename );
346 return;
347 }
348
349 if ( sPrefabFileStack.contains(mFilename) )
350 {
351 Con::errorf(
352 "Prefab::_loadFile - failed loading prefab file (%s). \n"
353 "File was referenced recursively by both a Parent and Child prefab.", mFilename );
354 return;
355 }
356
357 sPrefabFileStack.push_back(mFilename);
358
359 String command = String::ToString( "exec( \"%s\" );", mFilename );
360 Con::evaluate( command );
361
362 SimGroup *group;
363 if ( !Sim::findObject( Con::getVariable( "$ThisPrefab" ), group ) )
364 {
365 Con::errorf( "Prefab::_loadFile() - file %s did not create $ThisPrefab.", mFilename );
366 return;
367 }
368
369 if ( addFileNotify )
370 Torque::FS::AddChangeNotification( mFilename, this, &Prefab::_onFileChanged );
371
372 mChildGroup = group;
373
374 Vector<SceneObject*> foundObjects;
375 mChildGroup->findObjectByType( foundObjects );
376
377 if ( !foundObjects.empty() )
378 {
379 mWorldBox = Box3F::Invalid;
380
381 for ( S32 i = 0; i < foundObjects.size(); i++ )
382 {
383 SceneObject *child = foundObjects[i];
384 mChildMap.insert( child->getId(), Transform( child->getTransform(), child->getScale() ) );
385 smChildToPrefabMap.insert( child->getId(), getId() );
386
387 _updateChildTransform( child );
388
389 mWorldBox.intersect( child->getWorldBox() );
390 }
391
392 resetObjectBox();
393 }

Callers

nothing calls this directly

Calls 15

IsScriptFileFunction · 0.85
evaluateFunction · 0.85
getVariableFunction · 0.85
AddChangeNotificationFunction · 0.85
EmptyStringMethod · 0.80
findObjectByTypeMethod · 0.80
TransformClass · 0.70
getIdMethod · 0.65
errorfFunction · 0.50
findObjectFunction · 0.50
containsMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected