Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include "Headers/NavigationPath.h"
#include "Waypoints/Headers/WaypointGraph.h"

namespace Navigation {
   tQueryFilter::tQueryFilter() {
   }

   bool tQueryFilter::passFilter(const dtPolyRef ref, const dtMeshTile* tile, const dtPoly* poly) const  {
      return Parent::passFilter(ref, tile, poly);
   }

   NavigationPath::NavigationPath() :  _from(0.0f, 0.0f, 0.0f),
									   _to(0.0f, 0.0f, 0.0f)  {
      _mesh = NULL;
      _waypoints = NULL;

      _from.set(0, 0, 0);
      _fromSet = false;
      _to.set(0, 0, 0);
      _toSet = false;
      _length = 0.0f;

      _curIndex = -1;
      _isLooping = false;
      _autoUpdate = false;
      _isSliced = false;

      _maxIterations = 1;

      _alwaysRender = false;
      _Xray = false;

      _query = dtAllocNavMeshQuery();
   }

   NavigationPath::~NavigationPath() {
      dtFreeNavMeshQuery(_query);
      _query = NULL;
   }

  bool NavigationPath::init() {
      // Check that al the right data is provided.
      if(!_mesh || !_mesh->getNavigationMesh())
         return false;

      if(!(_fromSet && _toSet) && !(_waypoints && _waypoints->getSize()))
         return false;

      // Initialise out query.
      if(dtStatusFailed(_query->init(_mesh->getNavigationMesh(), MaxPathLen)))
         return false;

      _points.clear();
      _visitPoints.clear();
      _length = 0.0f;

      return true;
   }

   void NavigationPath::resize()  {
   }

   bool NavigationPath::plan()  {
      if(_isSliced)
         return planSliced();
      else
         return planInstant();
   }

   bool NavigationPath::planSliced()  {
      // Initialise query and visit locations.
      if(!init())
         return false;

      bool visited = visitNext();

      return visited;
   }

   bool NavigationPath::visitNext()  {
      U32 s = _visitPoints.size();

      if(s < 2)
         return false;

      // Current leg of journey.
      vec3<F32> start = _visitPoints[s-1];
      vec3<F32> end   = _visitPoints[s-2];

      // Convert to Detour-friendly coordinates and data structures.
      F32 from[] = {start.x, start.z, -start.y};
      F32 to[] =   {end.x,   end.z,   -end.y};
      F32 extents[] = {1.0f, 1.0f, 1.0f};
      dtPolyRef startRef, endRef;

      if(dtStatusFailed(_query->findNearestPoly(from, extents, &_filter, &startRef, start)))  {
		  ERROR_FN(Locale::get("ERROR_NAV_NO_POLY_NEAR_POINTS"), start.x, start.y, start.z);
         return false;
      }

      if(dtStatusFailed(_query->findNearestPoly(to, extents, &_filter, &endRef, end)))
      {
		  ERROR_FN(Locale::get("ERROR_NAV_NO_POLY_NEAR_POINTS"), end.x, end.y, end.z);
         return false;
      }

      // Init sliced pathfind.
      _status = _query->initSlicedFindPath(startRef, endRef, from, to, &_filter);

      if(dtStatusFailed(_status))
         return false;

      return true;
   }

   bool NavigationPath::update()  {
      return false;
   }

   bool NavigationPath::finalise()  {
      resize();

      return dtStatusSucceed(_status);
   }

   bool NavigationPath::planInstant()  {
      if(!init())
         return false;

      visitNext();

      while(update());

      if(!finalise())
         return false;

      resize();

      return true;
   }

   vec3<F32> NavigationPath::getNode(I32 idx)  {
      if(idx < getCount() && idx >= 0)
         return _points[idx];

      return vec3<F32>();
   }

   I32 NavigationPath::getCount()  {
      return _points.size();
   }

   I32 NavigationPath::getObject(I32 idx)  {
      return -1;
   }
};

Commits for Divide-Framework/trunk/Source Code/AI/PathFinding/NavigationPath.cpp

Diff revisions: vs.
Revision Author Commited Message
168 Diff Diff k1ngp1n picture k1ngp1n Sat 26 Oct, 2013 19:03:21 +0000

- Reworked the Camera class[[BR]]
— Now fully quaternion based [[BR]]
— Basic camera types added but not used yet (third person, first person, orbit) [[BR]]
- Cleaned up Material and Texture handling [[BR]]
- Added clipping plane support [[BR]]
— Similar to OpenGL fixed-function clip planes but fully shader driven [[BR]]
— Added a new class, “Plane”, that helps define clip planes [[BR]]
- Optimized the Singleton class to allow faster “getInstance” calls without performance penalties [[BR]]
-- “createInstance” must be called for each singleton class before usage. Or “gerOrCreateInstance” can be used, which is basically the former “getInstance” implementation [[BR]]
- Improved console logging by changing some heap allocations to stack and removing dependencies on the std::string class [[BR]]
- Added a lot of performance optimizations related to coding standards and redundant calculations [[BR]]
— e.g. Frustum AABB check didn’t need to recompute the AABB points as they were calculated already [[BR]]
— e.g. A vector did not need to be set to 0 on initialization as that is already it’s default state on creation [[BR]]
— e.g. Faster Framerate and Timing calculations by using less member variables that are not needed outsied of calling functions [[BR]]
- The SceneState now contains the SceneRenderState and is passed on to the SceneGraph’s update calls [[BR]]
- Better material export/import to/from XML format [[BR]]
- More bug fixes and cleanups [[BR]]

156 Diff Diff k1ngp1n picture k1ngp1n Thu 04 Jul, 2013 21:50:54 +0000

[Ionut] [[BR]]
- More work on Navigation Mesh creation [[BR]]
- IMEmulation primitives were not recycled properly (old, unused primitives were saved, new ones were deleted and recreated – behavior reversed ) [[BR]]

152 Diff Diff k1ngp1n picture k1ngp1n Thu 20 Jun, 2013 14:23:31 +0000

[Ionut] [[BR]]
- New rendering pipeline (experimental and unstable): [[BR]]
— OpenGL 3.x clean context (glLight commands are still used for now, but UBO support is there, but not used yet) [[BR]]
— Custom matrix stacks and UBO based shader data (UBOs cause some link errors on some nVidia cards)[[BR]]
— Multi-threaded texture loading and shader compilation (mt shader compilation disabled for now. needs more tests) [[BR]]
— VAO rendering is self contained (no more enable/disable calls before a draw request) [[BR]]
— Render instance class used for rendering information [[BR]]
[[BR]]
- New unique ID generation base class: GUIDWrapper. Each class that derives from this, gets an application wide unique id on construction [[BR]]
- Added base code for an in-game editor using CEGUI [[BR]]
- Replaced some mutex locks with lockless data structures or atomic data [[BR]]
- CEGUI 0.8.2, FTGL-GL3 and GLIM 0.4 modified to support GLEW_MX if defined [[BR]]
- Dropped VS2008 support [[BR]]
- Networking library, server framework and ReCast files are now projects inside the Divide Framework solution [[BR]]
- New console command “setFov” that modifies the horizontal FoV value in realtime [[BR]]
- New console command “recompileShader” that reparses shader files, recompiles shaders and relinks shader programs who’s names match or contain the argument string [[BR]]
- New debug utility: axis angle drawn in corner of the screen if needed [[BR]]
- More ‘const’-s pasted around the code, more loop performance tweaks (allocations before a loop, tighter loops, etc), more utility member functions added to various classes [[BR]]

121 Diff Diff k1ngp1n picture k1ngp1n Sun 10 Jun, 2012 16:40:45 +0000

[Ionut] [[BR]]
-Added basic localization support [[BR]]
-Added cross-platform INI parsing [[BR]]
-Moved ReCast+Detour to LIBS folder [[BR]]

110 k1ngp1n picture k1ngp1n Thu 26 Apr, 2012 15:48:58 +0000

[Ionut] [[BR]]
-Added Recast & Detour Navigation libraries (http://code.google.com/p/recastnavigation/ by Mikko Mononen) [[BR]]
--Added (a incomplete version for now) MeshLoader for Recast patch from the Torque3D forum and adapted it for DIVIDE (patch link: http://www.garagegames.com/community/blogs/view/21132) [[BR]]
--Added the NavigationMesh patch (a incomplete version for now) for Torque3D using Recast and adapted it for DIVIDE (patch link: http://www.garagegames.com/community/resources/view/21392) [[BR]]
[[BR]]
-Added empty folder structure for the War Scene to hold future classes and resources [[BR]]
-Added a GenericShape class to hold an empty VBO in which we can store any combination of vertices (incomplete) [[BR]]