Skip to content

Commit

Permalink
Fixed issue #490.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsschmidt1337 committed Dec 31, 2016
1 parent 486f02e commit 29fabef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
28 changes: 15 additions & 13 deletions src/org/nschmidt/ldparteditor/data/Unrectifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
public enum Unrectifier {
INSTANCE;

public static void splitAllIntoTriangles(StyledText st, DatFile fileNameObj) {
public static void splitAllIntoTriangles(StyledText st, DatFile fileNameObj, boolean splitQuads) {

// Backup selection range
final int x = st.getSelectionRange().x;
Expand Down Expand Up @@ -69,22 +69,24 @@ public static void splitAllIntoTriangles(StyledText st, DatFile fileNameObj) {
VertexManager vm = fileNameObj.getVertexManager();
vm.clearSelection();

HashSet<GData4> selectedQuads = new HashSet<GData4>();
if (splitQuads) {
HashSet<GData4> selectedQuads = new HashSet<GData4>();

data2draw = fileNameObj.getDrawChainStart();
while ((data2draw = data2draw.getNext()) != null) {
switch (data2draw.type()) {
case 4:
selectedQuads.add((GData4) data2draw);
break;
default:
data2draw = fileNameObj.getDrawChainStart();
while ((data2draw = data2draw.getNext()) != null) {
switch (data2draw.type()) {
case 4:
selectedQuads.add((GData4) data2draw);
break;
default:
}
}
}

vm.getSelectedQuads().addAll(selectedQuads);
vm.getSelectedData().addAll(selectedQuads);
vm.getSelectedQuads().addAll(selectedQuads);
vm.getSelectedData().addAll(selectedQuads);

vm.splitQuads(false);
vm.splitQuads(false);
}

if (vm.isModified()) {
st.setText(fileNameObj.getText());
Expand Down
4 changes: 2 additions & 2 deletions src/org/nschmidt/ldparteditor/i18n/TextEditor.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ SyncEdit = Single Vertex Modification is ON (press ESC to cancel)
SyncEditButton = Single Vertex Modification ("SyncEdit")
SyncEditDeactivated = Single Vertex Modification is OFF
Texmap = Toggle TEXMAP
Unrectify = 'Unrectifier': Split all Quads and rect*.dat-Primitives into Triangles
Unrectify = 'Unrectifier': Split all Quads and rect*.dat-Primitives into Triangles\n(Press Ctrl to split primitives only)
Warning = warning
Warnings = warnings
Warnings = warnings
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,13 @@ public void widgetSelected(SelectionEvent e) {
}
NLogger.debug(getClass(), "Unrectify.."); //$NON-NLS-1$
final StyledText st = selection.getTextComposite();
Unrectifier.splitAllIntoTriangles(st, selection.getState().getFileNameObj());
if ((e.stateMask & SWT.CTRL) == SWT.CTRL) {
// Don't split quads
Unrectifier.splitAllIntoTriangles(st, selection.getState().getFileNameObj(), false);
} else {
// Split quads AND rect primitives
Unrectifier.splitAllIntoTriangles(st, selection.getState().getFileNameObj(), true);
}
st.forceFocus();
}
}
Expand Down

0 comments on commit 29fabef

Please sign in to comment.