[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50057] branches/soc-2012-sushi/source/ blender: Parallel, and Planar snapping implemented, along with some fairly major
luke frisken
l.frisken at gmail.com
Mon Aug 20 20:45:33 CEST 2012
Revision: 50057
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50057
Author: lfrisken
Date: 2012-08-20 18:45:33 +0000 (Mon, 20 Aug 2012)
Log Message:
-----------
Parallel, and Planar snapping implemented, along with some fairly major
work on SnapSystem. More to come in the comming weeks!
GSOC 2012 Precision Modelling tools
Modified Paths:
--------------
branches/soc-2012-sushi/source/blender/blenkernel/BKE_bvhutils.h
branches/soc-2012-sushi/source/blender/blenkernel/BKE_snap.h
branches/soc-2012-sushi/source/blender/blenkernel/intern/bvhutils.c
branches/soc-2012-sushi/source/blender/blenkernel/intern/snap.c
branches/soc-2012-sushi/source/blender/editors/transform/transform.c
branches/soc-2012-sushi/source/blender/editors/transform/transform.h
branches/soc-2012-sushi/source/blender/editors/transform/transform_snap.c
branches/soc-2012-sushi/source/blender/makesdna/DNA_scene_types.h
branches/soc-2012-sushi/source/blender/makesrna/intern/rna_scene.c
Modified: branches/soc-2012-sushi/source/blender/blenkernel/BKE_bvhutils.h
===================================================================
--- branches/soc-2012-sushi/source/blender/blenkernel/BKE_bvhutils.h 2012-08-20 17:31:03 UTC (rev 50056)
+++ branches/soc-2012-sushi/source/blender/blenkernel/BKE_bvhutils.h 2012-08-20 18:45:33 UTC (rev 50057)
@@ -109,6 +109,7 @@
*/
float bvhtree_ray_tri_intersection(const BVHTreeRay *ray, const float m_dist, const float v0[3], const float v1[3], const float v2[3]);
float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const float v2[3], const float p[3], int *v, int *e, float nearest[3]);
+float sphereray_tri_intersection(const BVHTreeRay *ray, float radius, const float m_dist, const float v0[3], const float v1[3], const float v2[3]);
/*
* BVHCache
Modified: branches/soc-2012-sushi/source/blender/blenkernel/BKE_snap.h
===================================================================
--- branches/soc-2012-sushi/source/blender/blenkernel/BKE_snap.h 2012-08-20 17:31:03 UTC (rev 50056)
+++ branches/soc-2012-sushi/source/blender/blenkernel/BKE_snap.h 2012-08-20 18:45:33 UTC (rev 50057)
@@ -1,3 +1,26 @@
+/*
+ * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Luke Frisken 2012
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+
#ifndef __BKE_SNAP_H__
#define __BKE_SNAP_H__
@@ -26,14 +49,38 @@
SNAPSYSTEM_MODE_SELECT_NOT_OBEDIT = 2
}SnapSystem_mode_select;
+typedef enum{
+ SNAPSYSTEM_STATE_SNAPPING,
+ SNAPSYSTEM_STATE_INIT_SNAP,
+ SNAPSYSTEM_STATE_IDLE
+}SnapSystem_state;
+
+/*This function creates a new instance of the snapping system*/
+/*callback_data: is the data to be used by the code using the snapping system (e.g transform)
+ when the callbacks are called by snapsystem.
+
+ update_callback: gets called when the snapping system has not yet recieved confirmation from the user
+ of the chosen snap point, but there is a temporary snap_point available for providing realtime feedback
+ to the user of their actions when moving the mouse. In the case of transform, this means the geometry
+ moves towards the snap point without permenantly being applied.
+
+ finish_callback: same as update_callback, but the snap_point is to be applied this time.
+
+ cancel_callback: tells the code using the snapsystem that the current snapsystem snap search has been cancelled.
+
+ nofeedback_callback: will probably be removed/changed/refactored soon.
+ */
+/*The return value pointer to SnapSystem, when finished requires the code using the system to call SnapSystem_free
+ on it to free allocated data within the system*/
SnapSystem* SnapSystem_create( Scene* scene, View3D* v3d, ARegion* ar, Object* obedit, bContext* C,
void* callback_data,
- void (*update_callback)(void* callback_data, SnapPoint sp),
- void (*finish_callback)(void* callback_data, SnapPoint sp),
- void (*cancel_callback)(void* callback_data));
+ void (*update_callback)(SnapSystem *ssystem, void* callback_data, SnapPoint sp),
+ void (*nofeedback_callback)(SnapSystem *ssystem, void* callback_data),
+ void (*finish_callback)(SnapSystem *ssystem, void* callback_data, SnapPoint sp),
+ void (*cancel_callback)(SnapSystem *ssystem, void* callback_data));
void SnapSystem_test_run(SnapSystem* ssystem);
-void SnapSystem_reset_ob_list(SnapSystem* ssystem);
+void SnapSystem_reset_ob_list(SnapSystem* ssystem); //reset the list of objects the snapsystem uses for snapping
void SnapSystem_evaluate_stack(SnapSystem* ssystem);
void SnapSystem_find_snap(SnapSystem* ssystem);
void SnapSystem_pick_snap(SnapSystem* ssystem);
@@ -41,7 +88,15 @@
Object* SnapSystem_get_ob(SnapSystem* ssystem, int index);
void SnapSystem_set_mode_select(SnapSystem* ssystem, SnapSystem_mode_select mode_select);
int SnapSystem_get_retval(SnapSystem* ssystem);
+bContext* SnapSystem_get_C(SnapSystem* ssystem);
+SnapSystem_state SnapSystem_get_state(SnapSystem* ssystem);
+
+/*This function handles the events of the snapsystem, and returns a 1 if the event has been
+ handled (and consumed) by the snapsystem*/
int SnapSystem_Event(SnapSystem* ssystem, wmEvent* event);
+/*This function draws all the currently active snaps within the snapsystem*/
+void SnapSystem_draw(SnapSystem* ssystem);
+
void SnapSystem_reset_snappoint(SnapSystem* ssystem);
void SnapSystem_clear_pick(SnapSystem* ssystem);
void SnapSystem_reset(SnapSystem* ssystem);
@@ -68,7 +123,7 @@
typedef enum{
SNAPMESH_TYPE_VERTEX,
SNAPMESH_TYPE_FACE,
- SNAPMESH_TYPE_FACE_PLANE,
+ SNAPMESH_TYPE_PLANAR,
SNAPMESH_TYPE_EDGE,
SNAPMESH_TYPE_EDGE_MIDPOINT,
SNAPMESH_TYPE_EDGE_PARALLEL
@@ -80,6 +135,29 @@
SNAPMESH_DAT_face
}SnapMesh_data_array_type;
+/*This struct provides a storage of face + verts in one place for using
+ as return geometry in face picking, and gets used for planar snapping*/
+typedef struct{
+ MFace *face;
+ MVert *verts;
+ int nverts;
+ float no[3];
+}MeshData_pickface;
+
+/*Return data type for SnapMesh class*/
+typedef enum{
+ SNAPMESH_RET_DAT_vert_index,
+ SNAPMESH_RET_DAT_edge_index,
+ SNAPMESH_RET_DAT_pface //see MeshData_pickface struct
+}SnapMesh_ret_data_type;
+
+/*Flags for use in VertCheck or EdgeCheck or FaceCheck MeshData functions.*/
+typedef enum{
+ MESHDATA_CHECK_NONE = 0,
+ MESHDATA_CHECK_HIDDEN = 1,
+ MESHDATA_CHECK_SELECTED = 2
+}MeshData_check;
+
void Snap_run(Snap* s);
void Snap_free(Snap* s);
@@ -90,10 +168,11 @@
Snap* SnapMesh_create( void* mesh_data,
SnapMesh_data_type data_type,
- int free_mesh_data,
+ int free_mesh_data,
+ MeshData_check check,
SnapMesh_type sm_type,
Scene *scene, Object *ob, View3D *v3d, ARegion *ar, bContext *C, int mval[2]);
+void SnapMesh_draw(Snap *sm);
-
#endif // __BKE_SNAP_H__
Modified: branches/soc-2012-sushi/source/blender/blenkernel/intern/bvhutils.c
===================================================================
--- branches/soc-2012-sushi/source/blender/blenkernel/intern/bvhutils.c 2012-08-20 17:31:03 UTC (rev 50056)
+++ branches/soc-2012-sushi/source/blender/blenkernel/intern/bvhutils.c 2012-08-20 18:45:33 UTC (rev 50057)
@@ -57,7 +57,7 @@
return FLT_MAX;
}
-static float sphereray_tri_intersection(const BVHTreeRay *ray, float radius, const float m_dist, const float v0[3], const float v1[3], const float v2[3])
+float sphereray_tri_intersection(const BVHTreeRay *ray, float radius, const float m_dist, const float v0[3], const float v1[3], const float v2[3])
{
float idist;
Modified: branches/soc-2012-sushi/source/blender/blenkernel/intern/snap.c
===================================================================
--- branches/soc-2012-sushi/source/blender/blenkernel/intern/snap.c 2012-08-20 17:31:03 UTC (rev 50056)
+++ branches/soc-2012-sushi/source/blender/blenkernel/intern/snap.c 2012-08-20 18:45:33 UTC (rev 50057)
@@ -1,3 +1,25 @@
+/*
+ * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Luke Frisken 2012
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
#include "BKE_snap.h"
#include "BKE_mesh.h"
#include "BKE_tessmesh.h"
@@ -28,10 +50,14 @@
#include "BLI_math_vector.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
+#include "BLI_kdopbvh.h"
+#include "BLI_math_geom.h"
#include "UI_resources.h"
#include "transform.h"
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
#include <stdio.h>
#include <stdlib.h>
@@ -40,6 +66,7 @@
#include <assert.h>
//#define DEBUG_SNAP
+
/* -- PROTOTYPES -- */
typedef struct MeshData MeshData;
typedef struct SnapStack SnapStack;
@@ -56,29 +83,79 @@
void SnapStack_reset(SnapStack* sstack);
void SnapStack_free(SnapStack*);
void Snap_draw_default(Snap *s);
+void SnapMesh_draw_planar(Snap *sm);
+void SnapMesh_draw_edge_parallel(Snap *sm);
void SnapMesh_run(Snap *sm);
-void SnapMesh_free(Snap* sm);
+void SnapMesh_free(Snap *sm);
+void MeshData_pickface_free(MeshData_pickface *pface);
+MeshData_pickface* MeshData_pickface_create(MFace *face, MVert *verts, int nverts, float *no);
Snap_type Snap_getType(Snap* s);
-void SnapPoint_deepcopy(SnapPoint* out, SnapPoint* in){
- copy_v3_v3(out->location, in->location);
- copy_v3_v3(out->normal, in->normal);
- out->r_depth = in->r_depth;
- out->r_dist = in->r_dist;
-}
+/* -- STRUCTS and ENUMS -- */
+typedef enum{
+ SNAP_ISECT_TYPE_GEOMETRY,
+ SNAP_ISECT_TYPE_POINT
+}SnapIsect_type;
+struct SnapIsect{
+ SnapIsect_type type;
+ Snap* isect_geom; //a new snap containing the snap geometry of the intersection.
+ SnapPoint isect_point; //for use if the intersection is a single point (isect_type == SNAP_ISECT_TYPE_POINT)
+};
+
+struct Snap{
+ Snap_type s_type;
+ int snap_found; //boolean whether snap point has been found
+ SnapPoint snap_point;
+ SnapPoint* closest_point; //previously calculated closest point to mouse and screen.
+ Snap* pick; //previously calculated snap to use as a picking point in modes such as parallel snap and planar snap
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list