Skip to content

Commit 8e69b66

Browse files
authored
Patch v2.2.11 (#96)
* func_detail: Fix mesh offset when the VMFNode's position is not ZERO * prop_studio: Disable gen edit state for runtime mode * Bump v2.2.11 * VMF: Fix `Generate Collision` option support (#97) * func_detail: Disable lightmap uv2 generator in case it's disabled in config (#98)
1 parent 23329bc commit 8e69b66

6 files changed

Lines changed: 20 additions & 13 deletions

File tree

addons/godotvmf/entities/func_detail.gd

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
class_name func_detail extends VMFEntityNode
33

44
func _entity_setup(entity: VMFEntity):
5-
var mesh = get_mesh(true, false);
5+
var mesh = get_mesh(true, false, Vector3.ZERO);
66

77
if !mesh or mesh.get_surface_count() == 0:
88
queue_free();
99
return;
1010

11-
var unwrap_err = mesh.lightmap_unwrap(global_transform, config.import.lightmap_texel_size);
12-
if unwrap_err != OK:
13-
VMFLogger.warn("func_detail %s: lightmap_unwrap failed (%d), skipping UV2" % [entity.id, unwrap_err]);
11+
if config.import.generate_lightmap_uv2:
12+
var unwrap_err = mesh.lightmap_unwrap(global_transform, config.import.lightmap_texel_size);
13+
if unwrap_err != OK:
14+
VMFLogger.warn("func_detail %s: lightmap_unwrap failed (%d), skipping UV2" % [entity.id, unwrap_err]);
1415

1516
$MeshInstance3D.cast_shadow = entity.data.get("disableshadows", 0) == 0;
1617
$MeshInstance3D.set_mesh(mesh);
17-
$MeshInstance3D/StaticBody3D/CollisionShape3D.shape = $MeshInstance3D.mesh.create_trimesh_shape();
18+
19+
if config.import.generate_collision:
20+
$MeshInstance3D/StaticBody3D/CollisionShape3D.shape = $MeshInstance3D.mesh.create_trimesh_shape();

addons/godotvmf/entities/prop_studio.gd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ func _entity_setup(_entity: VMFEntity) -> void:
3737
VMFLogger.error("Failed to load model scene: " + model_path);
3838
return;
3939

40-
var instance := model_scene.instantiate(PackedScene.GEN_EDIT_STATE_MAIN_INHERITED);
40+
var edit_state := 0 if not Engine.is_editor_hint() \
41+
else PackedScene.GEN_EDIT_STATE_MAIN_INHERITED;
42+
43+
var instance := model_scene.instantiate(edit_state);
4144
instance.name = "model";
4245
instance.scale *= model_scale;
4346

addons/godotvmf/godotmdl/mdl_combiner.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ func create_occluder():
156156
func generate_collision():
157157
var yup_to_zup = Basis().rotated(Vector3.RIGHT, PI / 2);
158158
var yup_to_zup_transform = Transform3D(yup_to_zup, Vector3.ZERO);
159+
var static_body: StaticBody3D;
159160

160161
var surface_index = 0;
161162
for surface in phy.surfaces:
162163
var solid_index = 0;
163-
var static_body: StaticBody3D;
164164

165165
for solid in surface.solids:
166166
# NOTE: Skip the last solid since it's a fullbody collision shape

addons/godotvmf/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="GodotVMF"
44
description="Allows use VMF files in Godot"
55
author="H2xDev"
6-
version="2.2.10"
6+
version="2.2.11"
77
script="godotvmf.gd"

addons/godotvmf/src/vmf_entity_node.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func trigger_output(output) -> void:
207207
emit_signal(output);
208208

209209
## Returns mesh of the entity
210-
func get_mesh(cleanup = true, lods = true) -> ArrayMesh:
210+
func get_mesh(cleanup = true, lods = true, offset: Vector3 = global_position) -> ArrayMesh:
211211
if not has_solid: return null;
212212

213213
var solids = entity.solid if entity.solid is Array else [entity.solid];
@@ -217,9 +217,9 @@ func get_mesh(cleanup = true, lods = true) -> ArrayMesh:
217217
'world': { 'solid': solids },
218218
});
219219

220-
var mesh = VMFTool.cleanup_mesh(VMFTool.create_mesh(struct, global_position)) \
220+
var mesh = VMFTool.cleanup_mesh(VMFTool.create_mesh(struct, offset)) \
221221
if cleanup \
222-
else VMFTool.create_mesh(struct, global_position);
222+
else VMFTool.create_mesh(struct, offset);
223223

224224
if not mesh: return null;
225225

addons/godotvmf/src/vmf_node.gd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ func import_geometry() -> void:
120120

121121
geometry_mesh.mesh = mesh;
122122

123-
VMFTool.generate_collisions(geometry_mesh, default_physics_mask);
124-
save_collision_file();
123+
if VMFConfig.import.generate_collision:
124+
VMFTool.generate_collisions(geometry_mesh, default_physics_mask);
125+
save_collision_file();
125126

126127
if not get_meta("instance", false):
127128
generate_navmesh(geometry_mesh);

0 commit comments

Comments
 (0)