MCMic {l Wrote}:Hi!
I'm trying to see if I can implement a reverse mode in STK.
I tried just reversing the quads order in the vector, no the karts start backwards (that mean, in the right way for a reverse mode), but lap counting and kart ranking has gone crazy…
What are the other elements that I should alter?
I looked the checklap system but it does not seem way-dependent.
Also, on the math class track, the AI drives in the wall. But it's the only track on which I experienced this problem.
Auria {l Wrote}:1) when multiple checklines are chained, the chaining order needs to be reversed. This is I guess best done directly in blender
2) we have code that goes through the driveline and sets on each quad what is the required checkline. Check that this code does indeed go the reverse way, otherwise quad requirements will be wrong (see QuadGraph::setChecklineRequirements)
3) for rankings, start at LinearWorld::getDistanceDownTrackForKart
Auria {l Wrote}:The 2 unconnected edges are used only in blender and are not present on the C++ side of STK as far as I know.
Regarding checklines, one thing is that many tracks have only 1 checkline and don't chain them, so you could start with this case, which is much easier since there is no chaining to reverse then (i.e. nothing to do for reverse mode)
MCMic {l Wrote}:Ok, I got the reverse of the quads right, now it works on some tracks.
(As quads re-use points of previous quads, I have to wait for all quads to be load before reversing)
But I still got a problem on oliver math class:
It seems to me there is only one checkline so that should not be a problem. But the lapcounting does not work, and it seems the lapline is wrong placed
MCMic {l Wrote}:Ok, here is the svn diff with a reverse mode.
http://pastebin.com/03GC70Bp
It does not work for all tracks, but most of them are OK.
I revert the checklines order so that mess with their indexes and (some of the) tracks with multiple checklines works.
Is a mode the best way to integrate reverse tracks?
Could a STK dev look at my patch and tell me if it's OK?
I think we could activate only some levels in reverse mode (the one that works), the same way only battle levels are available in battle mode, is that possible?
What do you guys think? (Either way I'm enjoying playing reverse tracks, it's almost like playing new tracks ^^)
hiker {l Wrote}:It does not work for all tracks, but most of them are OK.
I revert the checklines order so that mess with their indexes and (some of the) tracks with multiple checklines works.
That sounds great
Is a mode the best way to integrate reverse tracks?
Sorry, definitely not. This way you can't have all three race modes in reverse, you only get one. I'd say that in the last gui screen (where you select number of laps) you can also select 'reverse track' (if available for the selected track).
It looks like you are just modifying the quads, not the quad graph (but admittedly based on a very quick look) - is that correct?
Also I noticed that you just completely commented out some (unrelated) functions (e.g. Track::loadCurves). If there is some reason for this this should certainly be a separate patch - bezier curve support was started in order to have a kind of camera zoom showing the track at start up or so, though it's not used atm).
It should be a per track flag added to the track.xml file.
MCMic {l Wrote}:Ok, here is the new version of it : http://pastebin.com/2t8jskwV
Now there is a "revert" option that must be set to "Y" in track.xml if a track can be reversed, and then when choosing the number of laps, there is a checkbox allowing to revert the track.
It seems to work pretty well.
- void loadTrackModel (World* parent, unsigned int mode_id=0);
+ void loadTrackModel (World* parent,
+ bool revert_track = false,
+ unsigned int mode_id=0);
And if this patch is validated, the option should be added to be able to add reversed track in GPs.
hiker {l Wrote}:[*]It would save us some work if you could follow our coding style guides, esp. using "{' on a new line, and perhaps the maximum line length of 80 (admittedly there is a lot of code that does not adhere to the latter).
hiker {l Wrote}:[*]If you add a new function parameter with a default, try to add it to the end (so that it's less likely that any other code might provide suddenly incorrect parameters), e.g.:
- {l Code}: {l Select All Code}
- void loadTrackModel (World* parent, unsigned int mode_id=0);
+ void loadTrackModel (World* parent,
+ bool revert_track = false,
+ unsigned int mode_id=0);
[*] I don't understand why you have to revert the quads. Ideally this shouldn't matter, but there might be a bug ... or I might be missing something But I would prefer fixing any bugs we might have, than working around them
[*]I don't think that simply reversing the quads will work - as soon as you have a short-cut/alternative way, it won't work anymore. Also there are some (at least one ) internal data structure which will likely not be correct anymore (the bouncing ball has information about what path to use to reach a kart that might be on a short cut). The right way would be to reverse the graph, since it's the graph that determines the order in which the quads must be driven. If you need additional explanation here, let me know!
[*] Just reverting the order of the check-structures is not good enough, it will (most likely) work if we have a simple linear list of check-structures, but not all tracks have that. Have a look at math class, which has two additional check lines to the left and right of the start line (which are (iirc) necessary if a kart crosses the line to far to the left, but still under the bridge). I didn't try, but with your change it should be possible to cross the lap line on the very far left, then you can drive back, cross to the right, drive back, .... Let me know if you want some additional explanation of this.
MCMic {l Wrote}:hiker {l Wrote}:[*]It would save us some work if you could follow our coding style guides, esp. using "{' on a new line, and perhaps the maximum line length of 80 (admittedly there is a lot of code that does not adhere to the latter).
Oh, yeah, sorry about that, didn't cross my mind :-/
hiker {l Wrote}:[*]If you add a new function parameter with a default, try to add it to the end (so that it's less likely that any other code might provide suddenly incorrect parameters), e.g.:
- {l Code}: {l Select All Code}
- void loadTrackModel (World* parent, unsigned int mode_id=0);
+ void loadTrackModel (World* parent,
+ bool revert_track = false,
+ unsigned int mode_id=0);
Hum, I searched in files and it seemed that this parameter was never used, that's why I added my parameter before it. (And if I add my parameter in the end, I'll have to fix the value of the other one when I call the function and want to set the value of my parameter.)
[*] I don't understand why you have to revert the quads. Ideally this shouldn't matter, but there might be a bug ... or I might be missing something But I would prefer fixing any bugs we might have, than working around them
If I just reverse the order of quads and not there direction, rank is wrong when two karts are on the same quad. (the kart that is behind the other is shown first in the kart list)
[*]I don't think that simply reversing the quads will work - as soon as you have a short-cut/alternative way, it won't work anymore. Also there are some (at least one ) internal data structure which will likely not be correct anymore (the bouncing ball has information about what path to use to reach a kart that might be on a short cut). The right way would be to reverse the graph, since it's the graph that determines the order in which the quads must be driven. If you need additional explanation here, let me know!
Yeah, I thought about these shortcut problems and things, but I don't know STK graph system enough to sort this issue out.[*] Just reverting the order of the check-structures is not good enough, it will (most likely) work if we have a simple linear list of check-structures, but not all tracks have that. Have a look at math class, which has two additional check lines to the left and right of the start line (which are (iirc) necessary if a kart crosses the line to far to the left, but still under the bridge). I didn't try, but with your change it should be possible to cross the lap line on the very far left, then you can drive back, cross to the right, drive back, .... Let me know if you want some additional explanation of this.
I know reverting the order of the check-structures won't work for all tracks, but I did not got any better idea.
That's why there is this "revert_available" flag for tracks.
I think tracks that have a more complicated check system should have a second check system for the revert version of the track.
So, what should I do now?
I'm not sure if I'm familiar enough with STK code to improve the reverting that much.
m_all_nodes[from]->addSuccessor(to);
if(reverse)
m_all_nodes[to]->addSuccessor(from);
else
m_all_nodes[from]->addSuccessor(to);
And besides I'm not sure on which version of the code I should work on (I think I should switch to the svn branch you created and send patches for this version, but I'm not sure about that)
hiker {l Wrote}:Well, I'd say that flag should only be used for tracks that can't be driven backwards, e.g. a track that has a jump in one direction that can't be driven the other way - iirc Crescent Crossing has that problem (when leaving the house).
MCMic {l Wrote}:Hiker, I commited in the branch.
I tried the reversing graph thing.
It does not fully work, even after putting back the quad reversing. (the directions, not the order)
No surprise lap counting is buggy as checklines are messed up (I don't reverse checklines order as we said it's not a good solution).
But kart ranking does not work either. I can't figure out why…
MCMic {l Wrote}:Oh, really?
I had the problem of being unable to check the checkbox when the text I had added was in front of it, but I thought I managed to fix this, it works on my computer.
Users browsing this forum: No registered users and 1 guest