void GuiRoadEditorCtrl::deleteSelectedNode() { if ( !mSelRoad || mSelNode == -1 ) return; // If the road has only two nodes remaining, // delete the whole road. if ( mSelRoad->mNodes.size() <= 2 ) { deleteSelectedRoad(); } else { // Only submit undo if we weren't in AddMode if ( mMode != mAddNodeMode ) submitUndo( "Delete Node" ); // Delete the SelectedNode of the SelectedRoad mSelRoad->deleteNode(mSelNode); mIsDirty = true; // We deleted the Node but not the Road (it has nodes left) // so decrement the currently selected node. if ( mSelRoad->mNodes.size() <= mSelNode ) mSelNode--; } }
void GuiRoadEditorCtrl::on3DMouseDragged(const Gui3DMouseEvent & event) { // Drags are only used to transform nodes if ( !mSelRoad || mSelNode == -1 || ( mMode != mMovePointMode && mMode != mScalePointMode ) ) return; if ( !mSavedDrag ) { submitUndo( "Modify Node" ); mSavedDrag = true; } if ( mMode == mScalePointMode ) { Point3F tPos; if ( !getTerrainPos( event, tPos ) ) return; if ( mStartWidth == -1.0f ) { mStartWidth = mSelRoad->mNodes[mSelNode].width; mStartX = event.mousePoint.x; mStartWorld = tPos; } S32 deltaScreenX = event.mousePoint.x - mStartX; F32 worldDist = ( event.pos - mStartWorld ).len(); F32 deltaWorldX = ( deltaScreenX * worldDist ) / getWorldToScreenScale().y; F32 width = mStartWidth + deltaWorldX; mSelRoad->setNodeWidth( mSelNode, width ); mIsDirty = true; } else if( mMode == mMovePointMode ) { Point3F tPos; if ( !getTerrainPos( event, tPos ) ) return; mSelRoad->setNodePosition( mSelNode, tPos ); mIsDirty = true; } Con::executef( this, "onNodeModified", Con::getIntArg(mSelNode) ); }
void GuiRiverEditorCtrl::deleteSelectedNode() { if ( !mSelRiver || mSelNode == -1 ) return; // If the River has only two nodes remaining, // delete the whole River. if ( mSelRiver->mNodes.size() <= 2 ) { deleteSelectedRiver( mMode != mAddNodeMode ); } else { if ( mMode != mAddNodeMode ) submitUndo( "Delete Node" ); // Delete the SelectedNode of the SelectedRiver mSelRiver->deleteNode(mSelNode); mIsDirty = true; // We deleted the Node but not the River (it has nodes left) // so decrement the currently selected node. if ( mSelRiver->mNodes.size() <= mSelNode ) setSelectedNode( mSelNode - 1 ); else { // force gizmo to update to the selected nodes position // the index didn't change but the node it refers to did. U32 i = mSelNode; mSelNode = -1; setSelectedNode( i ); } } // If you were in addNodeMode, // deleting a node should ends it. //mMode = smNormalMode; }
void GuiRoadEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event) { if ( !isFirstResponder() ) setFirstResponder(); // Get the clicked terrain position. Point3F tPos; if ( !getTerrainPos( event, tPos ) ) return; mouseLock(); // Find any road / node at the clicked position. // TODO: handle overlapping roads/nodes somehow, cycle through them. DecalRoad *roadPtr = NULL; S32 closestNodeIdx = -1; F32 closestDist = F32_MAX; DecalRoad *closestNodeRoad = NULL; // First, find the closest node in any road to the clicked position. for ( SimSetIterator iter(mRoadSet); *iter; ++iter ) { roadPtr = static_cast<DecalRoad*>( *iter ); U32 idx; if ( roadPtr->getClosestNode( tPos, idx ) ) { Point3F nodePos = roadPtr->getNodePosition(idx); F32 dist = ( nodePos - tPos ).len(); if ( dist < closestDist ) { closestNodeIdx = idx; closestDist = dist; closestNodeRoad = roadPtr; } } } // // Second, determine if the screen-space node rectangle // contains the clicked position. bool nodeClicked = false; S32 clickedNodeIdx = -1; if ( closestNodeIdx != -1 ) { Point3F nodePos = closestNodeRoad->getNodePosition( closestNodeIdx ); Point3F temp; project( nodePos, &temp ); Point2I screenPos( temp.x, temp.y ); RectI nodeRect( screenPos - mNodeHalfSize, mNodeHalfSize * 2 ); nodeClicked = nodeRect.pointInRect( event.mousePoint ); if ( nodeClicked ) clickedNodeIdx = closestNodeIdx; } // // Determine the clickedRoad // DecalRoad *clickedRoadPtr = NULL; U32 insertNodeIdx = 0; if ( nodeClicked && (mSelRoad == NULL || closestNodeRoad == mSelRoad) ) { // If a node was clicked, the owning road is always // considered the clicked road. clickedRoadPtr = closestNodeRoad; } else { // check the selected road first if ( mSelRoad != NULL && mSelRoad->containsPoint( tPos, &insertNodeIdx ) ) { clickedRoadPtr = mSelRoad; nodeClicked = false; clickedNodeIdx = -1; } else { // Otherwise, we must ask each road if it contains // the clicked pos. for ( SimSetIterator iter(mRoadSet); *iter; ++iter ) { roadPtr = static_cast<DecalRoad*>( *iter ); if ( roadPtr->containsPoint( tPos, &insertNodeIdx ) ) { clickedRoadPtr = roadPtr; break; } } } } // shortcuts bool dblClick = ( event.mouseClickCount > 1 ); if( dblClick ) { if( mMode == mSelectRoadMode ) { setMode( mAddRoadMode, true ); return; } if( mMode == mAddNodeMode ) { // Delete the node attached to the cursor. deleteSelectedNode(); mMode = mAddRoadMode; return; } } //this check is here in order to bounce back from deleting a whole road with ctrl+z //this check places the editor back into addroadmode if ( mMode == mAddNodeMode ) { if ( !mSelRoad ) mMode = mAddRoadMode; } if ( mMode == mSelectRoadMode ) { // Did not click on a road or a node. if ( !clickedRoadPtr ) { setSelectedRoad( NULL ); setSelectedNode( -1 ); return; } // Clicked on a road that wasn't the currently selected road. if ( clickedRoadPtr != mSelRoad ) { setSelectedRoad( clickedRoadPtr ); setSelectedNode( -1 ); return; } // Clicked on a node in the currently selected road that wasn't // the currently selected node. if ( nodeClicked ) { setSelectedNode( clickedNodeIdx ); return; } // Clicked a position on the currently selected road // that did not contain a node. //U32 newNode = clickedRoadPtr->insertNode( tPos, mDefaultWidth, insertNodeIdx ); //setSelectedNode( newNode ); } else if ( mMode == mAddRoadMode ) { if ( nodeClicked && clickedRoadPtr ) { // A double-click on a node in Normal mode means set AddNode mode. if ( clickedNodeIdx == 0 ) { setSelectedRoad( clickedRoadPtr ); setSelectedNode( clickedNodeIdx ); mAddNodeIdx = clickedNodeIdx; mMode = mAddNodeMode; mSelNode = mSelRoad->insertNode( tPos, mDefaultWidth, mAddNodeIdx ); mIsDirty = true; return; } else if ( clickedNodeIdx == clickedRoadPtr->mNodes.size() - 1 ) { setSelectedRoad( clickedRoadPtr ); setSelectedNode( clickedNodeIdx ); mAddNodeIdx = U32_MAX; mMode = mAddNodeMode; mSelNode = mSelRoad->addNode( tPos, mDefaultWidth ); mIsDirty = true; setSelectedNode( mSelNode ); return; } } DecalRoad *newRoad = new DecalRoad; newRoad->mMaterialName = mMaterialName; newRoad->registerObject(); // Add to MissionGroup SimGroup *missionGroup; if ( !Sim::findObject( "MissionGroup", missionGroup ) ) Con::errorf( "GuiDecalRoadEditorCtrl - could not find MissionGroup to add new DecalRoad" ); else missionGroup->addObject( newRoad ); newRoad->insertNode( tPos, mDefaultWidth, 0 ); U32 newNode = newRoad->insertNode( tPos, mDefaultWidth, 1 ); // Always add to the end of the road, the first node is the start. mAddNodeIdx = U32_MAX; setSelectedRoad( newRoad ); setSelectedNode( newNode ); mMode = mAddNodeMode; // Disable the hover node while in addNodeMode, we // don't want some random node enlarged. mHoverNode = -1; // Grab the mission editor undo manager. UndoManager *undoMan = NULL; if ( !Sim::findObject( "EUndoManager", undoMan ) ) { Con::errorf( "GuiRoadEditorCtrl::on3DMouseDown() - EUndoManager not found!" ); return; } // Create the UndoAction. MECreateUndoAction *action = new MECreateUndoAction("Create Road"); action->addObject( newRoad ); // Submit it. undoMan->addAction( action ); //send a callback to script after were done here if one exists if ( isMethod( "onRoadCreation" ) ) Con::executef( this, "onRoadCreation" ); return; } else if ( mMode == mAddNodeMode ) { // Oops the road got deleted, maybe from an undo action? // Back to NormalMode. if ( mSelRoad ) { // A double-click on a node in Normal mode means set AddNode mode. if ( clickedNodeIdx == 0 ) { submitUndo( "Add Node" ); mAddNodeIdx = clickedNodeIdx; mMode = mAddNodeMode; mSelNode = mSelRoad->insertNode( tPos, mDefaultWidth, mAddNodeIdx ); mIsDirty = true; setSelectedNode( mSelNode ); return; } else { if( clickedRoadPtr && clickedNodeIdx == clickedRoadPtr->mNodes.size() - 1 ) { submitUndo( "Add Node" ); mAddNodeIdx = U32_MAX; mMode = mAddNodeMode; mSelNode = mSelRoad->addNode( tPos, mDefaultWidth ); mIsDirty = true; setSelectedNode( mSelNode ); return; } else { submitUndo( "Insert Node" ); // A single-click on empty space while in // AddNode mode means insert / add a node. //submitUndo( "Add Node" ); //F32 width = mSelRoad->getNodeWidth( mSelNode ); U32 newNode = mSelRoad->insertNode( tPos, mDefaultWidth, mAddNodeIdx); mIsDirty = true; setSelectedNode( newNode ); return; } } } } else if ( mMode == mInsertPointMode && mSelRoad != NULL) { if ( clickedRoadPtr == mSelRoad ) { F32 w0 = mSelRoad->getNodeWidth( insertNodeIdx ); F32 w1 = mSelRoad->getNodeWidth( insertNodeIdx + 1 ); F32 width = ( w0 + w1 ) * 0.5f; submitUndo( "Insert Node" ); U32 newNode = mSelRoad->insertNode( tPos, width, insertNodeIdx + 1); mIsDirty = true; setSelectedNode( newNode ); return; } } else if ( mMode == mRemovePointMode && mSelRoad != NULL) { if ( nodeClicked && clickedRoadPtr == mSelRoad ) { setSelectedNode( clickedNodeIdx ); deleteSelectedNode(); return; } } else if ( mMode == mMovePointMode ) { if ( nodeClicked && clickedRoadPtr == mSelRoad ) { setSelectedNode( clickedNodeIdx ); return; } } else if ( mMode == mScalePointMode ) { if ( nodeClicked && clickedRoadPtr == mSelRoad ) { setSelectedNode( clickedNodeIdx ); return; } } }
void GuiRiverEditorCtrl::on3DMouseDragged(const Gui3DMouseEvent & event) { // If a node is not selected, we don't care about drags, // drags are only used for modifying nodes. if ( !mSelRiver || mSelNode == -1 || mMode == mAddNodeMode) return; // If we haven't already saved, // save an undo action to get back to this state, // before we make any modifications to the selected node. if ( !mSavedDrag ) { submitUndo( "Modify Node" ); mSavedDrag = true; } // Let the gizmo handle the drag, eg, modify its transforms mGizmo->on3DMouseDragged( event ); if ( mGizmo->isDirty() ) { Point3F pos = mGizmo->getPosition(); Point3F scale = mGizmo->getScale(); const MatrixF &mat = mGizmo->getTransform(); VectorF normal; mat.getColumn( 2, &normal ); mSelRiver->setNode( pos, scale.x, scale.z, normal, mSelNode ); mIsDirty = true; } Con::executef( this, "onNodeModified", Con::getIntArg(mSelNode) ); /* // If we are just starting a new drag, // we need to save the starting screen position of the mouse, // and the starting position of the selected node. if ( mStartDragMousePoint == InvalidMousePoint ) { mStartDragMousePoint = event.mousePoint; mStartDragNodePos = mSelRiver->getNodePosition( mSelNode ); } MathUtils::Line clickLine; clickLine.p = event.pos; clickLine.d = event.vec; MathUtils::Line axisLine; axisLine.p = mStartDragNodePos; axisLine.d = mGizmo.selectionToAxisVector( mGizmoSelection ); MathUtils::LineSegment segment; MathUtils::mShortestSegmentBetweenLines( clickLine, axisLine, segment ); // Segment.p1 is the closest point on the axis line, // We want to put the selected gizmo handle at that point, // So calculate the offset from the handle to the centerPoint to // determine the gizmo's position. mSelRiver->setNodePosition( mSelNode, segment.p1 ); */ /* // Convert the delta (dragged mouse distance) from screen space // into world space. Point2I deltaScreen = event.mousePoint - mStartDragMousePoint; F32 worldDist = ( event.pos - mStartDragNodePos ).len(); Point2F deltaWorld; deltaWorld.x = GFX->unprojectRadius( worldDist, deltaScreen.x ); deltaWorld.y = GFX->unprojectRadius( worldDist, deltaScreen.y ); // Now modify the selected node depending on the kind of operation we are doing. if ( mGizmoSelection == Gizmo::Axis_X ) { Point3F newPos = mStartDragNodePos; newPos.x += deltaWorld.x; mSelRiver->setNodePosition( mSelNode, newPos ); } else if ( mGizmoSelection == Gizmo::Axis_Y ) { Point3F newPos = mStartDragNodePos; newPos.y += deltaWorld.x; mSelRiver->setNodePosition( mSelNode, newPos ); } else if ( mGizmoSelection == Gizmo::Axis_Z ) { Point3F newPos = mStartDragNodePos; newPos.z += deltaWorld.y; mSelRiver->setNodePosition( mSelNode, newPos ); } */ /* F32 height = mStartHeight + deltaWorldX; Con::printf( "height = %g", height ); mSelRiver->setNodeHeight( mSelNode, height ); Con::executef( this, "onNodeHeightModified", Con::getFloatArg(height) ); if ( event.modifier & SI_PRIMARY_CTRL ) { //Point3F tPos; //if ( !getStaticPos( event, tPos ) ) // return; if ( mStartHeight == -1.0f ) { mStartHeight = mSelRiver->mNodes[mSelNode].point.z; mStartX = event.mousePoint.x; mStartWorld = mSelRiver->mNodes[mSelNode].point; } S32 deltaScreenX = event.mousePoint.x - mStartX; F32 worldDist = ( event.pos - mStartWorld ).len(); F32 deltaWorldX = GFX->unprojectRadius( worldDist, deltaScreenX ); F32 height = mStartHeight + deltaWorldX; Con::printf( "height = %g", height ); mSelRiver->setNodeHeight( mSelNode, height ); Con::executef( this, "onNodeHeightModified", Con::getFloatArg(height) ); } else if ( event.modifier & SI_SHIFT ) { Point3F tPos; if ( !getStaticPos( event, tPos ) ) return; if ( mStartWidth == -1.0f ) { mStartWidth = mSelRiver->mNodes[mSelNode].width; mStartX = event.mousePoint.x; mStartWorld = tPos; } S32 deltaScreenX = event.mousePoint.x - mStartX; F32 worldDist = ( event.pos - mStartWorld ).len(); F32 deltaWorldX = GFX->unprojectRadius( worldDist, deltaScreenX ); F32 width = mStartWidth + deltaWorldX; mSelRiver->setNodeWidth( mSelNode, width ); Con::executef( this, "onNodeWidthModified", Con::getFloatArg(width) ); } else { Point3F tPos; if ( !getStaticPos( event, tPos ) ) return; else if ( mGizmoSelection == Gizmo::Axis_Y ) { Point3F newPos = mStartDragNodePos; newPos.y += deltaWorld.x; mSelRiver->setNodePosition( mSelNode, newPos ); } mSelRiver->setNodePosition( mSelNode, tPos ); } */ }
void GuiRiverEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event) { mGizmo->on3DMouseDown( event ); if ( !isFirstResponder() ) setFirstResponder(); // Get the raycast collision position Point3F tPos; if ( !getStaticPos( event, tPos ) ) return; // Construct a LineSegment from the camera position to 1000 meters away in // the direction clicked. // If that segment hits the terrain, truncate the ray to only be that length. // We will use a LineSegment/Sphere intersection test to determine if a RiverNode // was clicked. Point3F startPnt = event.pos; Point3F endPnt = event.pos + event.vec * 1000.0f; RayInfo ri; if ( gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri) ) endPnt = ri.point; River *riverPtr = NULL; River *clickedRiverPtr = NULL; // Did we click on a river? check current selection first U32 insertNodeIdx = -1; Point3F collisionPnt; if ( mSelRiver != NULL && mSelRiver->collideRay( event.pos, event.vec, &insertNodeIdx, &collisionPnt ) ) { clickedRiverPtr = mSelRiver; } else { for ( SimSetIterator iter(mRiverSet); *iter; ++iter ) { riverPtr = static_cast<River*>( *iter ); if ( riverPtr->collideRay( event.pos, event.vec, &insertNodeIdx, &collisionPnt ) ) { clickedRiverPtr = riverPtr; break; } } } // Did we click on a riverNode? bool nodeClicked = false; S32 clickedNodeIdx = -1; F32 clickedNodeDist = mNodeSphereRadius; // If we clicked on the currently selected river, only scan its nodes if ( mSelRiver != NULL && clickedRiverPtr == mSelRiver ) { for ( U32 i = 0; i < mSelRiver->mNodes.size(); i++ ) { const Point3F &nodePos = mSelRiver->mNodes[i].point; Point3F screenPos; project( nodePos, &screenPos ); F32 dist = ( event.mousePoint - Point2I(screenPos.x, screenPos.y) ).len(); if ( dist < clickedNodeDist ) { clickedNodeDist = dist; clickedNodeIdx = i; nodeClicked = true; } } } else { for ( SimSetIterator iter(mRiverSet); *iter; ++iter ) { riverPtr = static_cast<River*>( *iter ); for ( U32 i = 0; i < riverPtr->mNodes.size(); i++ ) { const Point3F &nodePos = riverPtr->mNodes[i].point; Point3F screenPos; project( nodePos, &screenPos ); F32 dist = ( event.mousePoint - Point2I(screenPos.x, screenPos.y) ).len(); if ( dist < clickedNodeDist ) { // we found a hit! clickedNodeDist = dist; clickedNodeIdx = i; nodeClicked = true; clickedRiverPtr = riverPtr; } } } } // shortcuts bool dblClick = ( event.mouseClickCount > 1 ); if( dblClick ) { if( mMode == mSelectRiverMode ) { setMode( mAddRiverMode, true ); return; } if( mMode == mAddNodeMode ) { // Delete the node attached to the cursor. deleteSelectedNode(); mMode = mAddRiverMode; return; } } //this check is here in order to bounce back from deleting a whole road with ctrl+z //this check places the editor back into addrivermode if ( mMode == mAddNodeMode ) { if ( !mSelRiver ) mMode = mAddRiverMode; } if ( mMode == mSelectRiverMode ) { // Did not click on a River or a node. if ( !clickedRiverPtr ) { setSelectedRiver( NULL ); setSelectedNode( -1 ); return; } // Clicked on a River that wasn't the currently selected River. if ( clickedRiverPtr != mSelRiver ) { setSelectedRiver( clickedRiverPtr ); setSelectedNode( clickedNodeIdx ); return; } // Clicked on a node in the currently selected River that wasn't // the currently selected node. if ( nodeClicked ) { setSelectedNode( clickedNodeIdx ); return; } } else if ( mMode == mAddRiverMode ) { if ( nodeClicked ) { // A double-click on a node in Normal mode means set AddNode mode. if ( clickedNodeIdx == 0 ) { setSelectedRiver( clickedRiverPtr ); setSelectedNode( clickedNodeIdx ); mAddNodeIdx = clickedNodeIdx; mMode = mAddNodeMode; mSelNode = mSelRiver->insertNode( tPos, mDefaultWidth, mDefaultDepth, mDefaultNormal, mAddNodeIdx ); mIsDirty = true; return; } else if ( clickedNodeIdx == clickedRiverPtr->mNodes.size() - 1 ) { setSelectedRiver( clickedRiverPtr ); setSelectedNode( clickedNodeIdx ); mAddNodeIdx = U32_MAX; mMode = mAddNodeMode; mSelNode = mSelRiver->addNode( tPos, mDefaultWidth, mDefaultDepth, mDefaultNormal); mIsDirty = true; setSelectedNode( mSelNode ); return; } } if ( !isMethod( "createRiver" ) ) { Con::errorf( "GuiRiverEditorCtrl::on3DMouseDown - createRiver method does not exist." ); return; } const char *res = Con::executef( this, "createRiver" ); River *newRiver; if ( !Sim::findObject( res, newRiver ) ) { Con::errorf( "GuiRiverEditorCtrl::on3DMouseDown - createRiver method did not return a river object." ); return; } // Add to MissionGroup SimGroup *missionGroup; if ( !Sim::findObject( "MissionGroup", missionGroup ) ) Con::errorf( "GuiRiverEditorCtrl - could not find MissionGroup to add new River" ); else missionGroup->addObject( newRiver ); Point3F pos( endPnt ); pos.z += mDefaultDepth * 0.5f; newRiver->insertNode( pos, mDefaultWidth, mDefaultDepth, mDefaultNormal, 0 ); U32 newNode = newRiver->insertNode( pos, mDefaultWidth, mDefaultDepth, mDefaultNormal, 1 ); // Always add to the end of the road, the first node is the start. mAddNodeIdx = U32_MAX; setSelectedRiver( newRiver ); setSelectedNode( newNode ); mMode = mAddNodeMode; // Disable the hover node while in addNodeMode, we // don't want some random node enlarged. mHoverNode = -1; // Grab the mission editor undo manager. UndoManager *undoMan = NULL; if ( !Sim::findObject( "EUndoManager", undoMan ) ) { Con::errorf( "GuiMeshRoadEditorCtrl::on3DMouseDown() - EUndoManager not found!" ); return; } // Create the UndoAction. MECreateUndoAction *action = new MECreateUndoAction("Create MeshRoad"); action->addObject( newRiver ); // Submit it. undoMan->addAction( action ); return; } else if ( mMode == mAddNodeMode ) { // Oops the road got deleted, maybe from an undo action? // Back to NormalMode. if ( mSelRiver ) { // A double-click on a node in Normal mode means set AddNode mode. if ( clickedNodeIdx == 0 ) { submitUndo( "Add Node" ); mAddNodeIdx = clickedNodeIdx; mMode = mAddNodeMode; mSelNode = mSelRiver->insertNode( tPos, mDefaultWidth, mDefaultDepth, mDefaultNormal, mAddNodeIdx ); mIsDirty = true; setSelectedNode( mSelNode ); return; } else { if( clickedRiverPtr && clickedNodeIdx == clickedRiverPtr->mNodes.size() - 1 ) { submitUndo( "Add Node" ); mAddNodeIdx = U32_MAX; mMode = mAddNodeMode; U32 newNode = mSelRiver->addNode( tPos, mDefaultWidth, mDefaultDepth, mDefaultNormal); mIsDirty = true; setSelectedNode( newNode ); return; } else { submitUndo( "Insert Node" ); // A single-click on empty space while in // AddNode mode means insert / add a node. //submitUndo( "Add Node" ); //F32 width = mSelRiver->getNodeWidth( mSelNode ); U32 newNode = mSelRiver->insertNode( tPos, mDefaultWidth, mDefaultDepth, mDefaultNormal, mAddNodeIdx); mIsDirty = true; setSelectedNode( newNode ); return; } } } } else if ( mMode == mInsertPointMode && mSelRiver != NULL ) { if ( clickedRiverPtr == mSelRiver ) { // NOTE: I guess we have to determine the if the clicked ray intersects a road but not a specific node... // in order to handle inserting nodes in the same way as for DecalRoad U32 prevNodeIdx = insertNodeIdx; U32 nextNodeIdx = ( prevNodeIdx + 1 > mSelRiver->mNodes.size() - 1 ) ? prevNodeIdx : prevNodeIdx + 1; const RiverNode &prevNode = mSelRiver->mNodes[prevNodeIdx]; const RiverNode &nextNode = mSelRiver->mNodes[nextNodeIdx]; F32 width = ( prevNode.width + nextNode.width ) * 0.5f; F32 depth = ( prevNode.depth + nextNode.depth ) * 0.5f; Point3F normal = ( prevNode.normal + nextNode.normal ) * 0.5f; normal.normalize(); submitUndo( "Insert Node" ); U32 newNode = mSelRiver->insertNode( collisionPnt, width, depth, normal, insertNodeIdx + 1 ); mIsDirty = true; setSelectedNode( newNode ); return; } } else if ( mMode == mRemovePointMode && mSelRiver != NULL ) { if ( nodeClicked && clickedRiverPtr == mSelRiver ) { setSelectedNode( clickedNodeIdx ); deleteSelectedNode(); return; } } else if ( mMode == mMovePointMode ) { if ( nodeClicked && clickedRiverPtr == mSelRiver ) { setSelectedNode( clickedNodeIdx ); return; } } else if ( mMode == mScalePointMode ) { if ( nodeClicked && clickedRiverPtr == mSelRiver ) { setSelectedNode( clickedNodeIdx ); return; } } else if ( mMode == mRotatePointMode ) { if ( nodeClicked && clickedRiverPtr == mSelRiver ) { setSelectedNode( clickedNodeIdx ); return; } } }