The Spatials V3 devblog 2016-01-25

Internal development notes, very slightly cleaned up and commented a week later.

TL;DR: added support for complex layered objects, removed sectors from the galaxy

As part of the ship bridge work started earlier in January, a new kind of object display has been added. The bridge features some interactive objects that would benefit a lot if the officers could stand very close to them, or even sit inside them. This was impossible in V2 and thus the art wasn't prepared for it. But in V3 we want to make the simulation look better so adding this kind of interactivity was necessary.

There were several problems enabling these new objects. The main problem was the concept of having objects that are visually a block in the path of an entity, but are not such a block actually, in order to allow interacting entities to walk inside them when required. I toyed with a few ideas for two days, discarding them all.

- in-object positioning for interacting entities: dead ends
    (discarded) idea: dummy look-alike entity while hiding outside
        hiding of main entity, which remains standing in the nearby walkable
        a dummy entity with a pose copy gets spawned inside object
        a system waits for conditions to destroy the dummy
        problems: future cursor problems, possible leaks, better to reduce mess of spawns
    (discarded) idea: visual bias while standing outside
        main entity remains standing in the nearby walkable
        a iso+screen bias component is added to visually reposition the entity inside the object
        problems: future cursor problems, attack targets visually off, proper system for removing bias
    (discarded) idea: just make objects walkable
        everything perfect wrt interaction
        problems: ents walking on top of whenever, not a collider for combat, ...
            switching back to A* with node weights would solve this for 99% of the time
            combat collision is already using spatial queries, it should work
    (discarded) idea: actual warp
        pathing into them: path to nearby, then warp inside
        pathing out of them: let collision warp sort it out?
        problems: lots of stuff assume walkable, including the more emergent systems like vulnerable-s

A pathfinding system based on A* could handle this without a problem. Just giving the tiles where the walkable objects sit a very high pathing cost would make all entities avoid them, except for those who were interested in walking into them. But I didn't want to re-introduce A*, since the game is currently using the much more performant Jump Path Search algorithm. In the end it all boiled down to adding a slight tweak to the JPS code, and adding the concept of "slow tiles" in place of arbitrary costs.

- winner idea: 2 "flavor" pathfinding, with "slow" but walkable objects
    currently using very fast JPS, but doesnt allow for non-uniform grid costs
    try to avoid going back to A* unless it's absolutely necessary, hack over JPS instead
    introduce new bit for tiles: slow tiles
    JPS path finding modified like:
        if either origin or destination are a slow tile, (only) these slow tiles are accepted as walkable
        all other slow tiles are non-walkable tiles *only for the JPS search*
            in other instances (like combat ray-cast LoS) they are walkable
    ImpassableSystem/C patched to support the new bit
    -> now it's possible to walk inside apt-designed solid entities
- add hints for slow vs solid objects
    test on bridge command seat and terminal
- modify object maker to properly init ImpassableComp

I don't want to pile hacks upon hacks, so if in the future a new special requirement appears, I will re-evaluate going back to A*.

This made the model side of the code ready for the new objects, then it was time for the view side.

- layered objects
    add new hint to enable special Z bias mode
    1 layer: +0.9 for angles 0-1, 0 for angles 2-3
    2 layer: layer 0: 0, layer 1: 0.9
- correct heading for jobs inside walkable objects
    extrude heading position from object angle
- fix: flips are not correctly applied to multilayer objects, sometimes
    bridge object probe wasnt setting up flips at all
- custom pivot position for layered objects
    used as walk destination
    do snap-in in job sm
    adjust for civ
        encapsulate it all in helper + call to civ helper

Fortunately V3 already features a very flexible 2D display system for entities, supporting multiple layers with independent animations and Z-biases. Here's the result:

New galaxy screen

Notice how the officer in the top console is very far into the tile. In V2 he would have been limited to stand on one of the sides. A more complex example is the captain chair. Here we see an officer sandwitched between two display layers, with the correct Z values, to give the impression of being seated inside. The art must be created in layers for this to work, but everything else is automatic.

- galaxy map V3
    remove sector model
    direct galaxy -> system transition zoom, no more sectors
    restore system->galaxy zoom (button and keyboard)
    fix issues
        moving a ship removes labels from galaxy (listener issue + correctly re-set container opacity)
        bad opacity in ship avatar
        moving ships dont show up in galaxy
        moving ships in system show up in galaxy
        dndbuttons for ships in galaxy remain active in system view
    better default galaxy gen: spread out systems, avoid borders with bias
    new vis for systems in galaxy
        50% small icons
        small text label
    fix approaching ship in system view getting stuck

Sectors have been removed from the galaxy. Now the galaxy screen displays all the stars in the galaxy, and when clicking on them, the star system is displayed. This will make it much easier to support other galaxy shapes and densities and to do more complex things with the galaxy generation. Gone is the hardcoded limit of 30 stars or the rigid grid of sectors.

New galaxy screen

links

social