Skip to content

Commit

Permalink
MeshAddAction: Tracking Vertices axis information
Browse files Browse the repository at this point in the history
  • Loading branch information
r888800009 committed Sep 24, 2024
1 parent fe3ced0 commit 419c5db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion source/creator/actions/mesh.d
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ abstract class MeshAction : LazyBoundAction {

class MeshAddAction : MeshAction {
MeshVertex*[] vertices;
MeshVertex*[][4] axisVertices;

this(string name, IncMeshEditorOne editor, IncMesh mesh, void delegate() update = null) {
super(name, editor, mesh, update);
}

void addVertex(MeshVertex* vertex) {
void addVertex(MeshVertex* vertex, int axis = 0) {
vertices ~= vertex;
mesh.vertices ~= vertex;
axisVertices[axis] ~= vertex;
dirty = true;
}

Expand All @@ -96,6 +98,9 @@ class MeshAddAction : MeshAction {
override
void clear() {
vertices.length = 0;
foreach (v; axisVertices) {
v.length = 0;
}
super.clear();
}

Expand Down
4 changes: 2 additions & 2 deletions source/creator/viewport/common/mesheditor/tools/point.d
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class PointTool : NodeSelect {
} else {
impl.foreachMirror((uint axis) {
vertex = new MeshVertex(impl.mirror(axis, impl.mousePos));
action.addVertex(vertex);
action.addVertex(vertex, axis);
});
}
impl.refreshMesh();
Expand All @@ -169,7 +169,7 @@ class PointTool : NodeSelect {
auto lastAddAction = incActionFindLast!MeshAddAction(3);
if (lastAddAction is null || lastAddAction.vertices.length == 0) return;

auto prevVertexIdx = impl.getVertexFromPoint(lastAddAction.vertices[$ - 1].position);
auto prevVertexIdx = impl.getVertexFromPoint(lastAddAction.axisVertices[0][$ - 1].position);
auto prevVertex = impl.getVerticesByIndex([prevVertexIdx])[0];
if (prevVertex == null) return;
auto action = new MeshConnectAction(impl.getTarget().name, impl, mesh);
Expand Down

0 comments on commit 419c5db

Please sign in to comment.