| 367 | } |
| 368 | |
| 369 | void WorldEditor::WorldEditorUndoAction::undo() |
| 370 | { |
| 371 | // NOTE: This function also handles WorldEditorUndoAction::redo(). |
| 372 | |
| 373 | MatrixF oldMatrix; |
| 374 | VectorF oldScale; |
| 375 | for( U32 i = 0; i < mEntries.size(); i++ ) |
| 376 | { |
| 377 | SceneObject *obj; |
| 378 | if ( !Sim::findObject( mEntries[i].mObjId, obj ) ) |
| 379 | continue; |
| 380 | |
| 381 | mWorldEditor->setClientObjInfo( obj, mEntries[i].mMatrix, mEntries[i].mScale ); |
| 382 | |
| 383 | // Grab the current state. |
| 384 | oldMatrix = obj->getTransform(); |
| 385 | oldScale = obj->getScale(); |
| 386 | |
| 387 | // Restore the saved state. |
| 388 | obj->setTransform( mEntries[i].mMatrix ); |
| 389 | obj->setScale( mEntries[i].mScale ); |
| 390 | |
| 391 | // Store the previous state so the next time |
| 392 | // we're called we can restore it. |
| 393 | mEntries[i].mMatrix = oldMatrix; |
| 394 | mEntries[i].mScale = oldScale; |
| 395 | } |
| 396 | |
| 397 | // Mark the world editor as dirty! |
| 398 | mWorldEditor->setDirty(); |
| 399 | mWorldEditor->mSelected->invalidateCentroid(); |
| 400 | |
| 401 | // Let the script get a chance at it. |
| 402 | Con::executef( mWorldEditor, "onWorldEditorUndo" ); |
| 403 | } |
| 404 | |
| 405 | //------------------------------------------------------------------------------ |
| 406 | // edit stuff |
nothing calls this directly
no test coverage detected