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

Method _loadFile

Engine/source/T3D/prefab.cpp:333–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

errorfFunction · 0.85
evaluateFunction · 0.85
getVariableFunction · 0.85
AddChangeNotificationFunction · 0.85
TransformClass · 0.85
findObjectByTypeMethod · 0.80
findObjectFunction · 0.50
isEmptyMethod · 0.45
c_strMethod · 0.45
containsMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected