1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-19 01:29:49 +00:00

3D object optimizations

This commit is contained in:
Emmanouil Papadeas 2023-04-02 01:36:02 +03:00
parent 4943ab5eab
commit 8ce68700dd
2 changed files with 15 additions and 10 deletions

View file

@ -118,19 +118,22 @@ func _scene_property_changed() -> void: # Called by undo/redo
func _add_object_node(id: int) -> void:
if not object_properties.has(id):
print("Object id not found.")
return
var node3d := Cel3DObject.new()
node3d.id = id
node3d.cel = self
parent_node.add_child(node3d)
node3d.type = object_properties[id]["type"]
if object_properties.has(id):
if object_properties[id].has("id"):
node3d.deserialize(object_properties[id])
else:
if object_properties[id].has("transform"):
node3d.transform = object_properties[id]["transform"]
if object_properties[id].has("file_path"):
node3d.file_path = object_properties[id]["file_path"]
if object_properties[id].has("id"):
node3d.deserialize(object_properties[id])
else:
if object_properties[id].has("transform"):
node3d.transform = object_properties[id]["transform"]
if object_properties[id].has("file_path"):
node3d.file_path = object_properties[id]["file_path"]
if object_properties[id].has("type"):
node3d.type = object_properties[id]["type"]
object_properties[id] = node3d.serialize()
emit_signal("objects_changed")

View file

@ -107,10 +107,10 @@ func serialize() -> Dictionary:
func deserialize(dict: Dictionary) -> void:
id = dict["id"]
file_path = dict["file_path"]
self.type = dict["type"]
transform = dict["transform"]
visible = dict["visible"]
self.file_path = dict["file_path"]
if _is_mesh():
var mesh: Mesh = node3d_type.mesh
match type:
@ -164,6 +164,8 @@ func _is_mesh() -> bool:
func _set_type(value: int) -> void:
if type == value and is_instance_valid(node3d_type): # No reason to set the same type twice
return
type = value
if is_instance_valid(node3d_type):
node3d_type.queue_free()