Skip to content
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

Piston engine sliders are pasted with with constraint up/down instead of desired degree angle #306

Closed
dvdvideo1234 opened this issue Sep 17, 2020 · 19 comments
Labels

Comments

@dvdvideo1234
Copy link
Contributor

20200917213049_1

@dvdvideo1234
Copy link
Contributor Author

dvdvideo1234 commented Sep 17, 2020

  1. Literally all of my prop engines are affected by this bug. Here is the duplication:
    w16_roxx.txt . It is possible this can be related to this one , but in the latter, constraints to the prop-world are considered, instead of prop-prop.

  2. The ghosted contraption is not affected by the checkbox Use World Angles, only the spawned contraption is affected.

@thegrb93
Copy link
Contributor

thegrb93 commented Sep 25, 2020

I may look at this and related issue this weekend

@dvdvideo1234
Copy link
Contributor Author

@thegrb93 Oke..Tell me if I can help somehow ..

@dvdvideo1234
Copy link
Contributor Author

dvdvideo1234 commented Oct 15, 2020

Ok... Modded the sv_clipboard.txt as:

  1. Removed the continue statement ( Yep, there was one )
        for k, v in pairs(Ent.Constraints) do
          -- Filter duplicator blocked constraints out.
          if not v.DoNotDuplicate then index = v:GetCreationID()
            if (index and not Constraints[index]) then Constraints[index] = v end
          end
        end
  1. Formatted the syntax
  2. Added ENT:IsWorld() checks in some cases when rotation is made ( no difference )
  3. Added default material value to sliders as the factory accepts string ( no difference either )
    if(Constraint.Type:lower() == "slider" and Key == "material") then
      Val = Val or "cable/cable"
    else
      Val = Val or false
    end
  1. Added printouts for the sliders as apparently they are the only ones failing here ( at least in my case )

What I received is quite interesting as every time the tool requests from GMod to create slider, an internal check is triggered, which defaults the arguments to a SANE manner:

CreateConstraint: Slider
[1]<Ent1> = [Entity]<Entity [110][gmod_wire_thruster]>{Entity [110][gmod_wire_thruster]}
[2]<Ent2> = [Entity]<Entity [113][prop_physics]>{Entity [113][prop_physics]}
[3]<Bone1> = [number]<0>{0}
[4]<Bone2> = [number]<0>{0}
[5]<LPos1> = [Vector]<-0.009991 0.002121 2.282107>{-0.009991 0.002121 2.282107}
[6]<LPos2> = [Vector]<0.001543 -18.000153 -6.999977>{0.001543 -18.000153 -6.999977}
[7]<width> = [number]<1>{1}
[8]<material> = [string]<cable/cable>{nil}
Create slider request
GMOD: Forcing sane values for slider constraint!
Create slider constraint: Entity [0][phys_slideconstraint]

Every time this GMOD: Forcing sane values for slider constraint! is shown the bug is triggered. No exception!
It seems like when it moves it away it does something to it when the slider is created.

@dvdvideo1234
Copy link
Contributor Author

dvdvideo1234 commented Oct 15, 2020

Thiggers this ( Source: Discord GMOD forum ) and i seems it is a gmod slider protection or something:
msg

@dvdvideo1234
Copy link
Contributor Author

dvdvideo1234 commented Oct 15, 2020

Merged here: Facepunch/garrysmod-issues#4631 Slider lengths from the discord thread. The possible solution for really checking the slider length is by using world coordinates.

local WPos1 = Ent1:LocalToWorld(LPos1)
local WPos2 = Ent2:LocalToWorld(LPos2)

if((WPos1 - WPos2):LengthSqr() < 1) then .....

Pretty sure that the length is not zero:

CreateConstraint: Slider
[1]<Ent1> = [Entity]<Entity [69][gmod_wire_thruster]>{Entity [69][gmod_wire_thruster]}
[2]<Ent2> = [Entity]<Entity [66][prop_physics]>{Entity [66][prop_physics]}
[3]<Bone1> = [number]<0>{0}
[4]<Bone2> = [number]<0>{0}
[5]<LPos1> = [Vector]<-0.009991 0.002121 2.282107>{-0.009991 0.002121 2.282107}
LEN: 5.2081161168704
[6]<LPos2> = [Vector]<0.000514 -5.999893 -6.999992>{0.000514 -5.999893 -6.999992}
LEN: 84.998611726345
[7]<width> = [number]<1>{1}
[8]<material> = [string]<cable/cable>{nil}
Ent1Ang	=	45.000 90.000 0.000
Ent2Ang	=	0.000 90.000 0.000
EntityPos	=	6.002121 10.255859 3.236801
Create slider request
[1]E: Entity [69][gmod_wire_thruster],Entity [69][gmod_wire_thruster]
[1]P: -183.668045 -76.585129 -9979.854492
[1]A: 45.000 90.000 0.000
[1]L: -0.009991 0.002121 2.282107
[2]E: Entity [66][prop_physics],Entity [66][prop_physics]
[2]P: -189.670166 -86.840988 -9983.090820
[2]A: 0.000 90.000 0.000
[2]L: 0.000514 -5.999893 -6.999992
WLEN:281.30494295392
LLEN:122.18164192589
GMOD: Forcing sane values for slider constraint!
Create slider constraint: Entity [0][phys_slideconstraint]
After slider
[1]P: -183.668045 -76.585129 -9979.854492
[1]A: 45.000 90.000 0.000
[2]P: -189.670166 -86.840988 -9983.090820
[2]A: 0.000 90.000 0.000

@dvdvideo1234
Copy link
Contributor Author

Debugging code:

  if(Constraint.Type:lower() == "slider") then
    print("Create slider request")
    print("[1]E: "..tostring(first)..","..tostring(Args[1]))
    print("[1]P: "..tostring(first:GetPos()))
    print("[1]A: "..tostring(first:GetAngles()))
    print("[1]L: "..tostring(Args[5]))

    print("[2]E: "..tostring(second)..","..tostring(Args[2]))
    print("[2]P: "..tostring(second:GetPos()))
    print("[2]A: "..tostring(second:GetAngles()))
    print("[2]L: "..tostring(Args[6]))

    local WPos1 = Args[1]:LocalToWorld(Vector(Args[5]))
    local WPos2 = Args[2]:LocalToWorld(Vector(Args[6]))
    print("WLEN:"..tostring((WPos1 - WPos2):LengthSqr()))
    print("LLEN:"..tostring((Args[5] - Args[6]):LengthSqr()))
  end

@dvdvideo1234
Copy link
Contributor Author

dvdvideo1234 commented Oct 15, 2020

The new sv_clipboard sv_clipboard.txt

@thegrb93
Copy link
Contributor

Could you pull request your changes? It would be cleaner and easier to review that way.

@robotboy655
Copy link

Test Dev branch in an hour or so and @ me if it's fixed or not.

@dvdvideo1234
Copy link
Contributor Author

@thegrb93 @robotboy655
Hello, Done: #316

@thegrb93
Copy link
Contributor

Just the specific changes, not the code style corrections please.

@thegrb93
Copy link
Contributor

Keep code style corrections to their own PR.

@dvdvideo1234
Copy link
Contributor Author

dvdvideo1234 commented Oct 15, 2020

@thegrb93 This is intended for debugging purposes only. Do you mean you want to review and merge the PR.. ?

If so I can easily change it ;)

@thegrb93
Copy link
Contributor

Ah ok, I didn't know it was just debug. Maybe separate the debug changes from the code style changes and have them as two PRs. That way you can have code style changes merged and we can actually see the debug stuff.

@dvdvideo1234
Copy link
Contributor Author

@thegrb93 I will commit another mod, so to remove the debug prints and you can easily switch between them.
Here is a version with removed Diff: https://github.com/wiremod/advdupe2/pull/316/files#diff-acb623eeeb53481b1e82274b16a2d0d4413abd6b7cf5f0b67f18950f566bdf54&?w=1

@dvdvideo1234
Copy link
Contributor Author

@thegrb93 This now fixed by @Rubat on the pre-release branch of GMOD. Cheers. You can merge the file if you like. I am closing this.

@thegrb93
Copy link
Contributor

Kk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants