forked from MagicBane/Server
Only one kind of zone.
This commit is contained in:
@@ -277,24 +277,24 @@ public enum ZoneManager {
|
|||||||
// Converts world coordinates to coordinates local to a given zone.
|
// Converts world coordinates to coordinates local to a given zone.
|
||||||
|
|
||||||
public static Vector3fImmutable worldToLocal(Vector3fImmutable worldVector,
|
public static Vector3fImmutable worldToLocal(Vector3fImmutable worldVector,
|
||||||
Zone serverZone) {
|
Zone zone) {
|
||||||
|
|
||||||
Vector3fImmutable localCoords;
|
Vector3fImmutable localCoords;
|
||||||
|
|
||||||
localCoords = new Vector3fImmutable(worldVector.x - serverZone.absX,
|
localCoords = new Vector3fImmutable(worldVector.x - zone.absX,
|
||||||
worldVector.y - serverZone.absY, worldVector.z
|
worldVector.y - zone.absY, worldVector.z
|
||||||
- serverZone.absZ);
|
- zone.absZ);
|
||||||
|
|
||||||
return localCoords;
|
return localCoords;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2f worldToZoneOffset(Vector3fImmutable worldLoc,
|
public static Vector2f worldToZoneOffset(Vector3fImmutable worldLoc,
|
||||||
Zone serverZone) {
|
Zone zone) {
|
||||||
|
|
||||||
Vector2f localCoords;
|
Vector2f localCoords;
|
||||||
Vector2f zoneOrigin;
|
Vector2f zoneOrigin;
|
||||||
|
|
||||||
zoneOrigin = new Vector2f(serverZone.getLoc().x, serverZone.getLoc().z);
|
zoneOrigin = new Vector2f(zone.getLoc().x, zone.getLoc().z);
|
||||||
localCoords = new Vector2f(worldLoc.x, worldLoc.z);
|
localCoords = new Vector2f(worldLoc.x, worldLoc.z);
|
||||||
localCoords = localCoords.subtract(zoneOrigin);
|
localCoords = localCoords.subtract(zoneOrigin);
|
||||||
|
|
||||||
@@ -303,15 +303,15 @@ public enum ZoneManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2f worldToTerrainSpace(Vector3fImmutable worldLoc,
|
public static Vector2f worldToTerrainSpace(Vector3fImmutable worldLoc,
|
||||||
Zone serverZone) {
|
Zone zone) {
|
||||||
|
|
||||||
Vector2f localCoords;
|
Vector2f localCoords;
|
||||||
Vector2f zoneOrigin;
|
Vector2f zoneOrigin;
|
||||||
|
|
||||||
// Top left corner of zone is calculated in world space by the center and it's extents.
|
// Top left corner of zone is calculated in world space by the center and it's extents.
|
||||||
|
|
||||||
zoneOrigin = new Vector2f(serverZone.getLoc().x, serverZone.getLoc().z);
|
zoneOrigin = new Vector2f(zone.getLoc().x, zone.getLoc().z);
|
||||||
zoneOrigin = zoneOrigin.subtract(new Vector2f(serverZone.bounds.getHalfExtents().x, serverZone.bounds.getHalfExtents().y));
|
zoneOrigin = zoneOrigin.subtract(new Vector2f(zone.bounds.getHalfExtents().x, zone.bounds.getHalfExtents().y));
|
||||||
|
|
||||||
// Local coordinate in world space translated to an offset from the calculated zone origin.
|
// Local coordinate in world space translated to an offset from the calculated zone origin.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user