| 94 | } |
| 95 | |
| 96 | void GuiRoadEditorUndoAction::undo() |
| 97 | { |
| 98 | DecalRoad *road = NULL; |
| 99 | if ( !Sim::findObject( mObjId, road ) ) |
| 100 | return; |
| 101 | |
| 102 | // Temporarily save the roads current data. |
| 103 | String materialAssetId = road->mMaterialAssetId; |
| 104 | F32 textureLength = road->mTextureLength; |
| 105 | F32 breakAngle = road->mBreakAngle; |
| 106 | F32 segmentsPerBatch = road->mSegmentsPerBatch; |
| 107 | Vector<RoadNode> nodes; |
| 108 | nodes.merge( road->mNodes ); |
| 109 | |
| 110 | // Restore the Road properties saved in the UndoAction |
| 111 | road->_setMaterial(materialAssetId); |
| 112 | road->mBreakAngle = breakAngle; |
| 113 | road->mSegmentsPerBatch = segmentsPerBatch; |
| 114 | road->mTextureLength = textureLength; |
| 115 | road->inspectPostApply(); |
| 116 | |
| 117 | // Restore the Nodes saved in the UndoAction |
| 118 | road->mNodes.clear(); |
| 119 | for ( U32 i = 0; i < mNodes.size(); i++ ) |
| 120 | { |
| 121 | road->_addNode( mNodes[i].point, mNodes[i].width ); |
| 122 | } |
| 123 | |
| 124 | // Regenerate the road |
| 125 | road->regenerate(); |
| 126 | |
| 127 | // If applicable set the selected road and node |
| 128 | mRoadEditor->mSelRoad = road; |
| 129 | mRoadEditor->mSelNode = -1; |
| 130 | |
| 131 | // Now save the previous Road data in this UndoAction |
| 132 | // since an undo action must become a redo action and vice-versa |
| 133 | mMaterialAssetId = materialAssetId; |
| 134 | mBreakAngle = breakAngle; |
| 135 | mSegmentsPerBatch = segmentsPerBatch; |
| 136 | mTextureLength = textureLength; |
| 137 | |
| 138 | mNodes.clear(); |
| 139 | mNodes.merge( nodes ); |
| 140 | } |
| 141 | |
| 142 | bool GuiRoadEditorCtrl::onAdd() |
| 143 | { |
nothing calls this directly
no test coverage detected