[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38512] trunk/blender/source/blender/ makesrna/intern/rna_object_api.c: update to patch from Andrew Hale - obj. closest_point_ob_mesh() now takes an optional max_dist argument.
Campbell Barton
ideasman42 at gmail.com
Tue Jul 19 17:21:21 CEST 2011
Revision: 38512
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38512
Author: campbellbarton
Date: 2011-07-19 15:21:21 +0000 (Tue, 19 Jul 2011)
Log Message:
-----------
update to patch from Andrew Hale - obj.closest_point_ob_mesh() now takes an optional max_dist argument.
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/intern/rna_object_api.c
Modified: trunk/blender/source/blender/makesrna/intern/rna_object_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_object_api.c 2011-07-19 15:07:29 UTC (rev 38511)
+++ trunk/blender/source/blender/makesrna/intern/rna_object_api.c 2011-07-19 15:21:21 UTC (rev 38512)
@@ -45,6 +45,8 @@
// #include "ED_mesh.h"
+#include "BLI_math.h"
+
#ifdef RNA_RUNTIME
#include "BKE_main.h"
@@ -64,8 +66,6 @@
#include "BKE_mball.h"
#include "BKE_modifier.h"
-#include "BLI_math.h"
-
#include "DNA_mesh_types.h"
#include "DNA_scene_types.h"
#include "DNA_meshdata_types.h"
@@ -415,7 +415,7 @@
*index= -1;
}
-void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float point_co[3], float n_location[3], float n_normal[3], int *index)
+void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float point_co[3], float max_dist, float n_location[3], float n_normal[3], int *index)
{
BVHTreeFromMesh treeData= {NULL};
@@ -435,7 +435,7 @@
BVHTreeNearest nearest;
nearest.index = -1;
- nearest.dist = FLT_MAX;
+ nearest.dist = max_dist * max_dist;
if(BLI_bvhtree_find_nearest(treeData.tree, point_co, &nearest, treeData.nearest_callback, &treeData) != -1) {
copy_v3_v3(n_location, nearest.co);
@@ -541,9 +541,10 @@
RNA_def_function_ui_description(func, "Find the nearest point on the object.");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
- /* ray start and end */
+ /* location of point for test and max distance */
parm= RNA_def_float_vector(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm= RNA_def_float(func, "max_dist", sqrt(FLT_MAX), 0.0, FLT_MAX, "", "", 0.0, FLT_MAX);
/* return location and normal */
parm= RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "The location on the object closest to the point", -1e4, 1e4);
@@ -553,7 +554,7 @@
RNA_def_property_flag(parm, PROP_THICK_WRAP);
RNA_def_function_output(func, parm);
- parm= RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no intersection is found.", 0, 0);
+ parm= RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no closest point is found.", 0, 0);
RNA_def_function_output(func, parm);
/* View */
More information about the Bf-blender-cvs
mailing list