tools improvement (#926)

* tools improvement

* added "Source/DetourAssert.cpp" to recastnavigation/Detour/CMakeLists.txt

* increased MMAP and VMAP version numbers

* Will need to re extract MMAPS and VMAPS
This commit is contained in:
Stoabrogga
2018-07-13 13:46:04 +02:00
committed by Lee
parent 02d14df9b8
commit a18d1474a3
22 changed files with 256 additions and 97 deletions

View File

@@ -10,6 +10,7 @@
set(Detour_STAT_SRCS set(Detour_STAT_SRCS
Source/DetourAlloc.cpp Source/DetourAlloc.cpp
Source/DetourAssert.cpp
Source/DetourCommon.cpp Source/DetourCommon.cpp
Source/DetourNavMesh.cpp Source/DetourNavMesh.cpp
Source/DetourNavMeshBuilder.cpp Source/DetourNavMeshBuilder.cpp

View File

@@ -23,11 +23,34 @@
// Feel free to change the file and include your own implementation instead. // Feel free to change the file and include your own implementation instead.
#ifdef NDEBUG #ifdef NDEBUG
// From http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/ // From http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/
# define dtAssert(x) do { (void)sizeof(x); } while((void)(__LINE__==-1),false) # define dtAssert(x) do { (void)sizeof(x); } while((void)(__LINE__==-1),false)
#else #else
/// An assertion failure function.
// @param[in] expression asserted expression.
// @param[in] file Filename of the failed assertion.
// @param[in] line Line number of the failed assertion.
/// @see dtAssertFailSetCustom
typedef void (dtAssertFailFunc)(const char* expression, const char* file, int line);
/// Sets the base custom assertion failure function to be used by Detour.
/// @param[in] assertFailFunc The function to be invoked in case of failure of #dtAssert
void dtAssertFailSetCustom(dtAssertFailFunc *assertFailFunc);
/// Gets the base custom assertion failure function to be used by Detour.
dtAssertFailFunc* dtAssertFailGetCustom();
# include <assert.h> # include <assert.h>
# define dtAssert assert # define dtAssert(expression) \
{ \
dtAssertFailFunc* failFunc = dtAssertFailGetCustom(); \
if(failFunc == NULL) { assert(expression); } \
else if(!(expression)) { (*failFunc)(#expression, __FILE__, __LINE__); } \
}
#endif #endif
#endif // DETOURASSERT_H #endif // DETOURASSERT_H

View File

@@ -647,7 +647,7 @@ private:
dtPolyRef* polys, const int maxPolys) const; dtPolyRef* polys, const int maxPolys) const;
/// Find nearest polygon within a tile. /// Find nearest polygon within a tile.
dtPolyRef findNearestPolyInTile(const dtMeshTile* tile, const float* center, dtPolyRef findNearestPolyInTile(const dtMeshTile* tile, const float* center,
const float* extents, float* nearestPt) const; const float* halfExtents, float* nearestPt) const;
/// Returns closest point on polygon. /// Returns closest point on polygon.
void closestPointOnPoly(dtPolyRef ref, const float* pos, float* closest, bool* posOverPoly) const; void closestPointOnPoly(dtPolyRef ref, const float* pos, float* closest, bool* posOverPoly) const;

View File

@@ -316,33 +316,33 @@ public:
/// Finds the polygon nearest to the specified center point. /// Finds the polygon nearest to the specified center point.
/// @param[in] center The center of the search box. [(x, y, z)] /// @param[in] center The center of the search box. [(x, y, z)]
/// @param[in] extents The search distance along each axis. [(x, y, z)] /// @param[in] halfExtents The search distance along each axis. [(x, y, z)]
/// @param[in] filter The polygon filter to apply to the query. /// @param[in] filter The polygon filter to apply to the query.
/// @param[out] nearestRef The reference id of the nearest polygon. /// @param[out] nearestRef The reference id of the nearest polygon.
/// @param[out] nearestPt The nearest point on the polygon. [opt] [(x, y, z)] /// @param[out] nearestPt The nearest point on the polygon. [opt] [(x, y, z)]
/// @returns The status flags for the query. /// @returns The status flags for the query.
dtStatus findNearestPoly(const float* center, const float* extents, dtStatus findNearestPoly(const float* center, const float* halfExtents,
const dtQueryFilter* filter, const dtQueryFilter* filter,
dtPolyRef* nearestRef, float* nearestPt) const; dtPolyRef* nearestRef, float* nearestPt) const;
/// Finds polygons that overlap the search box. /// Finds polygons that overlap the search box.
/// @param[in] center The center of the search box. [(x, y, z)] /// @param[in] center The center of the search box. [(x, y, z)]
/// @param[in] extents The search distance along each axis. [(x, y, z)] /// @param[in] halfExtents The search distance along each axis. [(x, y, z)]
/// @param[in] filter The polygon filter to apply to the query. /// @param[in] filter The polygon filter to apply to the query.
/// @param[out] polys The reference ids of the polygons that overlap the query box. /// @param[out] polys The reference ids of the polygons that overlap the query box.
/// @param[out] polyCount The number of polygons in the search result. /// @param[out] polyCount The number of polygons in the search result.
/// @param[in] maxPolys The maximum number of polygons the search result can hold. /// @param[in] maxPolys The maximum number of polygons the search result can hold.
/// @returns The status flags for the query. /// @returns The status flags for the query.
dtStatus queryPolygons(const float* center, const float* extents, dtStatus queryPolygons(const float* center, const float* halfExtents,
const dtQueryFilter* filter, const dtQueryFilter* filter,
dtPolyRef* polys, int* polyCount, const int maxPolys) const; dtPolyRef* polys, int* polyCount, const int maxPolys) const;
/// Finds polygons that overlap the search box. /// Finds polygons that overlap the search box.
/// @param[in] center The center of the search box. [(x, y, z)] /// @param[in] center The center of the search box. [(x, y, z)]
/// @param[in] extents The search distance along each axis. [(x, y, z)] /// @param[in] halfExtents The search distance along each axis. [(x, y, z)]
/// @param[in] filter The polygon filter to apply to the query. /// @param[in] filter The polygon filter to apply to the query.
/// @param[in] query The query. Polygons found will be batched together and passed to this query. /// @param[in] query The query. Polygons found will be batched together and passed to this query.
dtStatus queryPolygons(const float* center, const float* extents, dtStatus queryPolygons(const float* center, const float* halfExtents,
const dtQueryFilter* filter, dtPolyQuery* query) const; const dtQueryFilter* filter, dtPolyQuery* query) const;
/// Finds the non-overlapping navigation polygons in the local neighbourhood around the center position. /// Finds the non-overlapping navigation polygons in the local neighbourhood around the center position.

View File

@@ -0,0 +1,35 @@
//
// Copyright (c) 2009-2010 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 "DetourAssert.h"
#ifndef NDEBUG
static dtAssertFailFunc* sAssertFailFunc = 0;
void dtAssertFailSetCustom(dtAssertFailFunc *assertFailFunc)
{
sAssertFailFunc = assertFailFunc;
}
dtAssertFailFunc* dtAssertFailGetCustom()
{
return sAssertFailFunc;
}
#endif

View File

@@ -342,8 +342,8 @@ void dtRandomPointInConvexPoly(const float* pts, const int npts, float* areas,
// Find sub triangle weighted by area. // Find sub triangle weighted by area.
const float thr = s*areasum; const float thr = s*areasum;
float acc = 0.0f; float acc = 0.0f;
float u = 0.0f; float u = 1.0f;
int tri = 0; int tri = npts - 1;
for (int i = 2; i < npts; i++) { for (int i = 2; i < npts; i++) {
const float dacc = areas[i]; const float dacc = areas[i];
if (thr >= acc && thr < (acc+dacc)) if (thr >= acc && thr < (acc+dacc))

View File

@@ -470,12 +470,12 @@ void dtNavMesh::connectExtOffMeshLinks(dtMeshTile* tile, dtMeshTile* target, int
if (targetPoly->firstLink == DT_NULL_LINK) if (targetPoly->firstLink == DT_NULL_LINK)
continue; continue;
const float ext[3] = { targetCon->rad, target->header->walkableClimb, targetCon->rad }; const float halfExtents[3] = { targetCon->rad, target->header->walkableClimb, targetCon->rad };
// Find polygon to connect to. // Find polygon to connect to.
const float* p = &targetCon->pos[3]; const float* p = &targetCon->pos[3];
float nearestPt[3]; float nearestPt[3];
dtPolyRef ref = findNearestPolyInTile(tile, p, ext, nearestPt); dtPolyRef ref = findNearestPolyInTile(tile, p, halfExtents, nearestPt);
if (!ref) if (!ref)
continue; continue;
// findNearestPoly may return too optimistic results, further check to make sure. // findNearestPoly may return too optimistic results, further check to make sure.
@@ -570,12 +570,12 @@ void dtNavMesh::baseOffMeshLinks(dtMeshTile* tile)
dtOffMeshConnection* con = &tile->offMeshCons[i]; dtOffMeshConnection* con = &tile->offMeshCons[i];
dtPoly* poly = &tile->polys[con->poly]; dtPoly* poly = &tile->polys[con->poly];
const float ext[3] = { con->rad, tile->header->walkableClimb, con->rad }; const float halfExtents[3] = { con->rad, tile->header->walkableClimb, con->rad };
// Find polygon to connect to. // Find polygon to connect to.
const float* p = &con->pos[0]; // First vertex const float* p = &con->pos[0]; // First vertex
float nearestPt[3]; float nearestPt[3];
dtPolyRef ref = findNearestPolyInTile(tile, p, ext, nearestPt); dtPolyRef ref = findNearestPolyInTile(tile, p, halfExtents, nearestPt);
if (!ref) continue; if (!ref) continue;
// findNearestPoly may return too optimistic results, further check to make sure. // findNearestPoly may return too optimistic results, further check to make sure.
if (dtSqr(nearestPt[0]-p[0])+dtSqr(nearestPt[2]-p[2]) > dtSqr(con->rad)) if (dtSqr(nearestPt[0]-p[0])+dtSqr(nearestPt[2]-p[2]) > dtSqr(con->rad))
@@ -687,7 +687,7 @@ void dtNavMesh::closestPointOnPoly(dtPolyRef ref, const float* pos, float* close
v[k] = &tile->detailVerts[(pd->vertBase+(t[k]-poly->vertCount))*3]; v[k] = &tile->detailVerts[(pd->vertBase+(t[k]-poly->vertCount))*3];
} }
float h; float h;
if (dtClosestHeightPointTriangle(pos, v[0], v[1], v[2], h)) if (dtClosestHeightPointTriangle(closest, v[0], v[1], v[2], h))
{ {
closest[1] = h; closest[1] = h;
break; break;
@@ -696,12 +696,12 @@ void dtNavMesh::closestPointOnPoly(dtPolyRef ref, const float* pos, float* close
} }
dtPolyRef dtNavMesh::findNearestPolyInTile(const dtMeshTile* tile, dtPolyRef dtNavMesh::findNearestPolyInTile(const dtMeshTile* tile,
const float* center, const float* extents, const float* center, const float* halfExtents,
float* nearestPt) const float* nearestPt) const
{ {
float bmin[3], bmax[3]; float bmin[3], bmax[3];
dtVsub(bmin, center, extents); dtVsub(bmin, center, halfExtents);
dtVadd(bmax, center, extents); dtVadd(bmax, center, halfExtents);
// Get nearby polygons from proximity grid. // Get nearby polygons from proximity grid.
dtPolyRef polys[128]; dtPolyRef polys[128];

View File

@@ -168,29 +168,55 @@ static void subdivide(BVItem* items, int nitems, int imin, int imax, int& curNod
} }
} }
static int createBVTree(const unsigned short* verts, const int /*nverts*/, static int createBVTree(dtNavMeshCreateParams* params, dtBVNode* nodes, int /*nnodes*/)
const unsigned short* polys, const int npolys, const int nvp,
const float cs, const float ch,
const int /*nnodes*/, dtBVNode* nodes)
{ {
// Build tree // Build tree
BVItem* items = (BVItem*)dtAlloc(sizeof(BVItem)*npolys, DT_ALLOC_TEMP); float quantFactor = 1 / params->cs;
for (int i = 0; i < npolys; i++) BVItem* items = (BVItem*)dtAlloc(sizeof(BVItem)*params->polyCount, DT_ALLOC_TEMP);
for (int i = 0; i < params->polyCount; i++)
{ {
BVItem& it = items[i]; BVItem& it = items[i];
it.i = i; it.i = i;
// Calc polygon bounds. // Calc polygon bounds. Use detail meshes if available.
const unsigned short* p = &polys[i*nvp*2]; if (params->detailMeshes)
it.bmin[0] = it.bmax[0] = verts[p[0]*3+0]; {
it.bmin[1] = it.bmax[1] = verts[p[0]*3+1]; int vb = (int)params->detailMeshes[i*4+0];
it.bmin[2] = it.bmax[2] = verts[p[0]*3+2]; int ndv = (int)params->detailMeshes[i*4+1];
float bmin[3];
float bmax[3];
for (int j = 1; j < nvp; ++j) const float* dv = &params->detailVerts[vb*3];
dtVcopy(bmin, dv);
dtVcopy(bmax, dv);
for (int j = 1; j < ndv; j++)
{
dtVmin(bmin, &dv[j * 3]);
dtVmax(bmax, &dv[j * 3]);
}
// BV-tree uses cs for all dimensions
it.bmin[0] = (unsigned short)dtClamp((int)((bmin[0] - params->bmin[0])*quantFactor), 0, 0xffff);
it.bmin[1] = (unsigned short)dtClamp((int)((bmin[1] - params->bmin[1])*quantFactor), 0, 0xffff);
it.bmin[2] = (unsigned short)dtClamp((int)((bmin[2] - params->bmin[2])*quantFactor), 0, 0xffff);
it.bmax[0] = (unsigned short)dtClamp((int)((bmax[0] - params->bmin[0])*quantFactor), 0, 0xffff);
it.bmax[1] = (unsigned short)dtClamp((int)((bmax[1] - params->bmin[1])*quantFactor), 0, 0xffff);
it.bmax[2] = (unsigned short)dtClamp((int)((bmax[2] - params->bmin[2])*quantFactor), 0, 0xffff);
}
else
{
const unsigned short* p = &params->polys[i*params->nvp * 2];
it.bmin[0] = it.bmax[0] = params->verts[p[0] * 3 + 0];
it.bmin[1] = it.bmax[1] = params->verts[p[0] * 3 + 1];
it.bmin[2] = it.bmax[2] = params->verts[p[0] * 3 + 2];
for (int j = 1; j < params->nvp; ++j)
{ {
if (p[j] == MESH_NULL_IDX) break; if (p[j] == MESH_NULL_IDX) break;
unsigned short x = verts[p[j]*3+0]; unsigned short x = params->verts[p[j] * 3 + 0];
unsigned short y = verts[p[j]*3+1]; unsigned short y = params->verts[p[j] * 3 + 1];
unsigned short z = verts[p[j]*3+2]; unsigned short z = params->verts[p[j] * 3 + 2];
if (x < it.bmin[0]) it.bmin[0] = x; if (x < it.bmin[0]) it.bmin[0] = x;
if (y < it.bmin[1]) it.bmin[1] = y; if (y < it.bmin[1]) it.bmin[1] = y;
@@ -201,12 +227,13 @@ static int createBVTree(const unsigned short* verts, const int /*nverts*/,
if (z > it.bmax[2]) it.bmax[2] = z; if (z > it.bmax[2]) it.bmax[2] = z;
} }
// Remap y // Remap y
it.bmin[1] = (unsigned short)dtMathFloorf((float)it.bmin[1]*ch/cs); it.bmin[1] = (unsigned short)dtMathFloorf((float)it.bmin[1] * params->ch / params->cs);
it.bmax[1] = (unsigned short)dtMathCeilf((float)it.bmax[1]*ch/cs); it.bmax[1] = (unsigned short)dtMathCeilf((float)it.bmax[1] * params->ch / params->cs);
}
} }
int curNode = 0; int curNode = 0;
subdivide(items, npolys, 0, npolys, curNode, nodes); subdivide(items, params->polyCount, 0, params->polyCount, curNode, nodes);
dtFree(items); dtFree(items);
@@ -595,11 +622,9 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData,
} }
// Store and create BVtree. // Store and create BVtree.
// TODO: take detail mesh into account! use byte per bbox extent?
if (params->buildBvTree) if (params->buildBvTree)
{ {
createBVTree(params->verts, params->vertCount, params->polys, params->polyCount, createBVTree(params, navBvtree, 2*params->polyCount);
nvp, params->cs, params->ch, params->polyCount*2, navBvtree);
} }
// Store Off-Mesh connections. // Store Off-Mesh connections.

View File

@@ -578,7 +578,7 @@ dtStatus dtNavMeshQuery::closestPointOnPoly(dtPolyRef ref, const float* pos, flo
v[k] = &tile->detailVerts[(pd->vertBase+(t[k]-poly->vertCount))*3]; v[k] = &tile->detailVerts[(pd->vertBase+(t[k]-poly->vertCount))*3];
} }
float h; float h;
if (dtClosestHeightPointTriangle(pos, v[0], v[1], v[2], h)) if (dtClosestHeightPointTriangle(closest, v[0], v[1], v[2], h))
{ {
closest[1] = h; closest[1] = h;
break; break;
@@ -759,7 +759,7 @@ public:
/// return #DT_SUCCESS, but @p nearestRef will be zero. So if in doubt, check /// return #DT_SUCCESS, but @p nearestRef will be zero. So if in doubt, check
/// @p nearestRef before using @p nearestPt. /// @p nearestRef before using @p nearestPt.
/// ///
dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* extents, dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* halfExtents,
const dtQueryFilter* filter, const dtQueryFilter* filter,
dtPolyRef* nearestRef, float* nearestPt) const dtPolyRef* nearestRef, float* nearestPt) const
{ {
@@ -770,7 +770,7 @@ dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* exten
dtFindNearestPolyQuery query(this, center); dtFindNearestPolyQuery query(this, center);
dtStatus status = queryPolygons(center, extents, filter, &query); dtStatus status = queryPolygons(center, halfExtents, filter, &query);
if (dtStatusFailed(status)) if (dtStatusFailed(status))
return status; return status;
@@ -943,7 +943,7 @@ public:
/// be filled to capacity. The method of choosing which polygons from the /// be filled to capacity. The method of choosing which polygons from the
/// full set are included in the partial result set is undefined. /// full set are included in the partial result set is undefined.
/// ///
dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* extents, dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* halfExtents,
const dtQueryFilter* filter, const dtQueryFilter* filter,
dtPolyRef* polys, int* polyCount, const int maxPolys) const dtPolyRef* polys, int* polyCount, const int maxPolys) const
{ {
@@ -952,7 +952,7 @@ dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* extents
dtCollectPolysQuery collector(polys, maxPolys); dtCollectPolysQuery collector(polys, maxPolys);
dtStatus status = queryPolygons(center, extents, filter, &collector); dtStatus status = queryPolygons(center, halfExtents, filter, &collector);
if (dtStatusFailed(status)) if (dtStatusFailed(status))
return status; return status;
@@ -963,21 +963,21 @@ dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* extents
/// @par /// @par
/// ///
/// The query will be invoked with batches of polygons. Polygons passed /// The query will be invoked with batches of polygons. Polygons passed
/// to the query have bounding boxes that overlap with the center and extents /// to the query have bounding boxes that overlap with the center and halfExtents
/// passed to this function. The dtPolyQuery::process function is invoked multiple /// passed to this function. The dtPolyQuery::process function is invoked multiple
/// times until all overlapping polygons have been processed. /// times until all overlapping polygons have been processed.
/// ///
dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* extents, dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* halfExtents,
const dtQueryFilter* filter, dtPolyQuery* query) const const dtQueryFilter* filter, dtPolyQuery* query) const
{ {
dtAssert(m_nav); dtAssert(m_nav);
if (!center || !extents || !filter || !query) if (!center || !halfExtents || !filter || !query)
return DT_FAILURE | DT_INVALID_PARAM; return DT_FAILURE | DT_INVALID_PARAM;
float bmin[3], bmax[3]; float bmin[3], bmax[3];
dtVsub(bmin, center, extents); dtVsub(bmin, center, halfExtents);
dtVadd(bmax, center, extents); dtVadd(bmax, center, halfExtents);
// Find tiles the query touches. // Find tiles the query touches.
int minx, miny, maxx, maxy; int minx, miny, maxx, maxy;

View File

@@ -11,6 +11,7 @@
set(Recast_STAT_SRCS set(Recast_STAT_SRCS
Source/Recast.cpp Source/Recast.cpp
Source/RecastAlloc.cpp Source/RecastAlloc.cpp
Source/RecastAssert.cpp
Source/RecastArea.cpp Source/RecastArea.cpp
Source/RecastContour.cpp Source/RecastContour.cpp
Source/RecastFilter.cpp Source/RecastFilter.cpp

View File

@@ -23,11 +23,34 @@
// Feel free to change the file and include your own implementation instead. // Feel free to change the file and include your own implementation instead.
#ifdef NDEBUG #ifdef NDEBUG
// From http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/ // From http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/
# define rcAssert(x) do { (void)sizeof(x); } while((void)(__LINE__==-1),false) # define rcAssert(x) do { (void)sizeof(x); } while((void)(__LINE__==-1),false)
#else #else
/// An assertion failure function.
// @param[in] expression asserted expression.
// @param[in] file Filename of the failed assertion.
// @param[in] line Line number of the failed assertion.
/// @see rcAssertFailSetCustom
typedef void (rcAssertFailFunc)(const char* expression, const char* file, int line);
/// Sets the base custom assertion failure function to be used by Recast.
/// @param[in] assertFailFunc The function to be used in case of failure of #dtAssert
void rcAssertFailSetCustom(rcAssertFailFunc *assertFailFunc);
/// Gets the base custom assertion failure function to be used by Recast.
rcAssertFailFunc* rcAssertFailGetCustom();
# include <assert.h> # include <assert.h>
# define rcAssert assert # define rcAssert(expression) \
{ \
rcAssertFailFunc* failFunc = rcAssertFailGetCustom(); \
if(failFunc == NULL) { assert(expression); } \
else if(!(expression)) { (*failFunc)(#expression, __FILE__, __LINE__); } \
}
#endif #endif
#endif // RECASTASSERT_H #endif // RECASTASSERT_H

View File

@@ -0,0 +1,35 @@
//
// Copyright (c) 2009-2010 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 "RecastAssert.h"
#ifndef NDEBUG
static rcAssertFailFunc* sRecastAssertFailFunc = 0;
void rcAssertFailSetCustom(rcAssertFailFunc *assertFailFunc)
{
sRecastAssertFailFunc = assertFailFunc;
}
rcAssertFailFunc* rcAssertFailGetCustom()
{
return sRecastAssertFailFunc;
}
#endif

View File

@@ -379,7 +379,7 @@ static int triangulate(int n, const int* verts, int* indices, int* tris)
// We might get here because the contour has overlapping segments, like this: // We might get here because the contour has overlapping segments, like this:
// //
// A o-o=====o---o B // A o-o=====o---o B
// / |C D| \ // / |C D| \.
// o o o o // o o o o
// : : : : // : : : :
// We'll try to recover by loosing up the inCone test a bit so that a diagonal // We'll try to recover by loosing up the inCone test a bit so that a diagonal

View File

@@ -1684,7 +1684,7 @@ bool rcBuildLayerRegions(rcContext* ctx, rcCompactHeightfield& chf,
rcScopedDelete<unsigned short> srcReg((unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP)); rcScopedDelete<unsigned short> srcReg((unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP));
if (!srcReg) if (!srcReg)
{ {
ctx->log(RC_LOG_ERROR, "rcBuildRegionsMonotone: Out of memory 'src' (%d).", chf.spanCount); ctx->log(RC_LOG_ERROR, "rcBuildLayerRegions: Out of memory 'src' (%d).", chf.spanCount);
return false; return false;
} }
memset(srcReg,0,sizeof(unsigned short)*chf.spanCount); memset(srcReg,0,sizeof(unsigned short)*chf.spanCount);
@@ -1693,7 +1693,7 @@ bool rcBuildLayerRegions(rcContext* ctx, rcCompactHeightfield& chf,
rcScopedDelete<rcSweepSpan> sweeps((rcSweepSpan*)rcAlloc(sizeof(rcSweepSpan)*nsweeps, RC_ALLOC_TEMP)); rcScopedDelete<rcSweepSpan> sweeps((rcSweepSpan*)rcAlloc(sizeof(rcSweepSpan)*nsweeps, RC_ALLOC_TEMP));
if (!sweeps) if (!sweeps)
{ {
ctx->log(RC_LOG_ERROR, "rcBuildRegionsMonotone: Out of memory 'sweeps' (%d).", nsweeps); ctx->log(RC_LOG_ERROR, "rcBuildLayerRegions: Out of memory 'sweeps' (%d).", nsweeps);
return false; return false;
} }

View File

@@ -12,8 +12,8 @@
namespace VMAP namespace VMAP
{ {
const char VMAP_MAGIC[] = "VMAP_4.1"; const char VMAP_MAGIC[] = "VMAP_4.2";
const char RAW_VMAP_MAGIC[] = "VMAP041"; // used in extracted vmap files with raw data const char RAW_VMAP_MAGIC[] = "VMAP042"; // used in extracted vmap files with raw data
const char GAMEOBJECT_MODELS[] = "GameObjectModels.dtree"; const char GAMEOBJECT_MODELS[] = "GameObjectModels.dtree";
// defined in TileAssembler.cpp currently... // defined in TileAssembler.cpp currently...

View File

@@ -3531,7 +3531,7 @@ enum PartyResult
}; };
#define MMAP_MAGIC 0x4d4d4150 // 'MMAP' #define MMAP_MAGIC 0x4d4d4150 // 'MMAP'
#define MMAP_VERSION 8 #define MMAP_VERSION 9
struct MmapTileHeader struct MmapTileHeader
{ {

View File

@@ -26,7 +26,7 @@ const float Constants::UnitSize = Constants::ChunkSize / 8.0f;
const float Constants::Origin[] = { -Constants::MaxXY, 0.0f, -Constants::MaxXY }; const float Constants::Origin[] = { -Constants::MaxXY, 0.0f, -Constants::MaxXY };
const float Constants::PI = 3.1415926f; const float Constants::PI = 3.1415926f;
const float Constants::MaxStandableHeight = 1.5f; const float Constants::MaxStandableHeight = 1.5f;
const char* Constants::VMAPMagic = "VMAP041"; const char* Constants::VMAPMagic = "VMAP042";
bool Constants::ToWoWCoords = false; bool Constants::ToWoWCoords = false;
bool Constants::Debug = false; bool Constants::Debug = false;
const float Constants::BaseUnitDim = 0.533333f; const float Constants::BaseUnitDim = 0.533333f;

View File

@@ -341,7 +341,7 @@ public:
}; };
#define MMAP_MAGIC 0x4d4d4150 // 'MMAP' #define MMAP_MAGIC 0x4d4d4150 // 'MMAP'
#define MMAP_VERSION 8 #define MMAP_VERSION 9
struct MmapTileHeader struct MmapTileHeader
{ {

View File

@@ -23,7 +23,7 @@ namespace DisableMgr
} }
#define MMAP_MAGIC 0x4d4d4150 // 'MMAP' #define MMAP_MAGIC 0x4d4d4150 // 'MMAP'
#define MMAP_VERSION 8 #define MMAP_VERSION 9
struct MmapTileHeader struct MmapTileHeader
{ {
@@ -577,8 +577,8 @@ namespace MMAP
config.minRegionArea = rcSqr(60); config.minRegionArea = rcSqr(60);
config.mergeRegionArea = rcSqr(50); config.mergeRegionArea = rcSqr(50);
config.maxSimplificationError = 1.8f; // eliminates most jagged edges (tiny polygons) config.maxSimplificationError = 1.8f; // eliminates most jagged edges (tiny polygons)
config.detailSampleDist = config.cs * 64; config.detailSampleDist = config.cs * 16;
config.detailSampleMaxError = config.ch * 2; config.detailSampleMaxError = config.ch * 1;
// this sets the dimensions of the heightfield - should maybe happen before border padding // this sets the dimensions of the heightfield - should maybe happen before border padding
rcCalcGridSize(config.bmin, config.bmax, config.cs, &config.width, &config.height); rcCalcGridSize(config.bmin, config.bmax, config.cs, &config.width, &config.height);

View File

@@ -64,7 +64,7 @@ bool preciseVectorData = false;
//static const char * szWorkDirMaps = ".\\Maps"; //static const char * szWorkDirMaps = ".\\Maps";
const char* szWorkDirWmo = "./Buildings"; const char* szWorkDirWmo = "./Buildings";
const char* szRawVMAPMagic = "VMAP041"; const char* szRawVMAPMagic = "VMAP042";
// Local testing functions // Local testing functions

View File

@@ -338,9 +338,11 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool precise
for (int i=0; i<nTriangles; ++i) for (int i=0; i<nTriangles; ++i)
{ {
// Skip no collision triangles // Skip no collision triangles
if (MOPY[2*i]&WMO_MATERIAL_NO_COLLISION || bool isRenderFace = (MOPY[2 * i] & WMO_MATERIAL_RENDER) && !(MOPY[2 * i] & WMO_MATERIAL_DETAIL);
!(MOPY[2*i]&(WMO_MATERIAL_HINT|WMO_MATERIAL_COLLIDE_HIT)) ) bool isCollision = MOPY[2 * i] & WMO_MATERIAL_COLLISION || isRenderFace;
if (!isCollision)
continue; continue;
// Use this triangle // Use this triangle
for (int j=0; j<3; ++j) for (int j=0; j<3; ++j)
{ {
@@ -472,23 +474,33 @@ WMOGroup::~WMOGroup()
} }
WMOInstance::WMOInstance(MPQFile& f, char const* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile) WMOInstance::WMOInstance(MPQFile& f, char const* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile)
: currx(0), curry(0), wmo(NULL), doodadset(0), pos(), indx(0), id(0), d2(0), d3(0) : currx(0), curry(0), wmo(NULL), doodadset(0), pos(), indx(0), id(0)
{ {
float ff[3]; float ff[3];
f.read(&id, 4); f.read(&id, 4);
f.read(ff,12); f.read(ff, 12);
pos = Vec3D(ff[0],ff[1],ff[2]); pos = Vec3D(ff[0], ff[1], ff[2]);
f.read(ff,12); f.read(ff, 12);
rot = Vec3D(ff[0],ff[1],ff[2]); rot = Vec3D(ff[0], ff[1], ff[2]);
f.read(ff,12); f.read(ff, 12);
pos2 = Vec3D(ff[0],ff[1],ff[2]); pos2 = Vec3D(ff[0], ff[1], ff[2]); // bounding box corners
f.read(ff,12); f.read(ff, 12);
pos3 = Vec3D(ff[0],ff[1],ff[2]); pos3 = Vec3D(ff[0], ff[1], ff[2]); // bounding box corners
f.read(&d2,4);
uint16 trash,adtId; uint16 fflags;
f.read(&adtId,2); f.read(&fflags, 2);
f.read(&trash,2);
uint16 doodadSet;
f.read(&doodadSet, 2);
uint16 trash, adtId;
f.read(&adtId, 2);
f.read(&trash, 2);
// destructible wmo, do not dump. we can handle the vmap for these
// in dynamic tree (gameobject vmaps)
if ((fflags & 0x01) != 0)
return;
//-----------add_in _dir_file---------------- //-----------add_in _dir_file----------------

View File

@@ -15,13 +15,17 @@
#include "loadlib/loadlib.h" #include "loadlib/loadlib.h"
// MOPY flags // MOPY flags
#define WMO_MATERIAL_NOCAMCOLLIDE 0x01 enum MopyFlags
#define WMO_MATERIAL_DETAIL 0x02 {
#define WMO_MATERIAL_NO_COLLISION 0x04 WMO_MATERIAL_UNK01 = 0x01,
#define WMO_MATERIAL_HINT 0x08 WMO_MATERIAL_NOCAMCOLLIDE = 0x02,
#define WMO_MATERIAL_RENDER 0x10 WMO_MATERIAL_DETAIL = 0x04,
#define WMO_MATERIAL_COLLIDE_HIT 0x20 WMO_MATERIAL_COLLISION = 0x08,
#define WMO_MATERIAL_WALL_SURFACE 0x40 WMO_MATERIAL_HINT = 0x10,
WMO_MATERIAL_RENDER = 0x20,
WMO_MATERIAL_WALL_SURFACE = 0x40, // Guessed
WMO_MATERIAL_COLLIDE_HIT = 0x80
};
class WMOInstance; class WMOInstance;
class WMOManager; class WMOManager;
@@ -112,7 +116,7 @@ public:
int doodadset; int doodadset;
Vec3D pos; Vec3D pos;
Vec3D pos2, pos3, rot; Vec3D pos2, pos3, rot;
uint32 indx, id, d2, d3; uint32 indx, id;
WMOInstance(MPQFile&f , char const* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile); WMOInstance(MPQFile&f , char const* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile);