Revision: 29052
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29052
Author:   ben2610
Date:     2010-05-28 22:45:41 +0200 (Fri, 28 May 2010)

Log Message:
-----------
EOL to native

Modified Paths:
--------------
    branches/soc-2010-nicks/source/gameengine/Ketsji/KX_Pathfinder.cpp

Property Changed:
----------------
    branches/soc-2010-nicks/source/gameengine/Ketsji/KX_Pathfinder.cpp

Modified: branches/soc-2010-nicks/source/gameengine/Ketsji/KX_Pathfinder.cpp
===================================================================
--- branches/soc-2010-nicks/source/gameengine/Ketsji/KX_Pathfinder.cpp  
2010-05-28 20:22:21 UTC (rev 29051)
+++ branches/soc-2010-nicks/source/gameengine/Ketsji/KX_Pathfinder.cpp  
2010-05-28 20:45:41 UTC (rev 29052)
@@ -1,180 +1,180 @@
-/**
-* $Id$ 
-* ***** BEGIN GPL LICENSE BLOCK *****
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*
-* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
-* All rights reserved.
-*
-* The Original Code is: all of this file.
-*
-* Contributor(s): none yet.
-*
-* ***** END GPL LICENSE BLOCK *****
-*/
-
-#include "KX_Pathfinder.h"
-#include "RAS_MeshObject.h"
-
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-extern "C" {
-#include "BKE_scene.h"
-#include "BKE_customdata.h"
-#include "BKE_cdderivedmesh.h"
-#include "BKE_DerivedMesh.h"
-}
-#include "KX_PythonInit.h"
-#include "KX_PyMath.h"
-#include "Value.h"
-#include "Recast.h"
-#include "DetourStatNavMeshBuilder.h"
-
-static const int MAX_PATH_LEN = 256;
-static const float polyPickExt[3] = {2, 4, 2};
-
-static void calcMeshBounds(const float* vert, int nverts, float* bmin, float* 
bmax)
-{
-       bmin[0] = bmax[0] = vert[0];
-       bmin[1] = bmax[1] = vert[1];
-       bmin[2] = bmax[2] = vert[2];
-       for (int i=1; i<nverts; i++)
-       {
-               if (bmin[0]>vert[3*i+0]) bmin[0] = vert[3*i+0];
-               if (bmin[1]>vert[3*i+1]) bmin[1] = vert[3*i+1];
-               if (bmin[2]>vert[3*i+2]) bmin[2] = vert[3*i+2];
-
-               if (bmax[0]<vert[3*i+0]) bmax[0] = vert[3*i+0];
-               if (bmax[1]<vert[3*i+1]) bmax[1] = vert[3*i+1];
-               if (bmax[2]<vert[3*i+2]) bmax[2] = vert[3*i+2];
-       }
-}
-
-inline void flipAxes(float* vec)
-{
-       std::swap(vec[1],vec[2]);
-}
-
-KX_Pathfinder::KX_Pathfinder(void* sgReplicationInfo, SG_Callbacks callbacks)
-:      KX_GameObject(sgReplicationInfo, callbacks)
-,      m_navMesh(NULL)
-{
-       
-}
-
-KX_Pathfinder::~KX_Pathfinder()
-{
-       if (m_navMesh)
-               delete m_navMesh;
-}
-
-bool KX_Pathfinder::BuildVertIndArrays(RAS_MeshObject* meshobj, float 
*&vertices, int& nverts,
-                                                                          
unsigned short* &faces, int& npolys)
-{
-       if (!meshobj || meshobj->HasColliderPolygon()==false) 
-       {
-               return false;
-       }
-
-       DerivedMesh* dm = CDDM_from_mesh(meshobj->GetMesh(), NULL);
-
-       MVert *mvert = dm->getVertArray(dm);
-       MFace *mface = dm->getFaceArray(dm);
-       int numpolys = dm->getNumFaces(dm);
-       int numverts = dm->getNumVerts(dm);
-       int* index = (int*)dm->getFaceDataArray(dm, CD_ORIGINDEX);
-       MTFace *tface = (MTFace *)dm->getFaceDataArray(dm, CD_MTFACE);
-
-       nverts = numverts;
+/**
+* $Id$ 
+* ***** BEGIN GPL LICENSE BLOCK *****
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+* All rights reserved.
+*
+* The Original Code is: all of this file.
+*
+* Contributor(s): none yet.
+*
+* ***** END GPL LICENSE BLOCK *****
+*/
+
+#include "KX_Pathfinder.h"
+#include "RAS_MeshObject.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+extern "C" {
+#include "BKE_scene.h"
+#include "BKE_customdata.h"
+#include "BKE_cdderivedmesh.h"
+#include "BKE_DerivedMesh.h"
+}
+#include "KX_PythonInit.h"
+#include "KX_PyMath.h"
+#include "Value.h"
+#include "Recast.h"
+#include "DetourStatNavMeshBuilder.h"
+
+static const int MAX_PATH_LEN = 256;
+static const float polyPickExt[3] = {2, 4, 2};
+
+static void calcMeshBounds(const float* vert, int nverts, float* bmin, float* 
bmax)
+{
+       bmin[0] = bmax[0] = vert[0];
+       bmin[1] = bmax[1] = vert[1];
+       bmin[2] = bmax[2] = vert[2];
+       for (int i=1; i<nverts; i++)
+       {
+               if (bmin[0]>vert[3*i+0]) bmin[0] = vert[3*i+0];
+               if (bmin[1]>vert[3*i+1]) bmin[1] = vert[3*i+1];
+               if (bmin[2]>vert[3*i+2]) bmin[2] = vert[3*i+2];
+
+               if (bmax[0]<vert[3*i+0]) bmax[0] = vert[3*i+0];
+               if (bmax[1]<vert[3*i+1]) bmax[1] = vert[3*i+1];
+               if (bmax[2]<vert[3*i+2]) bmax[2] = vert[3*i+2];
+       }
+}
+
+inline void flipAxes(float* vec)
+{
+       std::swap(vec[1],vec[2]);
+}
+
+KX_Pathfinder::KX_Pathfinder(void* sgReplicationInfo, SG_Callbacks callbacks)
+:      KX_GameObject(sgReplicationInfo, callbacks)
+,      m_navMesh(NULL)
+{
+       
+}
+
+KX_Pathfinder::~KX_Pathfinder()
+{
+       if (m_navMesh)
+               delete m_navMesh;
+}
+
+bool KX_Pathfinder::BuildVertIndArrays(RAS_MeshObject* meshobj, float 
*&vertices, int& nverts,
+                                                                          
unsigned short* &faces, int& npolys)
+{
+       if (!meshobj || meshobj->HasColliderPolygon()==false) 
+       {
+               return false;
+       }
+
+       DerivedMesh* dm = CDDM_from_mesh(meshobj->GetMesh(), NULL);
+
+       MVert *mvert = dm->getVertArray(dm);
+       MFace *mface = dm->getFaceArray(dm);
+       int numpolys = dm->getNumFaces(dm);
+       int numverts = dm->getNumVerts(dm);
+       int* index = (int*)dm->getFaceDataArray(dm, CD_ORIGINDEX);
+       MTFace *tface = (MTFace *)dm->getFaceDataArray(dm, CD_MTFACE);
+
+       nverts = numverts;
        if (nverts >= 0xffff)
-               return false;
-       //calculate count of tris
-       npolys = numpolys;
-       for (int p2=0; p2<numpolys; p2++)
-       {
-               MFace* mf = &mface[p2];
-               if (mf->v4)
-                       npolys+=1;
-       }
-
-       //create verts
-       vertices = new float[nverts*3];
-       for (int vi=0; vi<nverts; vi++)
-       {
-               MVert *v = &mvert[vi];
-               for (int j=0; j<3; j++)
-                       vertices[3*vi+j] = v->co[j];
-       }
-       //create tris
-       faces = new unsigned short[npolys*3*2];
-       memset(faces,0xff,sizeof(unsigned short)*3*2*npolys);
-       unsigned short *face = faces;
-       for (int p2=0; p2<numpolys; p2++)
-       {
-               MFace* mf = &mface[p2];
-               face[0]= mf->v1;
-               face[1]= mf->v2;
-               face[2]= mf->v3;
-               face += 6;
-               if (mf->v4)
-               {
-                       face[0]= mf->v1;
-                       face[1]= mf->v3;
-                       face[2]= mf->v4;
-                       face += 6;
-               }
-       }
-
-       dm->release(dm);
-       dm = NULL;
-       
-       return true;
-}
-
-bool KX_Pathfinder::BuildNavMesh()
-{
-       if (GetMeshCount()==0)
-               return false;
-
-       RAS_MeshObject* meshobj = GetMesh(0);
-
-       float* vertices = NULL;
+               return false;
+       //calculate count of tris
+       npolys = numpolys;
+       for (int p2=0; p2<numpolys; p2++)
+       {
+               MFace* mf = &mface[p2];
+               if (mf->v4)
+                       npolys+=1;
+       }
+
+       //create verts
+       vertices = new float[nverts*3];
+       for (int vi=0; vi<nverts; vi++)
+       {
+               MVert *v = &mvert[vi];
+               for (int j=0; j<3; j++)
+                       vertices[3*vi+j] = v->co[j];
+       }
+       //create tris
+       faces = new unsigned short[npolys*3*2];
+       memset(faces,0xff,sizeof(unsigned short)*3*2*npolys);
+       unsigned short *face = faces;
+       for (int p2=0; p2<numpolys; p2++)
+       {
+               MFace* mf = &mface[p2];
+               face[0]= mf->v1;
+               face[1]= mf->v2;
+               face[2]= mf->v3;
+               face += 6;
+               if (mf->v4)
+               {
+                       face[0]= mf->v1;
+                       face[1]= mf->v3;
+                       face[2]= mf->v4;
+                       face += 6;
+               }
+       }
+
+       dm->release(dm);
+       dm = NULL;
+       
+       return true;
+}
+
+bool KX_Pathfinder::BuildNavMesh()
+{
+       if (GetMeshCount()==0)
+               return false;
+
+       RAS_MeshObject* meshobj = GetMesh(0);
+
+       float* vertices = NULL;
        unsigned short* faces = NULL;
        int nverts = 0, npolys = 0;     
-       if (!BuildVertIndArrays(meshobj, vertices, nverts, faces, npolys))
-               return false;
+       if (!BuildVertIndArrays(meshobj, vertices, nverts, faces, npolys))
+               return false;
        
        //prepare vertices and indices
        MT_Transform worldTransform = GetSGNode()->GetWorldTransform();
        MT_Point3 pos;
-       for (int i=0; i<nverts; i++)
-       {
-               flipAxes(&vertices[i*3]);
-               pos.setValue(&vertices[i*3]);
-               //add world transform
-               pos = worldTransform(pos);
-               pos.getValue(&vertices[i*3]);
-
-       }
-       //reorder tris 
-       for (int i=0; i<npolys; i++)
-       {
-               std::swap(faces[6*i+1], faces[6*i+2]);
-       }
-       const int vertsPerPoly = 3;
+       for (int i=0; i<nverts; i++)
+       {
+               flipAxes(&vertices[i*3]);
+               pos.setValue(&vertices[i*3]);
+               //add world transform
+               pos = worldTransform(pos);
+               pos.getValue(&vertices[i*3]);
+
+       }
+       //reorder tris 
+       for (int i=0; i<npolys; i++)
+       {
+               std::swap(faces[6*i+1], faces[6*i+2]);
+       }
+       const int vertsPerPoly = 3;
        buildMeshAdjacency(faces, npolys, nverts, vertsPerPoly);
 
        
@@ -192,11 +192,11 @@
        //quantize vertex pos
        unsigned short* vertsi = new unsigned short[3*nverts];
        float ics = 1.f/cs;
-       for (int i=0; i<nverts; i++)
-       {
-               vertsi[3*i+0] = static_cast<unsigned 
short>((vertices[3*i+0]-bmin[0])*ics);
-               vertsi[3*i+1] = static_cast<unsigned 
short>((vertices[3*i+1]-bmin[1])*ics);
-               vertsi[3*i+2] = static_cast<unsigned 
short>((vertices[3*i+2]-bmin[2])*ics);
+       for (int i=0; i<nverts; i++)
+       {
+               vertsi[3*i+0] = static_cast<unsigned 
short>((vertices[3*i+0]-bmin[0])*ics);
+               vertsi[3*i+1] = static_cast<unsigned 
short>((vertices[3*i+1]-bmin[1])*ics);
+               vertsi[3*i+2] = static_cast<unsigned 
short>((vertices[3*i+2]-bmin[2])*ics);
        }
 
        // Calculate data size
@@ -285,25 +285,25 @@
        const unsigned short* face = faces;
        for(size_t i=0; i<ndtris; i++)
        {
-               for (size_t j=0; j<3; j++)
-                       tri[4*i+j] = j;
+               for (size_t j=0; j<3; j++)
+                       tri[4*i+j] = j;
        }
 
        m_navMesh = new dtStatNavMesh;
-       m_navMesh->init(data, dataSize, true);
-
-       delete [] vertices;
-       delete [] faces;
-       
-       return true;
-}
-
-void KX_Pathfinder::DebugDraw()
-{
-       if (!m_navMesh)
-               return;
-       MT_Vector3 color(0.f, 0.f, 0.f);
-
+       m_navMesh->init(data, dataSize, true);
+
+       delete [] vertices;
+       delete [] faces;
+       
+       return true;
+}
+
+void KX_Pathfinder::DebugDraw()
+{
+       if (!m_navMesh)
+               return;
+       MT_Vector3 color(0.f, 0.f, 0.f);
+
        for (int i = 0; i < m_navMesh->getPolyDetailCount(); ++i)
        {
                const dtStatPoly* p = m_navMesh->getPoly(i);

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