Announcement

Collapse
No announcement yet.

[OPEN-SOURCE] Machinery Modelling Toolkit

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Originally posted by BoredEngineer View Post
    On user reported that for him this change didn't made much difference and what made difference is removing LightTankExperimentalTracks from the level. It is performance heavy but not that heavy, perhaps there is something wrong with it in another aspect. For now, I'll remove it from the level. Could you try doing the same?

    Basically I should get rid of current way of how you get into vehicles. Was planning to have something like a spawner platform, where you can select a vehicle to spawn and then posses it to drive around. Just to avoid having all this vehicles in the level. especially as only few of them have ability to go into "sleep" state when inactive.
    Like user reported the same thing , after removing LightTankExperimentalTracks performance is back to normal
    Last edited by Miro-zg; 03-01-2017, 09:44 AM.


    Comment


      Another clue as to why there is such performance difference and I don't see it on my side - I never use it with Play In Editor Viewport. On my side, by default it starts in a New Window when I hit Play. As all default settings are removed from GitHub repo, for anyone who gets copy from repo by default it will start in editor main viewport, unless you change it. I'll test this on my side, at least I hope I can reproduce this issue this way.
      Last edited by BoredEngineer; 03-01-2017, 11:05 AM.
      Youtube Channel

      Comment


        Welp, so I get about 27 fps in both cases and around 80 when LightTankExperimentalTracks is removed... I've measured fps in Simple Examples level, where the same tank is placed off side and I get 55fps with tank and 120 without it.

        So I'll remove it for now from the main level as it clearly has some serious issues with performance. It will be back after porting track tracing to c++.
        Youtube Channel

        Comment


          Hi. First of all thanks for making this. and making it easy to use

          i have played around with this for a bit now but i have some problems with friction. It Looks like its in the compiled version you uploaded as well.
          The problem is that even if all my friction-points says static the tank still slides. And if i set the friction higher it slides less but will start stuttering when on flat ground. Not a lot, but it will never stop to move.
          Am i making the wrong assumption that when the friction is using static it should more or less be glued to the ground?

          Comment


            I have some problems with friction. Its present in the latest compiled version that you have uploaded.
            Even if the contact-point says it is using static friction they still slide.
            Should not the static ones be static to the ground its on?

            Comment


              Originally posted by MagnusAnder View Post
              I have some problems with friction. Its present in the latest compiled version that you have uploaded.
              Even if the contact-point says it is using static friction they still slide.
              Should not the static ones be static to the ground its on?
              So the main reason why it slides is because this implementation of the friction is reactive, meaning it react to velocity and if there is no velocity there won't be any friction. The side effect of this is that object will start moving under influence of gravity and only after friction will react. This is why it slides.
              There are two ways I know of to fix this. One is to add a breakable physics constraint when vehicle stops and it will keep it from sliding. The other is to use [MENTION=179867]0lento[/MENTION]'s idea where a fix can be added to correct specifically for force of gravity. I haven't tried neither of them on the actual tank model and just on some primitives. I'll see if I can address this while rewriting friction code, which I'm busy with right now.
              So short answer is that this issue will be addressed at some point.
              Youtube Channel

              Comment


                Ok. thanks for the clarification. (and sorry for the double post )

                Comment


                  Originally posted by MagnusAnder View Post
                  Ok. thanks for the clarification. (and sorry for the double post )
                  No worries. I got it working partially with a physics constraint, unfortunately we can't set constraint as breakable from BP so I need to wrap it into a c++ component first.
                  Youtube Channel

                  Comment


                    Update

                    Added "static friction lock" functionality which prevents vehicle from sliding on slope. Tried couple of different approaches and one which spawns a breakable physics constraint finally works. I don't remember who exactly suggested it first, I think it was [MENTION=252207]Black Phoenix[/MENTION].
                    With generous help of [MENTION=179867]0lento[/MENTION] made a small function that allows to set physics constraint as breakable, programmatically from BP. For some reason setters are not exposed to BP and it wasn't trivial on how to apply new settings, just setting their values does nothing.

                    For now, most of the implementation is in BP and two vehicles have this feature: 4WheeledVehicle and LightTankTraceWheelsWithAnimBP (T-26 in the main level).
                    I'll use BP of tank highlight changes which where made:
                    Friction component's physics update now returns a boolean to indicate if static friction was achieved during calculations, while wheels/tracks weren't rotating. Points which achieved such state are counted.
                    Click image for larger version

Name:	StaticFrictionLock_01.PNG
Views:	1
Size:	100.4 KB
ID:	1124870

                    Then we check if all or more than 80% of all friction points have achieved such state and advance a simple timer to make sure that lock is not engaged immediately but takes a second or two:
                    Click image for larger version

Name:	StaticFrictionLock_02.PNG
Views:	1
Size:	206.6 KB
ID:	1124871

                    In case if not enough points achieved static state, like if user pressed on throttle and wheels started to spin, then we destroy constraint if it was already made:
                    Click image for larger version

Name:	StaticFrictionLock_03.PNG
Views:	1
Size:	218.3 KB
ID:	1124872

                    If we pass timer check then constraint can be made, but first we calculate a sum of all friction limits on points. Friction limit is a normal force multiplied by static friction coefficient, if more than this amount of force is applied to an object then object should start to move. So we need our locking constraint to be breakable and use total friction limit as breakable force threshold:
                    Click image for larger version

Name:	StaticFrictionLock_04.PNG
Views:	1
Size:	183.6 KB
ID:	1124873

                    When constraint is broken on PhysX level it gets deactivated but UE4 component stays alive. Which means we need to track OnConstraintBroken event and destroy component. For this reason, creation of constraint had to be moved into CustomEvent, so we can bind some logic to OnConstraintBroken.
                    New constraint component is added when CreateStaticLock custom event is called:
                    Click image for larger version

Name:	StaticFrictionLock_05.PNG
Views:	1
Size:	156.7 KB
ID:	1124874

                    Custom function is used to set constraint as breakable and logic to destroy constraint when it gets broken is added:
                    Click image for larger version

Name:	StaticFrictionLock_06.PNG
Views:	1
Size:	160.3 KB
ID:	1124875


                    The end result is rather simple, if you posses 4WheeledVehicle or LightTankTraceWheelsWithAnimBP, after enabling debug mode (Shift+Alt+D) you will see on-screen messages when lock is activated or destroyed:
                    Click image for larger version

Name:	StaticFrictionLock_07.PNG
Views:	1
Size:	555.1 KB
ID:	1124876

                    Applying larger enough force, as a result of colliding into vehicle, will automatically break constraint. In my tests, constraint was broken at the instant of collision so you don't even notice that constraint was even there.
                    In case of tank I had to set logic to check if 80% percent of friction points are in static case because with many wheels and not equal distribution of weight, some points can stay in kinematic case just because they don't support enough weight. Raising static friction coefficient can solve this too, but it has a direct effect on vehicle handling. In this case, lowering amount of contacts that need to be in static state is a better compromise.


                    Unrelated change - switched suspension of LightTankTraceWheelsWithAnimBP to use sweep shapes and it restored it mobility, it can drive over all obstacles again.


                    Latest version of MMT Content is on github and new version of MMT Plugin will be uploaded shortly.

                    [MENTION=140505]MagnusAnder[/MENTION] let me know how this fix works for you. It's quite possible that I've missed some test cases.
                    Last edited by BoredEngineer; 03-18-2017, 03:22 PM.
                    Youtube Channel

                    Comment


                      Update

                      Added new high-poly tread element for the light tank, to demonstrate new features of track animation:



                      - now treads are aligned properly to each other, previously you could see pins not matching on curves
                      - treads are now always aligned with sprocket teeth
                      - experimental track sway for selected parts of the track (only top part of the track is effected by sway)
                      - all treads are actually moving, so you can use material where each tread have a unique character to it:
                      Click image for larger version

Name:	TrackAnimation_treads_moving999.PNG
Views:	1
Size:	655.9 KB
ID:	1125791

                      - option to update treads rendering manually, for example if you want to use multiple tread elements instead of a single type of instance as on tanks in BF1:
                      https://i.ytimg.com/vi/ETN5MBvYkas/maxresdefault.jpg
                      each 4-th tread has a different shape than the rest

                      for this you can use this function:
                      Click image for larger version

Name:	TrackAnimation_Custom_rendering_part2.PNG
Views:	1
Size:	36.8 KB
ID:	1125786
                      which provides you array of transforms for all treads.

                      You can set name of Instanced Static Mesh component to 'none':
                      Click image for larger version

Name:	TrackAnimation_Custom_rendering_part1.PNG
Views:	1
Size:	29.2 KB
ID:	1125785
                      to avoid updating your ISM from inside of component.
                      Attached Files
                      Last edited by BoredEngineer; 03-30-2017, 01:53 PM.
                      Youtube Channel

                      Comment


                        I'll see how common type of track like this, made from multiple parts can be added:


                        (fixed image link)
                        Last edited by BoredEngineer; 03-31-2017, 10:12 AM.
                        Youtube Channel

                        Comment


                          Nice. I hope I can find some time to try it out Thanks

                          Comment


                            Update

                            Added new sprocket model that can supports two different types of tracks - single element tread and two elements tread:
                            Click image for larger version

Name:	TrackAnimation_NewSprocket.PNG
Views:	1
Size:	636.0 KB
ID:	1126379

                            Single element is "latched" by the lower curve and in two elements configuration the joining link is "latched" by two upper curves:
                            Click image for larger version

Name:	TrackAnimation_TwoPieceTrack.JPG
Views:	1
Size:	157.0 KB
ID:	1126384

                            The new two elements tread looks like this disassembled:
                            Click image for larger version

Name:	TrackAnimation_MultiParts.PNG
Views:	1
Size:	835.4 KB
ID:	1126385

                            New options in TrackAnimation component to support two elements treads:
                            Click image for larger version

Name:	TrackAnimation_MultiPartsAndLagCompensation.PNG
Views:	1
Size:	33.7 KB
ID:	1126386
                            First option enables lag compensation of skeletal mesh rotation animation. It simply updates tread instances with one frame lag so they match with skeletal mesh elements (sprocket in this case). This option is not needed if you use separate static mesh components to render sprockets.
                            Second set of options is configuration of secondary piece of the tread, including name of the additional ISM component to render secondary instances.

                            [EDIT]
                            My apologies to people with older PCs, some of the new meshes are very high-poly, this way it was faster to make them and have good visual latching of track elements.
                            This updated is already on github.

                            And latest executable can be accessed here:
                            http://www.dropbox.com/s/rb8mebjfleo...MT_Content.zip
                            Attached Files
                            Last edited by BoredEngineer; 04-12-2017, 06:00 PM.
                            Youtube Channel

                            Comment


                              Forgot to update plugin. It's synced now and latest version is on git-hub.
                              Youtube Channel

                              Comment


                                Update

                                Fixed an old bug - worthy of separate commit. Previously, track velocity wasn't properly projected on the contact surface, it was assumed to be parallel to the friction component X vector and projected to the contact surface later. This is wrong as in case of vertical obstacle in front of the tank, sprocket would press against it and normal of the contact surface would coincide with track velocity vector leaving almost 0 projected velocity to work with. In new implementation only speed (float value) instead of velocity (vector) is passed to friction component. Friction component assumes that at any point of contact, track is moving parallel to the contact surface and this provides a proper magnitude of track velocity to work with. This fix enables tanks to properly scale vertical obstacles as you can see from video. I've recorded new sprocket and tracks in action too:
                                Youtube Channel

                                Comment

                                Working...
                                X