Commit: fd18aac25d17948bc287b589505fecbfc3f4b7c3
Author: Lukas Tönne
Date:   Sun Dec 28 15:48:18 2014 +0100
Branches: mathutils_bvhtree
https://developer.blender.org/rBfd18aac25d17948bc287b589505fecbfc3f4b7c3

Simplified dm_tessface_to_poly_index, no need to keep two version of
this around.

===================================================================

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 73ce4ff..8e9bb38 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.c
+++ b/source/blender/python/mathutils/mathutils_bvhtree.c
@@ -91,7 +91,7 @@ static bool parse_vector(PyObject *vec, float value[3])
 
 static int dm_tessface_to_poly_index(DerivedMesh *dm, int tessface_index)
 {
-       if (tessface_index != ORIGINDEX_NONE) {
+       if (tessface_index != ORIGINDEX_NONE && tessface_index < 
dm->getNumTessFaces(dm)) {
                /* double lookup */
                const int *index_mf_to_mpoly;
                if ((index_mf_to_mpoly = dm->getTessFaceDataArray(dm, 
CD_ORIGINDEX))) {
@@ -103,15 +103,6 @@ static int dm_tessface_to_poly_index(DerivedMesh *dm, int 
tessface_index)
        return ORIGINDEX_NONE;
 }
 
-/* does additional range check for tessface_index */
-static int dm_tessface_to_poly_index_safe(DerivedMesh *dm, int tessface_index)
-{
-       if (tessface_index < dm->getNumTessFaces(dm))
-               return dm_tessface_to_poly_index(dm, tessface_index);
-       
-       return ORIGINDEX_NONE;
-}
-
 static PyObject *bvhtree_ray_hit_to_py(const float co[3], const float no[3], 
int index, float dist)
 {
        PyObject *py_retval = PyTuple_New(4);
@@ -324,7 +315,7 @@ static PyObject 
*py_DerivedMeshBVHTree_ray_cast(PyDerivedMeshBVHTree *self, PyOb
                                         meshdata->raycast_callback, meshdata) 
!= -1)
                {
                        if (hit.dist <= ray_len) {
-                               int ret_index = use_poly_index ? 
dm_tessface_to_poly_index_safe(ob->derivedFinal, hit.index) : hit.index;
+                               int ret_index = use_poly_index ? 
dm_tessface_to_poly_index(ob->derivedFinal, hit.index) : hit.index;
                                return bvhtree_ray_hit_to_py(hit.co, hit.no, 
ret_index, hit.dist);
                        }
                }
@@ -381,7 +372,7 @@ static PyObject 
*py_DerivedMeshBVHTree_find_nearest(PyDerivedMeshBVHTree *self,
                if (BLI_bvhtree_find_nearest(meshdata->tree, point, &nearest,
                                             meshdata->nearest_callback, 
meshdata) != -1)
                {
-                       int ret_index = use_poly_index ? 
dm_tessface_to_poly_index_safe(ob->derivedFinal, nearest.index) : nearest.index;
+                       int ret_index = use_poly_index ? 
dm_tessface_to_poly_index(ob->derivedFinal, nearest.index) : nearest.index;
                        return bvhtree_nearest_to_py(nearest.co, nearest.no, 
ret_index, nearest.dist_sq);
                }
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to