Git Product home page Git Product logo

Comments (11)

Robmaister avatar Robmaister commented on July 16, 2024

Assigned to @xrj800

Should be implemented soon.

from sharpnav.

FreedomJack-X avatar FreedomJack-X commented on July 16, 2024

Yep, I am working on it, but i find one function which occurred in findnearestpoint like queryPolygens didn’t implement, so I am trying to implement that firstly.

Renjie Xie
On Feb 12, 2014, at 7:40 PM, Robert Rouhani [email protected] wrote:

Assigned to @xrj800

Should be implemented soon.


Reply to this email directly or view it on GitHub.

from sharpnav.

Robmaister avatar Robmaister commented on July 16, 2024

Implemented in f087ae8. I looked over it (though I have yet to test it), seems to be good. There are some bugs in PolyMeshDetail I'm working through that may give you wrong height values in this step. I also made a few changes to the navigation API and will make several more in the next few weeks.

Just another warning that we're still in a development phase and the API shouldn't be considered stable yet.

I'll close this issue once either I test it or you confirm that it works.

from sharpnav.

FreedomJack-X avatar FreedomJack-X commented on July 16, 2024

When I implement this function, it seems that the editor of C++ version is still modifying function now.

On Feb 19, 2014, at 2:33 PM, Robert Rouhani [email protected] wrote:

Implemented in f087ae8. I looked over it (though I have yet to test it), seems to be good. There are some bugs in PolyMeshDetail I'm working through that may give you wrong height values in this step. I also made a few changes to the navigation API and will make several more in the next few weeks.

Just another warning that we're still in a development phase and the API shouldn't be considered stable yet.

I'll close this issue once either I test it or you confirm that it works.


Reply to this email directly or view it on GitHub.

from sharpnav.

AqlaSolutions avatar AqlaSolutions commented on July 16, 2024

While I was checking it I've found that in the ClosestPointOnPoly you are directly assigning closest = pos and it returns the same point as input every time! After that you don't check the bool result of ClosestPointOnPoly at all (shouldn't you do "continue" if false?) Next: you are checking "if (nearestPt.Length() != 0) nearestPt = closestPtPoly;" - it returns (0, 0, 0) every time! And the "diff" is always (0,0,0) because ClosestPointOnPoly always returns the same point as input => it selects the resulting nearest point from the first poly. It doesn't work and it can't work...

from sharpnav.

Robmaister avatar Robmaister commented on July 16, 2024

That commit fixed a lot of small bugs from the method being ported over. Mostly a bit of confusion between checking whether a pointer isn't NULL vs. checking whether it's value is 0.

And the bool result of ClosestPointOnPoly should only return false in an exceptional state (at least at a quick glance). The method should probably return void instead of bool and throw exceptions, which is something I'll do when I have some free time (and also enhance the Examples project to let you click on positions you want to navigate between at the same time).

from sharpnav.

AqlaSolutions avatar AqlaSolutions commented on July 16, 2024

Found a bug in FindNearestPoly: in case where QueryPolygons returns true but polys list is empty it returns inconsistent results.

from sharpnav.

AqlaSolutions avatar AqlaSolutions commented on July 16, 2024

Query polygons doesn't find anything even if the input point have been taken from the poly itself with FindRandomPoint:

public class TestNav
{
        public void Test()
        {
            var navMeshQuery = new NavMeshQuery(_tiledNavMesh, 2048);

            SVector3 startPt = new SVector3();
            int startRef = 0;

            if (!navMeshQuery.FindRandomPoint(ref startRef, ref startPt))
                throw new CantFindPointOnPolyException();

            SVector3 endPt = new SVector3();
            int endRef = 0;

            if (!navMeshQuery.FindRandomPoint(ref endRef, ref endPt))
                throw new CantFindPointOnPolyException();

            FindPath(startPt, endPt);
        }

        public void FindPath(SVector3 from, SVector3 to)
        {
            var navMeshQuery = new NavMeshQuery(_tiledNavMesh, 2048);
            // !!! QueryPolygons inside returns empty list
            int startRef;
            SVector3 startPos;
            if (!GetClosestPoint(navMeshQuery, from, out startPos, out startRef))
                throw new CantFindPointOnPolyException();
            int endRef;
            SVector3 endPos;
            if (!GetClosestPoint(navMeshQuery, to, out endPos, out endRef))
                throw new CantFindPointOnPolyException();
        }

        static bool GetClosestPoint(NavMeshQuery navMeshQuery, SVector3 startPos, out SVector3 pt, out int ptRef)
        {
            var extents = new SVector3(5f, 5f, 5f);
            return navMeshQuery.FindNearestPoly(ref startPos, ref extents, out ptRef, out pt);
        }

        readonly TiledNavMesh _tiledNavMesh;
        public TestNav(TiledNavMesh tiledNavMesh) { _tiledNavMesh = tiledNavMesh; }
        public class CantFindPointOnPolyException : Exception { }
}

from sharpnav.

Robmaister avatar Robmaister commented on July 16, 2024

Fixed bug where QueryPolygons returns true if it doesn't find any polygons. Investigating it not finding a suitable poly.

Currently, if you provide a massive extends vector, it'll get you a poly within the extends box, but definitely not the nearest poly. Bug is narrowed down to QueryPolygonsInTile. If I can't figure it out tonight I'll look whenever I have some more free time.

from sharpnav.

Robmaister avatar Robmaister commented on July 16, 2024

Alright, it works for me now. In the Examples project, I replaced the randomly chosen start point and replaced it with the point nearest (10, 0, 0) with an extent of (5, 5, 5). You should be able to mess with those numbers and get a point as long as the bounds are within the level. It'll throw an exception a little bit further on if it can't find a start point, but that's another issue for another time, one that I'll likely fix through the design of the API.

Anyways, give it a whirl. I'll leave the issue open until you confirm it works for you.

Also, in case you were curious what the bug was, PolyMesh's vertices are stored in voxel units (they're supposed to be ushorts, but were kept as Vector3's in the port). I assumed that Vector3 meant it would be in world units. I re-added the quantization factor that converts world units to voxel units. Before, the comparison of bounding boxes was failing for all polys since the bounding volume tree is also in voxel units and the query bounding volume is in world units.

from sharpnav.

AqlaSolutions avatar AqlaSolutions commented on July 16, 2024

I confirm, it works. Thanks =)

from sharpnav.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.