Skip to content

Commit

Permalink
Take into consideration the elevation of the level
Browse files Browse the repository at this point in the history
Each piece of furniture in SH3D has it's position in 3D space including
its elevation. That the elevation is relative to the floor of the level
it's placed in.
When calculating the 2D-projected location of an entity we observe the
building in 3D space with all of its levels so it wasn't enough to use
the relative elevation of the entity but we need to offset it with the
elevation of the entire floor.

Fixes #82, for real (I hope)
  • Loading branch information
shmuelzon committed Oct 5, 2024
1 parent 6399f97 commit 91e2af3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/com/shmuelzon/HomeAssistantFloorPlan/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,8 @@ private void _getCombinations(List<String> inputList, int currentIndex, List<Str
}

private Point2d getFurniture2dLocation(HomePieceOfFurniture piece) {
Vector4d objectPosition = new Vector4d(piece.getX(), ((piece.getElevation() * 2) + piece.getHeight()) / 2, piece.getY(), 0);
float levelOffset = piece.getLevel() != null ? piece.getLevel().getElevation() : 0;
Vector4d objectPosition = new Vector4d(piece.getX(), (((piece.getElevation() * 2) + piece.getHeight()) / 2) + levelOffset, piece.getY(), 0);

objectPosition.sub(cameraPosition);
perspectiveTransform.transform(objectPosition);
Expand Down

0 comments on commit 91e2af3

Please sign in to comment.