[Bf-blender-cvs] [54abdf7] mathutils_bvhtree: misc docstring tweaks
Campbell Barton
noreply at git.blender.org
Wed Jul 15 18:04:40 CEST 2015
Commit: 54abdf758e08214bd04ccebdb3b5361679ebd0e3
Author: Campbell Barton
Date: Thu Jul 16 01:58:30 2015 +1000
Branches: mathutils_bvhtree
https://developer.blender.org/rB54abdf758e08214bd04ccebdb3b5361679ebd0e3
misc docstring tweaks
===================================================================
M source/blender/python/mathutils/mathutils_bvhtree.c
===================================================================
diff --git a/source/blender/python/mathutils/mathutils_bvhtree.c b/source/blender/python/mathutils/mathutils_bvhtree.c
index 4a19e0a..933e018 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.c
+++ b/source/blender/python/mathutils/mathutils_bvhtree.c
@@ -93,6 +93,26 @@ typedef struct PyBVHTree_Custom {
float epsilon;
} PyBVHTree_Custom;
+
+/* -------------------------------------------------------------------- */
+/* Docstring snippets */
+
+#define PYBVH_FIND_GENERIC_MAX_DIST_DOC \
+" :arg max_dist: Maximum distance threshold.\n" \
+" :type max_dist: float\n"
+
+#define PYBVH_FIND_GENERIC_RETURN_DOC \
+" :return: Returns a tuple (:class:`Vector` location, :class:`Vector` normal, int index, float distance),\n" \
+" index==-1 if no hit was found.\n" \
+" :rtype: :class:`tuple`\n"
+
+#define PYBVH_DM_TYPES_STR "'TESSFACE', 'POLY', 'EDGE', 'VERT'"
+
+#define PYBVH_MAX_DIST_STR "1.84467e+19"
+
+static const float max_dist_default = 1.844674352395373e+19f;
+
+
/* -------------------------------------------------------------------- */
/* Utility helper functions */
@@ -309,7 +329,7 @@ static int PyBVHTreeDerivedMesh__tp_init(PyBVHTree_DerivedMesh *self, PyObject *
success = true;
}
else {
- PyErr_Format(PyExc_ValueError, "'type' must be 'TESSFACE', 'POLY', 'VERT' or 'EDGE', not '%.200s'", type);
+ PyErr_Format(PyExc_ValueError,"'type' must be one of [" PYBVH_DM_TYPES_STR "], not '%.200s'", type);
success = false;
}
@@ -340,10 +360,8 @@ PyDoc_STRVAR(py_BVHTreeDerivedMesh_ray_cast_doc,
" :type ray_point: :class:`Vector`\n"
" :arg ray_direction: Direction of the ray in object space.\n"
" :type ray_direction: :class:`Vector`\n"
-" :arg ray_maxdist: Maximum distance of intersection.\n"
-" :type ray_maxdist: :float\n"
-" :return: Returns a tuple (:class:`Vector` location, :class:`Vector` normal, int index, float distance), index==-1 if no hit was found.\n"
-" :rtype: :class:`tuple`\n"
+PYBVH_FIND_GENERIC_MAX_DIST_DOC
+PYBVH_FIND_GENERIC_RETURN_DOC
);
static PyObject *py_BVHTreeDerivedMesh_ray_cast(PyBVHTree_DerivedMesh *self, PyObject *args)
{
@@ -389,16 +407,14 @@ static PyObject *py_BVHTreeDerivedMesh_ray_cast(PyBVHTree_DerivedMesh *self, PyO
}
PyDoc_STRVAR(py_BVHTreeDerivedMesh_find_nearest_doc,
-".. method:: find_nearest(point, max_dist=1.84467e+19)\n"
+".. method:: find_nearest(point, max_dist=" PYBVH_MAX_DIST_STR ")\n"
"\n"
" Find the nearest element to a point.\n"
"\n"
" :arg point: Find nearest element to this point.\n"
-" :type ray_start: :class:`Vector`\n"
-" :art max_dist: Maximum search distance\n"
-" :type max_dist: :float\n"
-" :return: Returns a tuple (:class:`Vector` location, :class:`Vector` normal, int index, float distance), index==-1 if no hit was found.\n"
-" :rtype: :class:`tuple`\n"
+" :type point: :class:`Vector`\n"
+PYBVH_FIND_GENERIC_MAX_DIST_DOC
+PYBVH_FIND_GENERIC_RETURN_DOC
);
static PyObject *py_BVHTreeDerivedMesh_find_nearest(PyBVHTree_DerivedMesh *self, PyObject *args)
{
@@ -409,7 +425,7 @@ static PyObject *py_BVHTreeDerivedMesh_find_nearest(PyBVHTree_DerivedMesh *self,
PyObject *py_point;
float point[3];
- float max_dist = 1.844674352395373e+19f;
+ float max_dist = max_dist_default;
BVHTreeNearest nearest;
if (!PyArg_ParseTuple(args, (char *)"O|f:find_nearest", &py_point, &max_dist))
@@ -450,8 +466,8 @@ PyDoc_STRVAR(py_BVHTreeDerivedMesh_doc,
"\n"
" :arg object: Mesh object.\n"
" :type object: :class:`Object`\n"
-" :art type: Maximum search distance\n"
-" :type type: :string in ['POLYS', 'FACES', 'VERTS', 'EDGES']\n"
+" :art type: Type of geometry to use for this tree.\n"
+" :type type: :string in [" PYBVH_DM_TYPES_STR "]\n"
);
PyTypeObject PyBVHTreeDerivedMesh_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
@@ -550,18 +566,16 @@ static void PyBVHTreeBMesh__tp_dealloc(PyBVHTree_BMesh *self)
}
PyDoc_STRVAR(py_BVHTreeBMesh_ray_cast_doc,
-".. method:: ray_cast(ray_start, ray_end)\n"
+".. method:: ray_cast(co, direction)\n"
"\n"
" Cast a ray onto the mesh.\n"
"\n"
-" :arg ray_point: Start location of the ray in object space.\n"
-" :type ray_point: :class:`Vector`\n"
-" :arg ray_direction: Direction of the ray in object space.\n"
-" :type ray_direction: :class:`Vector`\n"
-" :arg ray_maxdist: Maximum distance of intersection.\n"
-" :type ray_maxdist: :float\n"
-" :return: Returns a tuple (:class:`Vector` location, :class:`Vector` normal, int index, float distance), index==-1 if no hit was found.\n"
-" :rtype: :class:`tuple`\n"
+" :arg co: Start location of the ray in object space.\n"
+" :type co: :class:`Vector`\n"
+" :arg direction: Direction of the ray in object space.\n"
+" :type direction: :class:`Vector`\n"
+PYBVH_FIND_GENERIC_MAX_DIST_DOC
+PYBVH_FIND_GENERIC_RETURN_DOC
);
static PyObject *py_BVHTreeBMesh_ray_cast(PyBVHTree_BMesh *self, PyObject *args)
{
@@ -604,16 +618,14 @@ static PyObject *py_BVHTreeBMesh_ray_cast(PyBVHTree_BMesh *self, PyObject *args)
}
PyDoc_STRVAR(py_BVHTreeBMesh_find_nearest_doc,
-".. method:: find_nearest(point, max_dist=1.84467e+19)\n"
+".. method:: find_nearest(co, max_dist=" PYBVH_MAX_DIST_STR ")\n"
"\n"
" Find the nearest element to a point.\n"
"\n"
-" :arg point: Find nearest element to this point.\n"
-" :type ray_start: :class:`Vector`\n"
-" :art max_dist: Maximum search distance\n"
-" :type max_dist: :float\n"
-" :return: Returns a tuple (:class:`Vector` location, :class:`Vector` normal, int index, float distance), index==-1 if no hit was found.\n"
-" :rtype: :class:`tuple`\n"
+" :arg co: Find nearest element to this point.\n"
+" :type co: :class:`Vector`\n"
+PYBVH_FIND_GENERIC_MAX_DIST_DOC
+PYBVH_FIND_GENERIC_RETURN_DOC
);
static PyObject *py_BVHTreeBMesh_find_nearest(PyBVHTree_BMesh *self, PyObject *args)
{
@@ -623,7 +635,7 @@ static PyObject *py_BVHTreeBMesh_find_nearest(PyBVHTree_BMesh *self, PyObject *a
PyObject *py_point;
float point[3];
- float max_dist = 1.844674352395373e+19f;
+ float max_dist = max_dist_default;
if (!PyArg_ParseTuple(args, (char *)"O|f:find_nearest", &py_point, &max_dist))
{
@@ -867,18 +879,16 @@ static void bvhtree_custom_raycast_cb(void *userdata, int index, const BVHTreeRa
}
PyDoc_STRVAR(py_BVHTreeCustom_ray_cast_doc,
-".. method:: ray_cast(ray_start, ray_end)\n"
+".. method:: ray_cast(co, direction)\n"
"\n"
" Cast a ray onto the mesh.\n"
"\n"
-" :arg ray_point: Start location of the ray in object space.\n"
-" :type ray_point: :class:`Vector`\n"
-" :arg ray_direction: Direction of the ray in object space.\n"
-" :type ray_direction: :class:`Vector`\n"
-" :arg ray_maxdist: Maximum distance of intersection.\n"
-" :type ray_maxdist: :float\n"
-" :return: Returns a tuple (:class:`Vector` location, :class:`Vector` normal, int index, float distance), index==-1 if no hit was found.\n"
-" :rtype: :class:`tuple`\n"
+" :arg co: Start location of the ray in object space.\n"
+" :type co: :class:`Vector`\n"
+" :arg direction: Direction of the ray in object space.\n"
+" :type direction: :class:`Vector`\n"
+PYBVH_FIND_GENERIC_MAX_DIST_DOC
+PYBVH_FIND_GENERIC_RETURN_DOC
);
static PyObject *py_BVHTreeCustom_ray_cast(PyBVHTree_Custom *self, PyObject *args)
{
@@ -941,16 +951,14 @@ static void bvhtree_custom_nearest_point_cb(void *userdata, int index, const flo
}
PyDoc_STRVAR(py_BVHTreeCustom_find_nearest_doc,
-".. method:: find_nearest(point, max_dist=1.84467e+19)\n"
+".. method:: find_nearest(point, max_dist=" PYBVH_MAX_DIST_STR ")\n"
"\n"
" Find the nearest element to a point.\n"
"\n"
" :arg point: Find nearest element to this point.\n"
" :type ray_start: :class:`Vector`\n"
-" :art max_dist: Maximum search distance\n"
-" :type max_dist: :float\n"
-" :return: Returns a tuple (:class:`Vector` location, :class:`Vector` normal, int index, float distance), index==-1 if no hit was found.\n"
-" :rtype: :class:`tuple`\n"
+PYBVH_FIND_GENERIC_MAX_DIST_DOC
+PYBVH_FIND_GENERIC_RETURN_DOC
);
static PyObject *py_BVHTreeCustom_find_nearest(PyBVHTree_Custom *self, PyObject *args)
{
@@ -958,7 +966,7 @@ static PyObject *py_BVHTreeCustom_find_nearest(PyBVHTree_Custom *self, PyObject
PyObject *py_point;
float point[3];
- float max_dist = 1.844674352395373e+19f;
+ float max_dist = max_dist_default;
BVHTreeNearest nearest;
if (!PyArg_ParseTuple(args, (char *)"O|f:find_nearest", &py_point, &max_dist))
More information about the Bf-blender-cvs
mailing list