mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-21 13:16:49 +01:00
Implemented generating handle points.
This commit is contained in:
parent
e7110b5314
commit
ec0b477291
@ -21,8 +21,6 @@ func create_gizmo(spatial):
|
|||||||
|
|
||||||
gizmo.set_spatial_node(spatial)
|
gizmo.set_spatial_node(spatial)
|
||||||
gizmo.setup()
|
gizmo.setup()
|
||||||
|
|
||||||
#gizmo.plugin = plugin
|
|
||||||
plugin.register_gizmo(gizmo)
|
plugin.register_gizmo(gizmo)
|
||||||
|
|
||||||
return gizmo
|
return gizmo
|
||||||
|
@ -26,7 +26,6 @@ enum SelectionMode {
|
|||||||
var gizmo_size = 3.0
|
var gizmo_size = 3.0
|
||||||
|
|
||||||
var vertices : PoolVector3Array
|
var vertices : PoolVector3Array
|
||||||
var indices : PoolIntArray
|
|
||||||
|
|
||||||
var handle_points : PoolVector3Array
|
var handle_points : PoolVector3Array
|
||||||
var handle_to_vertex_map : Array
|
var handle_to_vertex_map : Array
|
||||||
@ -75,8 +74,9 @@ func set_handle(index: int, camera: Camera, point: Vector2):
|
|||||||
|
|
||||||
add_to_all_selected(ofs)
|
add_to_all_selected(ofs)
|
||||||
|
|
||||||
redraw()
|
recalculate_handle_points()
|
||||||
apply()
|
apply()
|
||||||
|
redraw()
|
||||||
elif edit_mode == EditMode.EDIT_MODE_SCALE:
|
elif edit_mode == EditMode.EDIT_MODE_SCALE:
|
||||||
var r : float = 1.0 + ((relative.x + relative.y) * 0.05)
|
var r : float = 1.0 + ((relative.x + relative.y) * 0.05)
|
||||||
|
|
||||||
@ -95,8 +95,9 @@ func set_handle(index: int, camera: Camera, point: Vector2):
|
|||||||
|
|
||||||
mul_all_selected_with_basis(b)
|
mul_all_selected_with_basis(b)
|
||||||
|
|
||||||
redraw()
|
recalculate_handle_points()
|
||||||
apply()
|
apply()
|
||||||
|
redraw()
|
||||||
elif edit_mode == EditMode.EDIT_MODE_ROTATE:
|
elif edit_mode == EditMode.EDIT_MODE_ROTATE:
|
||||||
print("MDR Editor: ROTATE NYI")
|
print("MDR Editor: ROTATE NYI")
|
||||||
|
|
||||||
@ -141,7 +142,6 @@ func apply() -> void:
|
|||||||
arrs[ArrayMesh.ARRAY_VERTEX] = vertices
|
arrs[ArrayMesh.ARRAY_VERTEX] = vertices
|
||||||
_mdr.array = arrs
|
_mdr.array = arrs
|
||||||
|
|
||||||
|
|
||||||
func forward_spatial_gui_input(index, camera, event):
|
func forward_spatial_gui_input(index, camera, event):
|
||||||
if event is InputEventMouseButton:
|
if event is InputEventMouseButton:
|
||||||
var gt : Transform = get_spatial_node().global_transform
|
var gt : Transform = get_spatial_node().global_transform
|
||||||
@ -281,6 +281,25 @@ func _notification(what):
|
|||||||
if get_plugin():
|
if get_plugin():
|
||||||
get_plugin().unregister_gizmo(self)
|
get_plugin().unregister_gizmo(self)
|
||||||
|
|
||||||
|
#todo if selection type changed recalc handles aswell
|
||||||
|
#add method recalc handles -> check for type
|
||||||
|
func recalculate_handle_points() -> void:
|
||||||
|
if !_mdr:
|
||||||
|
handle_points.resize(0)
|
||||||
|
handle_to_vertex_map.resize(0)
|
||||||
|
|
||||||
|
var merged_arrays : Array = MeshUtils.merge_mesh_array(_mdr.array)
|
||||||
|
handle_points = merged_arrays[ArrayMesh.ARRAY_VERTEX]
|
||||||
|
|
||||||
|
if selection_mode == SelectionMode.SELECTION_MODE_VERTEX:
|
||||||
|
handle_to_vertex_map = MeshDecompose.get_handle_vertex_to_vertex_map(_mdr.array, handle_points)
|
||||||
|
elif selection_mode == SelectionMode.SELECTION_MODE_EDGE:
|
||||||
|
#todo
|
||||||
|
handle_to_vertex_map = MeshDecompose.get_handle_vertex_to_vertex_map(_mdr.array, handle_points)
|
||||||
|
elif selection_mode == SelectionMode.SELECTION_MODE_FACE:
|
||||||
|
#todo
|
||||||
|
handle_to_vertex_map = MeshDecompose.get_handle_vertex_to_vertex_map(_mdr.array, handle_points)
|
||||||
|
|
||||||
func on_mesh_data_resource_changed(mdr : MeshDataResource) -> void:
|
func on_mesh_data_resource_changed(mdr : MeshDataResource) -> void:
|
||||||
_mdr = mdr
|
_mdr = mdr
|
||||||
|
|
||||||
@ -289,9 +308,5 @@ func on_mesh_data_resource_changed(mdr : MeshDataResource) -> void:
|
|||||||
else:
|
else:
|
||||||
vertices.resize(0)
|
vertices.resize(0)
|
||||||
|
|
||||||
#recalc handle points
|
recalculate_handle_points()
|
||||||
|
|
||||||
#if selection type changed recalc handles aswell
|
|
||||||
#add method recalc handles -> check for type
|
|
||||||
|
|
||||||
redraw()
|
redraw()
|
||||||
|
@ -5,9 +5,31 @@ extends Object
|
|||||||
|
|
||||||
static func get_handle_vertex_to_vertex_map(arrays : Array, handle_points : PoolVector3Array) -> Array:
|
static func get_handle_vertex_to_vertex_map(arrays : Array, handle_points : PoolVector3Array) -> Array:
|
||||||
var handle_to_vertex_map : Array
|
var handle_to_vertex_map : Array
|
||||||
|
handle_to_vertex_map.resize(handle_points.size())
|
||||||
|
|
||||||
#foreach handle points
|
if handle_points.size() == 0:
|
||||||
#get all equal approx vertex and put it into the map
|
return handle_to_vertex_map
|
||||||
|
|
||||||
|
if arrays.size() != ArrayMesh.ARRAY_MAX || arrays[ArrayMesh.ARRAY_INDEX] == null:
|
||||||
|
return handle_to_vertex_map
|
||||||
|
|
||||||
|
var vertices : PoolVector3Array = arrays[ArrayMesh.ARRAY_VERTEX]
|
||||||
|
|
||||||
|
if vertices.size() == 0:
|
||||||
|
return handle_to_vertex_map
|
||||||
|
|
||||||
|
for i in range(handle_points.size()):
|
||||||
|
var hv : Vector3 = handle_points[i]
|
||||||
|
var iarr : PoolIntArray = PoolIntArray()
|
||||||
|
|
||||||
|
#find all verts that have the same position as the handle
|
||||||
|
for j in range(vertices.size()):
|
||||||
|
var vn : Vector3 = vertices[j]
|
||||||
|
|
||||||
|
if is_equal_approx(hv.x, vn.x) && is_equal_approx(hv.y, vn.y) && is_equal_approx(hv.z, vn.z):
|
||||||
|
iarr.append(j)
|
||||||
|
|
||||||
|
handle_to_vertex_map[i] = iarr
|
||||||
|
|
||||||
return handle_to_vertex_map
|
return handle_to_vertex_map
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user