[Bf-committers] Ob Coords to oops

Campbell Barton bf-committers@blender.org
Sat, 05 Jun 2004 14:50:01 +1000


This is a multi-part message in MIME format.
--------------090205070506050306080405
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

This is a patch that allows you to make the OOPS objects move to the 
relative object locations.
Front/Side/Top, accsess from the OOPS view menu.

Noty working as yet are
- Moving object data (would like to move the object data X/Y in the oops 
and interpolate its loc between its users locations)
- The location dosent take parent/child into account (Blender must have 
a way to retrieve world coords- anybody help?)

- Cam

--------------090205070506050306080405
Content-Type: text/plain;
 name="coord2oops.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="coord2oops.txt"

Index: source/blender/include/BIF_oops.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/BIF_oops.h,v
retrieving revision 1.5
diff -u -r1.5 BIF_oops.h
--- source/blender/include/BIF_oops.h	27 Dec 2002 13:10:20 -0000	1.5
+++ source/blender/include/BIF_oops.h	5 Jun 2004 04:35:14 -0000
@@ -60,6 +60,7 @@
 int oops_test_overlaphide(struct Oops *test);
 float oopslink_totlen(struct Oops *oops);
 void shrink_oops(void);
+void obcoord_oops(int);
 void shuffle_oops(void);
 int test_oops(struct Oops *oops);
 void test_oopslink(struct OopsLink *ol);
Index: source/blender/src/header_oops.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/header_oops.c,v
retrieving revision 1.8
diff -u -r1.8 header_oops.c
--- source/blender/src/header_oops.c	3 Jun 2004 14:29:14 -0000	1.8
+++ source/blender/src/header_oops.c	5 Jun 2004 04:35:19 -0000
@@ -110,12 +110,21 @@
 		shuffle_oops();
 		break;
 	case 1: /* Shrink Selected Blocks */
-    	shrink_oops();
-        break;
-    case 2: /* View All */
+		shrink_oops();
+    break;
+	case 2: /* Object coords to opps positions Side */
+		obcoord_oops(0);
+    break;
+	case 3: /* Object coords to opps positions Front */
+		obcoord_oops(1);
+    break;
+	case 4: /* Object coords to opps positions Top */
+		obcoord_oops(2);
+    break;	
+	case 5: /* View All */
 		do_oops_buttons(B_OOPSHOME);
 		break;
-	case 3: /* Maximize Window */
+	case 6: /* Maximize Window */
 		/* using event B_FULL */
 		break;
 	}
@@ -131,11 +140,18 @@
 	uiBlockSetButmFunc(block, do_oops_viewmenu, NULL);
 		
 	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Shuffle Selected Blocks|Shift S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
-    uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Shrink Selected Blocks|Alt S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
+	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Shrink Selected Blocks|Alt S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
 
+	uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); 
+	
+	/* object coords to oops */
+	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Object Location to OOPS Side", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
+	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Object Location to OOPS Front", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
+	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Object Location to OOPS Top", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
+	
 	uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");  
 
-	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
+	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
 		
 	if(!curarea->full) uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
 	else uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
Index: source/blender/src/oops.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/oops.c,v
retrieving revision 1.6
diff -u -r1.6 oops.c
--- source/blender/src/oops.c	7 Jan 2004 12:26:40 -0000	1.6
+++ source/blender/src/oops.c	5 Jun 2004 04:35:20 -0000
@@ -311,6 +311,80 @@
 	
 }
 
+void obcoord_oops(int coords) /* coords 0=X/Y, 1=X/Z, 2=Y/Z */
+{
+	Object *ob;
+	Oops *o2, *oops;
+	OopsLink *ol, *oln;
+	float olen, len1, f1, f2;
+	int go= 1, tot=0, dir=1, type1, type2;
+	
+	
+	/* we take two oopses, calc the 'beauty' and the exchanged beauty */
+	
+	if(G.soops==0) return;
+	
+	waitcursor(1);
+	
+	/* to make it 100% OK and fast: temporal insert
+	 * to the ooplinklist - per oops - the 'from' links.
+	 * Don't forget to free!
+	 */
+	
+	oops= G.soops->oops.first;
+	while(oops) {
+		if(oops->hide==0) {
+		
+			/*  */
+			if(oops->type==ID_OB) {
+				ob= (Object *)oops->id;
+				switch (coords)
+				{
+					case 0:
+						oops->x = ob->loc[1];
+						oops->y = ob->loc[2];
+						break;
+					case 1:
+						oops->x = ob->loc[0];
+						oops->y = ob->loc[2];
+						break;
+					case 2:
+						oops->x = ob->loc[0];
+						oops->y = ob->loc[1];
+						break;								
+				}
+			}
+			
+			ol= ol->next;
+		
+		}
+		oops= oops->next;
+	}
+	
+	
+	
+	waitcursor(0);
+	
+	/* free the from links */
+	oops= G.soops->oops.first;
+	while(oops) {
+		if(oops->hide==0) {
+			ol= oops->link.first;
+			while(ol) {
+				oln= ol->next;
+				if(ol->from) {
+					BLI_remlink(&oops->link, ol);
+					MEM_freeN(ol);
+				}
+				ol= oln;
+			}
+		}
+		oops= oops->next;
+	}
+
+	allqueue(REDRAWOOPS, 1);
+}
+
 void shuffle_oops()
 {
 	Oops *o2, *oops;

--------------090205070506050306080405--