[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18068] branches/blender2.5/blender/source /blender/editors/space_view3d/view3d_edit.c: My very first commit ( kinda cool ) just to test my commit rights and to go through the motions of commiting

Michael Fox mfoxdogg at gmail.com
Fri Dec 26 11:32:03 CET 2008


Revision: 18068
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18068
Author:   mfoxdogg
Date:     2008-12-26 11:31:44 +0100 (Fri, 26 Dec 2008)

Log Message:
-----------
My very first commit (kinda cool ) just to test my commit rights and to go through the motions of commiting

just a single comment to seperate the ED_VIEW3D_OT_viewnumpad operator code from the rest so its easier to read

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_edit.c

Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_edit.c	2008-12-26 03:56:52 UTC (rev 18067)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_edit.c	2008-12-26 10:31:44 UTC (rev 18068)
@@ -6,7 +6,7 @@
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. 
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,7 +20,7 @@
  * The Original Code is Copyright (C) 2008 Blender Foundation.
  * All rights reserved.
  *
- * 
+ *
  * Contributor(s): Blender Foundation
  *
  * ***** END GPL LICENSE BLOCK *****
@@ -87,15 +87,15 @@
 typedef struct ViewOpsData {
 	ARegion *ar;
 	View3D *v3d;
-	
+
 	float oldquat[4];
 	float trackvec[3];
 	float ofs[3], obofs[3];
 	float reverse, dist0;
-	
+
 	int origx, origy, oldx, oldy;
 	int origkey;
-	
+
 } ViewOpsData;
 
 #define TRACKBALLSIZE  (1.1)
@@ -103,15 +103,15 @@
 static void calctrackballvec(rcti *rect, int mx, int my, float *vec)
 {
 	float x, y, radius, d, z, t;
-	
+
 	radius= TRACKBALLSIZE;
-	
+
 	/* normalize x and y */
 	x= (rect->xmax + rect->xmin)/2 - mx;
 	x/= (float)((rect->xmax - rect->xmin)/4);
 	y= (rect->ymax + rect->ymin)/2 - my;
 	y/= (float)((rect->ymax - rect->ymin)/2);
-	
+
 	d = sqrt(x*x + y*y);
 	if (d < radius*M_SQRT1_2)  	/* Inside sphere */
 		z = sqrt(radius*radius - d*d);
@@ -132,7 +132,7 @@
 	ScrArea *sa= CTX_wm_area(C);
 	View3D *v3d= sa->spacedata.first;
 	ViewOpsData *vod= MEM_callocN(sizeof(ViewOpsData), "viewops data");
-	
+
 	/* store data */
 	op->customdata= vod;
 	vod->ar= CTX_wm_region(C);
@@ -142,17 +142,17 @@
 	vod->origx= vod->oldx= event->x;
 	vod->origy= vod->oldy= event->y;
 	vod->origkey= event->type;
-	
+
 	calctrackballvec(&vod->ar->winrct, event->x, event->y, vod->trackvec);
-	
+
 	initgrabz(v3d, -v3d->ofs[0], -v3d->ofs[1], -v3d->ofs[2]);
-	
+
 	vod->reverse= 1.0f;
 	if (v3d->persmat[2][1] < 0.0f)
 		vod->reverse= -1.0f;
-	
-}	
 
+}
+
 /* ************************** viewrotate **********************************/
 
 static const float thres = 0.93f; //cos(20 deg);
@@ -168,7 +168,7 @@
 {0.0, -1.0, 0.0, 0.0, 7, 1},      //bottom
 {0.5, -0.5, -0.5, -0.5, 3, 0},    //left
 {0.5, -0.5, 0.5, 0.5, 3, 1},      //right
-	
+
 	/* some more 45 deg snaps */
 {0.65328145027160645, -0.65328145027160645, 0.27059805393218994, 0.27059805393218994, 0, 0},
 {0.92387950420379639, 0.0, 0.0, 0.38268342614173889, 0, 0},
@@ -210,54 +210,54 @@
 {
 	View3D *v3d= vod->v3d;
 	int use_sel= 0;	/* XXX */
-	
+
 	v3d->view= 0; /* need to reset everytime because of view snapping */
-	
+
 	if (U.flag & USER_TRACKBALL) {
 		float phi, si, q1[4], dvec[3], newvec[3];
-		
+
 		calctrackballvec(&vod->ar->winrct, x, y, newvec);
-	
+
 		VecSubf(dvec, newvec, vod->trackvec);
-	
+
 		si= sqrt(dvec[0]*dvec[0]+ dvec[1]*dvec[1]+ dvec[2]*dvec[2]);
 		si/= (2.0*TRACKBALLSIZE);
-	
+
 		Crossf(q1+1, vod->trackvec, newvec);
 		Normalize(q1+1);
-		
+
 		/* Allow for rotation beyond the interval
 			* [-pi, pi] */
 		while (si > 1.0)
 			si -= 2.0;
-		
+
 		/* This relation is used instead of
 			* phi = asin(si) so that the angle
 			* of rotation is linearly proportional
 			* to the distance that the mouse is
 			* dragged. */
 		phi = si * M_PI / 2.0;
-		
+
 		si= sin(phi);
 		q1[0]= cos(phi);
 		q1[1]*= si;
 		q1[2]*= si;
-		q1[3]*= si;	
+		q1[3]*= si;
 		QuatMul(v3d->viewquat, q1, vod->oldquat);
-		
+
 		if (use_sel) {
 			/* compute the post multiplication quat, to rotate the offset correctly */
 			QUATCOPY(q1, vod->oldquat);
 			QuatConj(q1);
 			QuatMul(q1, q1, v3d->viewquat);
-			
+
 			QuatConj(q1); /* conj == inv for unit quat */
 			VECCOPY(v3d->ofs, vod->ofs);
 			VecSubf(v3d->ofs, v3d->ofs, vod->obofs);
 			QuatMulVecf(q1, v3d->ofs);
 			VecAddf(v3d->ofs, v3d->ofs, vod->obofs);
 		}
-	} 
+	}
 	else {
 		/* New turntable view code by John Aughey */
 		float si, phi, q1[4];
@@ -269,15 +269,15 @@
 			on other modeling programs. */
 		/* Perhaps this should be a configurable user parameter. */
 		const float sensitivity = 0.0035;
-		
+
 		/* Get the 3x3 matrix and its inverse from the quaternion */
 		QuatToMat3(v3d->viewquat, m);
 		Mat3Inv(m_inv,m);
-		
+
 		/* Determine the direction of the x vector (for rotating up and down) */
 		/* This can likely be compuated directly from the quaternion. */
 		Mat3MulVecfl(m_inv,xvec);
-		
+
 		/* Perform the up/down rotation */
 		phi = sensitivity * -(y - vod->oldy);
 		si = sin(phi);
@@ -286,21 +286,21 @@
 		q1[2] = si * xvec[1];
 		q1[3] = si * xvec[2];
 		QuatMul(v3d->viewquat, v3d->viewquat, q1);
-		
+
 		if (use_sel) {
 			QuatConj(q1); /* conj == inv for unit quat */
 			VecSubf(v3d->ofs, v3d->ofs, vod->obofs);
 			QuatMulVecf(q1, v3d->ofs);
 			VecAddf(v3d->ofs, v3d->ofs, vod->obofs);
 		}
-		
+
 		/* Perform the orbital rotation */
 		phi = sensitivity * vod->reverse * (x - vod->oldx);
 		q1[0] = cos(phi);
 		q1[1] = q1[2] = 0.0;
 		q1[3] = sin(phi);
 		QuatMul(v3d->viewquat, v3d->viewquat, q1);
-		
+
 		if (use_sel) {
 			QuatConj(q1);
 			VecSubf(v3d->ofs, v3d->ofs, vod->obofs);
@@ -308,28 +308,28 @@
 			VecAddf(v3d->ofs, v3d->ofs, vod->obofs);
 		}
 	}
-	
+
 	/* check for view snap */
 	if (ctrl){
 		int i;
 		float viewmat[3][3];
-		
-		
+
+
 		QuatToMat3(v3d->viewquat, viewmat);
-		
+
 		for (i = 0 ; i < 39; i++){
 			float snapmat[3][3];
 			float view = (int)snapquats[i][4];
 			float oposite_dir = (int)snapquats[i][5];
-			
+
 			QuatToMat3(snapquats[i], snapmat);
-			
+
 			if ((Inpf(snapmat[0], viewmat[0]) > thres) &&
 				(Inpf(snapmat[1], viewmat[1]) > thres) &&
 				(Inpf(snapmat[2], viewmat[2]) > thres)){
-				
+
 				QUATCOPY(v3d->viewquat, snapquats[i]);
-				
+
 				v3d->view = view;
 				if (view){
 					if (oposite_dir){
@@ -338,7 +338,7 @@
 						v3d->flag2 &= ~V3D_OPP_DIRECTION_NAME;
 					}
 				}
-				
+
 				break;
 			}
 		}
@@ -358,52 +358,52 @@
 		case MOUSEMOVE:
 			viewrotate_apply(vod, event->x, event->y, event->ctrl);
 			break;
-			
+
 		default:
 			if(event->type==vod->origkey && event->val==0) {
-				
+
 				MEM_freeN(vod);
 				op->customdata= NULL;
-				
+
 				return OPERATOR_FINISHED;
 			}
 	}
-	
+
 	return OPERATOR_RUNNING_MODAL;
 }
 
 static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
 	ViewOpsData *vod;
-	
+
 	/* makes op->customdata */
 	viewops_data(C, op, event);
 	vod= op->customdata;
-	
+
 	/* switch from camera view when: */
 	if(vod->v3d->persp != V3D_PERSP) {
-		
-		if (U.uiflag & USER_AUTOPERSP) 
+
+		if (U.uiflag & USER_AUTOPERSP)
 			vod->v3d->persp= V3D_PERSP;
 		else if(vod->v3d->persp==V3D_CAMOB)
 			vod->v3d->persp= V3D_PERSP;
 		ED_region_tag_redraw(vod->ar);
 	}
-	
+
 	/* add temp handler */
 	WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
-	
+
 	return OPERATOR_RUNNING_MODAL;
 }
 
 
 void ED_VIEW3D_OT_viewrotate(wmOperatorType *ot)
 {
-	
+
 	/* identifiers */
 	ot->name= "Rotate view";
 	ot->idname= "ED_VIEW3D_OT_viewrotate";
-	
+
 	/* api callbacks */
 	ot->invoke= viewrotate_invoke;
 	ot->modal= viewrotate_modal;
@@ -416,7 +416,7 @@
 {
 	if(vod->v3d->persp==V3D_CAMOB) {
 		float max= (float)MAX2(vod->ar->winx, vod->ar->winy);
-		
+
 		vod->v3d->camdx += (vod->oldx - x)/(max);
 		vod->v3d->camdy += (vod->oldy - y)/(max);
 		CLAMP(vod->v3d->camdx, -1.0f, 1.0f);
@@ -425,38 +425,38 @@
 	}
 	else {
 		float dvec[3];
-		
+
 		window_to_3d(vod->ar, vod->v3d, dvec, x-vod->oldx, y-vod->oldy);
 		VecAddf(vod->v3d->ofs, vod->v3d->ofs, dvec);
 	}
-	
+
 	vod->oldx= x;
 	vod->oldy= y;
-	
+
 	ED_region_tag_redraw(vod->ar);
 }
 
 
 static int viewmove_modal(bContext *C, wmOperator *op, wmEvent *event)
-{	
+{
 	ViewOpsData *vod= op->customdata;
-	
+
 	/* execute the events */
 	switch(event->type) {
 		case MOUSEMOVE:
 			viewmove_apply(vod, event->x, event->y);
 			break;
-			
+
 		default:
 			if(event->type==vod->origkey && event->val==0) {
-				
+
 				MEM_freeN(vod);
 				op->customdata= NULL;
-				
+
 				return OPERATOR_FINISHED;
 			}
 	}
-	
+
 	return OPERATOR_RUNNING_MODAL;
 }
 
@@ -464,21 +464,21 @@
 {
 	/* makes op->customdata */
 	viewops_data(C, op, event);
-	
+
 	/* add temp handler */
 	WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
-	
+
 	return OPERATOR_RUNNING_MODAL;
 }
 
 
 void ED_VIEW3D_OT_viewmove(wmOperatorType *ot)
 {
-	
+
 	/* identifiers */
 	ot->name= "Rotate view";
 	ot->idname= "ED_VIEW3D_OT_viewmove";
-	
+
 	/* api callbacks */
 	ot->invoke= viewmove_invoke;
 	ot->modal= viewmove_modal;
@@ -495,38 +495,38 @@
 		float tpos[3];
 		float new_dist;
 		short vb[2], mouseloc[2];
-		
+
 		mouseloc[0]= mx - ar->winrct.xmin;
 		mouseloc[1]= my - ar->winrct.ymin;
-		
+
 		/* find the current window width and height */
 		vb[0] = ar->winx;
 		vb[1] = ar->winy;
-		
+
 		tpos[0] = -v3d->ofs[0];
 		tpos[1] = -v3d->ofs[1];
 		tpos[2] = -v3d->ofs[2];
-		
+
 		/* Project cursor position into 3D space */
 		initgrabz(v3d, tpos[0], tpos[1], tpos[2]);
 		window_to_3d(ar, v3d, dvec, mouseloc[0]-vb[0]/2, mouseloc[1]-vb[1]/2);
-		
+
 		/* Calculate view target position for dolly */
 		tvec[0] = -(tpos[0] + dvec[0]);
 		tvec[1] = -(tpos[1] + dvec[1]);
 		tvec[2] = -(tpos[2] + dvec[2]);
-		
+
 		/* Offset to target position and dolly */
 		new_dist = v3d->dist * dfac;
-		
+
 		VECCOPY(v3d->ofs, tvec);
 		v3d->dist = new_dist;
-		
+
 		/* Calculate final offset */
 		dvec[0] = tvec[0] + dvec[0] * dfac;
 		dvec[1] = tvec[1] + dvec[1] * dfac;
 		dvec[2] = tvec[2] + dvec[2] * dfac;
-		
+
 		VECCOPY(v3d->ofs, dvec);
 	} else {
 		v3d->dist *= dfac;
@@ -545,13 +545,13 @@
 	else if(U.viewzoom==USER_ZOOM_SCALE) {
 		int ctr[2], len1, len2;
 		// method which zooms based on how far you move the mouse
-		
+
 		ctr[0] = (vod->ar->winrct.xmax + vod->ar->winrct.xmin)/2;
 		ctr[1] = (vod->ar->winrct.ymax + vod->ar->winrct.ymin)/2;
-		
+
 		len1 = (int)sqrt((ctr[0] - x)*(ctr[0] - x) + (ctr[1] - y)*(ctr[1] - y)) + 5;
 		len2 = (int)sqrt((ctr[0] - vod->origx)*(ctr[0] - vod->origx) + (ctr[1] - vod->origy)*(ctr[1] - vod->origy)) + 5;
-		
+
 		zfac = vod->dist0 * ((float)len2/len1) / vod->v3d->dist;
 	}
 	else {	/* USER_ZOOM_DOLLY */
@@ -560,14 +560,14 @@
 		zfac = vod->dist0 * (2.0*((len2/len1)-1.0) + 1.0) / vod->v3d->dist;
 	}
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list