The online racing simulator
Collision detection
(56 posts, started )
Collision detection
So i was racing around a tight autoX course and i just realized how much this annoyed me. I'd clip a big red barrier, sink in a bit and then shoot off in the other direction when i should've hit it and ricocheted off, not sling shotted in the wrong direction. This also affects racing sometimes but i think thats more lag. I can understand that things like collision detection is hard to program for but most other racing games dont seem to do this sling shot thing at all. any thoughts?
THis is very annoying. It makes contact in LFS very unrealistic, in close racing in city tracks liek SO there is ALWAYS contact.

In LFS a contact that was just a small scrape could cause 2 cars to fly couple hundred feet into the air while IRL the car would have just hit each other and kept on going. This results in bad starts and causes racing expirience to be bad just because a person accidentally scraped a little bit of the front person's rear bumper. I think lag is one of the most serious problem but it isn't the only problem, there are a few bugs and it woudl be very good if the LFS team worked on that before anything else less important.
its just an incomplete collision system thats all, some objects act as rubber objects by absorbing mass and momentum and act as a single vertex and fling the car somewhere with tremendous force

.. which needs work, yes we all know.. not to much of a bug when everyone knows about it
Also, the car moves every 1/2000th of a second, but collision checking only happens every 1/100th (because it's CPU intensive). So the collision code should really allow for this somehow.
i think almost everyone could handle it updating at 1/2000th of a second... LFS only uses like 55% of my cpu when i Run it..
#6 - Lible
NOOO! My cpu is 100 and never less when i run LFS My computer should be in museum.
i think what bob said would be feasable. just allow for some tollerences to be accounted for when a collision occurs. not being a programmer i would have no idea where to start but i dont think we ned every 1/2000th of a sec updating for collision. that would make LFS much less accesable to everyone unless they had a high end pc
#8 - M.Mos
Only the cars are only updated 3-6 times per sec. , that isn't much or?
Is their a way to increase online car updates?
Quote from M.Mos :Only the cars are only updated 3-6 times per sec.

Thats PPS (Packets Per Second), which does not relate to physics steps. Each client runs its own physics steps, if they do not match the servers final outcome (per packet from the server), then the client is forced to alter its game state. By doing this you can run games over the net at a reasonable speed, but of course when you get slow machines or slow net connections you can get "snapping" of cars.

I believe Bob isnt 100% correct in his explanation (Scawen, or anyone who knows better feel free to correct me); The main game loop runs at 100Hz (100 times per second). In this loop boundary box sanity checking occurs. However, there is a internal loop, which runs at approximately 2MHz (if I remember correctly). This inner loop moves the car and samples things like tyres, etc.

Quote from Roadie :i think almost everyone could handle it updating at 1/2000th of a second... LFS only uses like 55% of my cpu when i Run it..

As said, increasing this to every 1/2000th of a second would certainly kill most machines, including yours. Why almost exponentially decrease the potential market of LFS, for the sake of stopping the rubber object syndrome?
either way.. i have a good replay of proof of how far ahead of time the damage works.. i have a replay of me running into a car stopped on WE after he spun out and i was on outside of turn and he spun into me path.. and about a quarter of a second before i hit him, my nose gets all crushed up
Thats very interesting XCNuse, could you possibly post this? Was it online?

It might change the way we think LFS runs. Either that or we could contribute it down to a lag, and then a tiny client snap.
Quote from the_angry_angel :I believe Bob isnt 100% correct in his explanation (Scawen, or anyone who knows better feel free to correct me); The main game loop runs at 100Hz (100 times per second). In this loop boundary box sanity checking occurs. However, there is a internal loop, which runs at approximately 2MHz (if I remember correctly). This inner loop moves the car and samples things like tyres, etc.

Isn't that what I said? And it's k for thousands
:doh: Didnt read your post properly Sorry Bob!

And yes, you're right. It should be KHz
Quote from XCNuse :either way.. i have a good replay of proof of how far ahead of time the damage works.. i have a replay of me running into a car stopped on WE after he spun out and i was on outside of turn and he spun into me path.. and about a quarter of a second before i hit him, my nose gets all crushed up

I saw something like this too, but I thought it would be just my imagination... I drove XFR on SO Long (somebody said it is scary and I had just to check it out... ) and crashed into a wall pretty bad... When I watched this crash on the replay, it was as if parts of the car backed off to avoid hitting the wall (did it anyways, but looks funny: "Car scared by wall" )
To XCNuse:

Isn't that what always happens when your car hits something? Check some of your replays and watch one hit in slow motion 0.250x to see that the damage is always slightly before the actual touch.

---
I am not a programmer myself either. It is hard to find the reason why sometimes a little touch can get so forceful (spelling...). As someone explained earlier the cars and other object in game move every 1/2000 seconds (?) and collision detection happens every 1/100 seconds. And in online races cars get updated 3-6 times per second, though this has nothing to do with this? (because these can can happen offline too and always with some objects, like the concrete road blocks)

So two cars side-by-side can get inside each other cars' in a 1/100 second and then the collision detection notices it and creates the force to simulate the touch between the cars. As an outcome the player feels the force

If the collision detection engine works how I think it does: It watches over the objects in the game and when too objects slightly cut each other's outlines the collision detection gives the phys-engine some data that there is a force between these two objects, the greater the cut in the greater the force.

But could it be that the damage-detection engine (...) can't handle sharp edges in collisions? Maybe the sharp edges can get a little deeper in other object before the collision detection notices it? And then the collision-engine thinks that the objects have much more speed than in reality they have at the moment. Because the the sharper object is so deep in the other object. So the force between the objects get too big and kaboom!

I assume the force should be equally as big as the objects' momentum? So the force was to just keep the objects separated (not allowing an object to get inside an other object)?


Sorry for bad english and horrible speculations :P
It down to many things inculding; ping/ cpu speed/ server cpu speed/ packet quality/ isp congestion.




If the game server is overloaded(too many clients/stuff going on at the same time etc) people will begin to see server induced lag.

Server lag can be caused by lack of bandwidth or a slow cpu, wont matter if you have a ping of 5ms if the server cant send new data that fast.

The same can be said for the client pc, but its easyer to see.
A low frame rate can indicate lag on a client, lowering the framelimiter will alow the cpu more time to do other things.
If your pc is running slow, then your car will sink further into objects before anything happens. Speed is also a factor, the faster you go the faster your cpu needs to run in order to calculate the cars positon.

lfs uses ( i think) a physics based collision system, and a force is placed on objects upon collision. Nothing stops them from moving through each other unlike the gt games. Which use a bounding box solid surface for collison. Evan then objects can still go through each other when the framerate drops very low. (like 5fps)
Too very overlapped objects can end up placing their forces in the wrong direction, which is why thay can take off evan offline.
Pridiction errors online will cause a larger than normal force to be transmitted before you get the next update. So you start to fly, while the other person drives on as if nothing as happend.

the ping time you see will only be the minimum time for data travel, its not the full story.

you need a ping of 10ms to match lfs physics rate(100hz)
50 ms ping will give you 20 updates a second, not much is it?



When everything is working well, lfs has proven to be very good at collision/multiplayer.
Quote from -wes- :The same can be said for the client pc, but its easyer to see.
A low frame rate can indicate lag on a client, lowering the framelimiter will alow the cpu more time to do other things.
If your pc is running slow, then your car will sink further into objects before anything happens. Speed is also a factor, the faster you go the faster your cpu needs to run in order to calculate the cars positon.

So setting the framelimit can prevent these too? I ask this because I've just bought a new computer but haven't set framelimit...would around 30fps be enough?

And if two car's collide, the player with slower PC or slower connection (not talking about megabytes) gets the aero-effect?

I was just wondering how the collision detection actually works
Quote from Hyperactive :Isn't that what always happens when your car hits something? Check some of your replays and watch one hit in slow motion 0.250x to see that the damage is always slightly before the actual touch.

Thinking about it, that could be probably be because the bounding box is very slightly larger than the car. A bounding box is a simplified "outline" of the car, which you can more easily check for intersection of vertexes on.

Quote from Hyperactive :If the collision detection engine works how I think it does: It watches over the objects in the game and when too objects slightly cut each other's outlines the collision detection gives the phys-engine some data that there is a force between these two objects, the greater the cut in the greater the force.

Thats exactly right Or at least how its traditionally done.
Quote from the_angry_angel :Thinking about it, that could be probably be because the bounding box is very slightly larger than the car. A bounding box is a simplified "outline" of the car, which you can more easily check for intersection of vertexes on.

But if I remember it correctly I've seen the damage appear when the car was like half metres or more (around 2 feet) away from the wall for example. And not doing more than 60kph. So a slightly bigger bounding box doesn't sound to me how it is - and I may be wrong of course :Handshake:
There's obviously a prediction system. We'd complain a lot more if the cars stuck through the fences momentarily before deforming!
yes hyper, you can pretty much watch any replay in slow mo, and you will see damage occur.. before you even get near the wall, here ill post just a quick replay showing this

just did a few tests.. it seems as though it only calculates early with cars (well.. hitting walls here and it crushes right after i go into them.. hm)

highlighted the times the corners
1 before
2 instant car deforms
3 well.. a bloody result :scared:
Attached images
rep1.jpg
rep2.jpg
rep3.jpg
Quote from Hyperactive :So setting the framelimit can prevent these too? I ask this because I've just bought a new computer but haven't set framelimit...would around 30fps be enough?

And if two car's collide, the player with slower PC or slower connection (not talking about megabytes) gets the aero-effect?

I was just wondering how the collision detection actually works

Well only if lfs is cpu bound on your system. It Just prevents the pc from doing screen related things.Put up the framerate on the screen. See if it changes after reducing the screen detail/res. If you have just bought a new pc a low framerate is more likely being caused by the graphics card.




programing link

source code
#23 - Gunn
Perhaps clipping adds to the illusion? OT, I was surprised to find my car undamaged recently after I slammed into a wall at high speed. On inspection of the replay my car appeared to repair itself as it rebounded from the wall, the way the AI does. New panels, new paint, new tyres! I should try to dig that one up and post it. Very unusual.
#24 - Vain
This is the usual way to substitute a full-blown prediction of collisions and all the trailing stuff and because of that I believe that the devs are fully aware of where, why and under which conditions this happens. And we will propably see advancements in the next versions. It's just very work-intensive.

Vain
I have had experiences when i drove straight throug the wooden fence @ blackwood carpark, and the car gets instant repair kinda LOL isn't it

Collision detection
(56 posts, started )
FGED GREDG RDFGDR GSFDG