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

Method undo

Engine/source/environment/editors/guiRoadEditorCtrl.cpp:96–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96void 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
142bool GuiRoadEditorCtrl::onAdd()
143{

Callers

nothing calls this directly

Calls 8

_setMaterialMethod · 0.80
findObjectFunction · 0.50
mergeMethod · 0.45
inspectPostApplyMethod · 0.45
clearMethod · 0.45
sizeMethod · 0.45
_addNodeMethod · 0.45
regenerateMethod · 0.45

Tested by

no test coverage detected