[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18967] branches/blender2.5/blender/source /blender/editors: 2.5

Ton Roosendaal ton at blender.org
Sat Feb 14 14:07:09 CET 2009


Revision: 18967
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18967
Author:   ton
Date:     2009-02-14 14:07:09 +0100 (Sat, 14 Feb 2009)

Log Message:
-----------
2.5

View3D: snap menu (SHIFT+S) back.

All options are own operators, a (temp?) menu collects them all.
Note that the operators have a full name, for the menu it seems
too much; still I'd prefer a way to name operators in a way
it fits everywhere. That will make a unified translation system
possible for example.

Also: this code was needed to get 'center view' (numpad dot) in
editmode to work.

Last note; it uses old transform code to gather vertex info.
This is fully local to this C file, and quite simple to replace 
in future with new transform.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/ED_mesh.h
    branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_edit.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_intern.h
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_snap.c

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_mesh.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_mesh.h	2009-02-14 11:58:52 UTC (rev 18966)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_mesh.h	2009-02-14 13:07:09 UTC (rev 18967)
@@ -120,11 +120,12 @@
 void		EM_select_flush(struct EditMesh *em);
 void		EM_convertsel(struct EditMesh *em, short oldmode, short selectmode);
 void		EM_validate_selections(struct EditMesh *em);
-			
+
 			/* exported to transform */
 int			EM_get_actSelection(struct EditMesh *em, struct EditSelection *ese);
 void		EM_editselection_normal(float *normal, struct EditSelection *ese);
 void		EM_editselection_plane(float *plane, struct EditSelection *ese);
+void		EM_editselection_center(float *center, struct EditSelection *ese);			
 
 struct UvVertMap *EM_make_uv_vert_map(struct EditMesh *em, int selected, int do_face_idx_array, float *limit);
 struct UvMapVert *EM_get_uv_map_vert(struct UvVertMap *vmap, unsigned int v);

Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c	2009-02-14 11:58:52 UTC (rev 18966)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c	2009-02-14 13:07:09 UTC (rev 18967)
@@ -324,6 +324,7 @@
 	switch(wmn->category) {
 		case NC_SCENE:
 			switch(wmn->data) {
+				case ND_TRANSFORM:
 				case ND_FRAME:
 				case ND_OB_ACTIVE:
 				case ND_OB_SELECT:

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	2009-02-14 11:58:52 UTC (rev 18966)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_edit.c	2009-02-14 13:07:09 UTC (rev 18967)
@@ -956,7 +956,7 @@
 
 
 	if(obedit) {
-// XXX		ok = minmax_verts(min, max);	/* only selected */
+		ok = minmax_verts(obedit, min, max);	/* only selected */
 	}
 	else if(ob && (ob->flag & OB_POSEMODE)) {
 		if(ob->pose) {
@@ -1042,6 +1042,7 @@
 
 	return OPERATOR_FINISHED;
 }
+
 void VIEW3D_OT_viewcenter(wmOperatorType *ot)
 {
 

Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_intern.h	2009-02-14 11:58:52 UTC (rev 18966)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_intern.h	2009-02-14 13:07:09 UTC (rev 18967)
@@ -144,6 +144,17 @@
 
 void view3d_buttons_area_defbuts(const struct bContext *C, ARegion *ar);
 
+/* view3d_snap.c */
+int minmax_verts(Object *obedit, float *min, float *max);
+
+void VIEW3D_OT_snap_selected_to_grid(struct wmOperatorType *ot);
+void VIEW3D_OT_snap_selected_to_cursor(struct wmOperatorType *ot);
+void VIEW3D_OT_snap_selected_to_center(struct wmOperatorType *ot);
+void VIEW3D_OT_snap_cursor_to_grid(struct wmOperatorType *ot);
+void VIEW3D_OT_snap_cursor_to_selected(struct wmOperatorType *ot);
+void VIEW3D_OT_snap_cursor_to_active(struct wmOperatorType *ot);
+void VIEW3D_OT_snap_menu(struct wmOperatorType *ot);
+
 /* space_view3d.c */
 ARegion *view3d_has_buttons_region(ScrArea *sa);
 

Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c	2009-02-14 11:58:52 UTC (rev 18966)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c	2009-02-14 13:07:09 UTC (rev 18967)
@@ -92,6 +92,14 @@
 	WM_operatortype_append(VIEW3D_OT_editmesh_face_toolbox);
 	WM_operatortype_append(VIEW3D_OT_properties);
 	WM_operatortype_append(VIEW3D_OT_localview);
+	
+	WM_operatortype_append(VIEW3D_OT_snap_selected_to_grid);
+	WM_operatortype_append(VIEW3D_OT_snap_selected_to_cursor);
+	WM_operatortype_append(VIEW3D_OT_snap_selected_to_center);
+	WM_operatortype_append(VIEW3D_OT_snap_cursor_to_grid);
+	WM_operatortype_append(VIEW3D_OT_snap_cursor_to_selected);
+	WM_operatortype_append(VIEW3D_OT_snap_cursor_to_active);
+	WM_operatortype_append(VIEW3D_OT_snap_menu);
 		
 	transform_operatortypes();
 }
@@ -181,6 +189,8 @@
 	
 	WM_keymap_add_item(keymap, "VIEW3D_OT_set_camera_to_view", PAD0, KM_PRESS, KM_ALT|KM_CTRL, 0);
 	
+	WM_keymap_add_item(keymap, "VIEW3D_OT_snap_menu", SKEY, KM_PRESS, KM_SHIFT, 0);
+	
 	/* radial control */
 	RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
 	RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);

Copied: branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_snap.c (from rev 18965, trunk/blender/source/blender/src/edit.c)
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_snap.c	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_snap.c	2009-02-14 13:07:09 UTC (rev 18967)
@@ -0,0 +1,1148 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <math.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_action_types.h"
+#include "DNA_armature_types.h"
+#include "DNA_curve_types.h"
+#include "DNA_group_types.h"
+#include "DNA_ipo_types.h"
+#include "DNA_lattice_types.h"
+#include "DNA_meta_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_object_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_space_types.h"
+#include "DNA_view3d_types.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+#include "BLI_editVert.h"
+#include "BLI_linklist.h"
+
+#include "BKE_action.h"
+#include "BKE_anim.h"
+#include "BKE_context.h"
+#include "BKE_armature.h"
+#include "BKE_curve.h"
+#include "BKE_depsgraph.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_displist.h"
+#include "BKE_global.h"
+#include "BKE_lattice.h"
+#include "BKE_mesh.h"
+#include "BKE_modifier.h"
+#include "BKE_object.h"
+#include "BKE_utildefines.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "UI_interface.h"
+
+#include "ED_anim_api.h"
+#include "ED_armature.h"
+#include "ED_mesh.h"
+#include "ED_screen.h"
+#include "ED_view3d.h"
+
+#include "view3d_intern.h"
+
+
+/* ************************************************** */
+/* ********************* old transform stuff ******** */
+/* *********** will get replaced with new transform * */
+/* ************************************************** */
+
+typedef struct TransVert {
+	float *loc;
+	float oldloc[3], fac;
+	float *val, oldval;
+	int flag;
+	float *nor;
+} TransVert;
+
+static TransVert *transvmain=NULL;
+static int tottrans= 0;
+
+/* copied from editobject.c, now uses (almost) proper depgraph */
+static void special_transvert_update(Scene *scene, Object *obedit)
+{
+	
+	if(obedit) {
+		
+		DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+		
+		if(obedit->type==OB_MESH) {
+			Mesh *me= obedit->data;
+			recalc_editnormals(me->edit_mesh);	// does face centers too
+		}
+		else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
+			Curve *cu= obedit->data;
+			Nurb *nu= cu->editnurb->first;
+			
+			while(nu) {
+				test2DNurb(nu);
+				testhandlesNurb(nu); /* test for bezier too */
+				nu= nu->next;
+			}
+		}
+		else if(obedit->type==OB_ARMATURE){
+			bArmature *arm= obedit->data;
+			EditBone *ebo;
+			TransVert *tv= transvmain;
+			int a=0;
+			
+			/* Ensure all bone tails are correctly adjusted */
+			for (ebo= arm->edbo->first; ebo; ebo=ebo->next) {
+				/* adjust tip if both ends selected */
+				if ((ebo->flag & BONE_ROOTSEL) && (ebo->flag & BONE_TIPSEL)) {
+					if (tv) {
+						float diffvec[3];
+						
+						VecSubf(diffvec, tv->loc, tv->oldloc);
+						VecAddf(ebo->tail, ebo->tail, diffvec);
+						
+						a++;
+						if (a<tottrans) tv++;
+					}
+				}
+			}
+			
+			/* Ensure all bones are correctly adjusted */
+			for (ebo= arm->edbo->first; ebo; ebo=ebo->next) {
+				if ((ebo->flag & BONE_CONNECTED) && ebo->parent){
+					/* If this bone has a parent tip that has been moved */
+					if (ebo->parent->flag & BONE_TIPSEL){
+						VECCOPY (ebo->head, ebo->parent->tail);
+					}
+					/* If this bone has a parent tip that has NOT been moved */
+					else{
+						VECCOPY (ebo->parent->tail, ebo->head);
+					}
+				}
+			}
+			if(arm->flag & ARM_MIRROR_EDIT) 
+				transform_armature_mirror_update(obedit);
+		}
+		else if(obedit->type==OB_LATTICE) {
+			Lattice *lt= obedit->data;
+			
+			if(lt->editlatt->flag & LT_OUTSIDE) 
+				outside_lattice(lt->editlatt);
+		}
+	}
+}
+
+/* copied from editobject.c, needs to be replaced with new transform code still */
+/* mode: 1 = proportional, 2 = all joints (for bones only) */
+static void make_trans_verts(Object *obedit, float *min, float *max, int mode)	
+{
+	Nurb *nu;
+	BezTriple *bezt;
+	BPoint *bp;
+	TransVert *tv=NULL;
+	MetaElem *ml;
+	EditVert *eve;
+	EditBone	*ebo;
+	float total, center[3], centroid[3];
+	int a;
+
+	tottrans= 0; // global!
+	
+	INIT_MINMAX(min, max);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list