Commit: 2e6634e4a8a78809453816d2c623495e21454e69
Author: Porteries Tristan
Date:   Fri May 8 18:08:02 2015 +0200
Branches: master
https://developer.blender.org/rB2e6634e4a8a78809453816d2c623495e21454e69

BGE: Cleanup function UpdateMesh and SetMesh in CcdPhysicsController.cpp

"if (value == true)" -> "if(value)"
"if (ptr == NULL)" -> "if (!ptr)"
"vector<bool>" -> "std::vector<bool>"
And other blender typo.

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

M       source/gameengine/Physics/Bullet/CcdPhysicsController.cpp

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

diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp 
b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index dfcad86..b6d2f84 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -1875,7 +1875,7 @@ CcdShapeConstructionInfo* 
CcdShapeConstructionInfo::FindMesh(RAS_MeshObject* mes
        return NULL;
 }
 
-bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* 
dm, bool polytope)
+bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject *meshobj, DerivedMesh 
*dm, bool polytope)
 {
        int numpolys, numverts;
 
@@ -1887,7 +1887,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* 
meshobj, DerivedMesh* dm,
        bool free_dm = false;
 
        // No mesh object or mesh has no polys
-       if (!meshobj || meshobj->HasColliderPolygon()==false) {
+       if (!meshobj || !meshobj->HasColliderPolygon()) {
                m_vertexArray.clear();
                m_polygonIndexArray.clear();
                m_triFaceArray.clear();
@@ -1910,80 +1910,83 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* 
meshobj, DerivedMesh* dm,
        /* double lookup */
        const int *index_mf_to_mpoly = (const int 
*)dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
        const int *index_mp_to_orig  = (const int *)dm->getPolyDataArray(dm, 
CD_ORIGINDEX);
-       if (index_mf_to_mpoly == NULL) {
+       if (!index_mf_to_mpoly) {
                index_mp_to_orig = NULL;
        }
 
        m_shapeType = (polytope) ? PHY_SHAPE_POLYTOPE : PHY_SHAPE_MESH;
 
        /* Convert blender geometry into bullet mesh, need these vars for 
mapping */
-       vector<bool> vert_tag_array(numverts, false);
-       unsigned int tot_bt_verts= 0;
+       std::vector<bool> vert_tag_array(numverts, false);
+       unsigned int tot_bt_verts = 0;
 
-       if (polytope)
-       {
+       if (polytope) {
                // Tag verts we're using
-               for (int p2=0; p2<numpolys; p2++)
-               {
-                       MFace* mf = &mface[p2];
+               for (int p2 = 0; p2 < numpolys; p2++) {
+                       MFace *mf = &mface[p2];
                        const int origi = index_mf_to_mpoly ? 
DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2;
-                       RAS_Polygon* poly = meshobj->GetPolygon(origi);
+                       RAS_Polygon *poly = meshobj->GetPolygon(origi);
 
                        // only add polygons that have the collision flag set
-                       if (poly->IsCollider())
-                       {
-                               if (vert_tag_array[mf->v1] == false) 
{vert_tag_array[mf->v1] = true; tot_bt_verts++;}
-                               if (vert_tag_array[mf->v2] == false) 
{vert_tag_array[mf->v2] = true; tot_bt_verts++;}
-                               if (vert_tag_array[mf->v3] == false) 
{vert_tag_array[mf->v3] = true; tot_bt_verts++;}
-                               if (mf->v4 && vert_tag_array[mf->v4] == false) 
{vert_tag_array[mf->v4] = true; tot_bt_verts++;}
+                       if (poly->IsCollider()) {
+                               if (!vert_tag_array[mf->v1]) {
+                                       vert_tag_array[mf->v1] = true;
+                                       tot_bt_verts++;
+                               }
+                               if (!vert_tag_array[mf->v2]) {
+                                       vert_tag_array[mf->v2] = true;
+                                       tot_bt_verts++;
+                               }
+                               if (!vert_tag_array[mf->v3]) {
+                                       vert_tag_array[mf->v3] = true;
+                                       tot_bt_verts++;
+                               }
+                               if (mf->v4 && !vert_tag_array[mf->v4]) {
+                                       vert_tag_array[mf->v4] = true;
+                                       tot_bt_verts++;
+                               }
                        }
                }
-               
+
                /* Can happen with ngons */
                if (!tot_bt_verts) {
                        goto cleanup_empty_mesh;
                }
 
-               m_vertexArray.resize(tot_bt_verts*3);
+               m_vertexArray.resize(tot_bt_verts * 3);
 
-               btScalar *bt= &m_vertexArray[0];
+               btScalar *bt = &m_vertexArray[0];
 
-               for (int p2=0; p2<numpolys; p2++)
-               {
-                       MFace* mf = &mface[p2];
+               for (int p2 = 0; p2 < numpolys; p2++) {
+                       MFace *mf = &mface[p2];
                        const int origi = index_mf_to_mpoly ? 
DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2;
-                       RAS_Polygon* poly= meshobj->GetPolygon(origi);
+                       RAS_Polygon *poly = meshobj->GetPolygon(origi);
 
                        // only add polygons that have the collisionflag set
-                       if (poly->IsCollider())
-                       {
-                               if (vert_tag_array[mf->v1]==true)
-                               {
-                                       const float* vtx = mvert[mf->v1].co;
+                       if (poly->IsCollider()) {
+                               if (vert_tag_array[mf->v1]) {
+                                       const float *vtx = mvert[mf->v1].co;
                                        vert_tag_array[mf->v1] = false;
                                        *bt++ = vtx[0];
                                        *bt++ = vtx[1];
                                        *bt++ = vtx[2];
                                }
-                               if (vert_tag_array[mf->v2]==true)
-                               {
-                                       const float* vtx = mvert[mf->v2].co;
+                               if (vert_tag_array[mf->v2]) {
+                                       const float *vtx = mvert[mf->v2].co;
                                        vert_tag_array[mf->v2] = false;
                                        *bt++ = vtx[0];
                                        *bt++ = vtx[1];
                                        *bt++ = vtx[2];
                                }
-                               if (vert_tag_array[mf->v3]==true)
-                               {
-                                       const float* vtx = mvert[mf->v3].co;
+                               if (vert_tag_array[mf->v3]) {
+                                       const float *vtx = mvert[mf->v3].co;
                                        vert_tag_array[mf->v3] = false;
                                        *bt++ = vtx[0];
                                        *bt++ = vtx[1];
                                        *bt++ = vtx[2];
                                }
-                               if (mf->v4 && vert_tag_array[mf->v4]==true)
-                               {
-                                       const float* vtx = mvert[mf->v4].co;
+                               if (mf->v4 && vert_tag_array[mf->v4]) {
+                                       const float *vtx = mvert[mf->v4].co;
                                        vert_tag_array[mf->v4] = false;
                                        *bt++ = vtx[0];
                                        *bt++ = vtx[1];
@@ -1993,28 +1996,38 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* 
meshobj, DerivedMesh* dm,
                }
        }
        else {
-               unsigned int tot_bt_tris= 0;
-               vector<int> vert_remap_array(numverts, 0);
-               
+               unsigned int tot_bt_tris = 0;
+               std::vector<int> vert_remap_array(numverts, 0);
+
                // Tag verts we're using
-               for (int p2=0; p2<numpolys; p2++)
-               {
-                       MFace* mf = &mface[p2];
+               for (int p2 = 0; p2 < numpolys; p2++) {
+                       MFace *mf = &mface[p2];
                        const int origi = index_mf_to_mpoly ? 
DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2;
-                       RAS_Polygon* poly= meshobj->GetPolygon(origi);
+                       RAS_Polygon *poly = meshobj->GetPolygon(origi);
 
                        // only add polygons that have the collision flag set
-                       if (poly->IsCollider())
-                       {
-                               if (vert_tag_array[mf->v1]==false)
-                                       {vert_tag_array[mf->v1] = 
true;vert_remap_array[mf->v1] = tot_bt_verts;tot_bt_verts++;}
-                               if (vert_tag_array[mf->v2]==false)
-                                       {vert_tag_array[mf->v2] = 
true;vert_remap_array[mf->v2] = tot_bt_verts;tot_bt_verts++;}
-                               if (vert_tag_array[mf->v3]==false)
-                                       {vert_tag_array[mf->v3] = 
true;vert_remap_array[mf->v3] = tot_bt_verts;tot_bt_verts++;}
-                               if (mf->v4 && vert_tag_array[mf->v4]==false)
-                                       {vert_tag_array[mf->v4] = 
true;vert_remap_array[mf->v4] = tot_bt_verts;tot_bt_verts++;}
-                               tot_bt_tris += (mf->v4 ? 2:1); /* a quad or a 
tri */
+                       if (poly->IsCollider()) {
+                               if (!vert_tag_array[mf->v1]) {
+                                       vert_tag_array[mf->v1] = true;
+                                       vert_remap_array[mf->v1] = tot_bt_verts;
+                                       tot_bt_verts++;
+                               }
+                               if (!vert_tag_array[mf->v2]) {
+                                       vert_tag_array[mf->v2] = true;
+                                       vert_remap_array[mf->v2] = tot_bt_verts;
+                                       tot_bt_verts++;
+                               }
+                               if (!vert_tag_array[mf->v3]) {
+                                       vert_tag_array[mf->v3] = true;
+                                       vert_remap_array[mf->v3] = tot_bt_verts;
+                                       tot_bt_verts++;
+                               }
+                               if (mf->v4 && !vert_tag_array[mf->v4]) {
+                                       vert_tag_array[mf->v4] = true;
+                                       vert_remap_array[mf->v4] = tot_bt_verts;
+                                       tot_bt_verts++;
+                               }
+                               tot_bt_tris += (mf->v4 ? 2 : 1); /* a quad or a 
tri */
                        }
                }
 
@@ -2023,43 +2036,39 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* 
meshobj, DerivedMesh* dm,
                        goto cleanup_empty_mesh;
                }
 
-               m_vertexArray.resize(tot_bt_verts*3);
+               m_vertexArray.resize(tot_bt_verts * 3);
                m_polygonIndexArray.resize(tot_bt_tris);
-               m_triFaceArray.resize(tot_bt_tris*3);
-               btScalar *bt= &m_vertexArray[0];
-               int *poly_index_pt= &m_polygonIndexArray[0];
-               int *tri_pt= &m_triFaceArray[0];
+               m_triFaceArray.resize(tot_bt_tris * 3);
+               btScalar *bt = &m_vertexArray[0];
+               int *poly_index_pt = &m_polygonIndexArray[0];
+               int *tri_pt = &m_triFaceArray[0];
 
                UVco *uv_pt = NULL;
-               if (tface)
-               {
-                       m_triFaceUVcoArray.resize(tot_bt_tris*3);
+               if (tface) {
+                       m_triFaceUVcoArray.resize(tot_bt_tris * 3);
                        uv_pt = &m_triFaceUVcoArray[0];
-               } 
-               else 
+               }
+               else
                        m_triFaceUVcoArray.clear();
 
-               for (int p2=0; p2<numpolys; p2++)
-               {
-                       MFace* mf = &mface[p2];
-                       MTFace* tf = (tface) ? &tface[p2] : NULL;
+               for (int p2 = 0; p2 < numpolys; p2++) {
+                       MFace *mf = &mface[p2];
+                       MTFace *tf = (tface) ? &tface[p2] : NULL;
                        const int origi = index_mf_to_mpoly ? 
DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2;
-                       RAS_Polygon* poly= meshobj->GetPolygon(origi);
+                       RAS_Polygon *poly = meshobj->GetPolygon(origi);
 
                        // only add polygons that have the collisionflag set
-                       if (poly->IsCollider())
-                       {
-                               MVert *v1= &mvert[mf->v1];
-                               MVert *v2= &mvert[mf->v2];
-                               MVert *v3= &mvert[mf->v3];
+                       if (poly->IsCollider()) {
+                               MVert *v1 = &mvert[mf->v1];
+                               MVert *v2 = &mvert[mf->v2];
+                               MVert *v3 = &mvert[mf->v3];
 
                                // the face indices
                                tri_pt[0] = vert_remap_array[mf->v1];
                                tri_pt[1] = vert_remap_array[mf->v2];
                                tri_pt[2] = vert_remap_array[mf->v3];
-                               tri_pt= tri_pt+3;
-                               if (tf)
-                               {
+                               tri_pt = tri_pt + 3;
+                               if (tf) {
                                        uv_pt[0].uv[0] = tf->uv[0][0];
                                        uv_pt[0].uv[1] = tf->uv[0][1];
                                        uv_pt[1].uv[0] = tf->uv[1][0];
@@ -2074,19 +2083,19 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* 
meshobj, DerivedMesh* dm,
                                poly_index_pt++;
 
                                // the vertex location
-                               if (vert_tag_array[mf->v1]==true) { /* *** v1 
*** */
+                               if (vert_tag_array[mf->v1]) { /* *** v1 *** */
                                        vert_tag_array[mf->v1] = false;
                                        *bt++ = v1->co[0];
                                        *bt++ = v1->co[1];
                                        *bt++ = v1->co[2];
                                }
-                               if (vert_tag_array[mf->v2]==true) { /* *** v2 
*** */
+                               if (vert_tag_array[mf->v2]) { /* *** v2 *** */
                                        vert_tag_array[mf->v2] = false;
                                        *bt++ = v2->co[0];
                                        *bt++ = v2->co[1];
                                        *bt++ = v2->co[2];
                                }
-                               if (vert_tag_array[mf->v3]==true) { /* *** v3 
*** */
+                               if (vert_tag_array[mf->v3]) { /* *** v3 *** */
                                        vert_tag_array[mf->v3] = false;
                                        *bt++ = v3->co[0];
                                        *bt++ = v3->co[1];
@@ -2095,12 +2104,12 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* 
meshobj, DerivedMesh* dm,
 
                                if (mf->v4)
                                {
-                                       MVert *v4= &mvert[mf->v4];
+                                       MVert *v4 = &mvert[mf->v4];
 
                                        tri_pt[0] = vert_remap_array[mf->v1];
                                        tri_pt[1] = vert_remap_array[mf->v3];
                                        tri_pt[2] = vert_remap_array[mf->v4];
-                                       tri_pt= tri_pt+3;
+                                       tri_pt = tri_pt + 3;
                                        if (tf)
                                        {
                                                uv_pt[0].uv[0] = tf->uv[0][0];
@@ -2117,7 +2126,7 @

@@ 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