Jump to content

[SOLVED] NavigationMesh/PathRoute problem


photo

Recommended Posts

Please patch the source/engine/game/navigations/NavigationMesh.cpp file at 1399 line:

 

from:

// nodes
node->nodes.resize(nodes.size());
node->npolygons.resize(npolygons.size());
Math::memcpy(node->nodes.get(),nodes.get(),sizeof(Node) * nodes.size());
Math::memcpy(node->npolygons.get(),npolygons.get(),sizeof(int) * npolygons.size());

 

to:

// nodes
node->nodes.resize(nodes.size());
Math::memcpy(node->nodes.get(),nodes.get(),sizeof(Node) * nodes.size());

// node polygons
node->npolygons.resize(npolygons.size());
for(int i = 0; i < npolygons.size(); i++) {
	node->npolygons[i] = node->polygons.get() + (int)(npolygons[i] - polygons.get());
}

 

And change 38 line at your sample:

add_editor(node);
//	engine.editor.addNode(node);

Link to comment
  • 3 weeks later...

For users who don't have a source version of the SDK, when is a patched binary version going to be available/new SDK available with this fix in it? This crash is currently blocking our development.

Link to comment

We can also suggest upgrade to the full source SDK so we'll be able to send you hotfixes faster. Moreover you'll get more control over the technology, if you need some deep modifications.

Link to comment
  • 8 months later...

In SDK-2013-06-07, same problem, can not create path and app crash when reload world. In another scene, path finded but Z = -5 in path point always.

Link to comment

I've tried your sample and my updated sample on the old SDK version (2012-10-19, with NavigationMesh.cpp fix) and I get "PathRoute failed" here too. 

 

Path updated sample is the same sample, but with edited mesh_00.cpp file on line 38: I've replaced engine.editor.addNode(node); to add_editor(node).

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Ok, add_editor is my mistake.

About Z = -5, "This upload failed" so check mesh_00.cpp in post.

Result:

p0 inside:1

p1 inside:1

point0: 68.09 77.45 -5.00

point1: 69.42 85.92 -5.00

#include <samples/paths/common/paths.h>

Navigation navigations[0];
Vec3 offset = Vec3(0.0f,0.0f,0.0f);

void update_scene() {
    engine.world.updateSpatial();
    
    PathRoute route = new PathRoute(0.5f);
    
//    Vec3 p0 = Vec3(0.0f,6.0f,26.5f) + offset;
//    Vec3 p1 = Vec3(9.25f,4.36f,26.5f) + offset;
    Vec3 p0 =  Vec3(68.09, 77.45, 3.86) + offset;
    Vec3 p1 =  Vec3(69.42, 85.92, 3.86) + offset;

    log.message("update scene\n");
    
    while(1) {        
        foreach(Navigation n; navigations) {
            n.renderVisualizer();
            engine.message(" p0 inside:%i",n.inside2D(p0, 1.0f));
            engine.message(" p1 inside:%i",n.inside2D(p1, 1.0f));
        }
        
        route.create2D(p0,p1);
        if(route.isReached()) {
            route.renderVisualizer(vec4_one);
            forloop(int i = 0; route.getNumPoints()) {
                vec3 point = route.getPoint(i);
                log.message("point%i: %.2f %.2f %.2f\n", i, point.x, point.y, point.z);
            }
        }
        else {
            engine.message("PathRoute failed\n");
        }
        
        wait;
    }
    
}

void create_scene() {    
    Node node = node_cast(node_append(engine.world.loadNode("samples/paths/nodes/terra_test.n")));
    node.setPosition(vec3(0.0f,0.0f,0.0f));
    int index = node.findChild("navigation_mesh");
    assert(index != -1);
    NavigationMesh navigation = node_cast(node.getChild(index));
    add_editor(node);
    //engine.editor.addNode(node);
    navigations.append(navigation);
    
    return "PathRoute2D in single NavigationMesh";
}
Link to comment

Hi,

 

Your mesh minimum Z coordinate is -5, maximum +5, so as a result if you trying to navigate on this mesh on it's bottom side you will get Z = -5, on top side you will get Z = 5. This behavior is absolutely correct.

 

Also, this behavior is absolutely identical to the old SDK version (2012-10-19, with NavigationMesh.cpp fix).

 

Thanks!

terra_test_mesh.png

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Destination point Vec3(69.42, 85.92, 3.86), why -5 is correct? After update meshes and nodes on test scene all finding good, but on work world other behavior. I will try to reproduce the test scene.

Link to comment
×
×
  • Create New...