-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
Tracked Locations on Crafts #616
Conversation
add trackedlocations
...es/Movecraft/src/main/java/net/countercraft/movecraft/async/translation/TranslationTask.java
Outdated
Show resolved
Hide resolved
modules/Movecraft/src/main/java/net/countercraft/movecraft/async/rotation/RotationTask.java
Outdated
Show resolved
Hide resolved
modules/Movecraft/src/main/java/net/countercraft/movecraft/craft/BaseCraft.java
Outdated
Show resolved
Hide resolved
modules/api/src/main/java/net/countercraft/movecraft/TrackedLocation.java
Outdated
Show resolved
Hide resolved
modules/api/src/main/java/net/countercraft/movecraft/TrackedLocation.java
Outdated
Show resolved
Hide resolved
modules/api/src/main/java/net/countercraft/movecraft/TrackedLocation.java
Outdated
Show resolved
Hide resolved
modules/api/src/main/java/net/countercraft/movecraft/TrackedLocation.java
Outdated
Show resolved
Hide resolved
reimplement TrackedLocation to specification
I've done the requested changes, will this work? |
modules/api/src/main/java/net/countercraft/movecraft/TrackedLocation.java
Outdated
Show resolved
Hide resolved
MovecraftLocation offSetToPivot = new MovecraftLocation( | ||
getAbsoluteLocation().getX() - pivot.getX(), | ||
getAbsoluteLocation().getY() - pivot.getY(), | ||
getAbsoluteLocation().getZ() - pivot.getZ() | ||
); | ||
//This is the position vector relative to the midpoint to the pivot. | ||
MovecraftLocation midPoint = craft.getHitBox().getMidPoint(); | ||
MovecraftLocation midPointToPivot = new MovecraftLocation( | ||
midPoint.getX() - pivot.getX(), | ||
midPoint.getY() - pivot.getY(), | ||
midPoint.getZ() - pivot.getZ() | ||
); | ||
//Rotates both vectors | ||
MovecraftLocation rotatedOffSetToPivot = MathUtils.rotateVec(rotation, offSetToPivot); | ||
MovecraftLocation rotatedMidPointToPivot = MathUtils.rotateVec(rotation, midPointToPivot); | ||
//Subtracts rotatedOffSetToPivot - rotatedMidPointToPivot to get the new offset to the midpoint. | ||
offSet = new MovecraftLocation( | ||
rotatedOffSetToPivot.getX() - rotatedMidPointToPivot.getX(), | ||
rotatedOffSetToPivot.getY() - rotatedMidPointToPivot.getY(), | ||
rotatedOffSetToPivot.getZ() - rotatedMidPointToPivot.getZ() | ||
); |
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.
Check how rotation does this, there's a utility function to do all this:
https://github.com/APDevTeam/Movecraft/blob/main/modules/Movecraft/src/main/java/net/countercraft/movecraft/async/rotation/RotationTask.java#L117
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.
I wonder, if a turret were to rotate in the craft, would the craft be able to track that as well? Or is that not worth going for right now?
modules/api/src/main/java/net/countercraft/movecraft/TrackedLocation.java
Outdated
Show resolved
Hide resolved
use built-in methods for vector manipulation
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 looks good to me, however I think we need to think about parent crafts a bit.
For rotation we should probably check parent crafts (recursively) for tracked locations and rotate them as well. That way if say a parent craft is tracking a location, which is subcraft rotated, it will continue to be correctly tracked.
I thought it looked good, but it doesn't appear to build. Not sure why |
Resolve merge
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.
In addition to the comment below, we should resolve the parent craft issue. The best way to tackle that is probably to do a do-while loop checking if the craft is a subcraft, and if so get it's parent and rotate any tracked locations within the hitbox of the subcraft.
Adds TrackedLocations and allows crafts to track locations within or relative to itself.
Checklist