diff --git a/addons/godotvmf/entities/func_detail.gd b/addons/godotvmf/entities/func_detail.gd index abf8919..0e78298 100644 --- a/addons/godotvmf/entities/func_detail.gd +++ b/addons/godotvmf/entities/func_detail.gd @@ -2,16 +2,19 @@ class_name func_detail extends VMFEntityNode func _entity_setup(entity: VMFEntity): - var mesh = get_mesh(true, false); + var mesh = get_mesh(true, false, Vector3.ZERO); if !mesh or mesh.get_surface_count() == 0: queue_free(); return; - var unwrap_err = mesh.lightmap_unwrap(global_transform, config.import.lightmap_texel_size); - if unwrap_err != OK: - VMFLogger.warn("func_detail %s: lightmap_unwrap failed (%d), skipping UV2" % [entity.id, unwrap_err]); + if config.import.generate_lightmap_uv2: + var unwrap_err = mesh.lightmap_unwrap(global_transform, config.import.lightmap_texel_size); + if unwrap_err != OK: + VMFLogger.warn("func_detail %s: lightmap_unwrap failed (%d), skipping UV2" % [entity.id, unwrap_err]); $MeshInstance3D.cast_shadow = entity.data.get("disableshadows", 0) == 0; $MeshInstance3D.set_mesh(mesh); - $MeshInstance3D/StaticBody3D/CollisionShape3D.shape = $MeshInstance3D.mesh.create_trimesh_shape(); + + if config.import.generate_collision: + $MeshInstance3D/StaticBody3D/CollisionShape3D.shape = $MeshInstance3D.mesh.create_trimesh_shape(); diff --git a/addons/godotvmf/entities/prop_studio.gd b/addons/godotvmf/entities/prop_studio.gd index 81d2f8b..b928756 100644 --- a/addons/godotvmf/entities/prop_studio.gd +++ b/addons/godotvmf/entities/prop_studio.gd @@ -37,7 +37,10 @@ func _entity_setup(_entity: VMFEntity) -> void: VMFLogger.error("Failed to load model scene: " + model_path); return; - var instance := model_scene.instantiate(PackedScene.GEN_EDIT_STATE_MAIN_INHERITED); + var edit_state := 0 if not Engine.is_editor_hint() \ + else PackedScene.GEN_EDIT_STATE_MAIN_INHERITED; + + var instance := model_scene.instantiate(edit_state); instance.name = "model"; instance.scale *= model_scale; diff --git a/addons/godotvmf/godotmdl/mdl_combiner.gd b/addons/godotvmf/godotmdl/mdl_combiner.gd index b28f5dd..47c2228 100644 --- a/addons/godotvmf/godotmdl/mdl_combiner.gd +++ b/addons/godotvmf/godotmdl/mdl_combiner.gd @@ -156,11 +156,11 @@ func create_occluder(): func generate_collision(): var yup_to_zup = Basis().rotated(Vector3.RIGHT, PI / 2); var yup_to_zup_transform = Transform3D(yup_to_zup, Vector3.ZERO); + var static_body: StaticBody3D; var surface_index = 0; for surface in phy.surfaces: var solid_index = 0; - var static_body: StaticBody3D; for solid in surface.solids: # NOTE: Skip the last solid since it's a fullbody collision shape diff --git a/addons/godotvmf/plugin.cfg b/addons/godotvmf/plugin.cfg index bc1d9d2..1320faf 100644 --- a/addons/godotvmf/plugin.cfg +++ b/addons/godotvmf/plugin.cfg @@ -3,5 +3,5 @@ name="GodotVMF" description="Allows use VMF files in Godot" author="H2xDev" -version="2.2.10" +version="2.2.11" script="godotvmf.gd" diff --git a/addons/godotvmf/src/vmf_entity_node.gd b/addons/godotvmf/src/vmf_entity_node.gd index 625bfeb..7022fc0 100644 --- a/addons/godotvmf/src/vmf_entity_node.gd +++ b/addons/godotvmf/src/vmf_entity_node.gd @@ -207,7 +207,7 @@ func trigger_output(output) -> void: emit_signal(output); ## Returns mesh of the entity -func get_mesh(cleanup = true, lods = true) -> ArrayMesh: +func get_mesh(cleanup = true, lods = true, offset: Vector3 = global_position) -> ArrayMesh: if not has_solid: return null; var solids = entity.solid if entity.solid is Array else [entity.solid]; @@ -217,9 +217,9 @@ func get_mesh(cleanup = true, lods = true) -> ArrayMesh: 'world': { 'solid': solids }, }); - var mesh = VMFTool.cleanup_mesh(VMFTool.create_mesh(struct, global_position)) \ + var mesh = VMFTool.cleanup_mesh(VMFTool.create_mesh(struct, offset)) \ if cleanup \ - else VMFTool.create_mesh(struct, global_position); + else VMFTool.create_mesh(struct, offset); if not mesh: return null; diff --git a/addons/godotvmf/src/vmf_node.gd b/addons/godotvmf/src/vmf_node.gd index 9313520..7e023ef 100644 --- a/addons/godotvmf/src/vmf_node.gd +++ b/addons/godotvmf/src/vmf_node.gd @@ -120,8 +120,9 @@ func import_geometry() -> void: geometry_mesh.mesh = mesh; - VMFTool.generate_collisions(geometry_mesh, default_physics_mask); - save_collision_file(); + if VMFConfig.import.generate_collision: + VMFTool.generate_collisions(geometry_mesh, default_physics_mask); + save_collision_file(); if not get_meta("instance", false): generate_navmesh(geometry_mesh);