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

Tracked Locations on Crafts #616

Merged
merged 14 commits into from
Jul 28, 2024
Merged

Tracked Locations on Crafts #616

merged 14 commits into from
Jul 28, 2024

Conversation

goodroach
Copy link
Contributor

Adds TrackedLocations and allows crafts to track locations within or relative to itself.

Checklist

  • Unit tests
  • Proper internationalization
  • Tested

@goodroach
Copy link
Contributor Author

I've done the requested changes, will this work?

Comment on lines 34 to 54
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()
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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?

Copy link
Contributor

@TylerS1066 TylerS1066 left a 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.

@TylerS1066
Copy link
Contributor

I thought it looked good, but it doesn't appear to build. Not sure why

Copy link
Contributor

@TylerS1066 TylerS1066 left a 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.

@TylerS1066 TylerS1066 mentioned this pull request Jul 21, 2024
3 tasks
@TylerS1066 TylerS1066 merged commit 6085cc5 into APDevTeam:main Jul 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants