-
Notifications
You must be signed in to change notification settings - Fork 50
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
SPS: Enforce a minimum distance from plug to ring #166
base: main
Are you sure you want to change the base?
Conversation
0a69e2c
to
cc061e2
Compare
|
||
// Consider plane aligned to orifice | ||
const float orfPerpDistance = dot(sps_normalize(-frontNormal), rootPos); | ||
float shiftLerp = (orfPerpDistance > minDistance) | (orfPerpDistance < -worldLength * hiltedSphereRadius) ? 0 : 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ambiguous order of operations. Add parens and use || rather than | (although ultimately it probably results in the same machine code)
const float lerpDistance = minDistance; | ||
|
||
// Consider plane aligned to orifice | ||
const float orfPerpDistance = dot(sps_normalize(-frontNormal), rootPos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this beneficial vs just using orfDistance directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was done for hypothetical hilted/uni-directional rings.
If we use orfDistance directly, we could end-up lerping out the min distance logic if the socket goes behind the plug, causing the plug to suddenly pull back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float shiftLerp = (orfPerpDistance > minDistance) | (orfPerpDistance < -worldLength * hiltedSphereRadius) ? 0 : 1; | ||
|
||
const float shiftAmount = (minDistance - orfPerpDistance); | ||
const float3 shiftedRoot = rootPos - sps_normalize(frontNormal) * shiftAmount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this arbitrarily just moves the socket backward, in respect to the direction it is facing, which I also don't think is correct in this scenario
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was based on your suggestion to "pretend" the rings are a bit forward.
Where you thinking of a different method when you suggested that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shiftLerp *= sps_saturated_map(orfPlaneDistance, minDistance + lerpDistance, minDistance); | ||
|
||
rootPos = lerp(rootPos, shiftedRoot, shiftLerp); | ||
orfDistance = length(rootPos); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the ultimate goal? DPS's proximity solver is... not great, so I'm reluctant to take much inspiration from it at all. Much of DPS's logic feels very much like a "throw things at the wall and see what works", while I think we can do better by defining how the behavior should actually work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you referring to this section of code? or the whole PR in general?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ultimate goal was to avoid the sudden rotations in the plug under lateral movements as it gets close to the socket
Ideally I think this should be handled directly in the solver algorithm, however, I was unable to do so.
cc061e2
to
d0e94db
Compare
d0e94db
to
e58a655
Compare
Returning to elaborate on my responses I haven't really battle tested this as much as I wanted to, I ended up switching back to DPS full time I think due to hilted range being reduced |
e58a655
to
ca946ac
Compare
Aims to reduce the undesired roll when the ring is too close to base of the penetrator.
One of the goals I had was to ensure that hypothetical hilted rings would behave correctly, while having a minimum distance smaller than the hilted distance.
With that in mind, I wanted to avoid a potential issue of a ring swinging under the minimum distance, and popping though.
DPS appears to consider a plane aligned to the base of the penetrator
I decided to take inspiration from this, and consider a plane with the same orientation as the orifice to impose a minimum distance against.
This approach is quite affective at reducing roll where the orifice is nearly aligned with the plug, but loses effectiveness as the orientation of the orifice approaches 90d.