Detour: Reduced tile navmesh link size by 6 bytes.
Demo: Fixed some include file errors from previous renaming fest. Added license at top of some files.
This commit is contained in:
parent
3149b86c4c
commit
c2e4e01201
@ -1,3 +1,21 @@
|
||||
//
|
||||
// Copyright (c) 2009 Mikko Mononen memon@inside.org
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would be
|
||||
// appreciated but is not required.
|
||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||
// misrepresented as being the original software.
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
|
||||
#ifndef DETOURCOMMON_H
|
||||
#define DETOURCOMMON_H
|
||||
|
||||
|
@ -52,6 +52,9 @@ struct dtStatNavMeshHeader
|
||||
int nnodes;
|
||||
float cs;
|
||||
float bmin[3], bmax[3];
|
||||
dtStatPoly* polys;
|
||||
float* verts;
|
||||
dtStatBVNode* bvtree;
|
||||
};
|
||||
|
||||
class dtStatNavMesh
|
||||
@ -161,11 +164,11 @@ public:
|
||||
// Returns number of navigation polygons.
|
||||
inline int getPolyCount() const { return m_header ? m_header->npolys : 0; }
|
||||
// Rerturns pointer to specified navigation polygon.
|
||||
inline const dtStatPoly* getPoly(int i) const { return &m_polys[i]; }
|
||||
inline const dtStatPoly* getPoly(int i) const { return &m_header->polys[i]; }
|
||||
// Returns number of vertices.
|
||||
inline int getVertexCount() const { return m_header ? m_header->nverts : 0; }
|
||||
// Returns pointer to specified vertex.
|
||||
inline const float* getVertex(int i) const { return &m_verts[i*3]; }
|
||||
inline const float* getVertex(int i) const { return &m_header->verts[i*3]; }
|
||||
|
||||
bool isInOpenList(dtStatPolyRef ref) const;
|
||||
|
||||
@ -173,8 +176,8 @@ public:
|
||||
|
||||
inline const dtStatNavMeshHeader* getHeader() const { return m_header; }
|
||||
|
||||
inline const dtStatBVNode* getBvTreeNodes() const { return m_bvtree; }
|
||||
inline int getBvTreeNodeCount() const { return m_header->nnodes; }
|
||||
inline const dtStatBVNode* getBvTreeNodes() const { return m_header ? m_header->bvtree : 0; }
|
||||
inline int getBvTreeNodeCount() const { return m_header ? m_header->nnodes : 0; }
|
||||
|
||||
private:
|
||||
|
||||
@ -190,9 +193,6 @@ private:
|
||||
int m_dataSize;
|
||||
|
||||
dtStatNavMeshHeader* m_header;
|
||||
dtStatPoly* m_polys;
|
||||
float* m_verts;
|
||||
dtStatBVNode* m_bvtree;
|
||||
|
||||
class dtNodePool* m_nodePool;
|
||||
class dtNodeQueue* m_openList;
|
||||
|
@ -1,3 +1,20 @@
|
||||
//
|
||||
// Copyright (c) 2009 Mikko Mononen memon@inside.org
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would be
|
||||
// appreciated but is not required.
|
||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||
// misrepresented as being the original software.
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
|
||||
#include <math.h>
|
||||
#include "DetourCommon.h"
|
||||
|
@ -190,12 +190,6 @@ void dtDebugDrawStatNavMesh(const dtStatNavMesh* mesh)
|
||||
|
||||
static void drawTile(const dtTileHeader* header)
|
||||
{
|
||||
const float col[4] = {0,0,0,0.25f};
|
||||
/* glBegin(GL_LINES);
|
||||
drawBoxWire(header->bmin[0],header->bmin[1],header->bmin[2],
|
||||
header->bmax[0],header->bmax[1],header->bmax[2], col);
|
||||
glEnd();*/
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
for (int i = 0; i < header->npolys; ++i)
|
||||
{
|
||||
|
@ -1,3 +1,20 @@
|
||||
//
|
||||
// Copyright (c) 2009 Mikko Mononen memon@inside.org
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would be
|
||||
// appreciated but is not required.
|
||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||
// misrepresented as being the original software.
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
|
||||
#include "DetourNode.h"
|
||||
#include <string.h>
|
||||
|
@ -28,9 +28,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
dtStatNavMesh::dtStatNavMesh() :
|
||||
m_header(0),
|
||||
m_polys(0),
|
||||
m_verts(0),
|
||||
m_bvtree(0),
|
||||
m_nodePool(0),
|
||||
m_openList(0),
|
||||
m_data(0),
|
||||
@ -59,9 +56,9 @@ bool dtStatNavMesh::init(unsigned char* data, int dataSize, bool ownsData)
|
||||
const int vertsSize = sizeof(float)*3*header->nverts;
|
||||
const int polysSize = sizeof(dtStatPoly)*header->npolys;
|
||||
|
||||
m_verts = (float*)(data + headerSize);
|
||||
m_polys = (dtStatPoly*)(data + headerSize + vertsSize);
|
||||
m_bvtree = (dtStatBVNode*)(data + headerSize + vertsSize + polysSize);
|
||||
header->verts = (float*)(data + headerSize);
|
||||
header->polys = (dtStatPoly*)(data + headerSize + vertsSize);
|
||||
header->bvtree = (dtStatBVNode*)(data + headerSize + vertsSize + polysSize);
|
||||
|
||||
m_nodePool = new dtNodePool(2048, 256);
|
||||
if (!m_nodePool)
|
||||
@ -87,8 +84,8 @@ float dtStatNavMesh::getCost(dtStatPolyRef prev, dtStatPolyRef from, dtStatPolyR
|
||||
const dtStatPoly* fromPoly = getPoly(prev ? prev-1 : from-1);
|
||||
const dtStatPoly* toPoly = getPoly(to-1);
|
||||
float fromPc[3], toPc[3];
|
||||
calcPolyCenter(fromPc, fromPoly->v, fromPoly->nv, m_verts);
|
||||
calcPolyCenter(toPc, toPoly->v, toPoly->nv, m_verts);
|
||||
calcPolyCenter(fromPc, fromPoly->v, fromPoly->nv, m_header->verts);
|
||||
calcPolyCenter(toPc, toPoly->v, toPoly->nv, m_header->verts);
|
||||
|
||||
float dx = fromPc[0]-toPc[0];
|
||||
float dy = fromPc[1]-toPc[1];
|
||||
@ -102,8 +99,8 @@ float dtStatNavMesh::getHeuristic(dtStatPolyRef from, dtStatPolyRef to) const
|
||||
const dtStatPoly* fromPoly = getPoly(from-1);
|
||||
const dtStatPoly* toPoly = getPoly(to-1);
|
||||
float fromPc[3], toPc[3];
|
||||
calcPolyCenter(fromPc, fromPoly->v, fromPoly->nv, m_verts);
|
||||
calcPolyCenter(toPc, toPoly->v, toPoly->nv, m_verts);
|
||||
calcPolyCenter(fromPc, fromPoly->v, fromPoly->nv, m_header->verts);
|
||||
calcPolyCenter(toPc, toPoly->v, toPoly->nv, m_header->verts);
|
||||
|
||||
float dx = fromPc[0]-toPc[0];
|
||||
float dy = fromPc[1]-toPc[1];
|
||||
@ -115,7 +112,7 @@ float dtStatNavMesh::getHeuristic(dtStatPolyRef from, dtStatPolyRef to) const
|
||||
const dtStatPoly* dtStatNavMesh::getPolyByRef(dtStatPolyRef ref) const
|
||||
{
|
||||
if (!m_header || ref == 0 || (int)ref > m_header->npolys) return 0;
|
||||
return &m_polys[ref-1];
|
||||
return &m_header->polys[ref-1];
|
||||
}
|
||||
|
||||
int dtStatNavMesh::findPath(dtStatPolyRef startRef, dtStatPolyRef endRef,
|
||||
@ -415,7 +412,7 @@ int dtStatNavMesh::getPolyVerts(dtStatPolyRef ref, float* verts) const
|
||||
float* v = verts;
|
||||
for (int i = 0; i < (int)poly->nv; ++i)
|
||||
{
|
||||
const float* cv = &m_verts[poly->v[i]*3];
|
||||
const float* cv = &m_header->verts[poly->v[i]*3];
|
||||
*v++ = cv[0];
|
||||
*v++ = cv[1];
|
||||
*v++ = cv[2];
|
||||
@ -702,8 +699,8 @@ int dtStatNavMesh::queryPolygons(const float* center, const float* extents,
|
||||
{
|
||||
if (!m_header) return 0;
|
||||
|
||||
const dtStatBVNode* node = &m_bvtree[0];
|
||||
const dtStatBVNode* end = &m_bvtree[m_header->nnodes];
|
||||
const dtStatBVNode* node = &m_header->bvtree[0];
|
||||
const dtStatBVNode* end = &m_header->bvtree[m_header->nnodes];
|
||||
|
||||
// Calculate quantized box
|
||||
const float ics = 1.0f / m_header->cs;
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -268,7 +268,8 @@
|
||||
<array>
|
||||
<string>29B97314FDCFA39411CA2CEA</string>
|
||||
<string>080E96DDFE201D6D7F000001</string>
|
||||
<string>6B555DF5100B25FC00247EA3</string>
|
||||
<string>6BDD9E030F91110C00904EEF</string>
|
||||
<string>6B137C7D0F7FCBE800459200</string>
|
||||
<string>29B97315FDCFA39411CA2CEA</string>
|
||||
<string>29B97317FDCFA39411CA2CEA</string>
|
||||
<string>1C37FBAC04509CD000000102</string>
|
||||
@ -277,7 +278,8 @@
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||
<array>
|
||||
<array>
|
||||
<integer>16</integer>
|
||||
<integer>11</integer>
|
||||
<integer>3</integer>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
@ -318,7 +320,7 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>main.cpp</string>
|
||||
<string>DetourTileNavMesh.cpp</string>
|
||||
<key>PBXSplitModuleInNavigatorKey</key>
|
||||
<dict>
|
||||
<key>Split0</key>
|
||||
@ -326,11 +328,11 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A40F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>main.cpp</string>
|
||||
<string>DetourTileNavMesh.cpp</string>
|
||||
<key>_historyCapacity</key>
|
||||
<integer>0</integer>
|
||||
<key>bookmark</key>
|
||||
<string>6B555F02100B431000247EA3</string>
|
||||
<string>6B555F52100B4CE300247EA3</string>
|
||||
<key>history</key>
|
||||
<array>
|
||||
<string>6BB87E0B0F9DE8A300E33F12</string>
|
||||
@ -357,22 +359,12 @@
|
||||
<string>6B024C011006098300CF7107</string>
|
||||
<string>6B024C1110060C7600CF7107</string>
|
||||
<string>6B1186211006945C0018F96F</string>
|
||||
<string>6B1186231006945C0018F96F</string>
|
||||
<string>6B1186241006945C0018F96F</string>
|
||||
<string>6B1186251006945C0018F96F</string>
|
||||
<string>6B1186A1100698B70018F96F</string>
|
||||
<string>6B1186CD100699A00018F96F</string>
|
||||
<string>6B1186CE100699A00018F96F</string>
|
||||
<string>6B1186CF100699A00018F96F</string>
|
||||
<string>6B1186D0100699A00018F96F</string>
|
||||
<string>6B1186D1100699A00018F96F</string>
|
||||
<string>6B1186D2100699A00018F96F</string>
|
||||
<string>6B1186E610069E200018F96F</string>
|
||||
<string>6B7EBB69100721310066EF8C</string>
|
||||
<string>6B8EF40C1007653C003F8851</string>
|
||||
<string>6B555D23100B136A00247EA3</string>
|
||||
<string>6B555D24100B136A00247EA3</string>
|
||||
<string>6B555D2F100B143200247EA3</string>
|
||||
<string>6B555D30100B143200247EA3</string>
|
||||
<string>6B555E01100B285300247EA3</string>
|
||||
<string>6B555E04100B285300247EA3</string>
|
||||
@ -381,18 +373,28 @@
|
||||
<string>6B555E79100B350E00247EA3</string>
|
||||
<string>6B555E7B100B350E00247EA3</string>
|
||||
<string>6B555E7C100B350E00247EA3</string>
|
||||
<string>6B555E8A100B35E000247EA3</string>
|
||||
<string>6B555E9D100B37AB00247EA3</string>
|
||||
<string>6B555E9E100B37AB00247EA3</string>
|
||||
<string>6B555E9F100B37AB00247EA3</string>
|
||||
<string>6B555EA1100B37AB00247EA3</string>
|
||||
<string>6B555EA2100B37AB00247EA3</string>
|
||||
<string>6B555EA3100B37AB00247EA3</string>
|
||||
<string>6B555EA4100B37AB00247EA3</string>
|
||||
<string>6B555EDE100B39A600247EA3</string>
|
||||
<string>6B555EF6100B42E600247EA3</string>
|
||||
<string>6B555EF7100B42E600247EA3</string>
|
||||
<string>6B555EF8100B42E600247EA3</string>
|
||||
<string>6B555F0C100B473F00247EA3</string>
|
||||
<string>6B555F0D100B473F00247EA3</string>
|
||||
<string>6B555F0E100B473F00247EA3</string>
|
||||
<string>6B555F0F100B473F00247EA3</string>
|
||||
<string>6B555F10100B473F00247EA3</string>
|
||||
<string>6B555F11100B473F00247EA3</string>
|
||||
<string>6B555F12100B473F00247EA3</string>
|
||||
<string>6B555F13100B473F00247EA3</string>
|
||||
<string>6B555F15100B473F00247EA3</string>
|
||||
<string>6B555F2A100B499000247EA3</string>
|
||||
<string>6B555F2B100B499000247EA3</string>
|
||||
<string>6B555F2C100B499000247EA3</string>
|
||||
<string>6B555F2D100B499000247EA3</string>
|
||||
<string>6B555F40100B4C5800247EA3</string>
|
||||
<string>6B555F41100B4C5800247EA3</string>
|
||||
<string>6B555F42100B4C5800247EA3</string>
|
||||
<string>6B555F43100B4C5800247EA3</string>
|
||||
<string>6B555F44100B4C5800247EA3</string>
|
||||
</array>
|
||||
<key>prevStack</key>
|
||||
<array>
|
||||
@ -433,7 +435,6 @@
|
||||
<string>6B0249051001EABD00CF7107</string>
|
||||
<string>6B02498D1003751300CF7107</string>
|
||||
<string>6B024A721004A2FE00CF7107</string>
|
||||
<string>6B024B1B1004C7E200CF7107</string>
|
||||
<string>6B024BBB1005DF5700CF7107</string>
|
||||
<string>6B024BCF1005DFAB00CF7107</string>
|
||||
<string>6B024C041006098300CF7107</string>
|
||||
@ -590,6 +591,38 @@
|
||||
<string>6B555EF9100B42E600247EA3</string>
|
||||
<string>6B555EFA100B42E600247EA3</string>
|
||||
<string>6B555EFB100B42E600247EA3</string>
|
||||
<string>6B555F17100B473F00247EA3</string>
|
||||
<string>6B555F18100B473F00247EA3</string>
|
||||
<string>6B555F19100B473F00247EA3</string>
|
||||
<string>6B555F1A100B473F00247EA3</string>
|
||||
<string>6B555F1B100B473F00247EA3</string>
|
||||
<string>6B555F1C100B473F00247EA3</string>
|
||||
<string>6B555F1D100B473F00247EA3</string>
|
||||
<string>6B555F1E100B473F00247EA3</string>
|
||||
<string>6B555F1F100B473F00247EA3</string>
|
||||
<string>6B555F20100B473F00247EA3</string>
|
||||
<string>6B555F21100B473F00247EA3</string>
|
||||
<string>6B555F22100B473F00247EA3</string>
|
||||
<string>6B555F23100B473F00247EA3</string>
|
||||
<string>6B555F30100B499000247EA3</string>
|
||||
<string>6B555F31100B499000247EA3</string>
|
||||
<string>6B555F32100B499000247EA3</string>
|
||||
<string>6B555F33100B499000247EA3</string>
|
||||
<string>6B555F34100B499000247EA3</string>
|
||||
<string>6B555F35100B499000247EA3</string>
|
||||
<string>6B555F36100B499000247EA3</string>
|
||||
<string>6B555F37100B499000247EA3</string>
|
||||
<string>6B555F38100B499000247EA3</string>
|
||||
<string>6B555F45100B4C5800247EA3</string>
|
||||
<string>6B555F46100B4C5800247EA3</string>
|
||||
<string>6B555F47100B4C5800247EA3</string>
|
||||
<string>6B555F48100B4C5800247EA3</string>
|
||||
<string>6B555F49100B4C5800247EA3</string>
|
||||
<string>6B555F4A100B4C5800247EA3</string>
|
||||
<string>6B555F4B100B4C5800247EA3</string>
|
||||
<string>6B555F4C100B4C5800247EA3</string>
|
||||
<string>6B555F4D100B4C5800247EA3</string>
|
||||
<string>6B555F4E100B4C5800247EA3</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
|
@ -1,3 +1,21 @@
|
||||
//
|
||||
// Copyright (c) 2009 Mikko Mononen memon@inside.org
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would be
|
||||
// appreciated but is not required.
|
||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||
// misrepresented as being the original software.
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
|
||||
#ifndef IMGUI_RENDER_GL_H
|
||||
#define IMGUI_RENDER_GL_H
|
||||
|
||||
|
@ -1,3 +1,21 @@
|
||||
//
|
||||
// Copyright (c) 2009 Mikko Mononen memon@inside.org
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would be
|
||||
// appreciated but is not required.
|
||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||
// misrepresented as being the original software.
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
|
||||
#include <math.h>
|
||||
#include "imgui.h"
|
||||
#include "SDL.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user