Coder Social home page Coder Social logo

Comments (5)

DummkopfOfHachtenduden avatar DummkopfOfHachtenduden commented on July 26, 2024 1

You can't use a single cell for an object of that size simply because the algorithm would break.

Assuming you only have a single cell which would be Cell0 in this case containing all edges. The algorithm on the client/server still excepts the outline lookup grid to cover the whole object. So a ray (red here) would entirely miss Cell0 as the 100x100 cell size is hardcoded. It would've practically not have hit any Cell and thus won't test any outline edges for intersection.
image

The outline edge has to be listed in every cell it overlaps with.
So yes, Edge 1 would be added to both Cell0 and Cell4.

from silkroaddoc.

DummkopfOfHachtenduden avatar DummkopfOfHachtenduden commented on July 26, 2024

All BMS collision is stored under https://github.com/DummkopfOfHachtenduden/SilkroadDoc/wiki/JMXVBMS#navmeshobj
The bounding boxes are not used for collision, they're also inaccurate. You'll have to check the flag of the edges you're intersecting with in a specific manner.

enum EdgeFlag : byte
{
    None = 0,
    BlockDst2Src = 1,
    BlockSrc2Dst = 2,
    Blocked = BlockDst2Src | BlockSrc2Dst,
    Internal = 4,
    Global = 8,
    Underpass = 16,
    Entrance = 32,  // Dungeon (obsolete?)
    Bit6 = 64,
    Siege = 128,    // Fortress War (attack passthrough)
}

This video shows how collision is found when raycasting from within the object (standing on NavMeshObj).
https://youtu.be/qxqx9wrCicU
Walkable edges are rendered in green.
Underpass edges are rendered in yellow. (they'll only be a collision from within)
Blocked edges are rendered in red.
Edges that have been checked for collision by the algorithm are highlighted blue.
The ray that is tested is rendered green when there is no collision found and red up until where the collision point has been found when colliding.

This video shows how collision is found when raycasting from outside the object (standing on NavMeshTerrain)
https://www.youtube.com/watch?v=4SgWcmloJ1U
Edges that have been checked for collision by the algorithm are highlighted YELLOW here.
OutlineLookupGrid cells that have been looked at by the algorithm are highlighted in magenta.
Blue circles are used to represent NavMesh changes (transition between graphs aka different terrain sections)
Magenta circles are used to represent possible intersection of which the closest will be the actual intersection point.

There are fully walkable objects in this game. You're raycasting algorithm needs to be able to transition from terrain into objects and vice versa so you can handle stuff like this
image

Is there some simple way to identify whether object has a collision or not? (checking some flag or offset)

If header.NavMeshOffset is 0 then the object has no collision. The only exception being ColObj's in a dungeon where the collision is defined by a circle radius as part of the object definition in the DOF.

from silkroaddoc.

Andrej730 avatar Andrej730 commented on July 26, 2024

Thanks for the detailed answer, it's really helpful.

What OutlineLookupGrid is used for and how do I generate it?
For example I have nav mesh from the screenshot - how do I derive LookupGrid from that? (btw this shape is w_cd_bigtortoise01.bms). Original bms grid has 16 cells each formed out of 1 or more outline edges.
image

Other thing I've noticed some .bms use for OutlineLookupGrid 1 cell formed out of all outline edges (like "rock_mt_house07_01.bms" from the screenshot below).
And the question is when that simple 1 cell grid is enough and when I need to go more complex?

image

from silkroaddoc.

DummkopfOfHachtenduden avatar DummkopfOfHachtenduden commented on July 26, 2024

The OutlineLookupGrid is an a grid based acceleration structure to reduce the amounts of tests you have to perform.

Every object has it's own grid and they look somewhat like this. image
Every cell is 100x100 units so the width and height (in cells) is therefore determined by the NavMesh size.
Every cell stores the outline edges that overlap (intersecting/fully contained) with it.
If the object is small enough to fit into a single cell then it obviously contains all outline edges.

It's used when testing for collision with an object from outside (standing on NavMeshTerrain).
Instead of testing every outline edge of the object against your ray, you check which cells of the outline lookup grid your ray intersects with first. Then check those outline edges within the cells you intersected with for an intersection with your ray.

Joymax's cell test is rather inefficient on bigger objects as you can see here:
image

I'd suggest for a more optimized test like this:
image

To create the grid itself you'd just create an AABB based on all vertices and inflate it to the next multiple of 100 in both axis.
That way you can calculate the width and height in cells and also know the origin as it should be the AABBs min.

from silkroaddoc.

Andrej730 avatar Andrej730 commented on July 26, 2024
  1. What if I just always use 1 cell even if object is 1000x1000? It won't be efficient since it's going to check all outline links all the time but it would work?
  2. What about outline links that fall in multiple cells - they should be enlisted in all cells they intersect? Like edge 1 should be added to both cells 0 and 4.

image

from silkroaddoc.

Related Issues (5)

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.