mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Implemented outline for face selection. (Face selection itself is not yet implemented though.)
This commit is contained in:
parent
6733787c46
commit
6629fa503c
@ -124,6 +124,8 @@ func redraw():
|
||||
|
||||
if selection_mode == SelectionMode.SELECTION_MODE_EDGE:
|
||||
_mesh_outline_generator.generate_mark_edges()
|
||||
elif selection_mode == SelectionMode.SELECTION_MODE_FACE:
|
||||
_mesh_outline_generator.generate_mark_faces()
|
||||
else:
|
||||
_mesh_outline_generator.generate()
|
||||
|
||||
|
@ -75,3 +75,51 @@ func generate_mark_edges():
|
||||
lines.append(pmid + Vector3(0, 0, -l))
|
||||
lines.append(pmid + Vector3(0, l, 0))
|
||||
lines.append(pmid + Vector3(0, -l, 0))
|
||||
|
||||
func generate_mark_faces():
|
||||
lines.resize(0)
|
||||
|
||||
if !_mdr:
|
||||
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:
|
||||
return
|
||||
|
||||
for i in range(0, indices.size(), 3):
|
||||
for j in range(3):
|
||||
lines.append(vertices[indices[i + j]])
|
||||
lines.append(vertices[indices[i + ((j + 1) % 3)]])
|
||||
|
||||
for i in range(0, indices.size(), 3):
|
||||
var i0 : int = indices[i + 0]
|
||||
var i1 : int = indices[i + 1]
|
||||
var i2 : int = indices[i + 2]
|
||||
|
||||
var v0 : Vector3 = vertices[i0]
|
||||
var v1 : Vector3 = vertices[i1]
|
||||
var v2 : Vector3 = vertices[i2]
|
||||
|
||||
var pmid : Vector3 = v0 + v1 + v2
|
||||
pmid /= 3
|
||||
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))
|
||||
|
Loading…
Reference in New Issue
Block a user