112 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			112 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package electrosphere.collision;
 | |
| 
 | |
| import electrosphere.client.scene.ClientWorldData;
 | |
| import electrosphere.client.terrain.manager.ClientTerrainManager;
 | |
| import electrosphere.game.server.world.ServerWorldData;
 | |
| import electrosphere.server.terrain.manager.ServerTerrainManager;
 | |
| 
 | |
| import org.joml.Vector3d;
 | |
| import org.joml.Vector3f;
 | |
| 
 | |
| public class CollisionWorldData {
 | |
|     
 | |
|     
 | |
|     
 | |
|     ClientWorldData clientWorldData;
 | |
|     ClientTerrainManager clientTerrainManager;
 | |
|     
 | |
|     
 | |
|     
 | |
|     ServerWorldData serverWorldData;
 | |
|     ServerTerrainManager serverTerrainManager;
 | |
|     
 | |
|     public CollisionWorldData(ServerWorldData serverWorldData){
 | |
|         this.serverWorldData = serverWorldData;
 | |
|     }
 | |
| 
 | |
|     public CollisionWorldData(ClientWorldData clientWorldData){
 | |
|         this.clientWorldData = clientWorldData;
 | |
|     }
 | |
|     
 | |
|     
 | |
|     /**
 | |
|      * IF SERVER, RETURN HEIGHT
 | |
|      * IF CLIENT:
 | |
|      *      IF HAS DATA,
 | |
|      *          RETURN HEIGHT
 | |
|      *      IF DOES NOT HAVE DATA,
 | |
|      *          RETURN 0
 | |
|      * @param position
 | |
|      * @return 
 | |
|      */
 | |
|     // public double getElevationAtPoint(Vector3d position){
 | |
|     //     if(clientWorldData != null){
 | |
|     //         if(clientTerrainManager.containsHeightmapAtRealPoint(position.x, position.z)){
 | |
|     //             return clientTerrainManager.getHeightAtPosition(position.x, position.z);
 | |
|     //         } else {
 | |
|     //             return 0;
 | |
|     //         }
 | |
|     //     } else {
 | |
|     //         return serverTerrainManager.getHeightAtPosition(position.x, position.z);
 | |
|     //     }
 | |
|     // }
 | |
|     
 | |
|     
 | |
|     public Vector3f getWorldBoundMin(){
 | |
|         if(clientWorldData != null){
 | |
|             return clientWorldData.getWorldBoundMin();
 | |
|         } else {
 | |
|             return serverWorldData.getWorldBoundMin();
 | |
|         }
 | |
|     }
 | |
|     
 | |
|     public Vector3f getWorldBoundMax(){
 | |
|         if(clientWorldData != null){
 | |
|             return clientWorldData.getWorldBoundMax();
 | |
|         } else {
 | |
|             return serverWorldData.getWorldBoundMax();
 | |
|         }
 | |
|     }
 | |
|     
 | |
|     public int convertRealToWorld(double real){
 | |
|         if(clientWorldData != null){
 | |
|             return clientWorldData.convertRealToChunkSpace(real);
 | |
|         } else {
 | |
|             return serverWorldData.convertRealToChunkSpace(real);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public double convertWorldToReal(int world){
 | |
|         if(clientWorldData != null){
 | |
|             return clientWorldData.convertChunkToRealSpace(world);
 | |
|         } else {
 | |
|             return serverWorldData.convertChunkToRealSpace(world);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public int getDynamicInterpolationRatio(){
 | |
|         if(clientWorldData != null){
 | |
|             return clientWorldData.getDynamicInterpolationRatio();
 | |
|         } else {
 | |
|             return serverWorldData.getDynamicInterpolationRatio();
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public int getWorldDiscreteSize(){
 | |
|         if(clientWorldData != null){
 | |
|             return clientWorldData.getWorldDiscreteSize();
 | |
|         } else {
 | |
|             return serverWorldData.getWorldSizeDiscrete();
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public float getRandomDampener(){
 | |
|         if(clientWorldData != null){
 | |
|             return clientWorldData.getRandomDampener();
 | |
|         } else {
 | |
|             return serverWorldData.getRandomDampener();
 | |
|         }
 | |
|     }
 | |
| 
 | |
| }
 |