| 305 | } |
| 306 | |
| 307 | void 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 | |
| 354 | void ForestEditorCtrl::updateCollision() |
| 355 | { |
no test coverage detected