[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30324] branches/soc-2010-nicks: - fixed bugs with unique vertices of detailed mesh in generation and conversion of navigation mesh
Nick Samarin
nicks1987 at bigmir.net
Wed Jul 14 15:20:13 CEST 2010
Revision: 30324
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30324
Author: nicks
Date: 2010-07-14 15:20:13 +0200 (Wed, 14 Jul 2010)
Log Message:
-----------
- fixed bugs with unique vertices of detailed mesh in generation and conversion of navigation mesh
- set default physic type and name for navigation mesh object
Modified Paths:
--------------
branches/soc-2010-nicks/projectfiles_vc9/blender/editors/ED_editors.vcproj
branches/soc-2010-nicks/projectfiles_vc9/blender/modifiers/modifiers.vcproj
branches/soc-2010-nicks/source/blender/editors/object/object_navmesh.cpp
branches/soc-2010-nicks/source/gameengine/Ketsji/KX_NavMeshObject.cpp
Modified: branches/soc-2010-nicks/projectfiles_vc9/blender/editors/ED_editors.vcproj
===================================================================
--- branches/soc-2010-nicks/projectfiles_vc9/blender/editors/ED_editors.vcproj 2010-07-14 12:40:46 UTC (rev 30323)
+++ branches/soc-2010-nicks/projectfiles_vc9/blender/editors/ED_editors.vcproj 2010-07-14 13:20:13 UTC (rev 30324)
@@ -44,7 +44,7 @@
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.6;..\..\..\..\build\msvc_9\intern\bsp\include;..\..\..\..\build\msvc_9\intern\ghost\include;..\..\..\..\build\msvc_9\intern\elbeem\include;..\..\..\..\build\msvc_9\intern\opennl\include;..\..\..\..\build\msvc_9\intern\bmfont\include;..\..\..\..\build\msvc_9\intern\blenkey\include;..\..\..\..\build\msvc_9\intern\decimation\include;..\..\..\..\build\msvc_9\intern\memutil\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\smoke\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\source\blender;..\..\..\source\blender\img;..\..\..\source\blender\verify;..\..\..\source\blender\ftfont;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\editors\include;..\..\..\source\blender\editors\interface;..\..\..\source\blender\renderui;..\..\..\source\blender\blenloader;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenfont;..\..\..\source\blender\makesdna;..\..\..\source\blender\makesrna;..\..\..\source\blender\nodes;..\..\..\source\blender\windowmanager;..\..\..\source\blender\blenpluginapi;..\..\..\source\blender\renderconverter;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include;..\..\..\source\blender\radiosity\extern\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\network;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\..\build\msvc_9\extern\verse\include;..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\blender\gpu;..\..\..\intern\audaspace\intern;..\..\..\source\blender\ikplugin;..\..\..\..\lib\windows\openal\include;..\..\..\..\lib\windows\jack\include"
+ AdditionalIncludeDirectories="..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.6;..\..\..\..\build\msvc_9\intern\bsp\include;..\..\..\..\build\msvc_9\intern\ghost\include;..\..\..\..\build\msvc_9\intern\elbeem\include;..\..\..\..\build\msvc_9\intern\opennl\include;..\..\..\..\build\msvc_9\intern\bmfont\include;..\..\..\..\build\msvc_9\intern\blenkey\include;..\..\..\..\build\msvc_9\intern\decimation\include;..\..\..\..\build\msvc_9\intern\memutil\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\smoke\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\source\blender;..\..\..\source\blender\img;..\..\..\source\blender\verify;..\..\..\source\blender\ftfont;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\editors\include;..\..\..\source\blender\editors\interface;..\..\..\source\blender\renderui;..\..\..\source\blender\blenloader;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenfont;..\..\..\source\blender\makesdna;..\..\..\source\blender\makesrna;..\..\..\source\blender\nodes;..\..\..\source\blender\windowmanager;..\..\..\source\blender\blenpluginapi;..\..\..\source\blender\renderconverter;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include;..\..\..\source\blender\radiosity\extern\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\network;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\..\build\msvc_9\extern\verse\include;..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\blender\gpu;..\..\..\intern\audaspace\intern;..\..\..\source\blender\ikplugin;..\..\..\..\lib\windows\openal\include;..\..\..\..\lib\windows\jack\include;..\..\..\..\build\msvc_9\extern\recastnavigation\Recast\Include"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;_CONSOLE;GAMEBLENDER=1;WITH_QUICKTIME;INTERNATIONAL;WITH_FREETYPE2;WITH_INTERNATIONAL;WITH_OPENEXR;WITH_DDS;WITH_BULLET=1;WITH_FFMPEG;WITH_SDL;WITH_OPENAL;WITH_JACK"
StringPooling="true"
RuntimeLibrary="0"
Modified: branches/soc-2010-nicks/projectfiles_vc9/blender/modifiers/modifiers.vcproj
===================================================================
--- branches/soc-2010-nicks/projectfiles_vc9/blender/modifiers/modifiers.vcproj 2010-07-14 12:40:46 UTC (rev 30323)
+++ branches/soc-2010-nicks/projectfiles_vc9/blender/modifiers/modifiers.vcproj 2010-07-14 13:20:13 UTC (rev 30324)
@@ -253,7 +253,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="2"
- AdditionalIncludeDirectories="..\..\..\..\lib\windows\zlib\include;..\..\..\..\build\msvc_9\intern\bsp\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\decimation\include;..\..\..\..\build\msvc_9\intern\elbeem\include;..\..\..\..\build\msvc_9\intern\iksolver\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenkernel\intern;..\..\..\source\blender\makesdna;..\..\..\source\blender\modifiers;..\..\..\source\blender\render\extern\include"
+ AdditionalIncludeDirectories="..\..\..\..\lib\windows\zlib\include;..\..\..\..\build\msvc_9\intern\bsp\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\decimation\include;..\..\..\..\build\msvc_9\intern\elbeem\include;..\..\..\..\build\msvc_9\intern\iksolver\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenkernel\intern;..\..\..\source\blender\makesdna;..\..\..\source\blender\modifiers;..\..\..\source\blender\render\extern\include;..\..\..\..\build\msvc_9\extern\recastnavigation\Recast\Include;..\..\..\source\blender\editors\include;..\..\..\source\blender\gpu"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;WITH_LZO;WITH_LZMA"
BasicRuntimeChecks="0"
RuntimeLibrary="0"
Modified: branches/soc-2010-nicks/source/blender/editors/object/object_navmesh.cpp
===================================================================
--- branches/soc-2010-nicks/source/blender/editors/object/object_navmesh.cpp 2010-07-14 12:40:46 UTC (rev 30323)
+++ branches/soc-2010-nicks/source/blender/editors/object/object_navmesh.cpp 2010-07-14 13:20:13 UTC (rev 30324)
@@ -38,6 +38,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_ID.h"
+#include "BKE_library.h"
#include "BKE_depsgraph.h"
#include "BKE_context.h"
#include "BKE_mesh.h"
@@ -345,7 +346,7 @@
//create unique verts
for (j=nv; j<ndv; j++)
{
- copy_v3_v3(co, &dmesh->verts[vbase + j]);
+ copy_v3_v3(co, &dmesh->verts[3*(vbase + j)]);
SWAP(float, co[1], co[2]);
addvertlist(em, co, NULL);
}
@@ -386,6 +387,11 @@
ED_object_exit_editmode(C, EM_FREEDATA);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit);
+
+ obedit->gameflag &= ~OB_COLLISION;
+ obedit->gameflag |= OB_NAVMESH;
+ obedit->body_type = OB_BODY_TYPE_NAVMESH;
+ rename_id((ID *)obedit, "Navmesh");
return obedit;
}
Modified: branches/soc-2010-nicks/source/gameengine/Ketsji/KX_NavMeshObject.cpp
===================================================================
--- branches/soc-2010-nicks/source/gameengine/Ketsji/KX_NavMeshObject.cpp 2010-07-14 12:40:46 UTC (rev 30323)
+++ branches/soc-2010-nicks/source/gameengine/Ketsji/KX_NavMeshObject.cpp 2010-07-14 13:20:13 UTC (rev 30324)
@@ -70,6 +70,24 @@
std::swap(vec[1],vec[2]);
}
+static float distPointToSegmentSq(const float* point, const float* a, const float* b)
+{
+ float abx[3], dx[3];
+ vsub(abx, b,a);
+ vsub(dx, point,a);
+ float d = abx[0]*abx[0]+abx[1]*abx[1];
+ float t = abx[0]*dx[0]+abx[1]*dx[1];
+ if (d > 0)
+ t /= d;
+ if (t < 0)
+ t = 0;
+ else if (t > 1)
+ t = 1;
+ dx[0] = a[0] + t*abx[0] - point[0];
+ dx[1] = a[1] + t*abx[1] - point[1];
+ return dx[0]*dx[0] + dx[1]*dx[1];
+}
+
KX_NavMeshObject::KX_NavMeshObject(void* sgReplicationInfo, SG_Callbacks callbacks)
: KX_GameObject(sgReplicationInfo, callbacks)
, m_navMesh(NULL)
@@ -177,7 +195,7 @@
for (int polyidx=0; polyidx<npolys; polyidx++)
{
- vector<int> poly;
+ vector<unsigned short> poly, tempPoly;
//search border
int btri = -1;
int bedge = -1;
@@ -239,9 +257,21 @@
}
}
- //.todo: process poly to remove degenerate vertices
- if (poly.size()>=vertsPerPoly)
+ size_t nv = poly.size();
+ for (size_t i=0; i<nv; i++)
{
+ unsigned short prev = poly[(poly.size()+i-1)%nv];
+ unsigned short cur = poly[i];
+ unsigned short next = poly[(i+1)%nv];
+ float distSq = distPointToSegmentSq(mvert[cur].co, mvert[prev].co, mvert[next].co);
+ static const float tolerance = 0.001f;
+ if (distSq>tolerance)
+ tempPoly.push_back(cur);
+ }
+ poly = tempPoly;
+
+ if (poly.size()>vertsPerPoly)
+ {
printf("Error! Polygon size exceeds max verts count");
return false;
}
@@ -254,7 +284,6 @@
//assumption: vertices in mesh are stored in following order:
//navigation mesh vertices - unique detailed mesh vertex
-
unsigned short maxidx = 0;
for (int polyidx=0; polyidx<npolys; polyidx++)
{
@@ -295,7 +324,7 @@
unsigned short minvert = 0xffff, maxvert = 0;
for (int j=0; j<dmesh[3]; j++)
{
- unsigned short* dtri = &dtris[dmesh[2]*3*2+j];
+ unsigned short* dtri = &dtris[(dmesh[2]+j)*3*2];
for (int k=0; k<3; k++)
{
if (dtri[k]<nverts)
@@ -308,7 +337,7 @@
dmesh[1] = minvert != 0xffff ? maxvert - minvert + 1 : 0; //vnum
}
- //recalculate detailed mesh indices (it must be local)
+ //recalculate detailed mesh indices (they must be local)
for (int polyIdx=0; polyIdx<npolys; polyIdx++)
{
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list