Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions addons/godotvmf/entities/func_detail.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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();
5 changes: 4 additions & 1 deletion addons/godotvmf/entities/prop_studio.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion addons/godotvmf/godotmdl/mdl_combiner.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion addons/godotvmf/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
6 changes: 3 additions & 3 deletions addons/godotvmf/src/vmf_entity_node.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions addons/godotvmf/src/vmf_node.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading