- g_PathView->Begin(trigger_ep->value, target_ep->value, rs.fMultiplier, rs.nPoints, rs.fGravity, rs.bNoUpdate, rs.bShowExtra);
- }
- else
- DoMessageBox("trigger_push target could not be found.", "Error", MB_OK);
- }
- else
- DoMessageBox("trigger_push has no target.", "Error", MB_OK);
+void DoMergePatches(){
+ UndoableCommand undo( "bobToolz.mergePatches" );
+ patch_merge_t merge_info;
+ DPatch mrgPatches[2];
+ int i;
+
+ // ensure we have something selected
+ if ( GlobalSelectionSystem().countSelected() != 2 ) {
+ globalErrorStream() << "bobToolz MergePatches: Invalid number of patches selected, choose 2 only.\n";
+ //DoMessageBox("Invalid number of patches selected, choose 2 only", "Error", eMB_OK);
+ return;
+ }
+
+ scene::Instance* patches[2];
+ patches[0] = &GlobalSelectionSystem().ultimateSelected();
+ patches[1] = &GlobalSelectionSystem().penultimateSelected();
+
+ for ( i = 0; i < 2; i++ )
+ {
+ if ( !Node_isPatch( patches[i]->path().top() ) ) {
+ //DoMessageBox("No patches selected, select ONLY patches", "Error", eMB_OK);
+ globalErrorStream() << "bobToolz MergePatches: Invalid number of patches selected, choose ONLY 2 patches.\n";
+ return;
+ }
+
+ mrgPatches[i].LoadFromPatch( *patches[i] );
+ }
+
+ /* mrgPatches[0].Transpose();
+ mrgPatches[0].RemoveFromRadiant();
+ mrgPatches[0].BuildInRadiant();*/
+
+ merge_info = mrgPatches[0].IsMergable( &mrgPatches[1] );
+
+ if ( merge_info.mergable ) {
+ globalOutputStream() << merge_info.pos1 << " " << merge_info.pos2;
+ //Message removed, No tools give feedback on success.
+ //globalOutputStream() << "bobToolz MergePatches: Patches Mergable.\n";
+ DPatch* newPatch = mrgPatches[0].MergePatches( merge_info, &mrgPatches[0], &mrgPatches[1] );
+
+ /* mrgPatches[0].RemoveFromRadiant();
+ mrgPatches[0].BuildInRadiant();
+
+ mrgPatches[1].RemoveFromRadiant();
+ mrgPatches[1].BuildInRadiant();
+
+
+ delete newPatch;*/
+
+ if ( !newPatch ) {