From 0966f90f08bf2519ce862981f28877442356081b Mon Sep 17 00:00:00 2001 From: Nemrav <> Date: Sun, 17 Nov 2024 18:10:40 -0400 Subject: update sim for billboards --- extension/deps/openvic-simulation | 2 +- .../singletons/MapItemSingleton.cpp | 5 +++- game/src/Game/GameSession/BillboardManager.gd | 28 ++++++---------------- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation index cb1b56b..e15bbf9 160000 --- a/extension/deps/openvic-simulation +++ b/extension/deps/openvic-simulation @@ -1 +1 @@ -Subproject commit cb1b56b0146d32c881abd48f53e85f7cf8283bef +Subproject commit e15bbf98879e797bf9161e0cb2a6b3a3cdf35df1 diff --git a/extension/src/openvic-extension/singletons/MapItemSingleton.cpp b/extension/src/openvic-extension/singletons/MapItemSingleton.cpp index d62e0fd..5b2127b 100644 --- a/extension/src/openvic-extension/singletons/MapItemSingleton.cpp +++ b/extension/src/openvic-extension/singletons/MapItemSingleton.cpp @@ -122,6 +122,7 @@ TypedArray MapItemSingleton::get_billboards(){ return ret; } +//dont use this, it includes water provinces int MapItemSingleton::get_province_count(){ GameSingleton const* game_singleton = GameSingleton::get_singleton(); ERR_FAIL_NULL_V(game_singleton, 0); @@ -143,8 +144,10 @@ PackedVector2Array MapItemSingleton::get_province_positions(){ Logger::info("prov_count ", prov_count); for(int i = 0; i < prov_count; i++){ + //i+1 because the province indices are 1 based (0 causes an error) ProvinceDefinition const* prov = game_singleton->get_definition_manager() .get_map_definition().get_province_definition_by_index(i+1); + if(prov->is_water()) continue; //billboards dont appear over water, skip fvec2_t city_pos = prov->get_city_position(); Vector2 pos = Utilities::to_godot_fvec2(city_pos) / game_singleton->get_map_dims(); @@ -155,6 +158,6 @@ PackedVector2Array MapItemSingleton::get_province_positions(){ //province_dict[position_key] = Utilities::to_godot_fvec2(province.get_text_position()) / get_map_dims(); } - + return billboard_pos; } \ No newline at end of file diff --git a/game/src/Game/GameSession/BillboardManager.gd b/game/src/Game/GameSession/BillboardManager.gd index ac1610b..298d3a8 100644 --- a/game/src/Game/GameSession/BillboardManager.gd +++ b/game/src/Game/GameSession/BillboardManager.gd @@ -47,32 +47,18 @@ func _ready(): multimesh.mesh.surface_set_material(0,material) - # Need to have one instance for every province - # need to get a list of province centers - #GameSingleton.get_mapmode_identifier(0) - #GameSingleton.get_mapmode_count() - - var positions_len = MapItemSingleton.get_province_count() - - - print(positions_len) - # Then resize (otherwise, changing the format is not allowed). - multimesh.instance_count = positions_len - multimesh.visible_instance_count = positions_len - print("===============") var positions = MapItemSingleton.get_province_positions() - print("===============") + + # Then resize (otherwise, changing the format is not allowed). + multimesh.instance_count = positions.size() + multimesh.visible_instance_count = positions.size() + var map_positions : PackedVector3Array = PackedVector3Array() for pos_in in positions: - var pos = _map_view._map_to_world_coords(pos_in)# + Vector3(0, 0.5 * SCALE_FACTOR, 0) + var pos = _map_view._map_to_world_coords(pos_in) map_positions.push_back(pos) - #print(positions) - #print(positions.size()) - # Set the transform of the instances. - #model.set_position( - #_map_view._map_to_world_coords(unit_dict[position_key]) - # + Vector3(0, 0.1 * MODEL_SCALE, 0)) + for i in multimesh.visible_instance_count: multimesh.set_instance_transform(i, Transform3D(Basis(), map_positions[i] -- cgit v1.2.3-56-ga3b1