clean up room collisions
This commit is contained in:
parent
139d9466ff
commit
caa73b5f55
|
@ -6,7 +6,7 @@ const ConstructRoomMesh = preload ("res://lib/utils/mesh/construct_room_mesh.gd"
|
|||
@onready var wall_edges = $Ceiling/WallEdges
|
||||
@onready var wall_mesh: MeshInstance3D = $WallMesh
|
||||
@onready var ceiling_mesh: MeshInstance3D = $CeilingMesh
|
||||
@onready var wall_collisions = $WallCollisions
|
||||
@onready var wall_collision = $WallCollision/CollisionShape3D
|
||||
|
||||
@onready var room_floor = $Floor
|
||||
@onready var room_ceiling = $Ceiling
|
||||
|
@ -60,9 +60,9 @@ static func generate_wall_mesh(room_store: Dictionary):
|
|||
var corners = room_store.corners
|
||||
var height = room_store.height
|
||||
|
||||
return ConstructRoomMesh.generate_wall_mesh_grid(corners, height)
|
||||
return ConstructRoomMesh.generate_wall_mesh(corners, height)
|
||||
|
||||
static func generate_ceiling_mesh(room_store: Dictionary):
|
||||
var corners = room_store.corners
|
||||
|
||||
return ConstructRoomMesh.generate_ceiling_mesh_grid(corners)
|
||||
return ConstructRoomMesh.generate_ceiling_mesh(corners)
|
||||
|
|
|
@ -28,7 +28,11 @@ script = ExtResource("1_ugebq")
|
|||
|
||||
[node name="CeilingMesh" type="MeshInstance3D" parent="."]
|
||||
|
||||
[node name="WallCollisions" type="Node3D" parent="."]
|
||||
[node name="WallCollision" type="StaticBody3D" parent="."]
|
||||
collision_layer = 24
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="WallCollision"]
|
||||
|
||||
[node name="Ceiling" type="StaticBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
|
||||
|
|
|
@ -29,20 +29,12 @@ func _on_enter():
|
|||
floor_shape.shape = room.ceiling_mesh.mesh.create_trimesh_shape()
|
||||
ceiling_shape.shape.backface_collision = true
|
||||
|
||||
var collision = CollisionShape3D.new()
|
||||
collision.shape = room.wall_mesh.mesh.create_trimesh_shape()
|
||||
|
||||
var static_body = StaticBody3D.new()
|
||||
static_body.set_collision_layer_value(4, true)
|
||||
static_body.set_collision_layer_value(5, true)
|
||||
static_body.collision_mask = 0
|
||||
static_body.add_child(collision)
|
||||
room.wall_collisions.add_child(static_body)
|
||||
var wall_collisions = room.wall_mesh.mesh.create_trimesh_shape()
|
||||
wall_collisions.backface_collision = true
|
||||
room.wall_collision.shape = wall_collisions
|
||||
|
||||
func _on_leave():
|
||||
room.room_ceiling.get_node("CollisionShape3D").disabled = true
|
||||
room.room_floor.get_node("CollisionShape3D").disabled = true
|
||||
|
||||
for collision in room.wall_collisions.get_children():
|
||||
collision.queue_free()
|
||||
await collision.tree_exited
|
||||
room.wall_collision.shape = null
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
extends Node3D
|
||||
|
||||
const Room = preload ("res://content/system/house/room/room.tscn")
|
||||
const RoomType = preload ("res://content/system/house/room/room.gd")
|
||||
const ConstructRoomMesh = preload ("res://lib/utils/mesh/construct_room_mesh.gd")
|
||||
|
||||
const material_selected = preload ("../room_selected.tres")
|
||||
const material_unselected = preload ("../room_unselected.tres")
|
||||
|
@ -128,7 +128,7 @@ func _generate_room_map():
|
|||
current_max.y = max(current_max.y, corner.y)
|
||||
|
||||
for room in rooms:
|
||||
var mesh = RoomType.generate_ceiling_mesh(room)
|
||||
var mesh = ConstructRoomMesh.generate_ceiling_mesh(room.corners)
|
||||
|
||||
if mesh == null:
|
||||
continue
|
||||
|
|
|
@ -10,13 +10,13 @@ static func generate_wall_mesh(corners, height):
|
|||
for corner in corners:
|
||||
var corner3D = Vector3(corner.x, 0, corner.y)
|
||||
|
||||
st.add_vertex(corner3D)
|
||||
st.add_vertex(corner3D + wall_up)
|
||||
st.add_vertex(corner3D)
|
||||
|
||||
var first_corner = Vector3(corners[0].x, 0, corners[0].y)
|
||||
|
||||
st.add_vertex(first_corner)
|
||||
st.add_vertex(first_corner + wall_up)
|
||||
st.add_vertex(first_corner)
|
||||
|
||||
st.index()
|
||||
st.generate_normals()
|
||||
|
@ -205,4 +205,4 @@ static func _create_mesh(points: PackedVector2Array, triangles: PackedInt32Array
|
|||
|
||||
var mesh = st.commit()
|
||||
|
||||
return mesh
|
||||
return mesh
|
||||
|
|
Loading…
Reference in New Issue
Block a user