AutomaticRoundaboutBuilder
AutomaticRoundaboutBuilder copied to clipboard
post-setup node/segment flags
Situation:
This is picture of node flags for roundabout built by roundabout builder (roundabout is partially shown under transparent view)
And here are the node flags for a similar roundabout:
Not having ground flag set for nodes on ground could potentially cause unforeseen problem.
Need:
- Understand how the current mismatch of flags influences the CS code.
- node and segments flags should be set properly
Action
Check if OnGround node is used anywhere in the base code. it can help to understand how bad the problem is.
Perform these experiments to find out where result from roundabout builder differs from manual build with NetTool (compare flags/elevation/...) .
- On a decent sloped hill, Build roundabouts with FRT with OnGround/tunnel/elevated/bridge roads with and without pedestrian lanes on main and connected segments. (
combinations = 6*2*2=24
) - On a decent sloped hill, Build roundabouts without FRT OnGround/"Higher than ground"/lower than ground" with and without pedestrian lanes on main and connected segments (
combinations=3*2*2=12
) - build the roundabouts with roundabout builder and without roundabout builder manually (
total combinations=(12+24)*2=72
). then check if the node and segment flags are as expected - Considering that building roundabouts manually is time consuming particularly if they are on a hill, it would suffice to build a few T junctions at different elevations.
- Try this would different roads train/pedestrian/pipe/wire/mono/tram/... (
total combinations=72*6= i lost count!
EDIT: actually pipes/wires/... don't have variants so combinations are less than that) - considering that the number of combos are too much we can prune some of the experiments.
Write code to fix all differences between roundabout builder and NetTool.
In NetTool i noticed this relevant code. we should also be careful of double and underground flags.:
if (num33 < -8f && (nodeInfo2.m_netAI.SupportUnderground() || nodeInfo2.m_netAI.IsUnderground()))
{
NetNode[] buffer9 = Singleton<NetManager>.instance.m_nodes.m_buffer;
ushort num53 = num51;
buffer9[(int)num53].m_flags = (buffer9[(int)num53].m_flags | NetNode.Flags.Underground);
}
if (nodeBuffer.m_buffer[num31].m_double)
{
NetNode[] buffer10 = Singleton<NetManager>.instance.m_nodes.m_buffer;
ushort num54 = num51;
buffer10[(int)num54].m_flags = (buffer10[(int)num54].m_flags | NetNode.Flags.Double);
}
if (nodeInfo2.m_netAI.IsUnderground())
{
Singleton<NetManager>.instance.m_nodes.m_buffer[(int)num51].m_elevation = (byte)Mathf.Clamp(Mathf.RoundToInt(-nodeBuffer[num31].m_elevation), 0, 255);
}
else if (nodeInfo2.m_netAI.IsOverground() && (nodeBuffer[num31].m_elevation > 0.1f || nodeBuffer[num31].m_position.y - nodeBuffer[num31].m_terrainHeight > 0.1f))
{
Singleton<NetManager>.instance.m_nodes.m_buffer[(int)num51].m_elevation = (byte)Mathf.Clamp(Mathf.RoundToInt(nodeBuffer[num31].m_elevation), 1, 255);
}
else
{
NetNode[] buffer11 = Singleton<NetManager>.instance.m_nodes.m_buffer;
ushort num55 = num51;
buffer11[(int)num55].m_flags = (buffer11[(int)num55].m_flags | NetNode.Flags.OnGround);
}
In NetTool Flags: Movable, Middle, Orginal
are used for comparison only.
OnGround
is used for terrain calculations in NetNode and NetSegment we should test out terrain tools near segments build by roundabout builder. it is also used Pedesterian*NetAI
for lane connection.
OnGround is sometimes used like this:
!info.m_lowerTerrain || (this.m_flags & NetNode.Flags.OnGround
So My guess is m_lowerTerrain
usually covers up for OnGround
Thanks for the research