worked on nav-mesh
added dijkstra support for nav mesh some minor changes to distributions minor fixes
This commit is contained in:
@@ -9,9 +9,12 @@
|
||||
#include <KLib/misc/gnuplot/GnuplotSplotElementPoints.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotSplotElementColorPoints.h>
|
||||
#include <KLib/misc/gnuplot/objects/GnuplotObjectPolygon.h>
|
||||
#include "../math/Distributions.h"
|
||||
|
||||
namespace NM {
|
||||
|
||||
class NavMeshTriangleDijkstra;
|
||||
|
||||
/**
|
||||
* debug plot NavMeshes
|
||||
*/
|
||||
@@ -25,6 +28,7 @@ namespace NM {
|
||||
K::GnuplotSplotElementPoints border;
|
||||
K::GnuplotSplotElementColorPoints particles;
|
||||
K::GnuplotSplotElementLines pathEstimated;
|
||||
K::GnuplotSplotElementColorPoints distances;
|
||||
|
||||
private:
|
||||
|
||||
@@ -45,7 +49,7 @@ namespace NM {
|
||||
plot.add(&border);
|
||||
plot.add(&particles); particles.setPointType(7); particles.setPointSize(0.2);
|
||||
plot.add(&pathEstimated); pathEstimated.getStroke().setWidth(2); pathEstimated.setShowPoints(false); pathEstimated.getStroke().getColor().setHexStr("#00ff00");
|
||||
|
||||
plot.add(&distances); distances.setPointSize(2); distances.setPointType(7);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
@@ -112,6 +116,34 @@ namespace NM {
|
||||
|
||||
}
|
||||
|
||||
template <typename Tria> void addDijkstra(NavMesh<Tria>& mesh) {
|
||||
|
||||
// ensure Tria extends NavMeshTriangleDijkstra
|
||||
StaticAssert::AinheritsB<Tria, NavMeshTriangleDijkstra>();
|
||||
|
||||
NavMeshRandom<Tria> rnd = mesh.getRandom();
|
||||
|
||||
for (int i = 0; i < 900; ++i) {
|
||||
NavMeshLocation<Tria> loc = rnd.draw();
|
||||
float v = loc.tria->interpolate(loc.pos, loc.tria->distAtP1, loc.tria->distAtP2, loc.tria->distAtP3);
|
||||
distances.add(K::GnuplotPoint3(loc.pos.x, loc.pos.y, loc.pos.z), v);
|
||||
}
|
||||
|
||||
|
||||
// Distribution::Uniform<float> dist (-0.5, +0.5);
|
||||
// for (const Tria* t : mesh) {
|
||||
// const Point3 posC = t->getCenter();
|
||||
// distances.add(K::GnuplotPoint3(posC.x+dist.draw(), posC.y+dist.draw(), posC.z), t->distAtCenter);
|
||||
// const Point3 pos1 = t->getP1();
|
||||
// distances.add(K::GnuplotPoint3(pos1.x+dist.draw(), pos1.y+dist.draw(), pos1.z), t->distAtP1);
|
||||
// const Point3 pos2 = t->getP2();
|
||||
// distances.add(K::GnuplotPoint3(pos2.x+dist.draw(), pos2.y+dist.draw(), pos2.z), t->distAtP2);
|
||||
// const Point3 pos3 = t->getP3();
|
||||
// distances.add(K::GnuplotPoint3(pos3.x+dist.draw(), pos3.y+dist.draw(), pos3.z), t->distAtP3);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
void setGT(const Point3 pt) {
|
||||
gp << "set arrow 31337 from " << pt.x << "," << pt.y << "," << (pt.z+1.4) << " to " << pt.x << "," << pt.y << "," << pt.z << " front \n";
|
||||
|
||||
Reference in New Issue
Block a user