Commit: eea25893d4588cf778d478a3641e62b44ed1da3f
Author: Campbell Barton
Date:   Tue Jul 28 11:10:54 2015 +1000
Branches: mathutils_bvhtree
https://developer.blender.org/rBeea25893d4588cf778d478a3641e62b44ed1da3f

Cleanup: ws & redundant 'struct'

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

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 66d3337..9f7ac5c 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.c
+++ b/source/blender/python/mathutils/mathutils_bvhtree.c
@@ -84,10 +84,10 @@ typedef struct BVHTriangle {
 typedef struct PyBVHTree_Custom {
        PyBVHTree base;
        /* geometry data */
-       struct BVHTree *tree;
+       BVHTree *tree;
        
-       struct BVHVertex *vert_array;
-       struct BVHTriangle *tri_array;
+       BVHVertex *vert_array;
+       BVHTriangle *tri_array;
        int totvert, tottri;
        
        float epsilon;
@@ -123,7 +123,7 @@ static DerivedMesh *bvh_get_derived_mesh(
 {
        /* we only need minimum mesh data for topology and vertex locations */
        CustomDataMask mask = CD_MASK_BAREMESH;
-       
+
        /* Write the display mesh into the dummy mesh */
        if (use_deform) {
                if (use_render) {
@@ -199,8 +199,8 @@ static bool py_BVHTreeDerivedMesh_ray_cast_parse_args(
                return false;
        }
 
-       if (mathutils_array_parse(r_co, 2, 3 | MU_ARRAY_ZERO, py_co, 
error_prefix) == -1 ||
-           mathutils_array_parse(r_direction, 2, 3 | MU_ARRAY_ZERO, 
py_direction, error_prefix) == -1)
+       if ((mathutils_array_parse(r_co, 2, 3 | MU_ARRAY_ZERO, py_co, 
error_prefix) == -1) ||
+           (mathutils_array_parse(r_direction, 2, 3 | MU_ARRAY_ZERO, 
py_direction, error_prefix) == -1))
        {
                return false;
        }
@@ -280,6 +280,7 @@ static PyObject *bvhtree_nearest_to_py(const float co[3], 
const float no[3], int
        return py_retval;
 }
 
+
 /* -------------------------------------------------------------------- */
 /* BVHTree */
 
@@ -345,6 +346,7 @@ PyTypeObject PyBVHTree_Type = {
        (destructor) NULL                            /* tp_del */
 };
 
+
 /* -------------------------------------------------------------------- */
 /* BVHTreeDerivedMesh */
 
@@ -352,7 +354,7 @@ static int 
PyBVHTreeDerivedMesh__tp_init(PyBVHTree_DerivedMesh *self, PyObject *
 {
        BVHTreeFromMesh *meshdata = &self->meshdata;
        const char *keywords[] = {"object", "scene", "type", "deform", 
"render", "cage", NULL};
-       
+
        PyObject *py_ob, *py_scene;
        Object *ob;
        struct Scene *scene;
@@ -362,28 +364,28 @@ static int 
PyBVHTreeDerivedMesh__tp_init(PyBVHTree_DerivedMesh *self, PyObject *
        int use_render = false;
        int use_cage = false;
        bool success;
-       
+
        if (PyBVHTree_Type.tp_init((PyObject *)self, args, kwargs) < 0)
                return -1;
-       
+
        if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char 
*)"OO|siii:BVHTreeDerivedMesh", (char **)keywords,
                                         &py_ob, &py_scene, &type, &use_deform, 
&use_render, &use_cage))
        {
                return -1;
        }
-       
+
        ob = PyC_RNA_AsPointer(py_ob, "Object");
        scene = PyC_RNA_AsPointer(py_scene, "Scene");
        if (!ob || !scene) {
                return -1;
        }
        self->ob = ob;
-       
+
        dm = bvh_get_derived_mesh("BVHTree", scene, ob, use_deform, use_render, 
use_cage);
        if (!dm) {
                return -1;
        }
-       
+
        if (STREQ(type, "TESSFACE")) {
                bvhtree_from_mesh_faces(meshdata, dm, 0.0f, 4, 6);
                self->use_poly_index = false;
@@ -408,9 +410,9 @@ static int 
PyBVHTreeDerivedMesh__tp_init(PyBVHTree_DerivedMesh *self, PyObject *
                PyErr_Format(PyExc_ValueError,"'type' must be one of [" 
PYBVH_DM_TYPES_STR "], not '%.200s'", type);
                success = false;
        }
-       
+
        dm->release(dm);
-       
+
        if (success)
                return 0;
        else
@@ -420,10 +422,10 @@ static int 
PyBVHTreeDerivedMesh__tp_init(PyBVHTree_DerivedMesh *self, PyObject *
 static void PyBVHTreeDerivedMesh__tp_dealloc(PyBVHTree_DerivedMesh *self)
 {
        BVHTreeFromMesh *meshdata = &self->meshdata;
-       
+
        self->ob = NULL;
        free_bvhtree_from_mesh(meshdata);
-       
+
        Py_TYPE(self)->tp_free((PyObject *)self);
 }
 
@@ -433,18 +435,18 @@ static PyObject 
*py_BVHTreeDerivedMesh_ray_cast(PyBVHTree_DerivedMesh *self, PyO
        const char *error_prefix = "ray_cast";
        float co[3], direction[3];
        float max_dist;
-       
+
        BVHTreeFromMesh *meshdata = &self->meshdata;
        Object *ob = self->ob;
 
        py_BVHTreeDerivedMesh_ray_cast_parse_args(args, error_prefix, co, 
direction, &max_dist);
-       
+
        /* may fail if the mesh has no faces, in that case the ray-cast misses 
*/
        if (meshdata->tree && meshdata->raycast_callback && ob->derivedFinal) {
                BVHTreeRayHit hit;
                hit.dist = max_dist;
                hit.index = -1;
-               
+
                if (BLI_bvhtree_ray_cast(meshdata->tree, co, direction, 0.0f, 
&hit,
                                         meshdata->raycast_callback, meshdata) 
!= -1)
                {
@@ -456,7 +458,7 @@ static PyObject 
*py_BVHTreeDerivedMesh_ray_cast(PyBVHTree_DerivedMesh *self, PyO
                        }
                }
        }
-       
+
        return bvhtree_ray_hit_to_py(NULL, NULL, -1, 0.0f);
 }
 
@@ -475,10 +477,10 @@ static PyObject 
*py_BVHTreeDerivedMesh_find_nearest(PyBVHTree_DerivedMesh *self,
        if (!py_BVHTreeDerivedMesh_find_nearest_parse_args(args, error_prefix, 
co, &max_dist)) {
                return NULL;
        }
-       
+
        nearest.index = -1;
        nearest.dist_sq = max_dist * max_dist;
-       
+
        /* may fail if the mesh has no faces, in that case the ray-cast misses 
*/
        if (meshdata->tree && meshdata->nearest_callback && ob->derivedFinal) {
                if (BLI_bvhtree_find_nearest(meshdata->tree, co, &nearest,
@@ -490,7 +492,7 @@ static PyObject 
*py_BVHTreeDerivedMesh_find_nearest(PyBVHTree_DerivedMesh *self,
                        return bvhtree_nearest_to_py(nearest.co, nearest.no, 
ret_index, sqrtf(nearest.dist_sq));
                }
        }
-       
+
        return bvhtree_nearest_to_py(NULL, NULL, -1, 0.0f);
 }
 
@@ -539,7 +541,7 @@ PyTypeObject PyBVHTreeDerivedMesh_Type = {
        0,                                           /* tp_weaklistoffset */
        NULL,                                        /* tp_iter */
        NULL,                                        /* tp_iternext */
-       (struct PyMethodDef *)PyBVHTreeDerivedMesh_methods, /* tp_methods */
+       (PyMethodDef *)PyBVHTreeDerivedMesh_methods, /* tp_methods */
        NULL,                                        /* tp_members */
        NULL,                                        /* tp_getset */
        NULL,                                        /* tp_base */
@@ -566,28 +568,28 @@ PyTypeObject PyBVHTreeDerivedMesh_Type = {
 static int PyBVHTreeBMesh__tp_init(PyBVHTree_BMesh *self, PyObject *args, 
PyObject *kwargs)
 {
        const char *keywords[] = {"bm", NULL};
-       
+
        PyObject *py_bm;
        BMesh *bm;
        int tottri;
        int flag = 0; /* TODO add optional RESPECT_SELECT and RESPECT_HIDDEN 
flag options */
-       
+
        if (PyBVHTree_Type.tp_init((PyObject *)self, args, kwargs) < 0)
                return -1;
-       
+
        if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *)"O!:from_bmesh", 
(char **)keywords,
                                         &BPy_BMesh_Type, &py_bm))
        {
                return -1;
        }
        bm = ((BPy_BMesh *)py_bm)->bm;
-       
+
        self->bmtotlooptris = poly_to_tri_count(bm->totface, bm->totloop);
        self->bmlooptris = MEM_mallocN(sizeof(*self->bmlooptris) * 
(size_t)self->bmtotlooptris, __func__);
        BM_bmesh_calc_tessellation(bm, self->bmlooptris, &tottri);
-       
+
        self->bmdata = BKE_bmbvh_new(bm, self->bmlooptris, tottri, flag, NULL, 
false);
-       
+
        return 0;
 }
 
@@ -602,7 +604,7 @@ static void PyBVHTreeBMesh__tp_dealloc(PyBVHTree_BMesh 
*self)
                BKE_bmbvh_free(self->bmdata);
                self->bmdata = NULL;
        }
-       
+
        Py_TYPE(self)->tp_free((PyObject *)self);
 }
 
@@ -612,7 +614,7 @@ static PyObject *py_BVHTreeBMesh_ray_cast(PyBVHTree_BMesh 
*self, PyObject *args)
        const char *error_prefix = "ray_cast";
        float co[3], direction[3];
        float max_dist;
-       
+
        BMBVHTree *bmdata = self->bmdata;
 
        py_BVHTreeDerivedMesh_ray_cast_parse_args(args, error_prefix, co, 
direction, &max_dist);
@@ -621,16 +623,16 @@ static PyObject *py_BVHTreeBMesh_ray_cast(PyBVHTree_BMesh 
*self, PyObject *args)
        if (bmdata) {
                BMFace *hit_face;
                float hit_co[3], hit_dist;
-               
+
                hit_dist = max_dist;
-               
+
                hit_face = BKE_bmbvh_ray_cast(bmdata, co, direction, 0.0f, 
&hit_dist, hit_co, NULL);
                if (hit_face && hit_dist <= max_dist) {
                        int ret_index = BM_elem_index_get(hit_face);
                        return bvhtree_ray_hit_to_py(hit_co, hit_face->no, 
ret_index, hit_dist);
                }
        }
-       
+
        return bvhtree_ray_hit_to_py(NULL, NULL, -1, 0.0f);
 }
 
@@ -640,17 +642,17 @@ static PyObject 
*py_BVHTreeBMesh_find_nearest(PyBVHTree_BMesh *self, PyObject *a
        const char *error_prefix = "find_nearest";
        float co[3];
        float max_dist;
-       
+
        BMBVHTree *bmdata = self->bmdata;
 
        if (!py_BVHTreeDerivedMesh_find_nearest_parse_args(args, error_prefix, 
co, &max_dist)) {
                return NULL;
        }
-       
+
        /* may fail if the mesh has no faces, in that case the ray-cast misses 
*/
        if (bmdata) {
                BMVert *nearest_vert;
-               
+
                nearest_vert = BKE_bmbvh_find_vert_closest(bmdata, co, 
max_dist);
                if (nearest_vert) {
                        return bvhtree_nearest_to_py(
@@ -658,7 +660,7 @@ static PyObject 
*py_BVHTreeBMesh_find_nearest(PyBVHTree_BMesh *self, PyObject *a
                                BM_elem_index_get(nearest_vert), len_v3v3(co, 
nearest_vert->co));
                }
        }
-       
+
        return bvhtree_nearest_to_py(NULL, NULL, -1, 0.0f);
 }
 
@@ -705,7 +707,7 @@ PyTypeObject PyBVHTreeBMesh_Type = {
        0,                                           /* tp_weaklistoffset */
        NULL,                                        /* tp_iter */
        NULL,                                        /* tp_iternext */
-       (struct PyMethodDef *)PyBVHTreeBMesh_methods,/* tp_methods */
+       (PyMethodDef *)PyBVHTreeBMesh_methods,       /* tp_methods */
        NULL,                                        /* tp_members */
        NULL,                                        /* tp_getset */
        NULL,                                        /* tp_base */
@@ -734,26 +736,26 @@ static BVHTree *bvhtree_from_triangles_create_tree(float 
epsilon, int tree_type,
 {
        BVHTree *tree = NULL;
        int i;
-       
+
        if (numtris == 0 || !vert || !tri)
                return NULL;
-       
+
        /* Create a bvh-tree of the given target */
        tree = BLI_bvhtree_new(numtris, epsilon, (char)tree_type, (char)axis);
        if (tree) {
                for (i = 0; i < numtris; i++) {
                        float co[3][3];
-                       
+
                        copy_v3_v3(co[0], vert[tri[i].tri[0]].co);
                        copy_v3_v3(co[1], vert[tri[i].tri[1]].co);
                        copy_v3_v3(co[2], vert[tri[i].tri[2]].co);
-                       
+
                        BLI_bvhtree_insert(tree, i, co[0], 3);
                }
-               
+
                BLI_bvhtree_balance(tree);
        }
-       
+
        return tree;
 }
 
@@ -761,7 +763,7 @@ static int PyBVHTreeCustom__tp_init(PyBVHTree_Custom *self, 
PyObject *args, PyOb
 {
        const char *error_prefix = "BVHTreeCustom";
        const char *keywords[] = {"vertices", "triangles", NULL};
-       
+
        PyObjec

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to