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

feat(JOML): migrate joml for BlockRegion #4

Merged
merged 5 commits into from
Dec 9, 2020

Conversation

jdrueckert
Copy link
Member

@@ -131,7 +132,7 @@ public void placeDoor(ActivateEvent event, EntityRef entity) {
if (!blockEvent.isConsumed()) {
EntityRef newDoor = entityManager.create(door.doorRegionPrefab);
entity.removeComponent(MeshComponent.class);
newDoor.addComponent(new BlockRegionComponent(Region3i.createBounded(bottomBlockPos, topBlockPos)));
newDoor.addComponent(new BlockRegionComponent(new BlockRegion().union(JomlUtil.from(bottomBlockPos)).union(JomlUtil.from(topBlockPos))));
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll introduce BlockRegions.encompassing(...) which could be used here.

Comment on lines 196 to 199
Block bottomBlock = door.bottomBlockFamily.getBlockForPlacement(new BlockPlacementData(regionComp.region.getMin(new org.joml.Vector3i()), newSide, new org.joml.Vector3f(Side.TOP.direction())));
worldProvider.setBlock(regionComp.region.getMin(new org.joml.Vector3i()), bottomBlock);
Block topBlock = door.topBlockFamily.getBlockForPlacement(new BlockPlacementData(regionComp.region.getMax(new org.joml.Vector3i()), newSide, new org.joml.Vector3f(Side.TOP.direction())));
worldProvider.setBlock(regionComp.region.getMax(new org.joml.Vector3i()), topBlock);
Copy link
Contributor

Choose a reason for hiding this comment

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

We're basically creating the same immutable vectors twice here 🤔 I think this should be joml-ified by making better use of vector allocation

Copy link
Member Author

@jdrueckert jdrueckert left a comment

Choose a reason for hiding this comment

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

Looks reasonable. Would approve if I could (PR creator and stuff).

@jdrueckert jdrueckert merged commit d566327 into develop Dec 9, 2020
@jdrueckert jdrueckert deleted the feature/joml-migrate-blockregion branch December 9, 2020 17:48
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.

3 participants