-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix saggy constraints #50
Comments
What's the fundamental issue causing saggy constraints - are things being physically simulated before the constraints are made and so they move due to gravity? Is the constraint solver moving things when some but not all of the constraints have been added? Would it work to weld everything to a |
If you take 10 props in a line and weld them one to the other, and then lift the whole thing up with the physgun, you're going to get massive sags. If you then dupe this saggy line of props with duplicator or adv duplicator, and paste it, the constraints will be created while the props are in these weird positions. This means that if you now lift it up again, it'll have as much leeway to sag as earlier, meaning they'll sag even more. This is the cause of saggy constraints and this is what adv dupe 2 fixes by memorizing the original positions of everything. (This problem also applies to less obvious situations) |
Ah, we lose all the 'potential energy' in the constraints. I bet we could override (We could then totally get that into vanilla GMod, and make Garrydupe awesome.) |
I worry that the later use of Constraint:SetTable(small ctable) would override anything we try to store in the constraints themselves. Something like that might work though yes. |
You know what is funny about saggy constraints? A long time ago, the work around was to rope everything. After pasting and removing the ropes, there were no sags, no matter how many dupes you made. I still do not know why that worked. But it did. |
I'm not sure I fully comprehend the problem anymore. I've spent hours fiddling at it, I can get it so 5 generations later, a pasted slinky (40 stacked plates) looks awful (some gaps are way larger), but upon freezing each component individually it looks perfect again. So the welds are being made in the right place.... they just sag. |
I wonder... Try doing that in 0 gravity. I wonder if duplicator is also saving the gravity forces acting on the contraptions and it's cumulating. |
It's the same with 0 gravity. |
Again, does duping with ropes still work? |
Works perfectly 👍 |
So, now we need to dig in and understand how ropes interact with the physics of duping. What happens if you change the weight of duped objects? If you were to zero out the weight on dupe, then after paste it puts the weight back, rinse and repeat, does it still cause problems then? |
No the weight does not work, and um I tried the ropes again and it somehow did not work this time, I'm sure I did everything in the same way as before, it'll be better if someone else confirm this too. |
You have to put the ropes on, dupe, paste, then remove the ropes. |
Just for further research in bettering this issue. I didn't have any benefit with the ropes, but with out replicating positions when it was constrained, it will still degrade. If you constrained the 10 props, froze 1 end and curved the other end around and froze it, when you duplicate it, it will be replicated very distorted. Since AD2 saves positions when constrained, it will not be distorted after replication. So, without saving positions if you try and lock and freeze your 100 prop contraption it may move slightly over time of copying and wouldn't perform the same; and also have to do the hassle of locking and freezing. It could probably go a step further and try and spawn the entities and constraints in in the order they were spawned into the game to try and get closer to matching their stepping calculations in the physics engine from the original creation. |
Yea, if constraints are ordered randomly then the contraption will spawn with random constraint systems and won't be a single solid constraint system. Advdupe2 orders them. |
-- Me, versus the unwashed masses
Okay, so advdupe2's solution was to hook into OnEntityCreated, and save the local positions of all physics objects involved in the constraint into the constraint itself. When pasting, it simply moves the physics objects to their original locations when the constraint was first made, pastes the constraint, then moves them back. It may seem a bit hacky, and its not 100% effective in all cases, but its a whole lot better than what we do now with regards to constraints.
I don't know if TB can copyright the basic idea of the above paragraph, as obviously copypasting his exact code isn't applicable, but we need to do something like it.
Advdupe2:
Save initial constraint positions line 18
Hook into OnEntityCreated to call the above function line 72
Inside PasteConstraint, before running the factory function, move ents into place line 519
Inside PasteConstraint, after running factory function line 569
The text was updated successfully, but these errors were encountered: