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

Method deleteMeshSafe

Engine/source/forest/editor/forestEditorCtrl.cpp:307–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307void ForestEditorCtrl::deleteMeshSafe( ForestItemData *mesh )
308{
309 UndoManager *undoMan = NULL;
310 if ( !Sim::findObject( "EUndoManager", undoMan ) )
311 {
312 Con::errorf( "ForestEditorCtrl::deleteMeshSafe() - EUndoManager not found." );
313 return;
314 }
315
316 // CompoundUndoAction which will delete the ForestItemData, ForestItem(s), and ForestBrushElement(s).
317 CompoundUndoAction *compoundAction = new CompoundUndoAction( "Delete Forest Mesh" );
318
319 // Find ForestItem(s) referencing this datablock and add their deletion
320 // to the undo action.
321 if ( mForest )
322 {
323 Vector<ForestItem> foundItems;
324 mForest->getData()->getItems( mesh, &foundItems );
325
326 ForestDeleteUndoAction *itemAction = new ForestDeleteUndoAction( mForest->getData(), this );
327 itemAction->removeItem( foundItems );
328 compoundAction->addAction( itemAction );
329 }
330
331 // Find ForestBrushElement(s) referencing this datablock.
332 SimSet* brushSet;
333 if (!Sim::findObject("ForestBrushSet", brushSet))
334 {
335 Con::errorf("ForestBrushTool::_collectElements() - could not find ForestBrushSet!");
336 return;
337 }
338
339 sKey = mesh;
340 Vector<SimObject*> foundElements;
341 brushSet->findObjectByCallback( &findMeshReferences, foundElements );
342
343 // Add UndoAction to delete the ForestBrushElement(s) and the ForestItemData.
344 MEDeleteUndoAction *elementAction = new MEDeleteUndoAction();
345 elementAction->deleteObject( foundElements );
346 elementAction->deleteObject( mesh );
347
348 // Add compound action to the UndoManager. Done.
349 undoMan->addAction( compoundAction );
350
351 updateCollision();
352}
353
354void ForestEditorCtrl::updateCollision()
355{

Callers 1

DefineEngineMethodFunction · 0.80

Calls 8

findObjectByCallbackMethod · 0.80
findObjectFunction · 0.50
errorfFunction · 0.50
getItemsMethod · 0.45
getDataMethod · 0.45
removeItemMethod · 0.45
addActionMethod · 0.45
deleteObjectMethod · 0.45

Tested by

no test coverage detected