diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2015-07-28 14:54:41 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2015-07-28 14:54:41 +0300 |
commit | d3acfa1d87ccc7932b61311b7084951dcce67eba (patch) | |
tree | d5455c89c4a81dbba2e198d3e61711e535517aa0 /source/gameengine | |
parent | 038d6ce2cce5aaabfbba90d934b235601fcb561f (diff) |
BGE: Navmesh fixes and improvements
The navigation mesh functionality was broken for quite a while. This patch
contains fixes: recalculating tesselations before getting the number of
tesselation faces (it otherwise returned 0) before calculating the navmesh,
and calling `DM_ensure_tessface()` on the navmesh's `DerivedMesh` object
(which fixes visualisation in Blender). This allows one to create a new
navmesh, which also works in the BGE.
Furthermore, the patch adds several return values, and shows more error
messages when things go wrong. In several places in the navmesh creation
code, return codes weren't checked and errors silently ignored.
Reviewers: nicks, brita_, campbellbarton, lordloki, moguri, panzergame
Reviewed By: panzergame
Differential Revision: https://developer.blender.org/D1435
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Ketsji/KX_NavMeshObject.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.cpp b/source/gameengine/Ketsji/KX_NavMeshObject.cpp index 891eb00cae6..b8907ca5c6b 100644 --- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp +++ b/source/gameengine/Ketsji/KX_NavMeshObject.cpp @@ -98,12 +98,14 @@ void KX_NavMeshObject::ProcessReplica() { KX_GameObject::ProcessReplica(); m_navMesh = NULL; /* without this, building frees the navmesh we copied from */ - BuildNavMesh(); + if (!BuildNavMesh()) { + std::cout << "Error in " << __func__ << ": unable to build navigation mesh" << std::endl; + return; + } KX_Scene* scene = KX_GetActiveScene(); KX_ObstacleSimulation* obssimulation = scene->GetObstacleSimulation(); if (obssimulation) obssimulation->AddObstaclesForNavMesh(this); - } bool KX_NavMeshObject::BuildVertIndArrays(float *&vertices, int& nverts, @@ -321,7 +323,11 @@ bool KX_NavMeshObject::BuildNavMesh() } } - buildMeshAdjacency(polys, npolys, nverts, vertsPerPoly); + if (!buildMeshAdjacency(polys, npolys, nverts, vertsPerPoly)) { + std::cout << __func__ << ": unable to build mesh adjacency information." << std::endl; + delete[] vertices; + return false; + } float cs = 0.2f; |