Closed kianzarrin closed 2 years ago
The catch is you cannot disconnect all tracks using this mehtod but as long as we are fixing vast majority of problems then i say its an improvement.
This is close to hide TMPE crosswalks mod but much easier since it does not require any image processing.
This approach does not work for multi track
I'll close #647 as this 734 has better detail.
Image from #647:
Would be great if lane connector could toggle the tracks crossing that junction in the image above so that only connected tracks were shown.
The catch is you cannot disconnect all tracks using this mehtod but as long as we are fixing vast majority of problems then i say its an improvement.
This approach does not work for multi track
Please elaborate.
@aubergine10 Please elaborate.
This approach does not work for multi track
Now that I see that nice picture of yours I take it back!
The catch is you cannot disconnect all tracks using this method but as long as we are fixing vast majority of problems then i say its an improvement.
I don' think anyone ever wants to do this. but lets say in this picture someone wants all tracks to be disconnected from one another (maybe he wants to paint the connections himself ? maybe he wants to create a funny clip ?) it is not possible to do so using lane connector. if there are no lane connection we fall back to the vanilla connection method.
progress note: my TranspilerUtil has very easy to use code to search for nodeDD, segmentID and instructions. This should be easy.
PS: This is good learning experience for https://github.com/kianzarrin/myrepo/issues/2 :D PS2: my code https://github.com/kianzarrin/KianButtonMod/tree/hide-unconnected-tracks
Metro overhaul is too heavy for my computer. I think I can make it work for a small test.
None of the NetNode.PupulateGroupData() NetNode.CalculateGroupData() ShouldDrawConnectTexture()
check for lanes. So I do not understand how do they connect the lanes together.
It does check for Info.m_forwardVehicleLane/Info.m_backwardVehicleLanes
.
I have to patch the code to exclude some code paths to see what happens.
EDIT: I am suspecting it has something to do with Info.m_nodes . I should check the materials
These pictures show I can disconnect tacks on an on segment basis for close camera:
@aubergine10 remember when I said:
The catch is you cannot disconnect all tracks using this method but as long as we are fixing vast majority of problems then i say its an improvement.
I meant that to achieve no connection at all like in the first screenshot is not an option ... not using lane connector anyways. LaneConnector GUI is setup such that each lane is connected to at least one other lane.
I meant that to achieve no connection at all like in the first screenshot is not an option ... not using lane connector anyways. LaneConnector GUI is setup such that each lane is connected to at least one other lane.
The way it currently works is correct. An incoming vehicle lane should be connected to at least one outgoing vehicle lane.
The way the lane connections are handled is by Info.m_nodes The relevant field is m_connectGroup
.
Two way track node Info has m_connectGroup=DoubleTracks
.
One way track has some extra connection node infos to deal with various conditions. m_connectGroup is one of the following combos:
m_connectGroup for connection node infos of Train station track network has the following combos:
This means its going to be difficult to hide unused tracks in the image bellow. I need to EITHER do some mesh processing (cut the mesh in half) and produce the extra meshes OR borrow node infos from single train track. The latter approach works for vanilla networks. for custom roads I EITHER need to ask assert creators to add extra node textures OR look at the name of ALL NetInfos and guess which one is the matching single track NetInfo.
Supporting the situation in the screen shot bellow on the other hand is going to be much easier because it is on a per segment basis rather than one a per lane basis:
This task needs to be divided into several steps:
I am reopening #647 to support the second step.
See if this is any use: #634 - specifically there's a flag (at least for station tracks, but maybe all tracks?) that is used to create X
junctions like those either side of train station. So maybe tracks contain a single track variant to make that work?
as far as I understand that flag is used to create junctions and does not influence already existing junctions. I tried it and observed no difference. I don't think we can solve the problem of mesh and textures with a flag or even extra code (unless if that code generates mesh!).
Progress!
works for close and medium camera range.
This might cause some user complaints : https://github.com/CitiesSkylinesMods/TMPE/milestone/20
This might cause some user complaints
??
in the link (https://github.com/CitiesSkylinesMods/TMPE/milestone/20) there is a list of issues related to selecting tracks which overlap with road. If the tram is overlapping with road and user cannot hide tracks because of it they cannot select the track in the lane connector, it would be such a bummer!
Good point. So it seems we need to solve the track vs. road issues first before we can properly tackle the hiding of tracks based on lane connectors.
And there is also the Harmony version issue discussed in Discord chat. :/
Suggested plan:
Possibly in parallel a separate mod could be done to start testing out the #734 and #647 stuff? Similar to the hide crosswalks mod. Would allow much faster iteration without need for translations, PR, etc., and users can more easily opt in/out of testing it.
What do you think?
I don't think we need to fix them we need to solve the track vs. road issues FIRST we should just increases their priority. this is only a problem only with track lanes on the top of car lanes. this is unlike Vanilla tracks in which the same lane supports both trams and cars. Only when tram and car lanes are separated (and tram lane has higher landex) this MIGHT be an issue.
Ok, that should be focus of v11.2 then.
Random thought: For the lane highlights, is there a way to have the border line dashed? Would be nice if the lane highlight could be visibly different when working with tracks.
Random thought: For the lane highlights, is there a way to have the border line dashed? Would be nice if the lane highlight could be visibly different when working with tracks.
Nope, changing border style is not supported by vanilla overlay shapes (I will consider it when I'll be working on improvements for new shader)
TMPE needs to patch RenderInstance() in order to solve this issue.
The problem is that NS2 is also patching RenderInstance() using incompatible version of Harmony. see https://github.com/pardeike/Harmony#harmony-12 .
We are using harmony V1.2 while NS2 is using intermediate V2.0 -NS2 readme explains why.
I think NS2 should change to 1.2 and find a way around __state problem (would patching 1.2 work?). I probably be the one who ends up doing that.
Other alternative is for TMPE to switch to version 2 but that is not going to work out well with other mods. TMPE could hold 2 versions of Harmony but I don't think that's a good idea because then explaining it to mod creators is going to be hard.
my conversation with boformer:
@krzychu124 I heard you are good at Harmony any ideas?
There are some problems which v2.0 resolves, but not available in 1.2, like ref struct params
.
I haven't looks into NS2 code yet, so I don't know where is/could be the exact problem. I only patched some Ui methods in FPS_Booster to make them compatible
I noticed that TMPE has worked around the ref struct params using manual harmony patching. NS2 could do the same.
EDIT: This issue Depends on #782
We must go to harmony 2.0.0.8 to resolve this issue. This is because I need to patch NetNode.RenderInstance()
which cannot be done in harmony 1.2.1 .
I did not manage to find a work around either.
Here is my conversation with @Brraiz
kian.zarrinToday at 20:30 Hi, Short version: does harmony 1.2.1 support by ref struct types? is there a list of bugs in for harmony 1.2.1? Long version: I am having trouble to patch a function with by ref struct parameter. It works on harmony 2.0.0.8 ... but on harmony 1.2.1, but I am getting format exception. I am patching it manually using Harmony.Patch(target:mytarget, transpiler:mytrasniler)
// the last parameter RenderManager/Instance& is a by ref struct type FormatException: Method NetNode.RenderInstance(RenderManager+CameraInfo, System.UInt16, NetInfo, System.Int32, NetNode+Flags, System.UInt32&, RenderManager+Instance&) cannot be patched. Reason: Invalid IL code in (wrapper dynamic-method) NetNode:RenderInstance_Patch0 (object,RenderManager/CameraInfo,uint16,NetInfo,int,NetNode/Flags,uint&,RenderManager/Instance&): IL_0e64: callvirt 0x000003b3
Brrainz Today at 20:45 It probably does not work
This is how the mesh looks like:
from right to left ConnectGroup
= oneway track:SingleTrack,OnewayStart - SingleTrack,OnewayEnd, SingleTrack,Oneway
twoway track: DoubleTrack
train station track: SingleTrack - DoubleTrack
These meshes are insufficient to cover all circumstances. I need to cut the material for two-way track in half. for more combos.
The UV map looks like this: UV map for the right track: UV map for the left track: They are intertwined. So I don't thin we need to cut the textures at all. We just need to modify the mesh and that's all. I don't want to go through the route of dynamic mesh creation. For now I will just create the mesh offline. I wonder if the mesh for the single track mesh could be shifted left or right without the need for mesh generation
I created the meshes for left and right track by loading the track in blender and deleting the virtexes for left or right. Left and right track.zip
Hopefully it will work as it is :)
EDIT: I have not got around doing the mesh for wires yet. but I need to do that at some point. EDIT2: IN any case even without this mesh I can do some stuff with train station tracks with the one way and two way meshes I already have.
Progress!
that's freaking awesome!
for quad networks we need meshes from asset creators. We have to let asset creators to use TMPE flags as required/forbidden flags for their assets. This means we need to work on Asset editor. I think I can create an add-on for that.
The code works for train tracks (not the wires yet) Now all that remains is dynamic mesh generation. Lods atlas could be tricky.
I closed this because this is now covered by the new AR tracks
Those RWY2 quad tracks? And procgen rails! Nice!
Can concrete/wood railway sleepers be added programatically to help fill some of the clipped region? Railway/BVU Track Customizations mod gives some indication of what to look for (at least for RWY1 assets).
Depends on #782
Setting max turn angle is one way of disconnecting sharp tracks. But it limited to disconnecting by angles. More customizable way of doing this is using lane connector.
To do this we need to patch NetNode.RenderNode() NetNode.PupulateGroupData() and NetNode.CalculateGroupData() . specially around the check flags code.
Use the same version of Harmony as Hide TMPE crosswalks and NS2 to be compatible with those mods. (boformer told me NS2 is buggy and different versions of NS2 don't work with each other :( )
EDIT:
Tasks:
ShouldDrawConnectTexture()
.ShouldDrawConnectTexture()
in every place where there is a check for direct connect insideNetNode.RenderNode()
to support close camera.PLAN: see https://github.com/CitiesSkylinesMods/TMPE/issues/734#issuecomment-590807175
This task needs to be divided into several steps: