Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasBaumgartinger committed Aug 28, 2019
2 parents 36bdad5 + 9ac7fa3 commit ae6c6c4
Show file tree
Hide file tree
Showing 19 changed files with 80 additions and 54 deletions.
2 changes: 1 addition & 1 deletion Assets/PhotovoltaicPlant/LargePVPlant.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[ext_resource path="res://Assets/Superclasses/MovableObject.tscn" type="PackedScene" id=1]
[ext_resource path="res://Assets/Util/PVMesh.tscn" type="PackedScene" id=2]
[ext_resource path="res://Util/Tooltip3D.tscn" type="PackedScene" id=3]
[ext_resource path="res://Resources/Images/UI/MapIcons/windmill_icon.png" type="Texture" id=4]
[ext_resource path="res://Resources/Images/UI/MapIcons/pv_icon.png" type="Texture" id=4]
[ext_resource path="res://Perspectives/PC/Minimap/MinimapIcon.tscn" type="PackedScene" id=5]

[sub_resource type="BoxShape" id=1]
Expand Down
4 changes: 2 additions & 2 deletions Assets/PhotovoltaicPlant/SmallPVPlant.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[ext_resource path="res://Assets/Superclasses/MovableObject.tscn" type="PackedScene" id=1]
[ext_resource path="res://Util/Tooltip3D.tscn" type="PackedScene" id=2]
[ext_resource path="res://Resources/Images/UI/MapIcons/windmill_icon.png" type="Texture" id=3]
[ext_resource path="res://Resources/Images/UI/MapIcons/pv_icon.png" type="Texture" id=3]
[ext_resource path="res://Assets/Util/PVMesh.tscn" type="PackedScene" id=4]
[ext_resource path="res://Perspectives/PC/Minimap/MinimapIcon.tscn" type="PackedScene" id=5]

Expand All @@ -13,7 +13,7 @@ height = 7.1452
[sub_resource type="BoxShape" id=2]
extents = Vector3( 1.65553, 0.0370111, 4.13087 )

[node name="PV" instance=ExtResource( 1 )]
[node name="PV" index="0" instance=ExtResource( 1 )]

[node name="Tooltip3D" parent="." index="0" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 10, 0 )
Expand Down
3 changes: 3 additions & 0 deletions Global/GlobalSignal.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ signal missing_map
signal missing_3rd
signal missing_1st

# Perspective handling
signal main_perspective_active(is_active)

# signal the ui to show the miniview again
signal miniview_show

Expand Down
1 change: 1 addition & 0 deletions Global/PlayerInfo.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var last_player_pos = Vector3(0, 0, 0)
var last_player_look_direction = Vector3(0, 0, 0)

var is_follow_enabled: bool = true
var is_main_active: bool = false

var walk_speed: float = 10

Expand Down
2 changes: 1 addition & 1 deletion Global/ServerConnection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Connection:
return null

if not _http.get_response_code() < 400:
logger.warn("HTTP client: got %s as http status which indicates missing data or a bug in the request url: %s" % [_http.get_response_code(), url])
logger.warning("HTTP client: got %s as http status which indicates missing data or a bug in the request url: %s" % [_http.get_response_code(), url])
return null

var response_headers = _get_response_headers() # FIXME: currently never used
Expand Down
2 changes: 1 addition & 1 deletion Materials/Shaders/HeightmapMesh.shader
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void vertex() {
VERTEX.y = get_height(UV);

if (int(texture(splat, get_relative_pos(UV)).r * 255.0) == water_splat_id) {
VERTEX.y -= 50.0; // TODO: This will become deprecated once water is precalculated into the heightmap!
VERTEX.y -= 2.0; // TODO: This will become deprecated once water is precalculated into the heightmap!
}

// Calculate the engine position of this vertex
Expand Down
2 changes: 1 addition & 1 deletion Materials/Shaders/VegetationShader.shader
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ uniform float distribution_pixels_per_meter;

uniform float base_light = 0.5; // Base value which vegetation is lit by any light, regardless of diretion
uniform float light_factor = 2.0; // Changes how much of an effect lighting has
uniform float opacity_cutoff = 0.75; // Opacity starts decreasing at uv.y > opacity_cutoff
uniform float opacity_cutoff = 0.9; // Opacity starts decreasing at uv.y > opacity_cutoff
uniform float max_opacity_cutoff_scale = 1.0; // Maximum scale (in meters) of plants where the opacity cutoff occurs

uniform vec3 pos;
Expand Down
13 changes: 12 additions & 1 deletion Perspectives/AbstractPlayer/AbstractPlayer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ var mouse_sensitivity = Settings.get_setting("player", "mouse-sensitivity")

func _ready():
Offset.connect("shift_world", self, "shift")

if is_main_perspective:
PlayerInfo.is_main_active = true


# This is a function that can handle notification, we will use it for "destructor"-purposes
func _notification(what):
if what == NOTIFICATION_PREDELETE:
if is_main_perspective:
PlayerInfo.is_main_active = false


func _physics_process(delta):
Expand Down Expand Up @@ -88,7 +98,8 @@ func _handle_general_input(event):

# Shift the player's in-engine translation by a certain offset, but not the player's true coordinates.
func shift(delta_x, delta_z):
PlayerInfo.add_player_pos(Vector3(delta_x, 0, delta_z))
if is_main_perspective or not PlayerInfo.is_main_active:
PlayerInfo.add_player_pos(Vector3(delta_x, 0, delta_z))

translation.x += delta_x
translation.z += delta_z
2 changes: 1 addition & 1 deletion Perspectives/PC/FirstPersonPC.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ icon = ExtResource( 5 )
rotate = true

[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 1.77636e-15, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 1.65595, 0 )
transform = Transform( 1, 0, 1.77636e-015, 0, -4.37114e-008, -1, 0, 1, -4.37114e-008, 0, 1.65595, 0 )
shape = SubResource( 1 )
disabled = true
10 changes: 6 additions & 4 deletions Perspectives/PerspectiveHandler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ func toggle_mouse_capture():
func toggle_vr(enabled):
vr_activated = enabled

for child in vr_viewport.get_children():
child.free()

if vr_activated:
vr_viewport.add_child(first_person_vr_scene.instance())
change_pc_mini_scene(first_person_vr_scene)
pc_mini_viewport.arvr = true
pc_mini_viewport.hdr = false
else:
pc_mini_viewport.arvr = false
pc_mini_viewport.hdr = true


# change the scene of the miniview to given scene
Expand Down
10 changes: 1 addition & 9 deletions Perspectives/PerspectiveHandler.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,10 @@ script = ExtResource( 2 )

[node name="MainUI" parent="ViewportContainer" instance=ExtResource( 3 )]

[node name="VRViewport" type="Viewport" parent="ViewportContainer"]
arvr = true
size = Vector2( 1920, 1080 )
handle_input_locally = false
msaa = 4
hdr = false
render_target_update_mode = 3
shadow_atlas_size = 64

[node name="PCViewport" type="Viewport" parent="ViewportContainer"]
size = Vector2( 1920, 1080 )
handle_input_locally = false
msaa = 4
render_target_update_mode = 3
shadow_atlas_size = 64
script = ExtResource( 4 )
Expand Down
5 changes: 5 additions & 0 deletions Perspectives/VR/ARVROrigin.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends ARVROrigin

func _process(delta):
# Keep the VR player at the global player position
translation = Vector3(PlayerInfo.get_engine_player_position().x, 0, PlayerInfo.get_engine_player_position().z)
16 changes: 9 additions & 7 deletions Perspectives/VR/FirstPersonVR.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=6 format=2]

[ext_resource path="res://Perspectives/VR/FirstPersonVR.gd" type="Script" id=1]
[ext_resource path="res://addons/godot-openvr/scenes/ovr_controller.tscn" type="PackedScene" id=2]
[ext_resource path="res://addons/vr-common/functions/Function_Teleport.tscn" type="PackedScene" id=3]
[ext_resource path="res://Perspectives/VR/ARVROrigin.gd" type="Script" id=2]
[ext_resource path="res://addons/godot-openvr/scenes/ovr_controller.tscn" type="PackedScene" id=3]
[ext_resource path="res://addons/vr-common/functions/Function_Teleport.tscn" type="PackedScene" id=4]

[sub_resource type="GDScript" id=1]
script/source = "extends ARVRController
Expand Down Expand Up @@ -62,19 +63,20 @@ func _process(delta):
script = ExtResource( 1 )
[node name="ARVROrigin" type="ARVROrigin" parent="."]
script = ExtResource( 2 )
[node name="ARVRCamera" type="ARVRCamera" parent="ARVROrigin"]
cull_mask = 119
current = true
far = 50000.0
far = 20000.0
[node name="OVRController" parent="ARVROrigin" instance=ExtResource( 2 )]
[node name="OVRController" parent="ARVROrigin" instance=ExtResource( 3 )]
script = SubResource( 1 )
[node name="Function_Teleport" parent="ARVROrigin/OVRController" instance=ExtResource( 3 )]
[node name="Function_Teleport" parent="ARVROrigin/OVRController" instance=ExtResource( 4 )]
origin = NodePath("../..")
floor_threshold = 0.75
[node name="OVRController2" parent="ARVROrigin" instance=ExtResource( 2 )]
[node name="OVRController2" parent="ARVROrigin" instance=ExtResource( 3 )]
controller_id = 2
script = SubResource( 1 )
4 changes: 2 additions & 2 deletions UI/EnergyUI/EnergyDetails.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ func _ready():

# An update should be called whenever the value changes (new asset spawned, asset removed, etc.)
func _update():
ThreadPool.enqueue_task(ThreadPool.Task.new(self, "_update_threaded", []), 100.0)
ThreadPool.enqueue_task(ThreadPool.Task.new(self, "_update_threaded", []), 30.0)


# Thread the server request
func _update_threaded(data):
for asset_type in assets:
var asset_type_name = assets[asset_type]["name"]
var asset_type_details = ServerConnection.get_json("/assetpos/energy_contribution/" + asset_type + ".json")
var asset_type_details = ServerConnection.get_json("/assetpos/energy_contribution/" + asset_type + ".json", false)

var asset_type_energy = "Current energy value: " + String(asset_type_details["total_energy_contribution"]) + " MW"
var asset_type_amount = "Placed amount: " + String(asset_type_details["number_of_assets"])
Expand Down
1 change: 0 additions & 1 deletion UI/MiniView/UiTeleport.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func _load_pois():
var fixed_pos = [-pois[poi]["location"][0], pois[poi]["location"][1]]
# With Offset.to_engine_coordinates change webmercator to the according in-game coordinates
var location_coordinates = Offset.to_engine_coordinates(fixed_pos)
var test = WorldPosition.get_position_on_ground(Vector3(location_coordinates.x, 0, location_coordinates.y))
# The ID in the list is not necessarily the same as the id in the json-file thus we have to
# set the poi-id in the metadata
poi_list.set_item_metadata(index, location_coordinates)
Expand Down
4 changes: 2 additions & 2 deletions UI/ui_energy.gd
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ func _toggled(button_pressed) -> void:

# An update should be called whenever the value changes (new asset spawned, asset removed, etc.)
func _update():
ThreadPool.enqueue_task(ThreadPool.Task.new(self, "_update_threaded", []), 80.0)
ThreadPool.enqueue_task(ThreadPool.Task.new(self, "_update_threaded", []), 30.0)


# Thread the server request
func _update_threaded(data):
var asset_details = ServerConnection.get_json("/assetpos/energy_contribution/all.json")
var asset_details = ServerConnection.get_json("/assetpos/energy_contribution/all.json", false)
energy_value_label.text = String(asset_details["total_energy_contribution"])
assets_amount_label.text = "Total placed assets: " + String(asset_details["number_of_assets"])

Expand Down
6 changes: 4 additions & 2 deletions Util/Tooltip3D.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=5 format=2]

[ext_resource path="res://Util/Tooltip3D.gd" type="Script" id=1]
[ext_resource path="res://Resources/Images/UI/MapIcons/pv_icon.png" type="Texture" id=2]

[sub_resource type="SpatialMaterial" id=1]
flags_unshaded = true
Expand Down Expand Up @@ -53,6 +54,7 @@ rect_min_size = Vector2( 32, 32 )
[node name="TextureRect" type="TextureRect" parent="Viewport/CenterContainer/PanelContainer/VBoxContainer/MarginContainer"]
margin_right = 52.0
margin_bottom = 32.0
texture = ExtResource( 2 )
expand = true
stretch_mode = 6

Expand All @@ -68,5 +70,5 @@ text = "0.0 kWh"
layers = 64
material_override = SubResource( 1 )
cast_shadow = 0
pixel_size = 0.005
pixel_size = 0.004
texture = SubResource( 2 )
9 changes: 9 additions & 0 deletions World/LODTerrain/Modules/TerrainColliderModule.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@ var collider_subdivision = Settings.get_setting("terrain-collider", "collision-m


func _ready():
connect("visibility_changed", self, "_on_visibility_changed")
tile.thread_task(self, "get_textures", [])


# When this node becomes invisible due to higher LOD terrain being active, disable the collider
func _on_visibility_changed():
if is_visible_in_tree():
col_shape.disabled = true
else:
col_shape.disabled = false


func _on_ready():
if heightmap:
col_shape.shape = create_tile_collision_shape()
Expand Down
38 changes: 19 additions & 19 deletions default-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@

"level-0-tile-size": 9783.93962,
"level-0-osm-zoom": 12,
"default-tile-subdivision": 32,
"default-tile-subdivision": 16,
"update-interval-seconds": 0.2,
"world-shift-distance": 1000,
"tile-spawn-radius": 1,
"tile-spawn-radius": 3,
"tile-removal-check-radius-summand": 2,
"distances": [
10000,
4000,
1000,
500,
5000,
2000,
700,
400,
200,
100,
70,
30
40,
20
],
"module-path": "res://World/LODTerrain/Modules/",
"modules": [
Expand All @@ -36,8 +37,7 @@
["-TerrainModule.tscn", "DetailedTerrainModule.tscn"],
["WaterModule.tscn", "Vegetation/LargeTreeModule.tscn", "Vegetation/SmallTreeModule.tscn"],
["Vegetation/LargeBushModule.tscn", "Vegetation/SmallBushModule.tscn", "StaticAssets/BuildingsModule.tscn"],
["Vegetation/HerbageModule.tscn"]

["Vegetation/HerbageModule.tscn", "-StaticAssets/BuildingsModule.tscn"]
],
"player-bounding-radius": 10000
},
Expand All @@ -47,24 +47,24 @@
},

"item-spawner": {
"camera-ray-length": 2000
"camera-ray-length": 5000
},

"herbage": {
"density-at-lod": {
"3": 0.15,
"4": 0.25,
"5": 0.35,
"6": 0.5,
"7": 0.55,
"8": 0.6
"4": 0.3,
"5": 0.55,
"6": 0.6,
"7": 0.7,
"8": 1.0
},
"density-modifiers-for-layers": {
"1": 2.2,
"2": 1,
"3": 0.7,
"4": 0.33,
"5": 0.25
"2": 0.8,
"3": 0.3,
"4": 0.25,
"5": 0.1
},
"detail-texture-start-distance": 300.0,
"detail-texture-scale": 0.4,
Expand Down

0 comments on commit ae6c6c4

Please sign in to comment.