Opened 4 years ago

Last modified 2 years ago

#3685 new enhancement

[PATCH] Improvements to obstructions

Reported by: stanislas69 Owned by:
Priority: Should Have Milestone: Backlog
Component: Core engine Keywords: patch
Cc: wraitii Patch:

Description (last modified by sanderd17)

There are several improvements that could be made wrt obstructions:

  1. Allow circular static obstructions:

Some buildings are circular, and it's weird that the ability to place them sometimes depends on the angle. If you check the stonehenge wonder f.e., the invisible corners are very big.

All wall towers should also have circular obstructions as the player can't determine the rotation of the first tower (but the rotation of the first tower is determined by the angle of the wall). So when starting a wall-piece in the direction you want, it can either obstruct the tower, or create a gap because the obstruction gets rotated.

Since the obstructions are always rasterized, it shouldn't be very calculation intensive to support circular static obstructions (just adding a check in the rasterization loop).

  1. It should be possible to overlay different obstruction types on one template

Most buildings aren't made to serve as a wall. So passages should be guaranteed between them. This would be possible by overlaying two different obstructions:

  • An obstruction that blocks pathfinding, so units don't walk through the building
  • A bigger obstruction that blocks construction, so buildings can't be placed close enough, and units can always pass.

The gap between two buildings should be wide enough so units can actually cross in that gap.

Walls on the other hand are in a different situation, and should probably block more pathfinding than they block construction, so they can create a certain obstruction overlap, and block all units with certainty. This may be a bit more difficult to achieve.

Note that these double obstructions seem already possible, since it's done with the gate (a gate has 3 obstructions, of which the center one can be made passable but not be constructed on). So I guess it mainly misses a way to put this into the schema.


Together, this should fix most issues with wall-placement, make building placement more relaxing, but also help fixing issues like #3517 (due to the guaranteed gap).

Attachments (6)

commands.txt (511.5 KB) - added by elexis 4 years ago.
Reported commands.txt for a19.
roundObstructions.diff (29.2 KB) - added by sanderd17 3 years ago.
Partial implementation of round obstructions. It works nicely for placing buildings, and works good with the long-range pathfinder, but supporting the vertex pathfinder is hard.
clearance.diff (15.2 KB) - added by sanderd17 3 years ago.
clearance.2.diff (13.6 KB) - added by sanderd17 3 years ago.
Clearances made optional, as they're only useful on entities that are placed by the player (and thus shouldn't be defined on the other templates)
clearance.3.diff (14.6 KB) - added by sanderd17 3 years ago.
Fix bridge actors
rebased_clearance.patch (14.4 KB) - added by wraitii 3 years ago.

Download all attachments as: .zip

Change History (18)

Changed 4 years ago by elexis

Attachment: commands.txt added

Reported commands.txt for a19.

comment:1 Changed 4 years ago by sanderd17

Description: modified (diff)
Summary: Can't build straight walls over obstructionImprovements to obstructions
Type: defectenhancement

I made this ticket a bit broader, as multiple improvements can be made.

Changed 3 years ago by sanderd17

Attachment: roundObstructions.diff added

Partial implementation of round obstructions. It works nicely for placing buildings, and works good with the long-range pathfinder, but supporting the vertex pathfinder is hard.

comment:2 Changed 3 years ago by sanderd17

Keywords: patch review added; pathfinding removed
Milestone: BacklogAlpha 21

The clearance patch is ready for review (the other is just a WiP).

The clearance patch cleans up the "onlyCenterpoint" parameter used with the previous pathfinder, and allows obstructions to have a clearance defined. Setting the clearance for regular units to 4 makes sure there's always a gap that's big enough for units to pass through.

Walls on the other hand get a negative clearance, allowing them to overlap a bit. The overlap is only 1m, so trees and other resources don't get berried completely inside the wall (the minimum obstruction size is 1.5m, so there's always at least 0.5m of the tree sticking out to be gathered).

This patch changes the gameplay too, as due to the clearance, you need more space to build stuff. So perhaps as a compensation, some structures could get a bit smaller obstruction size.

Changed 3 years ago by sanderd17

Attachment: clearance.diff added

comment:3 Changed 3 years ago by sanderd17

Note from fatherbushido: corpses are broken, and some other templates in the other/ directory (XML validation errors).

Changed 3 years ago by sanderd17

Attachment: clearance.2.diff added

Clearances made optional, as they're only useful on entities that are placed by the player (and thus shouldn't be defined on the other templates)

Changed 3 years ago by sanderd17

Attachment: clearance.3.diff added

Fix bridge actors

comment:4 Changed 3 years ago by fatherbushido

I tested the clearance patch. I ve got a really nice feeling (more realistic city building, better wall placement...).

comment:5 Changed 3 years ago by wraitii

Just a small comment: when playing around with clearance, please please please test edge cases. The pathfinder demo map is pretty good for small corridors for example.

Please also check compatibility between the short-range and long-range pathfinder. I literally cannot count how many "unit is stuck" issues were caused by this.

Re-the circular static obstruction thing: I believe the main reason for their non-existence is the lack of support in the short-range pathfinder. AFAIK there are no easy solutions to this problem.

Last edited 3 years ago by wraitii (previous) (diff)

comment:6 Changed 3 years ago by sanderd17

@wraitii, the clearance patch doesn't change anything to already placed buildings. It just guarantees there to be a certain clearance between a new foundation and already existing obstructions. Perhaps I should try to find a different name, as it indeed collides with the clearance of units :/ The clearance for units is needed clearance, the clearance for buildings is guaranteed clearance.

So as it only restricts building placement further (for regular buildings), there are no extra bugs that can happen with regular buildings.

But when calculating the guaranteed clearance, you do need to take the unit clearance into account so it's certain units can pass.

First, static obstructions are enlarged by the unit clearance (0.8), I think this happens on both sides, so buildings must be 1.6m apart to allow short-range pathfinder passability for units. Then the long-range pathfinder marks all tiles impassable that overlap the extended static obstruction with 1m² tiles, so with the diagonals of those tiles, you'd need to add 2*sqrt(2) to the minimum distance to guarantee passability for units.

So the required clearance for passability should be around 4.42. I first thought the clearance of 0.8 wasn't needed on both sides, so it would have been enough with 3.62 (or rounded up to 4).

I don't know if there are any mistakes in my calculations now, but at worst, it can cause bugs that were already possible.

comment:7 Changed 3 years ago by sanderd17

Summary: Improvements to obstructions[PATCH] Improvements to obstructions

comment:8 Changed 3 years ago by Itms

Keywords: rfc added; review removed

Move tickets from the review queue to the rfc one.

comment:9 Changed 3 years ago by Itms

I tested the patch, and as fatherbushido, I liked the feeling :)

One comment on the code: I would call TestStaticShape with w + 2*clearance instead of passing to the whole code a clearance with a double value, for semantics' sake.

comment:10 Changed 3 years ago by elexis

Milestone: Alpha 21Alpha 22

Feature freeze in 2 days.

Changed 3 years ago by wraitii

Attachment: rebased_clearance.patch added

comment:11 Changed 3 years ago by wraitii

Keywords: rfc removed

Patch works, but: -I don't like that it has no connection to footprint. Things are already confusing enough. -I don't like the name, it's confusing with pathfinder clearance with which it has nothing to do. That at least should be changed before committing.

I rebased it in the meantime, removing review keyword for inactivity.

comment:12 Changed 2 years ago by elexis

Milestone: Alpha 22Backlog

Backlogging due to lack of progress

Note: See TracTickets for help on using tickets.