Vegetation can pass through bridge

Vegetation can pass through bridge

Postby Wuzzy » 11 Sep 2014, 05:22

OK, I report a bug everyone probably already knows about but nobody bothered to complain … yet. :D
I also have not found it in the issue tracker.

The bug is very simple:
It is possible for vegetration to spawn under a bridge. That alone would not be a problem. But if the vegetation is high enough, it crosses the bridge, so that you have awkward cases where trees go simply through the bridge. It looks ugly. But what it much worse, it obscures the view and makes driving on an affected bridge painful. It gets even more annoying in pipes IMO.

It looks like this:
SRTreebug1.jpg

SRTreebug2.jpg


For tracks with many trees and bridges, this can be really an issue, to the point where the trees are totally blocking the view and you are almost blindly driving. The car usually does not collide with the tree when driving on a bridge. That’s at least something! :D



I think a simple fix might be to project the road down onto the floor and simply not spawn any vegetation on that pseudo-road, like it is done for the ordinary road already.

This would fix the bug. But it could be better IMO. And frankly, it would just replace one uglyness with another uglyness. The problem with this fix would be obviously that for very high bridges, you would get an awkward scenery on the ground, basically you can directly see the road’s projection because no tree whatsoever spawns there. Basically a “ghost road”. :D

A more sophisticasted fix might also take the tree height into account. So trees may spawn under a bridge, but only if the tree height is smaller than the bridge itself; probably the bridge height minus a little “buffer distance”, to be precise. This avoids those awkward-looking sceneries when the bridge is very high, like in Twister.
It could get a bit tricky for tilted roads however.

But I guess that would just mean that one has to subtract another number from the bridge height, namely half of the track width I guess. Why? That’s for the case when the road roll is exactly 90°; and the road always rolls around its center. And for 90°, half of the track width faces downwards.

So, the formula for the maximum tree (vegetation) height M under some point under a bridge might be:

M = h - 0.5*w - t

M: maximum vegetation height for that point
h: height of road at that point
w: width of road at that point
t: a small extra buffer (a constant)

This formula should always give a height so that only vegetation that comes only close to the bridge at most, but never touches or even crosses it is allowed under a bridge.



OK, with the second part of this post, this post has more become like a feature request than a pure bug report, I admit. ;)
But the problem is still real.
User avatar
Wuzzy
 
Posts: 989
Joined: 28 May 2012, 23:13

Re: Vegetation can pass through bridge

Postby CryHam » 11 Sep 2014, 12:42

I'll try to be short. If it was easy to fix, possibly would be done already.
(all the easy issues are gone since years, probably one of (many) reasons nobody codes beside me).
There is currently a simple check in road density, but not so good (it doesnt know tree height just some const factor into 8-bit color see CreateTrees, and roadDensity is in Road_Rebuild.cpp line 503, //par ] height diff mul). Actually don't try it, needs better code.

The way I see it there are 4 possible solutions:

1. Don't read this, but ideal. Creating trimesh for each vegetation model and asking bullet if it collides with any trimesh from road but somewhere above ground. Even if, then it would be like 2 sec before track load or sth. Can't do. And lots of code and CPU use.

2. The best IMO. Note that your solution doesn't at all take in account tree width. E.g. jungle trees (firs too, they arent just a pole right), that are to be placed 1m (or even few) to side will still be placed, since height diff is checked at their center (and road or pipe isn't there).
So I propose, having real mesh height an width radius for each model. Saved in some xml (a tool could do that).
Then another road density with only height diff from road to ground in real meters (idk if 8-bit is enough, maybe yes).
Then in placing code, we check the real dimensions on that new road dens and see real height diff [m] within the radius (of that point the tree is to be placed). This way IMO should be fast and I think quite good.

3. Painting in editor, is already an issue there. Would be possible in ed to paint with some brush an area where not to create trees, etc. Is anyway needed to code this, and could be usefull for more things.

4. Without anything, (those screens just scream to me) deform the ground to be higher, or to lower (unless it's just an example), or add noise there so high terrain angles would reject creating trees there. Stupid but usually works, and already now.
User avatar
CryHam
SR Moderator
 
Posts: 1047
Joined: 25 Nov 2012, 08:40

Re: Vegetation can pass through bridge

Postby Wuzzy » 11 Sep 2014, 16:24

OK, I can mostly understand.

E.g. jungle trees (firs too, they arent just a pole right), that are to be placed 1m (or even few) to side will still be placed, since height diff is checked at their center (and road or pipe isn't there).

So what? The user of the editor would just have to set a proper distance from road, which simply applies to the projected road as well. The user just would have to increase the distance a bit to make it fit for bridges.
And I was talking about the total mesh height of course, not some arbitrary height at some point.

And about XML: Wouldn’t it be possible to ask Ogre3D directly for the model height or something like that instead? Or would be that too expensive? But there can be only 10 model types at most, so there would be 10 calls at most. The heights of the individual models can be made by simple calculations.
Apart from that, I think solution no. 2 sounds pretty reasonable to me, yeah. And road height must still be known somehow, true.


And yeah, I already know about 4 but it’s a hack and would not always work without destroying the landscape. There are also a couple of “official” tracks in the game where the bug applies, like that jungle swamp or how it is called.


Off topic:
Painting sounds like an interesting addition. But would that mean that the editor loses some of its automatisms? I certainly would not like it when I have to paint the stuff all manually now.
User avatar
Wuzzy
 
Posts: 989
Joined: 28 May 2012, 23:13

Re: Vegetation can pass through bridge

Postby CryHam » 11 Sep 2014, 17:08

But that distance would have to be just for those under bridges. Not that what we already have on Gui, which would make all trees further from road right.
Yeah I guess tree size could be get right before creating them, without that xml.
Painting would be an additional feature. New mode to paint, add textures to paint. Use them here and there after. Saved as another png's in track's dir.
Surely I wouldn't want to paint vegetation for all 147 tracks after, right, hah.
User avatar
CryHam
SR Moderator
 
Posts: 1047
Joined: 25 Nov 2012, 08:40

Who is online

Users browsing this forum: No registered users and 1 guest