1. Trouble with the game?
    Try the troubleshooter!

    Dismiss Notice
  2. Issues with the game?
    Check the Known Issues list before reporting!

    Dismiss Notice
  3. Before reporting issues or bugs, please check the up-to-date Bug Reporting Thread for the current version.
    0.35 Bug Reporting thread
    Solutions and more information may already be available.

Why do backwards collision triangles exist?

Discussion in 'Troubleshooting: Bugs, Questions and Support' started by clayton8or, Jul 29, 2015.

  1. clayton8or

    clayton8or
    Expand Collapse

    Joined:
    Aug 26, 2013
    Messages:
    1,052
    Title is the question. Is there even a reason for them to exist? they seem to hurt way more than help... if triangles were the same on both sides it would be so much easier to prevent vehicles from clipping into themselves and others and would also stop them sticking to everything. can someone explain why they are this way and what the benefit is, and if no benefit exists, why is it still this way?
     
  2. estama

    estama
    Expand Collapse
    Developer
    BeamNG Team

    Joined:
    Aug 7, 2012
    Messages:
    268
    Triangles are more or less the same on both sides.

    The main difference between the two sides is that one side is somewhat "fatter" than the other side so it can stop faster moving nodes trying to go through it. The bias between the two sides exists because it is a very frequent case to have faster objects coming from the "outside" and slower self-collisions coming from the "inside" of a vehicle.
     
  3. Aboroath

    Aboroath
    Expand Collapse

    Joined:
    Aug 25, 2013
    Messages:
    3,804
    What dictates the calculation of "speed" with a node?....or what is the limitation of a face to prevent a node from penetrating?

    Do CPU cycles or ram speed dictate what and how a triangle performs? God I hope this makes sense. I'm trying to
    understand what causes clipping and how it can be remedied.
     
  4. clayton8or

    clayton8or
    Expand Collapse

    Joined:
    Aug 26, 2013
    Messages:
    1,052
    But then why such a sticky inner side triangle?
     
  5. clayton8or

    clayton8or
    Expand Collapse

    Joined:
    Aug 26, 2013
    Messages:
    1,052
    sorry for bump but post above hasnt been solved/answered.. ^^^
     
  6. ThreeDTech21

    ThreeDTech21
    Expand Collapse

    Joined:
    Sep 27, 2013
    Messages:
    1,616
    I would like an answer to this too, currently I am making a vehicle that would greatly benefit from having the strong collision on both sides. No one has spoken to the benefit of having a weaker side of coltris. Also coltris doesn't stop all collision, Maybe this is a limitation of the game engine or again is by design. To change the behavior of the coltris I think the source code would have to be edited which I doubt many would be able to do unless a Dev. Looking at it from a physics perspective the current design of coltris isn't right, since real metal/concrete will have the same strength on both sides. I can't tell if the current implementation of coltris is a game limitation or if it is by design.
     
  7. KennyWah

    KennyWah
    Expand Collapse

    Joined:
    Jan 16, 2013
    Messages:
    2,658
    It's likely a design flaw and a game limitation.

    I don't know but collision in video games might be connected to normals of meshes so when one makes a collision mesh if lets say that mesh has a backward normal would that be the same wonky collision that causes intersection and sticking.

    If double collision existed we'd be able to save tons of jbeam complication, fix some deformation and collision issues.

    Idk I could just sound like a complete moron but this could be why in jbeam you have to make a full box to allow for collision on both sides to exist.

    - - - Updated - - -

    Is there any way physics rates are effecting the efficiency of these triangles?

    [Coming back to how the physics update @ 2000 updates/second]

    even tho I don't think something could possibly move fast enough to penetrate a solid wall that is programmed to stop something that is running on a system updating at such a rate.

    However I understand the concept of collision in PC calculated physics is hard enough as it is.





    I'm sorry I really don't understand why/how collision works the way it does in coltris.
     
  8. estama

    estama
    Expand Collapse
    Developer
    BeamNG Team

    Joined:
    Aug 7, 2012
    Messages:
    268
    Collision detection in general is very computationally expensive. The bigger the frequency of the physics engine, the greater the load on the collision detection subsystem. Due to the extreme frequency that BeamNG's physics engine runs (2khz or 2000 times per second), collision detection requires a considerable percentage of the total CPU budget. This used to be around 45-55% with previous versions of BeamNG, but due to optimizations it has been reduced to 35-45% with later versions.

    The major reason that clipping happens is due to the collision subsystem not checking edge with edge collisions. It only checks for node with triangle collisions. I'm doing research on ways that this could be solved, but i have to be careful to not raise the collision subsystem's CPU cost. This isn't an easy problem, so it will take a while.

    Now, for a node to be able to clip through a triangle's side it has to move fast enough, so that it'll "skip" from one side of the triangle to the other side. The "fatter" the triangle, is the harder for the node to skip from one side to the other.

    Right now in BeamNG, collision triangles have a total width of 5cm (2.5cm on either side). The outer side occupies a significantly bigger % of this 5cm than the inner side. What in practical terms that means, is that the outer side is able to stop nodes that are moving faster (relative to it), than the inner side is able to. So the outer side should be able to stop a node approaching at ~350km/h and the inner side a node approaching at ~150 km/h.
     
    #8 estama, Oct 9, 2015
    Last edited: Oct 9, 2015
  9. SHOme1289

    SHOme1289
    Expand Collapse

    Joined:
    Nov 6, 2013
    Messages:
    1,286
    wow, that's amazingly interesting. Great to know.
     
  10. KennyWah

    KennyWah
    Expand Collapse

    Joined:
    Jan 16, 2013
    Messages:
    2,658


    This sounds like a very complex problem to tackle.


    Also why does the inside coltri cause sticking than? also is there any reason why the inner side can't be slightly increased in size to handle speeds faster than 150? does that increase CPU overhead? Does that introduce more issues such as inter-collision problems?

    I assume edge-detection isn't used for optimization reasons.

    Sure would be nice if we all had 10GHZ hex cores huh? or just super-computers. lol someday, maybe someday we will see a larger improvement in CPU speeds that aren't primarily core related and/or just slightly faster than previous iterations.
     
  11. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    601
    So if I'm understanding this correctly, collision detection is done on a point-in-volume basis? Now I'm far from an expert on physics calculations, but I would expect that line-plane intersection (the line being from a node's previous position to its current position) would not be significantly (if at all) more computationally expensive. Note that I'm not trying to say you're doing it wrong or anything - I'm just curious about the workings and performance of the collision detection.
     
  12. ThreeDTech21

    ThreeDTech21
    Expand Collapse

    Joined:
    Sep 27, 2013
    Messages:
    1,616
    node x, y, z position over time, sounds logical, that would be the reason why nodes can go through a collision mesh, if the node is moving fast enough it would present itself right in front of a collision mesh and in the next frame it would already be past the collision mesh or stuck inside it (clipping) I never thought collision could be explained in such a clear manner thanks! ;)

    now what would happen if the simulation doubled to 40Khz? would that be too much for current PC's?
     
  13. estama

    estama
    Expand Collapse
    Developer
    BeamNG Team

    Joined:
    Aug 7, 2012
    Messages:
    268
    I'll try to answer all the questions :) .

    @Slayersen:

    Micro-jitters and numerical precision problems might cause sticking because a node can momentarily manage to pass its allowed inner-threshold, and enter into the outside-threshold. When on the outside it is kept outwards. Increasing the inner side might be done in two ways. Either reducing the outside's width (which will make the outside more prone to clipping), or increasing the overall triangle's width. Increasing the overall width will make it more difficult for vehicle creators to design vehicles, because they'll need to keep bigger distances between triangles.

    Edge detection would massively increase the CPU cost of the collision subsystem. It is something that bothers me (not having edge-edge detection) and i'm trying to find ways to solve it. It isn't an easy problem (especially at 2khz [*]), so i cannot promise anything about that.

    @Scepheo:

    What you are talking is the approach of using swept volumes/lines to do the collision detection. This is a requirement when a physics engine works at low hz. At high hz it isn't needed that much (things move a lot less in a given time dt). Even so i have experimented with these ideas. Lines only help when you first switch sides. After that they are problematic or you need to go to more complex solutions that increase the CPU cost. In previous work i've used the beam skeleton to be able to find which is the "correct" side (looking at which side the nodes with which the colliding node is connected with, are), but it led to a new set of problems and overall wasn't worth it.

    @AmberPixel21:

    With double the hz, the collision subsystem will be able to stop nodes going at double the speeds. The overall CPU cost will also double. We have done experiments at higher hz (4.5khz), but until the CPU/GPU technology advances some more (and propagates to the users), it'll be non realtime for most of the people.


    [*] An easy way to understand what 2khz means, is to invert the meaning and look at it as msecs per physics step. 2khz = 0.5 msec per step, in which all the vehicle physics need to be calculated, collisions found, the work on multiple CPUs being orchestrated and so on. A CPU that runs at 3.4 ghz can do ~1.7 million operations (calculations and so on) in 0.5 msec. When a vehicle has 4000 beams that means that the core has ~425 CPU ops per beam to use (in reality these 425 ops are not only per beam but for all the nodes, the collisions and so on). So the CPU budget is pretty constrained.
     
    #13 estama, Oct 10, 2015
    Last edited: Oct 10, 2015
  14. Aboroath

    Aboroath
    Expand Collapse

    Joined:
    Aug 25, 2013
    Messages:
    3,804
    It's amazing reading Estama's posts and realizing how good the collision has come in two years. Great explanations and some good answers
    to questions I've had for a long time. Things are so unbelievably tight no one can even think about arguing against the optimization being done
    here. Amazing.
     
  15. KennyWah

    KennyWah
    Expand Collapse

    Joined:
    Jan 16, 2013
    Messages:
    2,658
    I think I would lose my mind just digging and digging for the impossible to find a good balance between optimization and performance in the said collision system.
     
  16. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    601
    I'm not sure what you mean when you say "lines only help when you first switch sides". Other than that I'd say continuous collision detection is used whenever discrete doesn't cut it - which seems to be happening here. I was thinking you could do edge collisions in much the same way, by generating plane segments for the movement of each edge (like you'd generate a line for a node) and seeing if these intersect. You'd still run into the problem of detecting the "correct" side, though I'd "solved" that (in my head) by assuming the previous position to be correct - I'd imagine you've considered this solution too and found it lacking. I'd also come up with using bounding boxes for edge collision, though I think that would give similar thickness issues. That said, I'm pretty fascinated by how such a "simple" thing like triangle-node collisions can generate such complex behavior.
     
  17. estama

    estama
    Expand Collapse
    Developer
    BeamNG Team

    Joined:
    Aug 7, 2012
    Messages:
    268
    Think what happens in the case, when a node is close at the boundary of the two sides and its "from previous position line" crosses this boundary [*]. If you use the "line logic" it'll tell you that the node should be on the previous side (the side of the triangle the node was on, previously), on the next frame, the line will be in the opposite direction signalling the opposite ... and so on. The end result is a node vibrating between the two sides of the triangle. So you'll need more complex "side choosing" logic to solve this problem (i actually know how to do that, i have coded it in the past). This more complex logic requires more CPU and memory traffic.

    So the main question becomes, is that worth it? Considering that all this additional CPU and memory traffic cost will benefit mostly the inside side case (increasing the stopping speed from 150 km/h to 500 km/h), without solving the major clipping reason that is: missing edge-edge collisions. I've decided that it isn't worth it. I prefer to invest this processing budget to other things like simulating for example pressured tires and so on.

    This does not mean that i won't ever add this logic in there. It is just that, when one faces a computational environment so tight, he has to constantly make trade-offs and very carefully choose the things where he'll put his scarce CPU cycles on.


    [*] There is also the case of the node being completely stationary and the triangle speeding towards it. In this case the "from previous node's position line" logic doesn't help at all. There is a way for this case to be solved but it requires to consider the triangle's moving/rotating frame of reference which would only make the discussion more complex.
     
    #17 estama, Oct 11, 2015
    Last edited: Oct 11, 2015
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice