Implemented a different outline for the edge select mode.

This commit is contained in:
Relintai 2021-12-31 08:41:25 +01:00
parent 2067291890
commit 4303e94617
2 changed files with 52 additions and 12 deletions

View File

@ -121,6 +121,12 @@ func redraw():
var material = get_plugin().get_material("main", self) var material = get_plugin().get_material("main", self)
_mesh_outline_generator.setup(_mdr) _mesh_outline_generator.setup(_mdr)
if selection_mode == SelectionMode.SELECTION_MODE_EDGE:
_mesh_outline_generator.generate_mark_edges()
else:
_mesh_outline_generator.generate()
add_lines(_mesh_outline_generator.lines, material, false) add_lines(_mesh_outline_generator.lines, material, false)
if _selected_points.size() > 0: if _selected_points.size() > 0:

View File

@ -8,9 +8,7 @@ var lines : PoolVector3Array
func setup(mdr : MeshDataResource) -> void: func setup(mdr : MeshDataResource) -> void:
_mdr = mdr _mdr = mdr
refresh() func generate():
func refresh():
lines.resize(0) lines.resize(0)
if !_mdr: if !_mdr:
@ -31,13 +29,49 @@ func refresh():
return return
if indices.size() % 3 == 0: if indices.size() % 3 == 0:
for i in range(0, len(indices), 3): for i in range(0, indices.size(), 3):
lines.append(vertices[indices[i]]) for j in range(3):
lines.append(vertices[indices[i + 1]]) lines.append(vertices[indices[i + j]])
lines.append(vertices[indices[i + ((j + 1) % 3)]])
lines.append(vertices[indices[i + 1]]) func generate_mark_edges():
lines.append(vertices[indices[i + 2]]) lines.resize(0)
lines.append(vertices[indices[i + 2]]) if !_mdr:
lines.append(vertices[indices[i]]) return
if _mdr.array.size() != ArrayMesh.ARRAY_MAX:
return
if _mdr.array[ArrayMesh.ARRAY_VERTEX] == null || _mdr.array[ArrayMesh.ARRAY_INDEX] == null:
return
var arr : Array = _mdr.array
var vertices : PoolVector3Array = arr[ArrayMesh.ARRAY_VERTEX]
var indices : PoolIntArray = arr[ArrayMesh.ARRAY_INDEX]
if vertices.size() == 0:
return
if indices.size() % 3 == 0:
for i in range(0, indices.size(), 3):
for j in range(3):
var i0 : int = indices[i + j]
var i1 : int = indices[i + ((j + 1) % 3)]
var v0 : Vector3 = vertices[i0]
var v1 : Vector3 = vertices[i1]
lines.append(v0)
lines.append(v1)
var pmid : Vector3 = lerp(v0, v1, 0.5)
var l : float = (v0 - v1).length() / 20.0
lines.append(pmid + Vector3(l, 0, 0))
lines.append(pmid + Vector3(-l, 0, 0))
lines.append(pmid + Vector3(0, 0, l))
lines.append(pmid + Vector3(0, 0, -l))
lines.append(pmid + Vector3(0, l, 0))
lines.append(pmid + Vector3(0, -l, 0))