Interior Maps #13

Merged
kayomn merged 30 commits from interior-maps into main 2023-02-01 01:16:16 +01:00
2 changed files with 22 additions and 11 deletions
Showing only changes of commit 8d014d69a9 - Show all commits

View File

@ -41,9 +41,9 @@ class Chunk:
##
func invalidate(interior_map: InteriorMap, coordinate: Vector2i) -> void:
# TODO: Once this is all lowered into native code, look for ways to parallelize the loops.
for multimesh_instance in _multimesh_instances:
RenderingServer.free_rid(multimesh_instance._instance_rid)
RenderingServer.free_rid(multimesh_instance._multimesh_rid)
for multi_mesh_instance in _multimesh_instances:
RenderingServer.free_rid(multi_mesh_instance._instance_rid)
RenderingServer.free_rid(multi_mesh_instance._multimesh_rid)
_multimesh_instances.clear()
@ -85,11 +85,11 @@ class Chunk:
var global_transform := interior_map.global_transform
for chunk_mesh in transforms_by_mesh:
var multimesh_instance := MultiMeshInstance.new(
var multi_mesh_instance := MultiMeshInstance.new(
scenario_rid, chunk_mesh.get_rid(), transforms_by_mesh[chunk_mesh])
multimesh_instance.set_offset(global_transform)
_multimesh_instances.append(multimesh_instance)
multi_mesh_instance.set_offset(global_transform)
_multimesh_instances.append(multi_mesh_instance)
##
## Sets the floor mesh in the chunk at the location relative [code]coordinatess[/code] to
@ -140,11 +140,17 @@ class MultiMeshInstance:
RenderingServer.multimesh_instance_set_transform(_multimesh_rid, i, transforms[i])
##
## Sets the parent transform of all mesh instances under it to [code]offset[/code].
## Sets the transform of the instance to [code]offset[/code].
##
func set_offset(offset: Transform3D) -> void:
RenderingServer.instance_set_transform(_instance_rid, offset)
##
## Sets the visibility of the instance to [code]is_visible[/code].
##
func set_visible(is_visible: bool) -> void:
RenderingServer.instance_set_visible(_instance_rid, is_visible)
var _chunks: Array[Chunk] = []
var _chunks_size := Vector2i.ZERO
@ -172,8 +178,13 @@ func _notification(what: int) -> void:
match what:
NOTIFICATION_TRANSFORM_CHANGED:
for chunk in _chunks:
for multimesh_instance in chunk._multimesh_instances:
multimesh_instance.set_offset_transform(global_transform)
for multi_mesh_instance in chunk._multimesh_instances:
multi_mesh_instance.set_offset_transform(global_transform)
kayomn marked this conversation as resolved Outdated

Doc comment does not mention purpose of orientation.

Doc comment does not mention purpose of `orientation`.
NOTIFICATION_VISIBILITY_CHANGED:
for chunk in _chunks:
for multi_mesh_instance in chunk._multimesh_instances:
multi_mesh_instance.set_visible(visible)
##
## Clears the entirety of the tile grid to only contain tiles of instance [code]tile[/code] pointing

BIN
map_editor.scn (Stored with Git LFS)

Binary file not shown.